coaiajs 0.1.0 → 0.1.2

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 (187) hide show
  1. package/README.md +7 -3
  2. package/dist/mcp/config.d.ts +4 -0
  3. package/dist/mcp/config.d.ts.map +1 -0
  4. package/dist/mcp/config.js +52 -26
  5. package/dist/mcp/config.js.map +1 -0
  6. package/dist/mcp/prompts.d.ts +19 -0
  7. package/dist/mcp/prompts.d.ts.map +1 -0
  8. package/dist/mcp/prompts.js +111 -0
  9. package/dist/mcp/prompts.js.map +1 -0
  10. package/dist/mcp/resources.d.ts +5 -0
  11. package/dist/mcp/resources.d.ts.map +1 -0
  12. package/dist/mcp/resources.js +77 -0
  13. package/dist/mcp/resources.js.map +1 -0
  14. package/dist/mcp/server.d.ts.map +1 -0
  15. package/dist/mcp/server.js +167 -75
  16. package/dist/mcp/server.js.map +1 -0
  17. package/dist/mcp/tools/coaiapy-tools.d.ts.map +1 -0
  18. package/dist/mcp/tools/coaiapy-tools.js +1 -0
  19. package/dist/mcp/tools/coaiapy-tools.js.map +1 -0
  20. package/dist/mcp/tools/index.d.ts.map +1 -0
  21. package/dist/mcp/tools/index.js.map +1 -0
  22. package/dist/src/audio.d.ts.map +1 -0
  23. package/dist/src/audio.js.map +1 -0
  24. package/dist/src/cli-helpers.d.ts.map +1 -0
  25. package/dist/src/cli-helpers.js.map +1 -0
  26. package/dist/src/cli.d.ts.map +1 -0
  27. package/dist/src/cli.js +4 -4
  28. package/dist/src/cli.js.map +1 -0
  29. package/dist/src/config.d.ts +2 -0
  30. package/dist/src/config.d.ts.map +1 -0
  31. package/dist/src/config.js +44 -14
  32. package/dist/src/config.js.map +1 -0
  33. package/dist/src/environment.d.ts.map +1 -0
  34. package/dist/src/environment.js.map +1 -0
  35. package/dist/src/github.d.ts.map +1 -0
  36. package/dist/src/github.js.map +1 -0
  37. package/dist/src/index.d.ts +13 -0
  38. package/dist/src/index.d.ts.map +1 -0
  39. package/dist/src/index.js +13 -0
  40. package/dist/src/index.js.map +1 -0
  41. package/dist/src/langfuse/client.d.ts.map +1 -0
  42. package/dist/src/langfuse/client.js.map +1 -0
  43. package/dist/src/langfuse/comments.d.ts.map +1 -0
  44. package/dist/src/langfuse/comments.js.map +1 -0
  45. package/dist/src/langfuse/datasets.d.ts.map +1 -0
  46. package/dist/src/langfuse/datasets.js.map +1 -0
  47. package/dist/src/langfuse/index.d.ts.map +1 -0
  48. package/dist/src/langfuse/index.js.map +1 -0
  49. package/dist/src/langfuse/media.d.ts.map +1 -0
  50. package/dist/src/langfuse/media.js.map +1 -0
  51. package/dist/src/langfuse/observations.d.ts.map +1 -0
  52. package/dist/src/langfuse/observations.js.map +1 -0
  53. package/dist/src/langfuse/prompts.d.ts.map +1 -0
  54. package/dist/src/langfuse/prompts.js.map +1 -0
  55. package/dist/src/langfuse/scores.d.ts.map +1 -0
  56. package/dist/src/langfuse/scores.js.map +1 -0
  57. package/dist/src/langfuse/traces.d.ts.map +1 -0
  58. package/dist/src/langfuse/traces.js.map +1 -0
  59. package/dist/src/llm.d.ts.map +1 -0
  60. package/dist/src/llm.js.map +1 -0
  61. package/dist/src/narrative/graph-manager.d.ts.map +1 -0
  62. package/dist/src/narrative/graph-manager.js.map +1 -0
  63. package/dist/src/narrative/index.d.ts +32 -1
  64. package/dist/src/narrative/index.d.ts.map +1 -0
  65. package/dist/src/narrative/index.js +97 -1
  66. package/dist/src/narrative/index.js.map +1 -0
  67. package/dist/src/narrative/markdown-export.d.ts.map +1 -0
  68. package/dist/src/narrative/markdown-export.js.map +1 -0
  69. package/dist/src/narrative/tool-definitions.d.ts.map +1 -0
  70. package/dist/src/narrative/tool-definitions.js.map +1 -0
  71. package/dist/src/narrative/tool-handlers.d.ts.map +1 -0
  72. package/dist/src/narrative/tool-handlers.js.map +1 -0
  73. package/dist/src/narrative/types.d.ts.map +1 -0
  74. package/dist/src/narrative/types.js.map +1 -0
  75. package/dist/src/narrative/validation.d.ts.map +1 -0
  76. package/dist/src/narrative/validation.js.map +1 -0
  77. package/dist/src/pde/index.d.ts +4 -0
  78. package/dist/src/pde/index.d.ts.map +1 -0
  79. package/dist/src/pde/index.js +19 -0
  80. package/dist/src/pde/index.js.map +1 -0
  81. package/dist/src/pde/mcp-handlers.d.ts.map +1 -0
  82. package/dist/src/pde/mcp-handlers.js.map +1 -0
  83. package/dist/src/pde/mcp-tools.d.ts.map +1 -0
  84. package/dist/src/pde/mcp-tools.js.map +1 -0
  85. package/dist/src/pde/session-manager.d.ts.map +1 -0
  86. package/dist/src/pde/session-manager.js.map +1 -0
  87. package/dist/src/pde/stc-mapper.d.ts.map +1 -0
  88. package/dist/src/pde/stc-mapper.js.map +1 -0
  89. package/dist/src/pipeline/index.d.ts.map +1 -0
  90. package/dist/src/pipeline/index.js.map +1 -0
  91. package/dist/src/pipeline/template-engine.d.ts.map +1 -0
  92. package/dist/src/pipeline/template-engine.js.map +1 -0
  93. package/dist/src/planning/index.d.ts +3 -0
  94. package/dist/src/planning/index.d.ts.map +1 -0
  95. package/dist/src/planning/index.js +13 -0
  96. package/dist/src/planning/index.js.map +1 -0
  97. package/dist/src/planning/mcp-handlers.d.ts.map +1 -0
  98. package/dist/src/planning/mcp-handlers.js.map +1 -0
  99. package/dist/src/planning/mcp-tools.d.ts.map +1 -0
  100. package/dist/src/planning/mcp-tools.js.map +1 -0
  101. package/dist/src/planning/plan-parser.d.ts.map +1 -0
  102. package/dist/src/planning/plan-parser.js.map +1 -0
  103. package/dist/src/redis.d.ts.map +1 -0
  104. package/dist/src/redis.js +20 -8
  105. package/dist/src/redis.js.map +1 -0
  106. package/dist/src/types.d.ts +1 -0
  107. package/dist/src/types.d.ts.map +1 -0
  108. package/dist/src/types.js.map +1 -0
  109. package/package.json +67 -2
  110. package/rispecs/00-coaiajs-platform.spec.md +23 -10
  111. package/rispecs/01-core-config.spec.md +7 -37
  112. package/rispecs/02-redis-module.spec.md +2 -1
  113. package/rispecs/03-langfuse-module.spec.md +7 -5
  114. package/rispecs/04-narrative-engine.spec.md +9 -9
  115. package/rispecs/05-pde-engine.spec.md +23 -23
  116. package/rispecs/06-planning-engine.spec.md +14 -13
  117. package/rispecs/07-pipeline-templates.spec.md +7 -7
  118. package/rispecs/08-cli-interface.spec.md +13 -25
  119. package/rispecs/09-mcp-server.spec.md +57 -62
  120. package/rispecs/10-audio-module.spec.md +3 -3
  121. package/rispecs/KINSHIP.md +4 -4
  122. package/rispecs/README.md +33 -7
  123. package/articles/academic/creative-orientation-vs-problem-solving.md +0 -177
  124. package/articles/academic/jsonl-knowledge-graphs-agent-memory.md +0 -142
  125. package/articles/academic/langfuse-observability-llm-pipelines.md +0 -144
  126. package/articles/academic/medicine-wheel-software-architecture.md +0 -163
  127. package/articles/academic/mmot-autonomous-agents.md +0 -156
  128. package/articles/academic/model-context-protocol-interagent.md +0 -161
  129. package/articles/academic/pde-prompt-decomposition.md +0 -186
  130. package/articles/academic/structural-tension-in-ai-agents.md +0 -134
  131. package/articles/reviews/mcp-protocol-design-review.md +0 -170
  132. package/articles/reviews/observability-ai-systems-review.md +0 -176
  133. package/articles/reviews/prompt-engineering-decomposition-review.md +0 -184
  134. package/articles/surveys/agent-orchestration-survey.md +0 -186
  135. package/articles/surveys/knowledge-graph-storage-survey.md +0 -204
  136. package/articles/surveys/structural-tension-methodology-survey.md +0 -154
  137. package/articles/technical/aws-sdk-v3-polly.md +0 -270
  138. package/articles/technical/commander-cli-framework.md +0 -262
  139. package/articles/technical/dotenv-config-patterns.md +0 -360
  140. package/articles/technical/ioredis-vs-redis.md +0 -142
  141. package/articles/technical/langfuse-js-sdk-vs-rest.md +0 -191
  142. package/articles/technical/mcp-sdk-typescript.md +0 -291
  143. package/articles/technical/octokit-github-api.md +0 -293
  144. package/articles/technical/openai-sdk-modern.md +0 -231
  145. package/articles/technical/yaml-parsing-node.md +0 -266
  146. package/articles/technical/zod-runtime-validation.md +0 -212
  147. package/mcp/config.ts +0 -196
  148. package/mcp/server.ts +0 -402
  149. package/mcp/tools/coaiapy-tools.ts +0 -364
  150. package/mcp/tools/index.ts +0 -4
  151. package/src/audio.ts +0 -76
  152. package/src/cli-helpers.ts +0 -86
  153. package/src/cli.ts +0 -1223
  154. package/src/config.ts +0 -172
  155. package/src/environment.ts +0 -171
  156. package/src/github.ts +0 -143
  157. package/src/langfuse/client.ts +0 -105
  158. package/src/langfuse/comments.ts +0 -52
  159. package/src/langfuse/datasets.ts +0 -178
  160. package/src/langfuse/index.ts +0 -33
  161. package/src/langfuse/media.ts +0 -193
  162. package/src/langfuse/observations.ts +0 -131
  163. package/src/langfuse/prompts.ts +0 -157
  164. package/src/langfuse/scores.ts +0 -456
  165. package/src/langfuse/traces.ts +0 -276
  166. package/src/llm.ts +0 -106
  167. package/src/narrative/graph-manager.ts +0 -1358
  168. package/src/narrative/index.ts +0 -32
  169. package/src/narrative/markdown-export.ts +0 -535
  170. package/src/narrative/tool-definitions.ts +0 -635
  171. package/src/narrative/tool-handlers.ts +0 -528
  172. package/src/narrative/types.ts +0 -9
  173. package/src/narrative/validation.ts +0 -179
  174. package/src/pde/index.ts +0 -8
  175. package/src/pde/mcp-handlers.ts +0 -359
  176. package/src/pde/mcp-tools.ts +0 -201
  177. package/src/pde/session-manager.ts +0 -248
  178. package/src/pde/stc-mapper.ts +0 -298
  179. package/src/pipeline/index.ts +0 -7
  180. package/src/pipeline/template-engine.ts +0 -398
  181. package/src/planning/index.ts +0 -13
  182. package/src/planning/mcp-handlers.ts +0 -369
  183. package/src/planning/mcp-tools.ts +0 -155
  184. package/src/planning/plan-parser.ts +0 -587
  185. package/src/redis.ts +0 -97
  186. package/src/types.ts +0 -280
  187. package/tsconfig.json +0 -26
