coaiajs 0.2.1 → 0.3.1

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 (172) hide show
  1. package/KINSHIP.md +1 -1
  2. package/README.md +191 -75
  3. package/dist/mcp/config.d.ts.map +1 -0
  4. package/dist/mcp/config.js +0 -2
  5. package/dist/mcp/config.js.map +1 -0
  6. package/dist/mcp/prompts.d.ts.map +1 -0
  7. package/dist/mcp/prompts.js.map +1 -0
  8. package/dist/mcp/resources.d.ts.map +1 -0
  9. package/dist/mcp/resources.js.map +1 -0
  10. package/dist/mcp/server.d.ts.map +1 -0
  11. package/dist/mcp/server.js +3 -2
  12. package/dist/mcp/server.js.map +1 -0
  13. package/dist/mcp/tools/coaiapy-tools.d.ts.map +1 -0
  14. package/dist/mcp/tools/coaiapy-tools.js.map +1 -0
  15. package/dist/mcp/tools/index.d.ts.map +1 -0
  16. package/dist/mcp/tools/index.js.map +1 -0
  17. package/dist/src/audio.d.ts.map +1 -0
  18. package/dist/src/audio.js.map +1 -0
  19. package/dist/src/cli-helpers.d.ts.map +1 -0
  20. package/dist/src/cli-helpers.js.map +1 -0
  21. package/dist/src/cli.d.ts.map +1 -0
  22. package/dist/src/cli.js +2 -1
  23. package/dist/src/cli.js.map +1 -0
  24. package/dist/src/config.d.ts.map +1 -0
  25. package/dist/src/config.js.map +1 -0
  26. package/dist/src/environment.d.ts.map +1 -0
  27. package/dist/src/environment.js.map +1 -0
  28. package/dist/src/github.d.ts.map +1 -0
  29. package/dist/src/github.js.map +1 -0
  30. package/dist/src/index.d.ts +1 -0
  31. package/dist/src/index.d.ts.map +1 -0
  32. package/dist/src/index.js +1 -0
  33. package/dist/src/index.js.map +1 -0
  34. package/dist/src/langfuse/client.d.ts.map +1 -0
  35. package/dist/src/langfuse/client.js.map +1 -0
  36. package/dist/src/langfuse/comments.d.ts.map +1 -0
  37. package/dist/src/langfuse/comments.js.map +1 -0
  38. package/dist/src/langfuse/datasets.d.ts.map +1 -0
  39. package/dist/src/langfuse/datasets.js.map +1 -0
  40. package/dist/src/langfuse/index.d.ts.map +1 -0
  41. package/dist/src/langfuse/index.js.map +1 -0
  42. package/dist/src/langfuse/media.d.ts.map +1 -0
  43. package/dist/src/langfuse/media.js.map +1 -0
  44. package/dist/src/langfuse/observations.d.ts.map +1 -0
  45. package/dist/src/langfuse/observations.js.map +1 -0
  46. package/dist/src/langfuse/prompts.d.ts.map +1 -0
  47. package/dist/src/langfuse/prompts.js.map +1 -0
  48. package/dist/src/langfuse/scores.d.ts.map +1 -0
  49. package/dist/src/langfuse/scores.js.map +1 -0
  50. package/dist/src/langfuse/traces.d.ts.map +1 -0
  51. package/dist/src/langfuse/traces.js.map +1 -0
  52. package/dist/src/llm.d.ts.map +1 -0
  53. package/dist/src/llm.js.map +1 -0
  54. package/dist/src/narrative/graph-manager.d.ts.map +1 -0
  55. package/dist/src/narrative/graph-manager.js.map +1 -0
  56. package/dist/src/narrative/index.d.ts.map +1 -0
  57. package/dist/src/narrative/index.js.map +1 -0
  58. package/dist/src/narrative/markdown-export.d.ts.map +1 -0
  59. package/dist/src/narrative/markdown-export.js.map +1 -0
  60. package/dist/src/narrative/tool-definitions.d.ts.map +1 -0
  61. package/dist/src/narrative/tool-definitions.js.map +1 -0
  62. package/dist/src/narrative/tool-handlers.d.ts.map +1 -0
  63. package/dist/src/narrative/tool-handlers.js.map +1 -0
  64. package/dist/src/narrative/types.d.ts.map +1 -0
  65. package/dist/src/narrative/types.js.map +1 -0
  66. package/dist/src/narrative/validation.d.ts.map +1 -0
  67. package/dist/src/narrative/validation.js.map +1 -0
  68. package/dist/src/pde/index.d.ts.map +1 -0
  69. package/dist/src/pde/index.js.map +1 -0
  70. package/dist/src/pde/mcp-handlers.d.ts.map +1 -0
  71. package/dist/src/pde/mcp-handlers.js.map +1 -0
  72. package/dist/src/pde/mcp-tools.d.ts.map +1 -0
  73. package/dist/src/pde/mcp-tools.js.map +1 -0
  74. package/dist/src/pde/session-manager.d.ts.map +1 -0
  75. package/dist/src/pde/session-manager.js.map +1 -0
  76. package/dist/src/pde/stc-mapper.d.ts.map +1 -0
  77. package/dist/src/pde/stc-mapper.js.map +1 -0
  78. package/dist/src/pipeline/index.d.ts.map +1 -0
  79. package/dist/src/pipeline/index.js.map +1 -0
  80. package/dist/src/pipeline/template-engine.d.ts.map +1 -0
  81. package/dist/src/pipeline/template-engine.js.map +1 -0
  82. package/dist/src/planning/index.d.ts.map +1 -0
  83. package/dist/src/planning/index.js.map +1 -0
  84. package/dist/src/planning/mcp-handlers.d.ts.map +1 -0
  85. package/dist/src/planning/mcp-handlers.js.map +1 -0
  86. package/dist/src/planning/mcp-tools.d.ts.map +1 -0
  87. package/dist/src/planning/mcp-tools.js.map +1 -0
  88. package/dist/src/planning/plan-parser.d.ts.map +1 -0
  89. package/dist/src/planning/plan-parser.js.map +1 -0
  90. package/dist/src/redis.d.ts.map +1 -0
  91. package/dist/src/redis.js.map +1 -0
  92. package/dist/src/types.d.ts.map +1 -0
  93. package/dist/src/types.js.map +1 -0
  94. package/dist/src/version.d.ts +3 -0
  95. package/dist/src/version.d.ts.map +1 -0
  96. package/dist/src/version.js +33 -0
  97. package/dist/src/version.js.map +1 -0
  98. package/llms-full.txt +361 -0
  99. package/llms.txt +43 -0
  100. package/package.json +79 -12
  101. package/.claude/settings.local.json +0 -16
  102. package/articles/academic/NOTES.md +0 -1
  103. package/articles/academic/README.md +0 -1
  104. package/articles/academic/creative-orientation-vs-problem-solving.md +0 -177
  105. package/articles/academic/jsonl-knowledge-graphs-agent-memory.md +0 -142
  106. package/articles/academic/langfuse-observability-llm-pipelines.md +0 -144
  107. package/articles/academic/medicine-wheel-software-architecture.md +0 -163
  108. package/articles/academic/mmot-autonomous-agents.md +0 -156
  109. package/articles/academic/model-context-protocol-interagent.md +0 -161
  110. package/articles/academic/pde-prompt-decomposition.md +0 -186
  111. package/articles/academic/structural-tension-in-ai-agents.md +0 -134
  112. package/articles/reviews/mcp-protocol-design-review.md +0 -170
  113. package/articles/reviews/observability-ai-systems-review.md +0 -176
  114. package/articles/reviews/prompt-engineering-decomposition-review.md +0 -184
  115. package/articles/surveys/agent-orchestration-survey.md +0 -186
  116. package/articles/surveys/knowledge-graph-storage-survey.md +0 -204
  117. package/articles/surveys/structural-tension-methodology-survey.md +0 -154
  118. package/articles/technical/aws-sdk-v3-polly.md +0 -270
  119. package/articles/technical/commander-cli-framework.md +0 -262
  120. package/articles/technical/dotenv-config-patterns.md +0 -360
  121. package/articles/technical/ioredis-vs-redis.md +0 -142
  122. package/articles/technical/langfuse-js-sdk-vs-rest.md +0 -191
  123. package/articles/technical/mcp-sdk-typescript.md +0 -291
  124. package/articles/technical/octokit-github-api.md +0 -293
  125. package/articles/technical/openai-sdk-modern.md +0 -231
  126. package/articles/technical/yaml-parsing-node.md +0 -266
  127. package/articles/technical/zod-runtime-validation.md +0 -212
  128. package/mcp/config.ts +0 -225
  129. package/mcp/prompts.ts +0 -131
  130. package/mcp/resources.ts +0 -84
  131. package/mcp/server.ts +0 -518
  132. package/mcp/tools/coaiapy-tools.ts +0 -366
  133. package/mcp/tools/index.ts +0 -4
  134. package/src/audio.ts +0 -76
  135. package/src/cli-helpers.ts +0 -86
  136. package/src/cli.ts +0 -1260
  137. package/src/config.ts +0 -207
  138. package/src/environment.ts +0 -171
  139. package/src/github.ts +0 -143
  140. package/src/index.ts +0 -82
  141. package/src/langfuse/client.ts +0 -105
  142. package/src/langfuse/comments.ts +0 -52
  143. package/src/langfuse/datasets.ts +0 -178
  144. package/src/langfuse/index.ts +0 -37
  145. package/src/langfuse/media.ts +0 -193
  146. package/src/langfuse/observations.ts +0 -155
  147. package/src/langfuse/prompts.ts +0 -157
  148. package/src/langfuse/scores.ts +0 -456
  149. package/src/langfuse/traces.ts +0 -353
  150. package/src/llm.ts +0 -106
  151. package/src/narrative/graph-manager.ts +0 -1358
  152. package/src/narrative/index.ts +0 -188
  153. package/src/narrative/markdown-export.ts +0 -535
  154. package/src/narrative/tool-definitions.ts +0 -635
  155. package/src/narrative/tool-handlers.ts +0 -528
  156. package/src/narrative/types.ts +0 -9
  157. package/src/narrative/validation.ts +0 -179
  158. package/src/pde/index.ts +0 -34
  159. package/src/pde/mcp-handlers.ts +0 -359
  160. package/src/pde/mcp-tools.ts +0 -201
  161. package/src/pde/session-manager.ts +0 -248
  162. package/src/pde/stc-mapper.ts +0 -298
  163. package/src/pipeline/index.ts +0 -7
  164. package/src/pipeline/template-engine.ts +0 -398
  165. package/src/planning/index.ts +0 -32
  166. package/src/planning/mcp-handlers.ts +0 -369
  167. package/src/planning/mcp-tools.ts +0 -155
  168. package/src/planning/plan-parser.ts +0 -587
  169. package/src/redis.ts +0 -111
  170. package/src/types.ts +0 -281
  171. package/test/config.test.mjs +0 -93
  172. package/tsconfig.json +0 -26
