@blaxel/core 0.2.0-preview5 → 0.2.1-dev.46

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.
@@ -13,7 +13,6 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
13
13
  path: { path },
14
14
  body: { isDirectory: true, permissions },
15
15
  baseUrl: this.url,
16
- client: this.client,
17
16
  });
18
17
  this.handleResponseError(response, data, error);
19
18
  return data;
@@ -24,7 +23,6 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
24
23
  path: { path },
25
24
  body: { content },
26
25
  baseUrl: this.url,
27
- client: this.client,
28
26
  });
29
27
  this.handleResponseError(response, data, error);
30
28
  return data;
@@ -34,7 +32,6 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
34
32
  const { response, data, error } = await (0, index_js_1.getFilesystemByPath)({
35
33
  path: { path },
36
34
  baseUrl: this.url,
37
- client: this.client,
38
35
  });
39
36
  this.handleResponseError(response, data, error);
40
37
  if (data && 'content' in data) {
@@ -48,7 +45,6 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
48
45
  path: { path },
49
46
  query: { recursive },
50
47
  baseUrl: this.url,
51
- client: this.client,
52
48
  });
53
49
  this.handleResponseError(response, data, error);
54
50
  return data;
@@ -58,7 +54,6 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
58
54
  const { response, data, error } = await (0, index_js_1.getFilesystemByPath)({
59
55
  path: { path },
60
56
  baseUrl: this.url,
61
- client: this.client,
62
57
  });
63
58
  this.handleResponseError(response, data, error);
64
59
  if (!data || !('files' in data || 'subdirectories' in data)) {
@@ -72,7 +67,6 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
72
67
  const { response, data, error } = await (0, index_js_1.getFilesystemByPath)({
73
68
  path: { path: source },
74
69
  baseUrl: this.url,
75
- client: this.client,
76
70
  });
77
71
  this.handleResponseError(response, data, error);
78
72
  if (data && ('files' in data || 'subdirectories' in data)) {
@@ -117,13 +111,136 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
117
111
  }
118
112
  throw new Error("Unsupported file type");
119
113
  }
