mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 07:30:42 +00:00
Summary: - The PR threads the embedded run's trusted requester agent id into plugin tool context and memory-core tool availability/execution, adds regression tests, and records an Active Memory changelog fix. - Reproducibility: yes. Current main shows Active Memory passing a synthetic `:active-memory:` session key plu ... ently derive memory scope from the session key; I did not run the regression test in this read-only review. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head33ab3d7fc7. - Required merge gates passed before the squash merge. Prepared head SHA:33ab3d7fc7Review: https://github.com/openclaw/openclaw/pull/76380#issuecomment-4365186657 Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import { expect } from "vitest";
|
|
import type { OpenClawConfig } from "../api.js";
|
|
import { createMemoryGetTool, createMemorySearchTool } from "./tools.js";
|
|
|
|
export function asOpenClawConfig(config: Partial<OpenClawConfig>): OpenClawConfig {
|
|
return config;
|
|
}
|
|
|
|
export function createDefaultMemoryToolConfig(): OpenClawConfig {
|
|
return asOpenClawConfig({ agents: { list: [{ id: "main", default: true }] } });
|
|
}
|
|
|
|
export function createMemorySearchToolOrThrow(params?: {
|
|
config?: OpenClawConfig;
|
|
agentId?: string;
|
|
agentSessionKey?: string;
|
|
}) {
|
|
const tool = createMemorySearchTool({
|
|
config: params?.config ?? createDefaultMemoryToolConfig(),
|
|
...(params?.agentId ? { agentId: params.agentId } : {}),
|
|
...(params?.agentSessionKey ? { agentSessionKey: params.agentSessionKey } : {}),
|
|
});
|
|
if (!tool) {
|
|
throw new Error("tool missing");
|
|
}
|
|
return tool;
|
|
}
|
|
|
|
export function createMemoryGetToolOrThrow(
|
|
config: OpenClawConfig = createDefaultMemoryToolConfig(),
|
|
) {
|
|
const tool = createMemoryGetTool({ config });
|
|
if (!tool) {
|
|
throw new Error("tool missing");
|
|
}
|
|
return tool;
|
|
}
|
|
|
|
export function createAutoCitationsMemorySearchTool(agentSessionKey: string) {
|
|
return createMemorySearchToolOrThrow({
|
|
config: asOpenClawConfig({
|
|
memory: { citations: "auto" },
|
|
agents: { list: [{ id: "main", default: true }] },
|
|
}),
|
|
agentSessionKey,
|
|
});
|
|
}
|
|
|
|
export function expectUnavailableMemorySearchDetails(
|
|
details: unknown,
|
|
params: {
|
|
error: string;
|
|
warning: string;
|
|
action: string;
|
|
},
|
|
) {
|
|
expect(details).toEqual({
|
|
results: [],
|
|
disabled: true,
|
|
unavailable: true,
|
|
error: params.error,
|
|
warning: params.warning,
|
|
action: params.action,
|
|
debug: {
|
|
warning: params.warning,
|
|
action: params.action,
|
|
error: params.error,
|
|
},
|
|
});
|
|
}
|