@blaxel/core 0.2.0-preview3 → 0.2.0-preview4
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 +1 -1
- package/dist/client/types.gen.d.ts +115 -17
- package/dist/common/env.js +3 -7
- 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/client/sdk.gen.d.ts +1 -1
- package/dist/sandbox/client/types.gen.d.ts +11 -14
- package/dist/sandbox/filesystem.js +3 -0
- package/package.json +3 -1
package/dist/client/sdk.gen.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export declare const listFunctionRevisions: <ThrowOnError extends boolean = fals
|
|
|
70
70
|
* List integrations connections
|
|
71
71
|
* Returns integration information by name.
|
|
72
72
|
*/
|
|
73
|
-
export declare const getIntegration: <ThrowOnError extends boolean = false>(options: Options<GetIntegrationData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<
|
|
73
|
+
export declare const getIntegration: <ThrowOnError extends boolean = false>(options: Options<GetIntegrationData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen.js").Integration, unknown, ThrowOnError>;
|
|
74
74
|
/**
|
|
75
75
|
* List integrations connections
|
|
76
76
|
* Returns a list of all connections integrations in the workspace.
|
|
@@ -419,6 +419,32 @@ export type HistogramStats = {
|
|
|
419
419
|
*/
|
|
420
420
|
p99?: number;
|
|
421
421
|
};
|
|
422
|
+
/**
|
|
423
|
+
* Integration
|
|
424
|
+
*/
|
|
425
|
+
export type Integration = {
|
|
426
|
+
/**
|
|
427
|
+
* Integration additional infos
|
|
428
|
+
*/
|
|
429
|
+
additionalInfos?: {
|
|
430
|
+
[key: string]: string;
|
|
431
|
+
};
|
|
432
|
+
endpoints?: IntegrationEndpoints;
|
|
433
|
+
headers?: IntegrationHeaders;
|
|
434
|
+
/**
|
|
435
|
+
* Integration name
|
|
436
|
+
*/
|
|
437
|
+
name?: string;
|
|
438
|
+
/**
|
|
439
|
+
* Integration organizations
|
|
440
|
+
*/
|
|
441
|
+
organizations?: Array<IntegrationOrganization>;
|
|
442
|
+
params?: IntegrationQueryParams;
|
|
443
|
+
/**
|
|
444
|
+
* Integration repositories
|
|
445
|
+
*/
|
|
446
|
+
repositories?: Array<IntegrationRepository>;
|
|
447
|
+
};
|
|
422
448
|
/**
|
|
423
449
|
* Integration Connection
|
|
424
450
|
*/
|
|
@@ -452,6 +478,62 @@ export type IntegrationConnectionSpec = {
|
|
|
452
478
|
};
|
|
453
479
|
};
|
|
454
480
|
export type IntegrationConnectionsList = Array<string>;
|
|
481
|
+
/**
|
|
482
|
+
* Integration endpoint
|
|
483
|
+
*/
|
|
484
|
+
export type IntegrationEndpoint = {
|
|
485
|
+
/**
|
|
486
|
+
* Integration endpoint body
|
|
487
|
+
*/
|
|
488
|
+
body?: string;
|
|
489
|
+
/**
|
|
490
|
+
* Integration endpoint ignore models
|
|
491
|
+
*/
|
|
492
|
+
ignoreModels?: Array<unknown>;
|
|
493
|
+
/**
|
|
494
|
+
* Integration endpoint method
|
|
495
|
+
*/
|
|
496
|
+
method?: string;
|
|
497
|
+
/**
|
|
498
|
+
* Integration endpoint models
|
|
499
|
+
*/
|
|
500
|
+
models?: Array<unknown>;
|
|
501
|
+
/**
|
|
502
|
+
* Integration endpoint stream key
|
|
503
|
+
*/
|
|
504
|
+
streamKey?: string;
|
|
505
|
+
streamToken?: IntegrationEndpointToken;
|
|
506
|
+
token?: IntegrationEndpointToken;
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Integration endpoint token
|
|
510
|
+
*/
|
|
511
|
+
export type IntegrationEndpointToken = {
|
|
512
|
+
/**
|
|
513
|
+
* Integration endpoint token received
|
|
514
|
+
*/
|
|
515
|
+
received?: string;
|
|
516
|
+
/**
|
|
517
|
+
* Integration endpoint token sent
|
|
518
|
+
*/
|
|
519
|
+
sent?: string;
|
|
520
|
+
/**
|
|
521
|
+
* Integration endpoint token total
|
|
522
|
+
*/
|
|
523
|
+
total?: string;
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* Integration endpoints
|
|
527
|
+
*/
|
|
528
|
+
export type IntegrationEndpoints = {
|
|
529
|
+
[key: string]: IntegrationEndpoint;
|
|
530
|
+
};
|
|
531
|
+
/**
|
|
532
|
+
* Integration headers
|
|
533
|
+
*/
|
|
534
|
+
export type IntegrationHeaders = {
|
|
535
|
+
[key: string]: string;
|
|
536
|
+
};
|
|
455
537
|
/**
|
|
456
538
|
* Model obtained from an external authentication provider, such as HuggingFace, OpenAI, etc...
|
|
457
539
|
*/
|
|
@@ -505,6 +587,33 @@ export type IntegrationModel = {
|
|
|
505
587
|
*/
|
|
506
588
|
trending_score?: number;
|
|
507
589
|
};
|
|
590
|
+
/**
|
|
591
|
+
* Integration organization
|
|
592
|
+
*/
|
|
593
|
+
export type IntegrationOrganization = {
|
|
594
|
+
/**
|
|
595
|
+
* Provider organization avatar URL
|
|
596
|
+
*/
|
|
597
|
+
avatar_url?: string;
|
|
598
|
+
/**
|
|
599
|
+
* Provider organization display name
|
|
600
|
+
*/
|
|
601
|
+
displayName?: string;
|
|
602
|
+
/**
|
|
603
|
+
* Provider organization ID
|
|
604
|
+
*/
|
|
605
|
+
id?: string;
|
|
606
|
+
/**
|
|
607
|
+
* Provider organization name
|
|
608
|
+
*/
|
|
609
|
+
name?: string;
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Integration query params
|
|
613
|
+
*/
|
|
614
|
+
export type IntegrationQueryParams = {
|
|
615
|
+
[key: string]: string;
|
|
616
|
+
};
|
|
508
617
|
/**
|
|
509
618
|
* Integration repository
|
|
510
619
|
*/
|
|
@@ -1109,6 +1218,10 @@ export type PreviewSpec = {
|
|
|
1109
1218
|
* Port of the preview
|
|
1110
1219
|
*/
|
|
1111
1220
|
port?: number;
|
|
1221
|
+
/**
|
|
1222
|
+
* Prefix URL
|
|
1223
|
+
*/
|
|
1224
|
+
prefixUrl?: string;
|
|
1112
1225
|
/**
|
|
1113
1226
|
* Whether the preview is public
|
|
1114
1227
|
*/
|
|
@@ -1162,10 +1275,6 @@ export type PreviewTokenSpec = {
|
|
|
1162
1275
|
* Expiration time of the token
|
|
1163
1276
|
*/
|
|
1164
1277
|
expiresAt?: string;
|
|
1165
|
-
/**
|
|
1166
|
-
* Whether the token is public
|
|
1167
|
-
*/
|
|
1168
|
-
public?: boolean;
|
|
1169
1278
|
/**
|
|
1170
1279
|
* Token
|
|
1171
1280
|
*/
|
|
@@ -1625,18 +1734,6 @@ export type SandboxSpec = CoreSpec & unknown;
|
|
|
1625
1734
|
* Name of a Sandbox definition
|
|
1626
1735
|
*/
|
|
1627
1736
|
export type SandboxStoreDefinitionName = unknown;
|
|
1628
|
-
/**
|
|
1629
|
-
* Micro VM for running agentic tasks
|
|
1630
|
-
*/
|
|
1631
|
-
export type Sandboxes = {
|
|
1632
|
-
events?: CoreEvents;
|
|
1633
|
-
metadata?: Metadata;
|
|
1634
|
-
spec?: SandboxSpec;
|
|
1635
|
-
/**
|
|
1636
|
-
* Sandbox status
|
|
1637
|
-
*/
|
|
1638
|
-
status?: string;
|
|
1639
|
-
};
|
|
1640
1737
|
/**
|
|
1641
1738
|
* Configuration for a serverless deployment
|
|
1642
1739
|
*/
|
|
@@ -2290,8 +2387,9 @@ export type GetIntegrationResponses = {
|
|
|
2290
2387
|
/**
|
|
2291
2388
|
* successful operation
|
|
2292
2389
|
*/
|
|
2293
|
-
200:
|
|
2390
|
+
200: Integration;
|
|
2294
2391
|
};
|
|
2392
|
+
export type GetIntegrationResponse = GetIntegrationResponses[keyof GetIntegrationResponses];
|
|
2295
2393
|
export type ListIntegrationConnectionsData = {
|
|
2296
2394
|
body?: never;
|
|
2297
2395
|
path?: never;
|
package/dist/common/env.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.env = void 0;
|
|
7
7
|
/* eslint-disable */
|
|
8
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
8
9
|
const toml_1 = __importDefault(require("toml"));
|
|
9
10
|
const node_js_1 = require("./node.js");
|
|
10
11
|
const secretEnv = {};
|
|
@@ -20,13 +21,8 @@ if (node_js_1.fs !== null) {
|
|
|
20
21
|
catch (error) { }
|
|
21
22
|
try {
|
|
22
23
|
const secretFile = node_js_1.fs.readFileSync(".env", "utf8");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const [key, value] = line.split("=");
|
|
28
|
-
secretEnv[key] = value;
|
|
29
|
-
});
|
|
24
|
+
const parsed = dotenv_1.default.parse(secretFile);
|
|
25
|
+
Object.assign(secretEnv, parsed);
|
|
30
26
|
}
|
|
31
27
|
catch (error) { }
|
|
32
28
|
}
|
|
@@ -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;
|
|
@@ -22,7 +22,7 @@ export declare const deleteFilesystemByPath: <ThrowOnError extends boolean = fal
|
|
|
22
22
|
* Get file or directory information
|
|
23
23
|
* Get content of a file or listing of a directory
|
|
24
24
|
*/
|
|
25
|
-
export declare const getFilesystemByPath: <ThrowOnError extends boolean = false>(options: Options<GetFilesystemByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").
|
|
25
|
+
export declare const getFilesystemByPath: <ThrowOnError extends boolean = false>(options: Options<GetFilesystemByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Directory | import("./types.gen").FileWithContent, import("./types.gen").ErrorResponse, ThrowOnError>;
|
|
26
26
|
/**
|
|
27
27
|
* Create or update file or directory
|
|
28
28
|
* Create or update a file or directory
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export type Directory = {
|
|
2
|
+
files?: Array<File>;
|
|
3
|
+
path?: string;
|
|
4
|
+
/**
|
|
5
|
+
* @name Subdirectories
|
|
6
|
+
*/
|
|
7
|
+
subdirectories?: Array<Subdirectory>;
|
|
8
|
+
};
|
|
1
9
|
export type ErrorResponse = {
|
|
2
10
|
error?: string;
|
|
3
11
|
};
|
|
@@ -6,9 +14,6 @@ export type File = {
|
|
|
6
14
|
lastModified?: string;
|
|
7
15
|
owner?: string;
|
|
8
16
|
path?: string;
|
|
9
|
-
/**
|
|
10
|
-
* swagger:strfmt string
|
|
11
|
-
*/
|
|
12
17
|
permissions?: string;
|
|
13
18
|
size?: number;
|
|
14
19
|
};
|
|
@@ -23,9 +28,6 @@ export type FileWithContent = {
|
|
|
23
28
|
lastModified?: string;
|
|
24
29
|
owner?: string;
|
|
25
30
|
path?: string;
|
|
26
|
-
/**
|
|
27
|
-
* swagger:strfmt string
|
|
28
|
-
*/
|
|
29
31
|
permissions?: string;
|
|
30
32
|
size?: number;
|
|
31
33
|
};
|
|
@@ -57,17 +59,12 @@ export type ProcessResponse = {
|
|
|
57
59
|
status?: string;
|
|
58
60
|
workingDir?: string;
|
|
59
61
|
};
|
|
60
|
-
export type
|
|
61
|
-
message?: string;
|
|
62
|
+
export type Subdirectory = {
|
|
62
63
|
path?: string;
|
|
63
64
|
};
|
|
64
|
-
export type
|
|
65
|
-
|
|
65
|
+
export type SuccessResponse = {
|
|
66
|
+
message?: string;
|
|
66
67
|
path?: string;
|
|
67
|
-
/**
|
|
68
|
-
* @name Subdirectories
|
|
69
|
-
*/
|
|
70
|
-
subdirectories?: Array<Directory>;
|
|
71
68
|
};
|
|
72
69
|
export type DeleteFilesystemByPathData = {
|
|
73
70
|
body?: never;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaxel/core",
|
|
3
|
-
"version": "0.2.0-
|
|
3
|
+
"version": "0.2.0-preview4",
|
|
4
4
|
"description": "Blaxel Core SDK for TypeScript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Blaxel, INC (https://blaxel.ai)",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"@hey-api/client-fetch": "^0.10.0",
|
|
57
57
|
"@modelcontextprotocol/sdk": "^1.11.0",
|
|
58
58
|
"crypto": "^1.0.1",
|
|
59
|
+
"dotenv": "^16.5.0",
|
|
59
60
|
"jwt-decode": "^4.0.0",
|
|
60
61
|
"toml": "^3.0.0",
|
|
61
62
|
"uuid": "^11.1.0",
|
|
@@ -71,6 +72,7 @@
|
|
|
71
72
|
},
|
|
72
73
|
"scripts": {
|
|
73
74
|
"lint": "eslint src/",
|
|
75
|
+
"dev": "tsc --watch",
|
|
74
76
|
"build": "tsc"
|
|
75
77
|
}
|
|
76
78
|
}
|