@@ -1,364 +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
- },
27
- required: ['key', 'value'],
28
- },
29
- });
30
- }
31
-
32
- if (featureConfig.isToolEnabled('coaia_fetch')) {
33
- tools.push({
34
- name: 'coaia_fetch',
35
- description: 'Fetch value from Redis by key',
36
- inputSchema: {
37
- type: 'object',
38
- properties: {
39
- key: { type: 'string', description: 'Redis key to fetch' },
40
- },
41
- required: ['key'],
42
- },
43
- });
44
- }
45
-
46
- // ─── Trace Tools ────────────────────────────────────────────────
47
-
48
- if (featureConfig.isToolEnabled('coaia_fuse_trace_create')) {
49
- tools.push({
50
- name: 'coaia_fuse_trace_create',
51
- description: 'Create a Langfuse trace for observability tracking',
52
- inputSchema: {
53
- type: 'object',
54
- properties: {
55
- trace_id: { type: 'string', description: 'Unique trace identifier' },
56
- user_id: { type: 'string', description: 'User identifier' },
57
- session_id: { type: 'string', description: 'Session identifier' },
58
- name: { type: 'string', description: 'Trace name' },
59
- metadata: { type: 'object', description: 'Metadata dictionary' },
60
- input_data: { description: 'Input data' },
61
- output_data: { description: 'Output data' },
62
- },
63
- required: ['trace_id'],
64
- },
65
- });
66
- }
67
-
68
- if (featureConfig.isToolEnabled('coaia_fuse_add_observation')) {
69
- tools.push({
70
- name: 'coaia_fuse_add_observation',
71
- description: 'Add an observation (event, span, or generation) to a trace',
72
- inputSchema: {
73
- type: 'object',
74
- properties: {
75
- observation_id: { type: 'string', description: 'Unique observation identifier' },
76
- trace_id: { type: 'string', description: 'Parent trace ID' },
77
- name: { type: 'string', description: 'Observation name' },
78
- observation_type: { type: 'string', enum: ['SPAN', 'EVENT', 'GENERATION'], description: 'Observation type' },
79
- parent_id: { type: 'string', description: 'Parent observation ID for nesting' },
80
- metadata: { type: 'object', description: 'Metadata' },
81
- input_data: { description: 'Input data' },
82
- output_data: { description: 'Output data' },
83
- start_time: { type: 'string', description: 'Start timestamp (ISO 8601)' },
84
- end_time: { type: 'string', description: 'End timestamp (ISO 8601)' },
85
- },
86
- required: ['observation_id', 'trace_id', 'name'],
87
- },
88
- });
89
- }
90
-
91
- if (featureConfig.isToolEnabled('coaia_fuse_trace_patch_output')) {
92
- tools.push({
93
- name: 'coaia_fuse_trace_patch_output',
94
- description: 'Update the output field of an existing trace',
95
- inputSchema: {
96
- type: 'object',
97
- properties: {
98
- trace_id: { type: 'string', description: 'Trace ID to update' },
99
- output_data: { description: 'New output data' },
100
- },
101
- required: ['trace_id', 'output_data'],
102
- },
103
- });
104
- }
105
-
106
- if (featureConfig.isToolEnabled('coaia_fuse_trace_get')) {
107
- tools.push({
108
- name: 'coaia_fuse_trace_get',
109
- description: 'Get a specific trace by ID with all its observations',
110
- inputSchema: {
111
- type: 'object',
112
- properties: {
113
- trace_id: { type: 'string', description: 'Trace ID to fetch' },
114
- json_output: { type: 'boolean', description: 'Return raw JSON instead of formatted tree' },
115
- },
116
- required: ['trace_id'],
117
- },
118
- });
119
- }
120
-
121
- if (featureConfig.isToolEnabled('coaia_fuse_trace_view')) {
122
- tools.push({
123
- name: 'coaia_fuse_trace_view',
124
- description: 'View trace details with observations (alias for trace_get)',
125
- inputSchema: {
126
- type: 'object',
127
- properties: {
128
- trace_id: { type: 'string', description: 'Trace ID' },
129
- json_output: { type: 'boolean', description: 'Return raw JSON' },
130
- },
131
- required: ['trace_id'],
132
- },
133
- });
134
- }
135
-
136
- if (featureConfig.isToolEnabled('coaia_fuse_observation_get')) {
137
- tools.push({
138
- name: 'coaia_fuse_observation_get',
139
- description: 'Get a specific observation by ID',
140
- inputSchema: {
141
- type: 'object',
142
- properties: {
143
- observation_id: { type: 'string', description: 'Observation ID' },
144
- json_output: { type: 'boolean', description: 'Return raw JSON' },
145
- },
146
- required: ['observation_id'],
147
- },
148
- });
149
- }
150
-
151
- if (featureConfig.isToolEnabled('coaia_fuse_traces_list')) {
152
- tools.push({
153
- name: 'coaia_fuse_traces_list',
154
- description: 'List traces with optional filtering by session, user, name, tags, and time range',
155
- inputSchema: {
156
- type: 'object',
157
- properties: {
158
- session_id: { type: 'string', description: 'Filter by session ID' },
159
- user_id: { type: 'string', description: 'Filter by user ID' },
160
- name: { type: 'string', description: 'Filter by trace name' },
161
- tags: { type: 'array', items: { type: 'string' }, description: 'Filter by tags' },
162
- from_timestamp: { type: 'string', description: 'Filter from timestamp (ISO 8601)' },
163
- to_timestamp: { type: 'string', description: 'Filter to timestamp (ISO 8601)' },
164
- order_by: { type: 'string', description: 'Sort order' },
165
- page: { type: 'integer', description: 'Page number', default: 1 },
166
- limit: { type: 'integer', description: 'Items per page', default: 50 },
167
- },
168
- },
169
- });
170
- }
171
-
172
- if (featureConfig.isToolEnabled('coaia_fuse_traces_session_view')) {
173
- tools.push({
174
- name: 'coaia_fuse_traces_session_view',
175
- description: 'View all traces for a specific session',
176
- inputSchema: {
177
- type: 'object',
178
- properties: {
179
- session_id: { type: 'string', description: 'Session ID to view traces for' },
180
- json_output: { type: 'boolean', description: 'Return raw JSON' },
181
- },
182
- required: ['session_id'],
183
- },
184
- });
185
- }
186
-
187
- // ─── Prompts Tools ──────────────────────────────────────────────
188
-
189
- if (featureConfig.isToolEnabled('coaia_fuse_prompts_list')) {
190
- tools.push({
191
- name: 'coaia_fuse_prompts_list',
192
- description: 'List all Langfuse prompts',
193
- inputSchema: { type: 'object', properties: {} },
194
- });
195
- }
196
-
197
- if (featureConfig.isToolEnabled('coaia_fuse_prompts_get')) {
198
- tools.push({
199
- name: 'coaia_fuse_prompts_get',
200
- description: 'Get a specific Langfuse prompt by name',
201
- inputSchema: {
202
- type: 'object',
203
- properties: {
204
- name: { type: 'string', description: 'Prompt name' },
205
- label: { type: 'string', description: 'Optional deployment label' },
206
- },
207
- required: ['name'],
208
- },
209
- });
210
- }
211
-
212
- // ─── Dataset Tools ──────────────────────────────────────────────
213
-
214
- if (featureConfig.isToolEnabled('coaia_fuse_datasets_list')) {
215
- tools.push({
216
- name: 'coaia_fuse_datasets_list',
217
- description: 'List all Langfuse datasets',
218
- inputSchema: { type: 'object', properties: {} },
219
- });
220
- }
221
-
222
- if (featureConfig.isToolEnabled('coaia_fuse_datasets_get')) {
223
- tools.push({
224
- name: 'coaia_fuse_datasets_get',
225
- description: 'Get a specific dataset by name with its items',
226
- inputSchema: {
227
- type: 'object',
228
- properties: {
229
- name: { type: 'string', description: 'Dataset name' },
230
- },
231
- required: ['name'],
232
- },
233
- });
234
- }
235
-
236
- // ─── Score Config Tools ─────────────────────────────────────────
237
-
238
- if (featureConfig.isToolEnabled('coaia_fuse_score_configs_list')) {
239
- tools.push({
240
- name: 'coaia_fuse_score_configs_list',
241
- description: 'List all Langfuse score configurations',
242
- inputSchema: { type: 'object', properties: {} },
243
- });
244
- }
245
-
246
- if (featureConfig.isToolEnabled('coaia_fuse_score_configs_get')) {
247
- tools.push({
248
- name: 'coaia_fuse_score_configs_get',
249
- description: 'Get specific Langfuse score configuration',
250
- inputSchema: {
251
- type: 'object',
252
- properties: {
253
- name_or_id: { type: 'string', description: 'Score config name or ID' },
254
- },
255
- required: ['name_or_id'],
256
- },
257
- });
258
- }
259
-
260
- if (featureConfig.isToolEnabled('coaia_fuse_score_apply')) {
261
- tools.push({
262
- name: 'coaia_fuse_score_apply',
263
- description: 'Apply a score configuration to a trace or observation with validation',
264
- inputSchema: {
265
- type: 'object',
266
- properties: {
267
- config_name_or_id: { type: 'string', description: 'Name or ID of the score configuration' },
268
- target_type: { type: 'string', enum: ['trace', 'session'], description: 'Target type' },
269
- target_id: { type: 'string', description: 'ID of the trace or session' },
270
- value: { description: 'Score value (validated against config)' },
271
- observation_id: { type: 'string', description: 'Optional observation ID' },
272
- comment: { type: 'string', description: 'Optional comment' },
273
- },
274
- required: ['config_name_or_id', 'target_type', 'target_id', 'value'],
275
- },
276
- });
277
- }
278
-
279
- // ─── Comment Tools ──────────────────────────────────────────────
280
-
281
- if (featureConfig.isToolEnabled('coaia_fuse_comments_list')) {
282
- tools.push({
283
- name: 'coaia_fuse_comments_list',
284
- description: 'List comments with optional filtering by object type/ID or author',
285
- inputSchema: {
286
- type: 'object',
287
- properties: {
288
- object_type: { type: 'string', description: 'Filter by object type (trace, observation, session, prompt)' },
289
- object_id: { type: 'string', description: 'Filter by specific object ID' },
290
- author_user_id: { type: 'string', description: 'Filter by author user ID' },
291
- page: { type: 'integer', description: 'Page number', default: 1 },
292
- limit: { type: 'integer', description: 'Items per page', default: 50 },
293
- },
294
- },
295
- });
296
- }
297
-
298
- if (featureConfig.isToolEnabled('coaia_fuse_comments_get')) {
299
- tools.push({
300
- name: 'coaia_fuse_comments_get',
301
- description: 'Get a specific comment by ID',
302
- inputSchema: {
303
- type: 'object',
304
- properties: {
305
- comment_id: { type: 'string', description: 'Comment ID' },
306
- },
307
- required: ['comment_id'],
308
- },
309
- });
310
- }
311
-
312
- if (featureConfig.isToolEnabled('coaia_fuse_comments_create')) {
313
- tools.push({
314
- name: 'coaia_fuse_comments_create',
315
- description: 'Create a comment attached to an object (trace, observation, session, or prompt)',
316
- inputSchema: {
317
- type: 'object',
318
- properties: {
319
- text: { type: 'string', description: 'Comment text' },
320
- object_type: { type: 'string', description: 'Object type (trace, observation, session, prompt)' },
321
- object_id: { type: 'string', description: 'Object ID' },
322
- author_user_id: { type: 'string', description: 'Author user ID' },
323
- },
324
- required: ['text', 'object_type', 'object_id'],
325
- },
326
- });
327
- }
328
-
329
- // ─── Media Tools (FULL only) ────────────────────────────────────
330
-
331
- if (featureConfig.isToolEnabled('coaia_fuse_media_upload')) {
332
- tools.push({
333
- name: 'coaia_fuse_media_upload',
334
- description: 'Upload a file and attach it to a Langfuse trace or observation. Supports images, video, audio, documents. Auto-detects MIME type.',
335
- inputSchema: {
336
- type: 'object',
337
- properties: {
338
- file_path: { type: 'string', description: 'Absolute path to the file to upload' },
339
- trace_id: { type: 'string', description: 'Trace ID to attach media to' },
340
- field: { type: 'string', enum: ['input', 'output', 'metadata'], description: 'Field to attach to', default: 'input' },
341
- observation_id: { type: 'string', description: 'Optional observation ID' },
342
- content_type: { type: 'string', description: 'MIME type override (auto-detected if omitted)' },
343
- },
344
- required: ['file_path', 'trace_id'],
345
- },
346
- });
347
- }
348
-
349
- if (featureConfig.isToolEnabled('coaia_fuse_media_get')) {
350
- tools.push({
351
- name: 'coaia_fuse_media_get',
352
- description: 'Get media metadata by media ID',
353
- inputSchema: {
354
- type: 'object',
355
- properties: {
356
- media_id: { type: 'string', description: 'Media ID' },
357
- },
358
- required: ['media_id'],
359
- },
360
- });
361
- }
362
-
363
- return tools;
364
- }
@@ -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
- }