coaiajs 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +56 -0
- package/KINSHIP.md +63 -0
- package/README.md +148 -0
- package/articles/academic/creative-orientation-vs-problem-solving.md +177 -0
- package/articles/academic/jsonl-knowledge-graphs-agent-memory.md +142 -0
- package/articles/academic/langfuse-observability-llm-pipelines.md +144 -0
- package/articles/academic/medicine-wheel-software-architecture.md +163 -0
- package/articles/academic/mmot-autonomous-agents.md +156 -0
- package/articles/academic/model-context-protocol-interagent.md +161 -0
- package/articles/academic/pde-prompt-decomposition.md +186 -0
- package/articles/academic/structural-tension-in-ai-agents.md +134 -0
- package/articles/reviews/mcp-protocol-design-review.md +170 -0
- package/articles/reviews/observability-ai-systems-review.md +176 -0
- package/articles/reviews/prompt-engineering-decomposition-review.md +184 -0
- package/articles/surveys/agent-orchestration-survey.md +186 -0
- package/articles/surveys/knowledge-graph-storage-survey.md +204 -0
- package/articles/surveys/structural-tension-methodology-survey.md +154 -0
- package/articles/technical/aws-sdk-v3-polly.md +270 -0
- package/articles/technical/commander-cli-framework.md +262 -0
- package/articles/technical/dotenv-config-patterns.md +360 -0
- package/articles/technical/ioredis-vs-redis.md +142 -0
- package/articles/technical/langfuse-js-sdk-vs-rest.md +191 -0
- package/articles/technical/mcp-sdk-typescript.md +291 -0
- package/articles/technical/octokit-github-api.md +293 -0
- package/articles/technical/openai-sdk-modern.md +231 -0
- package/articles/technical/yaml-parsing-node.md +266 -0
- package/articles/technical/zod-runtime-validation.md +212 -0
- package/dist/mcp/config.d.ts +14 -0
- package/dist/mcp/config.js +185 -0
- package/dist/mcp/server.d.ts +3 -0
- package/dist/mcp/server.js +324 -0
- package/dist/mcp/tools/coaiapy-tools.d.ts +8 -0
- package/dist/mcp/tools/coaiapy-tools.js +326 -0
- package/dist/mcp/tools/index.d.ts +3 -0
- package/dist/mcp/tools/index.js +3 -0
- package/dist/src/audio.d.ts +12 -0
- package/dist/src/audio.js +57 -0
- package/dist/src/cli-helpers.d.ts +9 -0
- package/dist/src/cli-helpers.js +78 -0
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.js +1086 -0
- package/dist/src/config.d.ts +15 -0
- package/dist/src/config.js +145 -0
- package/dist/src/environment.d.ts +44 -0
- package/dist/src/environment.js +146 -0
- package/dist/src/github.d.ts +47 -0
- package/dist/src/github.js +79 -0
- package/dist/src/langfuse/client.d.ts +30 -0
- package/dist/src/langfuse/client.js +75 -0
- package/dist/src/langfuse/comments.d.ts +16 -0
- package/dist/src/langfuse/comments.js +36 -0
- package/dist/src/langfuse/datasets.d.ts +19 -0
- package/dist/src/langfuse/datasets.js +140 -0
- package/dist/src/langfuse/index.d.ts +13 -0
- package/dist/src/langfuse/index.js +10 -0
- package/dist/src/langfuse/media.d.ts +11 -0
- package/dist/src/langfuse/media.js +167 -0
- package/dist/src/langfuse/observations.d.ts +18 -0
- package/dist/src/langfuse/observations.js +113 -0
- package/dist/src/langfuse/prompts.d.ts +14 -0
- package/dist/src/langfuse/prompts.js +127 -0
- package/dist/src/langfuse/scores.d.ts +54 -0
- package/dist/src/langfuse/scores.js +366 -0
- package/dist/src/langfuse/traces.d.ts +29 -0
- package/dist/src/langfuse/traces.js +225 -0
- package/dist/src/llm.d.ts +23 -0
- package/dist/src/llm.js +76 -0
- package/dist/src/narrative/graph-manager.d.ts +106 -0
- package/dist/src/narrative/graph-manager.js +915 -0
- package/dist/src/narrative/index.d.ts +9 -0
- package/dist/src/narrative/index.js +7 -0
- package/dist/src/narrative/markdown-export.d.ts +21 -0
- package/dist/src/narrative/markdown-export.js +383 -0
- package/dist/src/narrative/tool-definitions.d.ts +21 -0
- package/dist/src/narrative/tool-definitions.js +588 -0
- package/dist/src/narrative/tool-handlers.d.ts +11 -0
- package/dist/src/narrative/tool-handlers.js +462 -0
- package/dist/src/narrative/types.d.ts +2 -0
- package/dist/src/narrative/types.js +2 -0
- package/dist/src/narrative/validation.d.ts +29 -0
- package/dist/src/narrative/validation.js +144 -0
- package/dist/src/pde/index.d.ts +8 -0
- package/dist/src/pde/index.js +8 -0
- package/dist/src/pde/mcp-handlers.d.ts +7 -0
- package/dist/src/pde/mcp-handlers.js +300 -0
- package/dist/src/pde/mcp-tools.d.ts +15 -0
- package/dist/src/pde/mcp-tools.js +191 -0
- package/dist/src/pde/session-manager.d.ts +32 -0
- package/dist/src/pde/session-manager.js +205 -0
- package/dist/src/pde/stc-mapper.d.ts +26 -0
- package/dist/src/pde/stc-mapper.js +234 -0
- package/dist/src/pipeline/index.d.ts +2 -0
- package/dist/src/pipeline/index.js +3 -0
- package/dist/src/pipeline/template-engine.d.ts +20 -0
- package/dist/src/pipeline/template-engine.js +361 -0
- package/dist/src/planning/index.d.ts +7 -0
- package/dist/src/planning/index.js +7 -0
- package/dist/src/planning/mcp-handlers.d.ts +7 -0
- package/dist/src/planning/mcp-handlers.js +310 -0
- package/dist/src/planning/mcp-tools.d.ts +15 -0
- package/dist/src/planning/mcp-tools.js +145 -0
- package/dist/src/planning/plan-parser.d.ts +35 -0
- package/dist/src/planning/plan-parser.js +506 -0
- package/dist/src/redis.d.ts +21 -0
- package/dist/src/redis.js +78 -0
- package/dist/src/types.d.ts +244 -0
- package/dist/src/types.js +8 -0
- package/mcp/config.ts +196 -0
- package/mcp/server.ts +402 -0
- package/mcp/tools/coaiapy-tools.ts +364 -0
- package/mcp/tools/index.ts +4 -0
- package/package.json +52 -0
- package/rispecs/00-coaiajs-platform.spec.md +102 -0
- package/rispecs/01-core-config.spec.md +89 -0
- package/rispecs/02-redis-module.spec.md +62 -0
- package/rispecs/03-langfuse-module.spec.md +101 -0
- package/rispecs/04-narrative-engine.spec.md +185 -0
- package/rispecs/05-pde-engine.spec.md +112 -0
- package/rispecs/06-planning-engine.spec.md +128 -0
- package/rispecs/07-pipeline-templates.spec.md +97 -0
- package/rispecs/08-cli-interface.spec.md +134 -0
- package/rispecs/09-mcp-server.spec.md +140 -0
- package/rispecs/10-audio-module.spec.md +63 -0
- package/rispecs/KINSHIP.md +56 -0
- package/rispecs/README.md +100 -0
- package/src/audio.ts +76 -0
- package/src/cli-helpers.ts +86 -0
- package/src/cli.ts +1223 -0
- package/src/config.ts +172 -0
- package/src/environment.ts +171 -0
- package/src/github.ts +143 -0
- package/src/langfuse/client.ts +105 -0
- package/src/langfuse/comments.ts +52 -0
- package/src/langfuse/datasets.ts +178 -0
- package/src/langfuse/index.ts +33 -0
- package/src/langfuse/media.ts +193 -0
- package/src/langfuse/observations.ts +131 -0
- package/src/langfuse/prompts.ts +157 -0
- package/src/langfuse/scores.ts +456 -0
- package/src/langfuse/traces.ts +276 -0
- package/src/llm.ts +106 -0
- package/src/narrative/graph-manager.ts +1358 -0
- package/src/narrative/index.ts +32 -0
- package/src/narrative/markdown-export.ts +535 -0
- package/src/narrative/tool-definitions.ts +635 -0
- package/src/narrative/tool-handlers.ts +528 -0
- package/src/narrative/types.ts +9 -0
- package/src/narrative/validation.ts +179 -0
- package/src/pde/index.ts +8 -0
- package/src/pde/mcp-handlers.ts +359 -0
- package/src/pde/mcp-tools.ts +201 -0
- package/src/pde/session-manager.ts +248 -0
- package/src/pde/stc-mapper.ts +298 -0
- package/src/pipeline/index.ts +7 -0
- package/src/pipeline/template-engine.ts +398 -0
- package/src/planning/index.ts +13 -0
- package/src/planning/mcp-handlers.ts +369 -0
- package/src/planning/mcp-tools.ts +155 -0
- package/src/planning/plan-parser.ts +587 -0
- package/src/redis.ts +97 -0
- package/src/types.ts +280 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type FeatureLevel = 'MINIMAL' | 'STANDARD' | 'OBSERVABILITY' | 'FULL';
|
|
2
|
+
export declare class FeatureConfig {
|
|
3
|
+
private level;
|
|
4
|
+
private enabledTools;
|
|
5
|
+
constructor(level?: FeatureLevel);
|
|
6
|
+
isToolEnabled(toolName: string): boolean;
|
|
7
|
+
getEnabledTools(): Set<string>;
|
|
8
|
+
getFeatureLevel(): FeatureLevel;
|
|
9
|
+
getStats(): {
|
|
10
|
+
tools: number;
|
|
11
|
+
level: FeatureLevel;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// coaiajs/mcp/config.ts — Feature gating
|
|
2
|
+
// Port of coaiapy-mcp/config.py
|
|
3
|
+
// All available tool names across all modules
|
|
4
|
+
const ALL_TOOLS = new Set([
|
|
5
|
+
// Redis (coaiapy-mcp)
|
|
6
|
+
'coaia_tash',
|
|
7
|
+
'coaia_fetch',
|
|
8
|
+
// Langfuse traces (coaiapy-mcp)
|
|
9
|
+
'coaia_fuse_trace_create',
|
|
10
|
+
'coaia_fuse_add_observation',
|
|
11
|
+
'coaia_fuse_trace_patch_output',
|
|
12
|
+
'coaia_fuse_trace_get',
|
|
13
|
+
'coaia_fuse_trace_view',
|
|
14
|
+
'coaia_fuse_observation_get',
|
|
15
|
+
'coaia_fuse_traces_list',
|
|
16
|
+
'coaia_fuse_traces_session_view',
|
|
17
|
+
// Langfuse comments (coaiapy-mcp)
|
|
18
|
+
'coaia_fuse_comments_list',
|
|
19
|
+
'coaia_fuse_comments_get',
|
|
20
|
+
'coaia_fuse_comments_create',
|
|
21
|
+
// Langfuse prompts (coaiapy-mcp)
|
|
22
|
+
'coaia_fuse_prompts_list',
|
|
23
|
+
'coaia_fuse_prompts_get',
|
|
24
|
+
// Langfuse datasets (coaiapy-mcp)
|
|
25
|
+
'coaia_fuse_datasets_list',
|
|
26
|
+
'coaia_fuse_datasets_get',
|
|
27
|
+
// Score configs (coaiapy-mcp)
|
|
28
|
+
'coaia_fuse_score_configs_list',
|
|
29
|
+
'coaia_fuse_score_configs_get',
|
|
30
|
+
'coaia_fuse_score_apply',
|
|
31
|
+
// Media (coaiapy-mcp, FULL only)
|
|
32
|
+
'coaia_fuse_media_upload',
|
|
33
|
+
'coaia_fuse_media_get',
|
|
34
|
+
// Narrative (coaia-narrative, 28 tools)
|
|
35
|
+
'create_structural_tension_chart',
|
|
36
|
+
'telescope_action_step',
|
|
37
|
+
'mark_action_complete',
|
|
38
|
+
'get_chart_progress',
|
|
39
|
+
'list_active_charts',
|
|
40
|
+
'get_chart',
|
|
41
|
+
'get_action_step',
|
|
42
|
+
'update_action_progress',
|
|
43
|
+
'update_current_reality',
|
|
44
|
+
'manage_action_step',
|
|
45
|
+
'add_action_step',
|
|
46
|
+
'remove_action_step',
|
|
47
|
+
'update_desired_outcome',
|
|
48
|
+
'perform_mmot_evaluation',
|
|
49
|
+
'init_llm_guidance',
|
|
50
|
+
'create_narrative_beat',
|
|
51
|
+
'telescope_narrative_beat',
|
|
52
|
+
'list_narrative_beats',
|
|
53
|
+
'add_observations',
|
|
54
|
+
'create_entities',
|
|
55
|
+
'create_relations',
|
|
56
|
+
'search_nodes',
|
|
57
|
+
'open_nodes',
|
|
58
|
+
'read_graph',
|
|
59
|
+
'delete_entities',
|
|
60
|
+
'delete_relations',
|
|
61
|
+
'delete_observations',
|
|
62
|
+
'merge_entities',
|
|
63
|
+
// PDE (coaia-pde, 10 tools)
|
|
64
|
+
'pde_decompose',
|
|
65
|
+
'pde_parse_response',
|
|
66
|
+
'pde_get',
|
|
67
|
+
'pde_list',
|
|
68
|
+
'pde_export_markdown',
|
|
69
|
+
'import_pde',
|
|
70
|
+
'create_stc_from_pde',
|
|
71
|
+
'pde_sessions_list',
|
|
72
|
+
'pde_sessions_create',
|
|
73
|
+
'pde_sessions_update',
|
|
74
|
+
// Planning (coaia-planning, 6 tools)
|
|
75
|
+
'parse_plan',
|
|
76
|
+
'plan_to_stc',
|
|
77
|
+
'sync_plans',
|
|
78
|
+
'trace_plan',
|
|
79
|
+
'pde_to_plan',
|
|
80
|
+
'list_plans',
|
|
81
|
+
]);
|
|
82
|
+
const MINIMAL_TOOLS = new Set([
|
|
83
|
+
'coaia_tash',
|
|
84
|
+
'coaia_fetch',
|
|
85
|
+
'coaia_fuse_trace_create',
|
|
86
|
+
'coaia_fuse_add_observation',
|
|
87
|
+
'coaia_fuse_trace_patch_output',
|
|
88
|
+
'coaia_fuse_trace_get',
|
|
89
|
+
'coaia_fuse_trace_view',
|
|
90
|
+
'coaia_fuse_observation_get',
|
|
91
|
+
'coaia_fuse_traces_list',
|
|
92
|
+
'coaia_fuse_traces_session_view',
|
|
93
|
+
'coaia_fuse_comments_list',
|
|
94
|
+
'coaia_fuse_comments_get',
|
|
95
|
+
'coaia_fuse_comments_create',
|
|
96
|
+
'coaia_fuse_prompts_list',
|
|
97
|
+
'coaia_fuse_prompts_get',
|
|
98
|
+
'coaia_fuse_datasets_list',
|
|
99
|
+
'coaia_fuse_datasets_get',
|
|
100
|
+
'coaia_fuse_score_configs_list',
|
|
101
|
+
'coaia_fuse_score_configs_get',
|
|
102
|
+
'coaia_fuse_score_apply',
|
|
103
|
+
]);
|
|
104
|
+
const STANDARD_TOOLS = new Set([
|
|
105
|
+
...MINIMAL_TOOLS,
|
|
106
|
+
// Narrative STC tools
|
|
107
|
+
'create_structural_tension_chart',
|
|
108
|
+
'telescope_action_step',
|
|
109
|
+
'mark_action_complete',
|
|
110
|
+
'get_chart_progress',
|
|
111
|
+
'list_active_charts',
|
|
112
|
+
'get_chart',
|
|
113
|
+
'get_action_step',
|
|
114
|
+
'update_action_progress',
|
|
115
|
+
'update_current_reality',
|
|
116
|
+
'manage_action_step',
|
|
117
|
+
'add_action_step',
|
|
118
|
+
'remove_action_step',
|
|
119
|
+
'update_desired_outcome',
|
|
120
|
+
'perform_mmot_evaluation',
|
|
121
|
+
'init_llm_guidance',
|
|
122
|
+
'create_narrative_beat',
|
|
123
|
+
'telescope_narrative_beat',
|
|
124
|
+
'list_narrative_beats',
|
|
125
|
+
// KG tools
|
|
126
|
+
'add_observations',
|
|
127
|
+
'create_entities',
|
|
128
|
+
'create_relations',
|
|
129
|
+
'search_nodes',
|
|
130
|
+
'open_nodes',
|
|
131
|
+
'read_graph',
|
|
132
|
+
'delete_entities',
|
|
133
|
+
'delete_relations',
|
|
134
|
+
'delete_observations',
|
|
135
|
+
'merge_entities',
|
|
136
|
+
// PDE tools
|
|
137
|
+
'pde_decompose',
|
|
138
|
+
'pde_parse_response',
|
|
139
|
+
'pde_get',
|
|
140
|
+
'pde_list',
|
|
141
|
+
'pde_export_markdown',
|
|
142
|
+
'import_pde',
|
|
143
|
+
'create_stc_from_pde',
|
|
144
|
+
'pde_sessions_list',
|
|
145
|
+
'pde_sessions_create',
|
|
146
|
+
'pde_sessions_update',
|
|
147
|
+
// Planning tools
|
|
148
|
+
'parse_plan',
|
|
149
|
+
'plan_to_stc',
|
|
150
|
+
'sync_plans',
|
|
151
|
+
'trace_plan',
|
|
152
|
+
'pde_to_plan',
|
|
153
|
+
'list_plans',
|
|
154
|
+
]);
|
|
155
|
+
const FEATURE_SETS = {
|
|
156
|
+
MINIMAL: MINIMAL_TOOLS,
|
|
157
|
+
STANDARD: STANDARD_TOOLS,
|
|
158
|
+
OBSERVABILITY: STANDARD_TOOLS,
|
|
159
|
+
FULL: ALL_TOOLS,
|
|
160
|
+
};
|
|
161
|
+
export class FeatureConfig {
|
|
162
|
+
level;
|
|
163
|
+
enabledTools;
|
|
164
|
+
constructor(level) {
|
|
165
|
+
const envLevel = (level ?? process.env['COAIAJS_FEATURES'] ?? 'STANDARD').toUpperCase();
|
|
166
|
+
this.level = envLevel in FEATURE_SETS ? envLevel : 'STANDARD';
|
|
167
|
+
this.enabledTools = FEATURE_SETS[this.level];
|
|
168
|
+
}
|
|
169
|
+
isToolEnabled(toolName) {
|
|
170
|
+
return this.enabledTools.has(toolName);
|
|
171
|
+
}
|
|
172
|
+
getEnabledTools() {
|
|
173
|
+
return new Set(this.enabledTools);
|
|
174
|
+
}
|
|
175
|
+
getFeatureLevel() {
|
|
176
|
+
return this.level;
|
|
177
|
+
}
|
|
178
|
+
getStats() {
|
|
179
|
+
return {
|
|
180
|
+
tools: this.enabledTools.size,
|
|
181
|
+
level: this.level,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// coaiajs/mcp/server.ts — Unified MCP server
|
|
3
|
+
// Consolidates all tools: coaiapy-mcp (20) + narrative (28) + PDE (10) + planning (6) = 64+ tools
|
|
4
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
5
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
import { FeatureConfig } from './config.js';
|
|
8
|
+
import { getCoaiapyToolDefinitions } from './tools/index.js';
|
|
9
|
+
// Langfuse imports
|
|
10
|
+
import { addTrace, patchTraceOutput, listTraces, getTrace, formatTracesTable, formatTraceTree, } from '../src/langfuse/traces.js';
|
|
11
|
+
import { addObservation, getObservation, formatObservationDisplay } from '../src/langfuse/observations.js';
|
|
12
|
+
import { listPrompts, getPrompt, formatPromptsTable, formatPromptDisplay } from '../src/langfuse/prompts.js';
|
|
13
|
+
import { listDatasets, getDataset, formatDatasetsTable } from '../src/langfuse/datasets.js';
|
|
14
|
+
import { listScoreConfigs, getScoreConfig, applyScoreConfig, formatScoreConfigsTable, } from '../src/langfuse/scores.js';
|
|
15
|
+
import { listComments, getComment, createComment } from '../src/langfuse/comments.js';
|
|
16
|
+
import { uploadAndAttachMedia, getMedia, formatMediaDisplay } from '../src/langfuse/media.js';
|
|
17
|
+
// ─── Server Info ────────────────────────────────────────────────────
|
|
18
|
+
const SERVER_NAME = 'coaiajs-mcp';
|
|
19
|
+
const SERVER_VERSION = '0.1.0';
|
|
20
|
+
// ─── Parse CLI args ─────────────────────────────────────────────────
|
|
21
|
+
function parseArgs() {
|
|
22
|
+
const args = process.argv.slice(2);
|
|
23
|
+
const result = {};
|
|
24
|
+
for (let i = 0; i < args.length; i++) {
|
|
25
|
+
if (args[i] === '--memory-path' && args[i + 1]) {
|
|
26
|
+
result.memoryPath = args[++i];
|
|
27
|
+
}
|
|
28
|
+
else if (args[i] === '--plans-dir' && args[i + 1]) {
|
|
29
|
+
result.plansDir = args[++i];
|
|
30
|
+
}
|
|
31
|
+
else if (args[i] === '--features' && args[i + 1]) {
|
|
32
|
+
result.featureLevel = args[++i];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
function textResult(text, isError = false) {
|
|
38
|
+
return { content: [{ type: 'text', text }], isError };
|
|
39
|
+
}
|
|
40
|
+
async function handleCoaiapyTool(name, args) {
|
|
41
|
+
try {
|
|
42
|
+
switch (name) {
|
|
43
|
+
// ── Redis ──
|
|
44
|
+
case 'coaia_tash': {
|
|
45
|
+
// Redis stash — defer to redis module if available, placeholder for now
|
|
46
|
+
return textResult(JSON.stringify({
|
|
47
|
+
success: false,
|
|
48
|
+
error: 'Redis module not yet wired. Use coaiapy-mcp for Redis operations.',
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
case 'coaia_fetch': {
|
|
52
|
+
return textResult(JSON.stringify({
|
|
53
|
+
success: false,
|
|
54
|
+
error: 'Redis module not yet wired. Use coaiapy-mcp for Redis operations.',
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
// ── Traces ──
|
|
58
|
+
case 'coaia_fuse_trace_create': {
|
|
59
|
+
const result = await addTrace({
|
|
60
|
+
traceId: args.trace_id,
|
|
61
|
+
userId: args.user_id,
|
|
62
|
+
sessionId: args.session_id,
|
|
63
|
+
name: args.name,
|
|
64
|
+
metadata: args.metadata,
|
|
65
|
+
inputData: args.input_data,
|
|
66
|
+
outputData: args.output_data,
|
|
67
|
+
});
|
|
68
|
+
return textResult(result);
|
|
69
|
+
}
|
|
70
|
+
case 'coaia_fuse_add_observation': {
|
|
71
|
+
const result = await addObservation({
|
|
72
|
+
observationId: args.observation_id,
|
|
73
|
+
traceId: args.trace_id,
|
|
74
|
+
name: args.name,
|
|
75
|
+
type: args.observation_type,
|
|
76
|
+
parentId: args.parent_id,
|
|
77
|
+
metadata: args.metadata,
|
|
78
|
+
inputData: args.input_data,
|
|
79
|
+
outputData: args.output_data,
|
|
80
|
+
startTime: args.start_time,
|
|
81
|
+
endTime: args.end_time,
|
|
82
|
+
});
|
|
83
|
+
return textResult(result);
|
|
84
|
+
}
|
|
85
|
+
case 'coaia_fuse_trace_patch_output': {
|
|
86
|
+
const result = await patchTraceOutput(args.trace_id, args.output_data);
|
|
87
|
+
return textResult(result);
|
|
88
|
+
}
|
|
89
|
+
case 'coaia_fuse_trace_get':
|
|
90
|
+
case 'coaia_fuse_trace_view': {
|
|
91
|
+
const traceJson = await getTrace(args.trace_id);
|
|
92
|
+
if (args.json_output) {
|
|
93
|
+
return textResult(traceJson);
|
|
94
|
+
}
|
|
95
|
+
const formatted = formatTraceTree(traceJson);
|
|
96
|
+
return textResult(formatted);
|
|
97
|
+
}
|
|
98
|
+
case 'coaia_fuse_observation_get': {
|
|
99
|
+
const obsJson = await getObservation(args.observation_id);
|
|
100
|
+
if (args.json_output) {
|
|
101
|
+
return textResult(obsJson);
|
|
102
|
+
}
|
|
103
|
+
return textResult(formatObservationDisplay(obsJson));
|
|
104
|
+
}
|
|
105
|
+
case 'coaia_fuse_traces_list': {
|
|
106
|
+
const result = await listTraces({
|
|
107
|
+
sessionId: args.session_id,
|
|
108
|
+
userId: args.user_id,
|
|
109
|
+
name: args.name,
|
|
110
|
+
tags: args.tags,
|
|
111
|
+
fromTimestamp: args.from_timestamp,
|
|
112
|
+
toTimestamp: args.to_timestamp,
|
|
113
|
+
orderBy: args.order_by,
|
|
114
|
+
page: args.page,
|
|
115
|
+
limit: args.limit,
|
|
116
|
+
});
|
|
117
|
+
return textResult(formatTracesTable(result));
|
|
118
|
+
}
|
|
119
|
+
case 'coaia_fuse_traces_session_view': {
|
|
120
|
+
const result = await listTraces({
|
|
121
|
+
sessionId: args.session_id,
|
|
122
|
+
});
|
|
123
|
+
if (args.json_output)
|
|
124
|
+
return textResult(result);
|
|
125
|
+
return textResult(formatTracesTable(result));
|
|
126
|
+
}
|
|
127
|
+
// ── Prompts ──
|
|
128
|
+
case 'coaia_fuse_prompts_list': {
|
|
129
|
+
const result = await listPrompts();
|
|
130
|
+
return textResult(formatPromptsTable(result));
|
|
131
|
+
}
|
|
132
|
+
case 'coaia_fuse_prompts_get': {
|
|
133
|
+
const result = await getPrompt(args.name, args.label);
|
|
134
|
+
return textResult(formatPromptDisplay(result));
|
|
135
|
+
}
|
|
136
|
+
// ── Datasets ──
|
|
137
|
+
case 'coaia_fuse_datasets_list': {
|
|
138
|
+
const result = await listDatasets();
|
|
139
|
+
return textResult(formatDatasetsTable(result));
|
|
140
|
+
}
|
|
141
|
+
case 'coaia_fuse_datasets_get': {
|
|
142
|
+
const result = await getDataset(args.name);
|
|
143
|
+
return textResult(result);
|
|
144
|
+
}
|
|
145
|
+
// ── Score Configs ──
|
|
146
|
+
case 'coaia_fuse_score_configs_list': {
|
|
147
|
+
const result = await listScoreConfigs();
|
|
148
|
+
return textResult(formatScoreConfigsTable(result));
|
|
149
|
+
}
|
|
150
|
+
case 'coaia_fuse_score_configs_get': {
|
|
151
|
+
const result = await getScoreConfig(args.name_or_id);
|
|
152
|
+
return textResult(result);
|
|
153
|
+
}
|
|
154
|
+
case 'coaia_fuse_score_apply': {
|
|
155
|
+
const result = await applyScoreConfig(args.config_name_or_id, args.target_type, args.target_id, args.value, args.observation_id, args.comment);
|
|
156
|
+
return textResult(result);
|
|
157
|
+
}
|
|
158
|
+
// ── Comments ──
|
|
159
|
+
case 'coaia_fuse_comments_list': {
|
|
160
|
+
const result = await listComments({
|
|
161
|
+
objectType: args.object_type,
|
|
162
|
+
objectId: args.object_id,
|
|
163
|
+
authorUserId: args.author_user_id,
|
|
164
|
+
page: args.page,
|
|
165
|
+
limit: args.limit,
|
|
166
|
+
});
|
|
167
|
+
return textResult(result);
|
|
168
|
+
}
|
|
169
|
+
case 'coaia_fuse_comments_get': {
|
|
170
|
+
const result = await getComment(args.comment_id);
|
|
171
|
+
return textResult(result);
|
|
172
|
+
}
|
|
173
|
+
case 'coaia_fuse_comments_create': {
|
|
174
|
+
const result = await createComment({
|
|
175
|
+
text: args.text,
|
|
176
|
+
objectType: args.object_type,
|
|
177
|
+
objectId: args.object_id,
|
|
178
|
+
authorUserId: args.author_user_id,
|
|
179
|
+
});
|
|
180
|
+
return textResult(result);
|
|
181
|
+
}
|
|
182
|
+
// ── Media ──
|
|
183
|
+
case 'coaia_fuse_media_upload': {
|
|
184
|
+
const result = await uploadAndAttachMedia({
|
|
185
|
+
filePath: args.file_path,
|
|
186
|
+
traceId: args.trace_id,
|
|
187
|
+
field: args.field,
|
|
188
|
+
observationId: args.observation_id,
|
|
189
|
+
contentType: args.content_type,
|
|
190
|
+
});
|
|
191
|
+
return textResult(result);
|
|
192
|
+
}
|
|
193
|
+
case 'coaia_fuse_media_get': {
|
|
194
|
+
const result = await getMedia(args.media_id);
|
|
195
|
+
return textResult(formatMediaDisplay(result));
|
|
196
|
+
}
|
|
197
|
+
default:
|
|
198
|
+
return textResult(`Unknown tool: ${name}`, true);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
203
|
+
return textResult(JSON.stringify({ error: msg }), true);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// ─── Narrative/PDE/Planning tool stubs ──────────────────────────────
|
|
207
|
+
// These modules will be wired by other direction agents (SOUTH/EAST/WEST).
|
|
208
|
+
// For now we register placeholder definitions so the server schema is complete.
|
|
209
|
+
function getNarrativeToolDefinitions(featureConfig) {
|
|
210
|
+
const narrativeToolNames = [
|
|
211
|
+
'create_structural_tension_chart', 'telescope_action_step', 'mark_action_complete',
|
|
212
|
+
'get_chart_progress', 'list_active_charts', 'get_chart', 'get_action_step',
|
|
213
|
+
'update_action_progress', 'update_current_reality', 'manage_action_step',
|
|
214
|
+
'add_action_step', 'remove_action_step', 'update_desired_outcome',
|
|
215
|
+
'perform_mmot_evaluation', 'init_llm_guidance',
|
|
216
|
+
'create_narrative_beat', 'telescope_narrative_beat', 'list_narrative_beats',
|
|
217
|
+
'add_observations', 'create_entities', 'create_relations', 'search_nodes',
|
|
218
|
+
'open_nodes', 'read_graph', 'delete_entities', 'delete_relations',
|
|
219
|
+
'delete_observations', 'merge_entities',
|
|
220
|
+
];
|
|
221
|
+
return narrativeToolNames
|
|
222
|
+
.filter((name) => featureConfig.isToolEnabled(name))
|
|
223
|
+
.map((name) => ({
|
|
224
|
+
name,
|
|
225
|
+
description: `[Narrative] ${name.replace(/_/g, ' ')} — pending wiring from narrative module`,
|
|
226
|
+
inputSchema: { type: 'object', properties: {} },
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
function getPdeToolDefinitions(featureConfig) {
|
|
230
|
+
const pdeToolNames = [
|
|
231
|
+
'pde_decompose', 'pde_parse_response', 'pde_get', 'pde_list',
|
|
232
|
+
'pde_export_markdown', 'import_pde', 'create_stc_from_pde',
|
|
233
|
+
'pde_sessions_list', 'pde_sessions_create', 'pde_sessions_update',
|
|
234
|
+
];
|
|
235
|
+
return pdeToolNames
|
|
236
|
+
.filter((name) => featureConfig.isToolEnabled(name))
|
|
237
|
+
.map((name) => ({
|
|
238
|
+
name,
|
|
239
|
+
description: `[PDE] ${name.replace(/_/g, ' ')} — pending wiring from PDE module`,
|
|
240
|
+
inputSchema: { type: 'object', properties: {} },
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
function getPlanningToolDefinitions(featureConfig) {
|
|
244
|
+
const planToolNames = [
|
|
245
|
+
'parse_plan', 'plan_to_stc', 'sync_plans', 'trace_plan', 'pde_to_plan', 'list_plans',
|
|
246
|
+
];
|
|
247
|
+
return planToolNames
|
|
248
|
+
.filter((name) => featureConfig.isToolEnabled(name))
|
|
249
|
+
.map((name) => ({
|
|
250
|
+
name,
|
|
251
|
+
description: `[Planning] ${name.replace(/_/g, ' ')} — pending wiring from planning module`,
|
|
252
|
+
inputSchema: { type: 'object', properties: {} },
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
// ─── Server Creation ────────────────────────────────────────────────
|
|
256
|
+
function createServer() {
|
|
257
|
+
const cliArgs = parseArgs();
|
|
258
|
+
const featureConfig = new FeatureConfig(cliArgs.featureLevel);
|
|
259
|
+
const server = new Server({ name: SERVER_NAME, version: SERVER_VERSION }, { capabilities: { tools: {} } });
|
|
260
|
+
// Collect all tool definitions
|
|
261
|
+
const allToolDefs = [
|
|
262
|
+
...getCoaiapyToolDefinitions(featureConfig),
|
|
263
|
+
...getNarrativeToolDefinitions(featureConfig),
|
|
264
|
+
...getPdeToolDefinitions(featureConfig),
|
|
265
|
+
...getPlanningToolDefinitions(featureConfig),
|
|
266
|
+
];
|
|
267
|
+
// ── list_tools handler ──
|
|
268
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
269
|
+
return {
|
|
270
|
+
tools: allToolDefs.map((t) => ({
|
|
271
|
+
name: t.name,
|
|
272
|
+
description: t.description,
|
|
273
|
+
inputSchema: t.inputSchema,
|
|
274
|
+
})),
|
|
275
|
+
};
|
|
276
|
+
});
|
|
277
|
+
// ── call_tool handler ──
|
|
278
|
+
server.setRequestHandler(CallToolRequestSchema, async (request, _extra) => {
|
|
279
|
+
const { name, arguments: args } = request.params;
|
|
280
|
+
const toolArgs = (args ?? {});
|
|
281
|
+
// Route to coaiapy handler if it's a coaia_* tool
|
|
282
|
+
if (name.startsWith('coaia_')) {
|
|
283
|
+
return handleCoaiapyTool(name, toolArgs);
|
|
284
|
+
}
|
|
285
|
+
// Route to narrative/PDE/planning stubs
|
|
286
|
+
const stubModules = ['create_structural_tension_chart', 'telescope_action_step',
|
|
287
|
+
'mark_action_complete', 'get_chart_progress', 'list_active_charts', 'get_chart',
|
|
288
|
+
'get_action_step', 'update_action_progress', 'update_current_reality',
|
|
289
|
+
'manage_action_step', 'add_action_step', 'remove_action_step',
|
|
290
|
+
'update_desired_outcome', 'perform_mmot_evaluation', 'init_llm_guidance',
|
|
291
|
+
'create_narrative_beat', 'telescope_narrative_beat', 'list_narrative_beats',
|
|
292
|
+
'add_observations', 'create_entities', 'create_relations', 'search_nodes',
|
|
293
|
+
'open_nodes', 'read_graph', 'delete_entities', 'delete_relations',
|
|
294
|
+
'delete_observations', 'merge_entities',
|
|
295
|
+
'pde_decompose', 'pde_parse_response', 'pde_get', 'pde_list',
|
|
296
|
+
'pde_export_markdown', 'import_pde', 'create_stc_from_pde',
|
|
297
|
+
'pde_sessions_list', 'pde_sessions_create', 'pde_sessions_update',
|
|
298
|
+
'parse_plan', 'plan_to_stc', 'sync_plans', 'trace_plan', 'pde_to_plan', 'list_plans',
|
|
299
|
+
];
|
|
300
|
+
if (stubModules.includes(name)) {
|
|
301
|
+
return textResult(JSON.stringify({
|
|
302
|
+
status: 'pending',
|
|
303
|
+
message: `Tool '${name}' is registered but not yet wired. Module integration pending.`,
|
|
304
|
+
args: toolArgs,
|
|
305
|
+
}));
|
|
306
|
+
}
|
|
307
|
+
return textResult(`Unknown tool: ${name}`, true);
|
|
308
|
+
});
|
|
309
|
+
return server;
|
|
310
|
+
}
|
|
311
|
+
// ─── Main ───────────────────────────────────────────────────────────
|
|
312
|
+
async function main() {
|
|
313
|
+
const server = createServer();
|
|
314
|
+
const transport = new StdioServerTransport();
|
|
315
|
+
await server.connect(transport);
|
|
316
|
+
const featureConfig = new FeatureConfig();
|
|
317
|
+
const stats = featureConfig.getStats();
|
|
318
|
+
console.error(`${SERVER_NAME} v${SERVER_VERSION} started (${stats.level}: ${stats.tools} tools)`);
|
|
319
|
+
}
|
|
320
|
+
main().catch((error) => {
|
|
321
|
+
console.error('Fatal error:', error);
|
|
322
|
+
process.exit(1);
|
|
323
|
+
});
|
|
324
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FeatureConfig } from '../config.js';
|
|
2
|
+
export interface ToolDefinition {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export declare function getCoaiapyToolDefinitions(featureConfig: FeatureConfig): ToolDefinition[];
|
|
8
|
+
//# sourceMappingURL=coaiapy-tools.d.ts.map
|