coaiajs 0.1.0 → 0.1.2

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 (187) hide show
  1. package/README.md +7 -3
  2. package/dist/mcp/config.d.ts +4 -0
  3. package/dist/mcp/config.d.ts.map +1 -0
  4. package/dist/mcp/config.js +52 -26
  5. package/dist/mcp/config.js.map +1 -0
  6. package/dist/mcp/prompts.d.ts +19 -0
  7. package/dist/mcp/prompts.d.ts.map +1 -0
  8. package/dist/mcp/prompts.js +111 -0
  9. package/dist/mcp/prompts.js.map +1 -0
  10. package/dist/mcp/resources.d.ts +5 -0
  11. package/dist/mcp/resources.d.ts.map +1 -0
  12. package/dist/mcp/resources.js +77 -0
  13. package/dist/mcp/resources.js.map +1 -0
  14. package/dist/mcp/server.d.ts.map +1 -0
  15. package/dist/mcp/server.js +167 -75
  16. package/dist/mcp/server.js.map +1 -0
  17. package/dist/mcp/tools/coaiapy-tools.d.ts.map +1 -0
  18. package/dist/mcp/tools/coaiapy-tools.js +1 -0
  19. package/dist/mcp/tools/coaiapy-tools.js.map +1 -0
  20. package/dist/mcp/tools/index.d.ts.map +1 -0
  21. package/dist/mcp/tools/index.js.map +1 -0
  22. package/dist/src/audio.d.ts.map +1 -0
  23. package/dist/src/audio.js.map +1 -0
  24. package/dist/src/cli-helpers.d.ts.map +1 -0
  25. package/dist/src/cli-helpers.js.map +1 -0
  26. package/dist/src/cli.d.ts.map +1 -0
  27. package/dist/src/cli.js +4 -4
  28. package/dist/src/cli.js.map +1 -0
  29. package/dist/src/config.d.ts +2 -0
  30. package/dist/src/config.d.ts.map +1 -0
  31. package/dist/src/config.js +44 -14
  32. package/dist/src/config.js.map +1 -0
  33. package/dist/src/environment.d.ts.map +1 -0
  34. package/dist/src/environment.js.map +1 -0
  35. package/dist/src/github.d.ts.map +1 -0
  36. package/dist/src/github.js.map +1 -0
  37. package/dist/src/index.d.ts +13 -0
  38. package/dist/src/index.d.ts.map +1 -0
  39. package/dist/src/index.js +13 -0
  40. package/dist/src/index.js.map +1 -0
  41. package/dist/src/langfuse/client.d.ts.map +1 -0
  42. package/dist/src/langfuse/client.js.map +1 -0
  43. package/dist/src/langfuse/comments.d.ts.map +1 -0
  44. package/dist/src/langfuse/comments.js.map +1 -0
  45. package/dist/src/langfuse/datasets.d.ts.map +1 -0
  46. package/dist/src/langfuse/datasets.js.map +1 -0
  47. package/dist/src/langfuse/index.d.ts.map +1 -0
  48. package/dist/src/langfuse/index.js.map +1 -0
  49. package/dist/src/langfuse/media.d.ts.map +1 -0
  50. package/dist/src/langfuse/media.js.map +1 -0
  51. package/dist/src/langfuse/observations.d.ts.map +1 -0
  52. package/dist/src/langfuse/observations.js.map +1 -0
  53. package/dist/src/langfuse/prompts.d.ts.map +1 -0
  54. package/dist/src/langfuse/prompts.js.map +1 -0
  55. package/dist/src/langfuse/scores.d.ts.map +1 -0
  56. package/dist/src/langfuse/scores.js.map +1 -0
  57. package/dist/src/langfuse/traces.d.ts.map +1 -0
  58. package/dist/src/langfuse/traces.js.map +1 -0
  59. package/dist/src/llm.d.ts.map +1 -0
  60. package/dist/src/llm.js.map +1 -0
  61. package/dist/src/narrative/graph-manager.d.ts.map +1 -0
  62. package/dist/src/narrative/graph-manager.js.map +1 -0
  63. package/dist/src/narrative/index.d.ts +32 -1
  64. package/dist/src/narrative/index.d.ts.map +1 -0
  65. package/dist/src/narrative/index.js +97 -1
  66. package/dist/src/narrative/index.js.map +1 -0
  67. package/dist/src/narrative/markdown-export.d.ts.map +1 -0
  68. package/dist/src/narrative/markdown-export.js.map +1 -0
  69. package/dist/src/narrative/tool-definitions.d.ts.map +1 -0
  70. package/dist/src/narrative/tool-definitions.js.map +1 -0
  71. package/dist/src/narrative/tool-handlers.d.ts.map +1 -0
  72. package/dist/src/narrative/tool-handlers.js.map +1 -0
  73. package/dist/src/narrative/types.d.ts.map +1 -0
  74. package/dist/src/narrative/types.js.map +1 -0
  75. package/dist/src/narrative/validation.d.ts.map +1 -0
  76. package/dist/src/narrative/validation.js.map +1 -0
  77. package/dist/src/pde/index.d.ts +4 -0
  78. package/dist/src/pde/index.d.ts.map +1 -0
  79. package/dist/src/pde/index.js +19 -0
  80. package/dist/src/pde/index.js.map +1 -0
  81. package/dist/src/pde/mcp-handlers.d.ts.map +1 -0
  82. package/dist/src/pde/mcp-handlers.js.map +1 -0
  83. package/dist/src/pde/mcp-tools.d.ts.map +1 -0
  84. package/dist/src/pde/mcp-tools.js.map +1 -0
  85. package/dist/src/pde/session-manager.d.ts.map +1 -0
  86. package/dist/src/pde/session-manager.js.map +1 -0
  87. package/dist/src/pde/stc-mapper.d.ts.map +1 -0
  88. package/dist/src/pde/stc-mapper.js.map +1 -0
  89. package/dist/src/pipeline/index.d.ts.map +1 -0
  90. package/dist/src/pipeline/index.js.map +1 -0
  91. package/dist/src/pipeline/template-engine.d.ts.map +1 -0
  92. package/dist/src/pipeline/template-engine.js.map +1 -0
  93. package/dist/src/planning/index.d.ts +3 -0
  94. package/dist/src/planning/index.d.ts.map +1 -0
  95. package/dist/src/planning/index.js +13 -0
  96. package/dist/src/planning/index.js.map +1 -0
  97. package/dist/src/planning/mcp-handlers.d.ts.map +1 -0
  98. package/dist/src/planning/mcp-handlers.js.map +1 -0
  99. package/dist/src/planning/mcp-tools.d.ts.map +1 -0
  100. package/dist/src/planning/mcp-tools.js.map +1 -0
  101. package/dist/src/planning/plan-parser.d.ts.map +1 -0
  102. package/dist/src/planning/plan-parser.js.map +1 -0
  103. package/dist/src/redis.d.ts.map +1 -0
  104. package/dist/src/redis.js +20 -8
  105. package/dist/src/redis.js.map +1 -0
  106. package/dist/src/types.d.ts +1 -0
  107. package/dist/src/types.d.ts.map +1 -0
  108. package/dist/src/types.js.map +1 -0
  109. package/package.json +67 -2
  110. package/rispecs/00-coaiajs-platform.spec.md +23 -10
  111. package/rispecs/01-core-config.spec.md +7 -37
  112. package/rispecs/02-redis-module.spec.md +2 -1
  113. package/rispecs/03-langfuse-module.spec.md +7 -5
  114. package/rispecs/04-narrative-engine.spec.md +9 -9
  115. package/rispecs/05-pde-engine.spec.md +23 -23
  116. package/rispecs/06-planning-engine.spec.md +14 -13
  117. package/rispecs/07-pipeline-templates.spec.md +7 -7
  118. package/rispecs/08-cli-interface.spec.md +13 -25
  119. package/rispecs/09-mcp-server.spec.md +57 -62
  120. package/rispecs/10-audio-module.spec.md +3 -3
  121. package/rispecs/KINSHIP.md +4 -4
  122. package/rispecs/README.md +33 -7
  123. package/articles/academic/creative-orientation-vs-problem-solving.md +0 -177
  124. package/articles/academic/jsonl-knowledge-graphs-agent-memory.md +0 -142
  125. package/articles/academic/langfuse-observability-llm-pipelines.md +0 -144
  126. package/articles/academic/medicine-wheel-software-architecture.md +0 -163
  127. package/articles/academic/mmot-autonomous-agents.md +0 -156
  128. package/articles/academic/model-context-protocol-interagent.md +0 -161
  129. package/articles/academic/pde-prompt-decomposition.md +0 -186
  130. package/articles/academic/structural-tension-in-ai-agents.md +0 -134
  131. package/articles/reviews/mcp-protocol-design-review.md +0 -170
  132. package/articles/reviews/observability-ai-systems-review.md +0 -176
  133. package/articles/reviews/prompt-engineering-decomposition-review.md +0 -184
  134. package/articles/surveys/agent-orchestration-survey.md +0 -186
  135. package/articles/surveys/knowledge-graph-storage-survey.md +0 -204
  136. package/articles/surveys/structural-tension-methodology-survey.md +0 -154
  137. package/articles/technical/aws-sdk-v3-polly.md +0 -270
  138. package/articles/technical/commander-cli-framework.md +0 -262
  139. package/articles/technical/dotenv-config-patterns.md +0 -360
  140. package/articles/technical/ioredis-vs-redis.md +0 -142
  141. package/articles/technical/langfuse-js-sdk-vs-rest.md +0 -191
  142. package/articles/technical/mcp-sdk-typescript.md +0 -291
  143. package/articles/technical/octokit-github-api.md +0 -293
  144. package/articles/technical/openai-sdk-modern.md +0 -231
  145. package/articles/technical/yaml-parsing-node.md +0 -266
  146. package/articles/technical/zod-runtime-validation.md +0 -212
  147. package/mcp/config.ts +0 -196
  148. package/mcp/server.ts +0 -402
  149. package/mcp/tools/coaiapy-tools.ts +0 -364
  150. package/mcp/tools/index.ts +0 -4
  151. package/src/audio.ts +0 -76
  152. package/src/cli-helpers.ts +0 -86
  153. package/src/cli.ts +0 -1223
  154. package/src/config.ts +0 -172
  155. package/src/environment.ts +0 -171
  156. package/src/github.ts +0 -143
  157. package/src/langfuse/client.ts +0 -105
  158. package/src/langfuse/comments.ts +0 -52
  159. package/src/langfuse/datasets.ts +0 -178
  160. package/src/langfuse/index.ts +0 -33
  161. package/src/langfuse/media.ts +0 -193
  162. package/src/langfuse/observations.ts +0 -131
  163. package/src/langfuse/prompts.ts +0 -157
  164. package/src/langfuse/scores.ts +0 -456
  165. package/src/langfuse/traces.ts +0 -276
  166. package/src/llm.ts +0 -106
  167. package/src/narrative/graph-manager.ts +0 -1358
  168. package/src/narrative/index.ts +0 -32
  169. package/src/narrative/markdown-export.ts +0 -535
  170. package/src/narrative/tool-definitions.ts +0 -635
  171. package/src/narrative/tool-handlers.ts +0 -528
  172. package/src/narrative/types.ts +0 -9
  173. package/src/narrative/validation.ts +0 -179
  174. package/src/pde/index.ts +0 -8
  175. package/src/pde/mcp-handlers.ts +0 -359
  176. package/src/pde/mcp-tools.ts +0 -201
  177. package/src/pde/session-manager.ts +0 -248
  178. package/src/pde/stc-mapper.ts +0 -298
  179. package/src/pipeline/index.ts +0 -7
  180. package/src/pipeline/template-engine.ts +0 -398
  181. package/src/planning/index.ts +0 -13
  182. package/src/planning/mcp-handlers.ts +0 -369
  183. package/src/planning/mcp-tools.ts +0 -155
  184. package/src/planning/plan-parser.ts +0 -587
  185. package/src/redis.ts +0 -97
  186. package/src/types.ts +0 -280
  187. package/tsconfig.json +0 -26
