@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,257 +0,0 @@
1
- import { FastifyRequest, FastifyReply } from "fastify";
2
- import { agentInstanceManager } from "@axiom-lattice/core";
3
-
4
- // 设置内存项
5
- export const setMemoryItem = async (
6
- request: FastifyRequest,
7
- reply: FastifyReply
8
- ): Promise<void> => {
9
- try {
10
- const { assistantId, key } = request.params as {
11
- assistantId: string;
12
- key: string;
13
- };
14
- const value = request.body;
15
-
16
- if (!assistantId || !key) {
17
- reply.status(400).send({
18
- success: false,
19
- error: "助手ID和键是必需的",
20
- });
21
- return;
22
- }
23
-
24
- if (value === undefined) {
25
- reply.status(400).send({
26
- success: false,
27
- error: "值是必需的",
28
- });
29
- return;
30
- }
31
-
32
- //const result = await memoryModel.setMemoryItem(assistantId, key, value);
33
-
34
- // if (!result.success) {
35
- reply.status(500).send();
36
- return;
37
- // }
38
-
39
- //reply.send(result);
40
- } catch (error: any) {
41
- reply.status(500).send({
42
- success: false,
43
- error: `设置内存项时发生错误: ${error.message}`,
44
- });
45
- }
46
- };
47
-
48
- // 获取内存项
49
- export const getMemoryItem = async (
50
- request: FastifyRequest,
51
- reply: FastifyReply
52
- ): Promise<void> => {
53
- try {
54
- const { assistantId, key } = request.params as {
55
- assistantId: string;
56
- key: string;
57
- };
58
-
59
- if (!assistantId || !key) {
60
- reply.status(400).send({
61
- success: false,
62
- error: "助手ID和键是必需的",
63
- });
64
- return;
65
- }
66
-
67
- //const result = await memoryModel.getMemoryItem(assistantId, key);
68
-
69
- // if (!result.success) {
70
- reply.status(404).send();
71
- return;
72
- // }
73
-
74
- //reply.send(result);
75
- } catch (error: any) {
76
- reply.status(500).send({
77
- success: false,
78
- error: `获取内存项时发生错误: ${error.message}`,
79
- });
80
- }
81
- };
82
-
83
- // 获取所有内存项
84
- export const getAllMemoryItems = async (
85
- request: FastifyRequest,
86
- reply: FastifyReply
87
- ): Promise<void> => {
88
- try {
89
- const { assistantId, thread_id } = request.params as {
90
- assistantId: string;
91
- thread_id: string;
92
- };
93
- const tenant_id = request.headers["x-tenant-id"] as string;
94
-
95
- if (!thread_id) {
96
- reply.status(400).send({
97
- success: false,
98
- error: "线程ID是必需的",
99
- });
100
- return;
101
- }
102
-
103
- if (!assistantId) {
104
- reply.status(400).send({
105
- success: false,
106
- error: "助手ID是必需的",
107
- });
108
- return;
109
- }
110
-
111
- const agent = agentInstanceManager.getAgent({ assistant_id: assistantId, tenant_id, thread_id: thread_id })
112
-
113
- const result = await agent.getCurrentMessages();
114
-
115
- if (!result) {
116
- reply.status(500).send(result);
117
- return;
118
- }
119
-
120
- reply.send(result);
121
- } catch (error: any) {
122
- reply.status(500).send({
123
- success: false,
124
- error: `获取所有内存项时发生错误: ${error.message}`,
125
- });
126
- }
127
- };
128
-
129
- // 获取助手状态
130
- export const getAgentState = async (
131
- request: FastifyRequest,
132
- reply: FastifyReply
133
- ): Promise<void> => {
134
- try {
135
- const { assistantId, thread_id } = request.params as {
136
- assistantId: string;
137
- thread_id: string;
138
- };
139
-
140
- if (!thread_id) {
141
- reply.status(400).send({
142
- success: false,
143
- error: "线程ID是必需的",
144
- });
145
- return;
146
- }
147
-
148
- if (!assistantId) {
149
- reply.status(400).send({
150
- success: false,
151
- error: "助手ID是必需的",
152
- });
153
- return;
154
- }
155
-
156
- const tenant_id = request.headers["x-tenant-id"] as string;
157
- const agent = agentInstanceManager.getAgent({ assistant_id: assistantId, tenant_id, thread_id: thread_id })
158
-
159
- // 1. 获取 LangGraph 状态(现有逻辑)
160
- const result = await agent.getCurrentState();
161
- const pendingMessages = await agent.getPendingMessages();
162
-
163
-
164
- if (!result) {
165
- reply.status(500).send(result);
166
- return;
167
- }
168
-
169
- // 3. 合并返回
170
- // Normalize pendingMessages content to string for consistent frontend format
171
- const normalizedPendingMessages = pendingMessages.map(msg => ({
172
- ...msg,
173
- content: typeof msg.content === 'object' && msg.content !== null
174
- ? ('message' in msg.content ? msg.content.message : JSON.stringify(msg.content))
175
- : String(msg.content || '')
176
- }));
177
-
178
- const mergedResult = {
179
- ...result,
180
- pendingMessages: normalizedPendingMessages
181
- };
182
-
183
- reply.send(mergedResult);
184
- } catch (error: any) {
185
- reply.status(500).send({
186
- success: false,
187
- error: `获取助手状态时发生错误: ${error.message}`,
188
- });
189
- }
190
- };
191
-
192
- // 删除内存项
193
- export const deleteMemoryItem = async (
194
- request: FastifyRequest,
195
- reply: FastifyReply
196
- ): Promise<void> => {
197
- try {
198
- const { assistantId, key } = request.params as {
199
- assistantId: string;
200
- key: string;
201
- };
202
-
203
- if (!assistantId || !key) {
204
- reply.status(400).send({
205
- success: false,
206
- error: "助手ID和键是必需的",
207
- });
208
- return;
209
- }
210
-
211
- //const result = await memoryModel.deleteMemoryItem(assistantId, key);
212
-
213
- // if (!result.success) {
214
- reply.status(500).send();
215
- return;
216
- // }
217
-
218
- reply.status(204).send();
219
- } catch (error: any) {
220
- reply.status(500).send({
221
- success: false,
222
- error: `删除内存项时发生错误: ${error.message}`,
223
- });
224
- }
225
- };
226
-
227
- // 清除内存
228
- export const clearMemory = async (
229
- request: FastifyRequest,
230
- reply: FastifyReply
231
- ): Promise<void> => {
232
- try {
233
- const { assistantId } = request.params as { assistantId: string };
234
-
235
- if (!assistantId) {
236
- reply.status(400).send({
237
- success: false,
238
- error: "助手ID是必需的",
239
- });
240
- return;
241
- }
242
-
243
- let result: any; //= await memoryModel.clearMemory(assistantId);
244
-
245
- if (!result.success) {
246
- reply.status(500).send(result);
247
- return;
248
- }
249
-
250
- reply.status(204).send();
251
- } catch (error: any) {
252
- reply.status(500).send({
253
- success: false,
254
- error: `清除内存时发生错误: ${error.message}`,
255
- });
256
- }
257
- };
@@ -1,114 +0,0 @@
1
- import type { FastifyRequest, FastifyReply } from "fastify";
2
- import type { CreateMenuItemInput } from "@axiom-lattice/protocols";
3
- import { getMenuRegistry } from "@axiom-lattice/core";
4
-
5
- function getTenantId(request: FastifyRequest): string {
6
- const userTenantId = (request as any).user?.tenantId;
7
- if (userTenantId) return userTenantId;
8
- return (request.headers["x-tenant-id"] as string) || "default";
9
- }
10
-
11
- function errorMessage(err: unknown): string {
12
- return err instanceof Error ? err.message : "Unexpected error";
13
- }
14
-
15
- export async function getMenuItemList(
16
- request: FastifyRequest<{
17
- Querystring: { menuTarget?: string };
18
- }>,
19
- _reply: FastifyReply,
20
- ) {
21
- const tenantId = getTenantId(request);
22
- try {
23
- const registry = getMenuRegistry();
24
- const items = await registry.list({ tenantId, menuTarget: request.query.menuTarget as "sidebar" | "workspace" | undefined });
25
- return { success: true, message: "Menu items retrieved", data: { records: items, total: items.length } };
26
- } catch (error) {
27
- const msg = errorMessage(error);
28
- console.error("Failed to get menu items:", msg);
29
- return { success: false, message: msg, data: { records: [], total: 0 } };
30
- }
31
- }
32
-
33
- export async function getMenuItem(
34
- request: FastifyRequest<{ Params: { id: string } }>,
35
- reply: FastifyReply,
36
- ) {
37
- const tenantId = getTenantId(request);
38
- try {
39
- const registry = getMenuRegistry();
40
- const item = await registry.getById(request.params.id);
41
- if (!item || item.tenantId !== tenantId) {
42
- reply.status(404);
43
- return { success: false, message: "Menu item not found" };
44
- }
45
- return { success: true, message: "Menu item retrieved", data: item };
46
- } catch (error) {
47
- const msg = errorMessage(error);
48
- console.error("Failed to get menu item:", msg);
49
- reply.status(500);
50
- return { success: false, message: msg };
51
- }
52
- }
53
-
54
- export async function createMenuItem(
55
- request: FastifyRequest<{ Body: CreateMenuItemInput }>,
56
- reply: FastifyReply,
57
- ) {
58
- const tenantId = getTenantId(request);
59
- try {
60
- const registry = getMenuRegistry();
61
- const item = await registry.create({ ...request.body, tenantId });
62
- reply.status(201);
63
- return { success: true, message: "Menu item created", data: item };
64
- } catch (error) {
65
- const msg = errorMessage(error);
66
- console.error("Failed to create menu item:", msg);
67
- reply.status(500);
68
- return { success: false, message: msg };
69
- }
70
- }
71
-
72
- export async function updateMenuItem(
73
- request: FastifyRequest<{ Params: { id: string }; Body: Partial<CreateMenuItemInput & { enabled: boolean }> }>,
74
- reply: FastifyReply,
75
- ) {
76
- try {
77
- const tenantId = getTenantId(request);
78
- const registry = getMenuRegistry();
79
- const existing = await registry.getById(request.params.id);
80
- if (!existing || existing.tenantId !== tenantId) {
81
- reply.status(404);
82
- return { success: false, message: "Menu item not found" };
83
- }
84
- const item = await registry.update(request.params.id, request.body);
85
- return { success: true, message: "Menu item updated", data: item };
86
- } catch (error) {
87
- const msg = errorMessage(error);
88
- console.error("Failed to update menu item:", msg);
89
- reply.status(500);
90
- return { success: false, message: msg };
91
- }
92
- }
93
-
94
- export async function deleteMenuItem(
95
- request: FastifyRequest<{ Params: { id: string } }>,
96
- reply: FastifyReply,
97
- ) {
98
- try {
99
- const tenantId = getTenantId(request);
100
- const registry = getMenuRegistry();
101
- const existing = await registry.getById(request.params.id);
102
- if (!existing || existing.tenantId !== tenantId) {
103
- reply.status(404);
104
- return { success: false, message: "Menu item not found" };
105
- }
106
- await registry.delete(request.params.id);
107
- return { success: true, message: "Menu item deleted" };
108
- } catch (error) {
109
- const msg = errorMessage(error);
110
- console.error("Failed to delete menu item:", msg);
111
- reply.status(500);
112
- return { success: false, message: msg };
113
- }
114
- }