mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-19 20:44:45 +00:00
37 lines
1.4 KiB
TypeScript
37 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> {
|
|
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).toSorted()).toEqual([
|
|
"confidence",
|
|
"kind",
|
|
"lines",
|
|
"note",
|
|
"path",
|
|
"privacyTier",
|
|
"sourceId",
|
|
"updatedAt",
|
|
"weight",
|
|
]);
|
|
expect(evidenceProperties.confidence).toEqual({ type: "number", minimum: 0, maximum: 1 });
|
|
});
|
|
});
|