@axiom-lattice/gateway 3.0.2 → 3.0.4

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 +37 -9
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +37 -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,334 +0,0 @@
1
- import type { ExportableEntityDefinition, ExportableEntity, ImportPreviewResult } from '@axiom-lattice/core';
2
- import { getStoreLattice } from '@axiom-lattice/core';
3
- import type { EvalStore } from '@axiom-lattice/protocols';
4
-
5
- function getStore(): EvalStore {
6
- return getStoreLattice('default', 'eval').store as unknown as EvalStore;
7
- }
8
-
9
- export const evalRegistration: ExportableEntityDefinition = {
10
- entityType: 'eval',
11
- label: 'Eval(评估)',
12
- category: 'core',
13
- dependsOn: [],
14
- cascadeParents: [],
15
- referenceFields: { suiteId: 'eval_suite', projectId: 'eval_project', runId: 'eval_run', caseId: 'eval_case' },
16
-
17
- async listForExport(tenantId: string): Promise<ExportableEntity[]> {
18
- const store = getStore();
19
- const projects = await store.getProjectsByTenant(tenantId);
20
- const entities: ExportableEntity[] = [];
21
-
22
- for (const project of projects) {
23
- entities.push({
24
- _exportId: '',
25
- data: {
26
- _subType: 'eval_project',
27
- id: project.id,
28
- name: project.name,
29
- description: project.description,
30
- version: project.version,
31
- judgeModelConfig: project.judgeModelConfig,
32
- targetServerConfig: project.targetServerConfig,
33
- concurrency: project.concurrency,
34
- reportConfig: project.reportConfig,
35
- },
36
- });
37
-
38
- const suites = await store.getSuitesByProject(tenantId, project.id);
39
- for (const suite of suites) {
40
- entities.push({
41
- _exportId: '',
42
- data: {
43
- _subType: 'eval_suite',
44
- id: suite.id,
45
- projectId: suite.projectId,
46
- name: suite.name,
47
- },
48
- });
49
-
50
- const cases = await store.getCasesBySuite(tenantId, suite.id);
51
- for (const c of cases) {
52
- entities.push({
53
- _exportId: '',
54
- data: {
55
- _subType: 'eval_case',
56
- id: c.id,
57
- suiteId: c.suiteId,
58
- inputMessage: c.inputMessage,
59
- inputFiles: c.inputFiles,
60
- steps: c.steps,
61
- outputType: c.outputType,
62
- contentAssertion: c.contentAssertion,
63
- rubrics: c.rubrics,
64
- },
65
- });
66
- }
67
- }
68
-
69
- const runs = await store.getRunsByTenant(tenantId, { projectId: project.id });
70
- for (const run of runs) {
71
- entities.push({
72
- _exportId: '',
73
- data: {
74
- _subType: 'eval_run',
75
- id: run.id,
76
- projectId: run.projectId,
77
- status: run.status,
78
- concurrency: run.concurrency,
79
- totalCases: run.totalCases,
80
- passedCases: run.passedCases,
81
- failedCases: run.failedCases,
82
- avgScore: run.avgScore,
83
- error: run.error,
84
- },
85
- });
86
-
87
- const results = await store.getResultsByRun(tenantId, run.id);
88
- for (const result of results) {
89
- entities.push({
90
- _exportId: '',
91
- data: {
92
- _subType: 'eval_run_result',
93
- id: result.id,
94
- runId: result.runId,
95
- suiteName: result.suiteName,
96
- caseId: result.caseId,
97
- pass: result.pass,
98
- score: result.score,
99
- summary: result.summary,
100
- dimensionResults: result.dimensionResults,
101
- durationMs: result.durationMs,
102
- messages: result.messages,
103
- logs: result.logs,
104
- error: result.error,
105
- },
106
- });
107
- }
108
- }
109
- }
110
-
111
- return entities;
112
- },
113
-
114
- async previewImport(
115
- tenantId: string,
116
- entities: ExportableEntity[],
117
- ): Promise<ImportPreviewResult> {
118
- const store = getStore();
119
-
120
- const existingProjects = await store.getProjectsByTenant(tenantId);
121
- const existingProjectIds = new Set(existingProjects.map((p) => p.id));
122
- const existingProjectNames = new Set(existingProjects.map((p) => p.name));
123
-
124
- const existingSuites: Map<string, Set<string>> = new Map();
125
- const existingSuiteIds = new Set<string>();
126
- const existingCaseIds = new Set<string>();
127
- const existingRunIds = new Set<string>();
128
- const existingResultIds = new Set<string>();
129
-
130
- for (const project of existingProjects) {
131
- const suites = await store.getSuitesByProject(tenantId, project.id);
132
- existingSuites.set(project.id, new Set(suites.map((s) => `${s.projectId}:${s.name}`)));
133
- for (const s of suites) {
134
- existingSuiteIds.add(s.id);
135
- try {
136
- const cases = await store.getCasesBySuite(tenantId, s.id);
137
- for (const c of cases) existingCaseIds.add(c.id);
138
- } catch { /* suite may not exist */ }
139
- }
140
- }
141
-
142
- for (const project of existingProjects) {
143
- const runs = await store.getRunsByTenant(tenantId, { projectId: project.id });
144
- for (const run of runs) {
145
- existingRunIds.add(run.id);
146
- try {
147
- const results = await store.getResultsByRun(tenantId, run.id);
148
- for (const r of results) existingResultIds.add(r.id);
149
- } catch { /* run may not exist */ }
150
- }
151
- }
152
-
153
- const conflicts: ImportPreviewResult['conflicts'] = [];
154
- const insertions: ImportPreviewResult['insertions'] = [];
155
-
156
- for (const entity of entities) {
157
- const d = entity.data as Record<string, unknown>;
158
- const subType = d._subType as string;
159
- const id = d.id as string;
160
-
161
- switch (subType) {
162
- case 'eval_project': {
163
- const name = d.name as string;
164
- if (existingProjectIds.has(id)) {
165
- conflicts.push({
166
- _exportId: entity._exportId,
167
- entityType: 'eval_project',
168
- conflictType: 'id_exists',
169
- existingId: id,
170
- existingName: name,
171
- });
172
- } else if (name && existingProjectNames.has(name)) {
173
- conflicts.push({
174
- _exportId: entity._exportId,
175
- entityType: 'eval_project',
176
- conflictType: 'unique_constraint',
177
- existingName: name,
178
- field: 'name',
179
- });
180
- } else {
181
- insertions.push({ _exportId: entity._exportId, entityType: 'eval_project', name });
182
- }
183
- break;
184
- }
185
- case 'eval_suite': {
186
- const projectId = d.projectId as string;
187
- const name = d.name as string;
188
- const suiteKey = `${projectId}:${name}`;
189
- const projectSuites = existingSuites.get(projectId);
190
- if (existingSuiteIds.has(id)) {
191
- conflicts.push({
192
- _exportId: entity._exportId,
193
- entityType: 'eval_suite',
194
- conflictType: 'id_exists',
195
- existingId: id,
196
- existingName: name,
197
- });
198
- } else if (projectSuites?.has(suiteKey)) {
199
- conflicts.push({
200
- _exportId: entity._exportId,
201
- entityType: 'eval_suite',
202
- conflictType: 'unique_constraint',
203
- existingName: name,
204
- field: 'projectId+name',
205
- });
206
- } else {
207
- insertions.push({ _exportId: entity._exportId, entityType: 'eval_suite', name });
208
- }
209
- break;
210
- }
211
- case 'eval_case': {
212
- if (existingCaseIds.has(id)) {
213
- conflicts.push({
214
- _exportId: entity._exportId,
215
- entityType: 'eval_case',
216
- conflictType: 'id_exists',
217
- existingId: id,
218
- });
219
- } else {
220
- insertions.push({ _exportId: entity._exportId, entityType: 'eval_case', name: id });
221
- }
222
- break;
223
- }
224
- case 'eval_run': {
225
- if (existingRunIds.has(id)) {
226
- conflicts.push({
227
- _exportId: entity._exportId,
228
- entityType: 'eval_run',
229
- conflictType: 'id_exists',
230
- existingId: id,
231
- });
232
- } else {
233
- insertions.push({ _exportId: entity._exportId, entityType: 'eval_run', name: id });
234
- }
235
- break;
236
- }
237
- case 'eval_run_result': {
238
- if (existingResultIds.has(id)) {
239
- conflicts.push({
240
- _exportId: entity._exportId,
241
- entityType: 'eval_run_result',
242
- conflictType: 'id_exists',
243
- existingId: id,
244
- });
245
- } else {
246
- insertions.push({ _exportId: entity._exportId, entityType: 'eval_run_result', name: id });
247
- }
248
- break;
249
- }
250
- }
251
- }
252
-
253
- return { conflicts, insertions, errors: [] };
254
- },
255
-
256
- async applyImport(tenantId, entity, resolution) {
257
- if (resolution.action === 'skip') return {};
258
- const store = getStore();
259
- const d = entity.data as Record<string, unknown>;
260
- const subType = d._subType as string;
261
- const id = resolution.action === 'rename' && resolution.newId ? resolution.newId : d.id as string;
262
-
263
- switch (subType) {
264
- case 'eval_project': {
265
- if (resolution.action === 'overwrite') {
266
- try { await store.deleteProject(tenantId, id); } catch { /* may not exist */ }
267
- }
268
- await store.createProject(tenantId, id, {
269
- name: d.name as string,
270
- description: d.description as string | undefined,
271
- version: d.version as string | undefined,
272
- judgeModelConfig: d.judgeModelConfig as Record<string, unknown>,
273
- targetServerConfig: d.targetServerConfig as Record<string, unknown>,
274
- concurrency: d.concurrency as number | undefined,
275
- reportConfig: d.reportConfig as Record<string, unknown> | undefined,
276
- });
277
- break;
278
- }
279
- case 'eval_suite': {
280
- if (resolution.action === 'overwrite') {
281
- try { await store.deleteSuite(tenantId, id); } catch { /* may not exist */ }
282
- }
283
- await store.createSuite(tenantId, d.projectId as string, id, {
284
- name: d.name as string,
285
- });
286
- break;
287
- }
288
- case 'eval_case': {
289
- if (resolution.action === 'overwrite') {
290
- try { await store.deleteCase(tenantId, id); } catch { /* may not exist */ }
291
- }
292
- await store.createCase(tenantId, d.suiteId as string, id, {
293
- inputMessage: d.inputMessage as string,
294
- inputFiles: d.inputFiles as Record<string, string> | undefined,
295
- steps: d.steps as Array<{ agent_id: string; override_message?: string }>,
296
- outputType: d.outputType as 'file_content' | 'message_content',
297
- contentAssertion: d.contentAssertion as string,
298
- rubrics: d.rubrics as Array<{ name: string; weight: number; description: string }> | undefined,
299
- });
300
- break;
301
- }
302
- case 'eval_run': {
303
- if (resolution.action === 'overwrite') {
304
- try { await store.deleteRun(tenantId, id); } catch { /* may not exist */ }
305
- }
306
- await store.createRun(tenantId, d.projectId as string, id, {
307
- totalCases: d.totalCases as number,
308
- concurrency: d.concurrency as number,
309
- });
310
- break;
311
- }
312
- case 'eval_run_result': {
313
- if (resolution.action === 'overwrite') {
314
- try { await store.deleteRunResult(tenantId, entity.data.id as string); } catch { /* may not exist */ }
315
- }
316
- await store.createRunResult(tenantId, d.runId as string, id, {
317
- suiteName: d.suiteName as string,
318
- caseId: d.caseId as string | undefined,
319
- pass: d.pass as boolean,
320
- score: d.score as number,
321
- summary: d.summary as string | undefined,
322
- dimensionResults: d.dimensionResults as Array<{ name: string; score: number; reason: string }> | undefined,
323
- durationMs: d.durationMs as number | undefined,
324
- messages: d.messages as Array<{ role: string; content: string; id?: string }> | undefined,
325
- logs: d.logs as Array<{ timestamp: string; level: string; message: string; data?: unknown }> | undefined,
326
- error: d.error as string | undefined,
327
- });
328
- break;
329
- }
330
- }
331
-
332
- return { newId: id };
333
- },
334
- };
@@ -1,31 +0,0 @@
1
- import { ExportableEntityRegistry } from '@axiom-lattice/core';
2
- import { skillRegistration } from './skill.registration';
3
- import { agentRegistration } from './agent.registration';
4
- import { bindingRegistration } from './binding.registration';
5
- import { databaseConfigRegistration } from './database-config.registration';
6
- import { metricsConfigRegistration } from './metrics-config.registration';
7
- import { mcpConfigRegistration } from './mcp-config.registration';
8
- import { connectionRegistration } from './connection.registration';
9
- import { collectionRegistration } from './collection.registration';
10
- import { channelInstallationRegistration } from './channel-installation.registration';
11
- import { menuRegistration } from './menu.registration';
12
- import { taskRegistration } from './task.registration';
13
- import { a2aApiKeyRegistration } from './a2a-api-key.registration';
14
- import { evalRegistration } from './eval.registration';
15
-
16
- export function registerAllBuiltinEntities(): void {
17
- const registry = ExportableEntityRegistry.getInstance();
18
- registry.register(skillRegistration);
19
- registry.register(agentRegistration);
20
- registry.register(bindingRegistration);
21
- registry.register(databaseConfigRegistration);
22
- registry.register(metricsConfigRegistration);
23
- registry.register(mcpConfigRegistration);
24
- registry.register(connectionRegistration);
25
- registry.register(collectionRegistration);
26
- registry.register(channelInstallationRegistration);
27
- registry.register(menuRegistration);
28
- registry.register(taskRegistration);
29
- registry.register(a2aApiKeyRegistration);
30
- registry.register(evalRegistration);
31
- }
@@ -1,97 +0,0 @@
1
- import type { ExportableEntityDefinition, ExportableEntity, ImportPreviewResult } from '@axiom-lattice/core';
2
- import { getStoreLattice } from '@axiom-lattice/core';
3
- import type { McpServerConfigStore } from '@axiom-lattice/protocols';
4
-
5
- function getStore(): McpServerConfigStore {
6
- return getStoreLattice('default', 'mcp').store as unknown as McpServerConfigStore;
7
- }
8
-
9
- export const mcpConfigRegistration: ExportableEntityDefinition = {
10
- entityType: 'mcp_config',
11
- label: 'MCP Config(MCP配置)',
12
- category: 'core',
13
- dependsOn: [],
14
- cascadeParents: [],
15
-
16
- async listForExport(tenantId: string): Promise<ExportableEntity[]> {
17
- const store = getStore();
18
- const configs = await store.getAllConfigs(tenantId);
19
- return configs.map((c) => ({
20
- _exportId: '',
21
- data: {
22
- id: c.id,
23
- key: c.key,
24
- name: c.name,
25
- description: c.description,
26
- config: c.config,
27
- selectedTools: c.selectedTools,
28
- status: c.status,
29
- },
30
- }));
31
- },
32
-
33
- async previewImport(
34
- tenantId: string,
35
- entities: ExportableEntity[],
36
- ): Promise<ImportPreviewResult> {
37
- const store = getStore();
38
- const existing = await store.getAllConfigs(tenantId);
39
- const existingIds = new Set(existing.map((c) => c.id));
40
- const existingKeys = new Set(existing.map((c) => c.key));
41
-
42
- const conflicts: ImportPreviewResult['conflicts'] = [];
43
- const insertions: ImportPreviewResult['insertions'] = [];
44
-
45
- for (const entity of entities) {
46
- const d = entity.data as Record<string, unknown>;
47
- const id = d.id as string;
48
- const key = d.key as string;
49
-
50
- if (existingIds.has(id)) {
51
- conflicts.push({
52
- _exportId: entity._exportId,
53
- entityType: 'mcp_config',
54
- conflictType: 'id_exists',
55
- existingId: id,
56
- existingName: (d.name as string) || key,
57
- });
58
- } else if (key && existingKeys.has(key)) {
59
- conflicts.push({
60
- _exportId: entity._exportId,
61
- entityType: 'mcp_config',
62
- conflictType: 'unique_constraint',
63
- existingName: (d.name as string) || key,
64
- field: 'key',
65
- });
66
- } else {
67
- insertions.push({
68
- _exportId: entity._exportId,
69
- entityType: 'mcp_config',
70
- name: (d.name as string) || key,
71
- });
72
- }
73
- }
74
-
75
- return { conflicts, insertions, errors: [] };
76
- },
77
-
78
- async applyImport(tenantId, entity, resolution) {
79
- const store = getStore();
80
- const data = entity.data as Record<string, unknown>;
81
- const id = resolution.action === 'rename' && resolution.newId ? resolution.newId : data.id as string;
82
-
83
- if (resolution.action === 'overwrite') {
84
- try { await store.deleteConfig(tenantId, id); } catch { /* may not exist */ }
85
- }
86
-
87
- await store.createConfig(tenantId, id, {
88
- key: data.key as string,
89
- name: data.name as string | undefined,
90
- description: data.description as string | undefined,
91
- config: data.config as any,
92
- selectedTools: data.selectedTools as string[] | undefined,
93
- });
94
-
95
- return { newId: id };
96
- },
97
- };
@@ -1,91 +0,0 @@
1
- import type { ExportableEntityDefinition, ExportableEntity, ImportPreviewResult } from '@axiom-lattice/core';
2
- import { getStoreLattice } from '@axiom-lattice/core';
3
- import type { MenuRegistry } from '@axiom-lattice/protocols';
4
-
5
- function getStore(): MenuRegistry {
6
- return getStoreLattice('default', 'menu').store as unknown as MenuRegistry;
7
- }
8
-
9
- export const menuRegistration: ExportableEntityDefinition = {
10
- entityType: 'menu',
11
- label: 'Menu(菜单)',
12
- category: 'core',
13
- dependsOn: ['agent'],
14
- cascadeParents: [],
15
-
16
- async listForExport(tenantId: string): Promise<ExportableEntity[]> {
17
- const store = getStore();
18
- const menus = await store.list({ tenantId });
19
- return menus.map((m) => ({
20
- _exportId: '',
21
- data: {
22
- id: m.id,
23
- menuTarget: m.menuTarget,
24
- group: m.group,
25
- name: m.name,
26
- icon: m.icon,
27
- sortOrder: m.sortOrder,
28
- contentType: m.contentType,
29
- contentConfig: m.contentConfig,
30
- enabled: m.enabled,
31
- },
32
- }));
33
- },
34
-
35
- async previewImport(
36
- tenantId: string,
37
- entities: ExportableEntity[],
38
- ): Promise<ImportPreviewResult> {
39
- const store = getStore();
40
- const existing = await store.list({ tenantId });
41
- const existingIds = new Set(existing.map((m) => m.id));
42
-
43
- const conflicts: ImportPreviewResult['conflicts'] = [];
44
- const insertions: ImportPreviewResult['insertions'] = [];
45
-
46
- for (const entity of entities) {
47
- const d = entity.data as Record<string, unknown>;
48
- const id = d.id as string;
49
- if (existingIds.has(id)) {
50
- conflicts.push({
51
- _exportId: entity._exportId,
52
- entityType: 'menu',
53
- conflictType: 'id_exists',
54
- existingId: id,
55
- existingName: (d.name as string) || id,
56
- });
57
- } else {
58
- insertions.push({
59
- _exportId: entity._exportId,
60
- entityType: 'menu',
61
- name: (d.name as string) || id,
62
- });
63
- }
64
- }
65
-
66
- return { conflicts, insertions, errors: [] };
67
- },
68
-
69
- async applyImport(tenantId, entity, resolution) {
70
- const store = getStore();
71
- const d = entity.data as Record<string, unknown>;
72
- const id = resolution.action === 'rename' && resolution.newId ? resolution.newId : d.id as string;
73
-
74
- if (resolution.action === 'overwrite') {
75
- try { await store.delete(id); } catch { /* may not exist */ }
76
- }
77
-
78
- await store.create({
79
- tenantId,
80
- menuTarget: d.menuTarget as 'sidebar' | 'workspace',
81
- group: d.group as string | undefined,
82
- name: d.name as string,
83
- icon: d.icon as string | undefined,
84
- sortOrder: d.sortOrder as number | undefined,
85
- contentType: d.contentType as 'agent' | 'html' | 'custom',
86
- contentConfig: d.contentConfig as any,
87
- });
88
-
89
- return { newId: undefined };
90
- },
91
- };
@@ -1,94 +0,0 @@
1
- import type { ExportableEntityDefinition, ExportableEntity, ImportPreviewResult } from '@axiom-lattice/core';
2
- import { getStoreLattice } from '@axiom-lattice/core';
3
- import type { MetricsServerConfigStore } from '@axiom-lattice/protocols';
4
-
5
- function getStore(): MetricsServerConfigStore {
6
- return getStoreLattice('default', 'metrics').store as unknown as MetricsServerConfigStore;
7
- }
8
-
9
- export const metricsConfigRegistration: ExportableEntityDefinition = {
10
- entityType: 'metrics_config',
11
- label: 'Metrics Config(指标配置)',
12
- category: 'core',
13
- dependsOn: [],
14
- cascadeParents: [],
15
-
16
- async listForExport(tenantId: string): Promise<ExportableEntity[]> {
17
- const store = getStore();
18
- const configs = await store.getAllConfigs(tenantId);
19
- return configs.map((c) => ({
20
- _exportId: '',
21
- data: {
22
- id: c.id,
23
- key: c.key,
24
- name: c.name,
25
- description: c.description,
26
- config: c.config,
27
- },
28
- }));
29
- },
30
-
31
- async previewImport(
32
- tenantId: string,
33
- entities: ExportableEntity[],
34
- ): Promise<ImportPreviewResult> {
35
- const store = getStore();
36
- const existing = await store.getAllConfigs(tenantId);
37
- const existingIds = new Set(existing.map((c) => c.id));
38
- const existingKeys = new Set(existing.map((c) => c.key));
39
-
40
- const conflicts: ImportPreviewResult['conflicts'] = [];
41
- const insertions: ImportPreviewResult['insertions'] = [];
42
-
43
- for (const entity of entities) {
44
- const d = entity.data as Record<string, unknown>;
45
- const id = d.id as string;
46
- const key = d.key as string;
47
-
48
- if (existingIds.has(id)) {
49
- conflicts.push({
50
- _exportId: entity._exportId,
51
- entityType: 'metrics_config',
52
- conflictType: 'id_exists',
53
- existingId: id,
54
- existingName: (d.name as string) || key,
55
- });
56
- } else if (key && existingKeys.has(key)) {
57
- conflicts.push({
58
- _exportId: entity._exportId,
59
- entityType: 'metrics_config',
60
- conflictType: 'unique_constraint',
61
- existingName: (d.name as string) || key,
62
- field: 'key',
63
- });
64
- } else {
65
- insertions.push({
66
- _exportId: entity._exportId,
67
- entityType: 'metrics_config',
68
- name: (d.name as string) || key,
69
- });
70
- }
71
- }
72
-
73
- return { conflicts, insertions, errors: [] };
74
- },
75
-
76
- async applyImport(tenantId, entity, resolution) {
77
- const store = getStore();
78
- const data = entity.data as Record<string, unknown>;
79
- const id = resolution.action === 'rename' && resolution.newId ? resolution.newId : data.id as string;
80
-
81
- if (resolution.action === 'overwrite') {
82
- try { await store.deleteConfig(tenantId, id); } catch { /* may not exist */ }
83
- }
84
-
85
- await store.createConfig(tenantId, id, {
86
- key: data.key as string,
87
- name: data.name as string | undefined,
88
- description: data.description as string | undefined,
89
- config: data.config as any,
90
- });
91
-
92
- return { newId: id };
93
- },
94
- };