@axiom-lattice/gateway 3.0.2 → 3.0.3

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 (155) hide show
  1. package/dist/index.js +31 -9
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +31 -9
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +9 -6
  6. package/.eslintrc.json +0 -22
  7. package/.turbo/turbo-build.log +0 -46
  8. package/AGENTS.md +0 -112
  9. package/CHANGELOG.md +0 -1190
  10. package/LOGGER_CONFIG.md +0 -135
  11. package/RESUME_STREAM_CONTENT_BASED.md +0 -326
  12. package/RESUME_STREAM_README.md +0 -388
  13. package/jest.config.js +0 -72
  14. package/public/sdk/README.md +0 -695
  15. package/public/sdk/dashboard-engine-skill.md +0 -1122
  16. package/public/sdk/dashboard-single-file-spec.md +0 -357
  17. package/public/sdk/data-query-sdk-skill.md +0 -307
  18. package/public/sdk/data-query-sdk.d.ts +0 -252
  19. package/public/sdk/data-query-sdk.js +0 -970
  20. package/public/sdk/occupancy-dashboard.html +0 -363
  21. package/public/sdk/test-dashboard.html +0 -690
  22. package/scripts/seed-lark-installation.ts +0 -54
  23. package/src/__tests__/__mocks__/e2b.ts +0 -1
  24. package/src/__tests__/a2a.test.ts +0 -428
  25. package/src/__tests__/channel-installations.test.ts +0 -199
  26. package/src/__tests__/data-query.test.ts +0 -77
  27. package/src/__tests__/sandbox-provider-registration.test.ts +0 -74
  28. package/src/__tests__/setup.ts +0 -5
  29. package/src/__tests__/workspace.test.ts +0 -400
  30. package/src/channels/__tests__/routes.test.ts +0 -50
  31. package/src/channels/lark/LarkChannelAdapter.ts +0 -217
  32. package/src/channels/lark/README.md +0 -187
  33. package/src/channels/lark/__tests__/controller.test.ts +0 -136
  34. package/src/channels/lark/__tests__/mapping-service.test.ts +0 -118
  35. package/src/channels/lark/__tests__/parser.test.ts +0 -72
  36. package/src/channels/lark/__tests__/sender.test.ts +0 -37
  37. package/src/channels/lark/__tests__/verification.test.ts +0 -157
  38. package/src/channels/lark/controller.ts +0 -48
  39. package/src/channels/lark/mapping-service.ts +0 -138
  40. package/src/channels/lark/parser.ts +0 -68
  41. package/src/channels/lark/routes.ts +0 -22
  42. package/src/channels/lark/sender.ts +0 -58
  43. package/src/channels/lark/types.ts +0 -20
  44. package/src/channels/lark/verification.ts +0 -32
  45. package/src/channels/registry.ts +0 -20
  46. package/src/channels/routes.ts +0 -30
  47. package/src/channels/wechat/WechatChannelAdapter.ts +0 -294
  48. package/src/channels/wechat/__tests__/context-store.test.ts +0 -148
  49. package/src/channels/wechat/context-store.ts +0 -54
  50. package/src/channels/wechat/controller.ts +0 -59
  51. package/src/channels/wechat/routes.ts +0 -7
  52. package/src/channels/wechat/types.ts +0 -62
  53. package/src/channels/wechat/wechat-client.ts +0 -162
  54. package/src/config/local-a2a-templates.ts +0 -59
  55. package/src/config.ts +0 -124
  56. package/src/controllers/__tests__/assistant-local-a2a.test.ts +0 -147
  57. package/src/controllers/__tests__/local-a2a-templates.test.ts +0 -112
  58. package/src/controllers/__tests__/mime.test.ts +0 -74
  59. package/src/controllers/__tests__/resources.test.ts +0 -122
  60. package/src/controllers/__tests__/run.test.ts +0 -115
  61. package/src/controllers/__tests__/tasks.test.ts +0 -215
  62. package/src/controllers/__tests__/workflow-tracking.test.ts +0 -113
  63. package/src/controllers/agent_task.ts +0 -72
  64. package/src/controllers/assistant.ts +0 -490
  65. package/src/controllers/auth.ts +0 -524
  66. package/src/controllers/channel-bindings.ts +0 -135
  67. package/src/controllers/channel-installations.ts +0 -409
  68. package/src/controllers/collections.ts +0 -176
  69. package/src/controllers/config.ts +0 -126
  70. package/src/controllers/connections.ts +0 -181
  71. package/src/controllers/data-query.ts +0 -236
  72. package/src/controllers/database-configs.ts +0 -440
  73. package/src/controllers/embeddings.ts +0 -22
  74. package/src/controllers/entries.ts +0 -167
  75. package/src/controllers/eval.ts +0 -513
  76. package/src/controllers/export-import.ts +0 -166
  77. package/src/controllers/health.ts +0 -36
  78. package/src/controllers/local-a2a-templates.ts +0 -18
  79. package/src/controllers/local-a2a.ts +0 -149
  80. package/src/controllers/mcp-configs.ts +0 -673
  81. package/src/controllers/memory.ts +0 -257
  82. package/src/controllers/menu-items.ts +0 -114
  83. package/src/controllers/metrics-configs.ts +0 -1061
  84. package/src/controllers/middleware-types.ts +0 -15
  85. package/src/controllers/models.ts +0 -199
  86. package/src/controllers/personal-assistant.ts +0 -191
  87. package/src/controllers/resources.ts +0 -477
  88. package/src/controllers/run.ts +0 -338
  89. package/src/controllers/sandbox.ts +0 -255
  90. package/src/controllers/schedules.ts +0 -336
  91. package/src/controllers/skills.ts +0 -256
  92. package/src/controllers/tasks.ts +0 -213
  93. package/src/controllers/tenants.ts +0 -121
  94. package/src/controllers/thread_status.ts +0 -66
  95. package/src/controllers/threads.ts +0 -260
  96. package/src/controllers/tools.ts +0 -139
  97. package/src/controllers/users.ts +0 -135
  98. package/src/controllers/workflow-tracking.ts +0 -693
  99. package/src/controllers/workspace.ts +0 -879
  100. package/src/export_registrations/a2a-api-key.registration.ts +0 -89
  101. package/src/export_registrations/agent.registration.ts +0 -80
  102. package/src/export_registrations/binding.registration.ts +0 -106
  103. package/src/export_registrations/channel-installation.registration.ts +0 -88
  104. package/src/export_registrations/collection.registration.ts +0 -85
  105. package/src/export_registrations/connection.registration.ts +0 -97
  106. package/src/export_registrations/database-config.registration.ts +0 -94
  107. package/src/export_registrations/eval.registration.ts +0 -334
  108. package/src/export_registrations/index.ts +0 -31
  109. package/src/export_registrations/mcp-config.registration.ts +0 -97
  110. package/src/export_registrations/menu.registration.ts +0 -91
  111. package/src/export_registrations/metrics-config.registration.ts +0 -94
  112. package/src/export_registrations/skill.registration.ts +0 -88
  113. package/src/export_registrations/task.registration.ts +0 -99
  114. package/src/index.ts +0 -497
  115. package/src/logger/Logger.ts +0 -186
  116. package/src/router/MessageContext.ts +0 -14
  117. package/src/router/MessageRouter.ts +0 -490
  118. package/src/router/middlewares/auditLogger.ts +0 -34
  119. package/src/router/middlewares/deduplication.ts +0 -38
  120. package/src/router/middlewares/index.ts +0 -3
  121. package/src/router/middlewares/rateLimit.ts +0 -46
  122. package/src/routes/__tests__/a2a-test-connection.test.ts +0 -177
  123. package/src/routes/a2a-bridge.ts +0 -266
  124. package/src/routes/a2a-test-connection.ts +0 -126
  125. package/src/routes/a2a.ts +0 -851
  126. package/src/routes/channel-bindings.ts +0 -11
  127. package/src/routes/channel-installations.ts +0 -33
  128. package/src/routes/index.ts +0 -640
  129. package/src/routes/menu-items.ts +0 -10
  130. package/src/routes/resource-routes.ts +0 -35
  131. package/src/routes/stt.ts +0 -102
  132. package/src/schemas/data-query.ts +0 -69
  133. package/src/schemas/index.ts +0 -852
  134. package/src/services/ExportImportService.ts +0 -296
  135. package/src/services/__tests__/ExportImportService.test.ts +0 -130
  136. package/src/services/__tests__/eval-runner.test.ts +0 -131
  137. package/src/services/__tests__/local-a2a.test.ts +0 -124
  138. package/src/services/agent_task_consumer.ts +0 -348
  139. package/src/services/collection_service.ts +0 -258
  140. package/src/services/eval-runner.ts +0 -283
  141. package/src/services/local-a2a.ts +0 -354
  142. package/src/services/queue_service.ts +0 -104
  143. package/src/services/sandbox_service.ts +0 -223
  144. package/src/services/skill_service.ts +0 -97
  145. package/src/services/supabase.ts +0 -60
  146. package/src/swagger.ts +0 -77
  147. package/src/types/index.ts +0 -118
  148. package/src/types/koa.d.ts +0 -7
  149. package/src/utils/__tests__/local-a2a-runtime.test.ts +0 -77
  150. package/src/utils/__tests__/path-containment.test.ts +0 -35
  151. package/src/utils/a2a-url.ts +0 -20
  152. package/src/utils/local-a2a-runtime.ts +0 -107
  153. package/src/utils/mime.ts +0 -44
  154. package/src/utils/path-containment.ts +0 -38
  155. package/tsconfig.json +0 -26
