@axiom-lattice/gateway 2.1.21 → 2.1.22
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +10 -0
- package/dist/index.js +357 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +346 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -4
- package/src/controllers/sandbox.ts +150 -0
- package/src/controllers/tools.ts +410 -0
- package/src/index.ts +4 -0
- package/src/routes/index.ts +8 -0
- package/src/schemas/index.ts +42 -0
- package/src/services/agent_service.ts +14 -6
- package/src/services/sandbox_service.ts +222 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/gateway@2.1.
|
|
2
|
+
> @axiom-lattice/gateway@2.1.22 build /home/runner/work/agentic/agentic/packages/gateway
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts --clean --sourcemap
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
[34mCLI[39m Cleaning output folder
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
12
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m79.68 KB[39m
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m189.84 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 174ms
|
|
15
|
+
[32mCJS[39m [1mdist/index.js [22m[32m82.25 KB[39m
|
|
16
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m189.88 KB[39m
|
|
17
|
+
[32mCJS[39m ⚡️ Build success in 174ms
|
|
18
18
|
[34mDTS[39m Build start
|
|
19
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
+
[32mDTS[39m ⚡️ Build success in 8703ms
|
|
20
20
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.72 KB[39m
|
|
21
21
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.72 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @axiom-lattice/gateway
|
|
2
2
|
|
|
3
|
+
## 2.1.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2422cbf: add sandbox and mcp
|
|
8
|
+
- Updated dependencies [2422cbf]
|
|
9
|
+
- @axiom-lattice/protocols@2.1.11
|
|
10
|
+
- @axiom-lattice/core@2.1.17
|
|
11
|
+
- @axiom-lattice/queue-redis@1.0.10
|
|
12
|
+
|
|
3
13
|
## 2.1.21
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
36
36
|
var import_fastify = __toESM(require("fastify"));
|
|
37
37
|
var import_cors = __toESM(require("@fastify/cors"));
|
|
38
38
|
var import_sensible = __toESM(require("@fastify/sensible"));
|
|
39
|
+
var import_websocket = __toESM(require("@fastify/websocket"));
|
|
39
40
|
|
|
40
41
|
// src/services/agent_service.ts
|
|
41
42
|
var import_messages = require("@langchain/core/messages");
|
|
@@ -70,7 +71,11 @@ async function agent_invoke({
|
|
|
70
71
|
if (!runnable_agent) {
|
|
71
72
|
throw new Error(`Agent ${assistant_id} not found`);
|
|
72
73
|
}
|
|
73
|
-
const runConfig =
|
|
74
|
+
const runConfig = {
|
|
75
|
+
...agentLattice?.config?.runConfig || {},
|
|
76
|
+
assistant_id,
|
|
77
|
+
sandboxConfig: agentLattice?.config?.connectedSandbox
|
|
78
|
+
};
|
|
74
79
|
const result = await runnable_agent.invoke(
|
|
75
80
|
command ? new import_langgraph.Command(command) : { ...rest, messages, "x-tenant-id": tenant_id },
|
|
76
81
|
{
|
|
@@ -112,7 +117,11 @@ async function agent_stream({
|
|
|
112
117
|
messages = [humanMessage];
|
|
113
118
|
}
|
|
114
119
|
const chunkBuffer = getOrCreateChunkBuffer();
|
|
115
|
-
const runConfig =
|
|
120
|
+
const runConfig = {
|
|
121
|
+
...agentLattice?.config?.runConfig || {},
|
|
122
|
+
assistant_id,
|
|
123
|
+
sandboxConfig: agentLattice?.config?.connectedSandbox
|
|
124
|
+
};
|
|
116
125
|
try {
|
|
117
126
|
if (!runnable_agent) {
|
|
118
127
|
throw new Error(`Agent ${assistant_id} not found`);
|
|
@@ -1644,6 +1653,88 @@ async function filterSkillsByLicense(request, reply) {
|
|
|
1644
1653
|
}
|
|
1645
1654
|
}
|
|
1646
1655
|
|
|
1656
|
+
// src/controllers/tools.ts
|
|
1657
|
+
var import_core11 = require("@axiom-lattice/core");
|
|
1658
|
+
function serializeSchema(schema) {
|
|
1659
|
+
if (!schema) {
|
|
1660
|
+
return void 0;
|
|
1661
|
+
}
|
|
1662
|
+
try {
|
|
1663
|
+
if (schema._def) {
|
|
1664
|
+
const def = schema._def;
|
|
1665
|
+
if (def.typeName === "ZodObject") {
|
|
1666
|
+
const shape = def.shape();
|
|
1667
|
+
const properties = {};
|
|
1668
|
+
const required = [];
|
|
1669
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
1670
|
+
const fieldDef = value._def;
|
|
1671
|
+
if (fieldDef) {
|
|
1672
|
+
properties[key] = {
|
|
1673
|
+
type: fieldDef.typeName === "ZodString" ? "string" : fieldDef.typeName === "ZodNumber" ? "number" : fieldDef.typeName === "ZodBoolean" ? "boolean" : fieldDef.typeName === "ZodArray" ? "array" : fieldDef.typeName === "ZodObject" ? "object" : "unknown",
|
|
1674
|
+
description: fieldDef.description
|
|
1675
|
+
};
|
|
1676
|
+
if (!value.isOptional()) {
|
|
1677
|
+
required.push(key);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
return {
|
|
1682
|
+
type: "object",
|
|
1683
|
+
properties,
|
|
1684
|
+
required: required.length > 0 ? required : void 0
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
return {
|
|
1689
|
+
type: "object",
|
|
1690
|
+
description: schema.description || "Schema definition"
|
|
1691
|
+
};
|
|
1692
|
+
} catch (error) {
|
|
1693
|
+
return {
|
|
1694
|
+
type: "object",
|
|
1695
|
+
description: "Schema definition"
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
async function getToolConfigs(request, reply) {
|
|
1700
|
+
try {
|
|
1701
|
+
const allLattices = import_core11.toolLatticeManager.getAllLattices();
|
|
1702
|
+
const toolConfigs = allLattices.map((lattice) => {
|
|
1703
|
+
const config = { ...lattice.config };
|
|
1704
|
+
const serializedSchema = config.schema ? serializeSchema(config.schema) : void 0;
|
|
1705
|
+
return {
|
|
1706
|
+
id: lattice.key,
|
|
1707
|
+
name: config.name,
|
|
1708
|
+
description: config.description,
|
|
1709
|
+
schema: serializedSchema,
|
|
1710
|
+
returnDirect: config.returnDirect,
|
|
1711
|
+
needUserApprove: config.needUserApprove
|
|
1712
|
+
};
|
|
1713
|
+
});
|
|
1714
|
+
return reply.send({
|
|
1715
|
+
success: true,
|
|
1716
|
+
message: "Successfully retrieved tool configs",
|
|
1717
|
+
data: {
|
|
1718
|
+
records: toolConfigs,
|
|
1719
|
+
total: toolConfigs.length
|
|
1720
|
+
}
|
|
1721
|
+
});
|
|
1722
|
+
} catch (error) {
|
|
1723
|
+
console.error("Failed to get tool configs", {
|
|
1724
|
+
error: error.message,
|
|
1725
|
+
stack: error.stack
|
|
1726
|
+
});
|
|
1727
|
+
return reply.status(500).send({
|
|
1728
|
+
success: false,
|
|
1729
|
+
message: `Failed to retrieve tool configs: ${error.message}`,
|
|
1730
|
+
data: {
|
|
1731
|
+
records: [],
|
|
1732
|
+
total: 0
|
|
1733
|
+
}
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1647
1738
|
// src/schemas/index.ts
|
|
1648
1739
|
var getAllMemoryItemsSchema = {
|
|
1649
1740
|
description: "Get all memory items for an assistant thread",
|
|
@@ -1915,6 +2006,256 @@ var getHealthSchema = {
|
|
|
1915
2006
|
}
|
|
1916
2007
|
};
|
|
1917
2008
|
|
|
2009
|
+
// src/services/sandbox_service.ts
|
|
2010
|
+
var import_core12 = require("@axiom-lattice/core");
|
|
2011
|
+
var SANDBOX_BASE_URL = process.env.SANDBOX_BASE_URL || "http://localhost:8080";
|
|
2012
|
+
var ERROR_HTML = `<!DOCTYPE html>
|
|
2013
|
+
<html lang="zh-CN">
|
|
2014
|
+
<head>
|
|
2015
|
+
<meta charset="UTF-8">
|
|
2016
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
2017
|
+
<title>Sandbox \u8FDE\u63A5\u9519\u8BEF</title>
|
|
2018
|
+
<style>
|
|
2019
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
2020
|
+
body {
|
|
2021
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
2022
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
2023
|
+
min-height: 100vh;
|
|
2024
|
+
display: flex;
|
|
2025
|
+
align-items: center;
|
|
2026
|
+
justify-content: center;
|
|
2027
|
+
padding: 20px;
|
|
2028
|
+
}
|
|
2029
|
+
.container {
|
|
2030
|
+
background: white;
|
|
2031
|
+
border-radius: 16px;
|
|
2032
|
+
padding: 40px;
|
|
2033
|
+
max-width: 500px;
|
|
2034
|
+
width: 100%;
|
|
2035
|
+
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
|
2036
|
+
}
|
|
2037
|
+
.error-icon {
|
|
2038
|
+
width: 80px;
|
|
2039
|
+
height: 80px;
|
|
2040
|
+
background: #fee2e2;
|
|
2041
|
+
border-radius: 50%;
|
|
2042
|
+
display: flex;
|
|
2043
|
+
align-items: center;
|
|
2044
|
+
justify-content: center;
|
|
2045
|
+
margin: 0 auto 24px;
|
|
2046
|
+
}
|
|
2047
|
+
.error-icon svg {
|
|
2048
|
+
width: 40px;
|
|
2049
|
+
height: 40px;
|
|
2050
|
+
color: #dc2626;
|
|
2051
|
+
}
|
|
2052
|
+
h1 { color: #1f2937; margin-bottom: 16px; text-align: center; }
|
|
2053
|
+
p { color: #6b7280; margin-bottom: 12px; line-height: 1.6; }
|
|
2054
|
+
.info {
|
|
2055
|
+
background: #f3f4f6;
|
|
2056
|
+
border-radius: 8px;
|
|
2057
|
+
padding: 16px;
|
|
2058
|
+
margin: 20px 0;
|
|
2059
|
+
}
|
|
2060
|
+
.info-item {
|
|
2061
|
+
display: flex;
|
|
2062
|
+
justify-content: space-between;
|
|
2063
|
+
padding: 8px 0;
|
|
2064
|
+
border-bottom: 1px solid #e5e7eb;
|
|
2065
|
+
}
|
|
2066
|
+
.info-item:last-child { border-bottom: none; }
|
|
2067
|
+
.label { color: #6b7280; font-size: 14px; }
|
|
2068
|
+
.value { color: #1f2937; font-weight: 500; font-family: monospace; }
|
|
2069
|
+
.retry-btn {
|
|
2070
|
+
width: 100%;
|
|
2071
|
+
padding: 14px;
|
|
2072
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
2073
|
+
color: white;
|
|
2074
|
+
border: none;
|
|
2075
|
+
border-radius: 8px;
|
|
2076
|
+
font-size: 16px;
|
|
2077
|
+
cursor: pointer;
|
|
2078
|
+
transition: transform 0.2s;
|
|
2079
|
+
}
|
|
2080
|
+
.retry-btn:hover { transform: translateY(-2px); }
|
|
2081
|
+
</style>
|
|
2082
|
+
</head>
|
|
2083
|
+
<body>
|
|
2084
|
+
<div class="container">
|
|
2085
|
+
<div class="error-icon">
|
|
2086
|
+
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
2087
|
+
<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"/>
|
|
2088
|
+
</svg>
|
|
2089
|
+
</div>
|
|
2090
|
+
<h1>\u65E0\u6CD5\u8FDE\u63A5\u5230 Sandbox</h1>
|
|
2091
|
+
<p>\u65E0\u6CD5\u8FDE\u63A5\u5230\u6C99\u7BB1\u73AF\u5883\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E\u540E\u91CD\u8BD5\u3002</p>
|
|
2092
|
+
<div class="info">
|
|
2093
|
+
<div class="info-item">
|
|
2094
|
+
<span class="label">Assistant ID</span>
|
|
2095
|
+
<span class="value" id="assistantId">-</span>
|
|
2096
|
+
</div>
|
|
2097
|
+
<div class="info-item">
|
|
2098
|
+
<span class="label">Thread ID</span>
|
|
2099
|
+
<span class="value" id="threadId">-</span>
|
|
2100
|
+
</div>
|
|
2101
|
+
<div class="info-item">
|
|
2102
|
+
<span class="label">\u9694\u79BB\u7EA7\u522B</span>
|
|
2103
|
+
<span class="value" id="isolatedLevel">-</span>
|
|
2104
|
+
</div>
|
|
2105
|
+
<div class="info-item">
|
|
2106
|
+
<span class="label">\u9519\u8BEF\u4FE1\u606F</span>
|
|
2107
|
+
<span class="value" id="errorMsg">-</span>
|
|
2108
|
+
</div>
|
|
2109
|
+
</div>
|
|
2110
|
+
<button class="retry-btn" onclick="window.location.reload()">\u91CD\u65B0\u8FDE\u63A5</button>
|
|
2111
|
+
</div>
|
|
2112
|
+
<script>
|
|
2113
|
+
const params = new URLSearchParams(window.location.search);
|
|
2114
|
+
document.getElementById('assistantId').textContent = params.get('assistantId') || '-';
|
|
2115
|
+
document.getElementById('threadId').textContent = params.get('threadId') || '-';
|
|
2116
|
+
document.getElementById('isolatedLevel').textContent = params.get('isolatedLevel') || '-';
|
|
2117
|
+
document.getElementById('errorMsg').textContent = params.get('error') || '\u672A\u77E5\u9519\u8BEF';
|
|
2118
|
+
</script>
|
|
2119
|
+
</body>
|
|
2120
|
+
</html>`;
|
|
2121
|
+
var SandboxService = class {
|
|
2122
|
+
constructor(baseUrl) {
|
|
2123
|
+
this.baseUrl = baseUrl || SANDBOX_BASE_URL;
|
|
2124
|
+
}
|
|
2125
|
+
getSandboxConfig(assistantId) {
|
|
2126
|
+
const agentConfig = (0, import_core12.getAgentConfig)(assistantId);
|
|
2127
|
+
if (!agentConfig) {
|
|
2128
|
+
return null;
|
|
2129
|
+
}
|
|
2130
|
+
const agentLattice = (0, import_core12.getAgentLattice)(assistantId);
|
|
2131
|
+
return agentLattice?.config?.connectedSandbox || null;
|
|
2132
|
+
}
|
|
2133
|
+
computeSandboxName(assistantId, threadId, isolatedLevel) {
|
|
2134
|
+
let sandboxName;
|
|
2135
|
+
switch (isolatedLevel) {
|
|
2136
|
+
case "agent":
|
|
2137
|
+
sandboxName = assistantId;
|
|
2138
|
+
break;
|
|
2139
|
+
case "thread":
|
|
2140
|
+
sandboxName = threadId;
|
|
2141
|
+
break;
|
|
2142
|
+
case "global":
|
|
2143
|
+
default:
|
|
2144
|
+
sandboxName = "global";
|
|
2145
|
+
break;
|
|
2146
|
+
}
|
|
2147
|
+
return (0, import_core12.normalizeSandboxName)(sandboxName);
|
|
2148
|
+
}
|
|
2149
|
+
getTargetUrl(sandboxName) {
|
|
2150
|
+
return `${this.baseUrl}/sandbox/${sandboxName}`;
|
|
2151
|
+
}
|
|
2152
|
+
async getVncHtml(sandboxName) {
|
|
2153
|
+
const response = await fetch(`${this.getTargetUrl(sandboxName)}/vnc/index.html`);
|
|
2154
|
+
if (!response.ok) {
|
|
2155
|
+
throw new Error(`Failed to fetch VNC HTML: ${response.statusText}`);
|
|
2156
|
+
}
|
|
2157
|
+
return response.text();
|
|
2158
|
+
}
|
|
2159
|
+
rewriteHtml(html, assistantId, threadId) {
|
|
2160
|
+
const prefix = `/api/assistants/${assistantId}/threads/${threadId}/sandbox/vnc`;
|
|
2161
|
+
let rewritten = html;
|
|
2162
|
+
rewritten = rewritten.replace(
|
|
2163
|
+
/(src|href)=["']([^"']*)["']/g,
|
|
2164
|
+
(match, attr, url) => {
|
|
2165
|
+
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("//")) {
|
|
2166
|
+
return match;
|
|
2167
|
+
}
|
|
2168
|
+
const rewrittenUrl = url.startsWith("/") ? `${prefix}${url}` : `${prefix}/${url}`;
|
|
2169
|
+
return `${attr}="${rewrittenUrl}"`;
|
|
2170
|
+
}
|
|
2171
|
+
);
|
|
2172
|
+
rewritten = rewritten.replace(
|
|
2173
|
+
/path=sandbox\/[^&"']+/g,
|
|
2174
|
+
(match) => {
|
|
2175
|
+
return `path=${prefix}/websockify`;
|
|
2176
|
+
}
|
|
2177
|
+
);
|
|
2178
|
+
rewritten = rewritten.replace(
|
|
2179
|
+
/new WebSocket\([^)]*\?path=sandbox[^)]*\)/g,
|
|
2180
|
+
(match) => {
|
|
2181
|
+
return match.replace(/path=sandbox[^)]+/, `path=${prefix}/websockify`);
|
|
2182
|
+
}
|
|
2183
|
+
);
|
|
2184
|
+
return rewritten;
|
|
2185
|
+
}
|
|
2186
|
+
generateErrorHtml(assistantId, threadId, isolatedLevel, errorMessage) {
|
|
2187
|
+
const encodedError = encodeURIComponent(errorMessage);
|
|
2188
|
+
return ERROR_HTML.replace("{assistantId}", assistantId).replace("{threadId}", threadId).replace("{isolatedLevel}", isolatedLevel).replace("{errorMessage}", errorMessage);
|
|
2189
|
+
}
|
|
2190
|
+
};
|
|
2191
|
+
var sandboxService = new SandboxService();
|
|
2192
|
+
|
|
2193
|
+
// src/controllers/sandbox.ts
|
|
2194
|
+
var SANDBOX_BASE_URL2 = process.env.SANDBOX_BASE_URL || "http://localhost:8080";
|
|
2195
|
+
async function registerSandboxProxyRoutes(app2) {
|
|
2196
|
+
app2.get(
|
|
2197
|
+
"/api/assistants/:assistantId/threads/:threadId/sandbox",
|
|
2198
|
+
async (request, reply) => {
|
|
2199
|
+
const { assistantId, threadId } = request.params;
|
|
2200
|
+
const sandboxConfig = sandboxService.getSandboxConfig(assistantId);
|
|
2201
|
+
if (!sandboxConfig) {
|
|
2202
|
+
const errorHtml = sandboxService.generateErrorHtml(
|
|
2203
|
+
assistantId,
|
|
2204
|
+
threadId,
|
|
2205
|
+
"unknown",
|
|
2206
|
+
`Assistant ${assistantId} not found`
|
|
2207
|
+
);
|
|
2208
|
+
return reply.status(404).type("text/html").send(errorHtml);
|
|
2209
|
+
}
|
|
2210
|
+
const { isolatedLevel } = sandboxConfig;
|
|
2211
|
+
const sandboxName = sandboxService.computeSandboxName(
|
|
2212
|
+
assistantId,
|
|
2213
|
+
threadId,
|
|
2214
|
+
isolatedLevel
|
|
2215
|
+
);
|
|
2216
|
+
try {
|
|
2217
|
+
const html = await sandboxService.getVncHtml(sandboxName);
|
|
2218
|
+
const rewrittenHtml = sandboxService.rewriteHtml(html, assistantId, threadId);
|
|
2219
|
+
return reply.type("text/html").send(rewrittenHtml);
|
|
2220
|
+
} catch (error) {
|
|
2221
|
+
const errorHtml = sandboxService.generateErrorHtml(
|
|
2222
|
+
assistantId,
|
|
2223
|
+
threadId,
|
|
2224
|
+
isolatedLevel,
|
|
2225
|
+
error.message || "Failed to connect to sandbox"
|
|
2226
|
+
);
|
|
2227
|
+
return reply.status(502).type("text/html").send(errorHtml);
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
);
|
|
2231
|
+
app2.get(
|
|
2232
|
+
"/api/assistants/:assistantId/threads/:threadId/sandbox/vnc/*",
|
|
2233
|
+
async (request, reply) => {
|
|
2234
|
+
const { assistantId, threadId, "*": restPath } = request.params;
|
|
2235
|
+
const sandboxConfig = sandboxService.getSandboxConfig(assistantId);
|
|
2236
|
+
if (!sandboxConfig) {
|
|
2237
|
+
return reply.status(404).send("Assistant not found");
|
|
2238
|
+
}
|
|
2239
|
+
const { isolatedLevel } = sandboxConfig;
|
|
2240
|
+
const sandboxName = sandboxService.computeSandboxName(
|
|
2241
|
+
assistantId,
|
|
2242
|
+
threadId,
|
|
2243
|
+
isolatedLevel
|
|
2244
|
+
);
|
|
2245
|
+
const targetPath = restPath ? `/vnc/${restPath}` : "/vnc/";
|
|
2246
|
+
const targetUrl = `${sandboxService.getTargetUrl(sandboxName)}${targetPath}`;
|
|
2247
|
+
try {
|
|
2248
|
+
const response = await fetch(targetUrl);
|
|
2249
|
+
const contentType = response.headers.get("content-type") || "application/octet-stream";
|
|
2250
|
+
const body = await response.arrayBuffer();
|
|
2251
|
+
reply.status(response.status).type(contentType).send(Buffer.from(body));
|
|
2252
|
+
} catch (error) {
|
|
2253
|
+
reply.status(502).send(`Proxy error: ${error.message}`);
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
);
|
|
2257
|
+
}
|
|
2258
|
+
|
|
1918
2259
|
// src/routes/index.ts
|
|
1919
2260
|
var registerLatticeRoutes = (app2) => {
|
|
1920
2261
|
app2.post("/api/runs", createRun);
|
|
@@ -1990,6 +2331,7 @@ var registerLatticeRoutes = (app2) => {
|
|
|
1990
2331
|
);
|
|
1991
2332
|
app2.get("/api/models", getModels);
|
|
1992
2333
|
app2.put("/api/models", updateModels);
|
|
2334
|
+
app2.get("/api/tools", getToolConfigs);
|
|
1993
2335
|
app2.get(
|
|
1994
2336
|
"/health",
|
|
1995
2337
|
{ schema: getHealthSchema },
|
|
@@ -2032,6 +2374,7 @@ var registerLatticeRoutes = (app2) => {
|
|
|
2032
2374
|
"/api/skills/filter/license",
|
|
2033
2375
|
filterSkillsByLicense
|
|
2034
2376
|
);
|
|
2377
|
+
registerSandboxProxyRoutes(app2);
|
|
2035
2378
|
};
|
|
2036
2379
|
|
|
2037
2380
|
// src/swagger.ts
|
|
@@ -2097,7 +2440,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
|
|
|
2097
2440
|
};
|
|
2098
2441
|
|
|
2099
2442
|
// src/services/agent_task_consumer.ts
|
|
2100
|
-
var
|
|
2443
|
+
var import_core13 = require("@axiom-lattice/core");
|
|
2101
2444
|
var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
2102
2445
|
const {
|
|
2103
2446
|
assistant_id,
|
|
@@ -2161,7 +2504,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
2161
2504
|
}
|
|
2162
2505
|
if (callback_event) {
|
|
2163
2506
|
const state = await agent_state({ assistant_id, thread_id });
|
|
2164
|
-
|
|
2507
|
+
import_core13.eventBus.publish(callback_event, {
|
|
2165
2508
|
success: true,
|
|
2166
2509
|
state,
|
|
2167
2510
|
config: { assistant_id, thread_id, tenant_id }
|
|
@@ -2175,7 +2518,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
2175
2518
|
await response.text();
|
|
2176
2519
|
if (callback_event) {
|
|
2177
2520
|
const state = await agent_state({ assistant_id, thread_id });
|
|
2178
|
-
|
|
2521
|
+
import_core13.eventBus.publish(callback_event, {
|
|
2179
2522
|
success: true,
|
|
2180
2523
|
state,
|
|
2181
2524
|
config: { assistant_id, thread_id, tenant_id }
|
|
@@ -2202,7 +2545,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
2202
2545
|
return handleAgentTask(taskRequest, nextRetryCount);
|
|
2203
2546
|
}
|
|
2204
2547
|
if (callback_event) {
|
|
2205
|
-
|
|
2548
|
+
import_core13.eventBus.publish(callback_event, {
|
|
2206
2549
|
success: false,
|
|
2207
2550
|
error: error instanceof Error ? error.message : String(error),
|
|
2208
2551
|
config: { assistant_id, thread_id, tenant_id }
|
|
@@ -2240,7 +2583,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
2240
2583
|
* 初始化事件监听和队列轮询
|
|
2241
2584
|
*/
|
|
2242
2585
|
initialize() {
|
|
2243
|
-
|
|
2586
|
+
import_core13.eventBus.subscribe(import_core13.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
|
|
2244
2587
|
this.startPollingQueue();
|
|
2245
2588
|
console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
|
|
2246
2589
|
}
|
|
@@ -2359,7 +2702,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
2359
2702
|
handleAgentTask(taskRequest).catch((error) => {
|
|
2360
2703
|
console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
|
|
2361
2704
|
if (taskRequest.callback_event) {
|
|
2362
|
-
|
|
2705
|
+
import_core13.eventBus.publish(taskRequest.callback_event, {
|
|
2363
2706
|
success: false,
|
|
2364
2707
|
error: error instanceof Error ? error.message : String(error),
|
|
2365
2708
|
config: {
|
|
@@ -2379,7 +2722,7 @@ _AgentTaskConsumer.agent_run_endpoint = "http://localhost:4001/api/runs";
|
|
|
2379
2722
|
var AgentTaskConsumer = _AgentTaskConsumer;
|
|
2380
2723
|
|
|
2381
2724
|
// src/index.ts
|
|
2382
|
-
var
|
|
2725
|
+
var import_core14 = require("@axiom-lattice/core");
|
|
2383
2726
|
var import_protocols2 = require("@axiom-lattice/protocols");
|
|
2384
2727
|
process.on("unhandledRejection", (reason, promise) => {
|
|
2385
2728
|
console.error("\u672A\u5904\u7406\u7684Promise\u62D2\u7EDD:", reason);
|
|
@@ -2394,11 +2737,11 @@ var DEFAULT_LOGGER_CONFIG = {
|
|
|
2394
2737
|
var loggerLattice = initializeLogger(DEFAULT_LOGGER_CONFIG);
|
|
2395
2738
|
var logger = loggerLattice.client;
|
|
2396
2739
|
function initializeLogger(config) {
|
|
2397
|
-
if (
|
|
2398
|
-
|
|
2740
|
+
if (import_core14.loggerLatticeManager.hasLattice("default")) {
|
|
2741
|
+
import_core14.loggerLatticeManager.removeLattice("default");
|
|
2399
2742
|
}
|
|
2400
|
-
(0,
|
|
2401
|
-
return (0,
|
|
2743
|
+
(0, import_core14.registerLoggerLattice)("default", config);
|
|
2744
|
+
return (0, import_core14.getLoggerLattice)("default");
|
|
2402
2745
|
}
|
|
2403
2746
|
var app = (0, import_fastify.default)({
|
|
2404
2747
|
logger: false,
|
|
@@ -2450,6 +2793,7 @@ app.register(import_cors.default, {
|
|
|
2450
2793
|
credentials: true
|
|
2451
2794
|
});
|
|
2452
2795
|
app.register(import_sensible.default);
|
|
2796
|
+
app.register(import_websocket.default);
|
|
2453
2797
|
app.setErrorHandler((error, request, reply) => {
|
|
2454
2798
|
const getHeaderValue = (header) => {
|
|
2455
2799
|
if (Array.isArray(header)) {
|