package/src/types.ts DELETED
@@ -1,281 +0,0 @@
1
- // coaiajs/src/types.ts — Shared types
2
- // Union of coaia-narrative + coaia-pde + coaia-planning type systems
3
-
4
- // ─── Knowledge Graph Core ────────────────────────────────────────────
5
-
6
- export interface Entity {
7
- name: string;
8
- entityType: string;
9
- observations: string[];
10
- metadata?: EntityMetadata;
11
- }
12
-
13
- export interface EntityMetadata {
14
- dueDate?: string;
15
- chartId?: string;
16
- phase?: 'germination' | 'assimilation' | 'completion';
17
- completionStatus?: boolean;
18
- parentChart?: string;
19
- parentActionStep?: string;
20
- level?: number;
21
- createdAt?: string;
22
- updatedAt?: string;
23
- direction?: string;
24
- confidence?: number;
25
- implicit?: boolean;
26
- pdeId?: string;
27
- act?: number;
28
- type_dramatic?: string;
29
- universes?: string[];
30
- timestamp?: string;
31
- elementsOfPerformance?: Array<{ description: string; type: 'DESIGN' | 'EXECUTION' }>;
32
- mmotEvaluations?: Array<{
33
- phase: 'acknowledge' | 'analyze' | 'update' | 'recommit';
34
- assessment: string;
35
- direction?: 'South' | 'East' | 'West' | 'North';
36
- timestamp: string;
37
- }>;
38
- relationalAlignment?: {
39
- assessed: boolean;
40
- score: number | null;
41
- principles: string[];
42
- };
43
- fourDirections?: {
44
- north_vision: string | null;
45
- east_intention: string | null;
46
- south_emotion: string | null;
47
- west_introspection: string | null;
48
- };
49
- narrative?: {
50
- description: string;
51
- prose: string;
52
- lessons: string[];
53
- };
54
- order?: number;
55
- }
56
-
57
- export interface Relation {
58
- from: string;
59
- to: string;
60
- relationType: string;
61
- metadata?: RelationMetadata;
62
- }
63
-
64
- export interface RelationMetadata {
65
- createdAt?: string;
66
- strength?: number;
67
- context?: string;
68
- description?: string;
69
- }
70
-
71
- export interface KnowledgeGraph {
72
- entities: Entity[];
73
- relations: Relation[];
74
- }
75
-
76
- export interface McpToolResult {
77
- content: Array<{ type: string; text: string }>;
78
- isError?: boolean;
79
- }
80
-
81
- // ─── PDE Types ───────────────────────────────────────────────────────
82
-
83
- export type Urgency = 'immediate' | 'session' | 'persistent';
84
- export type Direction = 'east' | 'south' | 'west' | 'north';
85
-
86
- export interface PrimaryIntent {
87
- action: string;
88
- target: string;
89
- urgency: Urgency;
90
- confidence: number;
91
- }
92
-
93
- export interface SecondaryIntent {
94
- action: string;
95
- target: string;
96
- implicit: boolean;
97
- dependency: string | null;
98
- confidence: number;
99
- }
100
-
101
- export interface ContextRequirements {
102
- files_needed: string[];
103
- tools_required: string[];
104
- assumptions: string[];
105
- }
106
-
107
- export interface ExpectedOutputs {
108
- artifacts: string[];
109
- updates: string[];
110
- communications: string[];
111
- }
112
-
113
- export interface DirectionItem {
114
- text: string;
115
- confidence: number;
116
- implicit: boolean;
117
- }
118
-
119
- export type DirectionMap = Record<Direction, DirectionItem[]>;
120
-
121
- export interface ActionItem {
122
- text: string;
123
- direction: Direction;
124
- dependency: string | null;
125
- completed?: boolean;
126
- }
127
-
128
- export interface AmbiguityFlag {
129
- text: string;
130
- suggestion: string;
131
- }
132
-
133
- export interface DecompositionResult {
134
- primary: PrimaryIntent;
135
- secondary: SecondaryIntent[];
136
- context: ContextRequirements;
137
- outputs: ExpectedOutputs;
138
- directions: DirectionMap;
139
- actionStack: ActionItem[];
140
- ambiguities: AmbiguityFlag[];
141
- }
142
-
143
- export interface StoredDecomposition {
144
- id: string;
145
- timestamp: string;
146
- prompt: string;
147
- result: DecompositionResult;
148
- options: DecompositionOptions;
149
- markdownPath?: string;
150
- }
151
-
152
- export interface DecompositionOptions {
153
- extractImplicit: boolean;
154
- mapDependencies: boolean;
155
- }
156
-
157
- export interface PdeSession {
158
- type: 'pde_session';
159
- sessionId: string;
160
- originalPrompt: string;
161
- masterChartId: string;
162
- pdeDecompositionId?: string;
163
- createdAt: string;
164
- updatedAt: string;
165
- status: 'active' | 'completed' | 'abandoned';
166
- metadata?: Record<string, unknown>;
167
- }
168
-
169
- export const URGENCY_DAYS: Record<string, number> = {
170
- immediate: 1,
171
- session: 7,
172
- persistent: 30,
173
- };
174
-
175
- // ─── Plan Parser Types ───────────────────────────────────────────────
176
-
177
- export interface StructuralElement {
178
- type: 'desired_outcome' | 'current_reality' | 'action_step' | 'observation';
179
- content: string;
180
- confidence: number;
181
- sourceLines: { start: number; end: number };
182
- telescopesInto?: StructuralTensionPlan;
183
- }
184
-
185
- export interface StructuralTensionPlan {
186
- title: string;
187
- filePath: string;
188
- desiredOutcome: StructuralElement | null;
189
- currentReality: StructuralElement | null;
190
- actionSteps: StructuralElement[];
191
- observations: string[];
192
- metadata: {
193
- parsedAt: string;
194
- telescopeLevel: number;
195
- parentAction?: string;
196
- dueDate?: string;
197
- completionStatus: 'pending' | 'in_progress' | 'completed';
198
- };
199
- }
200
-
201
- // ─── Langfuse Types ──────────────────────────────────────────────────
202
-
203
- export interface ScoreCategory {
204
- label: string;
205
- value: number;
206
- }
207
-
208
- export interface ScoreConfig {
209
- name: string;
210
- dataType: 'NUMERIC' | 'CATEGORICAL' | 'BOOLEAN';
211
- description?: string;
212
- categories?: ScoreCategory[];
213
- minValue?: number;
214
- maxValue?: number;
215
- isArchived?: boolean;
216
- }
217
-
218
- // ─── Pipeline Types ──────────────────────────────────────────────────
219
-
220
- export interface PipelineVariable {
221
- name: string;
222
- type: string;
223
- required: boolean;
224
- default?: string;
225
- description?: string;
226
- choices?: string[];
227
- }
228
-
229
- export interface PipelineStep {
230
- name: string;
231
- observationType: string;
232
- description?: string;
233
- parent?: string;
234
- variables?: Record<string, string>;
235
- metadata?: Record<string, unknown>;
236
- conditional?: string;
237
- }
238
-
239
- export interface PipelineTemplate {
240
- name: string;
241
- version: string;
242
- description: string;
243
- author?: string;
244
- createdAt?: string;
245
- variables: PipelineVariable[];
246
- steps: PipelineStep[];
247
- extends?: string;
248
- metadata?: Record<string, unknown>;
249
- }
250
-
251
- // ─── Config Types ────────────────────────────────────────────────────
252
-
253
- export interface CoaiaConfig {
254
- redis?: {
255
- url?: string;
256
- host?: string;
257
- port?: number;
258
- password?: string;
259
- ssl?: boolean;
260
- upstashUrl?: string;
261
- upstashToken?: string;
262
- };
263
- langfuse?: {
264
- publicKey?: string;
265
- secretKey?: string;
266
- baseUrl?: string;
267
- };
268
- openai?: {
269
- apiKey?: string;
270
- model?: string;
271
- };
272
- aws?: {
273
- accessKeyId?: string;
274
- secretAccessKey?: string;
275
- region?: string;
276
- };
277
- github?: {
278
- token?: string;
279
- };
280
- [key: string]: unknown;
281
- }
@@ -1,93 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { mkdirSync, writeFileSync, mkdtempSync } from 'node:fs';
3
- import { join } from 'node:path';
4
- import { tmpdir } from 'node:os';
5
- import test from 'node:test';
6
-
7
- import { findEnvFiles, readConfig, resetConfig } from '../dist/src/config.js';
8
-
9
- const REDIS_ENV_KEYS = [
10
- 'COAIAJS_ENV_PATH',
11
- 'COAIAPY_ENV_PATH',
12
- 'UPSTASH_REDIS_REST_URL',
13
- 'UPSTASH_REDIS_REST_TOKEN',
14
- 'KV_REST_API_URL',
15
- 'KV_REST_API_TOKEN',
16
- 'KV_URL',
17
- 'REDIS_URL',
18
- 'REDIS_HOST',
19
- 'REDIS_PORT',
20
- 'REDIS_PASSWORD',
21
- 'REDIS_SSL',
22
- 'UPSTASH_HOST',
23
- 'UPSTASH_PASSWORD',
24
- ];
25
-
26
- function withCleanEnv(fn) {
27
- const originalEnv = {};
28
- for (const key of REDIS_ENV_KEYS) {
29
- originalEnv[key] = process.env[key];
30
- delete process.env[key];
31
- }
32
- const originalHome = process.env.HOME;
33
- const originalCwd = process.cwd();
34
-
35
- try {
36
- return fn();
37
- } finally {
38
- process.chdir(originalCwd);
39
- process.env.HOME = originalHome;
40
- for (const key of REDIS_ENV_KEYS) {
41
- if (originalEnv[key] === undefined) {
42
- delete process.env[key];
43
- } else {
44
- process.env[key] = originalEnv[key];
45
- }
46
- }
47
- resetConfig();
48
- }
49
- }
50
-
51
- test('loads ~/.coaia/.env when cwd .env is absent', () => withCleanEnv(() => {
52
- const root = mkdtempSync(join(tmpdir(), 'coaiajs-env-'));
53
- const home = join(root, 'home');
54
- const project = join(root, 'project');
55
- mkdirSync(join(home, '.coaia'), { recursive: true });
56
- mkdirSync(project, { recursive: true });
57
- writeFileSync(join(home, '.coaia', '.env'), 'REDIS_HOST=127.0.0.1\nREDIS_PORT=6388\n');
58
-
59
- process.env.HOME = home;
60
- process.chdir(project);
61
-
62
- assert.deepEqual(findEnvFiles(), [join(home, '.coaia', '.env')]);
63
- const cfg = readConfig();
64
-
65
- assert.equal(cfg.redis?.host, '127.0.0.1');
66
- assert.equal(cfg.redis?.port, 6388);
67
- }));
68
-
69
- test('keeps system env above dotenv files', () => withCleanEnv(() => {
70
- const root = mkdtempSync(join(tmpdir(), 'coaiajs-env-priority-'));
71
- mkdirSync(root, { recursive: true });
72
- writeFileSync(join(root, '.env'), 'REDIS_HOST=from-file\nREDIS_PORT=6388\n');
73
- process.chdir(root);
74
- process.env.REDIS_HOST = 'from-system';
75
-
76
- const cfg = readConfig();
77
-
78
- assert.equal(cfg.redis?.host, 'from-system');
79
- assert.equal(cfg.redis?.port, 6388);
80
- }));
81
-
82
- test('uses coaiapy-compatible Redis alias priority', () => withCleanEnv(() => {
83
- process.env.UPSTASH_REDIS_REST_URL = 'https://upstash.example.com';
84
- process.env.UPSTASH_REDIS_REST_TOKEN = 'upstash-token';
85
- process.env.REDIS_URL = 'redis://redis.example.com:6380';
86
- process.env.KV_URL = 'rediss://kv.example.com:6379';
87
-
88
- const cfg = readConfig();
89
-
90
- assert.equal(cfg.redis?.upstashUrl, 'https://upstash.example.com');
91
- assert.equal(cfg.redis?.upstashToken, 'upstash-token');
92
- assert.equal(cfg.redis?.url, 'rediss://kv.example.com:6379');
93
- }));
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "strict": true,
7
- "esModuleInterop": true,
8
- "outDir": "./dist",
9
- "rootDir": ".",
10
- "declaration": true,
11
- "declarationMap": true,
12
- "sourceMap": true,
13
- "skipLibCheck": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "resolveJsonModule": true
16
- },
17
- "include": [
18
- "src/**/*",
19
- "mcp/**/*"
20
- ],
21
- "exclude": [
22
- "node_modules",
23
- "dist",
24
- "tests"
25
- ]
26
- }