@blaxel/core 0.2.0-preview3 → 0.2.0-preview5
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/client/sdk.gen.d.ts +32 -2
- package/dist/client/sdk.gen.js +112 -2
- package/dist/client/types.gen.d.ts +237 -17
- package/dist/common/env.js +3 -7
- package/dist/common/internal.d.ts +1 -1
- package/dist/common/internal.js +3 -6
- package/dist/common/settings.d.ts +2 -0
- package/dist/common/settings.js +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.js +17 -0
- package/dist/jobs/jobs.d.ts +10 -0
- package/dist/jobs/jobs.js +42 -0
- package/dist/mcp/client.js +0 -3
- package/dist/mcp/server/http.d.ts +8 -0
- package/dist/mcp/server/http.js +16 -0
- package/dist/mcp/server/index.d.ts +4 -0
- package/dist/mcp/server/index.js +21 -0
- package/dist/mcp/server/websocket.d.ts +24 -0
- package/dist/mcp/server/websocket.js +213 -0
- package/dist/sandbox/action.d.ts +4 -3
- package/dist/sandbox/action.js +16 -2
- package/dist/sandbox/client/sdk.gen.d.ts +9 -6
- package/dist/sandbox/client/sdk.gen.js +14 -3
- package/dist/sandbox/client/types.gen.d.ts +33 -17
- package/dist/sandbox/filesystem.d.ts +6 -0
- package/dist/sandbox/filesystem.js +77 -0
- package/dist/sandbox/process.d.ts +11 -0
- package/dist/sandbox/process.js +77 -0
- package/dist/sandbox/sandbox.d.ts +5 -1
- package/dist/sandbox/sandbox.js +6 -0
- package/dist/sandbox/session.d.ts +21 -0
- package/dist/sandbox/session.js +97 -0
- package/dist/sandbox/types.d.ts +15 -0
- package/dist/sandbox/types.js +2 -0
- package/dist/telemetry/telemetry.d.ts +1 -0
- package/dist/telemetry/telemetry.js +14 -0
- package/package.json +5 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.blJob = void 0;
|
|
7
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
8
|
+
const helpers_1 = require("yargs/helpers");
|
|
9
|
+
const env_js_1 = require("../common/env.js");
|
|
10
|
+
class BlJob {
|
|
11
|
+
async getArguments() {
|
|
12
|
+
if (!env_js_1.env.BL_EXECUTION_DATA_URL) {
|
|
13
|
+
const argv = await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
14
|
+
.parseAsync();
|
|
15
|
+
return argv;
|
|
16
|
+
}
|
|
17
|
+
const response = await fetch(env_js_1.env.BL_EXECUTION_DATA_URL);
|
|
18
|
+
const data = await response.json();
|
|
19
|
+
return data.tasks[this.index] ?? {};
|
|
20
|
+
}
|
|
21
|
+
get indexKey() {
|
|
22
|
+
return env_js_1.env.BL_EXECUTION_INDEX_KEY ?? "TASK_INDEX";
|
|
23
|
+
}
|
|
24
|
+
get index() {
|
|
25
|
+
return env_js_1.env[this.indexKey] ? Number(env_js_1.env[this.indexKey]) ?? 0 : 0;
|
|
26
|
+
}
|
|
27
|
+
/*
|
|
28
|
+
Run a job defined in a function, it's run in the current process
|
|
29
|
+
*/
|
|
30
|
+
async start(func) {
|
|
31
|
+
try {
|
|
32
|
+
const parsedArgs = await this.getArguments();
|
|
33
|
+
await func(parsedArgs);
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error('Job execution failed:', error);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.blJob = new BlJob();
|
package/dist/mcp/client.js
CHANGED
|
@@ -63,16 +63,13 @@ class BlaxelMcpClientTransport {
|
|
|
63
63
|
this.onerror?.(error);
|
|
64
64
|
};
|
|
65
65
|
this._socket.onopen = () => {
|
|
66
|
-
logger_js_1.logger.debug("WebSocket opened");
|
|
67
66
|
resolve();
|
|
68
67
|
};
|
|
69
68
|
this._socket.onclose = () => {
|
|
70
|
-
logger_js_1.logger.debug("WebSocket closed");
|
|
71
69
|
this.onclose?.();
|
|
72
70
|
this._socket = undefined;
|
|
73
71
|
};
|
|
74
72
|
this._socket.onmessage = (event) => {
|
|
75
|
-
logger_js_1.logger.debug("WebSocket message received");
|
|
76
73
|
let message;
|
|
77
74
|
try {
|
|
78
75
|
let dataString;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
2
|
+
import { JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
export declare class BlaxelHttpMcpServerTransport implements Transport {
|
|
4
|
+
private server;
|
|
5
|
+
constructor(port: number);
|
|
6
|
+
start(): Promise<void>;
|
|
7
|
+
send(msg: JSONRPCMessage): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BlaxelHttpMcpServerTransport = void 0;
|
|
4
|
+
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
5
|
+
class BlaxelHttpMcpServerTransport {
|
|
6
|
+
server;
|
|
7
|
+
constructor(port) {
|
|
8
|
+
this.server = new streamableHttp_js_1.StreamableHTTPServerTransport({ port });
|
|
9
|
+
}
|
|
10
|
+
async start() {
|
|
11
|
+
await this.server.start();
|
|
12
|
+
}
|
|
13
|
+
async send(msg) {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.BlaxelHttpMcpServerTransport = BlaxelHttpMcpServerTransport;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
exports.BlaxelMcpServerTransport = void 0;
|
|
18
|
+
__exportStar(require("./http.js"), exports);
|
|
19
|
+
__exportStar(require("./websocket.js"), exports);
|
|
20
|
+
const websocket_js_1 = require("./websocket.js");
|
|
21
|
+
exports.BlaxelMcpServerTransport = websocket_js_1.BlaxelWebsocketMcpServerTransport;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
2
|
+
interface JSONRPCMessage {
|
|
3
|
+
jsonrpc: "2.0";
|
|
4
|
+
id?: string | number;
|
|
5
|
+
method?: string;
|
|
6
|
+
params?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export declare class BlaxelWebsocketMcpServerTransport implements Transport {
|
|
9
|
+
private port;
|
|
10
|
+
private wss;
|
|
11
|
+
private clients;
|
|
12
|
+
onclose?: () => void;
|
|
13
|
+
onerror?: (err: Error) => void;
|
|
14
|
+
private messageHandler?;
|
|
15
|
+
onconnection?: (clientId: string) => void;
|
|
16
|
+
ondisconnection?: (clientId: string) => void;
|
|
17
|
+
set onmessage(handler: ((message: JSONRPCMessage) => void) | undefined);
|
|
18
|
+
constructor(port?: number);
|
|
19
|
+
start(): Promise<void>;
|
|
20
|
+
send(msg: JSONRPCMessage): Promise<void>;
|
|
21
|
+
broadcast(msg: JSONRPCMessage): Promise<void>;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -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.BlaxelWebsocketMcpServerTransport = 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 BlaxelWebsocketMcpServerTransport {
|
|
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.BlaxelWebsocketMcpServerTransport = BlaxelWebsocketMcpServerTransport;
|
package/dist/sandbox/action.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SandboxConfiguration } from "./types.js";
|
|
2
2
|
export declare class ResponseError extends Error {
|
|
3
3
|
response: Response;
|
|
4
4
|
data: unknown;
|
|
@@ -6,12 +6,13 @@ export declare class ResponseError extends Error {
|
|
|
6
6
|
constructor(response: Response, data: unknown, error: unknown);
|
|
7
7
|
}
|
|
8
8
|
export declare class SandboxAction {
|
|
9
|
-
|
|
10
|
-
constructor(sandbox:
|
|
9
|
+
protected sandbox: SandboxConfiguration;
|
|
10
|
+
constructor(sandbox: SandboxConfiguration);
|
|
11
11
|
get name(): string;
|
|
12
12
|
get fallbackUrl(): string | null;
|
|
13
13
|
get externalUrl(): string;
|
|
14
14
|
get internalUrl(): string;
|
|
15
|
+
get client(): import("@hey-api/client-fetch").Client;
|
|
15
16
|
get forcedUrl(): string | null;
|
|
16
17
|
get url(): string;
|
|
17
18
|
handleResponseError(response: Response, data: unknown, error: unknown): void;
|
package/dist/sandbox/action.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SandboxAction = exports.ResponseError = void 0;
|
|
4
|
+
const client_fetch_1 = require("@hey-api/client-fetch");
|
|
4
5
|
const process_1 = require("process");
|
|
5
6
|
const internal_js_1 = require("../common/internal.js");
|
|
6
7
|
const settings_js_1 = require("../common/settings.js");
|
|
8
|
+
const client_gen_js_1 = require("./client/client.gen.js");
|
|
7
9
|
class ResponseError extends Error {
|
|
8
10
|
response;
|
|
9
11
|
data;
|
|
@@ -50,7 +52,18 @@ class SandboxAction {
|
|
|
50
52
|
const hash = (0, internal_js_1.getGlobalUniqueHash)(settings_js_1.settings.workspace, "sandbox", this.name);
|
|
51
53
|
return `${settings_js_1.settings.runInternalProtocol}://bl-${settings_js_1.settings.env}-${hash}.${settings_js_1.settings.runInternalHostname}`;
|
|
52
54
|
}
|
|
55
|
+
get client() {
|
|
56
|
+
if (this.sandbox.forceUrl) {
|
|
57
|
+
return (0, client_fetch_1.createClient)({
|
|
58
|
+
baseUrl: this.sandbox.forceUrl,
|
|
59
|
+
headers: this.sandbox.headers,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return client_gen_js_1.client;
|
|
63
|
+
}
|
|
53
64
|
get forcedUrl() {
|
|
65
|
+
if (this.sandbox.forceUrl)
|
|
66
|
+
return this.sandbox.forceUrl;
|
|
54
67
|
const envVar = this.name.replace(/-/g, "_").toUpperCase();
|
|
55
68
|
const envName = `BL_SANDBOX_${envVar}_URL`;
|
|
56
69
|
if (process_1.env[envName]) {
|
|
@@ -61,8 +74,9 @@ class SandboxAction {
|
|
|
61
74
|
get url() {
|
|
62
75
|
if (this.forcedUrl)
|
|
63
76
|
return this.forcedUrl;
|
|
64
|
-
|
|
65
|
-
|
|
77
|
+
// Uncomment and use this when agent and mcp are available in mk3
|
|
78
|
+
// Update all requests made in this package to use fallbackUrl when internalUrl is not working
|
|
79
|
+
// if (settings.runInternalHostname) return this.internalUrl;
|
|
66
80
|
return this.externalUrl;
|
|
67
81
|
}
|
|
68
82
|
handleResponseError(response, data, error) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
|
|
2
|
-
import type { DeleteFilesystemByPathData, GetFilesystemByPathData, PutFilesystemByPathData, DeleteNetworkProcessByPidMonitorData, PostNetworkProcessByPidMonitorData, GetNetworkProcessByPidPortsData, GetProcessData, PostProcessData, DeleteProcessByIdentifierData, GetProcessByIdentifierData, DeleteProcessByIdentifierKillData, GetProcessByIdentifierLogsData, GetProcessByIdentifierLogsStreamData } from './types.gen';
|
|
2
|
+
import type { DeleteFilesystemByPathData, GetFilesystemByPathData, PutFilesystemByPathData, DeleteNetworkProcessByPidMonitorData, PostNetworkProcessByPidMonitorData, GetNetworkProcessByPidPortsData, GetProcessData, PostProcessData, DeleteProcessByIdentifierData, GetProcessByIdentifierData, DeleteProcessByIdentifierKillData, GetProcessByIdentifierLogsData, GetProcessByIdentifierLogsStreamData, GetWatchFilesystemByPathData } from './types.gen';
|
|
3
3
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
@@ -82,9 +82,12 @@ export declare const getProcessByIdentifierLogs: <ThrowOnError extends boolean =
|
|
|
82
82
|
[key: string]: string;
|
|
83
83
|
}, import("./types.gen").ErrorResponse, ThrowOnError>;
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
85
|
+
* Stream process logs in real time
|
|
86
|
+
* 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.
|
|
87
87
|
*/
|
|
88
|
-
export declare const getProcessByIdentifierLogsStream: <ThrowOnError extends boolean = false>(options: Options<GetProcessByIdentifierLogsStreamData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
export declare const getProcessByIdentifierLogsStream: <ThrowOnError extends boolean = false>(options: Options<GetProcessByIdentifierLogsStreamData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<string, import("./types.gen").ErrorResponse, ThrowOnError>;
|
|
89
|
+
/**
|
|
90
|
+
* Stream file modification events in a directory
|
|
91
|
+
* Streams the path of modified files (one per line) in the given directory. Closes when the client disconnects.
|
|
92
|
+
*/
|
|
93
|
+
export declare const getWatchFilesystemByPath: <ThrowOnError extends boolean = false>(options: Options<GetWatchFilesystemByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<string, import("./types.gen").ErrorResponse, ThrowOnError>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
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;
|
|
4
|
+
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
5
|
const client_gen_1 = require("./client.gen");
|
|
6
6
|
/**
|
|
7
7
|
* Delete file or directory
|
|
@@ -152,8 +152,8 @@ const getProcessByIdentifierLogs = (options) => {
|
|
|
152
152
|
};
|
|
153
153
|
exports.getProcessByIdentifierLogs = getProcessByIdentifierLogs;
|
|
154
154
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
155
|
+
* Stream process logs in real time
|
|
156
|
+
* 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.
|
|
157
157
|
*/
|
|
158
158
|
const getProcessByIdentifierLogsStream = (options) => {
|
|
159
159
|
return (options.client ?? client_gen_1.client).get({
|
|
@@ -162,3 +162,14 @@ const getProcessByIdentifierLogsStream = (options) => {
|
|
|
162
162
|
});
|
|
163
163
|
};
|
|
164
164
|
exports.getProcessByIdentifierLogsStream = getProcessByIdentifierLogsStream;
|
|
165
|
+
/**
|
|
166
|
+
* Stream file modification events in a directory
|
|
167
|
+
* Streams the path of modified files (one per line) in the given directory. Closes when the client disconnects.
|
|
168
|
+
*/
|
|
169
|
+
const getWatchFilesystemByPath = (options) => {
|
|
170
|
+
return (options.client ?? client_gen_1.client).get({
|
|
171
|
+
url: '/watch/filesystem/{path}',
|
|
172
|
+
...options
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
exports.getWatchFilesystemByPath = getWatchFilesystemByPath;
|
|
@@ -41,7 +41,6 @@ export type ProcessKillRequest = {
|
|
|
41
41
|
export type ProcessRequest = {
|
|
42
42
|
command: string;
|
|
43
43
|
name?: string;
|
|
44
|
-
streamLogs?: boolean;
|
|
45
44
|
timeout?: number;
|
|
46
45
|
waitForCompletion?: boolean;
|
|
47
46
|
waitForPorts?: Array<number>;
|
|
@@ -394,12 +393,7 @@ export type GetProcessByIdentifierLogsData = {
|
|
|
394
393
|
*/
|
|
395
394
|
identifier: string;
|
|
396
395
|
};
|
|
397
|
-
query?:
|
|
398
|
-
/**
|
|
399
|
-
* Stream logs
|
|
400
|
-
*/
|
|
401
|
-
stream?: boolean;
|
|
402
|
-
};
|
|
396
|
+
query?: never;
|
|
403
397
|
url: '/process/{identifier}/logs';
|
|
404
398
|
};
|
|
405
399
|
export type GetProcessByIdentifierLogsErrors = {
|
|
@@ -430,12 +424,7 @@ export type GetProcessByIdentifierLogsStreamData = {
|
|
|
430
424
|
*/
|
|
431
425
|
identifier: string;
|
|
432
426
|
};
|
|
433
|
-
query?:
|
|
434
|
-
/**
|
|
435
|
-
* Stream logs
|
|
436
|
-
*/
|
|
437
|
-
stream?: boolean;
|
|
438
|
-
};
|
|
427
|
+
query?: never;
|
|
439
428
|
url: '/process/{identifier}/logs/stream';
|
|
440
429
|
};
|
|
441
430
|
export type GetProcessByIdentifierLogsStreamErrors = {
|
|
@@ -451,13 +440,40 @@ export type GetProcessByIdentifierLogsStreamErrors = {
|
|
|
451
440
|
export type GetProcessByIdentifierLogsStreamError = GetProcessByIdentifierLogsStreamErrors[keyof GetProcessByIdentifierLogsStreamErrors];
|
|
452
441
|
export type GetProcessByIdentifierLogsStreamResponses = {
|
|
453
442
|
/**
|
|
454
|
-
*
|
|
443
|
+
* Stream of process logs, one line per log (prefixed with stdout:/stderr:)
|
|
455
444
|
*/
|
|
456
|
-
200:
|
|
457
|
-
[key: string]: string;
|
|
458
|
-
};
|
|
445
|
+
200: string;
|
|
459
446
|
};
|
|
460
447
|
export type GetProcessByIdentifierLogsStreamResponse = GetProcessByIdentifierLogsStreamResponses[keyof GetProcessByIdentifierLogsStreamResponses];
|
|
448
|
+
export type GetWatchFilesystemByPathData = {
|
|
449
|
+
body?: never;
|
|
450
|
+
path: {
|
|
451
|
+
/**
|
|
452
|
+
* Directory path to watch
|
|
453
|
+
*/
|
|
454
|
+
path: string;
|
|
455
|
+
};
|
|
456
|
+
query?: never;
|
|
457
|
+
url: '/watch/filesystem/{path}';
|
|
458
|
+
};
|
|
459
|
+
export type GetWatchFilesystemByPathErrors = {
|
|
460
|
+
/**
|
|
461
|
+
* Invalid path
|
|
462
|
+
*/
|
|
463
|
+
400: ErrorResponse;
|
|
464
|
+
/**
|
|
465
|
+
* Internal server error
|
|
466
|
+
*/
|
|
467
|
+
500: ErrorResponse;
|
|
468
|
+
};
|
|
469
|
+
export type GetWatchFilesystemByPathError = GetWatchFilesystemByPathErrors[keyof GetWatchFilesystemByPathErrors];
|
|
470
|
+
export type GetWatchFilesystemByPathResponses = {
|
|
471
|
+
/**
|
|
472
|
+
* Stream of modified file paths, one per line
|
|
473
|
+
*/
|
|
474
|
+
200: string;
|
|
475
|
+
};
|
|
476
|
+
export type GetWatchFilesystemByPathResponse = GetWatchFilesystemByPathResponses[keyof GetWatchFilesystemByPathResponses];
|
|
461
477
|
export type ClientOptions = {
|
|
462
478
|
baseUrl: `${string}://localhost:8080` | (string & {});
|
|
463
479
|
};
|
|
@@ -14,5 +14,11 @@ export declare class SandboxFileSystem extends SandboxAction {
|
|
|
14
14
|
rm(path: string, recursive?: boolean): Promise<SuccessResponse>;
|
|
15
15
|
ls(path: string): Promise<Directory>;
|
|
16
16
|
cp(source: string, destination: string): Promise<CopyResponse>;
|
|
17
|
+
watch(path: string, callback: (filePath: string, content?: string) => void | Promise<void>, options?: {
|
|
18
|
+
onError?: (error: Error) => void;
|
|
19
|
+
withContent: boolean;
|
|
20
|
+
}): {
|
|
21
|
+
close: () => void;
|
|
22
|
+
};
|
|
17
23
|
private formatPath;
|
|
18
24
|
}
|