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