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.
Files changed (162) hide show
  1. package/CLAUDE.md +56 -0
  2. package/KINSHIP.md +63 -0
  3. package/README.md +148 -0
  4. package/articles/academic/creative-orientation-vs-problem-solving.md +177 -0
  5. package/articles/academic/jsonl-knowledge-graphs-agent-memory.md +142 -0
  6. package/articles/academic/langfuse-observability-llm-pipelines.md +144 -0
  7. package/articles/academic/medicine-wheel-software-architecture.md +163 -0
  8. package/articles/academic/mmot-autonomous-agents.md +156 -0
  9. package/articles/academic/model-context-protocol-interagent.md +161 -0
  10. package/articles/academic/pde-prompt-decomposition.md +186 -0
  11. package/articles/academic/structural-tension-in-ai-agents.md +134 -0
  12. package/articles/reviews/mcp-protocol-design-review.md +170 -0
  13. package/articles/reviews/observability-ai-systems-review.md +176 -0
  14. package/articles/reviews/prompt-engineering-decomposition-review.md +184 -0
  15. package/articles/surveys/agent-orchestration-survey.md +186 -0
  16. package/articles/surveys/knowledge-graph-storage-survey.md +204 -0
  17. package/articles/surveys/structural-tension-methodology-survey.md +154 -0
  18. package/articles/technical/aws-sdk-v3-polly.md +270 -0
  19. package/articles/technical/commander-cli-framework.md +262 -0
  20. package/articles/technical/dotenv-config-patterns.md +360 -0
  21. package/articles/technical/ioredis-vs-redis.md +142 -0
  22. package/articles/technical/langfuse-js-sdk-vs-rest.md +191 -0
  23. package/articles/technical/mcp-sdk-typescript.md +291 -0
  24. package/articles/technical/octokit-github-api.md +293 -0
  25. package/articles/technical/openai-sdk-modern.md +231 -0
  26. package/articles/technical/yaml-parsing-node.md +266 -0
  27. package/articles/technical/zod-runtime-validation.md +212 -0
  28. package/dist/mcp/config.d.ts +14 -0
  29. package/dist/mcp/config.js +185 -0
  30. package/dist/mcp/server.d.ts +3 -0
  31. package/dist/mcp/server.js +324 -0
  32. package/dist/mcp/tools/coaiapy-tools.d.ts +8 -0
  33. package/dist/mcp/tools/coaiapy-tools.js +326 -0
  34. package/dist/mcp/tools/index.d.ts +3 -0
  35. package/dist/mcp/tools/index.js +3 -0
  36. package/dist/src/audio.d.ts +12 -0
  37. package/dist/src/audio.js +57 -0
  38. package/dist/src/cli-helpers.d.ts +9 -0
  39. package/dist/src/cli-helpers.js +78 -0
  40. package/dist/src/cli.d.ts +3 -0
  41. package/dist/src/cli.js +1086 -0
  42. package/dist/src/config.d.ts +15 -0
  43. package/dist/src/config.js +145 -0
  44. package/dist/src/environment.d.ts +44 -0
  45. package/dist/src/environment.js +146 -0
  46. package/dist/src/github.d.ts +47 -0
  47. package/dist/src/github.js +79 -0
  48. package/dist/src/langfuse/client.d.ts +30 -0
  49. package/dist/src/langfuse/client.js +75 -0
  50. package/dist/src/langfuse/comments.d.ts +16 -0
  51. package/dist/src/langfuse/comments.js +36 -0
  52. package/dist/src/langfuse/datasets.d.ts +19 -0
  53. package/dist/src/langfuse/datasets.js +140 -0
  54. package/dist/src/langfuse/index.d.ts +13 -0
  55. package/dist/src/langfuse/index.js +10 -0
  56. package/dist/src/langfuse/media.d.ts +11 -0
  57. package/dist/src/langfuse/media.js +167 -0
  58. package/dist/src/langfuse/observations.d.ts +18 -0
  59. package/dist/src/langfuse/observations.js +113 -0
  60. package/dist/src/langfuse/prompts.d.ts +14 -0
  61. package/dist/src/langfuse/prompts.js +127 -0
  62. package/dist/src/langfuse/scores.d.ts +54 -0
  63. package/dist/src/langfuse/scores.js +366 -0
  64. package/dist/src/langfuse/traces.d.ts +29 -0
  65. package/dist/src/langfuse/traces.js +225 -0
  66. package/dist/src/llm.d.ts +23 -0
  67. package/dist/src/llm.js +76 -0
  68. package/dist/src/narrative/graph-manager.d.ts +106 -0
  69. package/dist/src/narrative/graph-manager.js +915 -0
  70. package/dist/src/narrative/index.d.ts +9 -0
  71. package/dist/src/narrative/index.js +7 -0
  72. package/dist/src/narrative/markdown-export.d.ts +21 -0
  73. package/dist/src/narrative/markdown-export.js +383 -0
  74. package/dist/src/narrative/tool-definitions.d.ts +21 -0
  75. package/dist/src/narrative/tool-definitions.js +588 -0
  76. package/dist/src/narrative/tool-handlers.d.ts +11 -0
  77. package/dist/src/narrative/tool-handlers.js +462 -0
  78. package/dist/src/narrative/types.d.ts +2 -0
  79. package/dist/src/narrative/types.js +2 -0
  80. package/dist/src/narrative/validation.d.ts +29 -0
  81. package/dist/src/narrative/validation.js +144 -0
  82. package/dist/src/pde/index.d.ts +8 -0
  83. package/dist/src/pde/index.js +8 -0
  84. package/dist/src/pde/mcp-handlers.d.ts +7 -0
  85. package/dist/src/pde/mcp-handlers.js +300 -0
  86. package/dist/src/pde/mcp-tools.d.ts +15 -0
  87. package/dist/src/pde/mcp-tools.js +191 -0
  88. package/dist/src/pde/session-manager.d.ts +32 -0
  89. package/dist/src/pde/session-manager.js +205 -0
  90. package/dist/src/pde/stc-mapper.d.ts +26 -0
  91. package/dist/src/pde/stc-mapper.js +234 -0
  92. package/dist/src/pipeline/index.d.ts +2 -0
  93. package/dist/src/pipeline/index.js +3 -0
  94. package/dist/src/pipeline/template-engine.d.ts +20 -0
  95. package/dist/src/pipeline/template-engine.js +361 -0
  96. package/dist/src/planning/index.d.ts +7 -0
  97. package/dist/src/planning/index.js +7 -0
  98. package/dist/src/planning/mcp-handlers.d.ts +7 -0
  99. package/dist/src/planning/mcp-handlers.js +310 -0
  100. package/dist/src/planning/mcp-tools.d.ts +15 -0
  101. package/dist/src/planning/mcp-tools.js +145 -0
  102. package/dist/src/planning/plan-parser.d.ts +35 -0
  103. package/dist/src/planning/plan-parser.js +506 -0
  104. package/dist/src/redis.d.ts +21 -0
  105. package/dist/src/redis.js +78 -0
  106. package/dist/src/types.d.ts +244 -0
  107. package/dist/src/types.js +8 -0
  108. package/mcp/config.ts +196 -0
  109. package/mcp/server.ts +402 -0
  110. package/mcp/tools/coaiapy-tools.ts +364 -0
  111. package/mcp/tools/index.ts +4 -0
  112. package/package.json +52 -0
  113. package/rispecs/00-coaiajs-platform.spec.md +102 -0
  114. package/rispecs/01-core-config.spec.md +89 -0
  115. package/rispecs/02-redis-module.spec.md +62 -0
  116. package/rispecs/03-langfuse-module.spec.md +101 -0
  117. package/rispecs/04-narrative-engine.spec.md +185 -0
  118. package/rispecs/05-pde-engine.spec.md +112 -0
  119. package/rispecs/06-planning-engine.spec.md +128 -0
  120. package/rispecs/07-pipeline-templates.spec.md +97 -0
  121. package/rispecs/08-cli-interface.spec.md +134 -0
  122. package/rispecs/09-mcp-server.spec.md +140 -0
  123. package/rispecs/10-audio-module.spec.md +63 -0
  124. package/rispecs/KINSHIP.md +56 -0
  125. package/rispecs/README.md +100 -0
  126. package/src/audio.ts +76 -0
  127. package/src/cli-helpers.ts +86 -0
  128. package/src/cli.ts +1223 -0
  129. package/src/config.ts +172 -0
  130. package/src/environment.ts +171 -0
  131. package/src/github.ts +143 -0
  132. package/src/langfuse/client.ts +105 -0
  133. package/src/langfuse/comments.ts +52 -0
  134. package/src/langfuse/datasets.ts +178 -0
  135. package/src/langfuse/index.ts +33 -0
  136. package/src/langfuse/media.ts +193 -0
  137. package/src/langfuse/observations.ts +131 -0
  138. package/src/langfuse/prompts.ts +157 -0
  139. package/src/langfuse/scores.ts +456 -0
  140. package/src/langfuse/traces.ts +276 -0
  141. package/src/llm.ts +106 -0
  142. package/src/narrative/graph-manager.ts +1358 -0
  143. package/src/narrative/index.ts +32 -0
  144. package/src/narrative/markdown-export.ts +535 -0
  145. package/src/narrative/tool-definitions.ts +635 -0
  146. package/src/narrative/tool-handlers.ts +528 -0
  147. package/src/narrative/types.ts +9 -0
  148. package/src/narrative/validation.ts +179 -0
  149. package/src/pde/index.ts +8 -0
  150. package/src/pde/mcp-handlers.ts +359 -0
  151. package/src/pde/mcp-tools.ts +201 -0
  152. package/src/pde/session-manager.ts +248 -0
  153. package/src/pde/stc-mapper.ts +298 -0
  154. package/src/pipeline/index.ts +7 -0
  155. package/src/pipeline/template-engine.ts +398 -0
  156. package/src/planning/index.ts +13 -0
  157. package/src/planning/mcp-handlers.ts +369 -0
  158. package/src/planning/mcp-tools.ts +155 -0
  159. package/src/planning/plan-parser.ts +587 -0
  160. package/src/redis.ts +97 -0
  161. package/src/types.ts +280 -0
  162. package/tsconfig.json +26 -0
