mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 19:50:43 +00:00
32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { ResolvedMemoryWikiConfig } from "./config.js";
|
|
import { createWikiApplyTool } from "./tool.js";
|
|
|
|
function asSchemaObject(value: unknown): Record<string, unknown> {
|
|
expect(typeof value).toBe("object");
|
|
expect(value).not.toBeNull();
|
|
expect(Array.isArray(value)).toBe(false);
|
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
throw new Error("Expected JSON schema object");
|
|
}
|
|
return value as Record<string, unknown>;
|
|
}
|
|
|
|
describe("memory-wiki tools", () => {
|
|
it("allows provenance metadata in wiki_apply claim evidence", () => {
|
|
const tool = createWikiApplyTool({} as ResolvedMemoryWikiConfig);
|
|
const applyProperties = asSchemaObject(asSchemaObject(tool.parameters).properties);
|
|
const claimsSchema = asSchemaObject(applyProperties.claims);
|
|
const claimSchema = asSchemaObject(claimsSchema.items);
|
|
const claimProperties = asSchemaObject(claimSchema.properties);
|
|
const evidenceSchema = asSchemaObject(claimProperties.evidence);
|
|
const evidenceArraySchema = asSchemaObject(evidenceSchema.items);
|
|
const evidenceProperties = asSchemaObject(evidenceArraySchema.properties);
|
|
|
|
expect(Object.keys(evidenceProperties)).toEqual(
|
|
expect.arrayContaining(["kind", "confidence", "privacyTier"]),
|
|
);
|
|
expect(evidenceProperties.confidence).toMatchObject({ minimum: 0, maximum: 1 });
|
|
});
|
|
});
|