@remnic/plugin-openclaw 9.69.39 → 9.69.41
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/dist/index.js +610 -578
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -42,11 +42,11 @@ import {
|
|
|
42
42
|
sanitizeSessionKeyForFilename,
|
|
43
43
|
defaultWorkspaceDir
|
|
44
44
|
} from "@remnic/core/orchestrator";
|
|
45
|
-
import { beginCodexSubscriptionShutdown, getCodexSubscriptionRunnerForOwner } from "@remnic/core";
|
|
45
|
+
import { beginCodexSubscriptionShutdown, getCodexSubscriptionRunnerForOwner, terminateActiveCodexSubscriptionChildren } from "@remnic/core";
|
|
46
46
|
|
|
47
47
|
// ../../src/tools.ts
|
|
48
48
|
import { createHash as createHash2 } from "crypto";
|
|
49
|
-
import { Type } from "@sinclair/typebox";
|
|
49
|
+
import { Type as Type2 } from "@sinclair/typebox";
|
|
50
50
|
|
|
51
51
|
// ../../src/temporal-index.ts
|
|
52
52
|
var temporal_index_exports = {};
|
|
@@ -213,6 +213,10 @@ async function executeMemoryPromote(orchestrator, params) {
|
|
|
213
213
|
return `Promoted ${srcNs}:${memoryId} \u2192 ${dstNs}:${newId}`;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
// ../../src/shared-context-tools.ts
|
|
217
|
+
import { Type } from "@sinclair/typebox";
|
|
218
|
+
import { parseSharedWriteOutputControls } from "@remnic/core/shared-context/write-output-controls";
|
|
219
|
+
|
|
216
220
|
// ../../src/tool-write-origin.ts
|
|
217
221
|
var UNATTRIBUTED_TOOL_WRITE_ORIGIN = "unattributed:openclaw-host";
|
|
218
222
|
function openClawToolWriteOrigin(runtimeAgentId, requestedAgentId) {
|
|
@@ -223,6 +227,198 @@ function openClawToolWriteOrigin(runtimeAgentId, requestedAgentId) {
|
|
|
223
227
|
return { agentId: requestedAgentId, unattributedOrigin: UNATTRIBUTED_TOOL_WRITE_ORIGIN };
|
|
224
228
|
}
|
|
225
229
|
|
|
230
|
+
// ../../src/shared-context-tools.ts
|
|
231
|
+
function toolResult(text) {
|
|
232
|
+
return { content: [{ type: "text", text }], details: void 0 };
|
|
233
|
+
}
|
|
234
|
+
function registerSharedContextTools(api, orchestrator, hostRuntimeAgentId) {
|
|
235
|
+
api.registerTool(
|
|
236
|
+
{
|
|
237
|
+
name: "shared_context_write_output",
|
|
238
|
+
label: "Write Shared Agent Output",
|
|
239
|
+
description: "Write an agent work product into the shared-context directory (v4.0). Other agents can read these files to coordinate without explicit message passing.",
|
|
240
|
+
parameters: Type.Object({
|
|
241
|
+
// Provenance is server-derived from the host runtime agent; a
|
|
242
|
+
// mismatching value here is rejected, never used as the origin.
|
|
243
|
+
agentId: Type.String({ description: "Agent ID producing this output; must match this host's runtime agent id when the host exposes one." }),
|
|
244
|
+
title: Type.String({ description: "Short title for the output." }),
|
|
245
|
+
content: Type.String({ description: "Markdown content to write." }),
|
|
246
|
+
authority: Type.Optional(Type.String({
|
|
247
|
+
enum: ["informational", "advisory", "binding"],
|
|
248
|
+
description: "Envelope authority class. `binding` additionally requires the operator config `sharedContextAllowBindingAuthority: true`."
|
|
249
|
+
})),
|
|
250
|
+
expiresAt: Type.Optional(Type.String({
|
|
251
|
+
description: "ISO-8601 instant strictly after the write time and at most 10 years out. Past, invalid, or over-bound values are rejected."
|
|
252
|
+
})),
|
|
253
|
+
supersedes: Type.Optional(Type.String({
|
|
254
|
+
description: "Id of the shared item this output supersedes (non-empty, single line)."
|
|
255
|
+
}))
|
|
256
|
+
}),
|
|
257
|
+
async execute(_toolCallId, params) {
|
|
258
|
+
const { agentId, title, content } = params;
|
|
259
|
+
if (!orchestrator.sharedContext) {
|
|
260
|
+
return toolResult(
|
|
261
|
+
"Shared context is disabled. Enable `sharedContextEnabled: true` to use shared-context tools."
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
try {
|
|
265
|
+
const controls = parseSharedWriteOutputControls(params);
|
|
266
|
+
const fp = await orchestrator.sharedContext.writeAgentOutput({
|
|
267
|
+
title,
|
|
268
|
+
content,
|
|
269
|
+
...openClawToolWriteOrigin(hostRuntimeAgentId, agentId),
|
|
270
|
+
...controls
|
|
271
|
+
});
|
|
272
|
+
return toolResult(`Wrote shared agent output: ${fp}`);
|
|
273
|
+
} catch (err) {
|
|
274
|
+
return toolResult(`shared_context_write_output error: ${err instanceof Error ? err.message : String(err)}`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
{ name: "shared_context_write_output" }
|
|
279
|
+
);
|
|
280
|
+
api.registerTool(
|
|
281
|
+
{
|
|
282
|
+
name: "shared_feedback_record",
|
|
283
|
+
label: "Record Shared Feedback",
|
|
284
|
+
description: "Append an approval/rejection decision into shared-context feedback inbox (v4.0/v5.0). Intended to power compounding learning.",
|
|
285
|
+
parameters: Type.Object({
|
|
286
|
+
agent: Type.String({ description: "Agent name that produced the recommendation/output." }),
|
|
287
|
+
decision: Type.String({
|
|
288
|
+
enum: ["approved", "approved_with_feedback", "rejected"],
|
|
289
|
+
description: "Decision outcome."
|
|
290
|
+
}),
|
|
291
|
+
reason: Type.String({ description: "Why the decision was made (short but specific)." }),
|
|
292
|
+
date: Type.Optional(Type.String({ description: "ISO timestamp. Defaults to now." })),
|
|
293
|
+
learning: Type.Optional(Type.String({ description: "Optional distilled learning/pattern." })),
|
|
294
|
+
outcome: Type.Optional(Type.String({ description: "Optional downstream outcome (day-one supported; may be empty initially)." })),
|
|
295
|
+
severity: Type.Optional(Type.String({
|
|
296
|
+
enum: ["low", "medium", "high"],
|
|
297
|
+
description: "Optional severity rating for the mistake/outcome."
|
|
298
|
+
})),
|
|
299
|
+
confidence: Type.Optional(Type.Number({ description: "Optional confidence score from 0 to 1." })),
|
|
300
|
+
workflow: Type.Optional(Type.String({ description: "Optional workflow or playbook name associated with the feedback." })),
|
|
301
|
+
tags: Type.Optional(Type.Array(Type.String(), { description: "Optional tags for rubric grouping and recall matching." })),
|
|
302
|
+
evidenceWindowStart: Type.Optional(Type.String({ description: "Optional start timestamp for the evidence window." })),
|
|
303
|
+
evidenceWindowEnd: Type.Optional(Type.String({ description: "Optional end timestamp for the evidence window." })),
|
|
304
|
+
refs: Type.Optional(Type.Array(Type.String(), { description: "Optional references (URLs, IDs, filenames)." }))
|
|
305
|
+
}),
|
|
306
|
+
async execute(_toolCallId, params) {
|
|
307
|
+
if (!orchestrator.sharedContext) {
|
|
308
|
+
return toolResult(
|
|
309
|
+
"Shared context is disabled. Enable `sharedContextEnabled: true` to record shared feedback."
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
const p = params;
|
|
313
|
+
const isDecision = (v) => v === "approved" || v === "approved_with_feedback" || v === "rejected";
|
|
314
|
+
if (!isDecision(p.decision)) {
|
|
315
|
+
return toolResult(
|
|
316
|
+
"shared_feedback_record error: decision must be one of approved, approved_with_feedback, rejected"
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
const isSeverity = (v) => v === "low" || v === "medium" || v === "high";
|
|
320
|
+
const entry = {
|
|
321
|
+
agent: typeof p.agent === "string" ? p.agent : "",
|
|
322
|
+
decision: p.decision,
|
|
323
|
+
reason: typeof p.reason === "string" ? p.reason : "",
|
|
324
|
+
date: typeof p.date === "string" && p.date.length > 0 ? p.date : (/* @__PURE__ */ new Date()).toISOString(),
|
|
325
|
+
learning: typeof p.learning === "string" ? p.learning : void 0,
|
|
326
|
+
outcome: typeof p.outcome === "string" ? p.outcome : void 0,
|
|
327
|
+
severity: isSeverity(p.severity) ? p.severity : void 0,
|
|
328
|
+
confidence: typeof p.confidence === "number" && Number.isFinite(p.confidence) ? p.confidence : void 0,
|
|
329
|
+
workflow: typeof p.workflow === "string" ? p.workflow : void 0,
|
|
330
|
+
tags: Array.isArray(p.tags) ? p.tags.map(String) : void 0,
|
|
331
|
+
evidenceWindowStart: typeof p.evidenceWindowStart === "string" ? p.evidenceWindowStart : void 0,
|
|
332
|
+
evidenceWindowEnd: typeof p.evidenceWindowEnd === "string" ? p.evidenceWindowEnd : void 0,
|
|
333
|
+
refs: Array.isArray(p.refs) ? p.refs.map(String) : void 0
|
|
334
|
+
};
|
|
335
|
+
await orchestrator.sharedContext.appendFeedback(entry);
|
|
336
|
+
return toolResult("OK");
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
{ name: "shared_feedback_record" }
|
|
340
|
+
);
|
|
341
|
+
api.registerTool(
|
|
342
|
+
{
|
|
343
|
+
name: "shared_priorities_append",
|
|
344
|
+
label: "Append Priorities Inbox",
|
|
345
|
+
description: "Append text into shared-context priorities inbox. A curator run should merge this into priorities.md.",
|
|
346
|
+
parameters: Type.Object({
|
|
347
|
+
agentId: Type.String({ description: "Agent ID appending priorities." }),
|
|
348
|
+
text: Type.String({ description: "Priority notes to append (markdown)." })
|
|
349
|
+
}),
|
|
350
|
+
async execute(_toolCallId, params) {
|
|
351
|
+
if (!orchestrator.sharedContext) {
|
|
352
|
+
return toolResult(
|
|
353
|
+
"Shared context is disabled. Enable `sharedContextEnabled: true` to write priorities inbox."
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
const { agentId, text } = params;
|
|
357
|
+
await orchestrator.sharedContext.appendPrioritiesInbox({ agentId, text });
|
|
358
|
+
return toolResult("OK");
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
{ name: "shared_priorities_append" }
|
|
362
|
+
);
|
|
363
|
+
api.registerTool(
|
|
364
|
+
{
|
|
365
|
+
name: "shared_context_cross_signals_run",
|
|
366
|
+
label: "Run Cross-Signal Synthesis",
|
|
367
|
+
description: "Generate today's shared-context cross-signal markdown + JSON artifacts on demand, without requiring a full roundtable curation pass.",
|
|
368
|
+
parameters: Type.Object({
|
|
369
|
+
date: Type.Optional(Type.String({ description: "YYYY-MM-DD. Defaults to today." }))
|
|
370
|
+
}),
|
|
371
|
+
async execute(_toolCallId, params) {
|
|
372
|
+
if (!orchestrator.sharedContext) {
|
|
373
|
+
return toolResult(
|
|
374
|
+
"Shared context is disabled. Enable `sharedContextEnabled: true` to synthesize cross-signals."
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
const { date } = params;
|
|
378
|
+
const result = await orchestrator.sharedContext.synthesizeCrossSignals({ date });
|
|
379
|
+
return toolResult(
|
|
380
|
+
[
|
|
381
|
+
`Cross-signals markdown: ${result.crossSignalsMarkdownPath}`,
|
|
382
|
+
`Cross-signals JSON: ${result.crossSignalsPath}`,
|
|
383
|
+
`Source outputs analyzed: ${result.report.sourceCount}`,
|
|
384
|
+
`Feedback entries analyzed: ${result.report.feedbackCount}`,
|
|
385
|
+
`Overlap count: ${result.overlapCount}`
|
|
386
|
+
].join("\n")
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
{ name: "shared_context_cross_signals_run" }
|
|
391
|
+
);
|
|
392
|
+
api.registerTool(
|
|
393
|
+
{
|
|
394
|
+
name: "shared_context_curate_daily",
|
|
395
|
+
label: "Curate Daily Roundtable",
|
|
396
|
+
description: "Curator tool: generate today's roundtable summary in shared-context/roundtable (deterministic baseline).",
|
|
397
|
+
parameters: Type.Object({
|
|
398
|
+
date: Type.Optional(Type.String({ description: "YYYY-MM-DD. Defaults to today." }))
|
|
399
|
+
}),
|
|
400
|
+
async execute(_toolCallId, params) {
|
|
401
|
+
if (!orchestrator.sharedContext) {
|
|
402
|
+
return toolResult(
|
|
403
|
+
"Shared context is disabled. Enable `sharedContextEnabled: true` to curate roundtables."
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
const { date } = params;
|
|
407
|
+
const result = await orchestrator.sharedContext.curateDaily({ date });
|
|
408
|
+
return toolResult(
|
|
409
|
+
[
|
|
410
|
+
`Roundtable: ${result.roundtablePath}`,
|
|
411
|
+
`Cross-signals markdown: ${result.crossSignalsMarkdownPath}`,
|
|
412
|
+
`Cross-signals JSON: ${result.crossSignalsPath}`,
|
|
413
|
+
`Overlap count: ${result.overlapCount}`
|
|
414
|
+
].join("\n")
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
{ name: "shared_context_curate_daily" }
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
|
|
226
422
|
// ../../src/tools.ts
|
|
227
423
|
import { WorkStorage } from "@remnic/core/work/storage";
|
|
228
424
|
import { exportWorkBoardMarkdown, exportWorkBoardSnapshot, importWorkBoardSnapshot } from "@remnic/core/work/board";
|
|
@@ -279,15 +475,15 @@ function blocksSupportPassportMutation(action, memory) {
|
|
|
279
475
|
}
|
|
280
476
|
|
|
281
477
|
// ../../src/tools.ts
|
|
282
|
-
function
|
|
478
|
+
function toolResult2(text) {
|
|
283
479
|
return { content: [{ type: "text", text }], details: void 0 };
|
|
284
480
|
}
|
|
285
481
|
function toolJsonResult(value, options) {
|
|
286
482
|
const payload = JSON.stringify(value, null, 2);
|
|
287
|
-
return
|
|
483
|
+
return toolResult2(wrapWorkLayerContext(payload, { linkToMemory: options?.linkToMemory === true }));
|
|
288
484
|
}
|
|
289
485
|
function workLayerTextResult(text, options) {
|
|
290
|
-
return
|
|
486
|
+
return toolResult2(wrapWorkLayerContext(text, { linkToMemory: options?.linkToMemory === true }));
|
|
291
487
|
}
|
|
292
488
|
function asNonEmptyString(value) {
|
|
293
489
|
if (typeof value !== "string") return void 0;
|
|
@@ -512,7 +708,7 @@ function registerTools(api, orchestrator, hostRuntimeAgentId) {
|
|
|
512
708
|
const result = await persistExplicitCapture(orchestrator, candidate, source);
|
|
513
709
|
if (result.tombstoneBlocked) {
|
|
514
710
|
orchestrator.requestQmdMaintenanceForTool(maintenanceReason);
|
|
515
|
-
return
|
|
711
|
+
return toolResult2(
|
|
516
712
|
`Memory queued for review (tombstone-blocked): ${result.id}${candidate.namespace ? ` (namespace: ${candidate.namespace})` : ""} \u2014 no active copy was created.
|
|
517
713
|
|
|
518
714
|
Content: ${candidate.content}`
|
|
@@ -526,7 +722,7 @@ Content: ${candidate.content}`
|
|
|
526
722
|
}
|
|
527
723
|
}
|
|
528
724
|
orchestrator.requestQmdMaintenanceForTool(maintenanceReason);
|
|
529
|
-
return
|
|
725
|
+
return toolResult2(
|
|
530
726
|
result.duplicateOf ? `Memory already exists: ${result.duplicateOf}${candidate.namespace ? ` (namespace: ${candidate.namespace})` : ""}
|
|
531
727
|
|
|
532
728
|
Content: ${candidate.content}` : `Memory stored: ${result.id}${candidate.namespace ? ` (namespace: ${candidate.namespace})` : ""}
|
|
@@ -537,7 +733,7 @@ Content: ${candidate.content}`
|
|
|
537
733
|
try {
|
|
538
734
|
const queued = await queueExplicitCaptureForReview(orchestrator, rawInput, source, error);
|
|
539
735
|
orchestrator.requestQmdMaintenanceForTool(`${maintenanceReason}.review`);
|
|
540
|
-
return
|
|
736
|
+
return toolResult2(
|
|
541
737
|
queued.duplicateOf ? `Memory already queued for review: ${queued.duplicateOf}${namespace ? ` (namespace: ${namespace})` : ""}
|
|
542
738
|
|
|
543
739
|
Content: ${content}` : `Memory queued for review: ${queued.id}${namespace ? ` (namespace: ${namespace})` : ""}
|
|
@@ -546,7 +742,7 @@ Content: ${content}`
|
|
|
546
742
|
);
|
|
547
743
|
} catch (queueError) {
|
|
548
744
|
logger_exports.log.warn(`explicit tool capture rejected: ${error}; review queue fallback failed: ${queueError}`);
|
|
549
|
-
return
|
|
745
|
+
return toolResult2(`Memory capture failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
550
746
|
}
|
|
551
747
|
}
|
|
552
748
|
}
|
|
@@ -565,24 +761,24 @@ Best for:
|
|
|
565
761
|
- Finding previously learned facts about the user
|
|
566
762
|
- Checking what you know about a topic
|
|
567
763
|
- Locating past decisions or corrections`,
|
|
568
|
-
parameters:
|
|
569
|
-
query:
|
|
764
|
+
parameters: Type2.Object({
|
|
765
|
+
query: Type2.String({
|
|
570
766
|
description: "Search query \u2014 keywords, phrases, or natural language"
|
|
571
767
|
}),
|
|
572
|
-
namespace:
|
|
573
|
-
|
|
768
|
+
namespace: Type2.Optional(
|
|
769
|
+
Type2.String({
|
|
574
770
|
description: "Optional namespace filter. When set, only returns results under memoryDir/namespaces/<namespace>/ (default namespace uses legacy root)."
|
|
575
771
|
})
|
|
576
772
|
),
|
|
577
|
-
maxResults:
|
|
578
|
-
|
|
773
|
+
maxResults: Type2.Optional(
|
|
774
|
+
Type2.Number({
|
|
579
775
|
description: "Maximum results (default: 8)",
|
|
580
776
|
minimum: 1,
|
|
581
777
|
maximum: 50
|
|
582
778
|
})
|
|
583
779
|
),
|
|
584
|
-
collection:
|
|
585
|
-
|
|
780
|
+
collection: Type2.Optional(
|
|
781
|
+
Type2.String({
|
|
586
782
|
description: "QMD collection to search. Omit for memory collection, use 'global' for all collections."
|
|
587
783
|
})
|
|
588
784
|
)
|
|
@@ -625,7 +821,7 @@ Best for:
|
|
|
625
821
|
}
|
|
626
822
|
filtered = filtered.slice(0, resultLimit);
|
|
627
823
|
if (filtered.length === 0) {
|
|
628
|
-
return
|
|
824
|
+
return toolResult2(`No memories found matching: "${query}"`);
|
|
629
825
|
}
|
|
630
826
|
const formatted = filtered.map((r, i) => {
|
|
631
827
|
const snippet = r.snippet ? r.snippet.slice(0, 800) : "(no preview)";
|
|
@@ -636,7 +832,7 @@ Score: ${r.score.toFixed(3)}
|
|
|
636
832
|
${snippet}
|
|
637
833
|
\`\`\``;
|
|
638
834
|
}).join("\n\n");
|
|
639
|
-
return
|
|
835
|
+
return toolResult2(
|
|
640
836
|
`## Memory Search: "${query}"
|
|
641
837
|
|
|
642
838
|
${filtered.length} result(s)
|
|
@@ -653,32 +849,32 @@ ${formatted}`
|
|
|
653
849
|
name: "continuity_audit_generate",
|
|
654
850
|
label: "Generate Continuity Audit",
|
|
655
851
|
description: "Generate a deterministic identity continuity audit report (weekly/monthly) and persist it under identity/audits.",
|
|
656
|
-
parameters:
|
|
657
|
-
period:
|
|
658
|
-
|
|
852
|
+
parameters: Type2.Object({
|
|
853
|
+
period: Type2.Optional(
|
|
854
|
+
Type2.String({
|
|
659
855
|
enum: ["weekly", "monthly"],
|
|
660
856
|
description: "Audit period. Defaults to weekly."
|
|
661
857
|
})
|
|
662
858
|
),
|
|
663
|
-
key:
|
|
664
|
-
|
|
859
|
+
key: Type2.Optional(
|
|
860
|
+
Type2.String({
|
|
665
861
|
description: "Optional period key (weekly: YYYY-Www, monthly: YYYY-MM). Defaults to current period."
|
|
666
862
|
})
|
|
667
863
|
)
|
|
668
864
|
}),
|
|
669
865
|
async execute(_toolCallId, params) {
|
|
670
866
|
if (!orchestrator.config.identityContinuityEnabled) {
|
|
671
|
-
return
|
|
867
|
+
return toolResult2(
|
|
672
868
|
"Identity continuity is disabled. Enable `identityContinuityEnabled: true` to generate continuity audits."
|
|
673
869
|
);
|
|
674
870
|
}
|
|
675
871
|
if (!orchestrator.config.continuityAuditEnabled) {
|
|
676
|
-
return
|
|
872
|
+
return toolResult2(
|
|
677
873
|
"Continuity audits are disabled. Enable `continuityAuditEnabled: true` to generate continuity audits."
|
|
678
874
|
);
|
|
679
875
|
}
|
|
680
876
|
if (!orchestrator.compounding) {
|
|
681
|
-
return
|
|
877
|
+
return toolResult2(
|
|
682
878
|
"Compounding engine is disabled. Enable `compoundingEnabled: true` to generate continuity audits."
|
|
683
879
|
);
|
|
684
880
|
}
|
|
@@ -688,7 +884,7 @@ ${formatted}`
|
|
|
688
884
|
period,
|
|
689
885
|
key
|
|
690
886
|
});
|
|
691
|
-
return
|
|
887
|
+
return toolResult2(
|
|
692
888
|
`OK
|
|
693
889
|
|
|
694
890
|
period: ${audit.period}
|
|
@@ -704,40 +900,40 @@ report: ${audit.reportPath}`
|
|
|
704
900
|
name: "continuity_incident_open",
|
|
705
901
|
label: "Open Continuity Incident",
|
|
706
902
|
description: "Create a new continuity incident record in append-only storage.",
|
|
707
|
-
parameters:
|
|
708
|
-
symptom:
|
|
903
|
+
parameters: Type2.Object({
|
|
904
|
+
symptom: Type2.String({
|
|
709
905
|
description: "Observed continuity failure symptom."
|
|
710
906
|
}),
|
|
711
|
-
namespace:
|
|
712
|
-
|
|
907
|
+
namespace: Type2.Optional(
|
|
908
|
+
Type2.String({
|
|
713
909
|
description: "Optional namespace override. Defaults to the default namespace."
|
|
714
910
|
})
|
|
715
911
|
),
|
|
716
|
-
triggerWindow:
|
|
717
|
-
|
|
912
|
+
triggerWindow: Type2.Optional(
|
|
913
|
+
Type2.String({
|
|
718
914
|
description: "Optional time window when incident occurred."
|
|
719
915
|
})
|
|
720
916
|
),
|
|
721
|
-
suspectedCause:
|
|
722
|
-
|
|
917
|
+
suspectedCause: Type2.Optional(
|
|
918
|
+
Type2.String({
|
|
723
919
|
description: "Optional suspected root cause."
|
|
724
920
|
})
|
|
725
921
|
)
|
|
726
922
|
}),
|
|
727
923
|
async execute(_toolCallId, params) {
|
|
728
924
|
if (!orchestrator.config.identityContinuityEnabled) {
|
|
729
|
-
return
|
|
925
|
+
return toolResult2(
|
|
730
926
|
"Identity continuity is disabled. Enable `identityContinuityEnabled: true` to open incidents."
|
|
731
927
|
);
|
|
732
928
|
}
|
|
733
929
|
if (!orchestrator.config.continuityIncidentLoggingEnabled) {
|
|
734
|
-
return
|
|
930
|
+
return toolResult2(
|
|
735
931
|
"Continuity incident logging is disabled. Enable `continuityIncidentLoggingEnabled: true` to open incidents."
|
|
736
932
|
);
|
|
737
933
|
}
|
|
738
934
|
const symptom = typeof params.symptom === "string" ? params.symptom.trim() : "";
|
|
739
935
|
if (!symptom) {
|
|
740
|
-
return
|
|
936
|
+
return toolResult2("Missing required field: symptom");
|
|
741
937
|
}
|
|
742
938
|
const storage = await orchestrator.getStorageForNamespace(
|
|
743
939
|
normalizeToolNamespace(params.namespace)
|
|
@@ -748,7 +944,7 @@ report: ${audit.reportPath}`
|
|
|
748
944
|
suspectedCause: typeof params.suspectedCause === "string" ? params.suspectedCause : void 0
|
|
749
945
|
});
|
|
750
946
|
logger_exports.log.info(`continuity-incident open id=${created.id}`);
|
|
751
|
-
return
|
|
947
|
+
return toolResult2(`Continuity incident opened.
|
|
752
948
|
|
|
753
949
|
${formatContinuityIncidentSummary(created)}`);
|
|
754
950
|
}
|
|
@@ -760,35 +956,35 @@ ${formatContinuityIncidentSummary(created)}`);
|
|
|
760
956
|
name: "continuity_incident_close",
|
|
761
957
|
label: "Close Continuity Incident",
|
|
762
958
|
description: "Close an open continuity incident with required verification details.",
|
|
763
|
-
parameters:
|
|
764
|
-
id:
|
|
959
|
+
parameters: Type2.Object({
|
|
960
|
+
id: Type2.String({
|
|
765
961
|
description: "Incident ID to close."
|
|
766
962
|
}),
|
|
767
|
-
namespace:
|
|
768
|
-
|
|
963
|
+
namespace: Type2.Optional(
|
|
964
|
+
Type2.String({
|
|
769
965
|
description: "Optional namespace override. Defaults to the default namespace."
|
|
770
966
|
})
|
|
771
967
|
),
|
|
772
|
-
fixApplied:
|
|
968
|
+
fixApplied: Type2.String({
|
|
773
969
|
description: "What fix was applied."
|
|
774
970
|
}),
|
|
775
|
-
verificationResult:
|
|
971
|
+
verificationResult: Type2.String({
|
|
776
972
|
description: "How closure was verified."
|
|
777
973
|
}),
|
|
778
|
-
preventiveRule:
|
|
779
|
-
|
|
974
|
+
preventiveRule: Type2.Optional(
|
|
975
|
+
Type2.String({
|
|
780
976
|
description: "Optional preventive follow-up rule."
|
|
781
977
|
})
|
|
782
978
|
)
|
|
783
979
|
}),
|
|
784
980
|
async execute(_toolCallId, params) {
|
|
785
981
|
if (!orchestrator.config.identityContinuityEnabled) {
|
|
786
|
-
return
|
|
982
|
+
return toolResult2(
|
|
787
983
|
"Identity continuity is disabled. Enable `identityContinuityEnabled: true` to close incidents."
|
|
788
984
|
);
|
|
789
985
|
}
|
|
790
986
|
if (!orchestrator.config.continuityIncidentLoggingEnabled) {
|
|
791
|
-
return
|
|
987
|
+
return toolResult2(
|
|
792
988
|
"Continuity incident logging is disabled. Enable `continuityIncidentLoggingEnabled: true` to close incidents."
|
|
793
989
|
);
|
|
794
990
|
}
|
|
@@ -796,9 +992,9 @@ ${formatContinuityIncidentSummary(created)}`);
|
|
|
796
992
|
const fixApplied = typeof params.fixApplied === "string" ? params.fixApplied.trim() : "";
|
|
797
993
|
const verificationResult = typeof params.verificationResult === "string" ? params.verificationResult.trim() : "";
|
|
798
994
|
const preventiveRule = typeof params.preventiveRule === "string" ? params.preventiveRule.trim() : void 0;
|
|
799
|
-
if (!id) return
|
|
800
|
-
if (!fixApplied) return
|
|
801
|
-
if (!verificationResult) return
|
|
995
|
+
if (!id) return toolResult2("Missing required field: id");
|
|
996
|
+
if (!fixApplied) return toolResult2("Missing required field: fixApplied");
|
|
997
|
+
if (!verificationResult) return toolResult2("Missing required field: verificationResult");
|
|
802
998
|
const storage = await orchestrator.getStorageForNamespace(
|
|
803
999
|
normalizeToolNamespace(params.namespace)
|
|
804
1000
|
);
|
|
@@ -807,9 +1003,9 @@ ${formatContinuityIncidentSummary(created)}`);
|
|
|
807
1003
|
verificationResult,
|
|
808
1004
|
preventiveRule
|
|
809
1005
|
});
|
|
810
|
-
if (!closed) return
|
|
1006
|
+
if (!closed) return toolResult2(`Incident not found: ${id}`);
|
|
811
1007
|
logger_exports.log.info(`continuity-incident close id=${id}`);
|
|
812
|
-
return
|
|
1008
|
+
return toolResult2(`Continuity incident closed.
|
|
813
1009
|
|
|
814
1010
|
${formatContinuityIncidentSummary(closed)}`);
|
|
815
1011
|
}
|
|
@@ -821,20 +1017,20 @@ ${formatContinuityIncidentSummary(closed)}`);
|
|
|
821
1017
|
name: "continuity_incident_list",
|
|
822
1018
|
label: "List Continuity Incidents",
|
|
823
1019
|
description: "List continuity incidents and optionally filter by state.",
|
|
824
|
-
parameters:
|
|
825
|
-
state:
|
|
826
|
-
|
|
1020
|
+
parameters: Type2.Object({
|
|
1021
|
+
state: Type2.Optional(
|
|
1022
|
+
Type2.String({
|
|
827
1023
|
enum: ["open", "closed", "all"],
|
|
828
1024
|
description: "Incident state filter (default: open)."
|
|
829
1025
|
})
|
|
830
1026
|
),
|
|
831
|
-
namespace:
|
|
832
|
-
|
|
1027
|
+
namespace: Type2.Optional(
|
|
1028
|
+
Type2.String({
|
|
833
1029
|
description: "Optional namespace override. Defaults to the default namespace."
|
|
834
1030
|
})
|
|
835
1031
|
),
|
|
836
|
-
limit:
|
|
837
|
-
|
|
1032
|
+
limit: Type2.Optional(
|
|
1033
|
+
Type2.Number({
|
|
838
1034
|
description: "Max incidents to return (default: 25, max: 200).",
|
|
839
1035
|
minimum: 1,
|
|
840
1036
|
maximum: 200
|
|
@@ -843,7 +1039,7 @@ ${formatContinuityIncidentSummary(closed)}`);
|
|
|
843
1039
|
}),
|
|
844
1040
|
async execute(_toolCallId, params) {
|
|
845
1041
|
if (!orchestrator.config.identityContinuityEnabled) {
|
|
846
|
-
return
|
|
1042
|
+
return toolResult2(
|
|
847
1043
|
"Identity continuity is disabled. Enable `identityContinuityEnabled: true` to list incidents."
|
|
848
1044
|
);
|
|
849
1045
|
}
|
|
@@ -855,10 +1051,10 @@ ${formatContinuityIncidentSummary(closed)}`);
|
|
|
855
1051
|
);
|
|
856
1052
|
const filtered = await storage.readContinuityIncidents(limit, state);
|
|
857
1053
|
if (filtered.length === 0) {
|
|
858
|
-
return
|
|
1054
|
+
return toolResult2(`No continuity incidents found for state=${state}.`);
|
|
859
1055
|
}
|
|
860
1056
|
const body = filtered.map((incident, index) => formatContinuityIncidentSummary(incident, index)).join("\n\n");
|
|
861
|
-
return
|
|
1057
|
+
return toolResult2(`## Continuity Incidents (${filtered.length}, state=${state})
|
|
862
1058
|
|
|
863
1059
|
${body}`);
|
|
864
1060
|
}
|
|
@@ -870,43 +1066,43 @@ ${body}`);
|
|
|
870
1066
|
name: "continuity_loop_add_or_update",
|
|
871
1067
|
label: "Add or Update Continuity Loop",
|
|
872
1068
|
description: "Add or update a continuity improvement loop entry in identity/improvement-loops.md.",
|
|
873
|
-
parameters:
|
|
874
|
-
id:
|
|
1069
|
+
parameters: Type2.Object({
|
|
1070
|
+
id: Type2.String({
|
|
875
1071
|
description: "Stable loop identifier."
|
|
876
1072
|
}),
|
|
877
|
-
namespace:
|
|
878
|
-
|
|
1073
|
+
namespace: Type2.Optional(
|
|
1074
|
+
Type2.String({
|
|
879
1075
|
description: "Optional namespace override. Defaults to the default namespace."
|
|
880
1076
|
})
|
|
881
1077
|
),
|
|
882
|
-
cadence:
|
|
1078
|
+
cadence: Type2.String({
|
|
883
1079
|
enum: ["daily", "weekly", "monthly", "quarterly"],
|
|
884
1080
|
description: "Review cadence."
|
|
885
1081
|
}),
|
|
886
|
-
purpose:
|
|
1082
|
+
purpose: Type2.String({
|
|
887
1083
|
description: "What this recurring loop improves."
|
|
888
1084
|
}),
|
|
889
|
-
status:
|
|
1085
|
+
status: Type2.String({
|
|
890
1086
|
enum: ["active", "paused", "retired"],
|
|
891
1087
|
description: "Current lifecycle status for the loop."
|
|
892
1088
|
}),
|
|
893
|
-
killCondition:
|
|
1089
|
+
killCondition: Type2.String({
|
|
894
1090
|
description: "Clear condition for retiring this loop."
|
|
895
1091
|
}),
|
|
896
|
-
lastReviewed:
|
|
897
|
-
|
|
1092
|
+
lastReviewed: Type2.Optional(
|
|
1093
|
+
Type2.String({
|
|
898
1094
|
description: "Optional ISO timestamp for last review. Defaults to now."
|
|
899
1095
|
})
|
|
900
1096
|
),
|
|
901
|
-
notes:
|
|
902
|
-
|
|
1097
|
+
notes: Type2.Optional(
|
|
1098
|
+
Type2.String({
|
|
903
1099
|
description: "Optional operator notes."
|
|
904
1100
|
})
|
|
905
1101
|
)
|
|
906
1102
|
}),
|
|
907
1103
|
async execute(_toolCallId, params) {
|
|
908
1104
|
if (!orchestrator.config.identityContinuityEnabled) {
|
|
909
|
-
return
|
|
1105
|
+
return toolResult2(
|
|
910
1106
|
"Identity continuity is disabled. Enable `identityContinuityEnabled: true` to manage continuity loops."
|
|
911
1107
|
);
|
|
912
1108
|
}
|
|
@@ -924,11 +1120,11 @@ ${body}`);
|
|
|
924
1120
|
notes: typeof params.notes === "string" ? params.notes : void 0
|
|
925
1121
|
});
|
|
926
1122
|
logger_exports.log.info(`continuity-loop upsert id=${loop.id} status=${loop.status}`);
|
|
927
|
-
return
|
|
1123
|
+
return toolResult2(`Continuity loop saved.
|
|
928
1124
|
|
|
929
1125
|
${formatContinuityLoopSummary(loop)}`);
|
|
930
1126
|
} catch (err) {
|
|
931
|
-
return
|
|
1127
|
+
return toolResult2(`Failed to save continuity loop: ${String(err)}`);
|
|
932
1128
|
}
|
|
933
1129
|
}
|
|
934
1130
|
},
|
|
@@ -939,40 +1135,40 @@ ${formatContinuityLoopSummary(loop)}`);
|
|
|
939
1135
|
name: "continuity_loop_review",
|
|
940
1136
|
label: "Review Continuity Loop",
|
|
941
1137
|
description: "Update review metadata (lastReviewed/status/notes) for an existing continuity loop.",
|
|
942
|
-
parameters:
|
|
943
|
-
id:
|
|
1138
|
+
parameters: Type2.Object({
|
|
1139
|
+
id: Type2.String({
|
|
944
1140
|
description: "Loop ID to review."
|
|
945
1141
|
}),
|
|
946
|
-
namespace:
|
|
947
|
-
|
|
1142
|
+
namespace: Type2.Optional(
|
|
1143
|
+
Type2.String({
|
|
948
1144
|
description: "Optional namespace override. Defaults to the default namespace."
|
|
949
1145
|
})
|
|
950
1146
|
),
|
|
951
|
-
status:
|
|
952
|
-
|
|
1147
|
+
status: Type2.Optional(
|
|
1148
|
+
Type2.String({
|
|
953
1149
|
enum: ["active", "paused", "retired"],
|
|
954
1150
|
description: "Optional status update."
|
|
955
1151
|
})
|
|
956
1152
|
),
|
|
957
|
-
notes:
|
|
958
|
-
|
|
1153
|
+
notes: Type2.Optional(
|
|
1154
|
+
Type2.String({
|
|
959
1155
|
description: "Optional notes update."
|
|
960
1156
|
})
|
|
961
1157
|
),
|
|
962
|
-
reviewedAt:
|
|
963
|
-
|
|
1158
|
+
reviewedAt: Type2.Optional(
|
|
1159
|
+
Type2.String({
|
|
964
1160
|
description: "Optional ISO timestamp for review event. Defaults to now."
|
|
965
1161
|
})
|
|
966
1162
|
)
|
|
967
1163
|
}),
|
|
968
1164
|
async execute(_toolCallId, params) {
|
|
969
1165
|
if (!orchestrator.config.identityContinuityEnabled) {
|
|
970
|
-
return
|
|
1166
|
+
return toolResult2(
|
|
971
1167
|
"Identity continuity is disabled. Enable `identityContinuityEnabled: true` to manage continuity loops."
|
|
972
1168
|
);
|
|
973
1169
|
}
|
|
974
1170
|
const id = typeof params.id === "string" ? params.id.trim() : "";
|
|
975
|
-
if (!id) return
|
|
1171
|
+
if (!id) return toolResult2("Missing required field: id");
|
|
976
1172
|
try {
|
|
977
1173
|
const storage = await orchestrator.getStorageForNamespace(
|
|
978
1174
|
normalizeToolNamespace(params.namespace)
|
|
@@ -982,13 +1178,13 @@ ${formatContinuityLoopSummary(loop)}`);
|
|
|
982
1178
|
notes: typeof params.notes === "string" ? params.notes : void 0,
|
|
983
1179
|
reviewedAt: typeof params.reviewedAt === "string" ? params.reviewedAt : void 0
|
|
984
1180
|
});
|
|
985
|
-
if (!reviewed) return
|
|
1181
|
+
if (!reviewed) return toolResult2(`Continuity loop not found: ${id}`);
|
|
986
1182
|
logger_exports.log.info(`continuity-loop review id=${id} status=${reviewed.status}`);
|
|
987
|
-
return
|
|
1183
|
+
return toolResult2(`Continuity loop reviewed.
|
|
988
1184
|
|
|
989
1185
|
${formatContinuityLoopSummary(reviewed)}`);
|
|
990
1186
|
} catch (err) {
|
|
991
|
-
return
|
|
1187
|
+
return toolResult2(`Failed to review continuity loop: ${String(err)}`);
|
|
992
1188
|
}
|
|
993
1189
|
}
|
|
994
1190
|
},
|
|
@@ -999,16 +1195,16 @@ ${formatContinuityLoopSummary(reviewed)}`);
|
|
|
999
1195
|
name: "identity_anchor_get",
|
|
1000
1196
|
label: "Get Identity Anchor",
|
|
1001
1197
|
description: "Read the identity continuity anchor document used for recovery-safe identity context.",
|
|
1002
|
-
parameters:
|
|
1003
|
-
namespace:
|
|
1004
|
-
|
|
1198
|
+
parameters: Type2.Object({
|
|
1199
|
+
namespace: Type2.Optional(
|
|
1200
|
+
Type2.String({
|
|
1005
1201
|
description: "Optional namespace override. Defaults to the default namespace."
|
|
1006
1202
|
})
|
|
1007
1203
|
)
|
|
1008
1204
|
}),
|
|
1009
1205
|
async execute(_toolCallId, params) {
|
|
1010
1206
|
if (!orchestrator.config.identityContinuityEnabled) {
|
|
1011
|
-
return
|
|
1207
|
+
return toolResult2(
|
|
1012
1208
|
"Identity continuity is disabled. Enable `identityContinuityEnabled: true` to use identity anchor tools."
|
|
1013
1209
|
);
|
|
1014
1210
|
}
|
|
@@ -1017,11 +1213,11 @@ ${formatContinuityLoopSummary(reviewed)}`);
|
|
|
1017
1213
|
);
|
|
1018
1214
|
const anchor = await storage.readIdentityAnchor();
|
|
1019
1215
|
if (!anchor) {
|
|
1020
|
-
return
|
|
1216
|
+
return toolResult2(
|
|
1021
1217
|
"No identity anchor found yet. Use `identity_anchor_update` to create one."
|
|
1022
1218
|
);
|
|
1023
1219
|
}
|
|
1024
|
-
return
|
|
1220
|
+
return toolResult2(`## Identity Anchor
|
|
1025
1221
|
|
|
1026
1222
|
${anchor}`);
|
|
1027
1223
|
}
|
|
@@ -1033,36 +1229,36 @@ ${anchor}`);
|
|
|
1033
1229
|
name: "identity_anchor_update",
|
|
1034
1230
|
label: "Update Identity Anchor",
|
|
1035
1231
|
description: "Conservatively update identity anchor sections without overwriting existing material.",
|
|
1036
|
-
parameters:
|
|
1037
|
-
namespace:
|
|
1038
|
-
|
|
1232
|
+
parameters: Type2.Object({
|
|
1233
|
+
namespace: Type2.Optional(
|
|
1234
|
+
Type2.String({
|
|
1039
1235
|
description: "Optional namespace override. Defaults to the default namespace."
|
|
1040
1236
|
})
|
|
1041
1237
|
),
|
|
1042
|
-
identityTraits:
|
|
1043
|
-
|
|
1238
|
+
identityTraits: Type2.Optional(
|
|
1239
|
+
Type2.String({
|
|
1044
1240
|
description: "Updates for the 'Identity Traits' section."
|
|
1045
1241
|
})
|
|
1046
1242
|
),
|
|
1047
|
-
communicationPreferences:
|
|
1048
|
-
|
|
1243
|
+
communicationPreferences: Type2.Optional(
|
|
1244
|
+
Type2.String({
|
|
1049
1245
|
description: "Updates for the 'Communication Preferences' section."
|
|
1050
1246
|
})
|
|
1051
1247
|
),
|
|
1052
|
-
operatingPrinciples:
|
|
1053
|
-
|
|
1248
|
+
operatingPrinciples: Type2.Optional(
|
|
1249
|
+
Type2.String({
|
|
1054
1250
|
description: "Updates for the 'Operating Principles' section."
|
|
1055
1251
|
})
|
|
1056
1252
|
),
|
|
1057
|
-
continuityNotes:
|
|
1058
|
-
|
|
1253
|
+
continuityNotes: Type2.Optional(
|
|
1254
|
+
Type2.String({
|
|
1059
1255
|
description: "Updates for the 'Continuity Notes' section."
|
|
1060
1256
|
})
|
|
1061
1257
|
)
|
|
1062
1258
|
}),
|
|
1063
1259
|
async execute(_toolCallId, params) {
|
|
1064
1260
|
if (!orchestrator.config.identityContinuityEnabled) {
|
|
1065
|
-
return
|
|
1261
|
+
return toolResult2(
|
|
1066
1262
|
"Identity continuity is disabled. Enable `identityContinuityEnabled: true` to use identity anchor tools."
|
|
1067
1263
|
);
|
|
1068
1264
|
}
|
|
@@ -1076,7 +1272,7 @@ ${anchor}`);
|
|
|
1076
1272
|
(value) => typeof value === "string" && value.trim().length > 0
|
|
1077
1273
|
);
|
|
1078
1274
|
if (!hasUpdate) {
|
|
1079
|
-
return
|
|
1275
|
+
return toolResult2(
|
|
1080
1276
|
"No updates provided. Supply at least one section field to update the identity anchor."
|
|
1081
1277
|
);
|
|
1082
1278
|
}
|
|
@@ -1090,7 +1286,7 @@ ${anchor}`);
|
|
|
1090
1286
|
logger_exports.log.info(
|
|
1091
1287
|
`identity-anchor update sections=${updatedSections.join(",")} chars=${merged.length}`
|
|
1092
1288
|
);
|
|
1093
|
-
return
|
|
1289
|
+
return toolResult2(
|
|
1094
1290
|
`Identity anchor updated (${updatedSections.length} section${updatedSections.length === 1 ? "" : "s"}).
|
|
1095
1291
|
|
|
1096
1292
|
${merged}`
|
|
@@ -1104,16 +1300,16 @@ ${merged}`
|
|
|
1104
1300
|
name: "memory_feedback",
|
|
1105
1301
|
label: "Memory Feedback",
|
|
1106
1302
|
description: "Thumbs up/down a memory's relevance. Stored locally and used as a soft ranking bias when enabled.",
|
|
1107
|
-
parameters:
|
|
1108
|
-
memoryId:
|
|
1303
|
+
parameters: Type2.Object({
|
|
1304
|
+
memoryId: Type2.String({
|
|
1109
1305
|
description: "Memory ID (filename without .md), e.g. fact-123"
|
|
1110
1306
|
}),
|
|
1111
|
-
vote:
|
|
1307
|
+
vote: Type2.String({
|
|
1112
1308
|
enum: ["up", "down"],
|
|
1113
1309
|
description: "up or down"
|
|
1114
1310
|
}),
|
|
1115
|
-
note:
|
|
1116
|
-
|
|
1311
|
+
note: Type2.Optional(
|
|
1312
|
+
Type2.String({
|
|
1117
1313
|
description: "Optional note explaining the feedback (stored locally)."
|
|
1118
1314
|
})
|
|
1119
1315
|
)
|
|
@@ -1121,12 +1317,12 @@ ${merged}`
|
|
|
1121
1317
|
async execute(_toolCallId, params) {
|
|
1122
1318
|
const { memoryId, vote, note } = params;
|
|
1123
1319
|
if (!orchestrator.config.feedbackEnabled) {
|
|
1124
|
-
return
|
|
1320
|
+
return toolResult2(
|
|
1125
1321
|
"Feedback is disabled. Enable `feedbackEnabled: true` in the Engram plugin config to store feedback."
|
|
1126
1322
|
);
|
|
1127
1323
|
}
|
|
1128
1324
|
await orchestrator.recordMemoryFeedback(memoryId, vote, note);
|
|
1129
|
-
return
|
|
1325
|
+
return toolResult2(
|
|
1130
1326
|
`Recorded feedback for ${memoryId}: ${vote}${note ? ` (note: ${note})` : ""}`
|
|
1131
1327
|
);
|
|
1132
1328
|
}
|
|
@@ -1138,9 +1334,9 @@ ${merged}`
|
|
|
1138
1334
|
name: "memory_last_recall",
|
|
1139
1335
|
label: "Last Recall Snapshot",
|
|
1140
1336
|
description: "Fetch the last set of memory IDs that were injected into context for a session. Useful when the user says things like 'why did you say that?' or 'that's not right' and you want to identify which memories may have misled the response.",
|
|
1141
|
-
parameters:
|
|
1142
|
-
sessionKey:
|
|
1143
|
-
|
|
1337
|
+
parameters: Type2.Object({
|
|
1338
|
+
sessionKey: Type2.Optional(
|
|
1339
|
+
Type2.String({
|
|
1144
1340
|
description: "Session key to look up. If omitted, returns the most recent snapshot across all sessions (may be wrong under concurrency)."
|
|
1145
1341
|
})
|
|
1146
1342
|
)
|
|
@@ -1149,12 +1345,12 @@ ${merged}`
|
|
|
1149
1345
|
const { sessionKey } = params;
|
|
1150
1346
|
const snap = sessionKey ? orchestrator.lastRecall.get(sessionKey) : orchestrator.lastRecall.getMostRecent();
|
|
1151
1347
|
if (!snap) {
|
|
1152
|
-
return
|
|
1348
|
+
return toolResult2("No last-recall snapshot found yet.");
|
|
1153
1349
|
}
|
|
1154
1350
|
const prefix = sessionKey ? `## Last Recall (${snap.sessionKey})` : `## Last Recall (most recent: ${snap.sessionKey})
|
|
1155
1351
|
|
|
1156
1352
|
NOTE: You did not provide sessionKey; under concurrency this may not match your current session.`;
|
|
1157
|
-
return
|
|
1353
|
+
return toolResult2(
|
|
1158
1354
|
[
|
|
1159
1355
|
prefix,
|
|
1160
1356
|
"",
|
|
@@ -1174,9 +1370,9 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1174
1370
|
name: "memory_intent_debug",
|
|
1175
1371
|
label: "Inspect Intent Debug",
|
|
1176
1372
|
description: "Inspect the last persisted planner/intent snapshot, including recall mode selection, query intent classification, and graph fallback decisions.",
|
|
1177
|
-
parameters:
|
|
1178
|
-
namespace:
|
|
1179
|
-
|
|
1373
|
+
parameters: Type2.Object({
|
|
1374
|
+
namespace: Type2.Optional(
|
|
1375
|
+
Type2.String({
|
|
1180
1376
|
description: "Optional namespace to inspect. Defaults to defaultNamespace."
|
|
1181
1377
|
})
|
|
1182
1378
|
)
|
|
@@ -1186,7 +1382,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1186
1382
|
const text = await orchestrator.recallIntrospection.explainLastIntent({
|
|
1187
1383
|
namespace
|
|
1188
1384
|
});
|
|
1189
|
-
return
|
|
1385
|
+
return toolResult2(text);
|
|
1190
1386
|
}
|
|
1191
1387
|
},
|
|
1192
1388
|
{ name: "memory_intent_debug" }
|
|
@@ -1196,14 +1392,14 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1196
1392
|
name: "memory_qmd_debug",
|
|
1197
1393
|
label: "Inspect QMD Recall",
|
|
1198
1394
|
description: "Inspect the last persisted QMD recall snapshot, including any intent hint, explain trace capture, and whether hybrid top-up was skipped or used.",
|
|
1199
|
-
parameters:
|
|
1200
|
-
namespace:
|
|
1201
|
-
|
|
1395
|
+
parameters: Type2.Object({
|
|
1396
|
+
namespace: Type2.Optional(
|
|
1397
|
+
Type2.String({
|
|
1202
1398
|
description: "Optional namespace to inspect. Defaults to defaultNamespace."
|
|
1203
1399
|
})
|
|
1204
1400
|
),
|
|
1205
|
-
maxResults:
|
|
1206
|
-
|
|
1401
|
+
maxResults: Type2.Optional(
|
|
1402
|
+
Type2.Number({
|
|
1207
1403
|
description: "Maximum results to show (default: 10, max: 25).",
|
|
1208
1404
|
minimum: 1,
|
|
1209
1405
|
maximum: 25
|
|
@@ -1216,7 +1412,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1216
1412
|
namespace,
|
|
1217
1413
|
maxResults
|
|
1218
1414
|
});
|
|
1219
|
-
return
|
|
1415
|
+
return toolResult2(text);
|
|
1220
1416
|
}
|
|
1221
1417
|
},
|
|
1222
1418
|
{ name: "memory_qmd_debug" }
|
|
@@ -1226,14 +1422,14 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1226
1422
|
name: "memory_graph_explain_last_recall",
|
|
1227
1423
|
label: "Explain Graph Recall",
|
|
1228
1424
|
description: "Inspect the last graph-mode recall expansion snapshot (seed paths + expanded candidates) to explain why graph memories were included.",
|
|
1229
|
-
parameters:
|
|
1230
|
-
namespace:
|
|
1231
|
-
|
|
1425
|
+
parameters: Type2.Object({
|
|
1426
|
+
namespace: Type2.Optional(
|
|
1427
|
+
Type2.String({
|
|
1232
1428
|
description: "Optional namespace to inspect. Defaults to defaultNamespace."
|
|
1233
1429
|
})
|
|
1234
1430
|
),
|
|
1235
|
-
maxExpanded:
|
|
1236
|
-
|
|
1431
|
+
maxExpanded: Type2.Optional(
|
|
1432
|
+
Type2.Number({
|
|
1237
1433
|
description: "Maximum expanded paths to show (default: 10, max: 50).",
|
|
1238
1434
|
minimum: 1,
|
|
1239
1435
|
maximum: 50
|
|
@@ -1246,7 +1442,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1246
1442
|
namespace,
|
|
1247
1443
|
maxExpanded
|
|
1248
1444
|
});
|
|
1249
|
-
return
|
|
1445
|
+
return toolResult2(text);
|
|
1250
1446
|
}
|
|
1251
1447
|
},
|
|
1252
1448
|
{ name: "memory_graph_explain_last_recall" }
|
|
@@ -1256,29 +1452,29 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1256
1452
|
name: "memory_feedback_last_recall",
|
|
1257
1453
|
label: "Feedback Last Recall",
|
|
1258
1454
|
description: "Batch feedback tool for the last recall snapshot. Can mark retrieved memories as 'not useful' (negative examples) so they are softly penalized in future ranking when negative examples are enabled.",
|
|
1259
|
-
parameters:
|
|
1260
|
-
sessionKey:
|
|
1261
|
-
|
|
1455
|
+
parameters: Type2.Object({
|
|
1456
|
+
sessionKey: Type2.Optional(
|
|
1457
|
+
Type2.String({
|
|
1262
1458
|
description: "Session key. If omitted, uses the most recent snapshot across all sessions (may be wrong under concurrency)."
|
|
1263
1459
|
})
|
|
1264
1460
|
),
|
|
1265
|
-
notUsefulMemoryIds:
|
|
1266
|
-
|
|
1461
|
+
notUsefulMemoryIds: Type2.Optional(
|
|
1462
|
+
Type2.Array(Type2.String(), {
|
|
1267
1463
|
description: "Memory IDs to mark as not useful. If omitted, you may use usefulMemoryIds + autoMarkOthersNotUseful to mark the rest as not useful."
|
|
1268
1464
|
})
|
|
1269
1465
|
),
|
|
1270
|
-
usefulMemoryIds:
|
|
1271
|
-
|
|
1466
|
+
usefulMemoryIds: Type2.Optional(
|
|
1467
|
+
Type2.Array(Type2.String(), {
|
|
1272
1468
|
description: "Memory IDs that were useful. Only used when autoMarkOthersNotUseful=true."
|
|
1273
1469
|
})
|
|
1274
1470
|
),
|
|
1275
|
-
autoMarkOthersNotUseful:
|
|
1276
|
-
|
|
1471
|
+
autoMarkOthersNotUseful: Type2.Optional(
|
|
1472
|
+
Type2.Boolean({
|
|
1277
1473
|
description: "If true, marks all last-recall memory IDs not listed in usefulMemoryIds as not useful. Safer than auto-marking without an explicit useful list."
|
|
1278
1474
|
})
|
|
1279
1475
|
),
|
|
1280
|
-
note:
|
|
1281
|
-
|
|
1476
|
+
note: Type2.Optional(
|
|
1477
|
+
Type2.String({
|
|
1282
1478
|
description: "Optional note explaining why these were not useful (stored locally)."
|
|
1283
1479
|
})
|
|
1284
1480
|
)
|
|
@@ -1292,20 +1488,20 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1292
1488
|
note
|
|
1293
1489
|
} = params;
|
|
1294
1490
|
if (!orchestrator.config.negativeExamplesEnabled) {
|
|
1295
|
-
return
|
|
1491
|
+
return toolResult2(
|
|
1296
1492
|
"Negative examples are disabled. Enable `negativeExamplesEnabled: true` in the Engram plugin config to store retrieved-but-not-useful feedback and apply penalties."
|
|
1297
1493
|
);
|
|
1298
1494
|
}
|
|
1299
1495
|
const snap = sessionKey ? orchestrator.lastRecall.get(sessionKey) : orchestrator.lastRecall.getMostRecent();
|
|
1300
1496
|
if (!snap) {
|
|
1301
|
-
return
|
|
1497
|
+
return toolResult2("No last-recall snapshot found yet.");
|
|
1302
1498
|
}
|
|
1303
1499
|
let toMark = null;
|
|
1304
1500
|
if (Array.isArray(notUsefulMemoryIds) && notUsefulMemoryIds.length > 0) {
|
|
1305
1501
|
toMark = notUsefulMemoryIds;
|
|
1306
1502
|
} else if (autoMarkOthersNotUseful) {
|
|
1307
1503
|
if (!Array.isArray(usefulMemoryIds) || usefulMemoryIds.length === 0) {
|
|
1308
|
-
return
|
|
1504
|
+
return toolResult2(
|
|
1309
1505
|
"autoMarkOthersNotUseful=true requires a non-empty usefulMemoryIds list (to avoid accidental mass-negative marking)."
|
|
1310
1506
|
);
|
|
1311
1507
|
}
|
|
@@ -1313,13 +1509,13 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1313
1509
|
toMark = snap.memoryIds.filter((id) => !useful.has(id));
|
|
1314
1510
|
}
|
|
1315
1511
|
if (!toMark || toMark.length === 0) {
|
|
1316
|
-
return
|
|
1512
|
+
return toolResult2(
|
|
1317
1513
|
"Nothing to record. Provide notUsefulMemoryIds, or provide usefulMemoryIds with autoMarkOthersNotUseful=true."
|
|
1318
1514
|
);
|
|
1319
1515
|
}
|
|
1320
1516
|
await orchestrator.recordNotUsefulMemories(toMark, note);
|
|
1321
1517
|
const warn = sessionKey ? "" : "\n\nNOTE: You did not provide sessionKey; under concurrency this may not match your current session.";
|
|
1322
|
-
return
|
|
1518
|
+
return toolResult2(
|
|
1323
1519
|
`Recorded ${toMark.length} not-useful memory ID(s) for last recall (${snap.sessionKey}).${warn}`
|
|
1324
1520
|
);
|
|
1325
1521
|
}
|
|
@@ -1331,50 +1527,50 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1331
1527
|
name: "context_checkpoint",
|
|
1332
1528
|
label: "Context Checkpoint",
|
|
1333
1529
|
description: "Create or validate a transcript checkpoint and record the corresponding context-compression action event (v8.3).",
|
|
1334
|
-
parameters:
|
|
1335
|
-
summary:
|
|
1530
|
+
parameters: Type2.Object({
|
|
1531
|
+
summary: Type2.String({
|
|
1336
1532
|
description: "Short summary of what was checkpointed."
|
|
1337
1533
|
}),
|
|
1338
|
-
sessionKey:
|
|
1339
|
-
|
|
1534
|
+
sessionKey: Type2.Optional(
|
|
1535
|
+
Type2.String({
|
|
1340
1536
|
description: "Session key for the checkpoint source transcript."
|
|
1341
1537
|
})
|
|
1342
1538
|
),
|
|
1343
|
-
turns:
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
timestamp:
|
|
1347
|
-
role:
|
|
1348
|
-
content:
|
|
1349
|
-
sessionKey:
|
|
1350
|
-
turnId:
|
|
1539
|
+
turns: Type2.Optional(
|
|
1540
|
+
Type2.Array(
|
|
1541
|
+
Type2.Object({
|
|
1542
|
+
timestamp: Type2.String(),
|
|
1543
|
+
role: Type2.String({ enum: ["user", "assistant"] }),
|
|
1544
|
+
content: Type2.String(),
|
|
1545
|
+
sessionKey: Type2.String(),
|
|
1546
|
+
turnId: Type2.String()
|
|
1351
1547
|
})
|
|
1352
1548
|
)
|
|
1353
1549
|
),
|
|
1354
|
-
ttlHours:
|
|
1355
|
-
|
|
1550
|
+
ttlHours: Type2.Optional(
|
|
1551
|
+
Type2.Number({
|
|
1356
1552
|
description: "Optional checkpoint TTL in hours."
|
|
1357
1553
|
})
|
|
1358
1554
|
),
|
|
1359
|
-
sourcePrompt:
|
|
1360
|
-
|
|
1555
|
+
sourcePrompt: Type2.Optional(
|
|
1556
|
+
Type2.String({
|
|
1361
1557
|
description: "Optional source prompt text used for hashing in telemetry."
|
|
1362
1558
|
})
|
|
1363
1559
|
),
|
|
1364
|
-
namespace:
|
|
1365
|
-
|
|
1560
|
+
namespace: Type2.Optional(
|
|
1561
|
+
Type2.String({
|
|
1366
1562
|
description: "Optional namespace. Defaults to defaultNamespace."
|
|
1367
1563
|
})
|
|
1368
1564
|
),
|
|
1369
|
-
dryRun:
|
|
1370
|
-
|
|
1565
|
+
dryRun: Type2.Optional(
|
|
1566
|
+
Type2.Boolean({
|
|
1371
1567
|
description: "When true, validate and log without persisting the checkpoint file."
|
|
1372
1568
|
})
|
|
1373
1569
|
)
|
|
1374
1570
|
}),
|
|
1375
1571
|
async execute(_toolCallId, params) {
|
|
1376
1572
|
if (!orchestrator.config.contextCompressionActionsEnabled) {
|
|
1377
|
-
return
|
|
1573
|
+
return toolResult2(
|
|
1378
1574
|
"Context compression actions are disabled. Enable `contextCompressionActionsEnabled: true` to use this tool."
|
|
1379
1575
|
);
|
|
1380
1576
|
}
|
|
@@ -1390,9 +1586,9 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1390
1586
|
promptHash: promptHashForTelemetry(sourcePrompt)
|
|
1391
1587
|
});
|
|
1392
1588
|
if (!wrote2) {
|
|
1393
|
-
return
|
|
1589
|
+
return toolResult2("Checkpoint recorded best-effort failed (fail-open).");
|
|
1394
1590
|
}
|
|
1395
|
-
return
|
|
1591
|
+
return toolResult2(`Recorded context checkpoint telemetry in namespace=${ns}.`);
|
|
1396
1592
|
}
|
|
1397
1593
|
const validationErrors = [];
|
|
1398
1594
|
if (!asNonEmptyString(sessionKey)) validationErrors.push("sessionKey is required");
|
|
@@ -1415,7 +1611,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1415
1611
|
status: "rejected",
|
|
1416
1612
|
reason: `validation: ${validationErrors.join("; ")}`
|
|
1417
1613
|
});
|
|
1418
|
-
return
|
|
1614
|
+
return toolResult2(`Validation failed: ${validationErrors.join("; ")}.`);
|
|
1419
1615
|
}
|
|
1420
1616
|
const structuredEvent = {
|
|
1421
1617
|
...baseEvent,
|
|
@@ -1425,7 +1621,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1425
1621
|
if (preview.policyDecision !== "allow") {
|
|
1426
1622
|
const wrote2 = await orchestrator.appendMemoryActionEvent(structuredEvent);
|
|
1427
1623
|
const suffix2 = wrote2 ? "" : " Telemetry write failed (fail-open).";
|
|
1428
|
-
return
|
|
1624
|
+
return toolResult2(
|
|
1429
1625
|
`Context checkpoint blocked by policy: action=${preview.action}, namespace=${preview.namespace}, policy=${preview.policyDecision}, rationale=${preview.policyRationale}.${suffix2}`
|
|
1430
1626
|
);
|
|
1431
1627
|
}
|
|
@@ -1447,9 +1643,9 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1447
1643
|
});
|
|
1448
1644
|
const suffix = wrote ? "" : " Telemetry write failed (fail-open).";
|
|
1449
1645
|
if (dryRun === true) {
|
|
1450
|
-
return
|
|
1646
|
+
return toolResult2(`Validated context checkpoint for session=${sessionKey} without saving it.${suffix}`);
|
|
1451
1647
|
}
|
|
1452
|
-
return
|
|
1648
|
+
return toolResult2(`Saved context checkpoint for session=${sessionKey} in namespace=${ns}.${suffix}`);
|
|
1453
1649
|
}
|
|
1454
1650
|
},
|
|
1455
1651
|
{ name: "context_checkpoint" }
|
|
@@ -1459,86 +1655,86 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1459
1655
|
name: "memory_action_apply",
|
|
1460
1656
|
label: "Apply Memory Action",
|
|
1461
1657
|
description: "Record a memory-action application event for policy-learning telemetry (v8.3).",
|
|
1462
|
-
parameters:
|
|
1463
|
-
action:
|
|
1658
|
+
parameters: Type2.Object({
|
|
1659
|
+
action: Type2.String({
|
|
1464
1660
|
enum: actionTypes,
|
|
1465
1661
|
description: "Memory action type."
|
|
1466
1662
|
}),
|
|
1467
|
-
category:
|
|
1468
|
-
|
|
1663
|
+
category: Type2.Optional(
|
|
1664
|
+
Type2.String({
|
|
1469
1665
|
description: "Optional memory category for write-style actions."
|
|
1470
1666
|
})
|
|
1471
1667
|
),
|
|
1472
|
-
content:
|
|
1473
|
-
|
|
1668
|
+
content: Type2.Optional(
|
|
1669
|
+
Type2.String({
|
|
1474
1670
|
description: "Content payload for store, update, artifact, or summarize actions."
|
|
1475
1671
|
})
|
|
1476
1672
|
),
|
|
1477
|
-
outcome:
|
|
1478
|
-
|
|
1673
|
+
outcome: Type2.Optional(
|
|
1674
|
+
Type2.String({
|
|
1479
1675
|
enum: ["applied", "skipped", "failed"],
|
|
1480
1676
|
description: "Outcome status (default: applied)."
|
|
1481
1677
|
})
|
|
1482
1678
|
),
|
|
1483
|
-
reason:
|
|
1484
|
-
|
|
1679
|
+
reason: Type2.Optional(
|
|
1680
|
+
Type2.String({
|
|
1485
1681
|
description: "Optional reason/notes for this action outcome."
|
|
1486
1682
|
})
|
|
1487
1683
|
),
|
|
1488
|
-
memoryId:
|
|
1489
|
-
|
|
1684
|
+
memoryId: Type2.Optional(
|
|
1685
|
+
Type2.String({
|
|
1490
1686
|
description: "Optional memory ID targeted by this action."
|
|
1491
1687
|
})
|
|
1492
1688
|
),
|
|
1493
|
-
sessionKey:
|
|
1494
|
-
|
|
1689
|
+
sessionKey: Type2.Optional(
|
|
1690
|
+
Type2.String({
|
|
1495
1691
|
description: "Optional source session key for audit logging."
|
|
1496
1692
|
})
|
|
1497
1693
|
),
|
|
1498
|
-
linkTargetId:
|
|
1499
|
-
|
|
1694
|
+
linkTargetId: Type2.Optional(
|
|
1695
|
+
Type2.String({
|
|
1500
1696
|
description: "Target memory ID for link_graph actions."
|
|
1501
1697
|
})
|
|
1502
1698
|
),
|
|
1503
|
-
linkType:
|
|
1504
|
-
|
|
1699
|
+
linkType: Type2.Optional(
|
|
1700
|
+
Type2.String({
|
|
1505
1701
|
description: "Link type for link_graph actions."
|
|
1506
1702
|
})
|
|
1507
1703
|
),
|
|
1508
|
-
linkStrength:
|
|
1509
|
-
|
|
1704
|
+
linkStrength: Type2.Optional(
|
|
1705
|
+
Type2.Number({
|
|
1510
1706
|
description: "Optional edge strength for link_graph actions."
|
|
1511
1707
|
})
|
|
1512
1708
|
),
|
|
1513
|
-
artifactType:
|
|
1514
|
-
|
|
1709
|
+
artifactType: Type2.Optional(
|
|
1710
|
+
Type2.String({
|
|
1515
1711
|
description: "Optional artifact type for create_artifact."
|
|
1516
1712
|
})
|
|
1517
1713
|
),
|
|
1518
|
-
execute:
|
|
1519
|
-
|
|
1714
|
+
execute: Type2.Optional(
|
|
1715
|
+
Type2.Boolean({
|
|
1520
1716
|
description: "When true, force structured execution mode even for target-only actions like discard."
|
|
1521
1717
|
})
|
|
1522
1718
|
),
|
|
1523
|
-
sourcePrompt:
|
|
1524
|
-
|
|
1719
|
+
sourcePrompt: Type2.Optional(
|
|
1720
|
+
Type2.String({
|
|
1525
1721
|
description: "Optional source prompt text used for hashing in telemetry."
|
|
1526
1722
|
})
|
|
1527
1723
|
),
|
|
1528
|
-
namespace:
|
|
1529
|
-
|
|
1724
|
+
namespace: Type2.Optional(
|
|
1725
|
+
Type2.String({
|
|
1530
1726
|
description: "Optional namespace. Defaults to defaultNamespace."
|
|
1531
1727
|
})
|
|
1532
1728
|
),
|
|
1533
|
-
dryRun:
|
|
1534
|
-
|
|
1729
|
+
dryRun: Type2.Optional(
|
|
1730
|
+
Type2.Boolean({
|
|
1535
1731
|
description: "When true, validate and report without persisting telemetry."
|
|
1536
1732
|
})
|
|
1537
1733
|
)
|
|
1538
1734
|
}),
|
|
1539
1735
|
async execute(_toolCallId, params) {
|
|
1540
1736
|
if (!orchestrator.config.contextCompressionActionsEnabled) {
|
|
1541
|
-
return
|
|
1737
|
+
return toolResult2(
|
|
1542
1738
|
"Context compression actions are disabled. Enable `contextCompressionActionsEnabled: true` to use this tool."
|
|
1543
1739
|
);
|
|
1544
1740
|
}
|
|
@@ -1561,7 +1757,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1561
1757
|
} = params;
|
|
1562
1758
|
const ns = typeof namespace === "string" && namespace.length > 0 ? namespace : orchestrator.config.defaultNamespace;
|
|
1563
1759
|
if (!isKnownMemoryActionType(action)) {
|
|
1564
|
-
return
|
|
1760
|
+
return toolResult2(`Validation failed: invalid action ${String(action)}.`);
|
|
1565
1761
|
}
|
|
1566
1762
|
const validationErrors = [];
|
|
1567
1763
|
const contentValue = asNonEmptyString(content);
|
|
@@ -1587,15 +1783,15 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1587
1783
|
};
|
|
1588
1784
|
const preview2 = orchestrator.previewMemoryActionEvent(event);
|
|
1589
1785
|
if (dryRun === true) {
|
|
1590
|
-
return
|
|
1786
|
+
return toolResult2(
|
|
1591
1787
|
`Dry run: memory action would be recorded with action=${preview2.action}, outcome=${preview2.outcome}, namespace=${preview2.namespace}, policy=${preview2.policyDecision}.`
|
|
1592
1788
|
);
|
|
1593
1789
|
}
|
|
1594
1790
|
const wrote2 = await orchestrator.appendMemoryActionEvent(event);
|
|
1595
1791
|
if (!wrote2) {
|
|
1596
|
-
return
|
|
1792
|
+
return toolResult2("Memory action telemetry write failed (fail-open).");
|
|
1597
1793
|
}
|
|
1598
|
-
return
|
|
1794
|
+
return toolResult2(
|
|
1599
1795
|
`Recorded memory action telemetry: action=${preview2.action}, outcome=${preview2.outcome}, namespace=${preview2.namespace}.`
|
|
1600
1796
|
);
|
|
1601
1797
|
}
|
|
@@ -1631,7 +1827,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1631
1827
|
outputMemoryIds: [],
|
|
1632
1828
|
reason: `validation: ${validationErrors.join("; ")}`
|
|
1633
1829
|
});
|
|
1634
|
-
return
|
|
1830
|
+
return toolResult2(
|
|
1635
1831
|
`Validation failed: ${validationErrors.join("; ")}.`
|
|
1636
1832
|
);
|
|
1637
1833
|
}
|
|
@@ -1646,7 +1842,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1646
1842
|
reason: `validation: invalid category ${String(category)}`
|
|
1647
1843
|
});
|
|
1648
1844
|
const suffix = wrote2 ? "" : " Telemetry write failed (fail-open).";
|
|
1649
|
-
return
|
|
1845
|
+
return toolResult2(`Validation failed: invalid category ${String(category)}.${suffix}`);
|
|
1650
1846
|
}
|
|
1651
1847
|
const storage = typeof orchestrator.getStorage === "function" ? await orchestrator.getStorage(ns) : orchestrator.storage;
|
|
1652
1848
|
const referencedMemory = await readReferencedMemoryForPolicyEligibility(storage, memoryIdValue);
|
|
@@ -1659,7 +1855,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1659
1855
|
outputMemoryIds: [],
|
|
1660
1856
|
reason: "validation: support passport records require the owner surface"
|
|
1661
1857
|
});
|
|
1662
|
-
return
|
|
1858
|
+
return toolResult2(
|
|
1663
1859
|
"Validation failed: support passport records can only be changed through the support passport owner surface."
|
|
1664
1860
|
);
|
|
1665
1861
|
}
|
|
@@ -1675,11 +1871,11 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1675
1871
|
const wrote2 = await orchestrator.appendMemoryActionEvent(structuredEvent);
|
|
1676
1872
|
const suffix = wrote2 ? "" : " Telemetry write failed (fail-open).";
|
|
1677
1873
|
if (preview2.policyDecision !== "allow") {
|
|
1678
|
-
return
|
|
1874
|
+
return toolResult2(
|
|
1679
1875
|
`Memory action blocked by policy during validation: action=${preview2.action}, namespace=${preview2.namespace}, policy=${preview2.policyDecision}, rationale=${preview2.policyRationale}.${suffix}`
|
|
1680
1876
|
);
|
|
1681
1877
|
}
|
|
1682
|
-
return
|
|
1878
|
+
return toolResult2(
|
|
1683
1879
|
`Validated memory action without applying it: action=${preview2.action}, namespace=${preview2.namespace}, policy=${preview2.policyDecision}.${suffix}`
|
|
1684
1880
|
);
|
|
1685
1881
|
}
|
|
@@ -1687,7 +1883,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1687
1883
|
if (preview.policyDecision !== "allow") {
|
|
1688
1884
|
const wrote2 = await orchestrator.appendMemoryActionEvent(structuredEvent);
|
|
1689
1885
|
const suffix = wrote2 ? "" : " Telemetry write failed (fail-open).";
|
|
1690
|
-
return
|
|
1886
|
+
return toolResult2(
|
|
1691
1887
|
`Memory action execution blocked by policy: action=${preview.action}, namespace=${preview.namespace}, policy=${preview.policyDecision}, rationale=${preview.policyRationale}.${suffix}`
|
|
1692
1888
|
);
|
|
1693
1889
|
}
|
|
@@ -1745,7 +1941,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1745
1941
|
reason: `execution: unable to update memory ${memoryIdValue}`
|
|
1746
1942
|
});
|
|
1747
1943
|
const suffix = wrote2 ? "" : " Telemetry write failed (fail-open).";
|
|
1748
|
-
return
|
|
1944
|
+
return toolResult2(`Validation failed: unable to update memory ${memoryIdValue}.${suffix}`);
|
|
1749
1945
|
}
|
|
1750
1946
|
outputMemoryIds.push(memoryIdValue);
|
|
1751
1947
|
appliedMessage = `Applied memory action: action=${action}, memoryId=${memoryIdValue}, namespace=${ns}.`;
|
|
@@ -1766,7 +1962,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1766
1962
|
reason: "execution: unable to create artifact"
|
|
1767
1963
|
});
|
|
1768
1964
|
const suffix = wrote2 ? "" : " Telemetry write failed (fail-open).";
|
|
1769
|
-
return
|
|
1965
|
+
return toolResult2(`Validation failed: unable to create artifact.${suffix}`);
|
|
1770
1966
|
}
|
|
1771
1967
|
outputMemoryIds.push(createdId);
|
|
1772
1968
|
appliedMessage = `Applied memory action: action=${action}, memoryId=${createdId}, namespace=${ns}.`;
|
|
@@ -1802,7 +1998,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1802
1998
|
reason: `execution: unable to find memory ${memoryIdValue}`
|
|
1803
1999
|
});
|
|
1804
2000
|
const suffix = wrote2 ? "" : " Telemetry write failed (fail-open).";
|
|
1805
|
-
return
|
|
2001
|
+
return toolResult2(`Validation failed: unable to find memory ${memoryIdValue}.${suffix}`);
|
|
1806
2002
|
}
|
|
1807
2003
|
await storage.writeMemoryFrontmatter(
|
|
1808
2004
|
target,
|
|
@@ -1845,7 +2041,7 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1845
2041
|
reason: `execution: unable to link memory ${memoryIdValue}`
|
|
1846
2042
|
});
|
|
1847
2043
|
const suffix = wrote2 ? "" : " Telemetry write failed (fail-open).";
|
|
1848
|
-
return
|
|
2044
|
+
return toolResult2(`Validation failed: unable to link memory ${memoryIdValue}.${suffix}`);
|
|
1849
2045
|
}
|
|
1850
2046
|
outputMemoryIds.push(memoryIdValue);
|
|
1851
2047
|
appliedMessage = `Applied memory action: action=${action}, memoryId=${memoryIdValue}, namespace=${ns}.`;
|
|
@@ -1869,9 +2065,9 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1869
2065
|
...queuedForReview ? { reason: "tombstone-blocked: write landed pending_review, no active copy created" } : {}
|
|
1870
2066
|
});
|
|
1871
2067
|
if (!wrote) {
|
|
1872
|
-
return
|
|
2068
|
+
return toolResult2(`${appliedMessage} Telemetry write failed (fail-open).`);
|
|
1873
2069
|
}
|
|
1874
|
-
return
|
|
2070
|
+
return toolResult2(appliedMessage);
|
|
1875
2071
|
}
|
|
1876
2072
|
},
|
|
1877
2073
|
{ name: "memory_action_apply" }
|
|
@@ -1881,14 +2077,14 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1881
2077
|
name: "compression_guidelines_optimize",
|
|
1882
2078
|
label: "Optimize Compression Guidelines",
|
|
1883
2079
|
description: "Run compression guideline optimizer and optionally persist the new guideline/state (v8.11).",
|
|
1884
|
-
parameters:
|
|
1885
|
-
dryRun:
|
|
1886
|
-
|
|
2080
|
+
parameters: Type2.Object({
|
|
2081
|
+
dryRun: Type2.Optional(
|
|
2082
|
+
Type2.Boolean({
|
|
1887
2083
|
description: "When true, compute candidate/output but do not persist changes."
|
|
1888
2084
|
})
|
|
1889
2085
|
),
|
|
1890
|
-
eventLimit:
|
|
1891
|
-
|
|
2086
|
+
eventLimit: Type2.Optional(
|
|
2087
|
+
Type2.Number({
|
|
1892
2088
|
description: "Max telemetry events to analyze (default: 500)."
|
|
1893
2089
|
})
|
|
1894
2090
|
)
|
|
@@ -1900,11 +2096,11 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1900
2096
|
eventLimit
|
|
1901
2097
|
});
|
|
1902
2098
|
if (!result.enabled) {
|
|
1903
|
-
return
|
|
2099
|
+
return toolResult2(
|
|
1904
2100
|
"Compression guideline learning is disabled. Enable `compressionGuidelineLearningEnabled: true` to run optimizer."
|
|
1905
2101
|
);
|
|
1906
2102
|
}
|
|
1907
|
-
return
|
|
2103
|
+
return toolResult2(
|
|
1908
2104
|
[
|
|
1909
2105
|
"Compression guideline optimization complete.",
|
|
1910
2106
|
`dryRun=${result.dryRun}`,
|
|
@@ -1925,9 +2121,9 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1925
2121
|
name: "compression_guidelines_activate",
|
|
1926
2122
|
label: "Activate Compression Guideline Draft",
|
|
1927
2123
|
description: "Promote the staged compression guideline draft to the active guideline/state after review (v8.11).",
|
|
1928
|
-
parameters:
|
|
1929
|
-
expectedContentHash:
|
|
1930
|
-
expectedGuidelineVersion:
|
|
2124
|
+
parameters: Type2.Object({
|
|
2125
|
+
expectedContentHash: Type2.Optional(Type2.String()),
|
|
2126
|
+
expectedGuidelineVersion: Type2.Optional(Type2.Number())
|
|
1931
2127
|
}),
|
|
1932
2128
|
async execute(_toolCallId, params) {
|
|
1933
2129
|
const expectedContentHash = typeof params.expectedContentHash === "string" ? params.expectedContentHash.trim() : "";
|
|
@@ -1937,32 +2133,32 @@ NOTE: You did not provide sessionKey; under concurrency this may not match your
|
|
|
1937
2133
|
...typeof expectedGuidelineVersion === "number" ? { expectedGuidelineVersion } : {}
|
|
1938
2134
|
});
|
|
1939
2135
|
if (!result.enabled) {
|
|
1940
|
-
return
|
|
2136
|
+
return toolResult2(
|
|
1941
2137
|
"Compression guideline learning is disabled. Enable `compressionGuidelineLearningEnabled: true` before activating drafts."
|
|
1942
2138
|
);
|
|
1943
2139
|
}
|
|
1944
2140
|
if (!result.activated) {
|
|
1945
2141
|
if (result.reason === "missing_draft") {
|
|
1946
|
-
return
|
|
2142
|
+
return toolResult2("No staged compression guideline draft is available to activate.");
|
|
1947
2143
|
}
|
|
1948
2144
|
if (result.reason === "expected_revision_required") {
|
|
1949
|
-
return
|
|
2145
|
+
return toolResult2(
|
|
1950
2146
|
"Activation requires `expectedContentHash` or `expectedGuidelineVersion` so the reviewed draft identity is pinned."
|
|
1951
2147
|
);
|
|
1952
2148
|
}
|
|
1953
2149
|
if (result.reason === "content_hash_mismatch" || result.reason === "draft_changed") {
|
|
1954
|
-
return
|
|
2150
|
+
return toolResult2(
|
|
1955
2151
|
"The staged compression guideline draft changed after review. Re-read the current draft and retry activation with its latest identity."
|
|
1956
2152
|
);
|
|
1957
2153
|
}
|
|
1958
2154
|
if (result.reason === "guideline_version_mismatch") {
|
|
1959
|
-
return
|
|
2155
|
+
return toolResult2(
|
|
1960
2156
|
"The staged draft guidelineVersion no longer matches the reviewed revision. Re-read the current draft and retry activation with its latest identity."
|
|
1961
2157
|
);
|
|
1962
2158
|
}
|
|
1963
|
-
return
|
|
2159
|
+
return toolResult2("Compression guideline draft activation was rejected.");
|
|
1964
2160
|
}
|
|
1965
|
-
return
|
|
2161
|
+
return toolResult2(
|
|
1966
2162
|
[
|
|
1967
2163
|
"Compression guideline draft activated.",
|
|
1968
2164
|
`guidelineVersion=${result.guidelineVersion ?? "unknown"}`
|
|
@@ -1985,45 +2181,45 @@ Best for:
|
|
|
1985
2181
|
- User says "remember that..." or "note that..."
|
|
1986
2182
|
- Critical corrections or preferences
|
|
1987
2183
|
- Important decisions or facts`,
|
|
1988
|
-
parameters:
|
|
1989
|
-
content:
|
|
2184
|
+
parameters: Type2.Object({
|
|
2185
|
+
content: Type2.String({
|
|
1990
2186
|
description: "The memory to store \u2014 a clear, standalone statement"
|
|
1991
2187
|
}),
|
|
1992
|
-
namespace:
|
|
1993
|
-
|
|
2188
|
+
namespace: Type2.Optional(
|
|
2189
|
+
Type2.String({
|
|
1994
2190
|
description: "Namespace to store into (v3.0+). Omit to store into defaultNamespace."
|
|
1995
2191
|
})
|
|
1996
2192
|
),
|
|
1997
|
-
category:
|
|
1998
|
-
|
|
2193
|
+
category: Type2.Optional(
|
|
2194
|
+
Type2.String({
|
|
1999
2195
|
description: 'Category: "fact", "preference", "correction", "entity", "decision", "relationship", "principle", "commitment", "moment", "skill", "rule", "procedure", "reasoning_trace" (default: "fact")',
|
|
2000
2196
|
enum: ["fact", "preference", "correction", "entity", "decision", "relationship", "principle", "commitment", "moment", "skill", "rule", "procedure", "reasoning_trace"]
|
|
2001
2197
|
})
|
|
2002
2198
|
),
|
|
2003
|
-
tags:
|
|
2004
|
-
|
|
2199
|
+
tags: Type2.Optional(
|
|
2200
|
+
Type2.Array(Type2.String(), {
|
|
2005
2201
|
description: "Tags for categorization"
|
|
2006
2202
|
})
|
|
2007
2203
|
),
|
|
2008
|
-
entityRef:
|
|
2009
|
-
|
|
2204
|
+
entityRef: Type2.Optional(
|
|
2205
|
+
Type2.String({
|
|
2010
2206
|
description: "Entity reference (e.g., person-jane-doe, project-my-app)"
|
|
2011
2207
|
})
|
|
2012
2208
|
),
|
|
2013
|
-
confidence:
|
|
2014
|
-
|
|
2209
|
+
confidence: Type2.Optional(
|
|
2210
|
+
Type2.Number({
|
|
2015
2211
|
description: "Explicit capture confidence (0-1). Defaults to 0.95.",
|
|
2016
2212
|
minimum: 0,
|
|
2017
2213
|
maximum: 1
|
|
2018
2214
|
})
|
|
2019
2215
|
),
|
|
2020
|
-
ttl:
|
|
2021
|
-
|
|
2216
|
+
ttl: Type2.Optional(
|
|
2217
|
+
Type2.String({
|
|
2022
2218
|
description: "Optional TTL expression to attach to the stored memory."
|
|
2023
2219
|
})
|
|
2024
2220
|
),
|
|
2025
|
-
sourceReason:
|
|
2026
|
-
|
|
2221
|
+
sourceReason: Type2.Optional(
|
|
2222
|
+
Type2.String({
|
|
2027
2223
|
description: "Optional reason code for audit history."
|
|
2028
2224
|
})
|
|
2029
2225
|
)
|
|
@@ -2043,45 +2239,45 @@ Best for:
|
|
|
2043
2239
|
name: "memory_capture",
|
|
2044
2240
|
label: "Capture Memory",
|
|
2045
2241
|
description: "Store a validated explicit memory note. Preferred tool for explicit capture modes and operator-controlled memory creation.",
|
|
2046
|
-
parameters:
|
|
2047
|
-
content:
|
|
2242
|
+
parameters: Type2.Object({
|
|
2243
|
+
content: Type2.String({
|
|
2048
2244
|
description: "The memory to store \u2014 one standalone validated statement."
|
|
2049
2245
|
}),
|
|
2050
|
-
namespace:
|
|
2051
|
-
|
|
2246
|
+
namespace: Type2.Optional(
|
|
2247
|
+
Type2.String({
|
|
2052
2248
|
description: "Namespace to store into. Omit to store into defaultNamespace."
|
|
2053
2249
|
})
|
|
2054
2250
|
),
|
|
2055
|
-
category:
|
|
2056
|
-
|
|
2251
|
+
category: Type2.Optional(
|
|
2252
|
+
Type2.String({
|
|
2057
2253
|
description: "Memory category.",
|
|
2058
2254
|
enum: ["fact", "preference", "correction", "entity", "decision", "relationship", "principle", "commitment", "moment", "skill", "rule", "procedure", "reasoning_trace"]
|
|
2059
2255
|
})
|
|
2060
2256
|
),
|
|
2061
|
-
tags:
|
|
2062
|
-
|
|
2257
|
+
tags: Type2.Optional(
|
|
2258
|
+
Type2.Array(Type2.String(), {
|
|
2063
2259
|
description: "Tags for categorization"
|
|
2064
2260
|
})
|
|
2065
2261
|
),
|
|
2066
|
-
entityRef:
|
|
2067
|
-
|
|
2262
|
+
entityRef: Type2.Optional(
|
|
2263
|
+
Type2.String({
|
|
2068
2264
|
description: "Entity reference (e.g., person-jane-doe, project-my-app)"
|
|
2069
2265
|
})
|
|
2070
2266
|
),
|
|
2071
|
-
confidence:
|
|
2072
|
-
|
|
2267
|
+
confidence: Type2.Optional(
|
|
2268
|
+
Type2.Number({
|
|
2073
2269
|
description: "Explicit capture confidence (0-1). Defaults to 0.95.",
|
|
2074
2270
|
minimum: 0,
|
|
2075
2271
|
maximum: 1
|
|
2076
2272
|
})
|
|
2077
2273
|
),
|
|
2078
|
-
ttl:
|
|
2079
|
-
|
|
2274
|
+
ttl: Type2.Optional(
|
|
2275
|
+
Type2.String({
|
|
2080
2276
|
description: "Optional TTL expression to attach to the stored memory."
|
|
2081
2277
|
})
|
|
2082
2278
|
),
|
|
2083
|
-
sourceReason:
|
|
2084
|
-
|
|
2279
|
+
sourceReason: Type2.Optional(
|
|
2280
|
+
Type2.String({
|
|
2085
2281
|
description: "Optional reason code for audit history."
|
|
2086
2282
|
})
|
|
2087
2283
|
)
|
|
@@ -2101,29 +2297,29 @@ Best for:
|
|
|
2101
2297
|
name: "memory_promote",
|
|
2102
2298
|
label: "Promote Memory To Shared",
|
|
2103
2299
|
description: "Copy a memory into the shared namespace (v3.0+). This is intended for curated promotion of agent-specific learning into a shared brain.",
|
|
2104
|
-
parameters:
|
|
2105
|
-
memoryId:
|
|
2300
|
+
parameters: Type2.Object({
|
|
2301
|
+
memoryId: Type2.String({
|
|
2106
2302
|
description: "Memory ID (filename without .md), e.g. fact-123"
|
|
2107
2303
|
}),
|
|
2108
|
-
fromNamespace:
|
|
2109
|
-
|
|
2304
|
+
fromNamespace: Type2.Optional(
|
|
2305
|
+
Type2.String({
|
|
2110
2306
|
description: "Source namespace (default: defaultNamespace)."
|
|
2111
2307
|
})
|
|
2112
2308
|
),
|
|
2113
|
-
toNamespace:
|
|
2114
|
-
|
|
2309
|
+
toNamespace: Type2.Optional(
|
|
2310
|
+
Type2.String({
|
|
2115
2311
|
description: "Target namespace (default: sharedNamespace)."
|
|
2116
2312
|
})
|
|
2117
2313
|
),
|
|
2118
|
-
note:
|
|
2119
|
-
|
|
2314
|
+
note: Type2.Optional(
|
|
2315
|
+
Type2.String({
|
|
2120
2316
|
description: "Optional note explaining why this should be shared (stored as a tag-like annotation)."
|
|
2121
2317
|
})
|
|
2122
2318
|
)
|
|
2123
2319
|
}),
|
|
2124
2320
|
async execute(_toolCallId, params) {
|
|
2125
2321
|
if (!orchestrator.config.namespacesEnabled) {
|
|
2126
|
-
return
|
|
2322
|
+
return toolResult2(
|
|
2127
2323
|
"Namespaces are disabled. Enable `namespacesEnabled: true` to use memory promotion."
|
|
2128
2324
|
);
|
|
2129
2325
|
}
|
|
@@ -2131,7 +2327,7 @@ Best for:
|
|
|
2131
2327
|
orchestrator,
|
|
2132
2328
|
params
|
|
2133
2329
|
);
|
|
2134
|
-
return
|
|
2330
|
+
return toolResult2(message);
|
|
2135
2331
|
}
|
|
2136
2332
|
},
|
|
2137
2333
|
{ name: "memory_promote" }
|
|
@@ -2149,9 +2345,9 @@ Best for:
|
|
|
2149
2345
|
- Understanding the user holistically
|
|
2150
2346
|
- Checking preferences before making decisions
|
|
2151
2347
|
- "What do you know about me?"`,
|
|
2152
|
-
parameters:
|
|
2153
|
-
namespace:
|
|
2154
|
-
|
|
2348
|
+
parameters: Type2.Object({
|
|
2349
|
+
namespace: Type2.Optional(
|
|
2350
|
+
Type2.String({
|
|
2155
2351
|
description: "Optional namespace override. Defaults to the default namespace."
|
|
2156
2352
|
})
|
|
2157
2353
|
)
|
|
@@ -2161,11 +2357,11 @@ Best for:
|
|
|
2161
2357
|
const storage = await orchestrator.getStorageForNamespace(namespace);
|
|
2162
2358
|
const profile = await storage.readProfile();
|
|
2163
2359
|
if (!profile) {
|
|
2164
|
-
return
|
|
2360
|
+
return toolResult2(
|
|
2165
2361
|
"No profile built yet. The profile builds automatically through conversations."
|
|
2166
2362
|
);
|
|
2167
2363
|
}
|
|
2168
|
-
return
|
|
2364
|
+
return toolResult2(`## User Profile
|
|
2169
2365
|
|
|
2170
2366
|
${profile}`);
|
|
2171
2367
|
}
|
|
@@ -2184,9 +2380,9 @@ Speed: Instant
|
|
|
2184
2380
|
Best for:
|
|
2185
2381
|
- Seeing all known entities
|
|
2186
2382
|
- Looking up facts about a specific entity`,
|
|
2187
|
-
parameters:
|
|
2188
|
-
name:
|
|
2189
|
-
|
|
2383
|
+
parameters: Type2.Object({
|
|
2384
|
+
name: Type2.Optional(
|
|
2385
|
+
Type2.String({
|
|
2190
2386
|
description: "Specific entity to look up (e.g., person-jane-doe)"
|
|
2191
2387
|
})
|
|
2192
2388
|
)
|
|
@@ -2196,17 +2392,17 @@ Best for:
|
|
|
2196
2392
|
if (name) {
|
|
2197
2393
|
const content = await orchestrator.storage.readEntity(name);
|
|
2198
2394
|
if (!content) {
|
|
2199
|
-
return
|
|
2395
|
+
return toolResult2(`Entity "${name}" not found.`);
|
|
2200
2396
|
}
|
|
2201
|
-
return
|
|
2397
|
+
return toolResult2(content);
|
|
2202
2398
|
}
|
|
2203
2399
|
const entities = await orchestrator.storage.readEntities();
|
|
2204
2400
|
if (entities.length === 0) {
|
|
2205
|
-
return
|
|
2401
|
+
return toolResult2(
|
|
2206
2402
|
"No entities tracked yet. Entities build automatically through conversations."
|
|
2207
2403
|
);
|
|
2208
2404
|
}
|
|
2209
|
-
return
|
|
2405
|
+
return toolResult2(
|
|
2210
2406
|
`## Known Entities (${entities.length})
|
|
2211
2407
|
|
|
2212
2408
|
${entities.map((e) => `- ${e}`).join("\n")}`
|
|
@@ -2228,15 +2424,15 @@ Best for:
|
|
|
2228
2424
|
- Seeing what questions have been generated from past conversations
|
|
2229
2425
|
- Resolving questions that have been answered
|
|
2230
2426
|
- "What questions do you have for me?"`,
|
|
2231
|
-
parameters:
|
|
2232
|
-
action:
|
|
2233
|
-
|
|
2427
|
+
parameters: Type2.Object({
|
|
2428
|
+
action: Type2.Optional(
|
|
2429
|
+
Type2.String({
|
|
2234
2430
|
description: '"list" (default) to show unresolved questions, "all" to show all, "resolve" to mark one as answered',
|
|
2235
2431
|
enum: ["list", "all", "resolve"]
|
|
2236
2432
|
})
|
|
2237
2433
|
),
|
|
2238
|
-
questionId:
|
|
2239
|
-
|
|
2434
|
+
questionId: Type2.Optional(
|
|
2435
|
+
Type2.String({
|
|
2240
2436
|
description: "Question ID to resolve (required when action is 'resolve')"
|
|
2241
2437
|
})
|
|
2242
2438
|
)
|
|
@@ -2245,15 +2441,15 @@ Best for:
|
|
|
2245
2441
|
const { action = "list", questionId } = params;
|
|
2246
2442
|
if (action === "resolve") {
|
|
2247
2443
|
if (!questionId) {
|
|
2248
|
-
return
|
|
2444
|
+
return toolResult2("Error: questionId is required when action is 'resolve'");
|
|
2249
2445
|
}
|
|
2250
2446
|
const resolved = await orchestrator.storage.resolveQuestion(questionId);
|
|
2251
|
-
return
|
|
2447
|
+
return toolResult2(resolved ? `Question ${questionId} marked as resolved.` : `Question ${questionId} not found.`);
|
|
2252
2448
|
}
|
|
2253
2449
|
const unresolvedOnly = action !== "all";
|
|
2254
2450
|
const questions = await orchestrator.storage.readQuestions({ unresolvedOnly });
|
|
2255
2451
|
if (questions.length === 0) {
|
|
2256
|
-
return
|
|
2452
|
+
return toolResult2(unresolvedOnly ? "No unresolved questions. Questions are generated automatically during memory extraction." : "No questions found.");
|
|
2257
2453
|
}
|
|
2258
2454
|
const formatted = questions.map(
|
|
2259
2455
|
(q, i) => `### [${i + 1}] ${q.id}
|
|
@@ -2263,7 +2459,7 @@ ${q.question}
|
|
|
2263
2459
|
|
|
2264
2460
|
_Context: ${q.context}_`
|
|
2265
2461
|
).join("\n\n");
|
|
2266
|
-
return
|
|
2462
|
+
return toolResult2(`## Questions (${questions.length})
|
|
2267
2463
|
|
|
2268
2464
|
${formatted}`);
|
|
2269
2465
|
}
|
|
@@ -2283,9 +2479,9 @@ Best for:
|
|
|
2283
2479
|
- Understanding the agent's self-model and growth
|
|
2284
2480
|
- "What have you learned about yourself?"
|
|
2285
2481
|
- Reviewing identity development over time`,
|
|
2286
|
-
parameters:
|
|
2287
|
-
namespace:
|
|
2288
|
-
|
|
2482
|
+
parameters: Type2.Object({
|
|
2483
|
+
namespace: Type2.Optional(
|
|
2484
|
+
Type2.String({
|
|
2289
2485
|
description: "Optional namespace override. Defaults to the default namespace."
|
|
2290
2486
|
})
|
|
2291
2487
|
)
|
|
@@ -2295,9 +2491,9 @@ Best for:
|
|
|
2295
2491
|
const storage = await orchestrator.getStorageForNamespace(namespace);
|
|
2296
2492
|
const identity = await storage.readIdentityReflections();
|
|
2297
2493
|
if (!identity) {
|
|
2298
|
-
return
|
|
2494
|
+
return toolResult2("No identity reflections found. Identity reflections build automatically through conversations when identityEnabled is true.");
|
|
2299
2495
|
}
|
|
2300
|
-
return
|
|
2496
|
+
return toolResult2(`## Agent Identity
|
|
2301
2497
|
|
|
2302
2498
|
${identity}`);
|
|
2303
2499
|
}
|
|
@@ -2317,32 +2513,32 @@ Best for:
|
|
|
2317
2513
|
- Nightly incremental governance sweeps
|
|
2318
2514
|
- Manual shadow runs on recent memory windows
|
|
2319
2515
|
- Small-batch review queue generation without scanning the full corpus at once`,
|
|
2320
|
-
parameters:
|
|
2321
|
-
namespace:
|
|
2322
|
-
|
|
2516
|
+
parameters: Type2.Object({
|
|
2517
|
+
namespace: Type2.Optional(
|
|
2518
|
+
Type2.String({
|
|
2323
2519
|
description: "Optional namespace override. Defaults to the default namespace."
|
|
2324
2520
|
})
|
|
2325
2521
|
),
|
|
2326
|
-
mode:
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2522
|
+
mode: Type2.Optional(
|
|
2523
|
+
Type2.Union([
|
|
2524
|
+
Type2.Literal("shadow"),
|
|
2525
|
+
Type2.Literal("apply")
|
|
2330
2526
|
], {
|
|
2331
2527
|
description: "Governance mode. Defaults to shadow."
|
|
2332
2528
|
})
|
|
2333
2529
|
),
|
|
2334
|
-
recentDays:
|
|
2335
|
-
|
|
2530
|
+
recentDays: Type2.Optional(
|
|
2531
|
+
Type2.Number({
|
|
2336
2532
|
description: "Only scan memories updated within the last N days."
|
|
2337
2533
|
})
|
|
2338
2534
|
),
|
|
2339
|
-
maxMemories:
|
|
2340
|
-
|
|
2535
|
+
maxMemories: Type2.Optional(
|
|
2536
|
+
Type2.Number({
|
|
2341
2537
|
description: "Maximum number of memories to scan in this run."
|
|
2342
2538
|
})
|
|
2343
2539
|
),
|
|
2344
|
-
batchSize:
|
|
2345
|
-
|
|
2540
|
+
batchSize: Type2.Optional(
|
|
2541
|
+
Type2.Number({
|
|
2346
2542
|
description: "File-read batch size for bounded governance runs."
|
|
2347
2543
|
})
|
|
2348
2544
|
)
|
|
@@ -2350,7 +2546,7 @@ Best for:
|
|
|
2350
2546
|
async execute(_toolCallId, params) {
|
|
2351
2547
|
const deepSleep = orchestrator.config.dreamsPhases.deepSleep;
|
|
2352
2548
|
if (deepSleep.enabled === false && deepSleep.enabledExplicitlySet === true) {
|
|
2353
|
-
return
|
|
2549
|
+
return toolResult2(
|
|
2354
2550
|
"Memory governance is disabled by `dreams.phases.deepSleep.enabled=false`."
|
|
2355
2551
|
);
|
|
2356
2552
|
}
|
|
@@ -2394,13 +2590,13 @@ Best for:
|
|
|
2394
2590
|
- Cron job scheduled hourly summarization
|
|
2395
2591
|
- Manual trigger to summarize recent conversations
|
|
2396
2592
|
- Building conversation summaries for context preservation`,
|
|
2397
|
-
parameters:
|
|
2593
|
+
parameters: Type2.Object({}),
|
|
2398
2594
|
async execute() {
|
|
2399
2595
|
try {
|
|
2400
2596
|
await orchestrator.summarizer.runHourly();
|
|
2401
|
-
return
|
|
2597
|
+
return toolResult2("Hourly summarization completed. Check the summaries directory for results.");
|
|
2402
2598
|
} catch (err) {
|
|
2403
|
-
return
|
|
2599
|
+
return toolResult2(`Hourly summarization failed: ${err}`);
|
|
2404
2600
|
}
|
|
2405
2601
|
}
|
|
2406
2602
|
},
|
|
@@ -2417,28 +2613,28 @@ This is optional and default-off (see config: conversationIndexEnabled).
|
|
|
2417
2613
|
Best for:
|
|
2418
2614
|
- Cron jobs to keep the conversation index fresh
|
|
2419
2615
|
- Manual rebuild after changing chunk sizes or retention`,
|
|
2420
|
-
parameters:
|
|
2421
|
-
sessionKey:
|
|
2422
|
-
|
|
2616
|
+
parameters: Type2.Object({
|
|
2617
|
+
sessionKey: Type2.Optional(
|
|
2618
|
+
Type2.String({
|
|
2423
2619
|
description: "Session key to index. If omitted, Engram will best-effort scan transcript storage and index all discovered sessionKeys."
|
|
2424
2620
|
})
|
|
2425
2621
|
),
|
|
2426
|
-
hours:
|
|
2427
|
-
|
|
2622
|
+
hours: Type2.Optional(
|
|
2623
|
+
Type2.Number({
|
|
2428
2624
|
description: "How many hours of transcript history to include (default: 24).",
|
|
2429
2625
|
minimum: 1,
|
|
2430
2626
|
maximum: 24 * 30
|
|
2431
2627
|
})
|
|
2432
2628
|
),
|
|
2433
|
-
embed:
|
|
2434
|
-
|
|
2629
|
+
embed: Type2.Optional(
|
|
2630
|
+
Type2.Boolean({
|
|
2435
2631
|
description: "If true, run QMD embed after update for this invocation. If omitted, uses conversationIndexEmbedOnUpdate config."
|
|
2436
2632
|
})
|
|
2437
2633
|
)
|
|
2438
2634
|
}),
|
|
2439
2635
|
async execute(_toolCallId, params) {
|
|
2440
2636
|
if (!orchestrator.config.conversationIndexEnabled) {
|
|
2441
|
-
return
|
|
2637
|
+
return toolResult2(
|
|
2442
2638
|
"Conversation indexing is disabled. Enable `conversationIndexEnabled: true` in the Engram plugin config to use this tool."
|
|
2443
2639
|
);
|
|
2444
2640
|
}
|
|
@@ -2448,11 +2644,11 @@ Best for:
|
|
|
2448
2644
|
const res = await orchestrator.conversationIndexCoordinator.update(sessionKey, h, { embed });
|
|
2449
2645
|
if (res.skipped && res.reason === "min_interval") {
|
|
2450
2646
|
const retrySec = Math.max(1, Math.ceil((res.retryAfterMs ?? 0) / 1e3));
|
|
2451
|
-
return
|
|
2647
|
+
return toolResult2(
|
|
2452
2648
|
`Skipped for sessionKey=${sessionKey} due to min interval. Retry in ~${retrySec}s or pass a higher interval config.`
|
|
2453
2649
|
);
|
|
2454
2650
|
}
|
|
2455
|
-
return
|
|
2651
|
+
return toolResult2(
|
|
2456
2652
|
`Indexed ${res.chunks} chunk(s) for sessionKey=${sessionKey}.${res.embedded ? " Ran embed." : ""}`
|
|
2457
2653
|
);
|
|
2458
2654
|
}
|
|
@@ -2472,7 +2668,7 @@ Best for:
|
|
|
2472
2668
|
}
|
|
2473
2669
|
const skippedSummary = skipped > 0 ? ` Skipped ${skipped} session(s) due to min-interval gating: ${skippedIds.slice(0, 6).join(", ")}${skippedIds.length > 6 ? "..." : ""}.` : "";
|
|
2474
2670
|
const embedSummary = embeddedRuns > 0 ? ` Ran embed for ${embeddedRuns} session update(s).` : "";
|
|
2475
|
-
return
|
|
2671
|
+
return toolResult2(
|
|
2476
2672
|
`Indexed ${total} total chunk(s) across ${sessions.length} session(s).${skippedSummary}${embedSummary}`
|
|
2477
2673
|
);
|
|
2478
2674
|
}
|
|
@@ -2484,21 +2680,21 @@ Best for:
|
|
|
2484
2680
|
name: "work_task",
|
|
2485
2681
|
label: "Manage Work Tasks",
|
|
2486
2682
|
description: "Manage Engram work-layer tasks (create, get, list, update, transition, delete). Responses are marked as work-layer context and excluded from default memory extraction.",
|
|
2487
|
-
parameters:
|
|
2488
|
-
action:
|
|
2683
|
+
parameters: Type2.Object({
|
|
2684
|
+
action: Type2.String({
|
|
2489
2685
|
enum: ["create", "get", "list", "update", "transition", "delete"],
|
|
2490
2686
|
description: "Task action to run."
|
|
2491
2687
|
}),
|
|
2492
|
-
id:
|
|
2493
|
-
title:
|
|
2494
|
-
description:
|
|
2495
|
-
status:
|
|
2496
|
-
priority:
|
|
2497
|
-
owner:
|
|
2498
|
-
assignee:
|
|
2499
|
-
projectId:
|
|
2500
|
-
tags:
|
|
2501
|
-
dueAt:
|
|
2688
|
+
id: Type2.Optional(Type2.String({ description: "Task ID for get/update/transition/delete." })),
|
|
2689
|
+
title: Type2.Optional(Type2.String({ description: "Task title (create/update)." })),
|
|
2690
|
+
description: Type2.Optional(Type2.String({ description: "Task description (create/update)." })),
|
|
2691
|
+
status: Type2.Optional(Type2.String({ enum: ["todo", "in_progress", "blocked", "done", "cancelled"] })),
|
|
2692
|
+
priority: Type2.Optional(Type2.String({ enum: ["low", "medium", "high"] })),
|
|
2693
|
+
owner: Type2.Optional(Type2.String()),
|
|
2694
|
+
assignee: Type2.Optional(Type2.String()),
|
|
2695
|
+
projectId: Type2.Optional(Type2.String()),
|
|
2696
|
+
tags: Type2.Optional(Type2.Array(Type2.String())),
|
|
2697
|
+
dueAt: Type2.Optional(Type2.String())
|
|
2502
2698
|
}),
|
|
2503
2699
|
async execute(_toolCallId, params) {
|
|
2504
2700
|
const p = params;
|
|
@@ -2606,19 +2802,19 @@ Best for:
|
|
|
2606
2802
|
name: "work_project",
|
|
2607
2803
|
label: "Manage Work Projects",
|
|
2608
2804
|
description: "Manage Engram work-layer projects (create, get, list, update, delete, link_task). Responses are marked as work-layer context and excluded from default memory extraction.",
|
|
2609
|
-
parameters:
|
|
2610
|
-
action:
|
|
2805
|
+
parameters: Type2.Object({
|
|
2806
|
+
action: Type2.String({
|
|
2611
2807
|
enum: ["create", "get", "list", "update", "delete", "link_task"],
|
|
2612
2808
|
description: "Project action to run."
|
|
2613
2809
|
}),
|
|
2614
|
-
id:
|
|
2615
|
-
name:
|
|
2616
|
-
description:
|
|
2617
|
-
status:
|
|
2618
|
-
owner:
|
|
2619
|
-
tags:
|
|
2620
|
-
taskId:
|
|
2621
|
-
projectId:
|
|
2810
|
+
id: Type2.Optional(Type2.String({ description: "Project ID for get/update/delete." })),
|
|
2811
|
+
name: Type2.Optional(Type2.String({ description: "Project name (create/update)." })),
|
|
2812
|
+
description: Type2.Optional(Type2.String({ description: "Project description (create/update)." })),
|
|
2813
|
+
status: Type2.Optional(Type2.String({ enum: ["active", "on_hold", "completed", "archived"] })),
|
|
2814
|
+
owner: Type2.Optional(Type2.String()),
|
|
2815
|
+
tags: Type2.Optional(Type2.Array(Type2.String())),
|
|
2816
|
+
taskId: Type2.Optional(Type2.String({ description: "Task ID for link_task action." })),
|
|
2817
|
+
projectId: Type2.Optional(Type2.String({ description: "Project ID for link_task action." }))
|
|
2622
2818
|
}),
|
|
2623
2819
|
async execute(_toolCallId, params) {
|
|
2624
2820
|
const p = params;
|
|
@@ -2700,15 +2896,15 @@ Best for:
|
|
|
2700
2896
|
name: "work_board",
|
|
2701
2897
|
label: "Work Board Import/Export",
|
|
2702
2898
|
description: "Export/import work-layer board snapshots and markdown. Outputs are marked as work-layer context and excluded from default memory extraction unless explicitly linked.",
|
|
2703
|
-
parameters:
|
|
2704
|
-
action:
|
|
2899
|
+
parameters: Type2.Object({
|
|
2900
|
+
action: Type2.String({
|
|
2705
2901
|
enum: ["export_markdown", "export_snapshot", "import_snapshot"],
|
|
2706
2902
|
description: "Board action to run."
|
|
2707
2903
|
}),
|
|
2708
|
-
projectId:
|
|
2709
|
-
snapshotJson:
|
|
2710
|
-
linkToMemory:
|
|
2711
|
-
|
|
2904
|
+
projectId: Type2.Optional(Type2.String({ description: "Optional project filter/id." })),
|
|
2905
|
+
snapshotJson: Type2.Optional(Type2.String({ description: "Snapshot JSON payload for import_snapshot." })),
|
|
2906
|
+
linkToMemory: Type2.Optional(
|
|
2907
|
+
Type2.Boolean({
|
|
2712
2908
|
description: "If true, wrap output as linkable work context so extraction can retain it as long-term memory."
|
|
2713
2909
|
})
|
|
2714
2910
|
)
|
|
@@ -2722,7 +2918,7 @@ Best for:
|
|
|
2722
2918
|
await new WorkStorage(orchestrator.config.memoryDir).ensureDirectories();
|
|
2723
2919
|
if (action === "export_markdown") {
|
|
2724
2920
|
const markdown = await exportWorkBoardMarkdown({ memoryDir: orchestrator.config.memoryDir, projectId });
|
|
2725
|
-
return
|
|
2921
|
+
return toolResult2(wrapWorkLayerContext(markdown, { linkToMemory }));
|
|
2726
2922
|
}
|
|
2727
2923
|
if (action === "export_snapshot") {
|
|
2728
2924
|
const snapshot = await exportWorkBoardSnapshot({ memoryDir: orchestrator.config.memoryDir, projectId });
|
|
@@ -2750,193 +2946,28 @@ Best for:
|
|
|
2750
2946
|
},
|
|
2751
2947
|
{ name: "work_board" }
|
|
2752
2948
|
);
|
|
2753
|
-
api
|
|
2754
|
-
{
|
|
2755
|
-
name: "shared_context_write_output",
|
|
2756
|
-
label: "Write Shared Agent Output",
|
|
2757
|
-
description: "Write an agent work product into the shared-context directory (v4.0). Other agents can read these files to coordinate without explicit message passing.",
|
|
2758
|
-
parameters: Type.Object({
|
|
2759
|
-
// Provenance is server-derived from the host runtime agent; a
|
|
2760
|
-
// mismatching value here is rejected, never used as the origin.
|
|
2761
|
-
agentId: Type.String({ description: "Agent ID producing this output; must match this host's runtime agent id when the host exposes one." }),
|
|
2762
|
-
title: Type.String({ description: "Short title for the output." }),
|
|
2763
|
-
content: Type.String({ description: "Markdown content to write." })
|
|
2764
|
-
}),
|
|
2765
|
-
async execute(_toolCallId, params) {
|
|
2766
|
-
const { agentId, title, content } = params;
|
|
2767
|
-
if (!orchestrator.sharedContext) {
|
|
2768
|
-
return toolResult(
|
|
2769
|
-
"Shared context is disabled. Enable `sharedContextEnabled: true` to use shared-context tools."
|
|
2770
|
-
);
|
|
2771
|
-
}
|
|
2772
|
-
try {
|
|
2773
|
-
const fp = await orchestrator.sharedContext.writeAgentOutput({
|
|
2774
|
-
title,
|
|
2775
|
-
content,
|
|
2776
|
-
...openClawToolWriteOrigin(hostRuntimeAgentId, agentId)
|
|
2777
|
-
});
|
|
2778
|
-
return toolResult(`Wrote shared agent output: ${fp}`);
|
|
2779
|
-
} catch (err) {
|
|
2780
|
-
return toolResult(`shared_context_write_output error: ${err instanceof Error ? err.message : String(err)}`);
|
|
2781
|
-
}
|
|
2782
|
-
}
|
|
2783
|
-
},
|
|
2784
|
-
{ name: "shared_context_write_output" }
|
|
2785
|
-
);
|
|
2786
|
-
api.registerTool(
|
|
2787
|
-
{
|
|
2788
|
-
name: "shared_feedback_record",
|
|
2789
|
-
label: "Record Shared Feedback",
|
|
2790
|
-
description: "Append an approval/rejection decision into shared-context feedback inbox (v4.0/v5.0). Intended to power compounding learning.",
|
|
2791
|
-
parameters: Type.Object({
|
|
2792
|
-
agent: Type.String({ description: "Agent name that produced the recommendation/output." }),
|
|
2793
|
-
decision: Type.String({
|
|
2794
|
-
enum: ["approved", "approved_with_feedback", "rejected"],
|
|
2795
|
-
description: "Decision outcome."
|
|
2796
|
-
}),
|
|
2797
|
-
reason: Type.String({ description: "Why the decision was made (short but specific)." }),
|
|
2798
|
-
date: Type.Optional(Type.String({ description: "ISO timestamp. Defaults to now." })),
|
|
2799
|
-
learning: Type.Optional(Type.String({ description: "Optional distilled learning/pattern." })),
|
|
2800
|
-
outcome: Type.Optional(Type.String({ description: "Optional downstream outcome (day-one supported; may be empty initially)." })),
|
|
2801
|
-
severity: Type.Optional(Type.String({
|
|
2802
|
-
enum: ["low", "medium", "high"],
|
|
2803
|
-
description: "Optional severity rating for the mistake/outcome."
|
|
2804
|
-
})),
|
|
2805
|
-
confidence: Type.Optional(Type.Number({ description: "Optional confidence score from 0 to 1." })),
|
|
2806
|
-
workflow: Type.Optional(Type.String({ description: "Optional workflow or playbook name associated with the feedback." })),
|
|
2807
|
-
tags: Type.Optional(Type.Array(Type.String(), { description: "Optional tags for rubric grouping and recall matching." })),
|
|
2808
|
-
evidenceWindowStart: Type.Optional(Type.String({ description: "Optional start timestamp for the evidence window." })),
|
|
2809
|
-
evidenceWindowEnd: Type.Optional(Type.String({ description: "Optional end timestamp for the evidence window." })),
|
|
2810
|
-
refs: Type.Optional(Type.Array(Type.String(), { description: "Optional references (URLs, IDs, filenames)." }))
|
|
2811
|
-
}),
|
|
2812
|
-
async execute(_toolCallId, params) {
|
|
2813
|
-
if (!orchestrator.sharedContext) {
|
|
2814
|
-
return toolResult(
|
|
2815
|
-
"Shared context is disabled. Enable `sharedContextEnabled: true` to record shared feedback."
|
|
2816
|
-
);
|
|
2817
|
-
}
|
|
2818
|
-
const p = params;
|
|
2819
|
-
const entry = {
|
|
2820
|
-
agent: String(p.agent ?? ""),
|
|
2821
|
-
decision: p.decision,
|
|
2822
|
-
reason: String(p.reason ?? ""),
|
|
2823
|
-
date: typeof p.date === "string" && p.date.length > 0 ? p.date : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2824
|
-
learning: typeof p.learning === "string" ? p.learning : void 0,
|
|
2825
|
-
outcome: typeof p.outcome === "string" ? p.outcome : void 0,
|
|
2826
|
-
severity: p.severity === "low" || p.severity === "medium" || p.severity === "high" ? p.severity : void 0,
|
|
2827
|
-
confidence: typeof p.confidence === "number" && Number.isFinite(p.confidence) ? p.confidence : void 0,
|
|
2828
|
-
workflow: typeof p.workflow === "string" ? p.workflow : void 0,
|
|
2829
|
-
tags: Array.isArray(p.tags) ? p.tags.map(String) : void 0,
|
|
2830
|
-
evidenceWindowStart: typeof p.evidenceWindowStart === "string" ? p.evidenceWindowStart : void 0,
|
|
2831
|
-
evidenceWindowEnd: typeof p.evidenceWindowEnd === "string" ? p.evidenceWindowEnd : void 0,
|
|
2832
|
-
refs: Array.isArray(p.refs) ? p.refs.map(String) : void 0
|
|
2833
|
-
};
|
|
2834
|
-
await orchestrator.sharedContext.appendFeedback(entry);
|
|
2835
|
-
return toolResult("OK");
|
|
2836
|
-
}
|
|
2837
|
-
},
|
|
2838
|
-
{ name: "shared_feedback_record" }
|
|
2839
|
-
);
|
|
2840
|
-
api.registerTool(
|
|
2841
|
-
{
|
|
2842
|
-
name: "shared_priorities_append",
|
|
2843
|
-
label: "Append Priorities Inbox",
|
|
2844
|
-
description: "Append text into shared-context priorities inbox. A curator run should merge this into priorities.md.",
|
|
2845
|
-
parameters: Type.Object({
|
|
2846
|
-
agentId: Type.String({ description: "Agent ID appending priorities." }),
|
|
2847
|
-
text: Type.String({ description: "Priority notes to append (markdown)." })
|
|
2848
|
-
}),
|
|
2849
|
-
async execute(_toolCallId, params) {
|
|
2850
|
-
if (!orchestrator.sharedContext) {
|
|
2851
|
-
return toolResult(
|
|
2852
|
-
"Shared context is disabled. Enable `sharedContextEnabled: true` to write priorities inbox."
|
|
2853
|
-
);
|
|
2854
|
-
}
|
|
2855
|
-
const { agentId, text } = params;
|
|
2856
|
-
await orchestrator.sharedContext.appendPrioritiesInbox({ agentId, text });
|
|
2857
|
-
return toolResult("OK");
|
|
2858
|
-
}
|
|
2859
|
-
},
|
|
2860
|
-
{ name: "shared_priorities_append" }
|
|
2861
|
-
);
|
|
2862
|
-
api.registerTool(
|
|
2863
|
-
{
|
|
2864
|
-
name: "shared_context_cross_signals_run",
|
|
2865
|
-
label: "Run Cross-Signal Synthesis",
|
|
2866
|
-
description: "Generate today's shared-context cross-signal markdown + JSON artifacts on demand, without requiring a full roundtable curation pass.",
|
|
2867
|
-
parameters: Type.Object({
|
|
2868
|
-
date: Type.Optional(Type.String({ description: "YYYY-MM-DD. Defaults to today." }))
|
|
2869
|
-
}),
|
|
2870
|
-
async execute(_toolCallId, params) {
|
|
2871
|
-
if (!orchestrator.sharedContext) {
|
|
2872
|
-
return toolResult(
|
|
2873
|
-
"Shared context is disabled. Enable `sharedContextEnabled: true` to synthesize cross-signals."
|
|
2874
|
-
);
|
|
2875
|
-
}
|
|
2876
|
-
const { date } = params;
|
|
2877
|
-
const result = await orchestrator.sharedContext.synthesizeCrossSignals({ date });
|
|
2878
|
-
return toolResult(
|
|
2879
|
-
[
|
|
2880
|
-
`Cross-signals markdown: ${result.crossSignalsMarkdownPath}`,
|
|
2881
|
-
`Cross-signals JSON: ${result.crossSignalsPath}`,
|
|
2882
|
-
`Source outputs analyzed: ${result.report.sourceCount}`,
|
|
2883
|
-
`Feedback entries analyzed: ${result.report.feedbackCount}`,
|
|
2884
|
-
`Overlap count: ${result.overlapCount}`
|
|
2885
|
-
].join("\n")
|
|
2886
|
-
);
|
|
2887
|
-
}
|
|
2888
|
-
},
|
|
2889
|
-
{ name: "shared_context_cross_signals_run" }
|
|
2890
|
-
);
|
|
2891
|
-
api.registerTool(
|
|
2892
|
-
{
|
|
2893
|
-
name: "shared_context_curate_daily",
|
|
2894
|
-
label: "Curate Daily Roundtable",
|
|
2895
|
-
description: "Curator tool: generate today's roundtable summary in shared-context/roundtable (deterministic baseline).",
|
|
2896
|
-
parameters: Type.Object({
|
|
2897
|
-
date: Type.Optional(Type.String({ description: "YYYY-MM-DD. Defaults to today." }))
|
|
2898
|
-
}),
|
|
2899
|
-
async execute(_toolCallId, params) {
|
|
2900
|
-
if (!orchestrator.sharedContext) {
|
|
2901
|
-
return toolResult(
|
|
2902
|
-
"Shared context is disabled. Enable `sharedContextEnabled: true` to curate roundtables."
|
|
2903
|
-
);
|
|
2904
|
-
}
|
|
2905
|
-
const { date } = params;
|
|
2906
|
-
const result = await orchestrator.sharedContext.curateDaily({ date });
|
|
2907
|
-
return toolResult(
|
|
2908
|
-
[
|
|
2909
|
-
`Roundtable: ${result.roundtablePath}`,
|
|
2910
|
-
`Cross-signals markdown: ${result.crossSignalsMarkdownPath}`,
|
|
2911
|
-
`Cross-signals JSON: ${result.crossSignalsPath}`,
|
|
2912
|
-
`Overlap count: ${result.overlapCount}`
|
|
2913
|
-
].join("\n")
|
|
2914
|
-
);
|
|
2915
|
-
}
|
|
2916
|
-
},
|
|
2917
|
-
{ name: "shared_context_curate_daily" }
|
|
2918
|
-
);
|
|
2949
|
+
registerSharedContextTools(api, orchestrator, hostRuntimeAgentId);
|
|
2919
2950
|
api.registerTool(
|
|
2920
2951
|
{
|
|
2921
2952
|
name: "compounding_weekly_synthesize",
|
|
2922
2953
|
label: "Synthesize Weekly Learning",
|
|
2923
2954
|
description: "Generate weekly compounding outputs (v5.0): weekly markdown + JSON reports, stable mistake registry, and rubric artifacts. Designed to work from day one (writes even if no feedback exists yet).",
|
|
2924
|
-
parameters:
|
|
2925
|
-
weekId:
|
|
2926
|
-
|
|
2955
|
+
parameters: Type2.Object({
|
|
2956
|
+
weekId: Type2.Optional(
|
|
2957
|
+
Type2.String({
|
|
2927
2958
|
description: "ISO week ID like YYYY-Www. Omit to use current week."
|
|
2928
2959
|
})
|
|
2929
2960
|
)
|
|
2930
2961
|
}),
|
|
2931
2962
|
async execute(_toolCallId, params) {
|
|
2932
2963
|
if (!orchestrator.compounding) {
|
|
2933
|
-
return
|
|
2964
|
+
return toolResult2(
|
|
2934
2965
|
"Compounding engine is disabled. Enable `compoundingEnabled: true` to use this tool."
|
|
2935
2966
|
);
|
|
2936
2967
|
}
|
|
2937
2968
|
const { weekId } = params;
|
|
2938
2969
|
const res = await orchestrator.compounding.synthesizeWeekly({ weekId });
|
|
2939
|
-
return
|
|
2970
|
+
return toolResult2(
|
|
2940
2971
|
`OK
|
|
2941
2972
|
|
|
2942
2973
|
weekId: ${res.weekId}
|
|
@@ -2956,26 +2987,26 @@ promotionCandidates: ${res.promotionCandidateCount}`
|
|
|
2956
2987
|
name: "compounding_promote_candidate",
|
|
2957
2988
|
label: "Promote Compounding Candidate",
|
|
2958
2989
|
description: "Persist one advisory compounding promotion candidate into durable rule/principle memory. Never auto-promotes; this is an explicit operator action.",
|
|
2959
|
-
parameters:
|
|
2960
|
-
weekId:
|
|
2990
|
+
parameters: Type2.Object({
|
|
2991
|
+
weekId: Type2.String({
|
|
2961
2992
|
description: "ISO week ID like YYYY-Www matching the synthesized weekly artifact."
|
|
2962
2993
|
}),
|
|
2963
|
-
candidateId:
|
|
2994
|
+
candidateId: Type2.String({
|
|
2964
2995
|
description: "Promotion candidate id from the weekly compounding report or JSON artifact."
|
|
2965
2996
|
}),
|
|
2966
|
-
dryRun:
|
|
2997
|
+
dryRun: Type2.Optional(Type2.Boolean({
|
|
2967
2998
|
description: "If true, preview the promoted guidance without writing memory."
|
|
2968
2999
|
}))
|
|
2969
3000
|
}),
|
|
2970
3001
|
async execute(_toolCallId, params) {
|
|
2971
3002
|
if (!orchestrator.compounding) {
|
|
2972
|
-
return
|
|
3003
|
+
return toolResult2(
|
|
2973
3004
|
"Compounding engine is disabled. Enable `compoundingEnabled: true` to use this tool."
|
|
2974
3005
|
);
|
|
2975
3006
|
}
|
|
2976
3007
|
const { weekId, candidateId, dryRun } = params;
|
|
2977
3008
|
const result = await orchestrator.compounding.promoteCandidate({ weekId, candidateId, dryRun });
|
|
2978
|
-
return
|
|
3009
|
+
return toolResult2(JSON.stringify(result, null, 2));
|
|
2979
3010
|
}
|
|
2980
3011
|
},
|
|
2981
3012
|
{ name: "compounding_promote_candidate" }
|
|
@@ -2991,14 +3022,14 @@ Requires profilingEnabled: true in plugin config.
|
|
|
2991
3022
|
Shows per-step timing with parallel vs sequential structure, bottleneck identification, and aggregate stats.
|
|
2992
3023
|
|
|
2993
3024
|
Returns: Performance trace data with timing breakdown`,
|
|
2994
|
-
parameters:
|
|
2995
|
-
format:
|
|
2996
|
-
|
|
3025
|
+
parameters: Type2.Object({
|
|
3026
|
+
format: Type2.Optional(
|
|
3027
|
+
Type2.String({
|
|
2997
3028
|
description: 'Output format: "ascii" for human-readable or "json" for structured data'
|
|
2998
3029
|
})
|
|
2999
3030
|
),
|
|
3000
|
-
limit:
|
|
3001
|
-
|
|
3031
|
+
limit: Type2.Optional(
|
|
3032
|
+
Type2.Number({
|
|
3002
3033
|
description: "Number of recent traces to include (1-20, default 5)",
|
|
3003
3034
|
minimum: 1,
|
|
3004
3035
|
maximum: 20
|
|
@@ -3008,7 +3039,7 @@ Returns: Performance trace data with timing breakdown`,
|
|
|
3008
3039
|
async execute(_toolCallId, params) {
|
|
3009
3040
|
const profiler = orchestrator.profiler;
|
|
3010
3041
|
if (!profiler.isEnabled) {
|
|
3011
|
-
return
|
|
3042
|
+
return toolResult2(
|
|
3012
3043
|
"Profiling is disabled. Set profilingEnabled: true in your plugin config to enable."
|
|
3013
3044
|
);
|
|
3014
3045
|
}
|
|
@@ -3018,7 +3049,7 @@ Returns: Performance trace data with timing breakdown`,
|
|
|
3018
3049
|
const stats = profiler.getStats();
|
|
3019
3050
|
const bottleneck = profiler.identifyBottleneck();
|
|
3020
3051
|
if (format === "json") {
|
|
3021
|
-
return
|
|
3052
|
+
return toolResult2(JSON.stringify({ traces, stats, bottleneck }, null, 2));
|
|
3022
3053
|
}
|
|
3023
3054
|
const lines = [];
|
|
3024
3055
|
lines.push("Engram Profiling Report");
|
|
@@ -3052,7 +3083,7 @@ Returns: Performance trace data with timing breakdown`,
|
|
|
3052
3083
|
lines.push("");
|
|
3053
3084
|
}
|
|
3054
3085
|
}
|
|
3055
|
-
return
|
|
3086
|
+
return toolResult2(lines.join("\n"));
|
|
3056
3087
|
}
|
|
3057
3088
|
},
|
|
3058
3089
|
{ name: "remnic_profiling_report" }
|
|
@@ -3062,14 +3093,14 @@ Returns: Performance trace data with timing breakdown`,
|
|
|
3062
3093
|
name: "engram_profiling_report",
|
|
3063
3094
|
label: "Profiling Report",
|
|
3064
3095
|
description: `Legacy alias for remnic_profiling_report.`,
|
|
3065
|
-
parameters:
|
|
3066
|
-
format:
|
|
3067
|
-
|
|
3096
|
+
parameters: Type2.Object({
|
|
3097
|
+
format: Type2.Optional(
|
|
3098
|
+
Type2.String({
|
|
3068
3099
|
description: 'Output format: "ascii" for human-readable or "json" for structured data'
|
|
3069
3100
|
})
|
|
3070
3101
|
),
|
|
3071
|
-
limit:
|
|
3072
|
-
|
|
3102
|
+
limit: Type2.Optional(
|
|
3103
|
+
Type2.Number({
|
|
3073
3104
|
description: "Number of recent traces to include (1-20, default 5)",
|
|
3074
3105
|
minimum: 1,
|
|
3075
3106
|
maximum: 20
|
|
@@ -3079,7 +3110,7 @@ Returns: Performance trace data with timing breakdown`,
|
|
|
3079
3110
|
async execute(_toolCallId, params) {
|
|
3080
3111
|
const profiler = orchestrator.profiler;
|
|
3081
3112
|
if (!profiler.isEnabled) {
|
|
3082
|
-
return
|
|
3113
|
+
return toolResult2(
|
|
3083
3114
|
"Profiling is disabled. Set profilingEnabled: true in your plugin config to enable."
|
|
3084
3115
|
);
|
|
3085
3116
|
}
|
|
@@ -3089,7 +3120,7 @@ Returns: Performance trace data with timing breakdown`,
|
|
|
3089
3120
|
const stats = profiler.getStats();
|
|
3090
3121
|
const bottleneck = profiler.identifyBottleneck();
|
|
3091
3122
|
if (format === "json") {
|
|
3092
|
-
return
|
|
3123
|
+
return toolResult2(JSON.stringify({ traces, stats, bottleneck }, null, 2));
|
|
3093
3124
|
}
|
|
3094
3125
|
const lines = [];
|
|
3095
3126
|
lines.push("Engram Profiling Report");
|
|
@@ -3123,7 +3154,7 @@ Returns: Performance trace data with timing breakdown`,
|
|
|
3123
3154
|
lines.push("");
|
|
3124
3155
|
}
|
|
3125
3156
|
}
|
|
3126
|
-
return
|
|
3157
|
+
return toolResult2(lines.join("\n"));
|
|
3127
3158
|
}
|
|
3128
3159
|
},
|
|
3129
3160
|
{ name: "engram_profiling_report" }
|
|
@@ -3403,17 +3434,17 @@ import {
|
|
|
3403
3434
|
} from "@remnic/core";
|
|
3404
3435
|
|
|
3405
3436
|
// src/openclaw-tools/shapes.ts
|
|
3406
|
-
import { Type as
|
|
3407
|
-
var MemorySearchInputSchema =
|
|
3408
|
-
query:
|
|
3409
|
-
limit:
|
|
3410
|
-
sessionKey:
|
|
3411
|
-
filters:
|
|
3437
|
+
import { Type as Type3 } from "@sinclair/typebox";
|
|
3438
|
+
var MemorySearchInputSchema = Type3.Object({
|
|
3439
|
+
query: Type3.String(),
|
|
3440
|
+
limit: Type3.Optional(Type3.Number({ minimum: 1, maximum: 50 })),
|
|
3441
|
+
sessionKey: Type3.Optional(Type3.String()),
|
|
3442
|
+
filters: Type3.Optional(Type3.Record(Type3.String(), Type3.Unknown()))
|
|
3412
3443
|
});
|
|
3413
|
-
var MemoryGetInputSchema =
|
|
3414
|
-
id:
|
|
3415
|
-
sessionKey:
|
|
3416
|
-
namespace:
|
|
3444
|
+
var MemoryGetInputSchema = Type3.Object({
|
|
3445
|
+
id: Type3.String(),
|
|
3446
|
+
sessionKey: Type3.Optional(Type3.String()),
|
|
3447
|
+
namespace: Type3.Optional(Type3.String())
|
|
3417
3448
|
});
|
|
3418
3449
|
|
|
3419
3450
|
// src/openclaw-tools/tool-json-result.ts
|
|
@@ -12486,6 +12517,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
12486
12517
|
} finally {
|
|
12487
12518
|
finishCodex();
|
|
12488
12519
|
}
|
|
12520
|
+
terminateActiveCodexSubscriptionChildren("SIGKILL", getCodexSubscriptionRunnerForOwner(cfg));
|
|
12489
12521
|
if (globalThis[keys.ORCHESTRATOR] === orchestrator) {
|
|
12490
12522
|
delete globalThis[keys.ORCHESTRATOR];
|
|
12491
12523
|
}
|