@@ -0,0 +1,300 @@
1
+ /**
2
+ * PDE MCP tool dispatch — handles each tool by calling stcMapper + sessionManager
3
+ * Ported from coaia-pde/src/mcp-server.ts handler logic
4
+ */
5
+ import { stcMapper } from './stc-mapper.js';
6
+ import { sessionManager } from './session-manager.js';
7
+ export async function handlePdeTool(name, args) {
8
+ try {
9
+ switch (name) {
10
+ case 'import_pde_decomposition': {
11
+ const pdeId = args.pde_id;
12
+ const workdir = args.workdir;
13
+ const stored = await sessionManager.loadPdeDecomposition(pdeId, workdir);
14
+ if (!stored) {
15
+ throw new Error(`PDE decomposition ${pdeId} not found in .pde/ directory`);
16
+ }
17
+ const { entities, relations, chartId } = stcMapper.mapDecompositionToChart(stored.result, stored.prompt, { pdeId: stored.id });
18
+ const session = await sessionManager.initSession(stored.prompt, chartId, stored.id);
19
+ for (const entity of entities) {
20
+ await sessionManager.appendEntity(session.sessionId, entity);
21
+ }
22
+ for (const relation of relations) {
23
+ await sessionManager.appendRelation(session.sessionId, relation);
24
+ }
25
+ const desiredOutcome = entities.find(e => e.entityType === 'desired_outcome')?.observations[0];
26
+ const currentReality = entities.find(e => e.entityType === 'current_reality')?.observations;
27
+ const actionSteps = entities
28
+ .filter(e => e.entityType === 'action_step')
29
+ .map(e => ({ name: e.name, description: e.observations[0] }));
30
+ return {
31
+ content: [{
32
+ type: 'text',
33
+ text: JSON.stringify({
34
+ success: true,
35
+ sessionId: session.sessionId,
36
+ chartId,
37
+ pdeDecompositionId: stored.id,
38
+ filePath: await sessionManager.getSessionFilePath(session.sessionId),
39
+ chart: { desiredOutcome, currentReality, actionSteps },
40
+ }, null, 2)
41
+ }]
42
+ };
43
+ }
44
+ case 'create_stc_from_pde': {
45
+ const resultJson = args.decomposition_result;
46
+ const originalPrompt = args.original_prompt;
47
+ const { entities, relations, chartId } = stcMapper.mapDecompositionToChart(resultJson, originalPrompt);
48
+ const session = await sessionManager.initSession(originalPrompt, chartId);
49
+ for (const entity of entities) {
50
+ await sessionManager.appendEntity(session.sessionId, entity);
51
+ }
52
+ for (const relation of relations) {
53
+ await sessionManager.appendRelation(session.sessionId, relation);
54
+ }
55
+ const desiredOutcome = entities.find(e => e.entityType === 'desired_outcome')?.observations[0];
56
+ const currentReality = entities.find(e => e.entityType === 'current_reality')?.observations;
57
+ const actionSteps = entities
58
+ .filter(e => e.entityType === 'action_step')
59
+ .map(e => ({ name: e.name, description: e.observations[0] }));
60
+ return {
61
+ content: [{
62
+ type: 'text',
63
+ text: JSON.stringify({
64
+ success: true,
65
+ sessionId: session.sessionId,
66
+ chartId,
67
+ filePath: await sessionManager.getSessionFilePath(session.sessionId),
68
+ chart: { desiredOutcome, currentReality, actionSteps },
69
+ }, null, 2)
70
+ }]
71
+ };
72
+ }
73
+ case 'list_pde_decompositions': {
74
+ const workdir = args.workdir;
75
+ const decompositions = await sessionManager.listPdeDecompositions(workdir);
76
+ return {
77
+ content: [{
78
+ type: 'text',
79
+ text: JSON.stringify({
80
+ count: decompositions.length,
81
+ decompositions: decompositions.map(d => ({
82
+ id: d.id,
83
+ timestamp: d.timestamp,
84
+ prompt: d.prompt.substring(0, 100) + (d.prompt.length > 100 ? '...' : '')
85
+ }))
86
+ }, null, 2)
87
+ }]
88
+ };
89
+ }
90
+ case 'get_session': {
91
+ const sessionId = args.session_id;
92
+ const { session, entities } = await sessionManager.loadSession(sessionId);
93
+ const chart = entities.find(e => e.entityType === 'structural_tension_chart');
94
+ const desiredOutcome = entities.find(e => e.entityType === 'desired_outcome');
95
+ const currentReality = entities.find(e => e.entityType === 'current_reality');
96
+ const actionSteps = entities.filter(e => e.entityType === 'action_step');
97
+ const completedCount = actionSteps.filter(a => a.metadata?.completionStatus).length;
98
+ const progress = actionSteps.length > 0 ? completedCount / actionSteps.length : 0;
99
+ return {
100
+ content: [{
101
+ type: 'text',
102
+ text: JSON.stringify({
103
+ session,
104
+ chart: {
105
+ chartId: chart?.metadata?.chartId,
106
+ desiredOutcome: desiredOutcome?.observations[0],
107
+ currentReality: currentReality?.observations,
108
+ dueDate: chart?.metadata?.dueDate,
109
+ progress: Math.round(progress * 100) + '%',
110
+ completedActions: completedCount,
111
+ totalActions: actionSteps.length
112
+ },
113
+ actionSteps: actionSteps.map(a => ({
114
+ name: a.name,
115
+ description: a.observations[0],
116
+ completed: a.metadata?.completionStatus || false,
117
+ dueDate: a.metadata?.dueDate,
118
+ progress: a.observations.slice(1)
119
+ }))
120
+ }, null, 2)
121
+ }]
122
+ };
123
+ }
124
+ case 'list_sessions': {
125
+ const status = args.status;
126
+ let sessions = await sessionManager.listSessions();
127
+ if (status && status !== 'all') {
128
+ sessions = sessions.filter(s => s.status === status);
129
+ }
130
+ return {
131
+ content: [{
132
+ type: 'text',
133
+ text: JSON.stringify({
134
+ count: sessions.length,
135
+ sessions: sessions.map(s => ({
136
+ sessionId: s.sessionId,
137
+ status: s.status,
138
+ createdAt: s.createdAt,
139
+ pdeDecompositionId: s.pdeDecompositionId,
140
+ prompt: s.originalPrompt.substring(0, 100) + (s.originalPrompt.length > 100 ? '...' : '')
141
+ }))
142
+ }, null, 2)
143
+ }]
144
+ };
145
+ }
146
+ case 'update_action_progress': {
147
+ const sessionId = args.session_id;
148
+ const actionName = args.action_name;
149
+ const observation = args.observation;
150
+ const updateCR = args.update_current_reality;
151
+ const { entities } = await sessionManager.loadSession(sessionId);
152
+ const action = entities.find(e => e.name === actionName);
153
+ if (!action) {
154
+ throw new Error(`Action step ${actionName} not found`);
155
+ }
156
+ action.observations.push(observation);
157
+ await sessionManager.updateEntity(sessionId, actionName, { observations: action.observations });
158
+ if (updateCR) {
159
+ const chartId = action.metadata?.chartId;
160
+ const realityName = `${chartId}_current_reality`;
161
+ const reality = entities.find(e => e.name === realityName);
162
+ if (reality) {
163
+ reality.observations.push(`Progress: ${observation}`);
164
+ await sessionManager.updateEntity(sessionId, realityName, { observations: reality.observations });
165
+ }
166
+ }
167
+ return {
168
+ content: [{
169
+ type: 'text',
170
+ text: JSON.stringify({ success: true, actionName, observation })
171
+ }]
172
+ };
173
+ }
174
+ case 'mark_action_complete': {
175
+ const sessionId = args.session_id;
176
+ const actionName = args.action_name;
177
+ const completionNote = args.completion_note;
178
+ const { entities } = await sessionManager.loadSession(sessionId);
179
+ const action = entities.find(e => e.name === actionName);
180
+ if (!action) {
181
+ throw new Error(`Action step ${actionName} not found`);
182
+ }
183
+ if (!action.metadata)
184
+ action.metadata = {};
185
+ action.metadata.completionStatus = true;
186
+ action.metadata.updatedAt = new Date().toISOString();
187
+ if (completionNote) {
188
+ action.observations.push(`Completed: ${completionNote}`);
189
+ }
190
+ await sessionManager.updateEntity(sessionId, actionName, {
191
+ observations: action.observations,
192
+ metadata: action.metadata
193
+ });
194
+ const chartId = action.metadata?.chartId;
195
+ const realityName = `${chartId}_current_reality`;
196
+ const reality = entities.find(e => e.name === realityName);
197
+ if (reality) {
198
+ reality.observations.push(`Completed: ${action.observations[0]}`);
199
+ await sessionManager.updateEntity(sessionId, realityName, { observations: reality.observations });
200
+ }
201
+ return {
202
+ content: [{
203
+ type: 'text',
204
+ text: JSON.stringify({ success: true, actionName, completed: true })
205
+ }]
206
+ };
207
+ }
208
+ case 'add_action_step': {
209
+ const sessionId = args.session_id;
210
+ const description = args.action_description;
211
+ const currentReality = args.current_reality;
212
+ const { session, entities } = await sessionManager.loadSession(sessionId);
213
+ const chart = entities.find(e => e.entityType === 'structural_tension_chart');
214
+ const chartId = chart?.metadata?.chartId || session.masterChartId;
215
+ const existingActions = entities.filter(e => e.entityType === 'action_step');
216
+ const actionNum = existingActions.length + 1;
217
+ const actionName = `${chartId}_action_${actionNum}`;
218
+ const now = new Date().toISOString();
219
+ const newAction = {
220
+ name: actionName,
221
+ entityType: 'action_step',
222
+ observations: currentReality ? [description, `Current: ${currentReality}`] : [description],
223
+ metadata: {
224
+ chartId,
225
+ completionStatus: false,
226
+ level: 1,
227
+ parentChart: chartId,
228
+ createdAt: now,
229
+ updatedAt: now,
230
+ }
231
+ };
232
+ await sessionManager.appendEntity(sessionId, newAction);
233
+ await sessionManager.appendRelation(sessionId, {
234
+ from: `${chartId}_chart`,
235
+ to: actionName,
236
+ relationType: 'has_action_step',
237
+ metadata: { createdAt: now }
238
+ });
239
+ return {
240
+ content: [{
241
+ type: 'text',
242
+ text: JSON.stringify({ success: true, actionName, description })
243
+ }]
244
+ };
245
+ }
246
+ case 'update_current_reality': {
247
+ const sessionId = args.session_id;
248
+ const observations = args.observations;
249
+ const { session, entities } = await sessionManager.loadSession(sessionId);
250
+ const chartId = session.masterChartId;
251
+ const realityName = `${chartId}_current_reality`;
252
+ const reality = entities.find(e => e.name === realityName);
253
+ if (!reality) {
254
+ throw new Error(`Current reality not found for chart ${chartId}`);
255
+ }
256
+ reality.observations.push(...observations);
257
+ await sessionManager.updateEntity(sessionId, realityName, { observations: reality.observations });
258
+ return {
259
+ content: [{
260
+ type: 'text',
261
+ text: JSON.stringify({ success: true, added: observations.length, totalObservations: reality.observations.length })
262
+ }]
263
+ };
264
+ }
265
+ case 'complete_session': {
266
+ const sessionId = args.session_id;
267
+ const finalNote = args.final_note;
268
+ await sessionManager.updateSession(sessionId, { status: 'completed' });
269
+ if (finalNote) {
270
+ const { session, entities } = await sessionManager.loadSession(sessionId);
271
+ const realityName = `${session.masterChartId}_current_reality`;
272
+ const reality = entities.find(e => e.name === realityName);
273
+ if (reality) {
274
+ reality.observations.push(`Final: ${finalNote}`);
275
+ await sessionManager.updateEntity(sessionId, realityName, { observations: reality.observations });
276
+ }
277
+ }
278
+ return {
279
+ content: [{
280
+ type: 'text',
281
+ text: JSON.stringify({ success: true, sessionId, status: 'completed' })
282
+ }]
283
+ };
284
+ }
285
+ default:
286
+ throw new Error(`Unknown PDE tool: ${name}`);
287
+ }
288
+ }
289
+ catch (error) {
290
+ const message = error instanceof Error ? error.message : String(error);
291
+ return {
292
+ content: [{
293
+ type: 'text',
294
+ text: `Error: ${message}`,
295
+ }],
296
+ isError: true
297
+ };
298
+ }
299
+ }
300
+ //# sourceMappingURL=mcp-handlers.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * MCP tool definitions for PDE module (10 tools)
3
+ * Ported from coaia-pde/src/mcp-server.ts tool schemas
4
+ */
5
+ export interface McpToolDef {
6
+ name: string;
7
+ description: string;
8
+ inputSchema: {
9
+ type: 'object';
10
+ properties: Record<string, unknown>;
11
+ required?: string[];
12
+ };
13
+ }
14
+ export declare const PDE_MCP_TOOLS: McpToolDef[];
15
+ //# sourceMappingURL=mcp-tools.d.ts.map
@@ -0,0 +1,191 @@
1
+ /**
2
+ * MCP tool definitions for PDE module (10 tools)
3
+ * Ported from coaia-pde/src/mcp-server.ts tool schemas
4
+ */
5
+ export const PDE_MCP_TOOLS = [
6
+ {
7
+ name: 'import_pde_decomposition',
8
+ description: 'Import a .pde/*.json StoredDecomposition and create an STC session from it. Reads the decomposition result, maps it to Structural Tension Chart entities, and persists as .coaia/pde/<UUID>.jsonl.',
9
+ inputSchema: {
10
+ type: 'object',
11
+ properties: {
12
+ pde_id: {
13
+ type: 'string',
14
+ description: 'ID of the PDE decomposition in .pde/ folder'
15
+ },
16
+ workdir: {
17
+ type: 'string',
18
+ description: 'Working directory containing .pde/ folder (default: cwd)'
19
+ }
20
+ },
21
+ required: ['pde_id']
22
+ }
23
+ },
24
+ {
25
+ name: 'create_stc_from_pde',
26
+ description: 'One-shot: provide a DecompositionResult JSON directly and create a Structural Tension Chart session. Use when you already have the decomposition in memory.',
27
+ inputSchema: {
28
+ type: 'object',
29
+ properties: {
30
+ decomposition_result: {
31
+ type: 'object',
32
+ description: 'DecompositionResult JSON object from mcp-pde'
33
+ },
34
+ original_prompt: {
35
+ type: 'string',
36
+ description: 'The original prompt that was decomposed'
37
+ }
38
+ },
39
+ required: ['decomposition_result', 'original_prompt']
40
+ }
41
+ },
42
+ {
43
+ name: 'list_pde_decompositions',
44
+ description: 'List available .pde/*.json decomposition files that can be imported into STC sessions.',
45
+ inputSchema: {
46
+ type: 'object',
47
+ properties: {
48
+ workdir: {
49
+ type: 'string',
50
+ description: 'Working directory containing .pde/ folder (default: cwd)'
51
+ }
52
+ }
53
+ }
54
+ },
55
+ {
56
+ name: 'get_session',
57
+ description: 'Get the current state of a PDE session including the Structural Tension Chart, action steps, and progress.',
58
+ inputSchema: {
59
+ type: 'object',
60
+ properties: {
61
+ session_id: {
62
+ type: 'string',
63
+ description: 'The session UUID'
64
+ }
65
+ },
66
+ required: ['session_id']
67
+ }
68
+ },
69
+ {
70
+ name: 'list_sessions',
71
+ description: 'List all PDE sessions in the current directory.',
72
+ inputSchema: {
73
+ type: 'object',
74
+ properties: {
75
+ status: {
76
+ type: 'string',
77
+ enum: ['active', 'completed', 'abandoned', 'all'],
78
+ description: 'Filter by session status'
79
+ }
80
+ }
81
+ }
82
+ },
83
+ {
84
+ name: 'update_action_progress',
85
+ description: 'Update progress on an action step with a factual observation.',
86
+ inputSchema: {
87
+ type: 'object',
88
+ properties: {
89
+ session_id: {
90
+ type: 'string',
91
+ description: 'The session UUID'
92
+ },
93
+ action_name: {
94
+ type: 'string',
95
+ description: 'The action step entity name (e.g., chart_abc123_action_1)'
96
+ },
97
+ observation: {
98
+ type: 'string',
99
+ description: 'Factual progress observation (what was done, not what will be done)'
100
+ },
101
+ update_current_reality: {
102
+ type: 'boolean',
103
+ description: 'Whether to also add this observation to the chart current reality'
104
+ }
105
+ },
106
+ required: ['session_id', 'action_name', 'observation']
107
+ }
108
+ },
109
+ {
110
+ name: 'mark_action_complete',
111
+ description: 'Mark an action step as complete. The completion flows into current reality.',
112
+ inputSchema: {
113
+ type: 'object',
114
+ properties: {
115
+ session_id: {
116
+ type: 'string',
117
+ description: 'The session UUID'
118
+ },
119
+ action_name: {
120
+ type: 'string',
121
+ description: 'The action step entity name'
122
+ },
123
+ completion_note: {
124
+ type: 'string',
125
+ description: 'Optional note about what was accomplished'
126
+ }
127
+ },
128
+ required: ['session_id', 'action_name']
129
+ }
130
+ },
131
+ {
132
+ name: 'add_action_step',
133
+ description: 'Add a new strategic action step to the chart. Each action step is a secondary choice supporting the primary goal.',
134
+ inputSchema: {
135
+ type: 'object',
136
+ properties: {
137
+ session_id: {
138
+ type: 'string',
139
+ description: 'The session UUID'
140
+ },
141
+ action_description: {
142
+ type: 'string',
143
+ description: 'Description of the strategic action'
144
+ },
145
+ current_reality: {
146
+ type: 'string',
147
+ description: 'Current reality for this specific action step'
148
+ }
149
+ },
150
+ required: ['session_id', 'action_description']
151
+ }
152
+ },
153
+ {
154
+ name: 'update_current_reality',
155
+ description: 'Add observations to the current reality of the chart.',
156
+ inputSchema: {
157
+ type: 'object',
158
+ properties: {
159
+ session_id: {
160
+ type: 'string',
161
+ description: 'The session UUID'
162
+ },
163
+ observations: {
164
+ type: 'array',
165
+ items: { type: 'string' },
166
+ description: 'Factual observations to add to current reality'
167
+ }
168
+ },
169
+ required: ['session_id', 'observations']
170
+ }
171
+ },
172
+ {
173
+ name: 'complete_session',
174
+ description: 'Mark the session as completed when the desired outcome is achieved.',
175
+ inputSchema: {
176
+ type: 'object',
177
+ properties: {
178
+ session_id: {
179
+ type: 'string',
180
+ description: 'The session UUID'
181
+ },
182
+ final_note: {
183
+ type: 'string',
184
+ description: 'Final observation about the completed outcome'
185
+ }
186
+ },
187
+ required: ['session_id']
188
+ }
189
+ },
190
+ ];
191
+ //# sourceMappingURL=mcp-tools.js.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Session Manager — JSONL persistence for PDE sessions in .coaia/pde/<UUID>.jsonl
3
+ * Ported from coaia-pde/src/session-manager.ts
4
+ */
5
+ import type { Entity, Relation, PdeSession, StoredDecomposition } from '../types.js';
6
+ export declare class SessionManager {
7
+ private baseDir;
8
+ constructor(baseDir?: string);
9
+ private getSessionPath;
10
+ ensureBaseDir(): Promise<void>;
11
+ initSession(originalPrompt: string, masterChartId: string, pdeDecompositionId?: string): Promise<PdeSession>;
12
+ loadSession(sessionId: string): Promise<{
13
+ session: PdeSession;
14
+ entities: Entity[];
15
+ relations: Relation[];
16
+ }>;
17
+ appendEntity(sessionId: string, entity: Entity): Promise<void>;
18
+ appendRelation(sessionId: string, relation: Relation): Promise<void>;
19
+ updateSession(sessionId: string, updates: Partial<PdeSession>): Promise<void>;
20
+ updateEntity(sessionId: string, entityName: string, updates: Partial<Entity>): Promise<void>;
21
+ listSessions(): Promise<PdeSession[]>;
22
+ deleteSession(sessionId: string): Promise<void>;
23
+ getSessionFilePath(sessionId: string): Promise<string>;
24
+ listPdeDecompositions(workdir?: string): Promise<Array<{
25
+ id: string;
26
+ timestamp: string;
27
+ prompt: string;
28
+ }>>;
29
+ loadPdeDecomposition(id: string, workdir?: string): Promise<StoredDecomposition | null>;
30
+ }
31
+ export declare const sessionManager: SessionManager;
32
+ //# sourceMappingURL=session-manager.d.ts.map