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,361 @@
|
|
|
1
|
+
// coaiajs/src/pipeline/template-engine.ts — Pipeline template engine
|
|
2
|
+
// Port of coaiapy's pipeline.py + mobile_template.py
|
|
3
|
+
import { readFileSync, writeFileSync, existsSync, readdirSync, mkdirSync } from 'node:fs';
|
|
4
|
+
import { join, extname } from 'node:path';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
6
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
7
|
+
import * as yaml from 'js-yaml';
|
|
8
|
+
// ─── MobileTemplateEngine ───────────────────────────────────────────
|
|
9
|
+
// Lightweight template engine replacing Jinja2 for TypeScript
|
|
10
|
+
const VARIABLE_RE = /\{\{([^}]+)\}\}/g;
|
|
11
|
+
const CONDITION_RE = /\{%\s*if\s+([^%]+)%\}(.*?)\{%\s*endif\s*%\}/gs;
|
|
12
|
+
const BUILTIN_FUNCTIONS = {
|
|
13
|
+
uuid4: () => uuidv4(),
|
|
14
|
+
now: () => new Date().toISOString(),
|
|
15
|
+
timestamp: () => new Date().toISOString(),
|
|
16
|
+
mobile_id: () => `mobile_${uuidv4().slice(0, 8)}`,
|
|
17
|
+
touch_timestamp: () => new Date().toLocaleTimeString('en-US', { hour12: false }),
|
|
18
|
+
};
|
|
19
|
+
export class MobileTemplateEngine {
|
|
20
|
+
renderString(text, variables) {
|
|
21
|
+
if (!text)
|
|
22
|
+
return '';
|
|
23
|
+
let result = processConditionals(text, variables);
|
|
24
|
+
result = processVariables(result, variables);
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
renderDict(data, variables) {
|
|
28
|
+
if (!data || typeof data !== 'object')
|
|
29
|
+
return data;
|
|
30
|
+
const result = {};
|
|
31
|
+
for (const [key, value] of Object.entries(data)) {
|
|
32
|
+
if (typeof value === 'string') {
|
|
33
|
+
result[key] = this.renderString(value, variables);
|
|
34
|
+
}
|
|
35
|
+
else if (Array.isArray(value)) {
|
|
36
|
+
result[key] = this.renderList(value, variables);
|
|
37
|
+
}
|
|
38
|
+
else if (value !== null && typeof value === 'object') {
|
|
39
|
+
result[key] = this.renderDict(value, variables);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
result[key] = value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
renderList(data, variables) {
|
|
48
|
+
return data.map((item) => {
|
|
49
|
+
if (typeof item === 'string')
|
|
50
|
+
return this.renderString(item, variables);
|
|
51
|
+
if (Array.isArray(item))
|
|
52
|
+
return this.renderList(item, variables);
|
|
53
|
+
if (item !== null && typeof item === 'object') {
|
|
54
|
+
return this.renderDict(item, variables);
|
|
55
|
+
}
|
|
56
|
+
return item;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// ─── Template Processing ────────────────────────────────────────────
|
|
61
|
+
function processVariables(content, variables) {
|
|
62
|
+
return content.replace(VARIABLE_RE, (_match, expr) => {
|
|
63
|
+
const trimmed = expr.trim();
|
|
64
|
+
// Function calls: uuid4(), now(), etc.
|
|
65
|
+
if (trimmed.endsWith('()')) {
|
|
66
|
+
const fnName = trimmed.slice(0, -2);
|
|
67
|
+
if (fnName in BUILTIN_FUNCTIONS)
|
|
68
|
+
return BUILTIN_FUNCTIONS[fnName]();
|
|
69
|
+
}
|
|
70
|
+
// Filters: variable|title, variable|upper
|
|
71
|
+
if (trimmed.includes('|')) {
|
|
72
|
+
const [varName, filterName] = trimmed.split('|').map((s) => s.trim());
|
|
73
|
+
const val = variables[varName];
|
|
74
|
+
if (val !== undefined)
|
|
75
|
+
return applyFilter(val, filterName);
|
|
76
|
+
return `[${varName}]`;
|
|
77
|
+
}
|
|
78
|
+
// "variable or default" expressions
|
|
79
|
+
if (trimmed.includes(' or ')) {
|
|
80
|
+
const parts = trimmed.split(' or ').map((p) => p.trim());
|
|
81
|
+
for (const part of parts) {
|
|
82
|
+
const unquoted = part.replace(/^['"]|['"]$/g, '');
|
|
83
|
+
if (part in variables && variables[part] != null)
|
|
84
|
+
return variables[part];
|
|
85
|
+
if (part.startsWith("'") || part.startsWith('"'))
|
|
86
|
+
return unquoted;
|
|
87
|
+
}
|
|
88
|
+
return parts[parts.length - 1].replace(/^['"]|['"]$/g, '');
|
|
89
|
+
}
|
|
90
|
+
// Simple lookup
|
|
91
|
+
if (trimmed in variables)
|
|
92
|
+
return variables[trimmed] ?? '';
|
|
93
|
+
return `[${trimmed}]`;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function processConditionals(content, variables) {
|
|
97
|
+
return content.replace(CONDITION_RE, (_match, condition, body) => {
|
|
98
|
+
return evaluateCondition(condition.trim(), variables) ? body : '';
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function evaluateCondition(condition, variables) {
|
|
102
|
+
if (condition.startsWith('not ')) {
|
|
103
|
+
const varName = condition.slice(4).trim();
|
|
104
|
+
return !isTruthy(variables[varName]);
|
|
105
|
+
}
|
|
106
|
+
if (condition.includes('==')) {
|
|
107
|
+
const [left, right] = condition.split('==').map((s) => s.trim().replace(/^['"]|['"]$/g, ''));
|
|
108
|
+
return String(variables[left] ?? left) === right;
|
|
109
|
+
}
|
|
110
|
+
if (condition.includes('!=')) {
|
|
111
|
+
const [left, right] = condition.split('!=').map((s) => s.trim().replace(/^['"]|['"]$/g, ''));
|
|
112
|
+
return String(variables[left] ?? left) !== right;
|
|
113
|
+
}
|
|
114
|
+
return isTruthy(variables[condition]);
|
|
115
|
+
}
|
|
116
|
+
function isTruthy(value) {
|
|
117
|
+
if (value == null || value === '' || (Array.isArray(value) && value.length === 0))
|
|
118
|
+
return false;
|
|
119
|
+
if (typeof value === 'boolean')
|
|
120
|
+
return value;
|
|
121
|
+
if (typeof value === 'string')
|
|
122
|
+
return !['false', '0', 'no', 'off', 'disabled'].includes(value.toLowerCase());
|
|
123
|
+
return Boolean(value);
|
|
124
|
+
}
|
|
125
|
+
function applyFilter(value, filter) {
|
|
126
|
+
switch (filter) {
|
|
127
|
+
case 'title': return value.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
128
|
+
case 'upper': return value.toUpperCase();
|
|
129
|
+
case 'lower': return value.toLowerCase();
|
|
130
|
+
case 'capitalize': return value.charAt(0).toUpperCase() + value.slice(1);
|
|
131
|
+
case 'strip': return value.trim();
|
|
132
|
+
default: return value;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// ─── TemplateLoader ─────────────────────────────────────────────────
|
|
136
|
+
export class TemplateLoader {
|
|
137
|
+
searchPaths;
|
|
138
|
+
constructor() {
|
|
139
|
+
this.searchPaths = this.getSearchPaths();
|
|
140
|
+
}
|
|
141
|
+
getSearchPaths() {
|
|
142
|
+
const paths = [];
|
|
143
|
+
const projectPath = join(process.cwd(), '.coaia', 'templates');
|
|
144
|
+
if (existsSync(projectPath))
|
|
145
|
+
paths.push(projectPath);
|
|
146
|
+
const userPath = join(homedir(), '.coaia', 'templates');
|
|
147
|
+
if (existsSync(userPath))
|
|
148
|
+
paths.push(userPath);
|
|
149
|
+
return paths;
|
|
150
|
+
}
|
|
151
|
+
listTemplates(includePath = false) {
|
|
152
|
+
const templates = [];
|
|
153
|
+
const seen = new Set();
|
|
154
|
+
for (const searchPath of this.searchPaths) {
|
|
155
|
+
if (!existsSync(searchPath))
|
|
156
|
+
continue;
|
|
157
|
+
for (const file of readdirSync(searchPath)) {
|
|
158
|
+
const ext = extname(file);
|
|
159
|
+
if (ext !== '.json' && ext !== '.yaml' && ext !== '.yml')
|
|
160
|
+
continue;
|
|
161
|
+
const stem = file.replace(ext, '');
|
|
162
|
+
if (seen.has(stem))
|
|
163
|
+
continue;
|
|
164
|
+
try {
|
|
165
|
+
const template = this.loadTemplate(stem);
|
|
166
|
+
if (template) {
|
|
167
|
+
const info = {
|
|
168
|
+
name: template.name,
|
|
169
|
+
description: template.description,
|
|
170
|
+
version: template.version,
|
|
171
|
+
author: template.author,
|
|
172
|
+
};
|
|
173
|
+
if (includePath)
|
|
174
|
+
info.path = join(searchPath, file);
|
|
175
|
+
templates.push(info);
|
|
176
|
+
seen.add(stem);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return templates;
|
|
185
|
+
}
|
|
186
|
+
loadTemplate(name) {
|
|
187
|
+
for (const searchPath of this.searchPaths) {
|
|
188
|
+
// Try JSON
|
|
189
|
+
const jsonFile = join(searchPath, `${name}.json`);
|
|
190
|
+
if (existsSync(jsonFile)) {
|
|
191
|
+
try {
|
|
192
|
+
const data = JSON.parse(readFileSync(jsonFile, 'utf-8'));
|
|
193
|
+
return parsePipelineTemplate(data);
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Try YAML
|
|
200
|
+
for (const ext of ['.yaml', '.yml']) {
|
|
201
|
+
const yamlFile = join(searchPath, `${name}${ext}`);
|
|
202
|
+
if (existsSync(yamlFile)) {
|
|
203
|
+
try {
|
|
204
|
+
const data = yaml.load(readFileSync(yamlFile, 'utf-8'));
|
|
205
|
+
return parsePipelineTemplate(data);
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
saveTemplate(template, location = 'user') {
|
|
216
|
+
const savePath = location === 'project'
|
|
217
|
+
? join(process.cwd(), '.coaia', 'templates')
|
|
218
|
+
: join(homedir(), '.coaia', 'templates');
|
|
219
|
+
mkdirSync(savePath, { recursive: true });
|
|
220
|
+
const data = serializePipelineTemplate(template);
|
|
221
|
+
if (!data.createdAt)
|
|
222
|
+
data.createdAt = new Date().toISOString();
|
|
223
|
+
const filePath = join(savePath, `${template.name}.json`);
|
|
224
|
+
writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// ─── TemplateRenderer ───────────────────────────────────────────────
|
|
228
|
+
export class TemplateRenderer {
|
|
229
|
+
engine = new MobileTemplateEngine();
|
|
230
|
+
renderTemplate(template, variables) {
|
|
231
|
+
const errors = validateVariables(template, variables);
|
|
232
|
+
if (errors.length)
|
|
233
|
+
throw new Error(`Template validation failed: ${errors.join('; ')}`);
|
|
234
|
+
const finalVars = mergeDefaults(template, variables);
|
|
235
|
+
const rendered = [];
|
|
236
|
+
for (const step of template.steps) {
|
|
237
|
+
if (step.conditional) {
|
|
238
|
+
const expanded = this.engine.renderString(step.conditional, finalVars);
|
|
239
|
+
if (!expanded.trim())
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
rendered.push({
|
|
243
|
+
name: this.engine.renderString(step.name, finalVars),
|
|
244
|
+
observationType: step.observationType,
|
|
245
|
+
description: step.description ? this.engine.renderString(step.description, finalVars) : undefined,
|
|
246
|
+
parent: step.parent ? this.engine.renderString(step.parent, finalVars) : undefined,
|
|
247
|
+
variables: step.variables
|
|
248
|
+
? this.engine.renderDict(step.variables, finalVars)
|
|
249
|
+
: undefined,
|
|
250
|
+
metadata: step.metadata
|
|
251
|
+
? this.engine.renderDict(step.metadata, finalVars)
|
|
252
|
+
: undefined,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return rendered;
|
|
256
|
+
}
|
|
257
|
+
renderWithJudgeIntegration(template, variables, enableJudge = false) {
|
|
258
|
+
const observations = this.renderTemplate(template, variables);
|
|
259
|
+
if (!enableJudge)
|
|
260
|
+
return observations;
|
|
261
|
+
return observations.map((obs) => {
|
|
262
|
+
const name = (obs.name ?? '').toLowerCase();
|
|
263
|
+
const desc = (obs.description ?? '').toLowerCase();
|
|
264
|
+
const indicators = ['judge', 'evaluation', 'assess', 'scoring', 'rating'];
|
|
265
|
+
const isJudge = indicators.some((i) => name.includes(i) || desc.includes(i));
|
|
266
|
+
if (isJudge) {
|
|
267
|
+
return {
|
|
268
|
+
...obs,
|
|
269
|
+
metadata: {
|
|
270
|
+
...obs.metadata,
|
|
271
|
+
judge_integration_ready: true,
|
|
272
|
+
judge_api_placeholder: true,
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
return obs;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// ─── Helpers ────────────────────────────────────────────────────────
|
|
281
|
+
function parsePipelineTemplate(data) {
|
|
282
|
+
return {
|
|
283
|
+
name: String(data.name),
|
|
284
|
+
version: String(data.version ?? '1.0'),
|
|
285
|
+
description: String(data.description ?? ''),
|
|
286
|
+
author: data.author,
|
|
287
|
+
createdAt: data.created_at ?? data.createdAt,
|
|
288
|
+
variables: (data.variables ?? []).map((v) => ({
|
|
289
|
+
name: String(v.name),
|
|
290
|
+
type: String(v.type ?? 'string'),
|
|
291
|
+
required: v.required !== false,
|
|
292
|
+
default: v.default,
|
|
293
|
+
description: v.description,
|
|
294
|
+
choices: v.choices,
|
|
295
|
+
})),
|
|
296
|
+
steps: (data.steps ?? []).map((s) => ({
|
|
297
|
+
name: String(s.name),
|
|
298
|
+
observationType: String(s.observation_type ?? s.observationType ?? 'EVENT'),
|
|
299
|
+
description: s.description,
|
|
300
|
+
parent: s.parent,
|
|
301
|
+
variables: (s.variables ?? {}),
|
|
302
|
+
metadata: (s.metadata ?? {}),
|
|
303
|
+
conditional: s.conditional,
|
|
304
|
+
})),
|
|
305
|
+
extends: data.extends,
|
|
306
|
+
metadata: (data.metadata ?? {}),
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function serializePipelineTemplate(t) {
|
|
310
|
+
return {
|
|
311
|
+
name: t.name,
|
|
312
|
+
version: t.version,
|
|
313
|
+
description: t.description,
|
|
314
|
+
author: t.author,
|
|
315
|
+
createdAt: t.createdAt,
|
|
316
|
+
extends: t.extends,
|
|
317
|
+
metadata: t.metadata,
|
|
318
|
+
variables: (t.variables ?? []).map((v) => ({
|
|
319
|
+
name: v.name,
|
|
320
|
+
type: v.type,
|
|
321
|
+
required: v.required,
|
|
322
|
+
default: v.default,
|
|
323
|
+
description: v.description,
|
|
324
|
+
choices: v.choices,
|
|
325
|
+
})),
|
|
326
|
+
steps: (t.steps ?? []).map((s) => ({
|
|
327
|
+
name: s.name,
|
|
328
|
+
observation_type: s.observationType,
|
|
329
|
+
description: s.description,
|
|
330
|
+
parent: s.parent,
|
|
331
|
+
variables: s.variables,
|
|
332
|
+
metadata: s.metadata,
|
|
333
|
+
conditional: s.conditional,
|
|
334
|
+
})),
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function validateVariables(template, provided) {
|
|
338
|
+
const errors = [];
|
|
339
|
+
for (const v of template.variables ?? []) {
|
|
340
|
+
if (v.required && v.default == null && !(v.name in provided)) {
|
|
341
|
+
errors.push(`Required variable '${v.name}' not provided`);
|
|
342
|
+
}
|
|
343
|
+
if (v.choices && v.name in provided && !v.choices.includes(provided[v.name])) {
|
|
344
|
+
errors.push(`Variable '${v.name}' must be one of: ${v.choices.join(', ')}`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return errors;
|
|
348
|
+
}
|
|
349
|
+
function mergeDefaults(template, provided) {
|
|
350
|
+
const result = {};
|
|
351
|
+
for (const v of template.variables ?? []) {
|
|
352
|
+
if (v.name in provided) {
|
|
353
|
+
result[v.name] = provided[v.name];
|
|
354
|
+
}
|
|
355
|
+
else if (v.default != null) {
|
|
356
|
+
result[v.name] = String(v.default);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return result;
|
|
360
|
+
}
|
|
361
|
+
//# sourceMappingURL=template-engine.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planning module — Plan Parser + Plan→STC transformation
|
|
3
|
+
*/
|
|
4
|
+
export { parsePlan, parsePlanContent, planToSTC, exportToJSONL, decompositionResultToPlan, } from './plan-parser.js';
|
|
5
|
+
export { PLANNING_MCP_TOOLS } from './mcp-tools.js';
|
|
6
|
+
export { handlePlanningTool } from './mcp-handlers.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planning module — Plan Parser + Plan→STC transformation
|
|
3
|
+
*/
|
|
4
|
+
export { parsePlan, parsePlanContent, planToSTC, exportToJSONL, decompositionResultToPlan, } from './plan-parser.js';
|
|
5
|
+
export { PLANNING_MCP_TOOLS } from './mcp-tools.js';
|
|
6
|
+
export { handlePlanningTool } from './mcp-handlers.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planning MCP tool dispatch — handles each tool by calling plan-parser functions
|
|
3
|
+
* Ported from coaia-planning/src/index.ts handler logic
|
|
4
|
+
*/
|
|
5
|
+
import type { McpToolResult } from '../types.js';
|
|
6
|
+
export declare function handlePlanningTool(name: string, args: Record<string, unknown>): Promise<McpToolResult>;
|
|
7
|
+
//# sourceMappingURL=mcp-handlers.d.ts.map
|