@theihtisham/agent-shadow-brain 7.1.3 → 7.1.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/CHANGELOG.md +20 -0
- package/README.md +125 -90
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/brain/activity-journal.d.ts.map +1 -1
- package/dist/brain/activity-journal.js +2 -1
- package/dist/brain/activity-journal.js.map +1 -1
- package/dist/brain/auto-update.js +1 -1
- package/dist/brain/brain-portability.js +1 -1
- package/dist/brain/client-config.d.ts +19 -0
- package/dist/brain/client-config.d.ts.map +1 -0
- package/dist/brain/client-config.js +40 -0
- package/dist/brain/client-config.js.map +1 -0
- package/dist/brain/client-integrations.d.ts +2 -0
- package/dist/brain/client-integrations.d.ts.map +1 -1
- package/dist/brain/client-integrations.js +8 -27
- package/dist/brain/client-integrations.js.map +1 -1
- package/dist/brain/context-assembly.d.ts +10 -2
- package/dist/brain/context-assembly.d.ts.map +1 -1
- package/dist/brain/context-assembly.js +238 -14
- package/dist/brain/context-assembly.js.map +1 -1
- package/dist/brain/context-request.d.ts +4 -0
- package/dist/brain/context-request.d.ts.map +1 -0
- package/dist/brain/context-request.js +22 -0
- package/dist/brain/context-request.js.map +1 -0
- package/dist/brain/context-retrieval.d.ts +88 -0
- package/dist/brain/context-retrieval.d.ts.map +1 -0
- package/dist/brain/context-retrieval.js +300 -0
- package/dist/brain/context-retrieval.js.map +1 -0
- package/dist/brain/feature-settings.d.ts.map +1 -1
- package/dist/brain/feature-settings.js +2 -1
- package/dist/brain/feature-settings.js.map +1 -1
- package/dist/brain/file-identity.d.ts +4 -0
- package/dist/brain/file-identity.d.ts.map +1 -0
- package/dist/brain/file-identity.js +27 -0
- package/dist/brain/file-identity.js.map +1 -0
- package/dist/brain/global-brain.d.ts +11 -1
- package/dist/brain/global-brain.d.ts.map +1 -1
- package/dist/brain/global-brain.js +58 -6
- package/dist/brain/global-brain.js.map +1 -1
- package/dist/brain/mcp-server.d.ts +9 -0
- package/dist/brain/mcp-server.d.ts.map +1 -1
- package/dist/brain/mcp-server.js +237 -53
- package/dist/brain/mcp-server.js.map +1 -1
- package/dist/brain/mcp-stdio.d.ts.map +1 -1
- package/dist/brain/mcp-stdio.js +10 -4
- package/dist/brain/mcp-stdio.js.map +1 -1
- package/dist/brain/memory-annotations.d.ts.map +1 -1
- package/dist/brain/memory-annotations.js +2 -1
- package/dist/brain/memory-annotations.js.map +1 -1
- package/dist/brain/memory-inspection.d.ts +72 -0
- package/dist/brain/memory-inspection.d.ts.map +1 -0
- package/dist/brain/memory-inspection.js +131 -0
- package/dist/brain/memory-inspection.js.map +1 -0
- package/dist/brain/memory-mcp-content.d.ts +44 -0
- package/dist/brain/memory-mcp-content.d.ts.map +1 -0
- package/dist/brain/memory-mcp-content.js +91 -0
- package/dist/brain/memory-mcp-content.js.map +1 -0
- package/dist/brain/orchestrator.js +1 -1
- package/dist/brain/project-feedback.d.ts +63 -0
- package/dist/brain/project-feedback.d.ts.map +1 -0
- package/dist/brain/project-feedback.js +289 -0
- package/dist/brain/project-feedback.js.map +1 -0
- package/dist/brain/project-hub-contract.d.ts +326 -0
- package/dist/brain/project-hub-contract.d.ts.map +1 -0
- package/dist/brain/project-hub-contract.js +56 -0
- package/dist/brain/project-hub-contract.js.map +1 -0
- package/dist/brain/project-hub-mcp.d.ts +168 -0
- package/dist/brain/project-hub-mcp.d.ts.map +1 -0
- package/dist/brain/project-hub-mcp.js +41 -0
- package/dist/brain/project-hub-mcp.js.map +1 -0
- package/dist/brain/project-hub-pdf-worker.d.ts +13 -0
- package/dist/brain/project-hub-pdf-worker.d.ts.map +1 -0
- package/dist/brain/project-hub-pdf-worker.js +84 -0
- package/dist/brain/project-hub-pdf-worker.js.map +1 -0
- package/dist/brain/project-hub-store.d.ts +38 -0
- package/dist/brain/project-hub-store.d.ts.map +1 -0
- package/dist/brain/project-hub-store.js +189 -0
- package/dist/brain/project-hub-store.js.map +1 -0
- package/dist/brain/project-hub.d.ts +127 -0
- package/dist/brain/project-hub.d.ts.map +1 -0
- package/dist/brain/project-hub.js +381 -0
- package/dist/brain/project-hub.js.map +1 -0
- package/dist/brain/project-kit-inspection.d.ts +28 -0
- package/dist/brain/project-kit-inspection.d.ts.map +1 -0
- package/dist/brain/project-kit-inspection.js +200 -0
- package/dist/brain/project-kit-inspection.js.map +1 -0
- package/dist/brain/project-kit-paths.d.ts +13 -0
- package/dist/brain/project-kit-paths.d.ts.map +1 -0
- package/dist/brain/project-kit-paths.js +141 -0
- package/dist/brain/project-kit-paths.js.map +1 -0
- package/dist/brain/project-kit.d.ts +41 -0
- package/dist/brain/project-kit.d.ts.map +1 -0
- package/dist/brain/project-kit.js +255 -0
- package/dist/brain/project-kit.js.map +1 -0
- package/dist/brain/project-memory.d.ts +38 -0
- package/dist/brain/project-memory.d.ts.map +1 -0
- package/dist/brain/project-memory.js +76 -0
- package/dist/brain/project-memory.js.map +1 -0
- package/dist/brain/subconscious.js +2 -2
- package/dist/brain/subconscious.js.map +1 -1
- package/dist/brain/workflow-skills.d.ts.map +1 -1
- package/dist/brain/workflow-skills.js +3 -2
- package/dist/brain/workflow-skills.js.map +1 -1
- package/dist/cli.js +22 -3
- package/dist/cli.js.map +1 -1
- package/dist/context-cli.d.ts.map +1 -1
- package/dist/context-cli.js +39 -5
- package/dist/context-cli.js.map +1 -1
- package/dist/dashboard/brain-hub-actions.d.ts +2 -0
- package/dist/dashboard/brain-hub-actions.d.ts.map +1 -0
- package/dist/dashboard/brain-hub-actions.js +137 -0
- package/dist/dashboard/brain-hub-actions.js.map +1 -0
- package/dist/dashboard/brain-hub-client.d.ts +2 -0
- package/dist/dashboard/brain-hub-client.d.ts.map +1 -0
- package/dist/dashboard/brain-hub-client.js +335 -0
- package/dist/dashboard/brain-hub-client.js.map +1 -0
- package/dist/dashboard/brain-hub-graph.d.ts +2 -0
- package/dist/dashboard/brain-hub-graph.d.ts.map +1 -0
- package/dist/dashboard/brain-hub-graph.js +176 -0
- package/dist/dashboard/brain-hub-graph.js.map +1 -0
- package/dist/dashboard/brain-hub-html.d.ts +2 -0
- package/dist/dashboard/brain-hub-html.d.ts.map +1 -0
- package/dist/dashboard/brain-hub-html.js +30 -0
- package/dist/dashboard/brain-hub-html.js.map +1 -0
- package/dist/dashboard/brain-hub-project-views.d.ts +2 -0
- package/dist/dashboard/brain-hub-project-views.d.ts.map +1 -0
- package/dist/dashboard/brain-hub-project-views.js +79 -0
- package/dist/dashboard/brain-hub-project-views.js.map +1 -0
- package/dist/dashboard/brain-hub-views.d.ts +2 -0
- package/dist/dashboard/brain-hub-views.d.ts.map +1 -0
- package/dist/dashboard/brain-hub-views.js +150 -0
- package/dist/dashboard/brain-hub-views.js.map +1 -0
- package/dist/dashboard/demo-workspace.d.ts +11 -0
- package/dist/dashboard/demo-workspace.d.ts.map +1 -0
- package/dist/dashboard/demo-workspace.js +178 -0
- package/dist/dashboard/demo-workspace.js.map +1 -0
- package/dist/dashboard/live-workspace-html.d.ts.map +1 -1
- package/dist/dashboard/live-workspace-html.js +177 -28
- package/dist/dashboard/live-workspace-html.js.map +1 -1
- package/dist/dashboard/project-feedback-html.d.ts +5 -0
- package/dist/dashboard/project-feedback-html.d.ts.map +1 -0
- package/dist/dashboard/project-feedback-html.js +216 -0
- package/dist/dashboard/project-feedback-html.js.map +1 -0
- package/dist/dashboard/project-hub-api.d.ts +5 -0
- package/dist/dashboard/project-hub-api.d.ts.map +1 -0
- package/dist/dashboard/project-hub-api.js +121 -0
- package/dist/dashboard/project-hub-api.js.map +1 -0
- package/dist/dashboard/project-kit-html.d.ts +4 -0
- package/dist/dashboard/project-kit-html.d.ts.map +1 -0
- package/dist/dashboard/project-kit-html.js +359 -0
- package/dist/dashboard/project-kit-html.js.map +1 -0
- package/dist/dashboard/project-workspace.d.ts +16 -0
- package/dist/dashboard/project-workspace.d.ts.map +1 -0
- package/dist/dashboard/project-workspace.js +106 -0
- package/dist/dashboard/project-workspace.js.map +1 -0
- package/dist/dashboard/server.d.ts +1 -0
- package/dist/dashboard/server.d.ts.map +1 -1
- package/dist/dashboard/server.js +15 -4
- package/dist/dashboard/server.js.map +1 -1
- package/dist/dashboard/v6-dashboard-html.d.ts +1 -1
- package/dist/dashboard/v6-dashboard-html.d.ts.map +1 -1
- package/dist/dashboard/v6-dashboard-html.js +27 -27
- package/dist/dashboard/workspace-api.d.ts +6 -0
- package/dist/dashboard/workspace-api.d.ts.map +1 -1
- package/dist/dashboard/workspace-api.js +154 -34
- package/dist/dashboard/workspace-api.js.map +1 -1
- package/dist/dashboard/workspace-html.d.ts.map +1 -1
- package/dist/dashboard/workspace-html.js +487 -81
- package/dist/dashboard/workspace-html.js.map +1 -1
- package/dist/dashboard/workspace-status.d.ts +50 -0
- package/dist/dashboard/workspace-status.d.ts.map +1 -0
- package/dist/dashboard/workspace-status.js +22 -0
- package/dist/dashboard/workspace-status.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/integration-cli.d.ts.map +1 -1
- package/dist/integration-cli.js +6 -4
- package/dist/integration-cli.js.map +1 -1
- package/dist/project-cli.d.ts +3 -0
- package/dist/project-cli.d.ts.map +1 -0
- package/dist/project-cli.js +100 -0
- package/dist/project-cli.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/docs/COMPARISON.md +22 -0
- package/docs/COMPONENTS.md +66 -0
- package/docs/CONTEXT_LAB.md +79 -0
- package/docs/FEATURES_AND_LIMITS.md +24 -0
- package/docs/INTEGRATIONS.md +68 -0
- package/docs/LEARNING.md +46 -0
- package/docs/PROJECT_KIT.md +93 -0
- package/docs/QUICKSTART.md +44 -0
- package/docs/README.md +33 -0
- package/docs/ROADMAP-v7.md +147 -0
- package/docs/SHARING.md +13 -0
- package/docs/SHOWCASE.md +87 -0
- package/docs/STATS.md +21 -0
- package/docs/TROUBLESHOOTING.md +42 -0
- package/docs/UPGRADE_PLAN_v7.0.0.md +203 -0
- package/docs/VIRAL-PLAYBOOK.md +259 -0
- package/docs/VISUAL_GUIDE_v7.1.4.md +70 -0
- package/docs/WORKFLOW_INTEGRATION.md +19 -1
- package/docs/WORKSPACE.md +17 -91
- package/docs/assets/7.1.4-collaboration-design-preview.png +0 -0
- package/docs/assets/7.1.4-comparison.png +0 -0
- package/docs/assets/7.1.4-context-lab.png +0 -0
- package/docs/assets/7.1.4-control-room-dense-preview.png +0 -0
- package/docs/assets/7.1.4-control-room-focus-preview.png +0 -0
- package/docs/assets/7.1.4-features.png +0 -0
- package/docs/assets/7.1.4-graph.png +0 -0
- package/docs/assets/7.1.4-hub-control-room.png +0 -0
- package/docs/assets/7.1.4-hub-empty.png +0 -0
- package/docs/assets/7.1.4-hub-knowledge.png +0 -0
- package/docs/assets/7.1.4-hub-learning.png +0 -0
- package/docs/assets/7.1.4-hub-mobile.png +0 -0
- package/docs/assets/7.1.4-hub-public-docs-source.png +0 -0
- package/docs/assets/7.1.4-hub-public-docs.gif +0 -0
- package/docs/assets/7.1.4-hub-public-docs.png +0 -0
- package/docs/assets/7.1.4-hub-setup.png +0 -0
- package/docs/assets/7.1.4-hub-walkthrough.gif +0 -0
- package/docs/assets/7.1.4-integrations.png +0 -0
- package/docs/assets/7.1.4-knowledge-design-preview.png +0 -0
- package/docs/assets/7.1.4-learning-design-preview.png +0 -0
- package/docs/assets/7.1.4-learning.png +0 -0
- package/docs/assets/7.1.4-live.png +0 -0
- package/docs/assets/7.1.4-memory-review.png +0 -0
- package/docs/assets/7.1.4-mobile.png +0 -0
- package/docs/assets/7.1.4-models-design-preview.png +0 -0
- package/docs/assets/7.1.4-outcome-ranking.png +0 -0
- package/docs/assets/7.1.4-overview.png +0 -0
- package/docs/assets/7.1.4-project-kit.png +0 -0
- package/docs/assets/7.1.4-project-skill-preview.png +0 -0
- package/docs/assets/7.1.4-replay.png +0 -0
- package/docs/assets/7.1.4-setup-design-preview.png +0 -0
- package/docs/assets/7.1.4-usage-design-preview.png +0 -0
- package/docs/assets/context-v7.1.3.png +0 -0
- package/docs/assets/features-v7.1.3.png +0 -0
- package/docs/assets/graph-v7.1.3.png +0 -0
- package/docs/assets/integrations-v7.1.3.png +0 -0
- package/docs/assets/live-v7.1.4.gif +0 -0
- package/docs/evaluation/CONTEXT_EVALUATION_v7.1.4.json +1818 -0
- package/docs/evaluation/CONTEXT_EVALUATION_v7.1.4.md +36 -0
- package/docs/launch/COMPONENT_MAP_v7.1.4.md +307 -0
- package/docs/launch/PROJECT_KIT_PLAN_v7.1.4.md +110 -0
- package/docs/launch/PROJECT_LEARNING_PLAN_v7.1.4.md +63 -0
- package/docs/launch/RELEASE_NOTES_v7.1.4.md +30 -0
- package/docs/launch/RESEARCH_AND_PLAN_v7.1.4.md +255 -0
- package/package.json +25 -7
- package/skills/shadow-research/SKILL.md +2 -0
- package/skills/shadow-workflow/SKILL.md +6 -0
package/dist/brain/mcp-server.js
CHANGED
|
@@ -5,8 +5,22 @@ import * as http from 'http';
|
|
|
5
5
|
import { randomUUID } from 'node:crypto';
|
|
6
6
|
import * as path from 'node:path';
|
|
7
7
|
import { performance } from 'node:perf_hooks';
|
|
8
|
+
import { parseContextRequest } from './context-request.js';
|
|
9
|
+
import { inspectMemory, inspectMemoryHealth, requireMemoryIdentifier } from './memory-inspection.js';
|
|
10
|
+
import { MEMORY_RESOURCES, MEMORY_RESOURCE_TEMPLATES, MEMORY_PROMPTS, MemoryResourceNotFound, readMemoryResource, getMemoryPrompt, refreshMemoryView } from './memory-mcp-content.js';
|
|
11
|
+
import { inspectProject, planProjectSkill, applyProjectSkill } from './project-kit.js';
|
|
12
|
+
import { requireProjectStore, addProjectKnowledge } from './project-memory.js';
|
|
13
|
+
import { ProjectFeedbackStore } from './project-feedback.js';
|
|
14
|
+
import { HUB_MCP_DEFINITIONS, HUB_MCP_TOOLS, isHubMcpTool } from './project-hub-mcp.js';
|
|
15
|
+
import { ProjectHubError } from './project-hub-contract.js';
|
|
8
16
|
const MEMORY_TOOLS = new Set(['global_recall', 'global_recall_scored', 'global_stats', 'global_storage_health',
|
|
9
|
-
'global_timeline', 'workflow_analyze', 'workflow_skills', 'context_pack', 'feature_flags', 'activity_report']);
|
|
17
|
+
'global_timeline', 'workflow_analyze', 'workflow_skills', 'context_pack', 'feature_flags', 'activity_report', 'memory_inspect', 'memory_health']);
|
|
18
|
+
const PROJECT_TOOLS = new Set(['project_inspect', 'project_knowledge', 'project_skill_preview', 'project_skill_apply', 'project_feedback']);
|
|
19
|
+
const PROJECT_SKILL_PROPERTIES = {
|
|
20
|
+
requirement: { type: 'string', minLength: 1, maxLength: 8000 },
|
|
21
|
+
target: { type: 'string', enum: ['codex', 'claude-code', 'opencode', 'deepseek-harness', 'portable'] },
|
|
22
|
+
name: { type: 'string', maxLength: 63 }, knowledge: { type: 'string', maxLength: 8000 },
|
|
23
|
+
};
|
|
10
24
|
export class MCPServer {
|
|
11
25
|
constructor(orchestrator, options, dependencies = {}) {
|
|
12
26
|
this.dependencies = dependencies;
|
|
@@ -17,6 +31,8 @@ export class MCPServer {
|
|
|
17
31
|
this.telemetryAgent = 'mcp-client';
|
|
18
32
|
this.telemetryInitialized = false;
|
|
19
33
|
this.telemetryWarning = false;
|
|
34
|
+
this.hubClosing = false;
|
|
35
|
+
this.hubRequests = new Set();
|
|
20
36
|
this.orchestrator = orchestrator;
|
|
21
37
|
this.options = {
|
|
22
38
|
port: options?.port ?? 7342,
|
|
@@ -54,6 +70,14 @@ export class MCPServer {
|
|
|
54
70
|
workflow_analyze: this.handleWorkflowAnalyze.bind(this),
|
|
55
71
|
workflow_skills: this.handleWorkflowSkills.bind(this),
|
|
56
72
|
context_pack: this.handleContextPack.bind(this),
|
|
73
|
+
memory_inspect: this.handleMemoryInspect.bind(this),
|
|
74
|
+
memory_health: this.handleMemoryHealth.bind(this),
|
|
75
|
+
project_inspect: params => this.handleProjectKit('inspect', params),
|
|
76
|
+
project_knowledge: params => this.handleProjectKit('knowledge', params),
|
|
77
|
+
project_skill_preview: params => this.handleProjectKit('preview', params),
|
|
78
|
+
project_skill_apply: params => this.handleProjectKit('apply', params),
|
|
79
|
+
project_feedback: params => this.handleProjectKit('feedback', params),
|
|
80
|
+
...Object.fromEntries(HUB_MCP_DEFINITIONS.map(tool => [tool.name, (params) => this.handleProjectHub(tool.name, params)])),
|
|
57
81
|
feature_flags: this.handleFeatureFlags.bind(this),
|
|
58
82
|
activity_report: this.handleActivityReport.bind(this),
|
|
59
83
|
attach_status: this.handleAttachStatus.bind(this),
|
|
@@ -331,7 +355,7 @@ export class MCPServer {
|
|
|
331
355
|
const brain = this.dependencies.brain ?? getGlobalBrain();
|
|
332
356
|
await Promise.all([sabb.init(), causal.init(), collisions.init(), dream.init(), rep.init(), tokens.init(), formal.init(), airgap.init(), brain.init()]);
|
|
333
357
|
return {
|
|
334
|
-
version: '7.1.
|
|
358
|
+
version: '7.1.4',
|
|
335
359
|
modules: {
|
|
336
360
|
sabb: sabb.getStats(),
|
|
337
361
|
causal: causal.stats(),
|
|
@@ -344,6 +368,8 @@ export class MCPServer {
|
|
|
344
368
|
},
|
|
345
369
|
localFirst: true,
|
|
346
370
|
totalAgentsConnected: brain.getStats().totalAgents,
|
|
371
|
+
totalRecordedAgents: brain.getStats().totalAgents,
|
|
372
|
+
agentCountEvidence: 'Historical tools recorded in memory; not current connections.',
|
|
347
373
|
totalMemoriesStored: brain.getStats().totalEntries,
|
|
348
374
|
generatedAt: new Date(),
|
|
349
375
|
};
|
|
@@ -394,6 +420,13 @@ export class MCPServer {
|
|
|
394
420
|
const { getAllCacheStats } = await import('./l0-cache.js');
|
|
395
421
|
const brain = this.dependencies.brain ?? getGlobalBrain();
|
|
396
422
|
await brain.init();
|
|
423
|
+
if (this.dependencies.localProject) {
|
|
424
|
+
const store = requireProjectStore(this.dependencies.projectDir, brain);
|
|
425
|
+
brain.refresh();
|
|
426
|
+
const entries = [...brain.contextEntries({ projectId: store.projectId })];
|
|
427
|
+
return { scope: { projectId: store.projectId }, brain: { totalEntries: entries.length,
|
|
428
|
+
totalProjects: entries.length ? 1 : 0, totalAgents: new Set(entries.map(entry => entry.agentTool)).size } };
|
|
429
|
+
}
|
|
397
430
|
return {
|
|
398
431
|
brain: brain.getStats(),
|
|
399
432
|
caches: getAllCacheStats(),
|
|
@@ -421,27 +454,41 @@ export class MCPServer {
|
|
|
421
454
|
const { assembleContext } = await import('./context-assembly.js');
|
|
422
455
|
const { getFeatureSettings } = await import('./feature-settings.js');
|
|
423
456
|
const { getGlobalBrain } = await import('./global-brain.js');
|
|
424
|
-
|
|
425
|
-
throw new TypeError('A project ID is required.');
|
|
426
|
-
if (params.query !== undefined && typeof params.query !== 'string')
|
|
427
|
-
throw new TypeError('Query must be text.');
|
|
428
|
-
if (params.tokenBudget !== undefined && (!Number.isSafeInteger(params.tokenBudget) || Number(params.tokenBudget) < 0 || Number(params.tokenBudget) > 12000))
|
|
429
|
-
throw new TypeError('Token budget must be an integer from 0 to 12000.');
|
|
430
|
-
if (params.includeCrossProject !== undefined && typeof params.includeCrossProject !== 'boolean')
|
|
431
|
-
throw new TypeError('Cross-project choice must be boolean.');
|
|
457
|
+
const options = parseContextRequest(params);
|
|
432
458
|
const features = (this.dependencies.settings ?? getFeatureSettings()).get().features;
|
|
433
459
|
const brain = this.dependencies.brain ?? getGlobalBrain();
|
|
434
460
|
if (features.contextAssembly) {
|
|
435
|
-
|
|
436
|
-
await brain.sync();
|
|
437
|
-
if (brain.getStorageHealth().lastError)
|
|
438
|
-
throw new Error('Memory store is not readable. Check global_storage_health.');
|
|
461
|
+
refreshMemoryView(brain);
|
|
439
462
|
}
|
|
440
463
|
const { memoryAnnotationsFor } = await import('./memory-annotations.js');
|
|
441
|
-
return assembleContext(brain, {
|
|
442
|
-
|
|
464
|
+
return assembleContext(brain, { ...options, features,
|
|
465
|
+
feedback: features.contextAssembly && options.profile === 'adaptive' && this.dependencies.localProject
|
|
466
|
+
? new ProjectFeedbackStore(this.dependencies.projectDir, brain).get() : undefined,
|
|
443
467
|
annotations: features.contextAssembly ? memoryAnnotationsFor(brain).get() : undefined });
|
|
444
468
|
}
|
|
469
|
+
async handleMemoryInspect(params) {
|
|
470
|
+
if (Object.keys(params).some(key => !['projectId', 'memoryId'].includes(key)))
|
|
471
|
+
throw new TypeError('Unknown inspection field.');
|
|
472
|
+
requireMemoryIdentifier(params.projectId);
|
|
473
|
+
requireMemoryIdentifier(params.memoryId, 'memoryId');
|
|
474
|
+
const { getGlobalBrain } = await import('./global-brain.js');
|
|
475
|
+
const { memoryAnnotationsFor } = await import('./memory-annotations.js');
|
|
476
|
+
const brain = this.dependencies.brain ?? getGlobalBrain();
|
|
477
|
+
refreshMemoryView(brain);
|
|
478
|
+
return inspectMemory(brain, memoryAnnotationsFor(brain).get(), params.projectId, params.memoryId) ?? { found: false };
|
|
479
|
+
}
|
|
480
|
+
async handleMemoryHealth(params) {
|
|
481
|
+
if (Object.keys(params).some(key => !['projectId', 'limit'].includes(key)))
|
|
482
|
+
throw new TypeError('Unknown health field.');
|
|
483
|
+
requireMemoryIdentifier(params.projectId);
|
|
484
|
+
if (params.limit !== undefined && (!Number.isSafeInteger(params.limit) || Number(params.limit) < 1 || Number(params.limit) > 100))
|
|
485
|
+
throw new TypeError('limit must be an integer from 1 to 100.');
|
|
486
|
+
const { getGlobalBrain } = await import('./global-brain.js');
|
|
487
|
+
const { memoryAnnotationsFor } = await import('./memory-annotations.js');
|
|
488
|
+
const brain = this.dependencies.brain ?? getGlobalBrain();
|
|
489
|
+
refreshMemoryView(brain);
|
|
490
|
+
return inspectMemoryHealth(brain, memoryAnnotationsFor(brain).get(), { projectId: params.projectId, limit: params.limit });
|
|
491
|
+
}
|
|
445
492
|
async handleFeatureFlags(_params) {
|
|
446
493
|
const { getFeatureSettings, FEATURE_DEFINITIONS } = await import('./feature-settings.js');
|
|
447
494
|
return { ...(this.dependencies.settings ?? getFeatureSettings()).get(), definitions: FEATURE_DEFINITIONS };
|
|
@@ -559,7 +606,7 @@ export class MCPServer {
|
|
|
559
606
|
// Lightweight health endpoint for tool connectivity checks
|
|
560
607
|
this.sendJSON(res, 200, {
|
|
561
608
|
status: 'ok',
|
|
562
|
-
version: '7.1.
|
|
609
|
+
version: '7.1.4',
|
|
563
610
|
uptime: process.uptime(),
|
|
564
611
|
tools: Object.keys(this.toolHandlers).length,
|
|
565
612
|
});
|
|
@@ -620,6 +667,8 @@ export class MCPServer {
|
|
|
620
667
|
}
|
|
621
668
|
const { method, params } = request;
|
|
622
669
|
try {
|
|
670
|
+
if (this.dependencies.localProject)
|
|
671
|
+
requireProjectStore(this.dependencies.projectDir, this.dependencies.brain);
|
|
623
672
|
switch (method) {
|
|
624
673
|
case 'initialize': {
|
|
625
674
|
if (this.options.toolProfile === 'memory') {
|
|
@@ -639,49 +688,102 @@ export class MCPServer {
|
|
|
639
688
|
case 'tools/list':
|
|
640
689
|
return this.makeResult(request.id, { tools: this.getToolDefinitions() });
|
|
641
690
|
case 'resources/list':
|
|
642
|
-
return this.makeResult(request.id, { resources:
|
|
691
|
+
return this.makeResult(request.id, { resources: MEMORY_RESOURCES });
|
|
692
|
+
case 'resources/templates/list':
|
|
693
|
+
return this.makeResult(request.id, { resourceTemplates: MEMORY_RESOURCE_TEMPLATES });
|
|
694
|
+
case 'resources/read': {
|
|
695
|
+
const { getGlobalBrain } = await import('./global-brain.js');
|
|
696
|
+
if (this.dependencies.localProject && typeof params?.uri === 'string') {
|
|
697
|
+
const match = /^shadow-brain:\/\/projects\/([^/?#]+)\//.exec(params.uri);
|
|
698
|
+
if (match && decodeURIComponent(match[1]) !== await this.telemetryProject())
|
|
699
|
+
throw new TypeError('This MCP service is pinned to its local project.');
|
|
700
|
+
}
|
|
701
|
+
return this.makeResult(request.id, await readMemoryResource(params?.uri, this.dependencies.brain ?? getGlobalBrain()));
|
|
702
|
+
}
|
|
643
703
|
case 'prompts/list':
|
|
644
|
-
return this.makeResult(request.id, { prompts:
|
|
704
|
+
return this.makeResult(request.id, { prompts: MEMORY_PROMPTS });
|
|
705
|
+
case 'prompts/get': {
|
|
706
|
+
const { getGlobalBrain } = await import('./global-brain.js');
|
|
707
|
+
const { getFeatureSettings } = await import('./feature-settings.js');
|
|
708
|
+
if (this.dependencies.localProject && params?.arguments?.projectId !== await this.telemetryProject())
|
|
709
|
+
throw new TypeError('This MCP service is pinned to its local project.');
|
|
710
|
+
return this.makeResult(request.id, await getMemoryPrompt(params?.name, params?.arguments, this.dependencies.brain ?? getGlobalBrain(), this.dependencies.settings ?? getFeatureSettings(), this.dependencies.localProject ? () => new ProjectFeedbackStore(this.dependencies.projectDir, this.dependencies.brain).get() : undefined));
|
|
711
|
+
}
|
|
645
712
|
case 'tools/call': {
|
|
646
713
|
const toolName = params?.name;
|
|
647
|
-
|
|
714
|
+
let toolArgs = params?.arguments ?? {};
|
|
648
715
|
if (typeof toolName !== 'string' || !toolName || !toolArgs || typeof toolArgs !== 'object' || Array.isArray(toolArgs)) {
|
|
649
716
|
return this.makeError(request.id, -32602, 'Missing tool name in params.name');
|
|
650
717
|
}
|
|
651
718
|
const handler = this.toolHandlers[toolName];
|
|
652
|
-
|
|
719
|
+
const hubTool = isHubMcpTool(toolName);
|
|
720
|
+
if (!Object.hasOwn(this.toolHandlers, toolName) || !handler ||
|
|
721
|
+
(PROJECT_TOOLS.has(toolName) && !this.dependencies.localProject) ||
|
|
722
|
+
(hubTool && !this.hubAvailable()) ||
|
|
723
|
+
(this.options.toolProfile === 'memory' && !hubTool && !MEMORY_TOOLS.has(toolName) && !PROJECT_TOOLS.has(toolName))) {
|
|
653
724
|
return this.makeError(request.id, -32601, `Unknown tool: ${toolName}`);
|
|
654
725
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
const measured = this.options.toolProfile === 'memory' && toolName !== 'activity_report';
|
|
659
|
-
const correlationId = randomUUID();
|
|
660
|
-
const projectId = typeof toolArgs.projectId === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/.test(toolArgs.projectId)
|
|
661
|
-
? toolArgs.projectId : undefined;
|
|
662
|
-
if (measured)
|
|
663
|
-
await this.recordMeasured({ kind: 'tool-start', tool: toolName, correlationId, ...(projectId ? { projectId } : {}) });
|
|
664
|
-
const started = performance.now();
|
|
665
|
-
let result;
|
|
726
|
+
if (hubTool && this.hubClosing)
|
|
727
|
+
return this.makeError(request.id, -32002, 'This project hub session is closing.');
|
|
728
|
+
const perform = async () => {
|
|
666
729
|
try {
|
|
667
|
-
|
|
730
|
+
if (this.dependencies.localProject && ['global_recall', 'global_recall_scored', 'global_timeline', 'context_pack', 'memory_inspect', 'memory_health', 'activity_report'].includes(toolName)) {
|
|
731
|
+
const projectId = await this.telemetryProject();
|
|
732
|
+
if ((toolArgs.projectId !== undefined && toolArgs.projectId !== projectId) ||
|
|
733
|
+
(toolArgs.projectDir !== undefined && (typeof toolArgs.projectDir !== 'string' || path.resolve(toolArgs.projectDir) !== path.resolve(this.dependencies.projectDir))) ||
|
|
734
|
+
toolArgs.includeCrossProject === true)
|
|
735
|
+
throw new TypeError('This MCP service is pinned to its local project.');
|
|
736
|
+
toolArgs = { ...toolArgs, projectId };
|
|
737
|
+
}
|
|
738
|
+
if (this.options.toolProfile === 'memory')
|
|
739
|
+
this.validateMemoryArguments(toolName, toolArgs);
|
|
740
|
+
const measured = this.options.toolProfile === 'memory' && toolName !== 'activity_report';
|
|
741
|
+
const correlationId = randomUUID();
|
|
742
|
+
const projectId = typeof toolArgs.projectId === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/.test(toolArgs.projectId)
|
|
743
|
+
? toolArgs.projectId : undefined;
|
|
668
744
|
if (measured)
|
|
669
|
-
await this.recordMeasured({ kind: 'tool-
|
|
670
|
-
|
|
745
|
+
await this.recordMeasured({ kind: 'tool-start', tool: toolName, correlationId, ...(projectId ? { projectId } : {}) });
|
|
746
|
+
const started = performance.now();
|
|
747
|
+
let result;
|
|
748
|
+
try {
|
|
749
|
+
result = await handler(toolArgs);
|
|
750
|
+
if (measured)
|
|
751
|
+
await this.recordMeasured({ kind: 'tool-end', tool: toolName, correlationId, outcome: 'success',
|
|
752
|
+
durationMs: Math.max(0, Math.round((performance.now() - started) * 1000) / 1000), ...(projectId ? { projectId } : {}) });
|
|
753
|
+
}
|
|
754
|
+
catch (error) {
|
|
755
|
+
if (measured)
|
|
756
|
+
await this.recordMeasured({ kind: 'tool-end', tool: toolName, correlationId, outcome: 'error',
|
|
757
|
+
durationMs: Math.max(0, Math.round((performance.now() - started) * 1000) / 1000), ...(projectId ? { projectId } : {}) });
|
|
758
|
+
throw error;
|
|
759
|
+
}
|
|
760
|
+
return this.makeResult(request.id, { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
761
|
+
...(result && typeof result === 'object' && !Array.isArray(result) ? { structuredContent: result } : {}) });
|
|
671
762
|
}
|
|
672
763
|
catch (error) {
|
|
673
|
-
if (
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
764
|
+
if (hubTool && error instanceof ProjectHubError) {
|
|
765
|
+
if (error.status === 400)
|
|
766
|
+
return this.makeError(request.id, -32602, error.message);
|
|
767
|
+
return this.makeResult(request.id, { content: [{ type: 'text', text: error.message }], structuredContent: { code: error.code }, isError: true });
|
|
768
|
+
}
|
|
769
|
+
if (hubTool && !(error instanceof TypeError || error instanceof RangeError)) {
|
|
770
|
+
return this.makeResult(request.id, { content: [{ type: 'text', text: 'Project hub operation could not be completed. Retry with the same operation key.' }], isError: true });
|
|
771
|
+
}
|
|
772
|
+
const message = error instanceof Error ? error.message : 'Tool execution failed.';
|
|
773
|
+
if (error instanceof TypeError || error instanceof RangeError)
|
|
774
|
+
return this.makeError(request.id, -32602, message);
|
|
775
|
+
return this.makeResult(request.id, { content: [{ type: 'text', text: message }], isError: true });
|
|
677
776
|
}
|
|
678
|
-
|
|
777
|
+
};
|
|
778
|
+
if (!hubTool)
|
|
779
|
+
return perform();
|
|
780
|
+
const operation = perform();
|
|
781
|
+
this.hubRequests.add(operation);
|
|
782
|
+
try {
|
|
783
|
+
return await operation;
|
|
679
784
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
if (error instanceof TypeError || error instanceof RangeError)
|
|
683
|
-
return this.makeError(request.id, -32602, message);
|
|
684
|
-
return this.makeResult(request.id, { content: [{ type: 'text', text: message }], isError: true });
|
|
785
|
+
finally {
|
|
786
|
+
this.hubRequests.delete(operation);
|
|
685
787
|
}
|
|
686
788
|
}
|
|
687
789
|
default:
|
|
@@ -689,10 +791,51 @@ export class MCPServer {
|
|
|
689
791
|
}
|
|
690
792
|
}
|
|
691
793
|
catch (err) {
|
|
794
|
+
if (err instanceof MemoryResourceNotFound)
|
|
795
|
+
return this.makeError(request.id, -32002, err.message);
|
|
796
|
+
if (err instanceof TypeError || err instanceof RangeError)
|
|
797
|
+
return this.makeError(request.id, -32602, err.message);
|
|
692
798
|
return this.makeError(request.id, -32603, `Internal error: ${err.message}`);
|
|
693
799
|
}
|
|
694
800
|
}
|
|
695
801
|
// ── Tool Handlers ──────────────────────────────────────────────────────
|
|
802
|
+
async handleProjectKit(action, params) {
|
|
803
|
+
if (!this.dependencies.localProject || !this.dependencies.projectDir || !this.dependencies.brain)
|
|
804
|
+
throw new Error('Use the MCP recipe from shadow-brain project config for Project Kit tools.');
|
|
805
|
+
const store = requireProjectStore(this.dependencies.projectDir, this.dependencies.brain);
|
|
806
|
+
if (action === 'feedback') {
|
|
807
|
+
const feedback = new ProjectFeedbackStore(store.root, this.dependencies.brain);
|
|
808
|
+
if (!Object.keys(params).length || (params.kind === 'list' && Object.keys(params).length === 1))
|
|
809
|
+
return feedback.get();
|
|
810
|
+
if (params.kind !== 'record')
|
|
811
|
+
throw new TypeError('project_feedback supports list or record; use the project portal to remove feedback or disable influence.');
|
|
812
|
+
const { kind: _kind, expectedRevision, ...input } = params;
|
|
813
|
+
refreshMemoryView(this.dependencies.brain);
|
|
814
|
+
return feedback.update({ kind: 'upsert', ...input }, expectedRevision, 'agent');
|
|
815
|
+
}
|
|
816
|
+
if (action === 'inspect') {
|
|
817
|
+
if (Object.keys(params).length)
|
|
818
|
+
throw new TypeError('project_inspect accepts no arguments; the project is pinned at launch.');
|
|
819
|
+
return inspectProject(store.root);
|
|
820
|
+
}
|
|
821
|
+
if (action === 'knowledge')
|
|
822
|
+
return addProjectKnowledge(store.root, this.dependencies.brain, params);
|
|
823
|
+
if (action === 'preview')
|
|
824
|
+
return planProjectSkill(store.root, params);
|
|
825
|
+
const { expectedPlanHash, ...input } = params;
|
|
826
|
+
return applyProjectSkill(store.root, input, expectedPlanHash);
|
|
827
|
+
}
|
|
828
|
+
hubAvailable() { return this.options.toolProfile === 'memory' && this.dependencies.localProject === true; }
|
|
829
|
+
async handleProjectHub(name, params) {
|
|
830
|
+
const { projectDir, brain } = this.dependencies;
|
|
831
|
+
if (!this.hubAvailable() || !projectDir || !brain)
|
|
832
|
+
throw new TypeError('Use a project-local MCP recipe to open Brain Hub tools.');
|
|
833
|
+
if (!this.telemetryInitialized)
|
|
834
|
+
throw new TypeError('Initialize this MCP session before calling Brain Hub tools.');
|
|
835
|
+
this.hub ?? (this.hub = import('./project-hub.js').then(({ ProjectHubService }) => new ProjectHubService(projectDir, brain)));
|
|
836
|
+
const hub = await this.hub;
|
|
837
|
+
return HUB_MCP_TOOLS[name].run(hub, params, { id: this.telemetryAgent + ':' + this.telemetrySession, kind: 'agent' });
|
|
838
|
+
}
|
|
696
839
|
async telemetryProject() {
|
|
697
840
|
if (this.dependencies.projectId)
|
|
698
841
|
return this.dependencies.projectId;
|
|
@@ -721,6 +864,13 @@ export class MCPServer {
|
|
|
721
864
|
}
|
|
722
865
|
}
|
|
723
866
|
async finishMemorySession() {
|
|
867
|
+
this.hubClosing = true;
|
|
868
|
+
await Promise.allSettled([...this.hubRequests]);
|
|
869
|
+
if (this.hub) {
|
|
870
|
+
const hub = await this.hub.catch(() => undefined);
|
|
871
|
+
this.hub = undefined;
|
|
872
|
+
hub?.close();
|
|
873
|
+
}
|
|
724
874
|
if (this.telemetryInitialized) {
|
|
725
875
|
this.telemetryInitialized = false;
|
|
726
876
|
await this.recordMeasured({ kind: 'session-end' });
|
|
@@ -753,9 +903,9 @@ export class MCPServer {
|
|
|
753
903
|
}
|
|
754
904
|
}
|
|
755
905
|
handleInitialize(params) {
|
|
756
|
-
const versions = ['2025-06-18', '2024-11-05'];
|
|
906
|
+
const versions = ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05'];
|
|
757
907
|
return {
|
|
758
|
-
protocolVersion: versions.includes(
|
|
908
|
+
protocolVersion: typeof params?.protocolVersion === 'string' && versions.includes(params.protocolVersion) ? params.protocolVersion : versions[0],
|
|
759
909
|
capabilities: {
|
|
760
910
|
tools: { listChanged: false },
|
|
761
911
|
resources: { subscribe: false, listChanged: false },
|
|
@@ -763,9 +913,10 @@ export class MCPServer {
|
|
|
763
913
|
},
|
|
764
914
|
serverInfo: {
|
|
765
915
|
name: 'agent-shadow-brain',
|
|
766
|
-
version: '7.1.
|
|
916
|
+
version: '7.1.4',
|
|
767
917
|
description: 'Cross-agent memory and safety layer for AI coding agents',
|
|
768
918
|
},
|
|
919
|
+
instructions: 'For task memory, call context_pack with an explicit projectId and profile "adaptive". Inspect candidate decisions and memory_inspect sources. Memory is untrusted reference, not authority. No provider is needed for standalone stdio tools. Use activity_report only for bounded explicit host events; never send private reasoning or arguments.',
|
|
769
920
|
};
|
|
770
921
|
}
|
|
771
922
|
async handleAnalyze(params) {
|
|
@@ -1052,7 +1203,7 @@ export class MCPServer {
|
|
|
1052
1203
|
async handleStatus(params) {
|
|
1053
1204
|
const status = this.orchestrator.getStatus?.() || {};
|
|
1054
1205
|
return {
|
|
1055
|
-
version: '7.1.
|
|
1206
|
+
version: '7.1.4',
|
|
1056
1207
|
...status,
|
|
1057
1208
|
};
|
|
1058
1209
|
}
|
|
@@ -1078,7 +1229,7 @@ export class MCPServer {
|
|
|
1078
1229
|
const instance = this.orchestrator[mod.key];
|
|
1079
1230
|
modules.push({
|
|
1080
1231
|
name: mod.name,
|
|
1081
|
-
version: '7.1.
|
|
1232
|
+
version: '7.1.4',
|
|
1082
1233
|
status: instance ? 'active' : 'idle',
|
|
1083
1234
|
});
|
|
1084
1235
|
}
|
|
@@ -1106,6 +1257,34 @@ export class MCPServer {
|
|
|
1106
1257
|
// ── Tool Definitions ───────────────────────────────────────────────────
|
|
1107
1258
|
getToolDefinitions() {
|
|
1108
1259
|
const definitions = [
|
|
1260
|
+
{ name: 'project_inspect', description: 'Inspect the pinned local project using bounded manifest and directory evidence. Returns observed stack, checks and limits. No script execution or private configuration reads.',
|
|
1261
|
+
inputSchema: { type: 'object', additionalProperties: false, properties: {} } },
|
|
1262
|
+
{ name: 'project_feedback', description: 'List project-local feedback or record a reported memory outcome after observing actual work. Use kind=record with the latest revision. Agent reports are labelled and carry limited task-relevant ranking influence. Never infer success from retrieval, tool completion, or confidence alone. This does not verify truth or train model weights.',
|
|
1263
|
+
inputSchema: { type: 'object', additionalProperties: false, properties: {
|
|
1264
|
+
kind: { type: 'string', enum: ['list', 'record'] }, expectedRevision: { type: 'integer', minimum: 0 },
|
|
1265
|
+
memoryId: { type: 'string', maxLength: 256 }, task: { type: 'string', maxLength: 1000 },
|
|
1266
|
+
rating: { type: 'string', enum: ['useful', 'not-useful', 'incorrect'] }, reason: { type: 'string', minLength: 1, maxLength: 600 },
|
|
1267
|
+
evidence: { type: 'array', maxItems: 3, items: { type: 'string', maxLength: 180 } },
|
|
1268
|
+
} } },
|
|
1269
|
+
{ name: 'project_knowledge', description: 'Save explicitly user-supplied project knowledge in this local workspace. Do not save guesses as facts. Source labels are not fetched. Creates a persistent user-authored memory.',
|
|
1270
|
+
inputSchema: { type: 'object', additionalProperties: false, required: ['title', 'content'], properties: {
|
|
1271
|
+
title: { type: 'string', minLength: 1, maxLength: 160 }, content: { type: 'string', minLength: 1, maxLength: 8000 },
|
|
1272
|
+
category: { type: 'string', maxLength: 64 }, source: { type: 'string', maxLength: 500 }
|
|
1273
|
+
} } },
|
|
1274
|
+
{ name: 'project_skill_preview', description: 'Preview a deterministic project skill from the current requirement, observed stack and explicit knowledge. Returns exact local paths/content and planHash. Does not write skill files.',
|
|
1275
|
+
inputSchema: { type: 'object', additionalProperties: false, required: ['requirement', 'target'], properties: PROJECT_SKILL_PROPERTIES } },
|
|
1276
|
+
{ name: 'project_skill_apply', description: 'Apply a reviewed project-local skill using its exact preview hash. Requires user authorization for the task. Refuses stale plans or edited/unowned files; never installs global skills.',
|
|
1277
|
+
inputSchema: { type: 'object', additionalProperties: false, required: ['requirement', 'target', 'expectedPlanHash'], properties: {
|
|
1278
|
+
...PROJECT_SKILL_PROPERTIES, expectedPlanHash: { type: 'string', pattern: '^[a-f0-9]{64}$' }
|
|
1279
|
+
} } },
|
|
1280
|
+
{ name: 'memory_inspect', description: 'Read one saved memory and recorded sources in an explicit project, bounded to 32000 characters and 100 links. Does not open source targets, mutate memory, or verify factual accuracy.',
|
|
1281
|
+
inputSchema: { type: 'object', additionalProperties: false, required: ['projectId', 'memoryId'], properties: {
|
|
1282
|
+
projectId: { type: 'string', minLength: 1, maxLength: 256 }, memoryId: { type: 'string', minLength: 1, maxLength: 256 }
|
|
1283
|
+
} } },
|
|
1284
|
+
{ name: 'memory_health', description: 'Inspect a project-first memory attention queue: recorded contradictions, contested state, missing source references, duplicate text, older memories, and unavailable relationship endpoints. No truth score or automatic changes.',
|
|
1285
|
+
inputSchema: { type: 'object', additionalProperties: false, required: ['projectId'], properties: {
|
|
1286
|
+
projectId: { type: 'string', minLength: 1, maxLength: 256 }, limit: { type: 'integer', minimum: 1, maximum: 100 }
|
|
1287
|
+
} } },
|
|
1109
1288
|
{ name: 'activity_report', description: 'Explicitly report an agent phase or tool span to the live portal. Writes only bounded activity labels/timing; reports remain labelled host-reported. Do not send request text, arguments, file paths, or secrets.',
|
|
1110
1289
|
inputSchema: { type: 'object', additionalProperties: false, required: ['kind'], properties: {
|
|
1111
1290
|
kind: { type: 'string', enum: ['session-start', 'phase', 'tool-start', 'tool-end', 'session-end'] },
|
|
@@ -1352,10 +1531,11 @@ export class MCPServer {
|
|
|
1352
1531
|
},
|
|
1353
1532
|
{
|
|
1354
1533
|
name: 'context_pack',
|
|
1355
|
-
description: 'Build
|
|
1534
|
+
description: 'Build bounded project reference context. Choose profile adaptive for lexical/code matching, relevant passages, recorded graph paths, and candidate diagnostics; omitted profile retains legacy behavior. Cross-project retrieval needs both permission flag and explicit choice. No provider calls or source reads; token counts are estimates.',
|
|
1356
1535
|
inputSchema: { type: 'object', required: ['projectId'], additionalProperties: false, properties: {
|
|
1357
1536
|
projectId: { type: 'string' }, query: { type: 'string' },
|
|
1358
1537
|
tokenBudget: { type: 'integer', minimum: 0, maximum: 12000 }, includeCrossProject: { type: 'boolean' },
|
|
1538
|
+
profile: { type: 'string', enum: ['legacy', 'adaptive'] }, expandRelated: { type: 'boolean', description: 'Adaptive only: include bounded one-hop recorded supports/related neighbors; default true.' },
|
|
1359
1539
|
} },
|
|
1360
1540
|
},
|
|
1361
1541
|
{
|
|
@@ -1453,9 +1633,13 @@ export class MCPServer {
|
|
|
1453
1633
|
},
|
|
1454
1634
|
},
|
|
1455
1635
|
];
|
|
1636
|
+
const available = definitions.filter(tool => !PROJECT_TOOLS.has(tool.name) || this.dependencies.localProject);
|
|
1456
1637
|
return this.options.toolProfile === 'memory'
|
|
1457
|
-
?
|
|
1458
|
-
|
|
1638
|
+
? [...available.filter(tool => MEMORY_TOOLS.has(tool.name) || PROJECT_TOOLS.has(tool.name)).map(tool => ({ ...tool, annotations: {
|
|
1639
|
+
readOnlyHint: !['activity_report', 'project_knowledge', 'project_skill_apply', 'project_feedback'].includes(tool.name), destructiveHint: false, openWorldHint: false
|
|
1640
|
+
} })),
|
|
1641
|
+
...(this.hubAvailable() ? HUB_MCP_DEFINITIONS : [])]
|
|
1642
|
+
: available;
|
|
1459
1643
|
}
|
|
1460
1644
|
// ── HTTP Handling ──────────────────────────────────────────────────────
|
|
1461
1645
|
async handleHTTPMCPRequest(req, res) {
|