@blaxel/core 0.2.43-dev.196 → 0.2.43-dev.199
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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/authentication/index.js +4 -30
- package/dist/cjs/cache/index.js +3 -16
- package/dist/cjs/common/browser.js +22 -0
- package/dist/cjs/common/env.js +12 -24
- package/dist/cjs/common/node.js +13 -25
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/sandbox/filesystem/filesystem.js +12 -13
- package/dist/cjs/sandbox/sandbox.js +2 -2
- package/dist/cjs/types/common/browser.d.ts +5 -0
- package/dist/cjs/types/common/node.d.ts +1 -2
- package/dist/cjs/types/sandbox/filesystem/filesystem.d.ts +6 -2
- package/dist/cjs-browser/.tsbuildinfo +1 -0
- package/dist/cjs-browser/agents/index.js +109 -0
- package/dist/cjs-browser/authentication/apikey.js +24 -0
- package/dist/cjs-browser/authentication/clientcredentials.js +85 -0
- package/dist/cjs-browser/authentication/credentials.js +17 -0
- package/dist/cjs-browser/authentication/deviceMode.js +70 -0
- package/dist/cjs-browser/authentication/index.js +62 -0
- package/dist/cjs-browser/authentication/types.js +2 -0
- package/dist/cjs-browser/cache/index.js +26 -0
- package/dist/cjs-browser/client/authentication.js +15 -0
- package/dist/cjs-browser/client/client.gen.js +8 -0
- package/dist/cjs-browser/client/client.js +17 -0
- package/dist/cjs-browser/client/index.js +19 -0
- package/dist/cjs-browser/client/interceptors.js +17 -0
- package/dist/cjs-browser/client/sdk.gen.js +1824 -0
- package/dist/cjs-browser/client/types.gen.js +4 -0
- package/dist/cjs-browser/common/autoload.js +27 -0
- package/dist/cjs-browser/common/env.js +57 -0
- package/dist/cjs-browser/common/errors.js +17 -0
- package/dist/cjs-browser/common/internal.js +228 -0
- package/dist/cjs-browser/common/internal.test.js +39 -0
- package/dist/cjs-browser/common/logger.js +69 -0
- package/dist/cjs-browser/common/node.js +22 -0
- package/dist/cjs-browser/common/settings.js +181 -0
- package/dist/cjs-browser/index.browser.test.js +45 -0
- package/dist/cjs-browser/index.js +34 -0
- package/dist/cjs-browser/jobs/index.js +19 -0
- package/dist/cjs-browser/jobs/jobs.js +90 -0
- package/dist/cjs-browser/jobs/start.js +66 -0
- package/dist/cjs-browser/jobs/types.js +2 -0
- package/dist/cjs-browser/mcp/client.js +235 -0
- package/dist/cjs-browser/mcp/index.js +18 -0
- package/dist/cjs-browser/mcp/server.js +213 -0
- package/dist/cjs-browser/models/index.js +31 -0
- package/dist/cjs-browser/sandbox/action.js +83 -0
- package/dist/cjs-browser/sandbox/client/client.gen.js +6 -0
- package/dist/cjs-browser/sandbox/client/index.js +19 -0
- package/dist/cjs-browser/sandbox/client/sdk.gen.js +289 -0
- package/dist/cjs-browser/sandbox/client/types.gen.js +3 -0
- package/dist/cjs-browser/sandbox/filesystem/filesystem.js +240 -0
- package/dist/cjs-browser/sandbox/filesystem/index.js +18 -0
- package/dist/cjs-browser/sandbox/filesystem/types.js +2 -0
- package/dist/cjs-browser/sandbox/index.js +36 -0
- package/dist/cjs-browser/sandbox/network/index.js +17 -0
- package/dist/cjs-browser/sandbox/network/network.js +10 -0
- package/dist/cjs-browser/sandbox/preview.js +148 -0
- package/dist/cjs-browser/sandbox/process/index.js +17 -0
- package/dist/cjs-browser/sandbox/process/process.js +189 -0
- package/dist/cjs-browser/sandbox/sandbox.js +180 -0
- package/dist/cjs-browser/sandbox/session.js +123 -0
- package/dist/cjs-browser/sandbox/types.js +81 -0
- package/dist/cjs-browser/telemetry/telemetry.js +80 -0
- package/dist/cjs-browser/tools/index.js +52 -0
- package/dist/cjs-browser/tools/mcpTool.js +254 -0
- package/dist/cjs-browser/tools/types.js +2 -0
- package/dist/cjs-browser/tools/zodSchema.js +50 -0
- package/dist/cjs-browser/types/agents/index.d.ts +15 -0
- package/dist/cjs-browser/types/authentication/apikey.d.ts +10 -0
- package/dist/cjs-browser/types/authentication/clientcredentials.d.ts +17 -0
- package/dist/cjs-browser/types/authentication/credentials.d.ts +6 -0
- package/dist/cjs-browser/types/authentication/deviceMode.d.ts +15 -0
- package/dist/cjs-browser/types/authentication/index.d.ts +3 -0
- package/dist/cjs-browser/types/authentication/types.d.ts +9 -0
- package/dist/cjs-browser/types/cache/index.d.ts +1 -0
- package/dist/cjs-browser/types/client/authentication.d.ts +25 -0
- package/dist/cjs-browser/types/client/client.d.ts +2 -0
- package/dist/cjs-browser/types/client/client.gen.d.ts +12 -0
- package/dist/cjs-browser/types/client/index.d.ts +2 -0
- package/dist/cjs-browser/types/client/interceptors.d.ts +3 -0
- package/dist/cjs-browser/types/client/sdk.gen.d.ts +519 -0
- package/dist/cjs-browser/types/client/types.gen.d.ts +4950 -0
- package/dist/cjs-browser/types/common/autoload.d.ts +3 -0
- package/dist/cjs-browser/types/common/browser.d.ts +5 -0
- package/dist/cjs-browser/types/common/env.d.ts +5 -0
- package/dist/cjs-browser/types/common/errors.d.ts +1 -0
- package/dist/cjs-browser/types/common/internal.d.ts +6 -0
- package/dist/cjs-browser/types/common/internal.test.d.ts +1 -0
- package/dist/cjs-browser/types/common/logger.d.ts +25 -0
- package/dist/cjs-browser/types/common/node.d.ts +6 -0
- package/dist/cjs-browser/types/common/settings.d.ts +32 -0
- package/dist/cjs-browser/types/index.browser.test.d.ts +1 -0
- package/dist/cjs-browser/types/index.d.ts +18 -0
- package/dist/cjs-browser/types/jobs/index.d.ts +3 -0
- package/dist/cjs-browser/types/jobs/jobs.d.ts +13 -0
- package/dist/cjs-browser/types/jobs/start.d.ts +1 -0
- package/dist/cjs-browser/types/jobs/types.d.ts +3 -0
- package/dist/cjs-browser/types/mcp/client.d.ts +28 -0
- package/dist/cjs-browser/types/mcp/index.d.ts +2 -0
- package/dist/cjs-browser/types/mcp/server.d.ts +24 -0
- package/dist/cjs-browser/types/models/index.d.ts +8 -0
- package/dist/cjs-browser/types/sandbox/action.d.ts +19 -0
- package/dist/cjs-browser/types/sandbox/client/client.gen.d.ts +12 -0
- package/dist/cjs-browser/types/sandbox/client/index.d.ts +2 -0
- package/dist/cjs-browser/types/sandbox/client/sdk.gen.d.ts +101 -0
- package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +578 -0
- package/dist/cjs-browser/types/sandbox/filesystem/filesystem.d.ts +27 -0
- package/dist/cjs-browser/types/sandbox/filesystem/index.d.ts +2 -0
- package/dist/cjs-browser/types/sandbox/filesystem/types.d.ts +15 -0
- package/dist/cjs-browser/types/sandbox/index.d.ts +4 -0
- package/dist/cjs-browser/types/sandbox/network/index.d.ts +1 -0
- package/dist/cjs-browser/types/sandbox/network/network.d.ts +5 -0
- package/dist/cjs-browser/types/sandbox/preview.d.ts +37 -0
- package/dist/cjs-browser/types/sandbox/process/index.d.ts +1 -0
- package/dist/cjs-browser/types/sandbox/process/process.d.ts +24 -0
- package/dist/cjs-browser/types/sandbox/sandbox.d.ts +33 -0
- package/dist/cjs-browser/types/sandbox/session.d.ts +27 -0
- package/dist/cjs-browser/types/sandbox/types.d.ts +52 -0
- package/dist/cjs-browser/types/telemetry/telemetry.d.ts +62 -0
- package/dist/cjs-browser/types/tools/index.d.ts +12 -0
- package/dist/cjs-browser/types/tools/mcpTool.d.ts +33 -0
- package/dist/cjs-browser/types/tools/types.d.ts +8 -0
- package/dist/cjs-browser/types/tools/zodSchema.d.ts +82 -0
- package/dist/cjs-browser/types/volume/index.d.ts +23 -0
- package/dist/cjs-browser/volume/index.js +113 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/authentication/index.js +1 -27
- package/dist/esm/cache/index.js +2 -15
- package/dist/esm/common/browser.js +18 -0
- package/dist/esm/common/env.js +7 -19
- package/dist/esm/common/node.js +10 -21
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/sandbox/filesystem/filesystem.js +13 -14
- package/dist/esm/sandbox/sandbox.js +2 -2
- package/dist/esm-browser/.tsbuildinfo +1 -0
- package/dist/esm-browser/agents/index.js +104 -0
- package/dist/esm-browser/authentication/apikey.js +20 -0
- package/dist/esm-browser/authentication/clientcredentials.js +81 -0
- package/dist/esm-browser/authentication/credentials.js +13 -0
- package/dist/esm-browser/authentication/deviceMode.js +66 -0
- package/dist/esm-browser/authentication/index.js +56 -0
- package/dist/esm-browser/authentication/types.js +1 -0
- package/dist/esm-browser/cache/index.js +20 -0
- package/dist/esm-browser/client/authentication.js +11 -0
- package/dist/esm-browser/client/client.gen.js +5 -0
- package/dist/esm-browser/client/client.js +1 -0
- package/dist/esm-browser/client/index.js +3 -0
- package/dist/esm-browser/client/interceptors.js +14 -0
- package/dist/esm-browser/client/sdk.gen.js +1717 -0
- package/dist/esm-browser/client/types.gen.js +3 -0
- package/dist/esm-browser/common/autoload.js +23 -0
- package/dist/esm-browser/common/env.js +51 -0
- package/dist/esm-browser/common/errors.js +14 -0
- package/dist/esm-browser/common/internal.js +220 -0
- package/dist/esm-browser/common/internal.test.js +37 -0
- package/dist/esm-browser/common/logger.js +65 -0
- package/dist/esm-browser/common/node.js +18 -0
- package/dist/esm-browser/common/settings.js +178 -0
- package/dist/esm-browser/index.browser.test.js +10 -0
- package/dist/esm-browser/index.js +18 -0
- package/dist/esm-browser/jobs/index.js +3 -0
- package/dist/esm-browser/jobs/jobs.js +86 -0
- package/dist/esm-browser/jobs/start.js +62 -0
- package/dist/esm-browser/jobs/types.js +1 -0
- package/dist/esm-browser/mcp/client.js +231 -0
- package/dist/esm-browser/mcp/index.js +2 -0
- package/dist/esm-browser/mcp/server.js +176 -0
- package/dist/esm-browser/models/index.js +25 -0
- package/dist/esm-browser/package.json +1 -0
- package/dist/esm-browser/sandbox/action.js +78 -0
- package/dist/esm-browser/sandbox/client/client.gen.js +3 -0
- package/dist/esm-browser/sandbox/client/index.js +3 -0
- package/dist/esm-browser/sandbox/client/sdk.gen.js +270 -0
- package/dist/esm-browser/sandbox/client/types.gen.js +2 -0
- package/dist/esm-browser/sandbox/filesystem/filesystem.js +236 -0
- package/dist/esm-browser/sandbox/filesystem/index.js +2 -0
- package/dist/esm-browser/sandbox/filesystem/types.js +1 -0
- package/dist/esm-browser/sandbox/index.js +7 -0
- package/dist/esm-browser/sandbox/network/index.js +1 -0
- package/dist/esm-browser/sandbox/network/network.js +6 -0
- package/dist/esm-browser/sandbox/preview.js +141 -0
- package/dist/esm-browser/sandbox/process/index.js +1 -0
- package/dist/esm-browser/sandbox/process/process.js +185 -0
- package/dist/esm-browser/sandbox/sandbox.js +176 -0
- package/dist/esm-browser/sandbox/session.js +119 -0
- package/dist/esm-browser/sandbox/types.js +76 -0
- package/dist/esm-browser/telemetry/telemetry.js +74 -0
- package/dist/esm-browser/tools/index.js +44 -0
- package/dist/esm-browser/tools/mcpTool.js +249 -0
- package/dist/esm-browser/tools/types.js +1 -0
- package/dist/esm-browser/tools/zodSchema.js +43 -0
- package/dist/esm-browser/volume/index.js +109 -0
- package/package.json +16 -4
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.BlaxelMcpServerTransport = void 0;
|
|
37
|
+
const uuid_1 = require("uuid");
|
|
38
|
+
const ws_1 = __importStar(require("ws"));
|
|
39
|
+
const env_js_1 = require("../common/env.js");
|
|
40
|
+
const logger_js_1 = require("../common/logger.js");
|
|
41
|
+
const telemetry_js_1 = require("../telemetry/telemetry.js");
|
|
42
|
+
const spans = new Map();
|
|
43
|
+
class BlaxelMcpServerTransport {
|
|
44
|
+
port;
|
|
45
|
+
wss;
|
|
46
|
+
clients = new Map();
|
|
47
|
+
onclose;
|
|
48
|
+
onerror;
|
|
49
|
+
messageHandler;
|
|
50
|
+
onconnection;
|
|
51
|
+
ondisconnection;
|
|
52
|
+
set onmessage(handler) {
|
|
53
|
+
this.messageHandler = handler
|
|
54
|
+
? (msg, clientId) => {
|
|
55
|
+
if (!("id" in msg)) {
|
|
56
|
+
return handler(msg);
|
|
57
|
+
}
|
|
58
|
+
return handler({
|
|
59
|
+
...msg,
|
|
60
|
+
id: clientId + ":" + msg.id,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
: undefined;
|
|
64
|
+
}
|
|
65
|
+
constructor(port) {
|
|
66
|
+
this.port = port ?? parseInt(env_js_1.env.BL_SERVER_PORT ?? "8080", 10);
|
|
67
|
+
this.wss = new ws_1.WebSocketServer({ port: this.port });
|
|
68
|
+
}
|
|
69
|
+
async start() {
|
|
70
|
+
logger_js_1.logger.info("Starting WebSocket Server on port " + this.port);
|
|
71
|
+
this.wss.on("connection", (ws) => {
|
|
72
|
+
const clientId = (0, uuid_1.v4)();
|
|
73
|
+
this.clients.set(clientId, {
|
|
74
|
+
ws,
|
|
75
|
+
});
|
|
76
|
+
this.onconnection?.(clientId);
|
|
77
|
+
ws.on("message", (data) => {
|
|
78
|
+
const span = (0, telemetry_js_1.startSpan)("message", {
|
|
79
|
+
attributes: {
|
|
80
|
+
"mcp.client.id": clientId,
|
|
81
|
+
"span.type": "mcp.message",
|
|
82
|
+
},
|
|
83
|
+
isRoot: false,
|
|
84
|
+
});
|
|
85
|
+
try {
|
|
86
|
+
const msg = JSON.parse(data.toString());
|
|
87
|
+
this.messageHandler?.(msg, clientId);
|
|
88
|
+
if ("method" in msg && "id" in msg && "params" in msg) {
|
|
89
|
+
span.setAttributes({
|
|
90
|
+
"mcp.message.parsed": true,
|
|
91
|
+
"mcp.method": msg.method,
|
|
92
|
+
"mcp.messageId": msg.id,
|
|
93
|
+
"mcp.toolName": msg.params?.name,
|
|
94
|
+
});
|
|
95
|
+
spans.set(clientId + ":" + msg.id, span);
|
|
96
|
+
}
|
|
97
|
+
// Handle msg.id safely
|
|
98
|
+
const msgId = msg.id ? String(msg.id) : "";
|
|
99
|
+
const [cId, parsedMsgId] = msgId.split(":");
|
|
100
|
+
msg.id = parsedMsgId ? parseInt(parsedMsgId) : undefined;
|
|
101
|
+
// Use optional chaining for safe access
|
|
102
|
+
const client = this.clients.get(cId ?? "");
|
|
103
|
+
if (client?.ws?.readyState === ws_1.default.OPEN) {
|
|
104
|
+
const msgSpan = spans.get(cId + ":" + (msg.id ?? ""));
|
|
105
|
+
try {
|
|
106
|
+
client.ws.send(JSON.stringify(msg));
|
|
107
|
+
if (msgSpan) {
|
|
108
|
+
msgSpan.setAttributes({
|
|
109
|
+
"mcp.message.response_sent": true,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
if (msgSpan) {
|
|
115
|
+
msgSpan.setStatus("error"); // Error status
|
|
116
|
+
msgSpan.recordException(err);
|
|
117
|
+
}
|
|
118
|
+
throw err;
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
if (msgSpan) {
|
|
122
|
+
msgSpan.end();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
this.clients.delete(cId);
|
|
128
|
+
this.ondisconnection?.(cId);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
if (err instanceof Error) {
|
|
133
|
+
span.setStatus("error"); // Error status
|
|
134
|
+
span.recordException(err);
|
|
135
|
+
this.onerror?.(err);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
this.onerror?.(new Error(`Failed to parse message: ${String(err)}`));
|
|
139
|
+
}
|
|
140
|
+
span.end();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
ws.on("close", () => {
|
|
144
|
+
this.clients.delete(clientId);
|
|
145
|
+
this.ondisconnection?.(clientId);
|
|
146
|
+
});
|
|
147
|
+
ws.on("error", (err) => {
|
|
148
|
+
this.onerror?.(err);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
return Promise.resolve();
|
|
152
|
+
}
|
|
153
|
+
async send(msg) {
|
|
154
|
+
const [cId, msgId] = msg.id ? String(msg.id).split(":") : [];
|
|
155
|
+
msg.id = parseInt(msgId);
|
|
156
|
+
const data = JSON.stringify(msg);
|
|
157
|
+
const deadClients = [];
|
|
158
|
+
if (cId) {
|
|
159
|
+
// Send to specific client
|
|
160
|
+
const client = this.clients.get(cId);
|
|
161
|
+
if (client?.ws?.readyState === ws_1.default.OPEN) {
|
|
162
|
+
const msgSpan = spans.get(cId + ":" + msg.id);
|
|
163
|
+
try {
|
|
164
|
+
client.ws.send(data);
|
|
165
|
+
if (msgSpan) {
|
|
166
|
+
msgSpan.setAttributes({
|
|
167
|
+
"mcp.message.response_sent": true,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
if (msgSpan) {
|
|
173
|
+
msgSpan.setStatus("error"); // Error status
|
|
174
|
+
msgSpan.recordException(err);
|
|
175
|
+
}
|
|
176
|
+
throw err;
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
if (msgSpan) {
|
|
180
|
+
msgSpan.end();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
this.clients.delete(cId);
|
|
186
|
+
this.ondisconnection?.(cId);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (const [id, client] of this.clients.entries()) {
|
|
190
|
+
if (client.ws.readyState !== ws_1.default.OPEN) {
|
|
191
|
+
deadClients.push(id);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// Cleanup dead clients
|
|
195
|
+
deadClients.forEach((id) => {
|
|
196
|
+
this.clients.delete(id);
|
|
197
|
+
this.ondisconnection?.(id);
|
|
198
|
+
});
|
|
199
|
+
return Promise.resolve();
|
|
200
|
+
}
|
|
201
|
+
async broadcast(msg) {
|
|
202
|
+
return this.send(msg);
|
|
203
|
+
}
|
|
204
|
+
async close() {
|
|
205
|
+
return new Promise((resolve) => {
|
|
206
|
+
this.wss.close(() => {
|
|
207
|
+
this.clients.clear();
|
|
208
|
+
resolve();
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.BlaxelMcpServerTransport = BlaxelMcpServerTransport;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getModelMetadata = exports.blModel = exports.BLModel = void 0;
|
|
4
|
+
const index_js_1 = require("../cache/index.js");
|
|
5
|
+
const sdk_gen_js_1 = require("../client/sdk.gen.js");
|
|
6
|
+
class BLModel {
|
|
7
|
+
modelName;
|
|
8
|
+
options;
|
|
9
|
+
constructor(modelName, options) {
|
|
10
|
+
this.modelName = modelName;
|
|
11
|
+
this.options = options || {};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.BLModel = BLModel;
|
|
15
|
+
const blModel = (modelName, options) => {
|
|
16
|
+
return new BLModel(modelName, options);
|
|
17
|
+
};
|
|
18
|
+
exports.blModel = blModel;
|
|
19
|
+
const getModelMetadata = async (model) => {
|
|
20
|
+
const cacheData = await (0, index_js_1.findFromCache)("Model", model);
|
|
21
|
+
if (cacheData) {
|
|
22
|
+
return cacheData;
|
|
23
|
+
}
|
|
24
|
+
const { data } = await (0, sdk_gen_js_1.getModel)({
|
|
25
|
+
path: {
|
|
26
|
+
modelName: model,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
return data || null;
|
|
30
|
+
};
|
|
31
|
+
exports.getModelMetadata = getModelMetadata;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SandboxAction = exports.ResponseError = void 0;
|
|
4
|
+
const client_fetch_1 = require("@hey-api/client-fetch");
|
|
5
|
+
const internal_js_1 = require("../common/internal.js");
|
|
6
|
+
const settings_js_1 = require("../common/settings.js");
|
|
7
|
+
const client_gen_js_1 = require("./client/client.gen.js");
|
|
8
|
+
class ResponseError extends Error {
|
|
9
|
+
response;
|
|
10
|
+
data;
|
|
11
|
+
error;
|
|
12
|
+
constructor(response, data, error) {
|
|
13
|
+
let dataError = {};
|
|
14
|
+
if (data && typeof data === 'object' && 'error' in data) {
|
|
15
|
+
dataError = data;
|
|
16
|
+
}
|
|
17
|
+
if (error && typeof error === 'object' && 'error' in error) {
|
|
18
|
+
dataError['error'] = error.error;
|
|
19
|
+
}
|
|
20
|
+
if (response.status) {
|
|
21
|
+
dataError['status'] = response.status;
|
|
22
|
+
}
|
|
23
|
+
if (response.statusText) {
|
|
24
|
+
dataError['statusText'] = response.statusText;
|
|
25
|
+
}
|
|
26
|
+
super(JSON.stringify(dataError));
|
|
27
|
+
this.response = response;
|
|
28
|
+
this.data = data;
|
|
29
|
+
this.error = error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ResponseError = ResponseError;
|
|
33
|
+
class SandboxAction {
|
|
34
|
+
sandbox;
|
|
35
|
+
constructor(sandbox) {
|
|
36
|
+
this.sandbox = sandbox;
|
|
37
|
+
}
|
|
38
|
+
get name() {
|
|
39
|
+
return this.sandbox.metadata?.name ?? "";
|
|
40
|
+
}
|
|
41
|
+
get fallbackUrl() {
|
|
42
|
+
if (this.externalUrl != this.url) {
|
|
43
|
+
return this.externalUrl;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
get externalUrl() {
|
|
48
|
+
return this.sandbox.metadata?.url ?? `${settings_js_1.settings.runUrl}/${settings_js_1.settings.workspace}/sandboxes/${this.name}`;
|
|
49
|
+
}
|
|
50
|
+
get internalUrl() {
|
|
51
|
+
return (0, internal_js_1.generateInternalUrl)(settings_js_1.settings.workspace, "sandbox", this.name, settings_js_1.settings.env, settings_js_1.settings.runInternalProtocol, settings_js_1.settings.runInternalHostname, settings_js_1.settings.blCloud, settings_js_1.settings.workspaceId);
|
|
52
|
+
}
|
|
53
|
+
get client() {
|
|
54
|
+
if (this.sandbox.forceUrl) {
|
|
55
|
+
return (0, client_fetch_1.createClient)({
|
|
56
|
+
baseUrl: this.sandbox.forceUrl,
|
|
57
|
+
headers: this.sandbox.headers,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return client_gen_js_1.client;
|
|
61
|
+
}
|
|
62
|
+
get forcedUrl() {
|
|
63
|
+
if (this.sandbox.forceUrl)
|
|
64
|
+
return this.sandbox.forceUrl;
|
|
65
|
+
return (0, internal_js_1.getForcedUrl)('sandbox', this.name);
|
|
66
|
+
}
|
|
67
|
+
get url() {
|
|
68
|
+
if (this.forcedUrl) {
|
|
69
|
+
const url = this.forcedUrl.toString();
|
|
70
|
+
return url.endsWith('/') ? url.slice(0, -1) : url;
|
|
71
|
+
}
|
|
72
|
+
// Uncomment and use this when agent and mcp are available in mk3
|
|
73
|
+
// Update all requests made in this package to use fallbackUrl when internalUrl is not working
|
|
74
|
+
// if (settings.runInternalHostname) return this.internalUrl;
|
|
75
|
+
return this.externalUrl;
|
|
76
|
+
}
|
|
77
|
+
handleResponseError(response, data, error) {
|
|
78
|
+
if (!response.ok || !data) {
|
|
79
|
+
throw new ResponseError(response, data, error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.SandboxAction = SandboxAction;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.client = void 0;
|
|
5
|
+
const client_fetch_1 = require("@hey-api/client-fetch");
|
|
6
|
+
exports.client = (0, client_fetch_1.createClient)((0, client_fetch_1.createConfig)());
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
18
|
+
__exportStar(require("./types.gen.js"), exports);
|
|
19
|
+
__exportStar(require("./sdk.gen.js"), exports);
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getWsWatchFilesystemByPath = exports.getWsProcessByIdentifierLogsStream = exports.getWatchFilesystemByPath = exports.getProcessByIdentifierLogsStream = exports.getProcessByIdentifierLogs = exports.deleteProcessByIdentifierKill = exports.getProcessByIdentifier = exports.deleteProcessByIdentifier = exports.postProcess = exports.getProcess = exports.getNetworkProcessByPidPorts = exports.postNetworkProcessByPidMonitor = exports.deleteNetworkProcessByPidMonitor = exports.putFilesystemByPath = exports.getFilesystemByPath = exports.deleteFilesystemByPath = void 0;
|
|
5
|
+
const client_gen_1 = require("./client.gen");
|
|
6
|
+
/**
|
|
7
|
+
* Delete file or directory
|
|
8
|
+
* Delete a file or directory
|
|
9
|
+
*/
|
|
10
|
+
const deleteFilesystemByPath = (options) => {
|
|
11
|
+
return (options.client ?? client_gen_1.client).delete({
|
|
12
|
+
security: [
|
|
13
|
+
{
|
|
14
|
+
scheme: 'bearer',
|
|
15
|
+
type: 'http'
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
url: '/filesystem/{path}',
|
|
19
|
+
...options
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
exports.deleteFilesystemByPath = deleteFilesystemByPath;
|
|
23
|
+
/**
|
|
24
|
+
* Get file or directory information
|
|
25
|
+
* Get content of a file or listing of a directory
|
|
26
|
+
*/
|
|
27
|
+
const getFilesystemByPath = (options) => {
|
|
28
|
+
return (options.client ?? client_gen_1.client).get({
|
|
29
|
+
security: [
|
|
30
|
+
{
|
|
31
|
+
scheme: 'bearer',
|
|
32
|
+
type: 'http'
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
url: '/filesystem/{path}',
|
|
36
|
+
...options
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.getFilesystemByPath = getFilesystemByPath;
|
|
40
|
+
/**
|
|
41
|
+
* Create or update a file or directory
|
|
42
|
+
* Create or update a file or directory
|
|
43
|
+
*/
|
|
44
|
+
const putFilesystemByPath = (options) => {
|
|
45
|
+
return (options.client ?? client_gen_1.client).put({
|
|
46
|
+
security: [
|
|
47
|
+
{
|
|
48
|
+
scheme: 'bearer',
|
|
49
|
+
type: 'http'
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
url: '/filesystem/{path}',
|
|
53
|
+
...options,
|
|
54
|
+
headers: {
|
|
55
|
+
'Content-Type': 'application/json',
|
|
56
|
+
...options?.headers
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
exports.putFilesystemByPath = putFilesystemByPath;
|
|
61
|
+
/**
|
|
62
|
+
* Stop monitoring ports for a process
|
|
63
|
+
* Stop monitoring for new ports opened by a process
|
|
64
|
+
*/
|
|
65
|
+
const deleteNetworkProcessByPidMonitor = (options) => {
|
|
66
|
+
return (options.client ?? client_gen_1.client).delete({
|
|
67
|
+
security: [
|
|
68
|
+
{
|
|
69
|
+
scheme: 'bearer',
|
|
70
|
+
type: 'http'
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
url: '/network/process/{pid}/monitor',
|
|
74
|
+
...options
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
exports.deleteNetworkProcessByPidMonitor = deleteNetworkProcessByPidMonitor;
|
|
78
|
+
/**
|
|
79
|
+
* Start monitoring ports for a process
|
|
80
|
+
* Start monitoring for new ports opened by a process
|
|
81
|
+
*/
|
|
82
|
+
const postNetworkProcessByPidMonitor = (options) => {
|
|
83
|
+
return (options.client ?? client_gen_1.client).post({
|
|
84
|
+
security: [
|
|
85
|
+
{
|
|
86
|
+
scheme: 'bearer',
|
|
87
|
+
type: 'http'
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
url: '/network/process/{pid}/monitor',
|
|
91
|
+
...options,
|
|
92
|
+
headers: {
|
|
93
|
+
'Content-Type': 'application/json',
|
|
94
|
+
...options?.headers
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
exports.postNetworkProcessByPidMonitor = postNetworkProcessByPidMonitor;
|
|
99
|
+
/**
|
|
100
|
+
* Get open ports for a process
|
|
101
|
+
* Get a list of all open ports for a process
|
|
102
|
+
*/
|
|
103
|
+
const getNetworkProcessByPidPorts = (options) => {
|
|
104
|
+
return (options.client ?? client_gen_1.client).get({
|
|
105
|
+
security: [
|
|
106
|
+
{
|
|
107
|
+
scheme: 'bearer',
|
|
108
|
+
type: 'http'
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
url: '/network/process/{pid}/ports',
|
|
112
|
+
...options
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
exports.getNetworkProcessByPidPorts = getNetworkProcessByPidPorts;
|
|
116
|
+
/**
|
|
117
|
+
* List all processes
|
|
118
|
+
* Get a list of all running and completed processes
|
|
119
|
+
*/
|
|
120
|
+
const getProcess = (options) => {
|
|
121
|
+
return (options?.client ?? client_gen_1.client).get({
|
|
122
|
+
security: [
|
|
123
|
+
{
|
|
124
|
+
scheme: 'bearer',
|
|
125
|
+
type: 'http'
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
url: '/process',
|
|
129
|
+
...options
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
exports.getProcess = getProcess;
|
|
133
|
+
/**
|
|
134
|
+
* Execute a command
|
|
135
|
+
* Execute a command and return process information
|
|
136
|
+
*/
|
|
137
|
+
const postProcess = (options) => {
|
|
138
|
+
return (options.client ?? client_gen_1.client).post({
|
|
139
|
+
security: [
|
|
140
|
+
{
|
|
141
|
+
scheme: 'bearer',
|
|
142
|
+
type: 'http'
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
url: '/process',
|
|
146
|
+
...options,
|
|
147
|
+
headers: {
|
|
148
|
+
'Content-Type': 'application/json',
|
|
149
|
+
...options?.headers
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
exports.postProcess = postProcess;
|
|
154
|
+
/**
|
|
155
|
+
* Stop a process
|
|
156
|
+
* Gracefully stop a running process
|
|
157
|
+
*/
|
|
158
|
+
const deleteProcessByIdentifier = (options) => {
|
|
159
|
+
return (options.client ?? client_gen_1.client).delete({
|
|
160
|
+
security: [
|
|
161
|
+
{
|
|
162
|
+
scheme: 'bearer',
|
|
163
|
+
type: 'http'
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
url: '/process/{identifier}',
|
|
167
|
+
...options
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
exports.deleteProcessByIdentifier = deleteProcessByIdentifier;
|
|
171
|
+
/**
|
|
172
|
+
* Get process by identifier
|
|
173
|
+
* Get information about a process by its PID or name
|
|
174
|
+
*/
|
|
175
|
+
const getProcessByIdentifier = (options) => {
|
|
176
|
+
return (options.client ?? client_gen_1.client).get({
|
|
177
|
+
security: [
|
|
178
|
+
{
|
|
179
|
+
scheme: 'bearer',
|
|
180
|
+
type: 'http'
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
url: '/process/{identifier}',
|
|
184
|
+
...options
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
exports.getProcessByIdentifier = getProcessByIdentifier;
|
|
188
|
+
/**
|
|
189
|
+
* Kill a process
|
|
190
|
+
* Forcefully kill a running process
|
|
191
|
+
*/
|
|
192
|
+
const deleteProcessByIdentifierKill = (options) => {
|
|
193
|
+
return (options.client ?? client_gen_1.client).delete({
|
|
194
|
+
security: [
|
|
195
|
+
{
|
|
196
|
+
scheme: 'bearer',
|
|
197
|
+
type: 'http'
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
url: '/process/{identifier}/kill',
|
|
201
|
+
...options
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
exports.deleteProcessByIdentifierKill = deleteProcessByIdentifierKill;
|
|
205
|
+
/**
|
|
206
|
+
* Get process logs
|
|
207
|
+
* Get the stdout and stderr output of a process
|
|
208
|
+
*/
|
|
209
|
+
const getProcessByIdentifierLogs = (options) => {
|
|
210
|
+
return (options.client ?? client_gen_1.client).get({
|
|
211
|
+
security: [
|
|
212
|
+
{
|
|
213
|
+
scheme: 'bearer',
|
|
214
|
+
type: 'http'
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
url: '/process/{identifier}/logs',
|
|
218
|
+
...options
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
exports.getProcessByIdentifierLogs = getProcessByIdentifierLogs;
|
|
222
|
+
/**
|
|
223
|
+
* Stream process logs in real time
|
|
224
|
+
* Streams the stdout and stderr output of a process in real time, one line per log, prefixed with 'stdout:' or 'stderr:'. Closes when the process exits or the client disconnects.
|
|
225
|
+
*/
|
|
226
|
+
const getProcessByIdentifierLogsStream = (options) => {
|
|
227
|
+
return (options.client ?? client_gen_1.client).get({
|
|
228
|
+
security: [
|
|
229
|
+
{
|
|
230
|
+
scheme: 'bearer',
|
|
231
|
+
type: 'http'
|
|
232
|
+
}
|
|
233
|
+
],
|
|
234
|
+
url: '/process/{identifier}/logs/stream',
|
|
235
|
+
...options
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
exports.getProcessByIdentifierLogsStream = getProcessByIdentifierLogsStream;
|
|
239
|
+
/**
|
|
240
|
+
* Stream file modification events in a directory
|
|
241
|
+
* Streams the path of modified files (one per line) in the given directory. Closes when the client disconnects.
|
|
242
|
+
*/
|
|
243
|
+
const getWatchFilesystemByPath = (options) => {
|
|
244
|
+
return (options.client ?? client_gen_1.client).get({
|
|
245
|
+
security: [
|
|
246
|
+
{
|
|
247
|
+
scheme: 'bearer',
|
|
248
|
+
type: 'http'
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
url: '/watch/filesystem/{path}',
|
|
252
|
+
...options
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
exports.getWatchFilesystemByPath = getWatchFilesystemByPath;
|
|
256
|
+
/**
|
|
257
|
+
* Stream process logs in real time via WebSocket
|
|
258
|
+
* Streams the stdout and stderr output of a process in real time as JSON messages.
|
|
259
|
+
*/
|
|
260
|
+
const getWsProcessByIdentifierLogsStream = (options) => {
|
|
261
|
+
return (options.client ?? client_gen_1.client).get({
|
|
262
|
+
security: [
|
|
263
|
+
{
|
|
264
|
+
scheme: 'bearer',
|
|
265
|
+
type: 'http'
|
|
266
|
+
}
|
|
267
|
+
],
|
|
268
|
+
url: '/ws/process/{identifier}/logs/stream',
|
|
269
|
+
...options
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
exports.getWsProcessByIdentifierLogsStream = getWsProcessByIdentifierLogsStream;
|
|
273
|
+
/**
|
|
274
|
+
* Stream file modification events in a directory via WebSocket
|
|
275
|
+
* Streams JSON events of modified files in the given directory. Closes when the client disconnects.
|
|
276
|
+
*/
|
|
277
|
+
const getWsWatchFilesystemByPath = (options) => {
|
|
278
|
+
return (options.client ?? client_gen_1.client).get({
|
|
279
|
+
security: [
|
|
280
|
+
{
|
|
281
|
+
scheme: 'bearer',
|
|
282
|
+
type: 'http'
|
|
283
|
+
}
|
|
284
|
+
],
|
|
285
|
+
url: '/ws/watch/filesystem/{path}',
|
|
286
|
+
...options
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
exports.getWsWatchFilesystemByPath = getWsWatchFilesystemByPath;
|