@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,43 @@
|
|
|
1
|
+
export declare const memoryMarkCitedToolSchema: {
|
|
2
|
+
readonly name: "memory_mark_cited";
|
|
3
|
+
readonly description: string;
|
|
4
|
+
readonly inputSchema: {
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly properties: {
|
|
7
|
+
readonly userId: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly description: "User identifier for isolation.";
|
|
10
|
+
};
|
|
11
|
+
readonly citedRecordIds: {
|
|
12
|
+
readonly type: "array";
|
|
13
|
+
readonly items: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
};
|
|
16
|
+
readonly description: string;
|
|
17
|
+
};
|
|
18
|
+
readonly allRecalledRecordIds: {
|
|
19
|
+
readonly type: "array";
|
|
20
|
+
readonly items: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
};
|
|
23
|
+
readonly description: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
readonly required: readonly ["citedRecordIds", "allRecalledRecordIds"];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export declare function handleMemoryMarkCited(args: unknown, options?: {
|
|
30
|
+
defaultUserId?: string;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
content: {
|
|
33
|
+
type: string;
|
|
34
|
+
text: string;
|
|
35
|
+
}[];
|
|
36
|
+
isError?: undefined;
|
|
37
|
+
} | {
|
|
38
|
+
isError: boolean;
|
|
39
|
+
content: {
|
|
40
|
+
type: string;
|
|
41
|
+
text: string;
|
|
42
|
+
}[];
|
|
43
|
+
}>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { memoryEngine } from "../memory/engine.js";
|
|
3
|
+
export const memoryMarkCitedToolSchema = {
|
|
4
|
+
name: "memory_mark_cited",
|
|
5
|
+
description: "Signal that specific recalled memories were used in the agent response. " +
|
|
6
|
+
"Pass all recalled record IDs (from the previous recall result) alongside the cited subset. " +
|
|
7
|
+
"Non-cited recalled memories accumulate a 'never_cited_count' signal that drives auto-archive. " +
|
|
8
|
+
"Call this once per turn, after your response is generated.",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
userId: {
|
|
13
|
+
type: "string",
|
|
14
|
+
description: "User identifier for isolation.",
|
|
15
|
+
},
|
|
16
|
+
citedRecordIds: {
|
|
17
|
+
type: "array",
|
|
18
|
+
items: { type: "string" },
|
|
19
|
+
description: "IDs of memories you actually referenced in your response. " +
|
|
20
|
+
"Pass an empty array if no memories were used (all recalled IDs will have never_cited_count incremented).",
|
|
21
|
+
},
|
|
22
|
+
allRecalledRecordIds: {
|
|
23
|
+
type: "array",
|
|
24
|
+
items: { type: "string" },
|
|
25
|
+
description: "All record IDs that were returned in the previous memory_recall result " +
|
|
26
|
+
"(recalledCognitiveMemories[].recordId). This is the full set that was surfaced to you.",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
required: ["citedRecordIds", "allRecalledRecordIds"],
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const memoryMarkCitedSchema = z.object({
|
|
33
|
+
userId: z.string().optional(),
|
|
34
|
+
citedRecordIds: z.array(z.string()),
|
|
35
|
+
allRecalledRecordIds: z.array(z.string()),
|
|
36
|
+
});
|
|
37
|
+
export async function handleMemoryMarkCited(args, options) {
|
|
38
|
+
const params = memoryMarkCitedSchema.parse(args);
|
|
39
|
+
const effectiveUserId = params.userId ?? options?.defaultUserId ?? "default";
|
|
40
|
+
try {
|
|
41
|
+
const result = memoryEngine.markCited(effectiveUserId, params.citedRecordIds, params.allRecalledRecordIds);
|
|
42
|
+
return {
|
|
43
|
+
content: [
|
|
44
|
+
{
|
|
45
|
+
type: "text",
|
|
46
|
+
text: JSON.stringify({
|
|
47
|
+
success: true,
|
|
48
|
+
...result,
|
|
49
|
+
message: `Marked ${result.cited} memories as cited. Incremented never_cited_count for ${result.nonCited} non-cited memories.${result.archiveThreshold > 0
|
|
50
|
+
? ` Auto-archive threshold: ${result.archiveThreshold}.`
|
|
51
|
+
: " Auto-archive disabled (BRAINROUTER_ACE_ARCHIVE_THRESHOLD=0)."}`,
|
|
52
|
+
}, null, 2),
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
return {
|
|
59
|
+
isError: true,
|
|
60
|
+
content: [{ type: "text", text: `memory_mark_cited failed: ${err.message}` }],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export declare const memoryRecallToolSchema: {
|
|
2
|
+
readonly name: "memory_recall";
|
|
3
|
+
readonly description: "Retrieve relevant memories, persona, and scene context before generating a response. Best used proactively when context is missing. Supports `filters` to scope results by type / scene / time range / minPriority / skillTag — apply them when the query is mid-conversation pivot or only one memory category is wanted.";
|
|
4
|
+
readonly inputSchema: {
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly properties: {
|
|
7
|
+
readonly userId: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly description: "The ID of the user (enforces multi-tenant isolation).";
|
|
10
|
+
};
|
|
11
|
+
readonly sessionKey: {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
readonly description: "A stable identifier for this conversation channel/session.";
|
|
14
|
+
};
|
|
15
|
+
readonly query: {
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
readonly description: "The user's query or intent to recall memories for.";
|
|
18
|
+
};
|
|
19
|
+
readonly activeSkill: {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
readonly description: "The name of the BrainRouter skill currently being executed (if any).";
|
|
22
|
+
};
|
|
23
|
+
readonly filters: {
|
|
24
|
+
readonly type: "object";
|
|
25
|
+
readonly description: "Optional filters narrowing the candidate pool before ranking.";
|
|
26
|
+
readonly properties: {
|
|
27
|
+
readonly types: {
|
|
28
|
+
readonly type: "array";
|
|
29
|
+
readonly items: {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
};
|
|
32
|
+
readonly description: "Whitelist of memory types (e.g. ['instruction', 'feedback']).";
|
|
33
|
+
};
|
|
34
|
+
readonly scenes: {
|
|
35
|
+
readonly type: "array";
|
|
36
|
+
readonly items: {
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
};
|
|
39
|
+
readonly description: "Whitelist of contextual focus scene names.";
|
|
40
|
+
};
|
|
41
|
+
readonly capturedAfter: {
|
|
42
|
+
readonly type: "string";
|
|
43
|
+
readonly description: "ISO 8601 lower bound on created_time.";
|
|
44
|
+
};
|
|
45
|
+
readonly capturedBefore: {
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
readonly description: "ISO 8601 upper bound on created_time.";
|
|
48
|
+
};
|
|
49
|
+
readonly minPriority: {
|
|
50
|
+
readonly type: "number";
|
|
51
|
+
readonly description: "Drop records whose stored priority is below this threshold (0-100).";
|
|
52
|
+
};
|
|
53
|
+
readonly skillTag: {
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
readonly description: "Restrict to records produced under this skill tag.";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
readonly required: readonly ["sessionKey", "query"];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export declare function handleMemoryRecall(args: any, options?: {
|
|
64
|
+
defaultUserId?: string;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
content: {
|
|
67
|
+
type: string;
|
|
68
|
+
text: string;
|
|
69
|
+
}[];
|
|
70
|
+
isError?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
isError: boolean;
|
|
73
|
+
content: {
|
|
74
|
+
type: string;
|
|
75
|
+
text: string;
|
|
76
|
+
}[];
|
|
77
|
+
}>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { memoryEngine } from "../memory/engine.js";
|
|
3
|
+
export const memoryRecallToolSchema = {
|
|
4
|
+
name: "memory_recall",
|
|
5
|
+
description: "Retrieve relevant memories, persona, and scene context before generating a response. Best used proactively when context is missing. Supports `filters` to scope results by type / scene / time range / minPriority / skillTag — apply them when the query is mid-conversation pivot or only one memory category is wanted.",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
userId: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "The ID of the user (enforces multi-tenant isolation)."
|
|
12
|
+
},
|
|
13
|
+
sessionKey: {
|
|
14
|
+
type: "string",
|
|
15
|
+
description: "A stable identifier for this conversation channel/session."
|
|
16
|
+
},
|
|
17
|
+
query: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "The user's query or intent to recall memories for."
|
|
20
|
+
},
|
|
21
|
+
activeSkill: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "The name of the BrainRouter skill currently being executed (if any)."
|
|
24
|
+
},
|
|
25
|
+
filters: {
|
|
26
|
+
type: "object",
|
|
27
|
+
description: "Optional filters narrowing the candidate pool before ranking.",
|
|
28
|
+
properties: {
|
|
29
|
+
types: { type: "array", items: { type: "string" }, description: "Whitelist of memory types (e.g. ['instruction', 'feedback'])." },
|
|
30
|
+
scenes: { type: "array", items: { type: "string" }, description: "Whitelist of contextual focus scene names." },
|
|
31
|
+
capturedAfter: { type: "string", description: "ISO 8601 lower bound on created_time." },
|
|
32
|
+
capturedBefore: { type: "string", description: "ISO 8601 upper bound on created_time." },
|
|
33
|
+
minPriority: { type: "number", description: "Drop records whose stored priority is below this threshold (0-100)." },
|
|
34
|
+
skillTag: { type: "string", description: "Restrict to records produced under this skill tag." }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
required: ["sessionKey", "query"]
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export async function handleMemoryRecall(args, options) {
|
|
42
|
+
const params = z.object({
|
|
43
|
+
userId: z.string().optional(),
|
|
44
|
+
sessionKey: z.string(),
|
|
45
|
+
query: z.string(),
|
|
46
|
+
activeSkill: z.string().optional(),
|
|
47
|
+
filters: z.object({
|
|
48
|
+
types: z.array(z.string()).optional(),
|
|
49
|
+
scenes: z.array(z.string()).optional(),
|
|
50
|
+
capturedAfter: z.string().optional(),
|
|
51
|
+
capturedBefore: z.string().optional(),
|
|
52
|
+
minPriority: z.number().optional(),
|
|
53
|
+
skillTag: z.string().optional(),
|
|
54
|
+
}).optional()
|
|
55
|
+
}).parse(args);
|
|
56
|
+
const effectiveUserId = params.userId ?? options?.defaultUserId ?? "default";
|
|
57
|
+
try {
|
|
58
|
+
if (params.activeSkill) {
|
|
59
|
+
memoryEngine.spikeSkill(effectiveUserId, params.activeSkill);
|
|
60
|
+
}
|
|
61
|
+
const result = await memoryEngine.recall({
|
|
62
|
+
userId: effectiveUserId,
|
|
63
|
+
sessionKey: params.sessionKey,
|
|
64
|
+
query: params.query,
|
|
65
|
+
activeSkill: params.activeSkill,
|
|
66
|
+
filters: params.filters,
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
content: [{
|
|
70
|
+
type: "text",
|
|
71
|
+
text: JSON.stringify(result, null, 2)
|
|
72
|
+
}]
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
return {
|
|
77
|
+
isError: true,
|
|
78
|
+
content: [{ type: "text", text: `Recall failed: ${err.message}` }]
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const memoryRegisterSkillHintsToolSchema: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
skillName: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
hints: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
skillPath: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare const memoryRegisterSkillHintsSchema: z.ZodEffects<z.ZodObject<{
|
|
24
|
+
skillName: z.ZodOptional<z.ZodString>;
|
|
25
|
+
hints: z.ZodOptional<z.ZodString>;
|
|
26
|
+
skillPath: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
skillName?: string | undefined;
|
|
29
|
+
hints?: string | undefined;
|
|
30
|
+
skillPath?: string | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
skillName?: string | undefined;
|
|
33
|
+
hints?: string | undefined;
|
|
34
|
+
skillPath?: string | undefined;
|
|
35
|
+
}>, {
|
|
36
|
+
skillName?: string | undefined;
|
|
37
|
+
hints?: string | undefined;
|
|
38
|
+
skillPath?: string | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
skillName?: string | undefined;
|
|
41
|
+
hints?: string | undefined;
|
|
42
|
+
skillPath?: string | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
export declare function handleMemoryRegisterSkillHints(args: unknown): Promise<{
|
|
45
|
+
content: {
|
|
46
|
+
type: string;
|
|
47
|
+
text: string;
|
|
48
|
+
}[];
|
|
49
|
+
}>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { memoryEngine } from '../memory/engine.js';
|
|
3
|
+
import { loadSkillHints } from '../memory/skill-hints-loader.js';
|
|
4
|
+
export const memoryRegisterSkillHintsToolSchema = {
|
|
5
|
+
name: 'memory_register_skill_hints',
|
|
6
|
+
description: 'Register extraction hints for a specific skill. Hints guide the memory engine to capture the most valuable context when this skill is active. Can load from a SKILL.md file path or accept hints directly.',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
skillName: { type: 'string', description: 'Canonical skill name (must match the name field in SKILL.md frontmatter)' },
|
|
11
|
+
hints: { type: 'string', description: 'The extraction hints text. Use this for manual registration.' },
|
|
12
|
+
skillPath: { type: 'string', description: 'Absolute path to a SKILL.md file to auto-load hints from.' },
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
export const memoryRegisterSkillHintsSchema = z.object({
|
|
17
|
+
skillName: z.string().optional(),
|
|
18
|
+
hints: z.string().optional(),
|
|
19
|
+
skillPath: z.string().optional(),
|
|
20
|
+
}).refine((data) => (data.skillPath) || (data.skillName && data.hints), { message: 'Either provide skillPath to auto-load, or both skillName and hints for manual registration.' });
|
|
21
|
+
export async function handleMemoryRegisterSkillHints(args) {
|
|
22
|
+
const params = memoryRegisterSkillHintsSchema.parse(args);
|
|
23
|
+
let skillName;
|
|
24
|
+
let hints;
|
|
25
|
+
let sourceFile = '';
|
|
26
|
+
if (params.skillPath) {
|
|
27
|
+
// Auto-load from SKILL.md
|
|
28
|
+
const loaded = loadSkillHints(params.skillPath);
|
|
29
|
+
if (!loaded) {
|
|
30
|
+
return {
|
|
31
|
+
content: [{ type: 'text', text: `No memory_hints found in ${params.skillPath}. Add a memory_hints field to the YAML frontmatter.` }],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (!loaded.name) {
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: 'text', text: `SKILL.md at ${params.skillPath} has no name field in its frontmatter. Cannot register.` }],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
skillName = loaded.name;
|
|
40
|
+
hints = loaded.hints;
|
|
41
|
+
sourceFile = params.skillPath;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// Manual registration
|
|
45
|
+
skillName = params.skillName;
|
|
46
|
+
hints = params.hints;
|
|
47
|
+
}
|
|
48
|
+
memoryEngine.registerSkillHints(skillName, hints, sourceFile);
|
|
49
|
+
return {
|
|
50
|
+
content: [{
|
|
51
|
+
type: 'text',
|
|
52
|
+
text: `✅ Skill hints registered for "${skillName}"\n\nHints:\n${hints}${sourceFile ? `\n\nLoaded from: ${sourceFile}` : ''}`,
|
|
53
|
+
}],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const memoryResolveSessionToolSchema: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: string;
|
|
6
|
+
properties: {
|
|
7
|
+
workspacePath: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
suggestedKey: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
required: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare function handleMemoryResolveSession(args: unknown): Promise<{
|
|
20
|
+
content: {
|
|
21
|
+
type: string;
|
|
22
|
+
text: string;
|
|
23
|
+
}[];
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
6
|
+
import { getSafeWorkspacePath } from '../resolver.js';
|
|
7
|
+
/**
|
|
8
|
+
* Per-workspace MCP cache directory under the user home, NOT inside the
|
|
9
|
+
* project tree. Mirrors the brainrouter CLI's convention so the workspace
|
|
10
|
+
* tree stays clean of MCP-side state.
|
|
11
|
+
*
|
|
12
|
+
* ~/.brainrouter/mcp-cache/<workspace-hash>/
|
|
13
|
+
*
|
|
14
|
+
* The hash is sha256(absoluteWorkspacePath).slice(0, 12) so two different
|
|
15
|
+
* workspaces never collide. We don't reuse the CLI's `<basename>-<hash8>`
|
|
16
|
+
* encoding because the MCP and CLI are separate processes — keeping them
|
|
17
|
+
* encoded independently avoids cross-package coupling.
|
|
18
|
+
*/
|
|
19
|
+
function getMcpCacheDir(workspacePath) {
|
|
20
|
+
const hash = createHash('sha256').update(workspacePath).digest('hex').slice(0, 12);
|
|
21
|
+
const dir = path.join(os.homedir(), '.brainrouter', 'mcp-cache', hash);
|
|
22
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
23
|
+
return dir;
|
|
24
|
+
}
|
|
25
|
+
export const memoryResolveSessionToolSchema = {
|
|
26
|
+
name: 'memory_resolve_session',
|
|
27
|
+
description: 'Resolve and standardize the active session key (Conversation ID). If missing or descriptive, caches and retrieves a stable session UUID in the workspace.',
|
|
28
|
+
inputSchema: {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
workspacePath: { type: 'string', description: 'The absolute path to the active project workspace.' },
|
|
32
|
+
suggestedKey: { type: 'string', description: 'Optional suggested conversation/session ID from prompt metadata.' },
|
|
33
|
+
},
|
|
34
|
+
required: ['workspacePath'],
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const resolveSessionSchema = z.object({
|
|
38
|
+
workspacePath: z.string(),
|
|
39
|
+
suggestedKey: z.string().optional(),
|
|
40
|
+
});
|
|
41
|
+
// Helper to check if a key is a valid non-descriptive unique identifier (like UUID or hex hash)
|
|
42
|
+
function isUniqueId(key) {
|
|
43
|
+
// UUID pattern
|
|
44
|
+
const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
45
|
+
// Simple generic alphanumeric hash (e.g. 16-64 chars, standard for thread IDs, no spaces/hyphens with common words)
|
|
46
|
+
const cleanHashPattern = /^[a-z0-9_-]{16,64}$/i;
|
|
47
|
+
// Reject keys that are purely descriptive natural language words like "datedrop-collab-playlists"
|
|
48
|
+
const containsCommonWords = /playlist|collab|task|feature|debug|collection|datedrop|implement/i;
|
|
49
|
+
if (uuidPattern.test(key))
|
|
50
|
+
return true;
|
|
51
|
+
if (cleanHashPattern.test(key) && !containsCommonWords.test(key))
|
|
52
|
+
return true;
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
export async function handleMemoryResolveSession(args) {
|
|
56
|
+
const { workspacePath, suggestedKey } = resolveSessionSchema.parse(args);
|
|
57
|
+
const safeWorkspacePath = getSafeWorkspacePath(workspacePath);
|
|
58
|
+
// 1. If suggestedKey is a valid clean unique ID, use it directly
|
|
59
|
+
if (suggestedKey && isUniqueId(suggestedKey)) {
|
|
60
|
+
return {
|
|
61
|
+
content: [
|
|
62
|
+
{
|
|
63
|
+
type: 'text',
|
|
64
|
+
text: JSON.stringify({ sessionKey: suggestedKey, source: 'provider_metadata' }, null, 2),
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// 2. Cache lives in the user-global MCP cache dir, NOT inside the
|
|
70
|
+
// workspace. Writing `<workspace>/.brainrouter/` polluted every project
|
|
71
|
+
// tree, then bounced back through the CLI's legacy-state migration on
|
|
72
|
+
// each restart — a loop the user could see as recurring
|
|
73
|
+
// `.brainrouter/` + `.brainrouter.migrated/` folders.
|
|
74
|
+
let cacheFilePath;
|
|
75
|
+
try {
|
|
76
|
+
const cacheDir = getMcpCacheDir(safeWorkspacePath);
|
|
77
|
+
cacheFilePath = path.join(cacheDir, 'active_session.json');
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
// If the user home itself is unwritable (rare), fall back to a transient
|
|
81
|
+
// UUID rather than touching the workspace tree.
|
|
82
|
+
const fallbackUuid = randomUUID();
|
|
83
|
+
return {
|
|
84
|
+
content: [
|
|
85
|
+
{
|
|
86
|
+
type: 'text',
|
|
87
|
+
text: JSON.stringify({ sessionKey: fallbackUuid, source: 'fallback_transient', error: err.message }, null, 2),
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// 3. Read cached session if it exists and is not too old (e.g. within 2 hours, or just stable for the workspace)
|
|
93
|
+
if (fs.existsSync(cacheFilePath)) {
|
|
94
|
+
try {
|
|
95
|
+
const data = JSON.parse(fs.readFileSync(cacheFilePath, 'utf8'));
|
|
96
|
+
if (data && data.sessionKey) {
|
|
97
|
+
return {
|
|
98
|
+
content: [
|
|
99
|
+
{
|
|
100
|
+
type: 'text',
|
|
101
|
+
text: JSON.stringify({ sessionKey: data.sessionKey, source: 'workspace_cache' }, null, 2),
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Ignore parse errors and generate fresh
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// 4. Generate fresh standard UUID session key
|
|
112
|
+
const newSessionKey = randomUUID();
|
|
113
|
+
const sessionData = {
|
|
114
|
+
sessionKey: newSessionKey,
|
|
115
|
+
createdAt: new Date().toISOString(),
|
|
116
|
+
workspace: workspacePath,
|
|
117
|
+
cacheWorkspace: safeWorkspacePath,
|
|
118
|
+
};
|
|
119
|
+
try {
|
|
120
|
+
fs.writeFileSync(cacheFilePath, JSON.stringify(sessionData, null, 2), 'utf8');
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
console.error(`[BrainRouter] Failed to write session cache: ${err.message}`);
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
content: [
|
|
127
|
+
{
|
|
128
|
+
type: 'text',
|
|
129
|
+
text: JSON.stringify({ sessionKey: newSessionKey, source: 'new_workspace_generation' }, null, 2),
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const memorySearchToolSchema: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
userId: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
query: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
sessionKey: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
activeSkill: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
limit: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
asOf: {
|
|
29
|
+
type: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
filters: {
|
|
33
|
+
type: string;
|
|
34
|
+
description: string;
|
|
35
|
+
properties: {
|
|
36
|
+
types: {
|
|
37
|
+
type: string;
|
|
38
|
+
items: {
|
|
39
|
+
type: string;
|
|
40
|
+
};
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
scenes: {
|
|
44
|
+
type: string;
|
|
45
|
+
items: {
|
|
46
|
+
type: string;
|
|
47
|
+
};
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
50
|
+
capturedAfter: {
|
|
51
|
+
type: string;
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
capturedBefore: {
|
|
55
|
+
type: string;
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
58
|
+
minPriority: {
|
|
59
|
+
type: string;
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
skillTag: {
|
|
63
|
+
type: string;
|
|
64
|
+
description: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
required: string[];
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export declare const memorySearchSchema: z.ZodObject<{
|
|
73
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
74
|
+
query: z.ZodString;
|
|
75
|
+
sessionKey: z.ZodString;
|
|
76
|
+
activeSkill: z.ZodOptional<z.ZodString>;
|
|
77
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
asOf: z.ZodOptional<z.ZodString>;
|
|
79
|
+
filters: z.ZodOptional<z.ZodObject<{
|
|
80
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
81
|
+
scenes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
82
|
+
capturedAfter: z.ZodOptional<z.ZodString>;
|
|
83
|
+
capturedBefore: z.ZodOptional<z.ZodString>;
|
|
84
|
+
minPriority: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
skillTag: z.ZodOptional<z.ZodString>;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
skillTag?: string | undefined;
|
|
88
|
+
capturedAfter?: string | undefined;
|
|
89
|
+
capturedBefore?: string | undefined;
|
|
90
|
+
types?: string[] | undefined;
|
|
91
|
+
scenes?: string[] | undefined;
|
|
92
|
+
minPriority?: number | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
skillTag?: string | undefined;
|
|
95
|
+
capturedAfter?: string | undefined;
|
|
96
|
+
capturedBefore?: string | undefined;
|
|
97
|
+
types?: string[] | undefined;
|
|
98
|
+
scenes?: string[] | undefined;
|
|
99
|
+
minPriority?: number | undefined;
|
|
100
|
+
}>>;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
query: string;
|
|
103
|
+
sessionKey: string;
|
|
104
|
+
userId?: string | undefined;
|
|
105
|
+
activeSkill?: string | undefined;
|
|
106
|
+
filters?: {
|
|
107
|
+
skillTag?: string | undefined;
|
|
108
|
+
capturedAfter?: string | undefined;
|
|
109
|
+
capturedBefore?: string | undefined;
|
|
110
|
+
types?: string[] | undefined;
|
|
111
|
+
scenes?: string[] | undefined;
|
|
112
|
+
minPriority?: number | undefined;
|
|
113
|
+
} | undefined;
|
|
114
|
+
limit?: number | undefined;
|
|
115
|
+
asOf?: string | undefined;
|
|
116
|
+
}, {
|
|
117
|
+
query: string;
|
|
118
|
+
sessionKey: string;
|
|
119
|
+
userId?: string | undefined;
|
|
120
|
+
activeSkill?: string | undefined;
|
|
121
|
+
filters?: {
|
|
122
|
+
skillTag?: string | undefined;
|
|
123
|
+
capturedAfter?: string | undefined;
|
|
124
|
+
capturedBefore?: string | undefined;
|
|
125
|
+
types?: string[] | undefined;
|
|
126
|
+
scenes?: string[] | undefined;
|
|
127
|
+
minPriority?: number | undefined;
|
|
128
|
+
} | undefined;
|
|
129
|
+
limit?: number | undefined;
|
|
130
|
+
asOf?: string | undefined;
|
|
131
|
+
}>;
|
|
132
|
+
export declare function handleMemorySearch(args: unknown, options?: {
|
|
133
|
+
defaultUserId?: string;
|
|
134
|
+
}): Promise<{
|
|
135
|
+
content: {
|
|
136
|
+
type: string;
|
|
137
|
+
text: string;
|
|
138
|
+
}[];
|
|
139
|
+
isError?: undefined;
|
|
140
|
+
} | {
|
|
141
|
+
isError: boolean;
|
|
142
|
+
content: {
|
|
143
|
+
type: string;
|
|
144
|
+
text: string;
|
|
145
|
+
}[];
|
|
146
|
+
}>;
|