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,326 @@
|
|
|
1
|
+
// coaiajs/mcp/tools/coaiapy-tools.ts — Tool definitions for coaiapy-equivalent tools
|
|
2
|
+
// Port of coaiapy-mcp/server.py tool schemas (20 tools)
|
|
3
|
+
export function getCoaiapyToolDefinitions(featureConfig) {
|
|
4
|
+
const tools = [];
|
|
5
|
+
// ─── Redis Tools ────────────────────────────────────────────────
|
|
6
|
+
if (featureConfig.isToolEnabled('coaia_tash')) {
|
|
7
|
+
tools.push({
|
|
8
|
+
name: 'coaia_tash',
|
|
9
|
+
description: 'Stash key-value pair to Redis',
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
key: { type: 'string', description: 'Redis key' },
|
|
14
|
+
value: { type: 'string', description: 'Value to store' },
|
|
15
|
+
},
|
|
16
|
+
required: ['key', 'value'],
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (featureConfig.isToolEnabled('coaia_fetch')) {
|
|
21
|
+
tools.push({
|
|
22
|
+
name: 'coaia_fetch',
|
|
23
|
+
description: 'Fetch value from Redis by key',
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
properties: {
|
|
27
|
+
key: { type: 'string', description: 'Redis key to fetch' },
|
|
28
|
+
},
|
|
29
|
+
required: ['key'],
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// ─── Trace Tools ────────────────────────────────────────────────
|
|
34
|
+
if (featureConfig.isToolEnabled('coaia_fuse_trace_create')) {
|
|
35
|
+
tools.push({
|
|
36
|
+
name: 'coaia_fuse_trace_create',
|
|
37
|
+
description: 'Create a Langfuse trace for observability tracking',
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
trace_id: { type: 'string', description: 'Unique trace identifier' },
|
|
42
|
+
user_id: { type: 'string', description: 'User identifier' },
|
|
43
|
+
session_id: { type: 'string', description: 'Session identifier' },
|
|
44
|
+
name: { type: 'string', description: 'Trace name' },
|
|
45
|
+
metadata: { type: 'object', description: 'Metadata dictionary' },
|
|
46
|
+
input_data: { description: 'Input data' },
|
|
47
|
+
output_data: { description: 'Output data' },
|
|
48
|
+
},
|
|
49
|
+
required: ['trace_id'],
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (featureConfig.isToolEnabled('coaia_fuse_add_observation')) {
|
|
54
|
+
tools.push({
|
|
55
|
+
name: 'coaia_fuse_add_observation',
|
|
56
|
+
description: 'Add an observation (event, span, or generation) to a trace',
|
|
57
|
+
inputSchema: {
|
|
58
|
+
type: 'object',
|
|
59
|
+
properties: {
|
|
60
|
+
observation_id: { type: 'string', description: 'Unique observation identifier' },
|
|
61
|
+
trace_id: { type: 'string', description: 'Parent trace ID' },
|
|
62
|
+
name: { type: 'string', description: 'Observation name' },
|
|
63
|
+
observation_type: { type: 'string', enum: ['SPAN', 'EVENT', 'GENERATION'], description: 'Observation type' },
|
|
64
|
+
parent_id: { type: 'string', description: 'Parent observation ID for nesting' },
|
|
65
|
+
metadata: { type: 'object', description: 'Metadata' },
|
|
66
|
+
input_data: { description: 'Input data' },
|
|
67
|
+
output_data: { description: 'Output data' },
|
|
68
|
+
start_time: { type: 'string', description: 'Start timestamp (ISO 8601)' },
|
|
69
|
+
end_time: { type: 'string', description: 'End timestamp (ISO 8601)' },
|
|
70
|
+
},
|
|
71
|
+
required: ['observation_id', 'trace_id', 'name'],
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (featureConfig.isToolEnabled('coaia_fuse_trace_patch_output')) {
|
|
76
|
+
tools.push({
|
|
77
|
+
name: 'coaia_fuse_trace_patch_output',
|
|
78
|
+
description: 'Update the output field of an existing trace',
|
|
79
|
+
inputSchema: {
|
|
80
|
+
type: 'object',
|
|
81
|
+
properties: {
|
|
82
|
+
trace_id: { type: 'string', description: 'Trace ID to update' },
|
|
83
|
+
output_data: { description: 'New output data' },
|
|
84
|
+
},
|
|
85
|
+
required: ['trace_id', 'output_data'],
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (featureConfig.isToolEnabled('coaia_fuse_trace_get')) {
|
|
90
|
+
tools.push({
|
|
91
|
+
name: 'coaia_fuse_trace_get',
|
|
92
|
+
description: 'Get a specific trace by ID with all its observations',
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {
|
|
96
|
+
trace_id: { type: 'string', description: 'Trace ID to fetch' },
|
|
97
|
+
json_output: { type: 'boolean', description: 'Return raw JSON instead of formatted tree' },
|
|
98
|
+
},
|
|
99
|
+
required: ['trace_id'],
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (featureConfig.isToolEnabled('coaia_fuse_trace_view')) {
|
|
104
|
+
tools.push({
|
|
105
|
+
name: 'coaia_fuse_trace_view',
|
|
106
|
+
description: 'View trace details with observations (alias for trace_get)',
|
|
107
|
+
inputSchema: {
|
|
108
|
+
type: 'object',
|
|
109
|
+
properties: {
|
|
110
|
+
trace_id: { type: 'string', description: 'Trace ID' },
|
|
111
|
+
json_output: { type: 'boolean', description: 'Return raw JSON' },
|
|
112
|
+
},
|
|
113
|
+
required: ['trace_id'],
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (featureConfig.isToolEnabled('coaia_fuse_observation_get')) {
|
|
118
|
+
tools.push({
|
|
119
|
+
name: 'coaia_fuse_observation_get',
|
|
120
|
+
description: 'Get a specific observation by ID',
|
|
121
|
+
inputSchema: {
|
|
122
|
+
type: 'object',
|
|
123
|
+
properties: {
|
|
124
|
+
observation_id: { type: 'string', description: 'Observation ID' },
|
|
125
|
+
json_output: { type: 'boolean', description: 'Return raw JSON' },
|
|
126
|
+
},
|
|
127
|
+
required: ['observation_id'],
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
if (featureConfig.isToolEnabled('coaia_fuse_traces_list')) {
|
|
132
|
+
tools.push({
|
|
133
|
+
name: 'coaia_fuse_traces_list',
|
|
134
|
+
description: 'List traces with optional filtering by session, user, name, tags, and time range',
|
|
135
|
+
inputSchema: {
|
|
136
|
+
type: 'object',
|
|
137
|
+
properties: {
|
|
138
|
+
session_id: { type: 'string', description: 'Filter by session ID' },
|
|
139
|
+
user_id: { type: 'string', description: 'Filter by user ID' },
|
|
140
|
+
name: { type: 'string', description: 'Filter by trace name' },
|
|
141
|
+
tags: { type: 'array', items: { type: 'string' }, description: 'Filter by tags' },
|
|
142
|
+
from_timestamp: { type: 'string', description: 'Filter from timestamp (ISO 8601)' },
|
|
143
|
+
to_timestamp: { type: 'string', description: 'Filter to timestamp (ISO 8601)' },
|
|
144
|
+
order_by: { type: 'string', description: 'Sort order' },
|
|
145
|
+
page: { type: 'integer', description: 'Page number', default: 1 },
|
|
146
|
+
limit: { type: 'integer', description: 'Items per page', default: 50 },
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
if (featureConfig.isToolEnabled('coaia_fuse_traces_session_view')) {
|
|
152
|
+
tools.push({
|
|
153
|
+
name: 'coaia_fuse_traces_session_view',
|
|
154
|
+
description: 'View all traces for a specific session',
|
|
155
|
+
inputSchema: {
|
|
156
|
+
type: 'object',
|
|
157
|
+
properties: {
|
|
158
|
+
session_id: { type: 'string', description: 'Session ID to view traces for' },
|
|
159
|
+
json_output: { type: 'boolean', description: 'Return raw JSON' },
|
|
160
|
+
},
|
|
161
|
+
required: ['session_id'],
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
// ─── Prompts Tools ──────────────────────────────────────────────
|
|
166
|
+
if (featureConfig.isToolEnabled('coaia_fuse_prompts_list')) {
|
|
167
|
+
tools.push({
|
|
168
|
+
name: 'coaia_fuse_prompts_list',
|
|
169
|
+
description: 'List all Langfuse prompts',
|
|
170
|
+
inputSchema: { type: 'object', properties: {} },
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (featureConfig.isToolEnabled('coaia_fuse_prompts_get')) {
|
|
174
|
+
tools.push({
|
|
175
|
+
name: 'coaia_fuse_prompts_get',
|
|
176
|
+
description: 'Get a specific Langfuse prompt by name',
|
|
177
|
+
inputSchema: {
|
|
178
|
+
type: 'object',
|
|
179
|
+
properties: {
|
|
180
|
+
name: { type: 'string', description: 'Prompt name' },
|
|
181
|
+
label: { type: 'string', description: 'Optional deployment label' },
|
|
182
|
+
},
|
|
183
|
+
required: ['name'],
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
// ─── Dataset Tools ──────────────────────────────────────────────
|
|
188
|
+
if (featureConfig.isToolEnabled('coaia_fuse_datasets_list')) {
|
|
189
|
+
tools.push({
|
|
190
|
+
name: 'coaia_fuse_datasets_list',
|
|
191
|
+
description: 'List all Langfuse datasets',
|
|
192
|
+
inputSchema: { type: 'object', properties: {} },
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (featureConfig.isToolEnabled('coaia_fuse_datasets_get')) {
|
|
196
|
+
tools.push({
|
|
197
|
+
name: 'coaia_fuse_datasets_get',
|
|
198
|
+
description: 'Get a specific dataset by name with its items',
|
|
199
|
+
inputSchema: {
|
|
200
|
+
type: 'object',
|
|
201
|
+
properties: {
|
|
202
|
+
name: { type: 'string', description: 'Dataset name' },
|
|
203
|
+
},
|
|
204
|
+
required: ['name'],
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
// ─── Score Config Tools ─────────────────────────────────────────
|
|
209
|
+
if (featureConfig.isToolEnabled('coaia_fuse_score_configs_list')) {
|
|
210
|
+
tools.push({
|
|
211
|
+
name: 'coaia_fuse_score_configs_list',
|
|
212
|
+
description: 'List all Langfuse score configurations',
|
|
213
|
+
inputSchema: { type: 'object', properties: {} },
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
if (featureConfig.isToolEnabled('coaia_fuse_score_configs_get')) {
|
|
217
|
+
tools.push({
|
|
218
|
+
name: 'coaia_fuse_score_configs_get',
|
|
219
|
+
description: 'Get specific Langfuse score configuration',
|
|
220
|
+
inputSchema: {
|
|
221
|
+
type: 'object',
|
|
222
|
+
properties: {
|
|
223
|
+
name_or_id: { type: 'string', description: 'Score config name or ID' },
|
|
224
|
+
},
|
|
225
|
+
required: ['name_or_id'],
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
if (featureConfig.isToolEnabled('coaia_fuse_score_apply')) {
|
|
230
|
+
tools.push({
|
|
231
|
+
name: 'coaia_fuse_score_apply',
|
|
232
|
+
description: 'Apply a score configuration to a trace or observation with validation',
|
|
233
|
+
inputSchema: {
|
|
234
|
+
type: 'object',
|
|
235
|
+
properties: {
|
|
236
|
+
config_name_or_id: { type: 'string', description: 'Name or ID of the score configuration' },
|
|
237
|
+
target_type: { type: 'string', enum: ['trace', 'session'], description: 'Target type' },
|
|
238
|
+
target_id: { type: 'string', description: 'ID of the trace or session' },
|
|
239
|
+
value: { description: 'Score value (validated against config)' },
|
|
240
|
+
observation_id: { type: 'string', description: 'Optional observation ID' },
|
|
241
|
+
comment: { type: 'string', description: 'Optional comment' },
|
|
242
|
+
},
|
|
243
|
+
required: ['config_name_or_id', 'target_type', 'target_id', 'value'],
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
// ─── Comment Tools ──────────────────────────────────────────────
|
|
248
|
+
if (featureConfig.isToolEnabled('coaia_fuse_comments_list')) {
|
|
249
|
+
tools.push({
|
|
250
|
+
name: 'coaia_fuse_comments_list',
|
|
251
|
+
description: 'List comments with optional filtering by object type/ID or author',
|
|
252
|
+
inputSchema: {
|
|
253
|
+
type: 'object',
|
|
254
|
+
properties: {
|
|
255
|
+
object_type: { type: 'string', description: 'Filter by object type (trace, observation, session, prompt)' },
|
|
256
|
+
object_id: { type: 'string', description: 'Filter by specific object ID' },
|
|
257
|
+
author_user_id: { type: 'string', description: 'Filter by author user ID' },
|
|
258
|
+
page: { type: 'integer', description: 'Page number', default: 1 },
|
|
259
|
+
limit: { type: 'integer', description: 'Items per page', default: 50 },
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
if (featureConfig.isToolEnabled('coaia_fuse_comments_get')) {
|
|
265
|
+
tools.push({
|
|
266
|
+
name: 'coaia_fuse_comments_get',
|
|
267
|
+
description: 'Get a specific comment by ID',
|
|
268
|
+
inputSchema: {
|
|
269
|
+
type: 'object',
|
|
270
|
+
properties: {
|
|
271
|
+
comment_id: { type: 'string', description: 'Comment ID' },
|
|
272
|
+
},
|
|
273
|
+
required: ['comment_id'],
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
if (featureConfig.isToolEnabled('coaia_fuse_comments_create')) {
|
|
278
|
+
tools.push({
|
|
279
|
+
name: 'coaia_fuse_comments_create',
|
|
280
|
+
description: 'Create a comment attached to an object (trace, observation, session, or prompt)',
|
|
281
|
+
inputSchema: {
|
|
282
|
+
type: 'object',
|
|
283
|
+
properties: {
|
|
284
|
+
text: { type: 'string', description: 'Comment text' },
|
|
285
|
+
object_type: { type: 'string', description: 'Object type (trace, observation, session, prompt)' },
|
|
286
|
+
object_id: { type: 'string', description: 'Object ID' },
|
|
287
|
+
author_user_id: { type: 'string', description: 'Author user ID' },
|
|
288
|
+
},
|
|
289
|
+
required: ['text', 'object_type', 'object_id'],
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
// ─── Media Tools (FULL only) ────────────────────────────────────
|
|
294
|
+
if (featureConfig.isToolEnabled('coaia_fuse_media_upload')) {
|
|
295
|
+
tools.push({
|
|
296
|
+
name: 'coaia_fuse_media_upload',
|
|
297
|
+
description: 'Upload a file and attach it to a Langfuse trace or observation. Supports images, video, audio, documents. Auto-detects MIME type.',
|
|
298
|
+
inputSchema: {
|
|
299
|
+
type: 'object',
|
|
300
|
+
properties: {
|
|
301
|
+
file_path: { type: 'string', description: 'Absolute path to the file to upload' },
|
|
302
|
+
trace_id: { type: 'string', description: 'Trace ID to attach media to' },
|
|
303
|
+
field: { type: 'string', enum: ['input', 'output', 'metadata'], description: 'Field to attach to', default: 'input' },
|
|
304
|
+
observation_id: { type: 'string', description: 'Optional observation ID' },
|
|
305
|
+
content_type: { type: 'string', description: 'MIME type override (auto-detected if omitted)' },
|
|
306
|
+
},
|
|
307
|
+
required: ['file_path', 'trace_id'],
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
if (featureConfig.isToolEnabled('coaia_fuse_media_get')) {
|
|
312
|
+
tools.push({
|
|
313
|
+
name: 'coaia_fuse_media_get',
|
|
314
|
+
description: 'Get media metadata by media ID',
|
|
315
|
+
inputSchema: {
|
|
316
|
+
type: 'object',
|
|
317
|
+
properties: {
|
|
318
|
+
media_id: { type: 'string', description: 'Media ID' },
|
|
319
|
+
},
|
|
320
|
+
required: ['media_id'],
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
return tools;
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=coaiapy-tools.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Reset client (testing). */
|
|
2
|
+
export declare function resetClient(): void;
|
|
3
|
+
/**
|
|
4
|
+
* Synthesize text to speech using AWS Polly.
|
|
5
|
+
* Returns the path to the output audio file.
|
|
6
|
+
*
|
|
7
|
+
* @param text - Text to synthesize
|
|
8
|
+
* @param voiceId - Polly voice ID (default: "Joanna")
|
|
9
|
+
* @param outFile - Output file path (default: "./output.mp3")
|
|
10
|
+
*/
|
|
11
|
+
export declare function synthesize(text: string, voiceId?: string, outFile?: string): Promise<string>;
|
|
12
|
+
//# sourceMappingURL=audio.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// coaiajs/src/audio.ts — Audio synthesis module
|
|
2
|
+
// Parity with coaiapy's syntation.py using AWS Polly
|
|
3
|
+
import { PollyClient, SynthesizeSpeechCommand, } from '@aws-sdk/client-polly';
|
|
4
|
+
import { writeFileSync } from 'node:fs';
|
|
5
|
+
import { resolve } from 'node:path';
|
|
6
|
+
import { getConfig } from './config.js';
|
|
7
|
+
let _client = null;
|
|
8
|
+
function getPollyClient() {
|
|
9
|
+
if (!_client) {
|
|
10
|
+
const cfg = getConfig();
|
|
11
|
+
_client = new PollyClient({
|
|
12
|
+
region: cfg.aws?.region ?? process.env['AWS_REGION'] ?? 'us-east-1',
|
|
13
|
+
credentials: cfg.aws?.accessKeyId
|
|
14
|
+
? {
|
|
15
|
+
accessKeyId: cfg.aws.accessKeyId,
|
|
16
|
+
secretAccessKey: cfg.aws.secretAccessKey ?? '',
|
|
17
|
+
}
|
|
18
|
+
: undefined,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return _client;
|
|
22
|
+
}
|
|
23
|
+
/** Reset client (testing). */
|
|
24
|
+
export function resetClient() {
|
|
25
|
+
_client = null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Synthesize text to speech using AWS Polly.
|
|
29
|
+
* Returns the path to the output audio file.
|
|
30
|
+
*
|
|
31
|
+
* @param text - Text to synthesize
|
|
32
|
+
* @param voiceId - Polly voice ID (default: "Joanna")
|
|
33
|
+
* @param outFile - Output file path (default: "./output.mp3")
|
|
34
|
+
*/
|
|
35
|
+
export async function synthesize(text, voiceId, outFile) {
|
|
36
|
+
const client = getPollyClient();
|
|
37
|
+
const outputPath = resolve(outFile ?? './output.mp3');
|
|
38
|
+
const params = {
|
|
39
|
+
Text: text,
|
|
40
|
+
OutputFormat: 'mp3',
|
|
41
|
+
VoiceId: (voiceId ?? 'Joanna'),
|
|
42
|
+
Engine: 'neural',
|
|
43
|
+
};
|
|
44
|
+
const result = await client.send(new SynthesizeSpeechCommand(params));
|
|
45
|
+
if (result.AudioStream) {
|
|
46
|
+
// AudioStream is a Readable or Uint8Array depending on environment
|
|
47
|
+
const chunks = [];
|
|
48
|
+
const stream = result.AudioStream;
|
|
49
|
+
for await (const chunk of stream) {
|
|
50
|
+
chunks.push(chunk);
|
|
51
|
+
}
|
|
52
|
+
const buffer = Buffer.concat(chunks);
|
|
53
|
+
writeFileSync(outputPath, buffer);
|
|
54
|
+
}
|
|
55
|
+
return outputPath;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=audio.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function setColorEnabled(enabled: boolean): void;
|
|
2
|
+
export declare function formatTable(headers: string[], rows: string[][]): string;
|
|
3
|
+
export declare function formatJson(data: unknown): string;
|
|
4
|
+
export declare function formatError(message: string): string;
|
|
5
|
+
export declare function formatSuccess(message: string): string;
|
|
6
|
+
export declare function truncate(text: string, maxLength: number): string;
|
|
7
|
+
export declare function formatDate(iso: string): string;
|
|
8
|
+
export declare function formatProgress(completed: number, total: number): string;
|
|
9
|
+
//# sourceMappingURL=cli-helpers.d.ts.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
let colorEnabled = true;
|
|
3
|
+
export function setColorEnabled(enabled) {
|
|
4
|
+
colorEnabled = enabled;
|
|
5
|
+
if (!enabled) {
|
|
6
|
+
chalk.level = 0;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function formatTable(headers, rows) {
|
|
10
|
+
if (rows.length === 0)
|
|
11
|
+
return '(no data)';
|
|
12
|
+
const widths = headers.map((h, i) => Math.max(h.length, ...rows.map(r => (r[i] ?? '').length)));
|
|
13
|
+
const headerLine = headers
|
|
14
|
+
.map((h, i) => h.padEnd(widths[i]))
|
|
15
|
+
.join(' ');
|
|
16
|
+
const separator = widths.map(w => '─'.repeat(w)).join('──');
|
|
17
|
+
const dataLines = rows.map(row => row.map((cell, i) => (cell ?? '').padEnd(widths[i])).join(' '));
|
|
18
|
+
return [
|
|
19
|
+
colorEnabled ? chalk.bold(headerLine) : headerLine,
|
|
20
|
+
separator,
|
|
21
|
+
...dataLines,
|
|
22
|
+
].join('\n');
|
|
23
|
+
}
|
|
24
|
+
export function formatJson(data) {
|
|
25
|
+
return JSON.stringify(data, null, 2);
|
|
26
|
+
}
|
|
27
|
+
export function formatError(message) {
|
|
28
|
+
const sym = colorEnabled ? chalk.red('✗') : '✗';
|
|
29
|
+
const txt = colorEnabled ? chalk.red(message) : message;
|
|
30
|
+
return `${sym} ${txt}`;
|
|
31
|
+
}
|
|
32
|
+
export function formatSuccess(message) {
|
|
33
|
+
const sym = colorEnabled ? chalk.green('✓') : '✓';
|
|
34
|
+
const txt = colorEnabled ? chalk.green(message) : message;
|
|
35
|
+
return `${sym} ${txt}`;
|
|
36
|
+
}
|
|
37
|
+
export function truncate(text, maxLength) {
|
|
38
|
+
if (text.length <= maxLength)
|
|
39
|
+
return text;
|
|
40
|
+
return text.slice(0, maxLength - 1) + '…';
|
|
41
|
+
}
|
|
42
|
+
export function formatDate(iso) {
|
|
43
|
+
const date = new Date(iso);
|
|
44
|
+
if (isNaN(date.getTime()))
|
|
45
|
+
return iso;
|
|
46
|
+
const now = new Date();
|
|
47
|
+
const diffMs = now.getTime() - date.getTime();
|
|
48
|
+
const diffMins = Math.floor(diffMs / 60_000);
|
|
49
|
+
const diffHours = Math.floor(diffMins / 60);
|
|
50
|
+
const diffDays = Math.floor(diffHours / 24);
|
|
51
|
+
if (diffMins < 1)
|
|
52
|
+
return 'just now';
|
|
53
|
+
if (diffMins < 60)
|
|
54
|
+
return `${diffMins}m ago`;
|
|
55
|
+
if (diffHours < 24)
|
|
56
|
+
return `${diffHours}h ago`;
|
|
57
|
+
if (diffDays < 7)
|
|
58
|
+
return `${diffDays}d ago`;
|
|
59
|
+
return date.toISOString().slice(0, 10);
|
|
60
|
+
}
|
|
61
|
+
export function formatProgress(completed, total) {
|
|
62
|
+
if (total === 0)
|
|
63
|
+
return '[░░░░░░░░░░] 0% (0/0)';
|
|
64
|
+
const ratio = Math.min(completed / total, 1);
|
|
65
|
+
const pct = Math.round(ratio * 100);
|
|
66
|
+
const filled = Math.round(ratio * 10);
|
|
67
|
+
const empty = 10 - filled;
|
|
68
|
+
const bar = '█'.repeat(filled) + '░'.repeat(empty);
|
|
69
|
+
const colored = colorEnabled
|
|
70
|
+
? ratio >= 1
|
|
71
|
+
? chalk.green(bar)
|
|
72
|
+
: ratio >= 0.5
|
|
73
|
+
? chalk.yellow(bar)
|
|
74
|
+
: chalk.red(bar)
|
|
75
|
+
: bar;
|
|
76
|
+
return `[${colored}] ${pct}% (${completed}/${total})`;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=cli-helpers.js.map
|