@@ -1,212 +0,0 @@
1
- # Zod Runtime Validation: Technical Assessment for CoAiA.js
2
-
3
- > Package selection brief — TypeScript-first schema validation replacing coaia-narrative's custom 181-line validation.ts
4
-
5
- ## Summary & Recommendation
6
-
7
- **Use `zod` v4.x** as the unified validation layer for all coaiajs modules. Zod replaces coaia-narrative's custom `validation.ts` (181 lines of hand-rolled recursive validation) with a standard, composable, type-inferring schema library. The MCP SDK already requires Zod as a peer dependency for tool argument schemas — using it everywhere eliminates dual validation code.
8
-
9
- **Pin:** `"zod": "^4.0.0"` (v4.3.6 stable, required by `@modelcontextprotocol/sdk`)
10
-
11
- ## What We're Replacing
12
-
13
- coaia-narrative has a custom `validation.ts` implementing recursive schema validation:
14
-
15
- ```typescript
16
- // coaia-narrative/src/validation.ts — 181 lines of custom validation
17
- type ValidationType = 'string' | 'number' | 'boolean' | 'array' | 'object' | 'date' | 'enum';
18
-
19
- interface ValidationRule {
20
- type: ValidationType;
21
- required?: boolean;
22
- minLength?: number;
23
- maxLength?: number;
24
- pattern?: RegExp;
25
- minValue?: number;
26
- maxValue?: number;
27
- enumValues?: (string | number)[];
28
- items?: ValidationRule; // array items schema
29
- properties?: Record<string, ValidationRule>; // object properties
30
- }
31
-
32
- export function validate(args: any, schema: ValidationSchema): { valid: boolean; error?: string }
33
- ```
34
-
35
- Pre-built schemas: `stringArray()`, `entityArray()`, `relationArray()`, `isoDate()`, `nonEmptyString()`.
36
-
37
- This works but: no type inference, no composition, no transform/coerce, no JSON Schema export, and every new validation type requires manual code.
38
-
39
- ## Options Compared
40
-
41
- | Feature | Zod v4 | Custom validation.ts | io-ts | Yup |
42
- |---------|--------|---------------------|-------|-----|
43
- | Type inference | ✅ Automatic `z.infer<>` | ❌ Manual types | ✅ (verbose) | ⚠️ Partial |
44
- | Schema composition | ✅ `.merge()`, `.extend()`, `.pick()` | ❌ Manual nesting | ✅ | ✅ |
45
- | MCP SDK compat | ✅ Required peer dep | ❌ N/A | ❌ | ❌ |
46
- | JSON Schema export | ✅ `toJSONSchema()` | ❌ N/A | ❌ | ❌ |
47
- | Transform/coerce | ✅ `.transform()`, `.coerce` | ❌ N/A | ❌ | ✅ |
48
- | Error messages | ✅ Structured `ZodError` | ⚠️ Single string | ⚠️ Verbose | ✅ |
49
- | Bundle size | ~2KB gzip (core) | ~3KB | ~15KB | ~12KB |
50
- | Weekly downloads | ~100M+ | N/A | ~8M | ~15M |
51
- | Performance (v4) | 14x faster strings, 7x faster arrays vs v3 | Adequate | Slower | Slower |
52
-
53
- ## API Overview
54
-
55
- ### Replacing Custom Schemas
56
-
57
- ```typescript
58
- import { z } from 'zod';
59
-
60
- // Replaces: ValidationSchemas.nonEmptyString()
61
- const NonEmptyString = z.string().min(1);
62
-
63
- // Replaces: ValidationSchemas.isoDate()
64
- const IsoDate = z.string().datetime();
65
-
66
- // Replaces: ValidationSchemas.stringArray(minLength)
67
- const StringArray = (min = 0) => z.array(z.string()).min(min);
68
-
69
- // Replaces: ValidationSchemas.entityArray()
70
- const Entity = z.object({
71
- name: z.string().min(1),
72
- entityType: z.string().min(1),
73
- observations: z.array(z.string()).default([]),
74
- });
75
- const EntityArray = z.array(Entity).min(1);
76
-
77
- // Replaces: ValidationSchemas.relationArray()
78
- const Relation = z.object({
79
- from: z.string().min(1),
80
- to: z.string().min(1),
81
- relationType: z.string().min(1),
82
- });
83
- const RelationArray = z.array(Relation);
84
- ```
85
-
86
- ### Structural Tension Chart Schema
87
-
88
- ```typescript
89
- const ChartSchema = z.object({
90
- id: z.string().min(1),
91
- desiredOutcome: z.string().min(1),
92
- currentReality: z.string().min(1),
93
- dueDate: z.string().datetime().optional(),
94
- actionSteps: z.array(z.object({
95
- title: z.string().min(1),
96
- status: z.enum(['pending', 'in_progress', 'done', 'blocked']),
97
- currentReality: z.string().optional(),
98
- })).default([]),
99
- createdAt: z.string().datetime(),
100
- updatedAt: z.string().datetime(),
101
- });
102
-
103
- type Chart = z.infer<typeof ChartSchema>; // TypeScript type auto-generated
104
- ```
105
-
106
- ### MCP Tool Argument Validation
107
-
108
- ```typescript
109
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
110
- import { z } from 'zod';
111
-
112
- const server = new McpServer({ name: 'coaiajs', version: '1.0.0' });
113
-
114
- // Zod schemas ARE the MCP tool input schemas — zero duplication
115
- server.tool(
116
- 'create_chart',
117
- 'Create a structural tension chart',
118
- {
119
- desiredOutcome: z.string().describe('What you want to CREATE'),
120
- currentReality: z.string().describe('Factual assessment of current state'),
121
- dueDate: z.string().datetime().optional().describe('Target date (ISO 8601)'),
122
- actionSteps: z.array(z.string()).optional().describe('Initial action steps'),
123
- },
124
- async ({ desiredOutcome, currentReality, dueDate, actionSteps }) => {
125
- // Arguments are already validated and typed
126
- const chart = await createChart({ desiredOutcome, currentReality, dueDate, actionSteps });
127
- return { content: [{ type: 'text', text: JSON.stringify(chart) }] };
128
- }
129
- );
130
- ```
131
-
132
- ### Pipeline Template Validation
133
-
134
- ```typescript
135
- // Replaces coaiapy's pipeline.py validate_variables()
136
- const PipelineVariable = z.object({
137
- name: z.string().min(1),
138
- type: z.enum(['string', 'number', 'boolean', 'list']).default('string'),
139
- required: z.boolean().default(true),
140
- default: z.unknown().optional(),
141
- choices: z.array(z.unknown()).optional(),
142
- });
143
-
144
- const PipelineTemplate = z.object({
145
- name: z.string().min(1),
146
- version: z.string().default('1.0'),
147
- variables: z.array(PipelineVariable).default([]),
148
- steps: z.array(z.object({
149
- name: z.string().min(1),
150
- observation_type: z.enum(['EVENT', 'SPAN', 'GENERATION']).default('EVENT'),
151
- conditional: z.string().optional(),
152
- })).min(1),
153
- });
154
-
155
- // Validate and get typed result
156
- function loadTemplate(raw: unknown): PipelineTemplate {
157
- return PipelineTemplate.parse(raw); // throws ZodError on invalid
158
- }
159
- ```
160
-
161
- ### Error Handling
162
-
163
- ```typescript
164
- import { z } from 'zod';
165
-
166
- function validateSafe<T>(schema: z.ZodSchema<T>, data: unknown): { valid: true; data: T } | { valid: false; error: string } {
167
- const result = schema.safeParse(data);
168
- if (result.success) {
169
- return { valid: true, data: result.data };
170
- }
171
- // Structured error messages
172
- const messages = result.error.issues.map(i => `${i.path.join('.')}: ${i.message}`);
173
- return { valid: false, error: messages.join('; ') };
174
- }
175
- ```
176
-
177
- ## Integration Plan
178
-
179
- 1. **Shared schemas:** `src/schemas/` directory with reusable Zod schemas
180
- - `chart.ts` — ChartSchema, ActionStepSchema
181
- - `entity.ts` — Entity, Relation schemas (replaces validation.ts)
182
- - `pipeline.ts` — PipelineTemplate, PipelineVariable
183
- - `session.ts` — Session, Trace schemas
184
- 2. **MCP tools:** Direct Zod schemas in tool definitions (no separate validation layer)
185
- 3. **Config validation:** Zod for config file/env var validation at startup
186
- 4. **JSON Schema export:** `toJSONSchema()` for documentation and interop
187
- 5. **Migration:** Delete coaia-narrative's `validation.ts`, import from `@coaiajs/schemas`
188
-
189
- ### @zod/mini for Future Frontend
190
-
191
- If coaiajs adds a web UI, use `@zod/mini` (~1.9KB) for client-side validation with the same schemas.
192
-
193
- ## Version & Ecosystem
194
-
195
- | Metric | Value |
196
- |--------|-------|
197
- | Current version | 4.3.6 (Jan 2026) |
198
- | Weekly downloads | ~100M+ |
199
- | TypeScript | First-class, type inference is the core value |
200
- | Bundle size | ~2KB gzip (core), ~1.9KB (@zod/mini) |
201
- | MCP SDK | Required peer dependency |
202
- | JSON Schema | `toJSONSchema()` built-in |
203
- | Node.js compat | Any (zero native deps) |
204
- | License | MIT |
205
-
206
- ## References
207
-
208
- - npm: https://www.npmjs.com/package/zod
209
- - GitHub: https://github.com/colinhacks/zod
210
- - v4 announcement: https://www.infoq.com/news/2025/08/zod-v4-available/
211
- - What's new in v4: https://basicutils.com/learn/zod/whats-new-in-zod-v4
212
- - MCP SDK peer dep: https://www.npmjs.com/package/@modelcontextprotocol/sdk
package/mcp/config.ts DELETED
@@ -1,196 +0,0 @@
1
- // coaiajs/mcp/config.ts — Feature gating
2
- // Port of coaiapy-mcp/config.py
3
-
4
- export type FeatureLevel = 'MINIMAL' | 'STANDARD' | 'OBSERVABILITY' | 'FULL';
5
-
6
- // All available tool names across all modules
7
- const ALL_TOOLS = new Set([
8
- // Redis (coaiapy-mcp)
9
- 'coaia_tash',
10
- 'coaia_fetch',
11
- // Langfuse traces (coaiapy-mcp)
12
- 'coaia_fuse_trace_create',
13
- 'coaia_fuse_add_observation',
14
- 'coaia_fuse_trace_patch_output',
15
- 'coaia_fuse_trace_get',
16
- 'coaia_fuse_trace_view',
17
- 'coaia_fuse_observation_get',
18
- 'coaia_fuse_traces_list',
19
- 'coaia_fuse_traces_session_view',
20
- // Langfuse comments (coaiapy-mcp)
21
- 'coaia_fuse_comments_list',
22
- 'coaia_fuse_comments_get',
23
- 'coaia_fuse_comments_create',
24
- // Langfuse prompts (coaiapy-mcp)
25
- 'coaia_fuse_prompts_list',
26
- 'coaia_fuse_prompts_get',
27
- // Langfuse datasets (coaiapy-mcp)
28
- 'coaia_fuse_datasets_list',
29
- 'coaia_fuse_datasets_get',
30
- // Score configs (coaiapy-mcp)
31
- 'coaia_fuse_score_configs_list',
32
- 'coaia_fuse_score_configs_get',
33
- 'coaia_fuse_score_apply',
34
- // Media (coaiapy-mcp, FULL only)
35
- 'coaia_fuse_media_upload',
36
- 'coaia_fuse_media_get',
37
- // Narrative (coaia-narrative, 28 tools)
38
- 'create_structural_tension_chart',
39
- 'telescope_action_step',
40
- 'mark_action_complete',
41
- 'get_chart_progress',
42
- 'list_active_charts',
43
- 'get_chart',
44
- 'get_action_step',
45
- 'update_action_progress',
46
- 'update_current_reality',
47
- 'manage_action_step',
48
- 'add_action_step',
49
- 'remove_action_step',
50
- 'update_desired_outcome',
51
- 'perform_mmot_evaluation',
52
- 'init_llm_guidance',
53
- 'create_narrative_beat',
54
- 'telescope_narrative_beat',
55
- 'list_narrative_beats',
56
- 'add_observations',
57
- 'create_entities',
58
- 'create_relations',
59
- 'search_nodes',
60
- 'open_nodes',
61
- 'read_graph',
62
- 'delete_entities',
63
- 'delete_relations',
64
- 'delete_observations',
65
- 'merge_entities',
66
- // PDE (coaia-pde, 10 tools)
67
- 'pde_decompose',
68
- 'pde_parse_response',
69
- 'pde_get',
70
- 'pde_list',
71
- 'pde_export_markdown',
72
- 'import_pde',
73
- 'create_stc_from_pde',
74
- 'pde_sessions_list',
75
- 'pde_sessions_create',
76
- 'pde_sessions_update',
77
- // Planning (coaia-planning, 6 tools)
78
- 'parse_plan',
79
- 'plan_to_stc',
80
- 'sync_plans',
81
- 'trace_plan',
82
- 'pde_to_plan',
83
- 'list_plans',
84
- ]);
85
-
86
- const MINIMAL_TOOLS = new Set([
87
- 'coaia_tash',
88
- 'coaia_fetch',
89
- 'coaia_fuse_trace_create',
90
- 'coaia_fuse_add_observation',
91
- 'coaia_fuse_trace_patch_output',
92
- 'coaia_fuse_trace_get',
93
- 'coaia_fuse_trace_view',
94
- 'coaia_fuse_observation_get',
95
- 'coaia_fuse_traces_list',
96
- 'coaia_fuse_traces_session_view',
97
- 'coaia_fuse_comments_list',
98
- 'coaia_fuse_comments_get',
99
- 'coaia_fuse_comments_create',
100
- 'coaia_fuse_prompts_list',
101
- 'coaia_fuse_prompts_get',
102
- 'coaia_fuse_datasets_list',
103
- 'coaia_fuse_datasets_get',
104
- 'coaia_fuse_score_configs_list',
105
- 'coaia_fuse_score_configs_get',
106
- 'coaia_fuse_score_apply',
107
- ]);
108
-
109
- const STANDARD_TOOLS = new Set([
110
- ...MINIMAL_TOOLS,
111
- // Narrative STC tools
112
- 'create_structural_tension_chart',
113
- 'telescope_action_step',
114
- 'mark_action_complete',
115
- 'get_chart_progress',
116
- 'list_active_charts',
117
- 'get_chart',
118
- 'get_action_step',
119
- 'update_action_progress',
120
- 'update_current_reality',
121
- 'manage_action_step',
122
- 'add_action_step',
123
- 'remove_action_step',
124
- 'update_desired_outcome',
125
- 'perform_mmot_evaluation',
126
- 'init_llm_guidance',
127
- 'create_narrative_beat',
128
- 'telescope_narrative_beat',
129
- 'list_narrative_beats',
130
- // KG tools
131
- 'add_observations',
132
- 'create_entities',
133
- 'create_relations',
134
- 'search_nodes',
135
- 'open_nodes',
136
- 'read_graph',
137
- 'delete_entities',
138
- 'delete_relations',
139
- 'delete_observations',
140
- 'merge_entities',
141
- // PDE tools
142
- 'pde_decompose',
143
- 'pde_parse_response',
144
- 'pde_get',
145
- 'pde_list',
146
- 'pde_export_markdown',
147
- 'import_pde',
148
- 'create_stc_from_pde',
149
- 'pde_sessions_list',
150
- 'pde_sessions_create',
151
- 'pde_sessions_update',
152
- // Planning tools
153
- 'parse_plan',
154
- 'plan_to_stc',
155
- 'sync_plans',
156
- 'trace_plan',
157
- 'pde_to_plan',
158
- 'list_plans',
159
- ]);
160
-
161
- const FEATURE_SETS: Record<FeatureLevel, Set<string>> = {
162
- MINIMAL: MINIMAL_TOOLS,
163
- STANDARD: STANDARD_TOOLS,
164
- OBSERVABILITY: STANDARD_TOOLS,
165
- FULL: ALL_TOOLS,
166
- };
167
-
168
- export class FeatureConfig {
169
- private level: FeatureLevel;
170
- private enabledTools: Set<string>;
171
-
172
- constructor(level?: FeatureLevel) {
173
- const envLevel = (level ?? process.env['COAIAJS_FEATURES'] ?? 'STANDARD').toUpperCase() as FeatureLevel;
174
- this.level = envLevel in FEATURE_SETS ? envLevel : 'STANDARD';
175
- this.enabledTools = FEATURE_SETS[this.level];
176
- }
177
-
178
- isToolEnabled(toolName: string): boolean {
179
- return this.enabledTools.has(toolName);
180
- }
181
-
182
- getEnabledTools(): Set<string> {
183
- return new Set(this.enabledTools);
184
- }
185
-
186
- getFeatureLevel(): FeatureLevel {
187
- return this.level;
188
- }
189
-
190
- getStats(): { tools: number; level: FeatureLevel } {
191
- return {
192
- tools: this.enabledTools.size,
193
- level: this.level,
194
- };
195
- }
196
- }