@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,104 +0,0 @@
1
- // Queue service adapter that uses QueueLatticeManager from core package
2
- // Provides backward-compatible API for gateway services
3
-
4
- import {
5
- queueLatticeManager,
6
- registerQueueLattice,
7
- getQueueLattice,
8
- } from "@axiom-lattice/core";
9
- import { QueueType } from "@axiom-lattice/protocols";
10
- import type { QueueConfig, QueueClient } from "@axiom-lattice/protocols";
11
- import { RedisQueueClient } from "@axiom-lattice/queue-redis";
12
-
13
- export type QueueServiceType = "memory" | "redis";
14
-
15
- // Default queue key
16
- const DEFAULT_QUEUE_KEY = "default";
17
-
18
- // Global configuration for queue service type
19
- // Can be set via environment variable QUEUE_SERVICE_TYPE or via LatticeGateway configuration
20
- let queueServiceType: QueueServiceType =
21
- (process.env.QUEUE_SERVICE_TYPE as QueueServiceType) || "memory";
22
-
23
- /**
24
- * Configure the queue service type
25
- * This will register or update the default queue service
26
- * @param type - "memory" or "redis"
27
- */
28
- export const setQueueServiceType = (type: QueueServiceType): void => {
29
- queueServiceType = type;
30
- console.log(`Queue service type set to: ${type}`);
31
-
32
- // Register or update the queue service
33
- const queueName = process.env.QUEUE_NAME || "tasks";
34
- const config: QueueConfig = {
35
- name: "Default Queue Service",
36
- description: `Default ${type} queue service`,
37
- type: type === "redis" ? QueueType.REDIS : QueueType.MEMORY,
38
- queueName,
39
- options:
40
- type === "redis"
41
- ? {
42
- redisUrl: process.env.REDIS_URL,
43
- redisPassword: process.env.REDIS_PASSWORD,
44
- }
45
- : undefined,
46
- };
47
-
48
- // Remove existing queue if it exists
49
- if (queueLatticeManager.hasLattice(DEFAULT_QUEUE_KEY)) {
50
- queueLatticeManager.removeLattice(DEFAULT_QUEUE_KEY);
51
- }
52
-
53
- // Create client for Redis type
54
- let client: QueueClient | undefined;
55
- if (type === "redis") {
56
- client = new RedisQueueClient(queueName, {
57
- redisUrl: process.env.REDIS_URL,
58
- redisPassword: process.env.REDIS_PASSWORD,
59
- });
60
- }
61
-
62
- // Register the new queue service
63
- registerQueueLattice(DEFAULT_QUEUE_KEY, config, client);
64
- };
65
-
66
- /**
67
- * Get the current queue service type
68
- */
69
- export const getQueueServiceType = (): QueueServiceType => {
70
- return queueServiceType;
71
- };
72
-
73
- /**
74
- * Get the default queue service
75
- * If not registered, register it with the current configuration
76
- */
77
- const getQueueService = () => {
78
- // Check if queue is already registered
79
- if (!queueLatticeManager.hasLattice(DEFAULT_QUEUE_KEY)) {
80
- // Auto-register with current configuration
81
- setQueueServiceType(queueServiceType);
82
- }
83
-
84
- return getQueueLattice(DEFAULT_QUEUE_KEY);
85
- };
86
-
87
- /**
88
- * Push agent task to queue
89
- * @param agentTask - Agent task to push
90
- */
91
- export const pushAgentTaskToQueue = async (agentTask: any) => {
92
- const queue = getQueueService();
93
- const result = await queue.push(agentTask);
94
- return result;
95
- };
96
-
97
- /**
98
- * Pop agent task from queue
99
- */
100
- export const popAgentTaskFromQueue = async () => {
101
- const queue = getQueueService();
102
- const result = await queue.pop();
103
- return result;
104
- };
@@ -1,223 +0,0 @@
1
- import { agentLatticeManager, getSandBoxManager, normalizeSandboxName, sandboxLatticeManager } from "@axiom-lattice/core";
2
- import { SandboxMiddlewareConfig } from "@axiom-lattice/protocols";
3
-
4
-
5
- const ERROR_HTML = `<!DOCTYPE html>
6
- <html lang="zh-CN">
7
- <head>
8
- <meta charset="UTF-8">
9
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
10
- <title>Sandbox 连接错误</title>
11
- <style>
12
- * { box-sizing: border-box; margin: 0; padding: 0; }
13
- body {
14
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
15
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
16
- min-height: 100vh;
17
- display: flex;
18
- align-items: center;
19
- justify-content: center;
20
- padding: 20px;
21
- }
22
- .container {
23
- background: white;
24
- border-radius: 16px;
25
- padding: 40px;
26
- max-width: 500px;
27
- width: 100%;
28
- box-shadow: 0 20px 60px rgba(0,0,0,0.3);
29
- }
30
- .error-icon {
31
- width: 80px;
32
- height: 80px;
33
- background: #fee2e2;
34
- border-radius: 50%;
35
- display: flex;
36
- align-items: center;
37
- justify-content: center;
38
- margin: 0 auto 24px;
39
- }
40
- .error-icon svg {
41
- width: 40px;
42
- height: 40px;
43
- color: #dc2626;
44
- }
45
- h1 { color: #1f2937; margin-bottom: 16px; text-align: center; }
46
- p { color: #6b7280; margin-bottom: 12px; line-height: 1.6; }
47
- .info {
48
- background: #f3f4f6;
49
- border-radius: 8px;
50
- padding: 16px;
51
- margin: 20px 0;
52
- }
53
- .info-item {
54
- display: flex;
55
- justify-content: space-between;
56
- padding: 8px 0;
57
- border-bottom: 1px solid #e5e7eb;
58
- }
59
- .info-item:last-child { border-bottom: none; }
60
- .label { color: #6b7280; font-size: 14px; }
61
- .value { color: #1f2937; font-weight: 500; font-family: monospace; }
62
- .retry-btn {
63
- width: 100%;
64
- padding: 14px;
65
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
66
- color: white;
67
- border: none;
68
- border-radius: 8px;
69
- font-size: 16px;
70
- cursor: pointer;
71
- transition: transform 0.2s;
72
- }
73
- .retry-btn:hover { transform: translateY(-2px); }
74
- </style>
75
- </head>
76
- <body>
77
- <div class="container">
78
- <div class="error-icon">
79
- <svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
80
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
81
- </svg>
82
- </div>
83
- <h1>无法连接到 Sandbox</h1>
84
- <p>无法连接到沙箱环境,请检查配置后重试。</p>
85
- <div class="info">
86
- <div class="info-item">
87
- <span class="label">Assistant ID</span>
88
- <span class="value" id="assistantId">-</span>
89
- </div>
90
- <div class="info-item">
91
- <span class="label">Thread ID</span>
92
- <span class="value" id="threadId">-</span>
93
- </div>
94
- <div class="info-item">
95
- <span class="label">隔离级别</span>
96
- <span class="value" id="vmIsolation">-</span>
97
- </div>
98
- <div class="info-item">
99
- <span class="label">错误信息</span>
100
- <span class="value" id="errorMsg">-</span>
101
- </div>
102
- </div>
103
- <button class="retry-btn" onclick="window.location.reload()">重新连接</button>
104
- </div>
105
- <script>
106
- const params = new URLSearchParams(window.location.search);
107
- document.getElementById('assistantId').textContent = params.get('assistantId') || '-';
108
- document.getElementById('threadId').textContent = params.get('threadId') || '-';
109
- document.getElementById('vmIsolation').textContent = params.get('vmIsolation') || '-';
110
- document.getElementById('errorMsg').textContent = params.get('error') || '未知错误';
111
- </script>
112
- </body>
113
- </html>`;
114
-
115
- export class SandboxService {
116
-
117
- getFilesystemVmIsolation(tenantId: string, assistantId: string): "agent" | "project" | "global" | null {
118
- const agentLattice = agentLatticeManager.getAgentLatticeWithTenant(tenantId, assistantId);
119
- if (!agentLattice) {
120
- return null;
121
- }
122
-
123
- const filesystemConfig = agentLattice?.config?.middleware?.find((m: any) => m.type === "filesystem");
124
- if (!filesystemConfig) {
125
- return null;
126
- }
127
-
128
- const config = filesystemConfig.config as SandboxMiddlewareConfig;
129
- return config?.vmIsolation || null;
130
- }
131
-
132
- computeSandboxName(
133
- assistantId: string,
134
- threadId: string,
135
- vmIsolation: string,
136
- tenantId?: string,
137
- workspaceId?: string,
138
- projectId?: string,
139
- ): string {
140
- switch (vmIsolation) {
141
- case "agent":
142
- return normalizeSandboxName(`${tenantId ?? "default"}-${assistantId}`);
143
- case "project":
144
- return normalizeSandboxName(
145
- `${tenantId ?? "default"}-${workspaceId ?? "default"}-${projectId ?? "default"}`
146
- );
147
- case "global":
148
- default:
149
- return "global";
150
- }
151
- }
152
-
153
- private getBrowserSandboxBaseURL(): string {
154
- return process.env.AGENT_INFRA_SANDBOX_BASE_URL || "http://localhost:8080";
155
- }
156
-
157
- getTargetUrl(sandboxName: string): string {
158
- return `${this.getBrowserSandboxBaseURL()}/sandbox/${sandboxName}`;
159
- }
160
-
161
- async getVncHtml(sandboxName: string): Promise<string> {
162
- const response = await fetch(`${this.getTargetUrl(sandboxName)}/vnc/index.html`);
163
-
164
- if (!response.ok) {
165
- throw new Error(`Failed to fetch VNC HTML: ${response.statusText}`);
166
- }
167
-
168
- return response.text();
169
- }
170
-
171
- rewriteHtml(
172
- html: string,
173
- assistantId: string,
174
- threadId: string
175
- ): string {
176
- const prefix = `/api/assistants/${assistantId}/threads/${threadId}/sandbox/vnc`;
177
-
178
- let rewritten = html;
179
-
180
- rewritten = rewritten.replace(
181
- /(src|href)=["']([^"']*)["']/g,
182
- (match, attr, url) => {
183
- if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("//")) {
184
- return match;
185
- }
186
- const rewrittenUrl = url.startsWith("/") ? `${prefix}${url}` : `${prefix}/${url}`;
187
- return `${attr}="${rewrittenUrl}"`;
188
- }
189
- );
190
-
191
- rewritten = rewritten.replace(
192
- /path=sandbox\/[^&"']+/g,
193
- (match) => {
194
- return `path=${prefix}/websockify`;
195
- }
196
- );
197
-
198
- rewritten = rewritten.replace(
199
- /new WebSocket\([^)]*\?path=sandbox[^)]*\)/g,
200
- (match) => {
201
- return match.replace(/path=sandbox[^)]+/, `path=${prefix}/websockify`);
202
- }
203
- );
204
-
205
- return rewritten;
206
- }
207
-
208
- generateErrorHtml(
209
- assistantId: string,
210
- threadId: string,
211
- vmIsolation: string,
212
- errorMessage: string
213
- ): string {
214
- const encodedError = encodeURIComponent(errorMessage);
215
- return ERROR_HTML
216
- .replace("{assistantId}", assistantId)
217
- .replace("{threadId}", threadId)
218
- .replace("{vmIsolation}", vmIsolation)
219
- .replace("{errorMessage}", errorMessage);
220
- }
221
- }
222
-
223
- export const sandboxService = new SandboxService();
@@ -1,97 +0,0 @@
1
- /**
2
- * SkillService
3
- *
4
- * Business logic layer for skill management.
5
- * Wraps SandboxSkillStore from @axiom-lattice/core.
6
- * Controllers should consume this service, not directly manipulate storage.
7
- */
8
-
9
- import { SandboxSkillStore } from "@axiom-lattice/core";
10
- import type {
11
- Skill,
12
- SkillStoreContext,
13
- CreateSkillRequest,
14
- } from "@axiom-lattice/protocols";
15
- import { FastifyRequest } from "fastify";
16
-
17
- function getTenantId(request: FastifyRequest): string {
18
- return (request as any).user?.tenantId || (request.headers["x-tenant-id"] as string) || "default";
19
- }
20
-
21
- function getWorkspaceId(request: FastifyRequest): string | undefined {
22
- return request.headers["x-workspace-id"] as string | undefined;
23
- }
24
-
25
- function getProjectId(request: FastifyRequest): string | undefined {
26
- return request.headers["x-project-id"] as string | undefined;
27
- }
28
-
29
- function buildContext(request: FastifyRequest): SkillStoreContext {
30
- return {
31
- workspaceId: getWorkspaceId(request),
32
- projectId: getProjectId(request),
33
- };
34
- }
35
-
36
- export class SkillService {
37
- private store: SandboxSkillStore;
38
-
39
- constructor() {
40
- this.store = new SandboxSkillStore();
41
- }
42
-
43
- async getAllSkills(request: FastifyRequest): Promise<Skill[]> {
44
- const tenantId = getTenantId(request);
45
- return this.store.getAllSkills(tenantId, buildContext(request));
46
- }
47
-
48
- async getSkillById(request: FastifyRequest, id: string): Promise<Skill | null> {
49
- const tenantId = getTenantId(request);
50
- return this.store.getSkillById(tenantId, id, buildContext(request));
51
- }
52
-
53
- async createSkill(
54
- request: FastifyRequest,
55
- id: string,
56
- data: CreateSkillRequest
57
- ): Promise<Skill> {
58
- const tenantId = getTenantId(request);
59
- return this.store.createSkill(tenantId, id, data, buildContext(request));
60
- }
61
-
62
- async updateSkill(
63
- request: FastifyRequest,
64
- id: string,
65
- updates: Partial<CreateSkillRequest>
66
- ): Promise<Skill | null> {
67
- const tenantId = getTenantId(request);
68
- return this.store.updateSkill(tenantId, id, updates, buildContext(request));
69
- }
70
-
71
- async deleteSkill(request: FastifyRequest, id: string): Promise<boolean> {
72
- const tenantId = getTenantId(request);
73
- return this.store.deleteSkill(tenantId, id, buildContext(request));
74
- }
75
-
76
- async searchByMetadata(
77
- request: FastifyRequest,
78
- key: string,
79
- value: string
80
- ): Promise<Skill[]> {
81
- const tenantId = getTenantId(request);
82
- return this.store.searchByMetadata(tenantId, key, value, buildContext(request));
83
- }
84
-
85
- async filterByCompatibility(
86
- request: FastifyRequest,
87
- compatibility: string
88
- ): Promise<Skill[]> {
89
- const tenantId = getTenantId(request);
90
- return this.store.filterByCompatibility(tenantId, compatibility, buildContext(request));
91
- }
92
-
93
- async filterByLicense(request: FastifyRequest, license: string): Promise<Skill[]> {
94
- const tenantId = getTenantId(request);
95
- return this.store.filterByLicense(tenantId, license, buildContext(request));
96
- }
97
- }
@@ -1,60 +0,0 @@
1
- import { createClient, SupabaseClient } from "@supabase/supabase-js";
2
- // import { Database } from "@/types/database.types";
3
- // import { Database as PgmqPublic } from "@/types/pgmq_public.types";
4
-
5
- /**
6
- * Get Supabase client
7
- * This function reads from environment variables directly
8
- */
9
- const getSupabaseClient = (): SupabaseClient => {
10
- const url = process.env.SUPABASE_URL;
11
- const key = process.env.SUPABASE_KEY;
12
- if (!url || !key) {
13
- throw new Error("Supabase URL and Key must be configured");
14
- }
15
- return createClient(url, key);
16
- };
17
-
18
- // Default export - creates client using current config
19
- // Note: Since config uses getters, this will read the latest config values
20
- export default getSupabaseClient();
21
-
22
- /**
23
- * Create a Supabase client with tenant headers
24
- * This function reads from environment variables directly
25
- */
26
- export const createSupabaseClient = (headers: Record<string, string>) => {
27
- const currentTenantId = headers["x-tenant-id"];
28
- const url = process.env.SUPABASE_URL;
29
- const key = process.env.SUPABASE_KEY;
30
- if (!url || !key) {
31
- throw new Error("Supabase URL and Key must be configured");
32
- }
33
- return createClient(url, key, {
34
- global: {
35
- fetch: async (input, init) => {
36
- const headers = new Headers(init?.headers);
37
- if (currentTenantId) headers.set("x-tenant-id", currentTenantId);
38
- return fetch(input, { ...init, headers });
39
- },
40
- },
41
- });
42
- };
43
-
44
- /**
45
- * Get Supabase queue client
46
- * This function reads from environment variables directly
47
- */
48
- export const getSupabaseQueueClient = (): SupabaseClient => {
49
- const url = process.env.SUPABASE_URL;
50
- const key = process.env.SUPABASE_KEY;
51
- if (!url || !key) {
52
- throw new Error("Supabase URL and Key must be configured");
53
- }
54
- return createClient(url, key);
55
- };
56
-
57
- // For backward compatibility, export a client that reads config dynamically
58
- // Note: This creates a new client each time, but Supabase clients are lightweight
59
- // and this ensures we always use the latest config
60
- export const supabaseQueueClient = getSupabaseQueueClient();
package/src/swagger.ts DELETED
@@ -1,77 +0,0 @@
1
- import { FastifyInstance } from "fastify";
2
- import swagger from "@fastify/swagger";
3
- import swaggerUi from "@fastify/swagger-ui";
4
- // Example usage:
5
- // configureSwagger(app)
6
- // configureSwagger(app, { openapi: { info: { version: "2.0.0" } } })
7
- // configureSwagger(app, undefined, { routePrefix: "/docs" })
8
-
9
- // Default swagger configuration
10
- export const defaultSwaggerConfig = {
11
- openapi: {
12
- openapi: "3.0.0",
13
- info: {
14
- title: "Axiom Lattice Gateway API",
15
- description: "API Gateway for LangGraph agent-based applications",
16
- version: "1.0.0",
17
- contact: {
18
- name: "Axiom Lattice Team",
19
- email: "support@axiom-lattice.com",
20
- },
21
- },
22
- servers: [
23
- {
24
- url: "http://localhost:4001",
25
- description: "Development environment",
26
- },
27
- ],
28
- components: {
29
- securitySchemes: {
30
- bearerAuth: {
31
- type: "http" as const,
32
- scheme: "bearer" as const,
33
- bearerFormat: "JWT",
34
- },
35
- },
36
- },
37
- security: [
38
- {
39
- bearerAuth: [],
40
- },
41
- ],
42
- tags: [
43
- { name: "Runs", description: "Agent run management" },
44
- { name: "Memory", description: "Agent memory management" },
45
- { name: "Graph", description: "Agent graph visualization" },
46
- { name: "Health", description: "System health checks" },
47
- ],
48
- },
49
- };
50
-
51
- // Default swagger UI configuration
52
- export const defaultSwaggerUiConfig = {
53
- routePrefix: "/api-docs",
54
- uiConfig: {
55
- docExpansion: "full" as const,
56
- deepLinking: false,
57
- },
58
- staticCSP: true,
59
- transformStaticCSP: (header: string) => header,
60
- };
61
-
62
- // Configure Swagger with optional custom configuration
63
- export const configureSwagger = async (
64
- app: FastifyInstance,
65
- customSwaggerConfig?: Partial<typeof defaultSwaggerConfig>,
66
- customSwaggerUiConfig?: Partial<typeof defaultSwaggerUiConfig>
67
- ) => {
68
- // Merge default config with custom config
69
- const swaggerConfig = { ...defaultSwaggerConfig, ...customSwaggerConfig };
70
- const swaggerUiConfig = {
71
- ...defaultSwaggerUiConfig,
72
- ...customSwaggerUiConfig,
73
- };
74
-
75
- await app.register(swagger, swaggerConfig);
76
- await app.register(swaggerUi, swaggerUiConfig);
77
- };
@@ -1,118 +0,0 @@
1
- // Re-export Assistant types from protocols package
2
- export type {
3
- Assistant,
4
- CreateAssistantRequest,
5
- } from "@axiom-lattice/protocols";
6
-
7
- // 运行状态枚举
8
- export enum RunStatus {
9
- CREATED = "created",
10
- RUNNING = "running",
11
- COMPLETED = "completed",
12
- FAILED = "failed",
13
- WAITING_FOR_INPUT = "waiting_for_input",
14
- CANCELLED = "cancelled",
15
- }
16
-
17
- // 运行类型
18
- export interface Run {
19
- id: string;
20
- assistantId: string;
21
- status: RunStatus;
22
- input: any;
23
- output?: any;
24
- error?: string;
25
- checkpoints: any[];
26
- createdAt: Date;
27
- updatedAt: Date;
28
- completedAt?: Date;
29
- }
30
-
31
- // 消息类型
32
- export interface Message {
33
- id: string;
34
- runId: string;
35
- role: "user" | "assistant" | "system";
36
- content: any;
37
- createdAt: Date;
38
- }
39
-
40
- // 内存存储类型
41
- export interface MemoryItem {
42
- id: string;
43
- assistantId: string;
44
- key: string;
45
- value: any;
46
- createdAt: Date;
47
- updatedAt: Date;
48
- }
49
-
50
- // 定时任务类型
51
- export interface CronJob {
52
- id: string;
53
- assistantId: string;
54
- name: string;
55
- schedule: string;
56
- action: any;
57
- isActive: boolean;
58
- lastRunAt?: Date;
59
- createdAt: Date;
60
- updatedAt: Date;
61
- }
62
-
63
- // Webhook类型
64
- export interface Webhook {
65
- id: string;
66
- assistantId: string;
67
- url: string;
68
- events: string[];
69
- isActive: boolean;
70
- createdAt: Date;
71
- updatedAt: Date;
72
- }
73
-
74
- // 创建运行请求类型
75
- export interface CreateRunRequest {
76
- tenant_id: string;
77
- thread_id: string;
78
- assistant_id: string;
79
- message: any;
80
- message_id?: string;
81
- command?: any;
82
- streaming?: boolean;
83
- background?: boolean;
84
- custom_run_config?: Record<string, any>;
85
- mode?: 'collect' | 'followup' | 'steer';
86
- }
87
-
88
- // 添加消息请求类型
89
- export interface AddMessageRequest {
90
- runId: string;
91
- role: "user" | "assistant" | "system";
92
- content: any;
93
- }
94
-
95
- // 流式响应类型
96
- export interface StreamEvent {
97
- type: "start" | "data" | "end" | "error" | "heartbeat";
98
- data?: any;
99
- error?: string;
100
- }
101
-
102
- // 双重消息处理策略
103
- export enum DoubleTextStrategy {
104
- IGNORE = 0,
105
- QUEUE = 1,
106
- CANCEL_PREVIOUS = 2,
107
- RESTART = 3,
108
- }
109
-
110
- // 服务响应类型
111
- export interface ServiceResponse<T = any> {
112
- success: boolean;
113
- data?: T;
114
- error?: string;
115
- }
116
-
117
- // Re-export Thread types from protocols package
118
- export type { Thread, CreateThreadRequest } from "@axiom-lattice/protocols";
@@ -1,7 +0,0 @@
1
- import "koa";
2
-
3
- declare module "koa" {
4
- interface Request {
5
- body?: any;
6
- }
7
- }