@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.
- package/dist/index.js +37 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -6
- package/.eslintrc.json +0 -22
- package/.turbo/turbo-build.log +0 -46
- package/AGENTS.md +0 -112
- package/CHANGELOG.md +0 -1190
- package/LOGGER_CONFIG.md +0 -135
- package/RESUME_STREAM_CONTENT_BASED.md +0 -326
- package/RESUME_STREAM_README.md +0 -388
- package/jest.config.js +0 -72
- package/public/sdk/README.md +0 -695
- package/public/sdk/dashboard-engine-skill.md +0 -1122
- package/public/sdk/dashboard-single-file-spec.md +0 -357
- package/public/sdk/data-query-sdk-skill.md +0 -307
- package/public/sdk/data-query-sdk.d.ts +0 -252
- package/public/sdk/data-query-sdk.js +0 -970
- package/public/sdk/occupancy-dashboard.html +0 -363
- package/public/sdk/test-dashboard.html +0 -690
- package/scripts/seed-lark-installation.ts +0 -54
- package/src/__tests__/__mocks__/e2b.ts +0 -1
- package/src/__tests__/a2a.test.ts +0 -428
- package/src/__tests__/channel-installations.test.ts +0 -199
- package/src/__tests__/data-query.test.ts +0 -77
- package/src/__tests__/sandbox-provider-registration.test.ts +0 -74
- package/src/__tests__/setup.ts +0 -5
- package/src/__tests__/workspace.test.ts +0 -400
- package/src/channels/__tests__/routes.test.ts +0 -50
- package/src/channels/lark/LarkChannelAdapter.ts +0 -217
- package/src/channels/lark/README.md +0 -187
- package/src/channels/lark/__tests__/controller.test.ts +0 -136
- package/src/channels/lark/__tests__/mapping-service.test.ts +0 -118
- package/src/channels/lark/__tests__/parser.test.ts +0 -72
- package/src/channels/lark/__tests__/sender.test.ts +0 -37
- package/src/channels/lark/__tests__/verification.test.ts +0 -157
- package/src/channels/lark/controller.ts +0 -48
- package/src/channels/lark/mapping-service.ts +0 -138
- package/src/channels/lark/parser.ts +0 -68
- package/src/channels/lark/routes.ts +0 -22
- package/src/channels/lark/sender.ts +0 -58
- package/src/channels/lark/types.ts +0 -20
- package/src/channels/lark/verification.ts +0 -32
- package/src/channels/registry.ts +0 -20
- package/src/channels/routes.ts +0 -30
- package/src/channels/wechat/WechatChannelAdapter.ts +0 -294
- package/src/channels/wechat/__tests__/context-store.test.ts +0 -148
- package/src/channels/wechat/context-store.ts +0 -54
- package/src/channels/wechat/controller.ts +0 -59
- package/src/channels/wechat/routes.ts +0 -7
- package/src/channels/wechat/types.ts +0 -62
- package/src/channels/wechat/wechat-client.ts +0 -162
- package/src/config/local-a2a-templates.ts +0 -59
- package/src/config.ts +0 -124
- package/src/controllers/__tests__/assistant-local-a2a.test.ts +0 -147
- package/src/controllers/__tests__/local-a2a-templates.test.ts +0 -112
- package/src/controllers/__tests__/mime.test.ts +0 -74
- package/src/controllers/__tests__/resources.test.ts +0 -122
- package/src/controllers/__tests__/run.test.ts +0 -115
- package/src/controllers/__tests__/tasks.test.ts +0 -215
- package/src/controllers/__tests__/workflow-tracking.test.ts +0 -113
- package/src/controllers/agent_task.ts +0 -72
- package/src/controllers/assistant.ts +0 -490
- package/src/controllers/auth.ts +0 -524
- package/src/controllers/channel-bindings.ts +0 -135
- package/src/controllers/channel-installations.ts +0 -409
- package/src/controllers/collections.ts +0 -176
- package/src/controllers/config.ts +0 -126
- package/src/controllers/connections.ts +0 -181
- package/src/controllers/data-query.ts +0 -236
- package/src/controllers/database-configs.ts +0 -440
- package/src/controllers/embeddings.ts +0 -22
- package/src/controllers/entries.ts +0 -167
- package/src/controllers/eval.ts +0 -513
- package/src/controllers/export-import.ts +0 -166
- package/src/controllers/health.ts +0 -36
- package/src/controllers/local-a2a-templates.ts +0 -18
- package/src/controllers/local-a2a.ts +0 -149
- package/src/controllers/mcp-configs.ts +0 -673
- package/src/controllers/memory.ts +0 -257
- package/src/controllers/menu-items.ts +0 -114
- package/src/controllers/metrics-configs.ts +0 -1061
- package/src/controllers/middleware-types.ts +0 -15
- package/src/controllers/models.ts +0 -199
- package/src/controllers/personal-assistant.ts +0 -191
- package/src/controllers/resources.ts +0 -477
- package/src/controllers/run.ts +0 -338
- package/src/controllers/sandbox.ts +0 -255
- package/src/controllers/schedules.ts +0 -336
- package/src/controllers/skills.ts +0 -256
- package/src/controllers/tasks.ts +0 -213
- package/src/controllers/tenants.ts +0 -121
- package/src/controllers/thread_status.ts +0 -66
- package/src/controllers/threads.ts +0 -260
- package/src/controllers/tools.ts +0 -139
- package/src/controllers/users.ts +0 -135
- package/src/controllers/workflow-tracking.ts +0 -693
- package/src/controllers/workspace.ts +0 -879
- package/src/export_registrations/a2a-api-key.registration.ts +0 -89
- package/src/export_registrations/agent.registration.ts +0 -80
- package/src/export_registrations/binding.registration.ts +0 -106
- package/src/export_registrations/channel-installation.registration.ts +0 -88
- package/src/export_registrations/collection.registration.ts +0 -85
- package/src/export_registrations/connection.registration.ts +0 -97
- package/src/export_registrations/database-config.registration.ts +0 -94
- package/src/export_registrations/eval.registration.ts +0 -334
- package/src/export_registrations/index.ts +0 -31
- package/src/export_registrations/mcp-config.registration.ts +0 -97
- package/src/export_registrations/menu.registration.ts +0 -91
- package/src/export_registrations/metrics-config.registration.ts +0 -94
- package/src/export_registrations/skill.registration.ts +0 -88
- package/src/export_registrations/task.registration.ts +0 -99
- package/src/index.ts +0 -497
- package/src/logger/Logger.ts +0 -186
- package/src/router/MessageContext.ts +0 -14
- package/src/router/MessageRouter.ts +0 -490
- package/src/router/middlewares/auditLogger.ts +0 -34
- package/src/router/middlewares/deduplication.ts +0 -38
- package/src/router/middlewares/index.ts +0 -3
- package/src/router/middlewares/rateLimit.ts +0 -46
- package/src/routes/__tests__/a2a-test-connection.test.ts +0 -177
- package/src/routes/a2a-bridge.ts +0 -266
- package/src/routes/a2a-test-connection.ts +0 -126
- package/src/routes/a2a.ts +0 -851
- package/src/routes/channel-bindings.ts +0 -11
- package/src/routes/channel-installations.ts +0 -33
- package/src/routes/index.ts +0 -640
- package/src/routes/menu-items.ts +0 -10
- package/src/routes/resource-routes.ts +0 -35
- package/src/routes/stt.ts +0 -102
- package/src/schemas/data-query.ts +0 -69
- package/src/schemas/index.ts +0 -852
- package/src/services/ExportImportService.ts +0 -296
- package/src/services/__tests__/ExportImportService.test.ts +0 -130
- package/src/services/__tests__/eval-runner.test.ts +0 -131
- package/src/services/__tests__/local-a2a.test.ts +0 -124
- package/src/services/agent_task_consumer.ts +0 -348
- package/src/services/collection_service.ts +0 -258
- package/src/services/eval-runner.ts +0 -283
- package/src/services/local-a2a.ts +0 -354
- package/src/services/queue_service.ts +0 -104
- package/src/services/sandbox_service.ts +0 -223
- package/src/services/skill_service.ts +0 -97
- package/src/services/supabase.ts +0 -60
- package/src/swagger.ts +0 -77
- package/src/types/index.ts +0 -118
- package/src/types/koa.d.ts +0 -7
- package/src/utils/__tests__/local-a2a-runtime.test.ts +0 -77
- package/src/utils/__tests__/path-containment.test.ts +0 -35
- package/src/utils/a2a-url.ts +0 -20
- package/src/utils/local-a2a-runtime.ts +0 -107
- package/src/utils/mime.ts +0 -44
- package/src/utils/path-containment.ts +0 -38
- 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
|
-
}
|
package/src/services/supabase.ts
DELETED
|
@@ -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
|
-
};
|
package/src/types/index.ts
DELETED
|
@@ -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";
|