@kinqs/brainrouter-mcp-server 0.3.4
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/.env.example +144 -0
- package/README.md +56 -0
- package/agents/README.md +120 -0
- package/agents/code-reviewer.md +97 -0
- package/agents/security-auditor.md +101 -0
- package/agents/test-engineer.md +95 -0
- package/dist/__tests__/agent_mode.test.d.ts +1 -0
- package/dist/__tests__/api-routes.test.d.ts +1 -0
- package/dist/__tests__/api-routes.test.js +170 -0
- package/dist/__tests__/crypto.test.d.ts +1 -0
- package/dist/__tests__/crypto.test.js +28 -0
- package/dist/__tests__/host-integrations.test.d.ts +1 -0
- package/dist/__tests__/host-integrations.test.js +82 -0
- package/dist/__tests__/integration.test.d.ts +1 -0
- package/dist/__tests__/integration.test.js +50 -0
- package/dist/__tests__/loader.test.d.ts +1 -0
- package/dist/__tests__/loader.test.js +89 -0
- package/dist/__tests__/neural-spark.test.d.ts +1 -0
- package/dist/__tests__/neural-spark.test.js +112 -0
- package/dist/__tests__/pagination.test.d.ts +1 -0
- package/dist/__tests__/pagination.test.js +23 -0
- package/dist/__tests__/redaction.test.d.ts +1 -0
- package/dist/__tests__/redaction.test.js +17 -0
- package/dist/__tests__/registry.test.d.ts +1 -0
- package/dist/__tests__/registry.test.js +56 -0
- package/dist/__tests__/retry.test.d.ts +1 -0
- package/dist/__tests__/retry.test.js +30 -0
- package/dist/__tests__/skill-activation.test.d.ts +1 -0
- package/dist/__tests__/skill-activation.test.js +112 -0
- package/dist/__tests__/working-memory.test.d.ts +1 -0
- package/dist/__tests__/working-memory.test.js +200 -0
- package/dist/__tests__/workspace-paths.test.d.ts +1 -0
- package/dist/__tests__/workspace-paths.test.js +56 -0
- package/dist/__tests__/writer.test.d.ts +1 -0
- package/dist/__tests__/writer.test.js +94 -0
- package/dist/api/auth/crypto.d.ts +4 -0
- package/dist/api/auth/crypto.js +54 -0
- package/dist/api/middleware/auth.d.ts +12 -0
- package/dist/api/middleware/auth.js +90 -0
- package/dist/api/pagination.d.ts +18 -0
- package/dist/api/pagination.js +32 -0
- package/dist/api/routes/auth.d.ts +1 -0
- package/dist/api/routes/auth.js +130 -0
- package/dist/api/routes/chat-completions.d.ts +7 -0
- package/dist/api/routes/chat-completions.js +474 -0
- package/dist/api/routes/contradictions.d.ts +1 -0
- package/dist/api/routes/contradictions.js +28 -0
- package/dist/api/routes/evidence.d.ts +1 -0
- package/dist/api/routes/evidence.js +59 -0
- package/dist/api/routes/governance.d.ts +1 -0
- package/dist/api/routes/governance.js +95 -0
- package/dist/api/routes/graph.d.ts +1 -0
- package/dist/api/routes/graph.js +25 -0
- package/dist/api/routes/hooks.d.ts +1 -0
- package/dist/api/routes/hooks.js +88 -0
- package/dist/api/routes/memories.d.ts +1 -0
- package/dist/api/routes/memories.js +92 -0
- package/dist/api/routes/persona.d.ts +1 -0
- package/dist/api/routes/persona.js +9 -0
- package/dist/api/routes/scenes.d.ts +1 -0
- package/dist/api/routes/scenes.js +35 -0
- package/dist/api/routes/skills.d.ts +1 -0
- package/dist/api/routes/skills.js +14 -0
- package/dist/api/routes/stats.d.ts +1 -0
- package/dist/api/routes/stats.js +8 -0
- package/dist/api/routes/users.d.ts +1 -0
- package/dist/api/routes/users.js +82 -0
- package/dist/api/routes/working.d.ts +1 -0
- package/dist/api/routes/working.js +88 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +492 -0
- package/dist/integrations/claude-code.d.ts +12 -0
- package/dist/integrations/claude-code.js +35 -0
- package/dist/integrations/codex.d.ts +12 -0
- package/dist/integrations/codex.js +34 -0
- package/dist/integrations/generic-mcp.d.ts +52 -0
- package/dist/integrations/generic-mcp.js +118 -0
- package/dist/loader.d.ts +29 -0
- package/dist/loader.js +200 -0
- package/dist/memory/capture.d.ts +35 -0
- package/dist/memory/capture.js +230 -0
- package/dist/memory/config.d.ts +2 -0
- package/dist/memory/config.js +3 -0
- package/dist/memory/engine.d.ts +203 -0
- package/dist/memory/engine.js +626 -0
- package/dist/memory/llm-semaphore.d.ts +41 -0
- package/dist/memory/llm-semaphore.js +81 -0
- package/dist/memory/memory-type-config.d.ts +11 -0
- package/dist/memory/memory-type-config.js +65 -0
- package/dist/memory/pipeline/cognitive-contradiction.d.ts +7 -0
- package/dist/memory/pipeline/cognitive-contradiction.js +59 -0
- package/dist/memory/pipeline/cognitive-dedup.d.ts +23 -0
- package/dist/memory/pipeline/cognitive-dedup.js +38 -0
- package/dist/memory/pipeline/cognitive-extractor.d.ts +21 -0
- package/dist/memory/pipeline/cognitive-extractor.js +183 -0
- package/dist/memory/pipeline/contextual-focus-builder.d.ts +13 -0
- package/dist/memory/pipeline/contextual-focus-builder.js +135 -0
- package/dist/memory/pipeline/focus-direction-shift.d.ts +10 -0
- package/dist/memory/pipeline/focus-direction-shift.js +27 -0
- package/dist/memory/pipeline/graph-builder.d.ts +11 -0
- package/dist/memory/pipeline/graph-builder.js +88 -0
- package/dist/memory/pipeline/graph-recall.d.ts +13 -0
- package/dist/memory/pipeline/graph-recall.js +55 -0
- package/dist/memory/pipeline/identity-distiller.d.ts +15 -0
- package/dist/memory/pipeline/identity-distiller.js +40 -0
- package/dist/memory/pipeline/l1-contradiction.d.ts +7 -0
- package/dist/memory/pipeline/l1-contradiction.js +66 -0
- package/dist/memory/pipeline/l1-dedup.d.ts +23 -0
- package/dist/memory/pipeline/l1-dedup.js +39 -0
- package/dist/memory/pipeline/l1-extractor.d.ts +21 -0
- package/dist/memory/pipeline/l1-extractor.js +180 -0
- package/dist/memory/pipeline/l2-direction-shift.d.ts +10 -0
- package/dist/memory/pipeline/l2-direction-shift.js +27 -0
- package/dist/memory/pipeline/l2-scene.d.ts +15 -0
- package/dist/memory/pipeline/l2-scene.js +140 -0
- package/dist/memory/pipeline/l3-distiller.d.ts +15 -0
- package/dist/memory/pipeline/l3-distiller.js +40 -0
- package/dist/memory/pipeline/neural-spark.d.ts +27 -0
- package/dist/memory/pipeline/neural-spark.js +78 -0
- package/dist/memory/pipeline/skill-prewarm.d.ts +63 -0
- package/dist/memory/pipeline/skill-prewarm.js +127 -0
- package/dist/memory/pipeline/task-queue.d.ts +54 -0
- package/dist/memory/pipeline/task-queue.js +117 -0
- package/dist/memory/prompts/cognitive-contradiction.d.ts +1 -0
- package/dist/memory/prompts/cognitive-contradiction.js +25 -0
- package/dist/memory/prompts/cognitive-extraction.d.ts +10 -0
- package/dist/memory/prompts/cognitive-extraction.js +114 -0
- package/dist/memory/prompts/core-identity.d.ts +6 -0
- package/dist/memory/prompts/core-identity.js +60 -0
- package/dist/memory/prompts/focus-direction-shift.d.ts +5 -0
- package/dist/memory/prompts/focus-direction-shift.js +32 -0
- package/dist/memory/prompts/focus-scene-cluster.d.ts +2 -0
- package/dist/memory/prompts/focus-scene-cluster.js +33 -0
- package/dist/memory/prompts/focus-scene.d.ts +7 -0
- package/dist/memory/prompts/focus-scene.js +40 -0
- package/dist/memory/prompts/graph-extraction-batch.d.ts +14 -0
- package/dist/memory/prompts/graph-extraction-batch.js +54 -0
- package/dist/memory/prompts/graph-extraction.d.ts +2 -0
- package/dist/memory/prompts/graph-extraction.js +53 -0
- package/dist/memory/prompts/l1-contradiction-batch.d.ts +16 -0
- package/dist/memory/prompts/l1-contradiction-batch.js +47 -0
- package/dist/memory/prompts/l1-contradiction.d.ts +1 -0
- package/dist/memory/prompts/l1-contradiction.js +25 -0
- package/dist/memory/prompts/l1-extraction.d.ts +10 -0
- package/dist/memory/prompts/l1-extraction.js +114 -0
- package/dist/memory/prompts/l2-direction-shift.d.ts +5 -0
- package/dist/memory/prompts/l2-direction-shift.js +32 -0
- package/dist/memory/prompts/l2-scene-cluster.d.ts +2 -0
- package/dist/memory/prompts/l2-scene-cluster.js +33 -0
- package/dist/memory/prompts/l2-scene.d.ts +7 -0
- package/dist/memory/prompts/l2-scene.js +40 -0
- package/dist/memory/prompts/l3-persona.d.ts +6 -0
- package/dist/memory/prompts/l3-persona.js +60 -0
- package/dist/memory/recall.d.ts +47 -0
- package/dist/memory/recall.js +427 -0
- package/dist/memory/redaction.d.ts +1 -0
- package/dist/memory/redaction.js +24 -0
- package/dist/memory/retry.d.ts +13 -0
- package/dist/memory/retry.js +53 -0
- package/dist/memory/scheduler.d.ts +9 -0
- package/dist/memory/scheduler.js +16 -0
- package/dist/memory/skill-hints-loader.d.ts +30 -0
- package/dist/memory/skill-hints-loader.js +100 -0
- package/dist/memory/store/embedding.d.ts +16 -0
- package/dist/memory/store/embedding.js +68 -0
- package/dist/memory/store/reranker.d.ts +24 -0
- package/dist/memory/store/reranker.js +83 -0
- package/dist/memory/store/sqlite.d.ts +167 -0
- package/dist/memory/store/sqlite.js +1816 -0
- package/dist/memory/store/types.d.ts +101 -0
- package/dist/memory/store/types.js +1 -0
- package/dist/memory/types.d.ts +207 -0
- package/dist/memory/types.js +7 -0
- package/dist/memory/validation.d.ts +441 -0
- package/dist/memory/validation.js +129 -0
- package/dist/memory/working/canvas.d.ts +5 -0
- package/dist/memory/working/canvas.js +43 -0
- package/dist/memory/working/offload.d.ts +71 -0
- package/dist/memory/working/offload.js +211 -0
- package/dist/memory/working/step-log.d.ts +16 -0
- package/dist/memory/working/step-log.js +35 -0
- package/dist/registry.d.ts +34 -0
- package/dist/registry.js +305 -0
- package/dist/resolver.d.ts +17 -0
- package/dist/resolver.js +126 -0
- package/dist/scripts/validate-foreign-workspace-path.d.ts +1 -0
- package/dist/scripts/validate-foreign-workspace-path.js +39 -0
- package/dist/tools/agent_memory_tools.d.ts +485 -0
- package/dist/tools/agent_memory_tools.js +793 -0
- package/dist/tools/create_skill.d.ts +46 -0
- package/dist/tools/create_skill.js +46 -0
- package/dist/tools/get_doc.d.ts +21 -0
- package/dist/tools/get_doc.js +24 -0
- package/dist/tools/get_persona.d.ts +15 -0
- package/dist/tools/get_persona.js +20 -0
- package/dist/tools/get_reference.d.ts +15 -0
- package/dist/tools/get_reference.js +20 -0
- package/dist/tools/get_skill.d.ts +34 -0
- package/dist/tools/get_skill.js +65 -0
- package/dist/tools/get_template_doc.d.ts +21 -0
- package/dist/tools/get_template_doc.js +24 -0
- package/dist/tools/list_docs.d.ts +15 -0
- package/dist/tools/list_docs.js +16 -0
- package/dist/tools/list_skills.d.ts +18 -0
- package/dist/tools/list_skills.js +17 -0
- package/dist/tools/list_template_docs.d.ts +15 -0
- package/dist/tools/list_template_docs.js +16 -0
- package/dist/tools/memory-engineering.d.ts +225 -0
- package/dist/tools/memory-engineering.js +284 -0
- package/dist/tools/memory-explain.d.ts +34 -0
- package/dist/tools/memory-explain.js +109 -0
- package/dist/tools/memory-governance.d.ts +171 -0
- package/dist/tools/memory-governance.js +224 -0
- package/dist/tools/memory-hooks.d.ts +67 -0
- package/dist/tools/memory-hooks.js +102 -0
- package/dist/tools/memory-working.d.ts +98 -0
- package/dist/tools/memory-working.js +101 -0
- package/dist/tools/memory_capture_turn.d.ts +66 -0
- package/dist/tools/memory_capture_turn.js +85 -0
- package/dist/tools/memory_consolidate.d.ts +55 -0
- package/dist/tools/memory_consolidate.js +176 -0
- package/dist/tools/memory_contradictions.d.ts +53 -0
- package/dist/tools/memory_contradictions.js +52 -0
- package/dist/tools/memory_graph_query.d.ts +51 -0
- package/dist/tools/memory_graph_query.js +35 -0
- package/dist/tools/memory_mark_cited.d.ts +43 -0
- package/dist/tools/memory_mark_cited.js +63 -0
- package/dist/tools/memory_recall.d.ts +77 -0
- package/dist/tools/memory_recall.js +81 -0
- package/dist/tools/memory_register_skill_hints.d.ts +49 -0
- package/dist/tools/memory_register_skill_hints.js +55 -0
- package/dist/tools/memory_resolve_session.d.ts +24 -0
- package/dist/tools/memory_resolve_session.js +133 -0
- package/dist/tools/memory_search.d.ts +146 -0
- package/dist/tools/memory_search.js +84 -0
- package/dist/tools/search_skills.d.ts +18 -0
- package/dist/tools/search_skills.js +17 -0
- package/dist/tools/update_doc.d.ts +24 -0
- package/dist/tools/update_doc.js +35 -0
- package/dist/tools/update_skill.d.ts +30 -0
- package/dist/tools/update_skill.js +80 -0
- package/dist/types.d.ts +81 -0
- package/dist/types.js +4 -0
- package/dist/writer.d.ts +30 -0
- package/dist/writer.js +220 -0
- package/docs/TEMPLATE ONLY +1 -0
- package/docs/api/API.md +64 -0
- package/docs/api/security/SECURITY.md +58 -0
- package/docs/deployment/DockerDeployment.md +30 -0
- package/docs/design/Design.md +59 -0
- package/docs/design/themes/apple.md +101 -0
- package/docs/design/themes/dieter-grid.md +100 -0
- package/docs/design/themes/gallery-white.md +100 -0
- package/docs/design/themes/pinterest.md +101 -0
- package/docs/design/themes/realty-open-house.md +101 -0
- package/docs/design/themes/vodafone.md +101 -0
- package/docs/hooks/Hooks.md +30 -0
- package/docs/schema/Schema.md +35 -0
- package/docs/strategy/ScalingStrategy.md +19 -0
- package/package.json +88 -0
- package/references/accessibility-checklist.md +160 -0
- package/references/orchestration-patterns.md +370 -0
- package/references/performance-checklist.md +153 -0
- package/references/security-checklist.md +134 -0
- package/references/testing-patterns.md +236 -0
- package/skills/agent/adr-skill/SKILL.md +299 -0
- package/skills/agent/agentic-engineering-workflow/SKILL.md +95 -0
- package/skills/agent/bootstrap-skill/SKILL.md +103 -0
- package/skills/agent/context-engineering/SKILL.md +307 -0
- package/skills/agent/debugging-and-error-recovery/SKILL.md +308 -0
- package/skills/agent/developer-growth-analysis/SKILL.md +328 -0
- package/skills/agent/doubt-driven-skill/SKILL.md +249 -0
- package/skills/agent/handover-skill/SKILL.md +112 -0
- package/skills/agent/idea-refine-skill/SKILL.md +185 -0
- package/skills/agent/idea-refine-skill/examples.md +238 -0
- package/skills/agent/idea-refine-skill/frameworks.md +99 -0
- package/skills/agent/idea-refine-skill/refinement-criteria.md +113 -0
- package/skills/agent/interview-skill/SKILL.md +226 -0
- package/skills/agent/planning-skill/SKILL.md +270 -0
- package/skills/agent/skill-authoring/SKILL.md +189 -0
- package/skills/agent/source-driven-skill/SKILL.md +197 -0
- package/skills/agent/spec-driven-skill/SKILL.md +221 -0
- package/skills/agent/sync-skill/SKILL.md +92 -0
- package/skills/agent/using-agent-skills/SKILL.md +189 -0
- package/skills/api/a11y-skill/SKILL.md +88 -0
- package/skills/api/api-skill/SKILL.md +123 -0
- package/skills/api/auth-skill/SKILL.md +80 -0
- package/skills/api/debug-skill/SKILL.md +535 -0
- package/skills/api/performance-skill/SKILL.md +100 -0
- package/skills/api/testing-skill/SKILL.md +100 -0
- package/skills/codebase/code-review-and-quality/SKILL.md +228 -0
- package/skills/codebase/code-simplification/SKILL.md +352 -0
- package/skills/codebase/code-structure-cleanup/SKILL.md +142 -0
- package/skills/codebase/concerns-skill/SKILL.md +89 -0
- package/skills/codebase/conventions-skill/SKILL.md +95 -0
- package/skills/codebase/doc-management-skill/SKILL.md +47 -0
- package/skills/codebase/git-workflow-skill/SKILL.md +312 -0
- package/skills/communication/1-3-1-rule/SKILL.md +120 -0
- package/skills/design/brutalist-skill/SKILL.md +131 -0
- package/skills/design/concept-diagrams/SKILL.md +387 -0
- package/skills/design/concept-diagrams/examples/apartment-floor-plan-conversion.md +244 -0
- package/skills/design/concept-diagrams/examples/automated-password-reset-flow.md +276 -0
- package/skills/design/concept-diagrams/examples/autonomous-llm-research-agent-flow.md +240 -0
- package/skills/design/concept-diagrams/examples/banana-journey-tree-to-smoothie.md +161 -0
- package/skills/design/concept-diagrams/examples/commercial-aircraft-structure.md +209 -0
- package/skills/design/concept-diagrams/examples/cpu-ooo-microarchitecture.md +236 -0
- package/skills/design/concept-diagrams/examples/electricity-grid-flow.md +182 -0
- package/skills/design/concept-diagrams/examples/feature-film-production-pipeline.md +172 -0
- package/skills/design/concept-diagrams/examples/hospital-emergency-department-flow.md +165 -0
- package/skills/design/concept-diagrams/examples/ml-benchmark-grouped-bar-chart.md +114 -0
- package/skills/design/concept-diagrams/examples/place-order-uml-sequence.md +325 -0
- package/skills/design/concept-diagrams/examples/smart-city-infrastructure.md +173 -0
- package/skills/design/concept-diagrams/examples/smartphone-layer-anatomy.md +154 -0
- package/skills/design/concept-diagrams/examples/sn2-reaction-mechanism.md +247 -0
- package/skills/design/concept-diagrams/examples/wind-turbine-structure.md +338 -0
- package/skills/design/concept-diagrams/references/dashboard-patterns.md +43 -0
- package/skills/design/concept-diagrams/references/infrastructure-patterns.md +144 -0
- package/skills/design/concept-diagrams/references/physical-shape-cookbook.md +42 -0
- package/skills/design/concept-diagrams/templates/template.html +174 -0
- package/skills/design/gpt-tasteskill/SKILL.md +114 -0
- package/skills/design/minimalist-skill/SKILL.md +116 -0
- package/skills/design/output-skill/SKILL.md +87 -0
- package/skills/design/redesign-skill/SKILL.md +213 -0
- package/skills/design/soft-skill/SKILL.md +132 -0
- package/skills/design/stitch-skill/EXAMPLE.md +121 -0
- package/skills/design/stitch-skill/SKILL.md +222 -0
- package/skills/design/taste-skill/SKILL.md +269 -0
- package/skills/devops/ci-cd-skill/SKILL.md +402 -0
- package/skills/devops/docker-skill/SKILL.md +297 -0
- package/skills/devops/domain-skill/SKILL.md +234 -0
- package/skills/lifecycle/changelog-generator/SKILL.md +135 -0
- package/skills/lifecycle/incremental-skill/SKILL.md +257 -0
- package/skills/lifecycle/migration-skill/SKILL.md +218 -0
- package/skills/lifecycle/shipping-skill/SKILL.md +321 -0
- package/skills/memory/agent-memory/SKILL.md +122 -0
- package/skills/qa/browser-testing-skill/SKILL.md +314 -0
- package/skills/ux/adversarial-ux-skill/SKILL.md +168 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
export declare const memoryGovernanceToolSchemas: readonly [{
|
|
2
|
+
readonly name: "memory_get";
|
|
3
|
+
readonly description: "Fetch a specific memory with attached evidence.";
|
|
4
|
+
readonly inputSchema: {
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly properties: {
|
|
7
|
+
readonly userId: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
};
|
|
10
|
+
readonly recordId: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
readonly required: readonly ["recordId"];
|
|
15
|
+
};
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "memory_update";
|
|
18
|
+
readonly description: "Correct memory content or update trust/status metadata.";
|
|
19
|
+
readonly inputSchema: {
|
|
20
|
+
readonly type: "object";
|
|
21
|
+
readonly properties: {
|
|
22
|
+
readonly userId: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
};
|
|
25
|
+
readonly recordId: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
};
|
|
28
|
+
readonly content: {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
};
|
|
31
|
+
readonly status: {
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
readonly enum: readonly ["active", "superseded", "archived", "needs_verification"];
|
|
34
|
+
};
|
|
35
|
+
readonly confidence: {
|
|
36
|
+
readonly type: "number";
|
|
37
|
+
};
|
|
38
|
+
readonly verificationStatus: {
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
readonly enum: readonly ["", "verified", "unverified", "stale"];
|
|
41
|
+
};
|
|
42
|
+
readonly note: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
readonly required: readonly ["recordId"];
|
|
47
|
+
};
|
|
48
|
+
}, {
|
|
49
|
+
readonly name: "memory_evidence_add";
|
|
50
|
+
readonly description: "Attach evidence to a memory.";
|
|
51
|
+
readonly inputSchema: {
|
|
52
|
+
readonly type: "object";
|
|
53
|
+
readonly properties: {
|
|
54
|
+
readonly userId: {
|
|
55
|
+
readonly type: "string";
|
|
56
|
+
};
|
|
57
|
+
readonly recordId: {
|
|
58
|
+
readonly type: "string";
|
|
59
|
+
};
|
|
60
|
+
readonly kind: {
|
|
61
|
+
readonly type: "string";
|
|
62
|
+
readonly enum: readonly ["file", "command", "url", "test", "benchmark", "memory", "other"];
|
|
63
|
+
};
|
|
64
|
+
readonly ref: {
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
};
|
|
67
|
+
readonly excerpt: {
|
|
68
|
+
readonly type: "string";
|
|
69
|
+
};
|
|
70
|
+
readonly metadata: {
|
|
71
|
+
readonly type: "object";
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
readonly required: readonly ["recordId", "kind", "ref"];
|
|
75
|
+
};
|
|
76
|
+
}, {
|
|
77
|
+
readonly name: "memory_evidence_get";
|
|
78
|
+
readonly description: "Retrieve evidence attached to a memory.";
|
|
79
|
+
readonly inputSchema: {
|
|
80
|
+
readonly type: "object";
|
|
81
|
+
readonly properties: {
|
|
82
|
+
readonly userId: {
|
|
83
|
+
readonly type: "string";
|
|
84
|
+
};
|
|
85
|
+
readonly recordId: {
|
|
86
|
+
readonly type: "string";
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
readonly required: readonly ["recordId"];
|
|
90
|
+
};
|
|
91
|
+
}, {
|
|
92
|
+
readonly name: "memory_export";
|
|
93
|
+
readonly description: "Export all memories, evidence, and audit operations for a user.";
|
|
94
|
+
readonly inputSchema: {
|
|
95
|
+
readonly type: "object";
|
|
96
|
+
readonly properties: {
|
|
97
|
+
readonly userId: {
|
|
98
|
+
readonly type: "string";
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
}, {
|
|
103
|
+
readonly name: "memory_import";
|
|
104
|
+
readonly description: "Import a BrainRouter memory export envelope.";
|
|
105
|
+
readonly inputSchema: {
|
|
106
|
+
readonly type: "object";
|
|
107
|
+
readonly properties: {
|
|
108
|
+
readonly userId: {
|
|
109
|
+
readonly type: "string";
|
|
110
|
+
};
|
|
111
|
+
readonly data: {
|
|
112
|
+
readonly type: "object";
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
readonly required: readonly ["data"];
|
|
116
|
+
};
|
|
117
|
+
}, {
|
|
118
|
+
readonly name: "memory_governance_delete";
|
|
119
|
+
readonly description: "Hard delete a memory and write an audit record.";
|
|
120
|
+
readonly inputSchema: {
|
|
121
|
+
readonly type: "object";
|
|
122
|
+
readonly properties: {
|
|
123
|
+
readonly userId: {
|
|
124
|
+
readonly type: "string";
|
|
125
|
+
};
|
|
126
|
+
readonly recordId: {
|
|
127
|
+
readonly type: "string";
|
|
128
|
+
};
|
|
129
|
+
readonly reason: {
|
|
130
|
+
readonly type: "string";
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
readonly required: readonly ["recordId", "reason"];
|
|
134
|
+
};
|
|
135
|
+
}, {
|
|
136
|
+
readonly name: "memory_audit";
|
|
137
|
+
readonly description: "List memory audit log entries for a user.";
|
|
138
|
+
readonly inputSchema: {
|
|
139
|
+
readonly type: "object";
|
|
140
|
+
readonly properties: {
|
|
141
|
+
readonly userId: {
|
|
142
|
+
readonly type: "string";
|
|
143
|
+
};
|
|
144
|
+
readonly limit: {
|
|
145
|
+
readonly type: "number";
|
|
146
|
+
};
|
|
147
|
+
readonly cursor: {
|
|
148
|
+
readonly type: "object";
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
}, {
|
|
153
|
+
readonly name: "memory_diagnostics";
|
|
154
|
+
readonly description: "Return a scrubbed diagnostics bundle with runtime versions, database stats, env key names, and recent error/degradation logs.";
|
|
155
|
+
readonly inputSchema: {
|
|
156
|
+
readonly type: "object";
|
|
157
|
+
readonly properties: {
|
|
158
|
+
readonly userId: {
|
|
159
|
+
readonly type: "string";
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
}];
|
|
164
|
+
export declare function handleMemoryGovernanceTool(name: string, args: unknown, options?: {
|
|
165
|
+
defaultUserId?: string;
|
|
166
|
+
}): Promise<{
|
|
167
|
+
content: {
|
|
168
|
+
type: string;
|
|
169
|
+
text: string;
|
|
170
|
+
}[];
|
|
171
|
+
}>;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { memoryEngine } from "../memory/engine.js";
|
|
3
|
+
const baseUser = { userId: z.string().optional() };
|
|
4
|
+
export const memoryGovernanceToolSchemas = [
|
|
5
|
+
{
|
|
6
|
+
name: "memory_get",
|
|
7
|
+
description: "Fetch a specific memory with attached evidence.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: { userId: { type: "string" }, recordId: { type: "string" } },
|
|
11
|
+
required: ["recordId"],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "memory_update",
|
|
16
|
+
description: "Correct memory content or update trust/status metadata.",
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: "object",
|
|
19
|
+
properties: {
|
|
20
|
+
userId: { type: "string" },
|
|
21
|
+
recordId: { type: "string" },
|
|
22
|
+
content: { type: "string" },
|
|
23
|
+
status: { type: "string", enum: ["active", "superseded", "archived", "needs_verification"] },
|
|
24
|
+
confidence: { type: "number" },
|
|
25
|
+
verificationStatus: { type: "string", enum: ["", "verified", "unverified", "stale"] },
|
|
26
|
+
note: { type: "string" },
|
|
27
|
+
},
|
|
28
|
+
required: ["recordId"],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "memory_evidence_add",
|
|
33
|
+
description: "Attach evidence to a memory.",
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: "object",
|
|
36
|
+
properties: {
|
|
37
|
+
userId: { type: "string" },
|
|
38
|
+
recordId: { type: "string" },
|
|
39
|
+
kind: { type: "string", enum: ["file", "command", "url", "test", "benchmark", "memory", "other"] },
|
|
40
|
+
ref: { type: "string" },
|
|
41
|
+
excerpt: { type: "string" },
|
|
42
|
+
metadata: { type: "object" },
|
|
43
|
+
},
|
|
44
|
+
required: ["recordId", "kind", "ref"],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "memory_evidence_get",
|
|
49
|
+
description: "Retrieve evidence attached to a memory.",
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: { userId: { type: "string" }, recordId: { type: "string" } },
|
|
53
|
+
required: ["recordId"],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "memory_export",
|
|
58
|
+
description: "Export all memories, evidence, and audit operations for a user.",
|
|
59
|
+
inputSchema: { type: "object", properties: { userId: { type: "string" } } },
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "memory_import",
|
|
63
|
+
description: "Import a BrainRouter memory export envelope.",
|
|
64
|
+
inputSchema: {
|
|
65
|
+
type: "object",
|
|
66
|
+
properties: { userId: { type: "string" }, data: { type: "object" } },
|
|
67
|
+
required: ["data"],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "memory_governance_delete",
|
|
72
|
+
description: "Hard delete a memory and write an audit record.",
|
|
73
|
+
inputSchema: {
|
|
74
|
+
type: "object",
|
|
75
|
+
properties: { userId: { type: "string" }, recordId: { type: "string" }, reason: { type: "string" } },
|
|
76
|
+
required: ["recordId", "reason"],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "memory_audit",
|
|
81
|
+
description: "List memory audit log entries for a user.",
|
|
82
|
+
inputSchema: {
|
|
83
|
+
type: "object",
|
|
84
|
+
properties: { userId: { type: "string" }, limit: { type: "number" }, cursor: { type: "object" } },
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "memory_diagnostics",
|
|
89
|
+
description: "Return a scrubbed diagnostics bundle with runtime versions, database stats, env key names, and recent error/degradation logs.",
|
|
90
|
+
inputSchema: { type: "object", properties: { userId: { type: "string" } } },
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
// Shared enum schemas — used both in the import envelope and the individual tool handlers.
|
|
94
|
+
const statusSchema = z.enum(["active", "superseded", "archived", "needs_verification"]);
|
|
95
|
+
const verificationSchema = z.enum(["", "verified", "unverified", "stale"]);
|
|
96
|
+
const evidenceKindSchema = z.enum(["file", "command", "url", "test", "benchmark", "memory", "other"]);
|
|
97
|
+
const evidenceSchema = z.object({
|
|
98
|
+
id: z.string(),
|
|
99
|
+
userId: z.string().optional(),
|
|
100
|
+
recordId: z.string(),
|
|
101
|
+
kind: evidenceKindSchema,
|
|
102
|
+
ref: z.string(),
|
|
103
|
+
excerpt: z.string().optional().default(""),
|
|
104
|
+
observedAt: z.string().optional().default(""),
|
|
105
|
+
metadata: z.record(z.unknown()).optional().default({}),
|
|
106
|
+
});
|
|
107
|
+
const memoryRecordSchema = z.object({
|
|
108
|
+
id: z.string(),
|
|
109
|
+
content: z.string(),
|
|
110
|
+
type: z.string(),
|
|
111
|
+
priority: z.number().optional().default(50),
|
|
112
|
+
sceneName: z.string().optional().default(""),
|
|
113
|
+
skillTag: z.string().optional().default(""),
|
|
114
|
+
sessionKey: z.string().optional().default(""),
|
|
115
|
+
sessionId: z.string().optional().default(""),
|
|
116
|
+
halfLifeDays: z.number().nullable().optional().default(null),
|
|
117
|
+
supersededBy: z.string().nullable().optional().default(null),
|
|
118
|
+
invalidAt: z.string().nullable().optional().default(null),
|
|
119
|
+
timestampStr: z.string().optional().default(""),
|
|
120
|
+
timestampStart: z.string().optional().default(""),
|
|
121
|
+
timestampEnd: z.string().optional().default(""),
|
|
122
|
+
createdTime: z.string().optional().default(""),
|
|
123
|
+
updatedTime: z.string().optional().default(""),
|
|
124
|
+
metadata: z.record(z.unknown()).optional().default({}),
|
|
125
|
+
confidence: z.number().min(0).max(1).optional().default(0.65),
|
|
126
|
+
status: z.enum(["active", "superseded", "archived", "needs_verification"]).optional().default("active"),
|
|
127
|
+
sourceKind: z.string().optional().default(""),
|
|
128
|
+
verificationStatus: z.string().optional().default(""),
|
|
129
|
+
repoPaths: z.array(z.string()).optional().default([]),
|
|
130
|
+
filePaths: z.array(z.string()).optional().default([]),
|
|
131
|
+
commands: z.array(z.string()).optional().default([]),
|
|
132
|
+
citationCount: z.number().optional().default(0),
|
|
133
|
+
lastCitedAt: z.string().nullable().optional().default(null),
|
|
134
|
+
neverCitedCount: z.number().optional().default(0),
|
|
135
|
+
archived: z.boolean().optional().default(false),
|
|
136
|
+
});
|
|
137
|
+
const importOperationSchema = z.object({
|
|
138
|
+
id: z.string(),
|
|
139
|
+
recordId: z.string().nullable().optional().default(null),
|
|
140
|
+
operation: z.string().min(1),
|
|
141
|
+
actor: z.string().optional().default("system"),
|
|
142
|
+
sessionKey: z.string().optional().default(""),
|
|
143
|
+
reason: z.string().optional().default(""),
|
|
144
|
+
createdAt: z.string(),
|
|
145
|
+
metadata: z.record(z.unknown()).optional().default({}),
|
|
146
|
+
});
|
|
147
|
+
const importEnvelopeSchema = z.object({
|
|
148
|
+
version: z.literal(1),
|
|
149
|
+
memories: z.array(memoryRecordSchema).optional().default([]),
|
|
150
|
+
evidence: z.array(evidenceSchema).optional().default([]),
|
|
151
|
+
/** Audit operations from a prior export — re-imported for historical continuity. */
|
|
152
|
+
operations: z.array(importOperationSchema).optional().default([]),
|
|
153
|
+
});
|
|
154
|
+
function effectiveUserId(userId, defaultUserId) {
|
|
155
|
+
return userId ?? defaultUserId ?? "default";
|
|
156
|
+
}
|
|
157
|
+
function toolResult(value) {
|
|
158
|
+
return { content: [{ type: "text", text: JSON.stringify(value, null, 2) }] };
|
|
159
|
+
}
|
|
160
|
+
export async function handleMemoryGovernanceTool(name, args, options) {
|
|
161
|
+
switch (name) {
|
|
162
|
+
case "memory_get": {
|
|
163
|
+
const params = z.object({ ...baseUser, recordId: z.string() }).parse(args);
|
|
164
|
+
return toolResult(memoryEngine.getMemoryById(effectiveUserId(params.userId, options?.defaultUserId), params.recordId));
|
|
165
|
+
}
|
|
166
|
+
case "memory_update": {
|
|
167
|
+
const params = z.object({
|
|
168
|
+
...baseUser,
|
|
169
|
+
recordId: z.string(),
|
|
170
|
+
content: z.string().optional(),
|
|
171
|
+
status: statusSchema.optional(),
|
|
172
|
+
confidence: z.number().min(0).max(1).optional(),
|
|
173
|
+
verificationStatus: verificationSchema.optional(),
|
|
174
|
+
note: z.string().optional(),
|
|
175
|
+
}).parse(args);
|
|
176
|
+
return toolResult(memoryEngine.updateMemory(effectiveUserId(params.userId, options?.defaultUserId), params.recordId, params));
|
|
177
|
+
}
|
|
178
|
+
case "memory_evidence_add": {
|
|
179
|
+
const params = z.object({
|
|
180
|
+
...baseUser,
|
|
181
|
+
recordId: z.string(),
|
|
182
|
+
kind: evidenceKindSchema,
|
|
183
|
+
ref: z.string(),
|
|
184
|
+
excerpt: z.string().optional().default(""),
|
|
185
|
+
metadata: z.record(z.unknown()).optional().default({}),
|
|
186
|
+
}).parse(args);
|
|
187
|
+
return toolResult(memoryEngine.addEvidence(effectiveUserId(params.userId, options?.defaultUserId), params.recordId, params));
|
|
188
|
+
}
|
|
189
|
+
case "memory_evidence_get": {
|
|
190
|
+
const params = z.object({ ...baseUser, recordId: z.string() }).parse(args);
|
|
191
|
+
return toolResult(memoryEngine.getEvidence(effectiveUserId(params.userId, options?.defaultUserId), params.recordId));
|
|
192
|
+
}
|
|
193
|
+
case "memory_export": {
|
|
194
|
+
const params = z.object(baseUser).parse(args ?? {});
|
|
195
|
+
return toolResult(memoryEngine.exportMemories(effectiveUserId(params.userId, options?.defaultUserId)));
|
|
196
|
+
}
|
|
197
|
+
case "memory_import": {
|
|
198
|
+
const params = z.object({ ...baseUser, data: importEnvelopeSchema }).parse(args);
|
|
199
|
+
return toolResult(memoryEngine.importMemories(effectiveUserId(params.userId, options?.defaultUserId), params.data));
|
|
200
|
+
}
|
|
201
|
+
case "memory_governance_delete": {
|
|
202
|
+
const params = z.object({ ...baseUser, recordId: z.string(), reason: z.string().min(1) }).parse(args);
|
|
203
|
+
memoryEngine.governanceDelete(effectiveUserId(params.userId, options?.defaultUserId), params.recordId, params.reason);
|
|
204
|
+
return toolResult({ success: true });
|
|
205
|
+
}
|
|
206
|
+
case "memory_audit": {
|
|
207
|
+
const params = z.object({
|
|
208
|
+
...baseUser,
|
|
209
|
+
limit: z.number().int().min(1).max(200).optional().default(50),
|
|
210
|
+
cursor: z.object({ createdAt: z.string(), id: z.string() }).optional(),
|
|
211
|
+
}).parse(args ?? {});
|
|
212
|
+
return toolResult(memoryEngine.getOperationLog(effectiveUserId(params.userId, options?.defaultUserId), {
|
|
213
|
+
limit: params.limit,
|
|
214
|
+
cursor: params.cursor,
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
case "memory_diagnostics": {
|
|
218
|
+
const params = z.object(baseUser).parse(args ?? {});
|
|
219
|
+
return toolResult(memoryEngine.getDiagnostics(effectiveUserId(params.userId, options?.defaultUserId)));
|
|
220
|
+
}
|
|
221
|
+
default:
|
|
222
|
+
throw new Error(`Unknown governance tool: ${name}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare const memoryHookToolSchemas: readonly [{
|
|
2
|
+
readonly name: "memory_hook_register";
|
|
3
|
+
readonly description: "Register a passive host lifecycle hook source and optionally process one hook event into L0 memory.";
|
|
4
|
+
readonly inputSchema: {
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly properties: {
|
|
7
|
+
readonly source: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly enum: readonly ["claude-code", "codex", "generic-mcp"];
|
|
10
|
+
};
|
|
11
|
+
readonly events: {
|
|
12
|
+
readonly type: "array";
|
|
13
|
+
readonly items: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
readonly userId: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
};
|
|
20
|
+
readonly sessionKey: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
};
|
|
23
|
+
readonly sessionId: {
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
};
|
|
26
|
+
readonly workspacePath: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
};
|
|
29
|
+
readonly event: {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
readonly description: "Optional lifecycle event to process immediately.";
|
|
32
|
+
};
|
|
33
|
+
readonly payload: {
|
|
34
|
+
readonly type: "object";
|
|
35
|
+
readonly additionalProperties: true;
|
|
36
|
+
};
|
|
37
|
+
readonly metadata: {
|
|
38
|
+
readonly type: "object";
|
|
39
|
+
readonly additionalProperties: true;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
readonly required: readonly ["source"];
|
|
43
|
+
};
|
|
44
|
+
}, {
|
|
45
|
+
readonly name: "memory_hook_status";
|
|
46
|
+
readonly description: "List registered passive lifecycle hook sources and their last-seen timestamps.";
|
|
47
|
+
readonly inputSchema: {
|
|
48
|
+
readonly type: "object";
|
|
49
|
+
readonly properties: {
|
|
50
|
+
readonly source: {
|
|
51
|
+
readonly type: "string";
|
|
52
|
+
readonly enum: readonly ["claude-code", "codex", "generic-mcp"];
|
|
53
|
+
};
|
|
54
|
+
readonly userId: {
|
|
55
|
+
readonly type: "string";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}];
|
|
60
|
+
export declare function handleMemoryHookTool(name: string, args: unknown, options?: {
|
|
61
|
+
defaultUserId?: string;
|
|
62
|
+
}): Promise<{
|
|
63
|
+
content: {
|
|
64
|
+
type: string;
|
|
65
|
+
text: string;
|
|
66
|
+
}[];
|
|
67
|
+
}>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { processClaudeCodeHook } from "../integrations/claude-code.js";
|
|
3
|
+
import { processCodexHook } from "../integrations/codex.js";
|
|
4
|
+
import { buildHookResult, listHostHooks, processGenericMcpHook, registerHostHook, } from "../integrations/generic-mcp.js";
|
|
5
|
+
import { memoryEngine } from "../memory/engine.js";
|
|
6
|
+
const hookSourceSchema = z.enum(["claude-code", "codex", "generic-mcp"]);
|
|
7
|
+
export const memoryHookToolSchemas = [
|
|
8
|
+
{
|
|
9
|
+
name: "memory_hook_register",
|
|
10
|
+
description: "Register a passive host lifecycle hook source and optionally process one hook event into L0 memory.",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
source: { type: "string", enum: ["claude-code", "codex", "generic-mcp"] },
|
|
15
|
+
events: { type: "array", items: { type: "string" } },
|
|
16
|
+
userId: { type: "string" },
|
|
17
|
+
sessionKey: { type: "string" },
|
|
18
|
+
sessionId: { type: "string" },
|
|
19
|
+
workspacePath: { type: "string" },
|
|
20
|
+
event: { type: "string", description: "Optional lifecycle event to process immediately." },
|
|
21
|
+
payload: { type: "object", additionalProperties: true },
|
|
22
|
+
metadata: { type: "object", additionalProperties: true },
|
|
23
|
+
},
|
|
24
|
+
required: ["source"],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "memory_hook_status",
|
|
29
|
+
description: "List registered passive lifecycle hook sources and their last-seen timestamps.",
|
|
30
|
+
inputSchema: {
|
|
31
|
+
type: "object",
|
|
32
|
+
properties: {
|
|
33
|
+
source: { type: "string", enum: ["claude-code", "codex", "generic-mcp"] },
|
|
34
|
+
userId: { type: "string" },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
export async function handleMemoryHookTool(name, args, options) {
|
|
40
|
+
switch (name) {
|
|
41
|
+
case "memory_hook_register": {
|
|
42
|
+
const params = z.object({
|
|
43
|
+
source: hookSourceSchema,
|
|
44
|
+
events: z.array(z.string()).optional(),
|
|
45
|
+
userId: z.string().optional(),
|
|
46
|
+
sessionKey: z.string().optional(),
|
|
47
|
+
sessionId: z.string().optional(),
|
|
48
|
+
workspacePath: z.string().optional(),
|
|
49
|
+
event: z.string().optional(),
|
|
50
|
+
payload: z.record(z.unknown()).optional(),
|
|
51
|
+
metadata: z.record(z.unknown()).optional(),
|
|
52
|
+
}).parse(args);
|
|
53
|
+
const defaultUserId = options?.defaultUserId ?? "default";
|
|
54
|
+
const userId = params.userId ?? defaultUserId;
|
|
55
|
+
const hook = registerHostHook({
|
|
56
|
+
userId,
|
|
57
|
+
source: params.source,
|
|
58
|
+
events: params.events,
|
|
59
|
+
sessionKey: params.sessionKey,
|
|
60
|
+
workspacePath: params.workspacePath,
|
|
61
|
+
metadata: params.metadata,
|
|
62
|
+
});
|
|
63
|
+
if (!params.event) {
|
|
64
|
+
return buildHookResult({ registered: hook });
|
|
65
|
+
}
|
|
66
|
+
const payload = {
|
|
67
|
+
...(params.payload ?? {}),
|
|
68
|
+
event: params.event,
|
|
69
|
+
userId,
|
|
70
|
+
sessionKey: params.sessionKey,
|
|
71
|
+
sessionId: params.sessionId,
|
|
72
|
+
workspacePath: params.workspacePath,
|
|
73
|
+
};
|
|
74
|
+
const captureResult = params.source === "claude-code"
|
|
75
|
+
? await processClaudeCodeHook(memoryEngine, payload, defaultUserId)
|
|
76
|
+
: params.source === "codex"
|
|
77
|
+
? await processCodexHook(memoryEngine, payload, defaultUserId)
|
|
78
|
+
: await processGenericMcpHook(memoryEngine, {
|
|
79
|
+
source: "generic-mcp",
|
|
80
|
+
event: params.event,
|
|
81
|
+
userId,
|
|
82
|
+
sessionKey: params.sessionKey ?? hook.sessionKey ?? "generic-mcp",
|
|
83
|
+
sessionId: params.sessionId,
|
|
84
|
+
workspacePath: params.workspacePath,
|
|
85
|
+
args: params.payload,
|
|
86
|
+
metadata: params.metadata,
|
|
87
|
+
});
|
|
88
|
+
return buildHookResult({ registered: hook, captureResult });
|
|
89
|
+
}
|
|
90
|
+
case "memory_hook_status": {
|
|
91
|
+
const params = z.object({
|
|
92
|
+
source: hookSourceSchema.optional(),
|
|
93
|
+
userId: z.string().optional(),
|
|
94
|
+
}).parse(args ?? {});
|
|
95
|
+
const userId = params.userId ?? options?.defaultUserId ?? "default";
|
|
96
|
+
const hooks = listHostHooks(userId).filter((hook) => !params.source || hook.source === params.source);
|
|
97
|
+
return buildHookResult({ hooks });
|
|
98
|
+
}
|
|
99
|
+
default:
|
|
100
|
+
throw new Error(`Unknown hook tool: ${name}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export declare const memoryWorkingToolSchemas: readonly [{
|
|
2
|
+
readonly name: "memory_working_context";
|
|
3
|
+
readonly description: "Return the current working-memory canvas and injected state block without raw payloads. Optionally fetch one raw ref by nodeId.";
|
|
4
|
+
readonly inputSchema: {
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly properties: {
|
|
7
|
+
readonly workspacePath: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
};
|
|
10
|
+
readonly userId: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
};
|
|
13
|
+
readonly sessionKey: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
};
|
|
16
|
+
readonly nodeId: {
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
readonly description: "Optional ref node to fetch raw payload for.";
|
|
19
|
+
};
|
|
20
|
+
readonly activeNodeId: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly description: "Optional node to highlight in the returned Mermaid canvas.";
|
|
23
|
+
};
|
|
24
|
+
readonly contextWindowTokens: {
|
|
25
|
+
readonly type: "number";
|
|
26
|
+
};
|
|
27
|
+
readonly estimatedTokens: {
|
|
28
|
+
readonly type: "number";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
readonly required: readonly ["sessionKey"];
|
|
32
|
+
};
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "memory_working_offload";
|
|
35
|
+
readonly description: "Offload a large short-term working payload to .brainrouter/work refs and update step log, canvas, and injected state.";
|
|
36
|
+
readonly inputSchema: {
|
|
37
|
+
readonly type: "object";
|
|
38
|
+
readonly properties: {
|
|
39
|
+
readonly workspacePath: {
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
};
|
|
42
|
+
readonly userId: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
};
|
|
45
|
+
readonly sessionKey: {
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
};
|
|
48
|
+
readonly payload: {
|
|
49
|
+
readonly type: "string";
|
|
50
|
+
};
|
|
51
|
+
readonly title: {
|
|
52
|
+
readonly type: "string";
|
|
53
|
+
};
|
|
54
|
+
readonly summary: {
|
|
55
|
+
readonly type: "string";
|
|
56
|
+
};
|
|
57
|
+
readonly kind: {
|
|
58
|
+
readonly type: "string";
|
|
59
|
+
};
|
|
60
|
+
readonly contextWindowTokens: {
|
|
61
|
+
readonly type: "number";
|
|
62
|
+
};
|
|
63
|
+
readonly estimatedTokens: {
|
|
64
|
+
readonly type: "number";
|
|
65
|
+
};
|
|
66
|
+
readonly forceAggressive: {
|
|
67
|
+
readonly type: "boolean";
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
readonly required: readonly ["sessionKey", "payload"];
|
|
71
|
+
};
|
|
72
|
+
}, {
|
|
73
|
+
readonly name: "memory_working_reset";
|
|
74
|
+
readonly description: "Clear working memory files for a session after session end or when starting a clean task context.";
|
|
75
|
+
readonly inputSchema: {
|
|
76
|
+
readonly type: "object";
|
|
77
|
+
readonly properties: {
|
|
78
|
+
readonly workspacePath: {
|
|
79
|
+
readonly type: "string";
|
|
80
|
+
};
|
|
81
|
+
readonly userId: {
|
|
82
|
+
readonly type: "string";
|
|
83
|
+
};
|
|
84
|
+
readonly sessionKey: {
|
|
85
|
+
readonly type: "string";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
readonly required: readonly ["sessionKey"];
|
|
89
|
+
};
|
|
90
|
+
}];
|
|
91
|
+
export declare function handleMemoryWorkingTool(name: string, args: unknown, options?: {
|
|
92
|
+
defaultUserId?: string;
|
|
93
|
+
}): Promise<{
|
|
94
|
+
content: {
|
|
95
|
+
type: string;
|
|
96
|
+
text: string;
|
|
97
|
+
}[];
|
|
98
|
+
}>;
|