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
package/src/types.ts
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
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
|
+
upstashUrl?: string;
|
|
260
|
+
upstashToken?: string;
|
|
261
|
+
};
|
|
262
|
+
langfuse?: {
|
|
263
|
+
publicKey?: string;
|
|
264
|
+
secretKey?: string;
|
|
265
|
+
baseUrl?: string;
|
|
266
|
+
};
|
|
267
|
+
openai?: {
|
|
268
|
+
apiKey?: string;
|
|
269
|
+
model?: string;
|
|
270
|
+
};
|
|
271
|
+
aws?: {
|
|
272
|
+
accessKeyId?: string;
|
|
273
|
+
secretAccessKey?: string;
|
|
274
|
+
region?: string;
|
|
275
|
+
};
|
|
276
|
+
github?: {
|
|
277
|
+
token?: string;
|
|
278
|
+
};
|
|
279
|
+
[key: string]: unknown;
|
|
280
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|