@@ -1,11 +0,0 @@
1
- import type { FastifyInstance } from "fastify";
2
- import * as bindingsController from "../controllers/channel-bindings";
3
-
4
- export function registerChannelBindingRoutes(app: FastifyInstance): void {
5
- app.get("/api/channel-bindings", bindingsController.getBindingList);
6
- app.get("/api/channel-bindings/resolve", bindingsController.resolveBinding);
7
- app.post("/api/channel-bindings", bindingsController.createBinding);
8
- app.get("/api/channel-bindings/:id", bindingsController.getBinding);
9
- app.put("/api/channel-bindings/:id", bindingsController.updateBinding);
10
- app.delete("/api/channel-bindings/:id", bindingsController.deleteBinding);
11
- }
@@ -1,33 +0,0 @@
1
- import { FastifyInstance } from "fastify";
2
- import * as channelInstallationController from "../controllers/channel-installations";
3
-
4
- /**
5
- * Register channel installation management routes
6
- */
7
- export function registerChannelInstallationRoutes(app: FastifyInstance): void {
8
- // List all installations for current tenant
9
- app.get<{
10
- Querystring: { channel?: "lark" };
11
- }>("/api/channel-installations", channelInstallationController.getChannelInstallationList);
12
-
13
- // Get single installation by ID
14
- app.get<{
15
- Params: { installationId: string };
16
- }>("/api/channel-installations/:installationId", channelInstallationController.getChannelInstallation);
17
-
18
- // Create new installation
19
- app.post<{
20
- Body: any;
21
- }>("/api/channel-installations", channelInstallationController.createChannelInstallation);
22
-
23
- // Update installation
24
- app.put<{
25
- Params: { installationId: string };
26
- Body: any;
27
- }>("/api/channel-installations/:installationId", channelInstallationController.updateChannelInstallation);
28
-
29
- // Delete installation
30
- app.delete<{
31
- Params: { installationId: string };
32
- }>("/api/channel-installations/:installationId", channelInstallationController.deleteChannelInstallation);
33
- }
@@ -1,640 +0,0 @@
1
- import { FastifyInstance } from "fastify";
2
- import { ScheduledTaskStatus } from "@axiom-lattice/protocols";
3
- import * as assistantController from "../controllers/assistant";
4
- import * as runController from "../controllers/run";
5
- import * as memoryController from "../controllers/memory";
6
- import * as graphController from "../controllers/assistant";
7
- import * as agentTaskController from "../controllers/agent_task";
8
- import * as threadsController from "../controllers/threads";
9
- import * as schedulesController from "../controllers/schedules";
10
- import * as configController from "../controllers/config";
11
- import * as modelsController from "../controllers/models";
12
- import * as healthController from "../controllers/health";
13
- import * as skillsController from "../controllers/skills";
14
- import * as collectionController from "../controllers/collections";
15
- import * as embeddingsController from "../controllers/embeddings";
16
- import * as entriesController from "../controllers/entries";
17
- import * as toolsController from "../controllers/tools";
18
- import * as dataQueryController from "../controllers/data-query";
19
- import * as workflowTrackingController from "../controllers/workflow-tracking";
20
- import * as paController from "../controllers/personal-assistant";
21
- import * as tasksController from "../controllers/tasks";
22
- import * as exportImportController from "../controllers/export-import";
23
- import { middlewareTypesRoutes } from "../controllers/middleware-types";
24
- import {
25
- createRunSchema,
26
- getAllMemoryItemsSchema,
27
- getAgentStateSchema,
28
- getMemoryItemSchema,
29
- setMemoryItemSchema,
30
- deleteMemoryItemSchema,
31
- clearMemorySchema,
32
- getAgentGraphSchema,
33
- resumeStreamSchema,
34
- triggerAgentTaskSchema,
35
- updateConfigSchema,
36
- getConfigSchema,
37
- getHealthSchema,
38
- getSandboxUrlSchema,
39
- dataQuerySchema,
40
- } from "../schemas";
41
- import { removePendingMessageHandler } from "../controllers/thread_status";
42
- import { registerSandboxProxyRoutes } from "../controllers/sandbox";
43
- import { registerWorkspaceRoutes } from "../controllers/workspace";
44
- import { registerDatabaseConfigRoutes } from "../controllers/database-configs";
45
- import { registerMetricsServerConfigRoutes } from "../controllers/metrics-configs";
46
- import { connectionRoutes } from "../controllers/connections";
47
- import { registerMcpServerConfigRoutes } from "../controllers/mcp-configs";
48
- import { registerEvalRoutes } from "../controllers/eval";
49
- import { registerUserRoutes } from "../controllers/users";
50
- import { registerTenantRoutes } from "../controllers/tenants";
51
- import { registerAuthRoutes } from "../controllers/auth";
52
- import { registerChannelRoutes } from "../channels/routes";
53
- import { registerChannelInstallationRoutes } from "./channel-installations";
54
- import { registerChannelBindingRoutes } from "./channel-bindings";
55
- import { registerMenuItemRoutes } from "./menu-items";
56
- import type { MessageRouter } from "../router/MessageRouter";
57
- import type { ChannelInstallationStore } from "@axiom-lattice/protocols";
58
- // import {
59
- // getThreadStatusHandler,
60
- // getAgentThreadsHandler,
61
- // getActiveThreadsHandler,
62
- // addMessageHandler,
63
- // removeMessageHandler,
64
- // updateQueueConfigHandler,
65
- // } from "../controllers/thread_status";
66
-
67
- import { registerA2ABridgeRoutes } from './a2a-bridge';
68
- import { registerSTTRoutes } from './stt';
69
- import {
70
- getLocalA2AProvider,
71
- getLocalA2AStatus,
72
- restartLocalA2AProvider,
73
- startLocalA2AProvider,
74
- stopLocalA2AProvider,
75
- } from "../controllers/local-a2a";
76
- import {
77
- getLocalA2ATemplates,
78
- } from "../controllers/local-a2a-templates";
79
- import { registerA2ATestConnectionRoute } from "./a2a-test-connection";
80
-
81
- export const registerLatticeRoutes = (app: FastifyInstance, channelDeps?: { router: MessageRouter; installationStore: ChannelInstallationStore }): void => {
82
- // A2A Bridge — WebSocket-based reverse proxy for agents behind NAT
83
- registerA2ABridgeRoutes(app);
84
-
85
- // STT (speech-to-text) transcription
86
- registerSTTRoutes(app);
87
-
88
- // Local A2A runtime management
89
- app.get("/api/local-a2a", getLocalA2AStatus);
90
-
91
- app.get("/api/local-a2a/templates", getLocalA2ATemplates);
92
-
93
- app.get("/api/local-a2a/:assistantId", getLocalA2AProvider);
94
- app.post("/api/local-a2a/:assistantId/start", startLocalA2AProvider);
95
- app.post("/api/local-a2a/:assistantId/stop", stopLocalA2AProvider);
96
- app.post("/api/local-a2a/:assistantId/restart", restartLocalA2AProvider);
97
-
98
- registerA2ATestConnectionRoute(app);
99
-
100
- // 运行路由
101
- app.post<{
102
- Body: any;
103
- }>("/api/runs", runController.createRun);
104
-
105
- // Resume stream route
106
- app.post<{
107
- Body: any;
108
- }>("/api/resume_stream", runController.resumeStream);
109
-
110
- // Abort agent execution for a thread
111
- app.post<{
112
- Params: { assistantId: string; threadId: string };
113
- }>("/api/assistants/:assistantId/threads/:threadId/abort", runController.abortRun);
114
-
115
- // Recover agent execution after a crash or manual abort
116
- app.post<{
117
- Params: { assistantId: string; threadId: string };
118
- }>("/api/assistants/:assistantId/threads/:threadId/recover", runController.recoverRun);
119
-
120
- // app.get<{
121
- // Params: { id: string };
122
- // }>("/api/runs/:id", runController.getRun);
123
-
124
- // app.get<{
125
- // Params: { assistantId: string };
126
- // }>("/api/assistants/:assistantId/runs", runController.getRunsByAssistant);
127
-
128
- // app.post<{
129
- // Params: { id: string };
130
- // }>("/api/runs/:id/cancel", runController.cancelRun);
131
-
132
- // 内存路由
133
- app.get<{
134
- Params: { assistantId: string; thread_id: string };
135
- }>(
136
- "/api/assistants/:assistantId/:thread_id/memory",
137
- { schema: getAllMemoryItemsSchema },
138
- memoryController.getAllMemoryItems
139
- );
140
-
141
- app.get<{
142
- Params: { assistantId: string; thread_id: string };
143
- }>(
144
- "/api/assistants/:assistantId/:thread_id/state",
145
- { schema: getAgentStateSchema },
146
- memoryController.getAgentState
147
- );
148
-
149
- app.get<{
150
- Params: { assistantId: string; key: string };
151
- }>(
152
- "/api/assistants/:assistantId/memory/:key",
153
- { schema: getMemoryItemSchema },
154
- memoryController.getMemoryItem
155
- );
156
-
157
- app.put<{
158
- Params: { assistantId: string; key: string };
159
- Body: any;
160
- }>(
161
- "/api/assistants/:assistantId/memory/:key",
162
- { schema: setMemoryItemSchema },
163
- memoryController.setMemoryItem
164
- );
165
-
166
- app.delete<{
167
- Params: { assistantId: string; key: string };
168
- }>(
169
- "/api/assistants/:assistantId/memory/:key",
170
- { schema: deleteMemoryItemSchema },
171
- memoryController.deleteMemoryItem
172
- );
173
-
174
- app.delete<{
175
- Params: { assistantId: string };
176
- }>(
177
- "/api/assistants/:assistantId/memory",
178
- { schema: clearMemorySchema },
179
- memoryController.clearMemory
180
- );
181
-
182
- // Assistant CRUD routes
183
- app.get("/api/assistants", assistantController.getAssistantList);
184
-
185
- app.get<{
186
- Params: { id: string };
187
- }>("/api/assistants/:id", assistantController.getAssistant);
188
-
189
- app.post<{
190
- Body: any;
191
- }>("/api/assistants", assistantController.createAssistant);
192
-
193
- app.put<{
194
- Params: { id: string };
195
- Body: any;
196
- }>("/api/assistants/:id", assistantController.updateAssistant);
197
-
198
- app.delete<{
199
- Params: { id: string };
200
- }>("/api/assistants/:id", assistantController.deleteAssistant);
201
-
202
- // Personal Assistant routes
203
- app.post<{ Body: any }>("/api/personal-assistant", paController.createPersonalAssistant);
204
- app.get("/api/personal-assistant", paController.getPersonalAssistant);
205
- app.delete("/api/personal-assistant", paController.deletePersonalAssistant);
206
-
207
- // Task CRUD routes
208
- app.get("/api/tasks", tasksController.listTasks);
209
- app.get("/api/tasks/:id", tasksController.getTask);
210
- app.post("/api/tasks", tasksController.createTask);
211
- app.put("/api/tasks/:id", tasksController.updateTask);
212
- app.delete("/api/tasks/:id", tasksController.deleteTask);
213
- app.patch("/api/tasks/:id/complete", tasksController.completeTask);
214
- app.get("/api/tasks/:id/work-items", tasksController.listTaskWorkItems);
215
-
216
- // 图表路由
217
- app.get<{
218
- Params: { assistantId: string };
219
- }>(
220
- "/api/assistants/:assistantId/graph",
221
- { schema: getAgentGraphSchema },
222
- graphController.getAgentGraph
223
- );
224
-
225
- // Agent Task路由
226
- app.post<{
227
- Body: any;
228
- }>(
229
- "/api/agent-tasks/trigger",
230
- { schema: triggerAgentTaskSchema },
231
- agentTaskController.triggerAgentTask
232
- );
233
-
234
- // Thread CRUD routes for a specific assistant
235
- app.get<{
236
- Params: { assistantId: string };
237
- }>("/api/assistants/:assistantId/threads", threadsController.getThreadList);
238
-
239
- app.get<{
240
- Params: { assistantId: string; threadId: string };
241
- }>(
242
- "/api/assistants/:assistantId/threads/:threadId",
243
- threadsController.getThread
244
- );
245
-
246
- app.post<{
247
- Params: { assistantId: string };
248
- Body: any;
249
- }>("/api/assistants/:assistantId/threads", threadsController.createThread);
250
-
251
- app.put<{
252
- Params: { assistantId: string; threadId: string };
253
- Body: any;
254
- }>(
255
- "/api/assistants/:assistantId/threads/:threadId",
256
- threadsController.updateThread
257
- );
258
-
259
- app.delete<{
260
- Params: { assistantId: string; threadId: string };
261
- }>(
262
- "/api/assistants/:assistantId/threads/:threadId",
263
- threadsController.deleteThread
264
- );
265
-
266
- // Configuration routes
267
- app.get(
268
- "/api/config",
269
- { schema: getConfigSchema },
270
- configController.getConfig
271
- );
272
-
273
- app.put<{
274
- Body: { config: Record<string, any> };
275
- }>(
276
- "/api/config",
277
- { schema: updateConfigSchema },
278
- configController.updateConfig
279
- );
280
-
281
- // Models routes
282
- app.get("/api/models", modelsController.getModels);
283
-
284
- app.put<{
285
- Body: { models: any[] };
286
- }>("/api/models", modelsController.updateModels);
287
-
288
- // Tools config meta route
289
- app.get("/api/tools", toolsController.getToolConfigs);
290
-
291
- // Health check route
292
- app.get(
293
- "/health",
294
- { schema: getHealthSchema },
295
- healthController.getHealth
296
- );
297
-
298
- // Schedule routes for viewing scheduled tasks by thread
299
- app.get<{
300
- Params: { assistantId: string; threadId: string };
301
- Querystring: {
302
- status?: ScheduledTaskStatus;
303
- limit?: string;
304
- offset?: string;
305
- };
306
- }>(
307
- "/api/assistants/:assistantId/threads/:threadId/schedules",
308
- schedulesController.getThreadSchedules
309
- );
310
-
311
- // Get a specific scheduled task
312
- app.get<{
313
- Params: { taskId: string };
314
- }>("/api/schedules/:taskId", schedulesController.getScheduledTask);
315
-
316
- // Cancel a scheduled task
317
- app.post<{
318
- Params: { taskId: string };
319
- }>("/api/schedules/:taskId/cancel", schedulesController.cancelScheduledTask);
320
-
321
- // Pause a scheduled cron task
322
- app.post<{
323
- Params: { taskId: string };
324
- }>("/api/schedules/:taskId/pause", schedulesController.pauseScheduledTask);
325
-
326
- // Resume a paused cron task
327
- app.post<{
328
- Params: { taskId: string };
329
- }>("/api/schedules/:taskId/resume", schedulesController.resumeScheduledTask);
330
-
331
- // Skills CRUD routes
332
- app.get("/api/skills", skillsController.getSkillList);
333
-
334
- app.get<{
335
- Params: { id: string };
336
- }>(
337
- "/api/skills/:id",
338
- skillsController.getSkill
339
- );
340
-
341
- app.post<{
342
- Body: any;
343
- }>(
344
- "/api/skills",
345
- skillsController.createSkill
346
- );
347
-
348
- app.put<{
349
- Params: { id: string };
350
- Body: any;
351
- }>(
352
- "/api/skills/:id",
353
- skillsController.updateSkill
354
- );
355
-
356
- app.delete<{
357
- Params: { id: string };
358
- }>(
359
- "/api/skills/:id",
360
- skillsController.deleteSkill
361
- );
362
-
363
- // Skills search and filter routes
364
- app.get<{
365
- Querystring: { key: string; value: string };
366
- }>(
367
- "/api/skills/search/metadata",
368
- skillsController.searchSkillsByMetadata
369
- );
370
-
371
- app.get<{
372
- Querystring: { compatibility: string };
373
- }>(
374
- "/api/skills/filter/compatibility",
375
- skillsController.filterSkillsByCompatibility
376
- );
377
-
378
- app.get<{
379
- Querystring: { license: string };
380
- }>(
381
- "/api/skills/filter/license",
382
- skillsController.filterSkillsByLicense
383
- );
384
-
385
- // Collections CRUD routes
386
- app.get("/api/collections", collectionController.getCollectionList);
387
-
388
- app.get<{
389
- Params: { name: string };
390
- }>("/api/collections/:name", collectionController.getCollection);
391
-
392
- app.post<{
393
- Body: any;
394
- }>("/api/collections", collectionController.createCollection);
395
-
396
- app.put<{
397
- Params: { name: string };
398
- Body: any;
399
- }>("/api/collections/:name", collectionController.updateCollection);
400
-
401
- app.delete<{
402
- Params: { name: string };
403
- }>("/api/collections/:name", collectionController.deleteCollection);
404
-
405
- // Embeddings route
406
- app.get("/api/embeddings", embeddingsController.listEmbeddings);
407
-
408
- // Collection entries routes
409
- app.get<{
410
- Params: { name: string };
411
- }>("/api/collections/:name/entries", entriesController.listEntries);
412
-
413
- app.post<{
414
- Params: { name: string };
415
- Body: any;
416
- }>("/api/collections/:name/entries", entriesController.createEntry);
417
-
418
- app.get<{
419
- Params: { name: string; id: string };
420
- }>("/api/collections/:name/entries/:id", entriesController.getEntry);
421
-
422
- app.put<{
423
- Params: { name: string; id: string };
424
- Body: any;
425
- }>("/api/collections/:name/entries/:id", entriesController.updateEntry);
426
-
427
- app.delete<{
428
- Params: { name: string; id: string };
429
- }>("/api/collections/:name/entries/:id", entriesController.deleteEntry);
430
-
431
- app.post<{
432
- Params: { name: string };
433
- Body: any;
434
- }>("/api/collections/:name/search", entriesController.searchEntries);
435
-
436
- registerSandboxProxyRoutes(app);
437
-
438
- registerEvalRoutes(app);
439
-
440
- registerWorkspaceRoutes(app);
441
-
442
- registerDatabaseConfigRoutes(app);
443
-
444
- registerMetricsServerConfigRoutes(app);
445
-
446
- connectionRoutes(app);
447
-
448
- // Plugin middleware types discovery
449
- middlewareTypesRoutes(app);
450
-
451
- // Data query route
452
- app.post<{
453
- Body: any;
454
- }>(
455
- "/api/data/query",
456
- { schema: dataQuerySchema },
457
- dataQueryController.executeDataQuery
458
- );
459
-
460
- registerMcpServerConfigRoutes(app);
461
-
462
- registerUserRoutes(app);
463
-
464
- registerTenantRoutes(app);
465
-
466
- registerAuthRoutes(app, {
467
- autoApproveUsers: process.env.AUTO_APPROVE_USERS !== "false",
468
- allowTenantRegistration: process.env.ALLOW_TENANT_REGISTRATION !== "false",
469
- });
470
-
471
- registerChannelRoutes(app, channelDeps);
472
-
473
- registerChannelInstallationRoutes(app);
474
-
475
- registerMenuItemRoutes(app);
476
-
477
- if (channelDeps) {
478
- registerChannelBindingRoutes(app);
479
- }
480
-
481
- // Direct inbound message dispatch
482
- if (channelDeps?.router) {
483
- app.post("/api/channels/inbound", async (request, reply) => {
484
- try {
485
- const router = channelDeps.router;
486
- const msg = request.body as Record<string, unknown>;
487
-
488
- if (!msg.channel || !msg.sender || !msg.content) {
489
- reply.status(400).send({
490
- success: false,
491
- message: "Missing required fields: channel, sender, content",
492
- });
493
- return;
494
- }
495
-
496
- const inboundMessage = {
497
- channel: msg.channel as string,
498
- channelInstallationId: (msg.channelInstallationId || "") as string,
499
- tenantId: msg.tenantId as string | undefined,
500
- sender: {
501
- id: (msg.sender as Record<string, unknown>).id as string,
502
- displayName: (msg.sender as Record<string, unknown>).displayName as string | undefined,
503
- },
504
- content: {
505
- text: (msg.content as Record<string, unknown>).text as string,
506
- metadata: (msg.content as Record<string, unknown>).metadata as Record<string, unknown> | undefined,
507
- },
508
- conversation: msg.conversation as { id: string; type: string } | undefined,
509
- replyTarget: msg.replyTarget as Record<string, unknown> | undefined,
510
- } as Parameters<typeof router.dispatch>[0];
511
-
512
- await router.dispatch(inboundMessage).catch((error) => {
513
- console.error(JSON.stringify({
514
- event: "inbound:dispatch_error",
515
- error: error instanceof Error ? error.message : String(error),
516
- channel: inboundMessage.channel,
517
- senderId: inboundMessage.sender.id,
518
- }));
519
- });
520
-
521
- reply.status(200).send({ accepted: true });
522
- } catch (error) {
523
- console.error("Inbound route error:", error);
524
- reply.status(500).send({ success: false, message: "Internal error" });
525
- }
526
- });
527
- }
528
-
529
- // Workflow tracking routes
530
- app.get(
531
- "/api/workflows/definitions",
532
- workflowTrackingController.getAllWorkflowDefinitions
533
- );
534
-
535
- app.get<{
536
- Querystring: { assistantId?: string; status?: string };
537
- }>(
538
- "/api/workflows/runs",
539
- workflowTrackingController.getAllWorkflowRuns
540
- );
541
-
542
- app.get<{
543
- Querystring: { page?: string; pageSize?: string };
544
- }>(
545
- "/api/workflows/inbox",
546
- workflowTrackingController.getInboxItems
547
- );
548
-
549
- app.get<{
550
- Params: { assistantId: string };
551
- }>(
552
- "/api/assistants/:assistantId/workflows/definitions",
553
- workflowTrackingController.getWorkflowDefinitions
554
- );
555
-
556
- app.get<{
557
- Params: { assistantId: string; threadId: string };
558
- }>(
559
- "/api/assistants/:assistantId/threads/:threadId/workflows/runs",
560
- workflowTrackingController.getWorkflowRuns
561
- );
562
-
563
- app.get<{
564
- Params: { runId: string };
565
- }>("/api/workflows/runs/:runId", workflowTrackingController.getWorkflowRun);
566
-
567
- app.delete<{
568
- Params: { runId: string };
569
- }>("/api/workflows/runs/:runId", workflowTrackingController.deleteWorkflowRun);
570
-
571
- app.get<{
572
- Params: { runId: string };
573
- Querystring: { step_type?: string; status?: string };
574
- }>("/api/workflows/runs/:runId/steps", workflowTrackingController.getRunSteps);
575
-
576
- app.get<{
577
- Params: { runId: string };
578
- }>("/api/workflows/runs/:runId/tasks", workflowTrackingController.getRunTasks);
579
-
580
- // Abort a running workflow — stops graph + all sub-agents
581
- app.post<{
582
- Params: { runId: string };
583
- }>("/api/workflows/runs/:runId/abort", workflowTrackingController.abortWorkflowRun);
584
-
585
- // 简化的 Inbox 任务回复接口(后台 streaming 执行,立即返回)
586
- app.post<{
587
- Body: { runId: string; answers: Array<{ questionIndex: number; selectedOptions: string[] }> };
588
- }>("/api/workflows/inbox/reply", workflowTrackingController.replyInboxTask);
589
-
590
- // // Thread 状态查询路由
591
- // app.get("/api/threads/:thread_id/status", getThreadStatusHandler);
592
- // app.get("/api/assistants/:assistant_id/threads/status", getAgentThreadsHandler);
593
- // app.get("/api/threads/active", getActiveThreadsHandler);
594
-
595
- // // Thread 消息队列路由
596
- // app.post("/api/threads/:thread_id/messages", addMessageHandler);
597
- // app.delete("/api/threads/:thread_id/messages/:message_id", removeMessageHandler);
598
- // app.put("/api/threads/:thread_id/queue-config", updateQueueConfigHandler);
599
-
600
- // Delete pending message route
601
- app.delete<{
602
- Params: { assistant_id: string; thread_id: string; message_id: string };
603
- }>(
604
- "/api/assistants/:assistant_id/threads/:thread_id/pending-messages/:message_id",
605
- removePendingMessageHandler
606
- );
607
-
608
- // Export/Import endpoints
609
- app.get("/api/tenants/exportable-types", exportImportController.getExportableTypes);
610
-
611
- app.post<{ Params: { tenantId: string }; Body: { entityTypes: string[]; entityIds?: Record<string, string[]> } }>(
612
- "/api/tenants/:tenantId/export",
613
- exportImportController.exportConfig,
614
- );
615
-
616
- app.post<{ Params: { tenantId: string }; Body: { entityTypes: string[]; entityIds?: Record<string, string[]> } }>(
617
- "/api/tenants/:tenantId/export/confirm",
618
- exportImportController.exportConfigConfirm,
619
- );
620
-
621
- app.post<{ Params: { tenantId: string }; Body: { entityTypes: string[] } }>(
622
- "/api/tenants/:tenantId/export/entities",
623
- exportImportController.previewEntities,
624
- );
625
-
626
- app.get<{ Params: { tenantId: string; jobId: string } }>(
627
- "/api/tenants/:tenantId/export/:jobId/download",
628
- exportImportController.downloadExport,
629
- );
630
-
631
- app.post<{ Params: { tenantId: string }; Body: { bundle: any } }>(
632
- "/api/tenants/:tenantId/import/preview",
633
- exportImportController.importPreview,
634
- );
635
-
636
- app.post<{ Params: { tenantId: string }; Body: { bundle: any; resolutions: Record<string, any> } }>(
637
- "/api/tenants/:tenantId/import/apply",
638
- exportImportController.importApply,
639
- );
640
- };
@@ -1,10 +0,0 @@
1
- import type { FastifyInstance } from "fastify";
2
- import * as menuController from "../controllers/menu-items";
3
-
4
- export function registerMenuItemRoutes(app: FastifyInstance): void {
5
- app.get("/api/menu-items", menuController.getMenuItemList);
6
- app.post("/api/menu-items", menuController.createMenuItem);
7
- app.get("/api/menu-items/:id", menuController.getMenuItem);
8
- app.put("/api/menu-items/:id", menuController.updateMenuItem);
9
- app.delete("/api/menu-items/:id", menuController.deleteMenuItem);
10
- }