@agentmemory/agentmemory 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +14 -0
- package/.github/workflows/ci.yml +22 -0
- package/.github/workflows/publish.yml +28 -0
- package/AGENTS.md +113 -0
- package/LICENSE +190 -0
- package/README.md +828 -0
- package/assets/banner.png +0 -0
- package/assets/demo.gif +0 -0
- package/assets/demo.mp4 +0 -0
- package/benchmark/QUALITY.md +73 -0
- package/benchmark/REAL-EMBEDDINGS.md +67 -0
- package/benchmark/SCALE.md +110 -0
- package/benchmark/dataset.ts +293 -0
- package/benchmark/quality-eval.ts +643 -0
- package/benchmark/real-embeddings-eval.ts +405 -0
- package/benchmark/scale-eval.ts +398 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +137 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/docker-compose.yml +14 -0
- package/dist/hooks/notification.d.mts +1 -0
- package/dist/hooks/notification.mjs +45 -0
- package/dist/hooks/notification.mjs.map +1 -0
- package/dist/hooks/post-tool-failure.d.mts +1 -0
- package/dist/hooks/post-tool-failure.mjs +45 -0
- package/dist/hooks/post-tool-failure.mjs.map +1 -0
- package/dist/hooks/post-tool-use.d.mts +1 -0
- package/dist/hooks/post-tool-use.mjs +53 -0
- package/dist/hooks/post-tool-use.mjs.map +1 -0
- package/dist/hooks/pre-compact.d.mts +1 -0
- package/dist/hooks/pre-compact.mjs +50 -0
- package/dist/hooks/pre-compact.mjs.map +1 -0
- package/dist/hooks/pre-tool-use.d.mts +1 -0
- package/dist/hooks/pre-tool-use.mjs +69 -0
- package/dist/hooks/pre-tool-use.mjs.map +1 -0
- package/dist/hooks/prompt-submit.d.mts +1 -0
- package/dist/hooks/prompt-submit.mjs +40 -0
- package/dist/hooks/prompt-submit.mjs.map +1 -0
- package/dist/hooks/session-end.d.mts +1 -0
- package/dist/hooks/session-end.mjs +61 -0
- package/dist/hooks/session-end.mjs.map +1 -0
- package/dist/hooks/session-start.d.mts +1 -0
- package/dist/hooks/session-start.mjs +42 -0
- package/dist/hooks/session-start.mjs.map +1 -0
- package/dist/hooks/stop.d.mts +1 -0
- package/dist/hooks/stop.mjs +33 -0
- package/dist/hooks/stop.mjs.map +1 -0
- package/dist/hooks/subagent-start.d.mts +1 -0
- package/dist/hooks/subagent-start.mjs +43 -0
- package/dist/hooks/subagent-start.mjs.map +1 -0
- package/dist/hooks/subagent-stop.d.mts +1 -0
- package/dist/hooks/subagent-stop.mjs +45 -0
- package/dist/hooks/subagent-stop.mjs.map +1 -0
- package/dist/hooks/task-completed.d.mts +1 -0
- package/dist/hooks/task-completed.mjs +46 -0
- package/dist/hooks/task-completed.mjs.map +1 -0
- package/dist/iii-config.yaml +51 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +13776 -0
- package/dist/index.mjs.map +1 -0
- package/dist/src-QxitMPfJ.mjs +13775 -0
- package/dist/src-QxitMPfJ.mjs.map +1 -0
- package/dist/standalone.d.mts +1 -0
- package/dist/standalone.mjs +1155 -0
- package/dist/standalone.mjs.map +1 -0
- package/dist/transformers-BX_tgxdO.mjs +38684 -0
- package/dist/transformers-BX_tgxdO.mjs.map +1 -0
- package/dist/transformers-KMm1i9no.mjs +38683 -0
- package/dist/transformers-KMm1i9no.mjs.map +1 -0
- package/docker-compose.yml +14 -0
- package/iii-config.yaml +51 -0
- package/package.json +59 -0
- package/plugin/.claude-plugin/plugin.json +10 -0
- package/plugin/hooks/hooks.json +77 -0
- package/plugin/scripts/diagnostics.mjs +551 -0
- package/plugin/scripts/notification.mjs +45 -0
- package/plugin/scripts/post-tool-failure.mjs +45 -0
- package/plugin/scripts/post-tool-use.mjs +53 -0
- package/plugin/scripts/pre-compact.mjs +50 -0
- package/plugin/scripts/pre-tool-use.mjs +69 -0
- package/plugin/scripts/prompt-submit.mjs +40 -0
- package/plugin/scripts/session-end.mjs +61 -0
- package/plugin/scripts/session-start.mjs +42 -0
- package/plugin/scripts/stop.mjs +33 -0
- package/plugin/scripts/subagent-start.mjs +43 -0
- package/plugin/scripts/subagent-stop.mjs +45 -0
- package/plugin/scripts/task-completed.mjs +46 -0
- package/plugin/skills/forget/SKILL.md +32 -0
- package/plugin/skills/recall/SKILL.md +18 -0
- package/plugin/skills/remember/SKILL.md +25 -0
- package/plugin/skills/session-history/SKILL.md +17 -0
- package/src/auth.ts +12 -0
- package/src/cli.ts +159 -0
- package/src/config.ts +221 -0
- package/src/eval/metrics-store.ts +65 -0
- package/src/eval/quality.ts +51 -0
- package/src/eval/schemas.ts +124 -0
- package/src/eval/self-correct.ts +28 -0
- package/src/eval/validator.ts +31 -0
- package/src/functions/actions.ts +288 -0
- package/src/functions/audit.ts +61 -0
- package/src/functions/auto-forget.ts +169 -0
- package/src/functions/branch-aware.ts +169 -0
- package/src/functions/cascade.ts +80 -0
- package/src/functions/checkpoints.ts +209 -0
- package/src/functions/claude-bridge.ts +161 -0
- package/src/functions/compress.ts +194 -0
- package/src/functions/consolidate.ts +212 -0
- package/src/functions/consolidation-pipeline.ts +258 -0
- package/src/functions/context.ts +169 -0
- package/src/functions/crystallize.ts +293 -0
- package/src/functions/dedup.ts +57 -0
- package/src/functions/diagnostics.ts +785 -0
- package/src/functions/enrich.ts +132 -0
- package/src/functions/evict.ts +163 -0
- package/src/functions/export-import.ts +508 -0
- package/src/functions/facets.ts +248 -0
- package/src/functions/file-index.ts +106 -0
- package/src/functions/flow-compress.ts +214 -0
- package/src/functions/frontier.ts +196 -0
- package/src/functions/governance.ts +131 -0
- package/src/functions/graph-retrieval.ts +277 -0
- package/src/functions/graph.ts +275 -0
- package/src/functions/leases.ts +216 -0
- package/src/functions/lessons.ts +253 -0
- package/src/functions/mesh.ts +434 -0
- package/src/functions/migrate.ts +165 -0
- package/src/functions/observe.ts +144 -0
- package/src/functions/obsidian-export.ts +310 -0
- package/src/functions/patterns.ts +138 -0
- package/src/functions/privacy.ts +39 -0
- package/src/functions/profile.ts +155 -0
- package/src/functions/query-expansion.ts +186 -0
- package/src/functions/relations.ts +237 -0
- package/src/functions/remember.ts +162 -0
- package/src/functions/retention.ts +235 -0
- package/src/functions/routines.ts +289 -0
- package/src/functions/search.ts +80 -0
- package/src/functions/sentinels.ts +417 -0
- package/src/functions/signals.ts +186 -0
- package/src/functions/sketches.ts +274 -0
- package/src/functions/sliding-window.ts +257 -0
- package/src/functions/smart-search.ts +115 -0
- package/src/functions/snapshot.ts +219 -0
- package/src/functions/summarize.ts +155 -0
- package/src/functions/team.ts +147 -0
- package/src/functions/temporal-graph.ts +476 -0
- package/src/functions/timeline.ts +138 -0
- package/src/functions/verify.ts +117 -0
- package/src/health/monitor.ts +110 -0
- package/src/health/thresholds.ts +73 -0
- package/src/hooks/notification.ts +52 -0
- package/src/hooks/post-tool-failure.ts +58 -0
- package/src/hooks/post-tool-use.ts +62 -0
- package/src/hooks/pre-compact.ts +60 -0
- package/src/hooks/pre-tool-use.ts +72 -0
- package/src/hooks/prompt-submit.ts +46 -0
- package/src/hooks/session-end.ts +71 -0
- package/src/hooks/session-start.ts +48 -0
- package/src/hooks/stop.ts +39 -0
- package/src/hooks/subagent-start.ts +49 -0
- package/src/hooks/subagent-stop.ts +54 -0
- package/src/hooks/task-completed.ts +54 -0
- package/src/index.ts +342 -0
- package/src/mcp/in-memory-kv.ts +61 -0
- package/src/mcp/server.ts +1455 -0
- package/src/mcp/standalone.ts +177 -0
- package/src/mcp/tools-registry.ts +769 -0
- package/src/mcp/transport.ts +91 -0
- package/src/prompts/compression.ts +67 -0
- package/src/prompts/consolidation.ts +48 -0
- package/src/prompts/graph-extraction.ts +35 -0
- package/src/prompts/summary.ts +38 -0
- package/src/prompts/xml.ts +26 -0
- package/src/providers/agent-sdk.ts +34 -0
- package/src/providers/anthropic.ts +35 -0
- package/src/providers/circuit-breaker.ts +82 -0
- package/src/providers/embedding/cohere.ts +46 -0
- package/src/providers/embedding/gemini.ts +54 -0
- package/src/providers/embedding/index.ts +39 -0
- package/src/providers/embedding/local.ts +52 -0
- package/src/providers/embedding/openai.ts +45 -0
- package/src/providers/embedding/openrouter.ts +51 -0
- package/src/providers/embedding/voyage.ts +46 -0
- package/src/providers/fallback-chain.ts +31 -0
- package/src/providers/index.ts +84 -0
- package/src/providers/openrouter.ts +71 -0
- package/src/providers/resilient.ts +37 -0
- package/src/state/hybrid-search.ts +295 -0
- package/src/state/index-persistence.ts +63 -0
- package/src/state/keyed-mutex.ts +18 -0
- package/src/state/kv.ts +33 -0
- package/src/state/schema.ts +71 -0
- package/src/state/search-index.ts +245 -0
- package/src/state/stemmer.ts +104 -0
- package/src/state/synonyms.ts +63 -0
- package/src/state/vector-index.ts +130 -0
- package/src/telemetry/setup.ts +116 -0
- package/src/triggers/api.ts +1904 -0
- package/src/triggers/events.ts +71 -0
- package/src/types.ts +769 -0
- package/src/version.ts +1 -0
- package/src/viewer/index.html +2497 -0
- package/src/viewer/server.ts +207 -0
- package/src/xenova.d.ts +3 -0
- package/test/actions.test.ts +490 -0
- package/test/audit.test.ts +108 -0
- package/test/auto-forget.test.ts +188 -0
- package/test/cascade.test.ts +277 -0
- package/test/checkpoints.test.ts +493 -0
- package/test/circuit-breaker.test.ts +107 -0
- package/test/claude-bridge.test.ts +178 -0
- package/test/confidence.test.ts +247 -0
- package/test/consistency.test.ts +61 -0
- package/test/consolidation-pipeline.test.ts +251 -0
- package/test/crystallize.test.ts +521 -0
- package/test/diagnostics.test.ts +638 -0
- package/test/embedding-provider.test.ts +49 -0
- package/test/enrich.test.ts +209 -0
- package/test/eval.test.ts +300 -0
- package/test/export-import.test.ts +251 -0
- package/test/facets.test.ts +448 -0
- package/test/fallback-chain.test.ts +93 -0
- package/test/frontier.test.ts +485 -0
- package/test/governance.test.ts +147 -0
- package/test/graph-retrieval.test.ts +186 -0
- package/test/graph.test.ts +160 -0
- package/test/helpers/mocks.ts +40 -0
- package/test/hybrid-search.test.ts +145 -0
- package/test/index-persistence.test.ts +124 -0
- package/test/integration.test.ts +265 -0
- package/test/leases.test.ts +399 -0
- package/test/mcp-prompts.test.ts +218 -0
- package/test/mcp-resources.test.ts +286 -0
- package/test/mcp-standalone.test.ts +113 -0
- package/test/mesh.test.ts +700 -0
- package/test/privacy.test.ts +87 -0
- package/test/profile.test.ts +161 -0
- package/test/query-expansion.test.ts +154 -0
- package/test/relations.test.ts +198 -0
- package/test/retention.test.ts +245 -0
- package/test/routines.test.ts +497 -0
- package/test/schema-fingerprint.test.ts +81 -0
- package/test/schema.test.ts +42 -0
- package/test/search-index.test.ts +128 -0
- package/test/sentinels.test.ts +626 -0
- package/test/signals.test.ts +410 -0
- package/test/sketches.test.ts +549 -0
- package/test/sliding-window.test.ts +199 -0
- package/test/smart-search.test.ts +169 -0
- package/test/snapshot.test.ts +165 -0
- package/test/team.test.ts +156 -0
- package/test/temporal-graph.test.ts +378 -0
- package/test/timeline.test.ts +148 -0
- package/test/vector-index.test.ts +79 -0
- package/test/verify.test.ts +209 -0
- package/test/xml.test.ts +65 -0
- package/tsconfig.json +22 -0
- package/tsdown.config.ts +62 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createServer,
|
|
3
|
+
type Server,
|
|
4
|
+
type IncomingMessage,
|
|
5
|
+
type ServerResponse,
|
|
6
|
+
} from "node:http";
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { join, dirname } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { timingSafeCompare, VIEWER_CSP } from "../auth.js";
|
|
11
|
+
|
|
12
|
+
const ALLOWED_ORIGINS = (
|
|
13
|
+
process.env.VIEWER_ALLOWED_ORIGINS ||
|
|
14
|
+
"http://localhost:3111,http://localhost:3113,http://127.0.0.1:3111,http://127.0.0.1:3113"
|
|
15
|
+
)
|
|
16
|
+
.split(",")
|
|
17
|
+
.map((o) => o.trim());
|
|
18
|
+
|
|
19
|
+
function corsHeaders(req: IncomingMessage): Record<string, string> {
|
|
20
|
+
const origin = req.headers.origin || "";
|
|
21
|
+
const allowed = ALLOWED_ORIGINS.includes(origin)
|
|
22
|
+
? origin
|
|
23
|
+
: ALLOWED_ORIGINS[0];
|
|
24
|
+
return {
|
|
25
|
+
"Access-Control-Allow-Origin": allowed,
|
|
26
|
+
"Access-Control-Allow-Methods": "GET, POST, DELETE, OPTIONS",
|
|
27
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization",
|
|
28
|
+
Vary: "Origin",
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function json(
|
|
33
|
+
res: ServerResponse,
|
|
34
|
+
status: number,
|
|
35
|
+
data: unknown,
|
|
36
|
+
req?: IncomingMessage,
|
|
37
|
+
): void {
|
|
38
|
+
const body = JSON.stringify(data);
|
|
39
|
+
const cors = req
|
|
40
|
+
? corsHeaders(req)
|
|
41
|
+
: { "Access-Control-Allow-Origin": ALLOWED_ORIGINS[0], Vary: "Origin" };
|
|
42
|
+
res.writeHead(status, { ...cors, "Content-Type": "application/json" });
|
|
43
|
+
res.end(body);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function readBody(req: IncomingMessage): Promise<string> {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
let data = "";
|
|
49
|
+
let size = 0;
|
|
50
|
+
req.on("data", (chunk: Buffer) => {
|
|
51
|
+
size += chunk.length;
|
|
52
|
+
if (size > 1_000_000) {
|
|
53
|
+
req.destroy();
|
|
54
|
+
reject(new Error("too large"));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
data += chunk.toString();
|
|
58
|
+
});
|
|
59
|
+
req.on("end", () => resolve(data));
|
|
60
|
+
req.on("error", reject);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function checkAuth(req: IncomingMessage, secret: string | undefined): boolean {
|
|
65
|
+
if (!secret) return true;
|
|
66
|
+
const auth = req.headers["authorization"] || "";
|
|
67
|
+
return (
|
|
68
|
+
typeof auth === "string" && timingSafeCompare(auth, `Bearer ${secret}`)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function startViewerServer(
|
|
73
|
+
port: number,
|
|
74
|
+
_kv: unknown,
|
|
75
|
+
_sdk: unknown,
|
|
76
|
+
secret?: string,
|
|
77
|
+
restPort?: number,
|
|
78
|
+
): Server {
|
|
79
|
+
const resolvedRestPort = restPort ?? port - 2;
|
|
80
|
+
|
|
81
|
+
const server = createServer(async (req, res) => {
|
|
82
|
+
const raw = req.url || "/";
|
|
83
|
+
const qIdx = raw.indexOf("?");
|
|
84
|
+
const pathname = qIdx >= 0 ? raw.slice(0, qIdx) : raw;
|
|
85
|
+
const qs = qIdx >= 0 ? raw.slice(qIdx + 1) : "";
|
|
86
|
+
const method = req.method || "GET";
|
|
87
|
+
|
|
88
|
+
if (method === "OPTIONS") {
|
|
89
|
+
res.writeHead(204, {
|
|
90
|
+
...corsHeaders(req),
|
|
91
|
+
"Access-Control-Max-Age": "86400",
|
|
92
|
+
});
|
|
93
|
+
res.end();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (
|
|
98
|
+
method === "GET" &&
|
|
99
|
+
(pathname === "/" ||
|
|
100
|
+
pathname === "/viewer" ||
|
|
101
|
+
pathname === "/agentmemory/viewer")
|
|
102
|
+
) {
|
|
103
|
+
const base = dirname(fileURLToPath(import.meta.url));
|
|
104
|
+
const candidates = [
|
|
105
|
+
join(base, "..", "src", "viewer", "index.html"),
|
|
106
|
+
join(base, "..", "viewer", "index.html"),
|
|
107
|
+
join(base, "viewer", "index.html"),
|
|
108
|
+
];
|
|
109
|
+
for (const p of candidates) {
|
|
110
|
+
try {
|
|
111
|
+
const html = readFileSync(p, "utf-8");
|
|
112
|
+
res.writeHead(200, {
|
|
113
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
114
|
+
"Content-Security-Policy": VIEWER_CSP,
|
|
115
|
+
"Cache-Control": "no-cache",
|
|
116
|
+
});
|
|
117
|
+
res.end(html);
|
|
118
|
+
return;
|
|
119
|
+
} catch {}
|
|
120
|
+
}
|
|
121
|
+
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
122
|
+
res.end("viewer not found");
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!checkAuth(req, secret)) {
|
|
127
|
+
json(res, 401, { error: "unauthorized" }, req);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
await proxyToRestApi(resolvedRestPort, pathname, qs, method, req, res, secret);
|
|
133
|
+
} catch (err) {
|
|
134
|
+
console.error(`[viewer] proxy error on ${method} ${pathname}:`, err);
|
|
135
|
+
json(res, 502, { error: "upstream error" }, req);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
server.listen(port, "127.0.0.1", () => {
|
|
140
|
+
console.log(`[agentmemory] Viewer: http://localhost:${port}`);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
return server;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function proxyToRestApi(
|
|
147
|
+
restPort: number,
|
|
148
|
+
pathname: string,
|
|
149
|
+
qs: string,
|
|
150
|
+
method: string,
|
|
151
|
+
req: IncomingMessage,
|
|
152
|
+
res: ServerResponse,
|
|
153
|
+
secret?: string,
|
|
154
|
+
): Promise<void> {
|
|
155
|
+
const upstreamPath = pathname.startsWith("/agentmemory/")
|
|
156
|
+
? pathname
|
|
157
|
+
: `/agentmemory${pathname.startsWith("/") ? pathname : "/" + pathname}`;
|
|
158
|
+
|
|
159
|
+
const upstreamUrl = `http://127.0.0.1:${restPort}${upstreamPath}${qs ? "?" + qs : ""}`;
|
|
160
|
+
|
|
161
|
+
const headers: Record<string, string> = {};
|
|
162
|
+
if (secret) {
|
|
163
|
+
headers["Authorization"] = `Bearer ${secret}`;
|
|
164
|
+
}
|
|
165
|
+
const ct = req.headers["content-type"];
|
|
166
|
+
if (ct) {
|
|
167
|
+
headers["Content-Type"] = ct;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
let body: string | undefined;
|
|
171
|
+
if (method === "POST" || method === "PUT" || method === "DELETE" || method === "PATCH") {
|
|
172
|
+
body = await readBody(req);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const controller = new AbortController();
|
|
176
|
+
const fetchTimeout = setTimeout(() => controller.abort(), 10000);
|
|
177
|
+
let upstream: Response;
|
|
178
|
+
try {
|
|
179
|
+
upstream = await fetch(upstreamUrl, {
|
|
180
|
+
method,
|
|
181
|
+
headers,
|
|
182
|
+
body: body || undefined,
|
|
183
|
+
signal: controller.signal,
|
|
184
|
+
});
|
|
185
|
+
clearTimeout(fetchTimeout);
|
|
186
|
+
} catch (err) {
|
|
187
|
+
clearTimeout(fetchTimeout);
|
|
188
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
189
|
+
json(res, 504, { error: "upstream timeout" }, req);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
throw err;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const cors = corsHeaders(req);
|
|
196
|
+
const responseBody = await upstream.text();
|
|
197
|
+
const responseHeaders: Record<string, string> = {
|
|
198
|
+
...cors,
|
|
199
|
+
};
|
|
200
|
+
const upstreamCt = upstream.headers.get("content-type");
|
|
201
|
+
if (upstreamCt) {
|
|
202
|
+
responseHeaders["Content-Type"] = upstreamCt;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
res.writeHead(upstream.status, responseHeaders);
|
|
206
|
+
res.end(responseBody);
|
|
207
|
+
}
|
package/src/xenova.d.ts
ADDED
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
vi.mock("iii-sdk", () => ({
|
|
4
|
+
getContext: () => ({
|
|
5
|
+
logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },
|
|
6
|
+
}),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
import { registerActionsFunction } from "../src/functions/actions.js";
|
|
10
|
+
import type { Action, ActionEdge } from "../src/types.js";
|
|
11
|
+
|
|
12
|
+
function mockKV() {
|
|
13
|
+
const store = new Map<string, Map<string, unknown>>();
|
|
14
|
+
return {
|
|
15
|
+
get: async <T>(scope: string, key: string): Promise<T | null> => {
|
|
16
|
+
return (store.get(scope)?.get(key) as T) ?? null;
|
|
17
|
+
},
|
|
18
|
+
set: async <T>(scope: string, key: string, data: T): Promise<T> => {
|
|
19
|
+
if (!store.has(scope)) store.set(scope, new Map());
|
|
20
|
+
store.get(scope)!.set(key, data);
|
|
21
|
+
return data;
|
|
22
|
+
},
|
|
23
|
+
delete: async (scope: string, key: string): Promise<void> => {
|
|
24
|
+
store.get(scope)?.delete(key);
|
|
25
|
+
},
|
|
26
|
+
list: async <T>(scope: string): Promise<T[]> => {
|
|
27
|
+
const entries = store.get(scope);
|
|
28
|
+
return entries ? (Array.from(entries.values()) as T[]) : [];
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function mockSdk() {
|
|
34
|
+
const functions = new Map<string, Function>();
|
|
35
|
+
return {
|
|
36
|
+
registerFunction: (opts: { id: string }, handler: Function) => {
|
|
37
|
+
functions.set(opts.id, handler);
|
|
38
|
+
},
|
|
39
|
+
registerTrigger: () => {},
|
|
40
|
+
trigger: async (id: string, data: unknown) => {
|
|
41
|
+
const fn = functions.get(id);
|
|
42
|
+
if (!fn) throw new Error(`No function: ${id}`);
|
|
43
|
+
return fn(data);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
describe("Actions Functions", () => {
|
|
49
|
+
let sdk: ReturnType<typeof mockSdk>;
|
|
50
|
+
let kv: ReturnType<typeof mockKV>;
|
|
51
|
+
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
sdk = mockSdk();
|
|
54
|
+
kv = mockKV();
|
|
55
|
+
registerActionsFunction(sdk as never, kv as never);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe("mem::action-create", () => {
|
|
59
|
+
it("creates an action with valid data", async () => {
|
|
60
|
+
const result = (await sdk.trigger("mem::action-create", {
|
|
61
|
+
title: "Fix login bug",
|
|
62
|
+
description: "Users cannot log in with SSO",
|
|
63
|
+
priority: 7,
|
|
64
|
+
createdBy: "agent-1",
|
|
65
|
+
project: "webapp",
|
|
66
|
+
tags: ["bug", "auth"],
|
|
67
|
+
})) as { success: boolean; action: Action; edges: ActionEdge[] };
|
|
68
|
+
|
|
69
|
+
expect(result.success).toBe(true);
|
|
70
|
+
expect(result.action.id).toMatch(/^act_/);
|
|
71
|
+
expect(result.action.title).toBe("Fix login bug");
|
|
72
|
+
expect(result.action.description).toBe("Users cannot log in with SSO");
|
|
73
|
+
expect(result.action.status).toBe("pending");
|
|
74
|
+
expect(result.action.priority).toBe(7);
|
|
75
|
+
expect(result.action.createdBy).toBe("agent-1");
|
|
76
|
+
expect(result.action.project).toBe("webapp");
|
|
77
|
+
expect(result.action.tags).toEqual(["bug", "auth"]);
|
|
78
|
+
expect(result.action.createdAt).toBeDefined();
|
|
79
|
+
expect(result.action.updatedAt).toBeDefined();
|
|
80
|
+
expect(result.edges).toEqual([]);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("returns error when title is missing", async () => {
|
|
84
|
+
const result = (await sdk.trigger("mem::action-create", {
|
|
85
|
+
description: "No title provided",
|
|
86
|
+
})) as { success: boolean; error: string };
|
|
87
|
+
|
|
88
|
+
expect(result.success).toBe(false);
|
|
89
|
+
expect(result.error).toContain("title is required");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("clamps priority 0 to default 5 (falsy fallback)", async () => {
|
|
93
|
+
const result = (await sdk.trigger("mem::action-create", {
|
|
94
|
+
title: "Zero priority task",
|
|
95
|
+
priority: 0,
|
|
96
|
+
})) as { success: boolean; action: Action };
|
|
97
|
+
|
|
98
|
+
expect(result.success).toBe(true);
|
|
99
|
+
expect(result.action.priority).toBe(5);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("clamps negative priority to 1", async () => {
|
|
103
|
+
const result = (await sdk.trigger("mem::action-create", {
|
|
104
|
+
title: "Negative priority task",
|
|
105
|
+
priority: -3,
|
|
106
|
+
})) as { success: boolean; action: Action };
|
|
107
|
+
|
|
108
|
+
expect(result.success).toBe(true);
|
|
109
|
+
expect(result.action.priority).toBe(1);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("clamps priority 15 to 10", async () => {
|
|
113
|
+
const result = (await sdk.trigger("mem::action-create", {
|
|
114
|
+
title: "High priority task",
|
|
115
|
+
priority: 15,
|
|
116
|
+
})) as { success: boolean; action: Action };
|
|
117
|
+
|
|
118
|
+
expect(result.success).toBe(true);
|
|
119
|
+
expect(result.action.priority).toBe(10);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("validates parent action exists", async () => {
|
|
123
|
+
const result = (await sdk.trigger("mem::action-create", {
|
|
124
|
+
title: "Child task",
|
|
125
|
+
parentId: "nonexistent_parent",
|
|
126
|
+
})) as { success: boolean; error: string };
|
|
127
|
+
|
|
128
|
+
expect(result.success).toBe(false);
|
|
129
|
+
expect(result.error).toContain("parent action not found");
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("creates action with valid parent", async () => {
|
|
133
|
+
const parentResult = (await sdk.trigger("mem::action-create", {
|
|
134
|
+
title: "Parent task",
|
|
135
|
+
})) as { success: boolean; action: Action };
|
|
136
|
+
|
|
137
|
+
const childResult = (await sdk.trigger("mem::action-create", {
|
|
138
|
+
title: "Child task",
|
|
139
|
+
parentId: parentResult.action.id,
|
|
140
|
+
})) as { success: boolean; action: Action };
|
|
141
|
+
|
|
142
|
+
expect(childResult.success).toBe(true);
|
|
143
|
+
expect(childResult.action.parentId).toBe(parentResult.action.id);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("creates inline edges with valid types", async () => {
|
|
147
|
+
const targetResult = (await sdk.trigger("mem::action-create", {
|
|
148
|
+
title: "Target action",
|
|
149
|
+
})) as { success: boolean; action: Action };
|
|
150
|
+
|
|
151
|
+
const result = (await sdk.trigger("mem::action-create", {
|
|
152
|
+
title: "Source action",
|
|
153
|
+
edges: [
|
|
154
|
+
{ type: "requires", targetActionId: targetResult.action.id },
|
|
155
|
+
{ type: "unlocks", targetActionId: targetResult.action.id },
|
|
156
|
+
],
|
|
157
|
+
})) as { success: boolean; action: Action; edges: ActionEdge[] };
|
|
158
|
+
|
|
159
|
+
expect(result.success).toBe(true);
|
|
160
|
+
expect(result.edges.length).toBe(2);
|
|
161
|
+
expect(result.edges[0].id).toMatch(/^ae_/);
|
|
162
|
+
expect(result.edges[0].type).toBe("requires");
|
|
163
|
+
expect(result.edges[0].sourceActionId).toBe(result.action.id);
|
|
164
|
+
expect(result.edges[0].targetActionId).toBe(targetResult.action.id);
|
|
165
|
+
expect(result.edges[1].type).toBe("unlocks");
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("returns error for inline edge with invalid type", async () => {
|
|
169
|
+
const targetResult = (await sdk.trigger("mem::action-create", {
|
|
170
|
+
title: "Target action",
|
|
171
|
+
})) as { success: boolean; action: Action };
|
|
172
|
+
|
|
173
|
+
const result = (await sdk.trigger("mem::action-create", {
|
|
174
|
+
title: "Source action",
|
|
175
|
+
edges: [
|
|
176
|
+
{ type: "invalid_type", targetActionId: targetResult.action.id },
|
|
177
|
+
],
|
|
178
|
+
})) as { success: boolean; error: string };
|
|
179
|
+
|
|
180
|
+
expect(result.success).toBe(false);
|
|
181
|
+
expect(result.error).toContain("invalid edge type");
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("returns error for inline edge with nonexistent target", async () => {
|
|
185
|
+
const result = (await sdk.trigger("mem::action-create", {
|
|
186
|
+
title: "Source action",
|
|
187
|
+
edges: [{ type: "requires", targetActionId: "nonexistent_id" }],
|
|
188
|
+
})) as { success: boolean; error: string };
|
|
189
|
+
|
|
190
|
+
expect(result.success).toBe(false);
|
|
191
|
+
expect(result.error).toContain("target action not found");
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
describe("mem::action-update", () => {
|
|
196
|
+
it("updates an action with valid data", async () => {
|
|
197
|
+
const createResult = (await sdk.trigger("mem::action-create", {
|
|
198
|
+
title: "Original title",
|
|
199
|
+
priority: 5,
|
|
200
|
+
})) as { success: boolean; action: Action };
|
|
201
|
+
|
|
202
|
+
const updateResult = (await sdk.trigger("mem::action-update", {
|
|
203
|
+
actionId: createResult.action.id,
|
|
204
|
+
title: "Updated title",
|
|
205
|
+
priority: 8,
|
|
206
|
+
status: "active",
|
|
207
|
+
assignedTo: "agent-2",
|
|
208
|
+
tags: ["updated"],
|
|
209
|
+
})) as { success: boolean; action: Action };
|
|
210
|
+
|
|
211
|
+
expect(updateResult.success).toBe(true);
|
|
212
|
+
expect(updateResult.action.title).toBe("Updated title");
|
|
213
|
+
expect(updateResult.action.priority).toBe(8);
|
|
214
|
+
expect(updateResult.action.status).toBe("active");
|
|
215
|
+
expect(updateResult.action.assignedTo).toBe("agent-2");
|
|
216
|
+
expect(updateResult.action.tags).toEqual(["updated"]);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it("returns error when actionId is missing", async () => {
|
|
220
|
+
const result = (await sdk.trigger("mem::action-update", {
|
|
221
|
+
title: "no id",
|
|
222
|
+
})) as { success: boolean; error: string };
|
|
223
|
+
|
|
224
|
+
expect(result.success).toBe(false);
|
|
225
|
+
expect(result.error).toContain("actionId is required");
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it("returns error for nonexistent action", async () => {
|
|
229
|
+
const result = (await sdk.trigger("mem::action-update", {
|
|
230
|
+
actionId: "nonexistent_id",
|
|
231
|
+
status: "done",
|
|
232
|
+
})) as { success: boolean; error: string };
|
|
233
|
+
|
|
234
|
+
expect(result.success).toBe(false);
|
|
235
|
+
expect(result.error).toContain("action not found");
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it("propagates completion when status set to done", async () => {
|
|
239
|
+
const actionB = (await sdk.trigger("mem::action-create", {
|
|
240
|
+
title: "Dependency B",
|
|
241
|
+
})) as { success: boolean; action: Action };
|
|
242
|
+
|
|
243
|
+
const actionA = (await sdk.trigger("mem::action-create", {
|
|
244
|
+
title: "Action A depends on B",
|
|
245
|
+
edges: [{ type: "requires", targetActionId: actionB.action.id }],
|
|
246
|
+
})) as { success: boolean; action: Action };
|
|
247
|
+
|
|
248
|
+
await sdk.trigger("mem::action-update", {
|
|
249
|
+
actionId: actionA.action.id,
|
|
250
|
+
status: "blocked",
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
await sdk.trigger("mem::action-update", {
|
|
254
|
+
actionId: actionB.action.id,
|
|
255
|
+
status: "done",
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const getResult = (await sdk.trigger("mem::action-get", {
|
|
259
|
+
actionId: actionA.action.id,
|
|
260
|
+
})) as { success: boolean; action: Action };
|
|
261
|
+
|
|
262
|
+
expect(getResult.action.status).toBe("pending");
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
describe("mem::action-edge-create", () => {
|
|
267
|
+
it("creates an edge between two actions", async () => {
|
|
268
|
+
const source = (await sdk.trigger("mem::action-create", {
|
|
269
|
+
title: "Source",
|
|
270
|
+
})) as { success: boolean; action: Action };
|
|
271
|
+
|
|
272
|
+
const target = (await sdk.trigger("mem::action-create", {
|
|
273
|
+
title: "Target",
|
|
274
|
+
})) as { success: boolean; action: Action };
|
|
275
|
+
|
|
276
|
+
const result = (await sdk.trigger("mem::action-edge-create", {
|
|
277
|
+
sourceActionId: source.action.id,
|
|
278
|
+
targetActionId: target.action.id,
|
|
279
|
+
type: "requires",
|
|
280
|
+
})) as { success: boolean; edge: ActionEdge };
|
|
281
|
+
|
|
282
|
+
expect(result.success).toBe(true);
|
|
283
|
+
expect(result.edge.id).toMatch(/^ae_/);
|
|
284
|
+
expect(result.edge.type).toBe("requires");
|
|
285
|
+
expect(result.edge.sourceActionId).toBe(source.action.id);
|
|
286
|
+
expect(result.edge.targetActionId).toBe(target.action.id);
|
|
287
|
+
expect(result.edge.createdAt).toBeDefined();
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it("returns error when required fields are missing", async () => {
|
|
291
|
+
const result = (await sdk.trigger("mem::action-edge-create", {
|
|
292
|
+
sourceActionId: "some_id",
|
|
293
|
+
})) as { success: boolean; error: string };
|
|
294
|
+
|
|
295
|
+
expect(result.success).toBe(false);
|
|
296
|
+
expect(result.error).toContain("required");
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it("returns error for invalid edge type", async () => {
|
|
300
|
+
const source = (await sdk.trigger("mem::action-create", {
|
|
301
|
+
title: "Source",
|
|
302
|
+
})) as { success: boolean; action: Action };
|
|
303
|
+
|
|
304
|
+
const target = (await sdk.trigger("mem::action-create", {
|
|
305
|
+
title: "Target",
|
|
306
|
+
})) as { success: boolean; action: Action };
|
|
307
|
+
|
|
308
|
+
const result = (await sdk.trigger("mem::action-edge-create", {
|
|
309
|
+
sourceActionId: source.action.id,
|
|
310
|
+
targetActionId: target.action.id,
|
|
311
|
+
type: "invalid_type",
|
|
312
|
+
})) as { success: boolean; error: string };
|
|
313
|
+
|
|
314
|
+
expect(result.success).toBe(false);
|
|
315
|
+
expect(result.error).toContain("type must be one of");
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it("returns error for nonexistent source action", async () => {
|
|
319
|
+
const target = (await sdk.trigger("mem::action-create", {
|
|
320
|
+
title: "Target",
|
|
321
|
+
})) as { success: boolean; action: Action };
|
|
322
|
+
|
|
323
|
+
const result = (await sdk.trigger("mem::action-edge-create", {
|
|
324
|
+
sourceActionId: "nonexistent",
|
|
325
|
+
targetActionId: target.action.id,
|
|
326
|
+
type: "requires",
|
|
327
|
+
})) as { success: boolean; error: string };
|
|
328
|
+
|
|
329
|
+
expect(result.success).toBe(false);
|
|
330
|
+
expect(result.error).toContain("source action not found");
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it("returns error for nonexistent target action", async () => {
|
|
334
|
+
const source = (await sdk.trigger("mem::action-create", {
|
|
335
|
+
title: "Source",
|
|
336
|
+
})) as { success: boolean; action: Action };
|
|
337
|
+
|
|
338
|
+
const result = (await sdk.trigger("mem::action-edge-create", {
|
|
339
|
+
sourceActionId: source.action.id,
|
|
340
|
+
targetActionId: "nonexistent",
|
|
341
|
+
type: "requires",
|
|
342
|
+
})) as { success: boolean; error: string };
|
|
343
|
+
|
|
344
|
+
expect(result.success).toBe(false);
|
|
345
|
+
expect(result.error).toContain("target action not found");
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
describe("mem::action-list", () => {
|
|
350
|
+
beforeEach(async () => {
|
|
351
|
+
await sdk.trigger("mem::action-create", {
|
|
352
|
+
title: "Task A",
|
|
353
|
+
status: "pending",
|
|
354
|
+
project: "alpha",
|
|
355
|
+
tags: ["frontend"],
|
|
356
|
+
});
|
|
357
|
+
await new Promise((r) => setTimeout(r, 5));
|
|
358
|
+
await sdk.trigger("mem::action-create", {
|
|
359
|
+
title: "Task B",
|
|
360
|
+
project: "alpha",
|
|
361
|
+
tags: ["backend"],
|
|
362
|
+
});
|
|
363
|
+
await new Promise((r) => setTimeout(r, 5));
|
|
364
|
+
await sdk.trigger("mem::action-create", {
|
|
365
|
+
title: "Task C",
|
|
366
|
+
project: "beta",
|
|
367
|
+
tags: ["frontend", "backend"],
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it("returns all actions", async () => {
|
|
372
|
+
const result = (await sdk.trigger("mem::action-list", {})) as {
|
|
373
|
+
success: boolean;
|
|
374
|
+
actions: Action[];
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
expect(result.success).toBe(true);
|
|
378
|
+
expect(result.actions.length).toBe(3);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it("filters by status", async () => {
|
|
382
|
+
const all = (await sdk.trigger("mem::action-list", {})) as {
|
|
383
|
+
actions: Action[];
|
|
384
|
+
};
|
|
385
|
+
const firstAction = all.actions[0];
|
|
386
|
+
|
|
387
|
+
await sdk.trigger("mem::action-update", {
|
|
388
|
+
actionId: firstAction.id,
|
|
389
|
+
status: "done",
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
const result = (await sdk.trigger("mem::action-list", {
|
|
393
|
+
status: "done",
|
|
394
|
+
})) as { success: boolean; actions: Action[] };
|
|
395
|
+
|
|
396
|
+
expect(result.success).toBe(true);
|
|
397
|
+
expect(result.actions.length).toBe(1);
|
|
398
|
+
expect(result.actions[0].status).toBe("done");
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it("filters by project", async () => {
|
|
402
|
+
const result = (await sdk.trigger("mem::action-list", {
|
|
403
|
+
project: "alpha",
|
|
404
|
+
})) as { success: boolean; actions: Action[] };
|
|
405
|
+
|
|
406
|
+
expect(result.success).toBe(true);
|
|
407
|
+
expect(result.actions.length).toBe(2);
|
|
408
|
+
expect(result.actions.every((a) => a.project === "alpha")).toBe(true);
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
it("filters by tags", async () => {
|
|
412
|
+
const result = (await sdk.trigger("mem::action-list", {
|
|
413
|
+
tags: ["backend"],
|
|
414
|
+
})) as { success: boolean; actions: Action[] };
|
|
415
|
+
|
|
416
|
+
expect(result.success).toBe(true);
|
|
417
|
+
expect(result.actions.length).toBe(2);
|
|
418
|
+
expect(
|
|
419
|
+
result.actions.every((a) => a.tags.includes("backend")),
|
|
420
|
+
).toBe(true);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
it("respects limit", async () => {
|
|
424
|
+
const result = (await sdk.trigger("mem::action-list", {
|
|
425
|
+
limit: 2,
|
|
426
|
+
})) as { success: boolean; actions: Action[] };
|
|
427
|
+
|
|
428
|
+
expect(result.success).toBe(true);
|
|
429
|
+
expect(result.actions.length).toBe(2);
|
|
430
|
+
});
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
describe("mem::action-get", () => {
|
|
434
|
+
it("returns action with edges and children", async () => {
|
|
435
|
+
const parent = (await sdk.trigger("mem::action-create", {
|
|
436
|
+
title: "Parent",
|
|
437
|
+
})) as { success: boolean; action: Action };
|
|
438
|
+
|
|
439
|
+
const child = (await sdk.trigger("mem::action-create", {
|
|
440
|
+
title: "Child",
|
|
441
|
+
parentId: parent.action.id,
|
|
442
|
+
})) as { success: boolean; action: Action };
|
|
443
|
+
|
|
444
|
+
const other = (await sdk.trigger("mem::action-create", {
|
|
445
|
+
title: "Other",
|
|
446
|
+
})) as { success: boolean; action: Action };
|
|
447
|
+
|
|
448
|
+
await sdk.trigger("mem::action-edge-create", {
|
|
449
|
+
sourceActionId: parent.action.id,
|
|
450
|
+
targetActionId: other.action.id,
|
|
451
|
+
type: "unlocks",
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
const result = (await sdk.trigger("mem::action-get", {
|
|
455
|
+
actionId: parent.action.id,
|
|
456
|
+
})) as {
|
|
457
|
+
success: boolean;
|
|
458
|
+
action: Action;
|
|
459
|
+
edges: ActionEdge[];
|
|
460
|
+
children: Action[];
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
expect(result.success).toBe(true);
|
|
464
|
+
expect(result.action.id).toBe(parent.action.id);
|
|
465
|
+
expect(result.edges.length).toBe(1);
|
|
466
|
+
expect(result.edges[0].type).toBe("unlocks");
|
|
467
|
+
expect(result.children.length).toBe(1);
|
|
468
|
+
expect(result.children[0].id).toBe(child.action.id);
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
it("returns error for missing actionId", async () => {
|
|
472
|
+
const result = (await sdk.trigger("mem::action-get", {})) as {
|
|
473
|
+
success: boolean;
|
|
474
|
+
error: string;
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
expect(result.success).toBe(false);
|
|
478
|
+
expect(result.error).toContain("actionId is required");
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
it("returns error for nonexistent action", async () => {
|
|
482
|
+
const result = (await sdk.trigger("mem::action-get", {
|
|
483
|
+
actionId: "nonexistent",
|
|
484
|
+
})) as { success: boolean; error: string };
|
|
485
|
+
|
|
486
|
+
expect(result.success).toBe(false);
|
|
487
|
+
expect(result.error).toContain("action not found");
|
|
488
|
+
});
|
|
489
|
+
});
|
|
490
|
+
});
|