114
+ /**
115
+ * Watch for changes in a directory. Calls the callback with the changed file path (and optionally its content).
116
+ * Returns a handle with a close() method to stop watching.
117
+ * @param path Directory to watch
118
+ * @param callback Function called on each change: (filePath, content?)
119
+ * @param withContent If true, also fetches and passes the file content (default: false)
120
+ */
120
121
  watch(path, callback, options) {
122
+ if (options?.ws) {
123
+ return this.wsWatch(path, callback, options);
124
+ }
125
+ return this.sseWatch(path, callback, options);
126
+ }
127
+ wsWatch(path, callback, options) {
128
+ path = this.formatPath(path);
129
+ let closed = false;
130
+ let ws = this.websocket(`watch/filesystem${path.startsWith('/') ? path : '/' + path}`);
131
+ let pingInterval = null;
132
+ let pongTimeout = null;
133
+ const PING_INTERVAL_MS = 30000;
134
+ const PONG_TIMEOUT_MS = 10000;
135
+ function sendPing() {
136
+ if (ws && ws.readyState === ws.OPEN) {
137
+ try {
138
+ ws.send(JSON.stringify({ type: 'ping' }));
139
+ }
140
+ catch { }
141
+ // Set pong timeout
142
+ if (pongTimeout)
143
+ clearTimeout(pongTimeout);
144
+ pongTimeout = setTimeout(() => {
145
+ // No pong received in time, close connection
146
+ if (ws && typeof ws.close === 'function')
147
+ ws.close();
148
+ }, PONG_TIMEOUT_MS);
149
+ }
150
+ }
151
+ if (ws) {
152
+ ws.onmessage = async (event) => {
153
+ if (closed)
154
+ return;
155
+ let data;
156
+ try {
157
+ data = typeof event.data === 'string' ? event.data : event.data;
158
+ if (!data)
159
+ return;
160
+ // Accept both JSON and plain string (file path)
161
+ let payload;
162
+ try {
163
+ payload = JSON.parse(data);
164
+ }
165
+ catch {
166
+ payload = { name: data, event: undefined };
167
+ }
168
+ // Handle ping/pong
169
+ if (payload.type === 'ping') {
170
+ // Respond to ping with pong
171
+ if (ws && ws.readyState === ws.OPEN) {
172
+ try {
173
+ ws.send(JSON.stringify({ type: 'pong' }));
174
+ }
175
+ catch { }
176
+ }
177
+ return;
178
+ }
179
+ if (payload.type === 'pong') {
180
+ // Pong received, clear pong timeout
181
+ if (pongTimeout)
182
+ clearTimeout(pongTimeout);
183
+ pongTimeout = null;
184
+ return;
185
+ }
186
+ const filePath = payload.name || payload.path || data;
187
+ if (!filePath)
188
+ return;
189
+ if (options?.withContent) {
190
+ try {
191
+ const content = await this.read(filePath);
192
+ await callback(filePath, content);
193
+ }
194
+ catch (e) {
195
+ await callback(filePath, undefined);
196
+ }
197
+ }
198
+ else {
199
+ await callback(filePath);
200
+ }
201
+ }
202
+ catch (err) {
203
+ if (options?.onError)
204
+ options.onError(err);
205
+ }
206
+ };
207
+ ws.onerror = (err) => {
208
+ if (options?.onError)
209
+ options.onError(err instanceof Error ? err : new Error(String(err)));
210
+ closed = true;
211
+ if (ws && typeof ws.close === 'function')
212
+ ws.close();
213
+ };
214
+ ws.onclose = () => {
215
+ closed = true;
216
+ ws = null;
217
+ if (pingInterval)
218
+ clearInterval(pingInterval);
219
+ if (pongTimeout)
220
+ clearTimeout(pongTimeout);
221
+ };
222
+ // Start ping interval
223
+ pingInterval = setInterval(sendPing, PING_INTERVAL_MS);
224
+ }
225
+ return {
226
+ close: () => {
227
+ closed = true;
228
+ if (ws && typeof ws.close === 'function')
229
+ ws.close();
230
+ ws = null;
231
+ if (pingInterval)
232
+ clearInterval(pingInterval);
233
+ if (pongTimeout)
234
+ clearTimeout(pongTimeout);
235
+ },
236
+ };
237
+ }
238
+ sseWatch(path, callback, options) {
121
239
  path = this.formatPath(path);
122
240
  let closed = false;
123
241
  let controller = new AbortController();
124
242
  const start = async () => {
125
243
  const { response, data, error } = await (0, index_js_1.getWatchFilesystemByPath)({
126
- client: this.client,
127
244
  path: { path },
128
245
  baseUrl: this.url,
129
246
  parseAs: 'stream',
@@ -4,6 +4,21 @@ import { DeleteProcessByIdentifierKillResponse, DeleteProcessByIdentifierRespons
4
4
  export declare class SandboxProcess extends SandboxAction {
5
5
  constructor(sandbox: Sandbox);
6
6
  streamLogs(identifier: string, options: {
7
+ ws?: boolean;
8
+ onLog?: (log: string) => void;
9
+ onStdout?: (stdout: string) => void;
10
+ onStderr?: (stderr: string) => void;
11
+ }): {
12
+ close: () => void;
13
+ };
14
+ wsStreamLogs(identifier: string, options: {
15
+ onLog?: (log: string) => void;
16
+ onStdout?: (stdout: string) => void;
17
+ onStderr?: (stderr: string) => void;
18
+ }): {
19
+ close: () => void;
20
+ };
21
+ sseStreamLogs(identifier: string, options: {
7
22
  onLog?: (log: string) => void;
8
23
  onStdout?: (stdout: string) => void;
9
24
  onStderr?: (stderr: string) => void;
@@ -9,14 +9,126 @@ class SandboxProcess extends action_js_1.SandboxAction {
9
9
  super(sandbox);
10
10
  }
11
11
  streamLogs(identifier, options) {
12
+ if (options.ws) {
13
+ return this.wsStreamLogs(identifier, options);
14
+ }
15
+ return this.sseStreamLogs(identifier, options);
16
+ }
17
+ wsStreamLogs(identifier, options) {
18
+ let closed = false;
19
+ let ws = this.websocket(`process/${identifier}/logs/stream`);
20
+ let pingInterval = null;
21
+ let pongTimeout = null;
22
+ const PING_INTERVAL_MS = 30000;
23
+ const PONG_TIMEOUT_MS = 10000;
24
+ function sendPing() {
25
+ if (ws && ws.readyState === ws.OPEN) {
26
+ try {
27
+ ws.send(JSON.stringify({ type: 'ping' }));
28
+ }
29
+ catch { }
30
+ // Set pong timeout
31
+ if (pongTimeout)
32
+ clearTimeout(pongTimeout);
33
+ pongTimeout = setTimeout(() => {
34
+ // No pong received in time, close connection
35
+ if (ws && typeof ws.close === 'function')
36
+ ws.close();
37
+ }, PONG_TIMEOUT_MS);
38
+ }
39
+ }
40
+ if (ws) {
41
+ ws.onmessage = (event) => {
42
+ if (closed)
43
+ return;
44
+ let data;
45
+ try {
46
+ data = typeof event.data === 'string' ? event.data : event.data;
47
+ if (!data)
48
+ return;
49
+ let payload;
50
+ try {
51
+ payload = JSON.parse(data);
52
+ }
53
+ catch {
54
+ payload = { log: data };
55
+ }
56
+ // Handle ping/pong
57
+ if (payload.type === 'ping') {
58
+ // Respond to ping with pong
59
+ if (ws && ws.readyState === ws.OPEN) {
60
+ try {
61
+ ws.send(JSON.stringify({ type: 'pong' }));
62
+ }
63
+ catch { }
64
+ }
65
+ return;
66
+ }
67
+ if (payload.type === 'pong') {
68
+ // Pong received, clear pong timeout
69
+ if (pongTimeout)
70
+ clearTimeout(pongTimeout);
71
+ pongTimeout = null;
72
+ return;
73
+ }
74
+ if (payload.type === 'log') {
75
+ const logLine = payload.log || "";
76
+ if (typeof logLine === 'string') {
77
+ if (logLine.startsWith('stdout:')) {
78
+ options.onStdout?.(logLine.slice(7));
79
+ options.onLog?.(logLine.slice(7));
80
+ }
81
+ else if (logLine.startsWith('stderr:')) {
82
+ options.onStderr?.(logLine.slice(7));
83
+ options.onLog?.(logLine.slice(7));
84
+ }
85
+ else {
86
+ options.onLog?.(logLine);
87
+ }
88
+ }
89
+ }
90
+ }
91
+ catch (err) {
92
+ console.error('WebSocket log stream error:', err);
93
+ }
94
+ };
95
+ ws.onerror = (err) => {
96
+ closed = true;
97
+ if (ws && typeof ws.close === 'function')
98
+ ws.close();
99
+ };
100
+ ws.onclose = () => {
101
+ closed = true;
102
+ ws = null;
103
+ if (pingInterval)
104
+ clearInterval(pingInterval);
105
+ if (pongTimeout)
106
+ clearTimeout(pongTimeout);
107
+ };
108
+ // Start ping interval
109
+ pingInterval = setInterval(sendPing, PING_INTERVAL_MS);
110
+ }
111
+ return {
112
+ close: () => {
113
+ closed = true;
114
+ if (ws && typeof ws.close === 'function')
115
+ ws.close();
116
+ ws = null;
117
+ if (pingInterval)
118
+ clearInterval(pingInterval);
119
+ if (pongTimeout)
120
+ clearTimeout(pongTimeout);
121
+ },
122
+ };
123
+ }
124
+ sseStreamLogs(identifier, options) {
12
125
  const controller = new AbortController();
13
126
  (async () => {
14
127
  try {
15
- const headers = this.sandbox.forceUrl ? this.sandbox.headers : settings_js_1.settings.headers;
16
128
  const stream = await fetch(`${this.url}/process/${identifier}/logs/stream`, {
17
129
  method: 'GET',
18
130
  signal: controller.signal,
19
- headers,
131
+ headers: settings_js_1.settings.headers,
20
132
  });
21
133
  if (stream.status !== 200) {
22
134
  throw new Error(`Failed to stream logs: ${await stream.text()}`);
@@ -63,7 +175,6 @@ class SandboxProcess extends action_js_1.SandboxAction {
63
175
  const { response, data, error } = await (0, index_js_1.postProcess)({
64
176
  body: process,
65
177
  baseUrl: this.url,
66
- client: this.client,
67
178
  });
68
179
  this.handleResponseError(response, data, error);
69
180
  return data;
@@ -91,7 +202,6 @@ class SandboxProcess extends action_js_1.SandboxAction {
91
202
  const { response, data, error } = await (0, index_js_1.getProcessByIdentifier)({
92
203
  path: { identifier },
93
204
  baseUrl: this.url,
94
- client: this.client,
95
205
  });
96
206
  this.handleResponseError(response, data, error);
97
207
  return data;
@@ -99,7 +209,6 @@ class SandboxProcess extends action_js_1.SandboxAction {
99
209
  async list() {
100
210
  const { response, data, error } = await (0, index_js_1.getProcess)({
101
211
  baseUrl: this.url,
102
- client: this.client,
103
212
  });
104
213
  this.handleResponseError(response, data, error);
105
214
  return data;
@@ -108,7 +217,6 @@ class SandboxProcess extends action_js_1.SandboxAction {
108
217
  const { response, data, error } = await (0, index_js_1.deleteProcessByIdentifier)({
109
218
  path: { identifier },
110
219
  baseUrl: this.url,
111
- client: this.client,
112
220
  });
113
221
  this.handleResponseError(response, data, error);
114
222
  return data;
@@ -117,7 +225,6 @@ class SandboxProcess extends action_js_1.SandboxAction {
117
225
  const { response, data, error } = await (0, index_js_1.deleteProcessByIdentifierKill)({
118
226
  path: { identifier },
119
227
  baseUrl: this.url,
120
- client: this.client,
121
228
  });
122
229
  this.handleResponseError(response, data, error);
123
230
  return data;
@@ -126,7 +233,6 @@ class SandboxProcess extends action_js_1.SandboxAction {
126
233
  const { response, data, error } = await (0, index_js_1.getProcessByIdentifierLogs)({
127
234
  path: { identifier },
128
235
  baseUrl: this.url,
129
- client: this.client,
130
236
  });
131
237
  this.handleResponseError(response, data, error);
132
238
  if (data && type in data) {
@@ -3,16 +3,13 @@ import { SandboxFileSystem } from "./filesystem.js";
3
3
  import { SandboxNetwork } from "./network.js";
4
4
  import { SandboxPreviews } from "./preview.js";
5
5
  import { SandboxProcess } from "./process.js";
6
- import { SandboxSessions } from "./session.js";
7
- import { SandboxConfiguration, SessionWithToken } from "./types.js";
8
6
  export declare class SandboxInstance {
9
7
  private sandbox;
10
8
  fs: SandboxFileSystem;
11
9
  network: SandboxNetwork;
12
10
  process: SandboxProcess;
13
11
  previews: SandboxPreviews;
14
- sessions: SandboxSessions;
15
- constructor(sandbox: SandboxConfiguration);
12
+ constructor(sandbox: SandboxModel);
16
13
  get metadata(): import("../client/types.gen.js").Metadata | undefined;
17
14
  get status(): string | undefined;
18
15
  get events(): import("../client/types.gen.js").CoreEvents | undefined;
@@ -25,5 +22,4 @@ export declare class SandboxInstance {
25
22
  static get(sandboxName: string): Promise<SandboxInstance>;
26
23
  static list(): Promise<SandboxInstance[]>;
27
24
  static delete(sandboxName: string): Promise<SandboxModel>;
28
- static fromSession(session: SessionWithToken): Promise<SandboxInstance>;
29
25
  }
@@ -7,21 +7,18 @@ const filesystem_js_1 = require("./filesystem.js");
7
7
  const network_js_1 = require("./network.js");
8
8
  const preview_js_1 = require("./preview.js");
9
9
  const process_js_1 = require("./process.js");
10
- const session_js_1 = require("./session.js");
11
10
  class SandboxInstance {
12
11
  sandbox;
13
12
  fs;
14
13
  network;
15
14
  process;
16
15
  previews;
17
- sessions;
18
16
  constructor(sandbox) {
19
17
  this.sandbox = sandbox;
20
18
  this.fs = new filesystem_js_1.SandboxFileSystem(sandbox);
21
19
  this.network = new network_js_1.SandboxNetwork(sandbox);
22
20
  this.process = new process_js_1.SandboxProcess(sandbox);
23
21
  this.previews = new preview_js_1.SandboxPreviews(sandbox);
24
- this.sessions = new session_js_1.SandboxSessions(sandbox);
25
22
  }
26
23
  get metadata() {
27
24
  return this.sandbox.metadata;
@@ -94,8 +91,5 @@ class SandboxInstance {
94
91
  });
95
92
  return data;
96
93
  }
97
- static async fromSession(session) {
98
- return new SandboxInstance({ forceUrl: session.url, params: { bl_preview_token: session.token }, headers: { "X-Blaxel-Preview-Token": session.token } });
99
- }
100
94
  }
101
95
  exports.SandboxInstance = SandboxInstance;
@@ -55,5 +55,4 @@ export declare const telemetryRegistry: TelemetryRegistry;
55
55
  * Create a span with the registered provider
56
56
  */
57
57
  export declare function startSpan(name: string, options?: BlaxelSpanOptions): BlaxelSpan;
58
- export declare function withSpan<T>(name: string, fn: () => T, options?: BlaxelSpanOptions): T;
59
58
  export {};
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.telemetryRegistry = void 0;
5
5
  exports.startSpan = startSpan;
6
- exports.withSpan = withSpan;
7
6
  /**
8
7
  * No-operation implementation of Span
9
8
  */
@@ -58,16 +57,3 @@ exports.telemetryRegistry = TelemetryRegistry.getInstance();
58
57
  function startSpan(name, options) {
59
58
  return exports.telemetryRegistry.getProvider().startSpan(name, options);
60
59
  }
61
- function withSpan(name, fn, options) {
62
- const span = startSpan(name, options);
63
- try {
64
- const result = fn();
65
- span.end();
66
- return result;
67
- }
68
- catch (error) {
69
- span.recordException(error);
70
- span.end();
71
- throw error;
72
- }
73
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/core",
3
- "version": "0.2.0-preview5",
3
+ "version": "0.2.1-dev.46",
4
4
  "description": "Blaxel Core SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",
@@ -62,13 +62,11 @@
62
62
  "uuid": "^11.1.0",
63
63
  "ws": "^8.18.2",
64
64
  "yaml": "^2.7.1",
65
- "yargs": "^17.7.2",
66
65
  "zod": "^3.24.3"
67
66
  },
68
67
  "devDependencies": {
69
68
  "@eslint/js": "^9.26.0",
70
69
  "@types/ws": "^8.18.1",
71
- "@types/yargs": "^17.0.33",
72
70
  "typescript": "^5.0.0",
73
71
  "typescript-eslint": "^8.31.1"
74
72
  },
@@ -1 +0,0 @@
1
- export * from "./jobs.js";
@@ -1,17 +0,0 @@
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
- __exportStar(require("./jobs.js"), exports);
@@ -1,10 +0,0 @@
1
- declare class BlJob {
2
- getArguments(): Promise<{
3
- [key: number]: any;
4
- }>;
5
- get indexKey(): string;
6
- get index(): number;
7
- start(func: (args: any) => Promise<void>): Promise<void>;
8
- }
9
- export declare const blJob: BlJob;
10
- export {};
package/dist/jobs/jobs.js DELETED
@@ -1,42 +0,0 @@
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();
@@ -1,8 +0,0 @@
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
- }
@@ -1,16 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- export * from "./http.js";
2
- export * from "./websocket.js";
3
- import { BlaxelWebsocketMcpServerTransport } from "./websocket.js";
4
- export declare const BlaxelMcpServerTransport: typeof BlaxelWebsocketMcpServerTransport;
@@ -1,21 +0,0 @@
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;
@@ -1,24 +0,0 @@
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 {};