@blaxel/core 0.2.70 → 0.2.71-dev.105
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/agents/index.js +2 -19
- package/dist/cjs/common/autoload.js +64 -0
- package/dist/cjs/common/h2fetch.js +207 -0
- package/dist/cjs/common/h2pool.js +137 -0
- package/dist/cjs/common/h2warm.js +54 -0
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/jobs/jobs.js +10 -28
- package/dist/cjs/mcp/server.js +4 -65
- package/dist/cjs/sandbox/action.js +33 -0
- package/dist/cjs/sandbox/drive/drive.js +3 -3
- package/dist/cjs/sandbox/filesystem/filesystem.js +1 -2
- package/dist/cjs/sandbox/interpreter.js +12 -2
- package/dist/cjs/sandbox/process/process.js +2 -2
- package/dist/cjs/sandbox/sandbox.js +84 -10
- package/dist/cjs/tools/index.js +3 -1
- package/dist/cjs/tools/mcpTool.js +15 -43
- package/dist/cjs/types/agents/index.d.ts +1 -2
- package/dist/cjs/types/common/autoload.d.ts +5 -0
- package/dist/cjs/types/common/h2fetch.d.ts +22 -0
- package/dist/cjs/types/common/h2pool.d.ts +38 -0
- package/dist/cjs/types/common/h2warm.d.ts +2 -0
- package/dist/cjs/types/jobs/jobs.d.ts +1 -2
- package/dist/cjs/types/sandbox/action.d.ts +8 -1
- package/dist/cjs/types/sandbox/client/types.gen.d.ts +11 -0
- package/dist/cjs/types/sandbox/interpreter.d.ts +1 -0
- package/dist/cjs/types/sandbox/sandbox.d.ts +6 -0
- package/dist/cjs/types/sandbox/types.d.ts +2 -0
- package/dist/cjs/types/tools/index.d.ts +1 -0
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/agents/index.js +2 -19
- package/dist/cjs-browser/common/autoload.js +64 -0
- package/dist/cjs-browser/common/h2fetch.js +4 -0
- package/dist/cjs-browser/common/h2pool.js +4 -0
- package/dist/cjs-browser/common/h2warm.js +2 -0
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/jobs/jobs.js +10 -28
- package/dist/cjs-browser/mcp/server.js +4 -65
- package/dist/cjs-browser/sandbox/action.js +33 -0
- package/dist/cjs-browser/sandbox/drive/drive.js +3 -3
- package/dist/cjs-browser/sandbox/filesystem/filesystem.js +1 -2
- package/dist/cjs-browser/sandbox/interpreter.js +12 -2
- package/dist/cjs-browser/sandbox/process/process.js +2 -2
- package/dist/cjs-browser/sandbox/sandbox.js +84 -10
- package/dist/cjs-browser/tools/index.js +3 -1
- package/dist/cjs-browser/tools/mcpTool.js +15 -43
- package/dist/cjs-browser/types/agents/index.d.ts +1 -2
- package/dist/cjs-browser/types/common/autoload.d.ts +5 -0
- package/dist/cjs-browser/types/common/h2fetch.d.ts +22 -0
- package/dist/cjs-browser/types/common/h2pool.d.ts +38 -0
- package/dist/cjs-browser/types/common/h2warm.d.ts +2 -0
- package/dist/cjs-browser/types/jobs/jobs.d.ts +1 -2
- package/dist/cjs-browser/types/sandbox/action.d.ts +8 -1
- package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +11 -0
- package/dist/cjs-browser/types/sandbox/interpreter.d.ts +1 -0
- package/dist/cjs-browser/types/sandbox/sandbox.d.ts +6 -0
- package/dist/cjs-browser/types/sandbox/types.d.ts +2 -0
- package/dist/cjs-browser/types/tools/index.d.ts +1 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/agents/index.js +1 -19
- package/dist/esm/common/autoload.js +30 -0
- package/dist/esm/common/h2fetch.js +202 -0
- package/dist/esm/common/h2pool.js +101 -0
- package/dist/esm/common/h2warm.js +48 -0
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/jobs/jobs.js +9 -28
- package/dist/esm/mcp/server.js +4 -65
- package/dist/esm/sandbox/action.js +33 -0
- package/dist/esm/sandbox/drive/drive.js +3 -3
- package/dist/esm/sandbox/filesystem/filesystem.js +1 -2
- package/dist/esm/sandbox/interpreter.js +12 -2
- package/dist/esm/sandbox/process/process.js +2 -2
- package/dist/esm/sandbox/sandbox.js +51 -10
- package/dist/esm/tools/index.js +1 -0
- package/dist/esm/tools/mcpTool.js +15 -43
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/agents/index.js +1 -19
- package/dist/esm-browser/common/autoload.js +30 -0
- package/dist/esm-browser/common/h2fetch.js +4 -0
- package/dist/esm-browser/common/h2pool.js +4 -0
- package/dist/esm-browser/common/h2warm.js +2 -0
- package/dist/esm-browser/common/settings.js +2 -2
- package/dist/esm-browser/jobs/jobs.js +9 -28
- package/dist/esm-browser/mcp/server.js +4 -65
- package/dist/esm-browser/sandbox/action.js +33 -0
- package/dist/esm-browser/sandbox/drive/drive.js +3 -3
- package/dist/esm-browser/sandbox/filesystem/filesystem.js +1 -2
- package/dist/esm-browser/sandbox/interpreter.js +12 -2
- package/dist/esm-browser/sandbox/process/process.js +2 -2
- package/dist/esm-browser/sandbox/sandbox.js +51 -10
- package/dist/esm-browser/tools/index.js +1 -0
- package/dist/esm-browser/tools/mcpTool.js +15 -43
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getToolMetadata = exports.blTool = exports.blTools = exports.BLTools = exports.getTool = void 0;
|
|
3
|
+
exports.getToolMetadata = exports.blTool = exports.blTools = exports.BLTools = exports.getTool = exports.McpTool = void 0;
|
|
4
4
|
const index_js_1 = require("../cache/index.js");
|
|
5
5
|
const client_js_1 = require("../client/client.js");
|
|
6
6
|
const internal_js_1 = require("../common/internal.js");
|
|
7
7
|
const mcpTool_js_1 = require("./mcpTool.js");
|
|
8
|
+
var mcpTool_js_2 = require("./mcpTool.js");
|
|
9
|
+
Object.defineProperty(exports, "McpTool", { enumerable: true, get: function () { return mcpTool_js_2.McpTool; } });
|
|
8
10
|
const getTool = async (name, options) => {
|
|
9
11
|
return await (0, mcpTool_js_1.getMcpTool)(name, options);
|
|
10
12
|
};
|
|
@@ -9,7 +9,6 @@ const logger_js_1 = require("../common/logger.js");
|
|
|
9
9
|
const settings_js_1 = require("../common/settings.js");
|
|
10
10
|
const index_js_2 = require("../index.js");
|
|
11
11
|
const client_js_1 = require("../mcp/client.js");
|
|
12
|
-
const telemetry_js_1 = require("../telemetry/telemetry.js");
|
|
13
12
|
const zodSchema_js_1 = require("./zodSchema.js");
|
|
14
13
|
const McpToolCache = new Map();
|
|
15
14
|
class McpTool {
|
|
@@ -141,47 +140,24 @@ class McpTool {
|
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
async listTools() {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Listing tools`);
|
|
144
|
+
await this.start();
|
|
145
|
+
const { tools } = (await this.client.listTools());
|
|
146
|
+
await this.close();
|
|
147
|
+
const result = tools.map((tool) => {
|
|
148
|
+
return {
|
|
149
|
+
name: tool.name,
|
|
150
|
+
description: tool.description,
|
|
151
|
+
inputSchema: (0, zodSchema_js_1.schemaToZodSchema)(tool.inputSchema),
|
|
152
|
+
originalSchema: tool.inputSchema,
|
|
153
|
+
call: (input) => {
|
|
154
|
+
return this.call(tool.name, input);
|
|
155
|
+
},
|
|
156
|
+
};
|
|
148
157
|
});
|
|
149
|
-
|
|
150
|
-
logger_js_1.logger.debug(`MCP:${this.name}:Listing tools`);
|
|
151
|
-
await this.start();
|
|
152
|
-
const { tools } = (await this.client.listTools());
|
|
153
|
-
await this.close();
|
|
154
|
-
const result = tools.map((tool) => {
|
|
155
|
-
return {
|
|
156
|
-
name: tool.name,
|
|
157
|
-
description: tool.description,
|
|
158
|
-
inputSchema: (0, zodSchema_js_1.schemaToZodSchema)(tool.inputSchema),
|
|
159
|
-
originalSchema: tool.inputSchema,
|
|
160
|
-
call: (input) => {
|
|
161
|
-
return this.call(tool.name, input);
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
});
|
|
165
|
-
span.setAttribute("tool.list.result", JSON.stringify(result));
|
|
166
|
-
return result;
|
|
167
|
-
}
|
|
168
|
-
catch (err) {
|
|
169
|
-
span.setStatus("error");
|
|
170
|
-
span.recordException(err);
|
|
171
|
-
throw err;
|
|
172
|
-
}
|
|
173
|
-
finally {
|
|
174
|
-
span.end();
|
|
175
|
-
}
|
|
158
|
+
return result;
|
|
176
159
|
}
|
|
177
160
|
async call(toolName, args) {
|
|
178
|
-
const span = (0, telemetry_js_1.startSpan)(this.name + "." + toolName, {
|
|
179
|
-
attributes: {
|
|
180
|
-
"span.type": "tool.call",
|
|
181
|
-
"tool.name": toolName,
|
|
182
|
-
"tool.args": JSON.stringify(args),
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
161
|
try {
|
|
186
162
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool calling`, toolName, JSON.stringify(args));
|
|
187
163
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool calling:start`);
|
|
@@ -195,7 +171,6 @@ class McpTool {
|
|
|
195
171
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool calling:result`);
|
|
196
172
|
await this.close();
|
|
197
173
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool result`, toolName, JSON.stringify(args));
|
|
198
|
-
span.setAttribute("tool.call.result", JSON.stringify(result));
|
|
199
174
|
return result;
|
|
200
175
|
}
|
|
201
176
|
catch (err) {
|
|
@@ -210,9 +185,6 @@ class McpTool {
|
|
|
210
185
|
}
|
|
211
186
|
throw err;
|
|
212
187
|
}
|
|
213
|
-
finally {
|
|
214
|
-
span.end();
|
|
215
|
-
}
|
|
216
188
|
}
|
|
217
189
|
async getTransport(forcedUrl) {
|
|
218
190
|
if (!this.transportName) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Agent } from "../client/index.js";
|
|
2
|
-
declare class BlAgent {
|
|
2
|
+
export declare class BlAgent {
|
|
3
3
|
agentName: string;
|
|
4
4
|
constructor(agentName: string);
|
|
5
5
|
get fallbackUrl(): import("url").URL | null;
|
|
@@ -12,4 +12,3 @@ declare class BlAgent {
|
|
|
12
12
|
}
|
|
13
13
|
export declare const blAgent: (agentName: string) => BlAgent;
|
|
14
14
|
export declare const getAgentMetadata: (agent: string) => Promise<Agent | null>;
|
|
15
|
-
export {};
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { Config } from "./settings.js";
|
|
2
2
|
export declare function initialize(config: Config): void;
|
|
3
3
|
export declare function authenticate(): Promise<void>;
|
|
4
|
+
/**
|
|
5
|
+
* Close all pooled H2 connections. Call this for explicit cleanup
|
|
6
|
+
* (e.g. in test teardown or before process exit).
|
|
7
|
+
*/
|
|
8
|
+
export declare function closeConnections(): Promise<void>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import http2 from "http2";
|
|
2
|
+
import type { h2Pool as H2PoolType } from "./h2pool.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a fetch()-compatible function that sends requests over an existing
|
|
5
|
+
* HTTP/2 session. Falls back to global fetch() if the session is closed,
|
|
6
|
+
* destroyed, or if the H2 request times out.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createH2Fetch(session: http2.ClientHttp2Session): (input: Request) => Promise<Response>;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a fetch()-compatible function backed by the H2 session pool.
|
|
11
|
+
*
|
|
12
|
+
* Non-blocking: checks the pool cache synchronously. If a warm session is
|
|
13
|
+
* available it's used immediately; otherwise the request goes through
|
|
14
|
+
* regular fetch with zero delay (the pool keeps warming in the background
|
|
15
|
+
* so subsequent calls get H2).
|
|
16
|
+
*/
|
|
17
|
+
export declare function createPoolBackedH2Fetch(pool: typeof H2PoolType, domain: string): (input: Request) => Promise<Response>;
|
|
18
|
+
/**
|
|
19
|
+
* Low-level H2 request that takes raw URL + init, skipping Request construction.
|
|
20
|
+
* Used by SandboxAction.h2Fetch() for direct calls from subsystems.
|
|
21
|
+
*/
|
|
22
|
+
export declare function h2RequestDirect(session: http2.ClientHttp2Session, url: string, init?: RequestInit): Promise<Response>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type http2 from "http2";
|
|
2
|
+
/**
|
|
3
|
+
* Singleton H2 session pool keyed by edge domain.
|
|
4
|
+
*
|
|
5
|
+
* - `warm(domain)` starts a background connection (fire-and-forget).
|
|
6
|
+
* - `get(domain)` returns a live session immediately if cached, or awaits
|
|
7
|
+
* an in-flight warming, or establishes a fresh one.
|
|
8
|
+
* - Closed / destroyed sessions are automatically evicted.
|
|
9
|
+
*/
|
|
10
|
+
declare class H2Pool {
|
|
11
|
+
private sessions;
|
|
12
|
+
private inflight;
|
|
13
|
+
private _establish;
|
|
14
|
+
/**
|
|
15
|
+
* Lazily resolve the establish function so the http2 / tls / dns modules
|
|
16
|
+
* are only imported in Node.js environments.
|
|
17
|
+
*/
|
|
18
|
+
private establish;
|
|
19
|
+
/**
|
|
20
|
+
* Fire-and-forget background warming. Safe to call multiple times for
|
|
21
|
+
* the same domain — only one connection attempt per domain at a time.
|
|
22
|
+
*/
|
|
23
|
+
warm(domain: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Synchronous cache check. Returns a live cached session or `null`.
|
|
26
|
+
* Never blocks, never establishes — use for non-blocking fast paths.
|
|
27
|
+
*/
|
|
28
|
+
tryGet(domain: string): http2.ClientHttp2Session | null;
|
|
29
|
+
/**
|
|
30
|
+
* Get a live H2 session for `domain`. Returns immediately from cache,
|
|
31
|
+
* joins an in-flight warming, or starts a new one.
|
|
32
|
+
*/
|
|
33
|
+
get(domain: string): Promise<http2.ClientHttp2Session | null>;
|
|
34
|
+
/** Close all sessions (for cleanup). */
|
|
35
|
+
closeAll(): void;
|
|
36
|
+
}
|
|
37
|
+
export declare const h2Pool: H2Pool;
|
|
38
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CreateJobExecutionRequest, JobExecution } from "../client/index.js";
|
|
2
|
-
declare class BlJob {
|
|
2
|
+
export declare class BlJob {
|
|
3
3
|
jobName: string;
|
|
4
4
|
constructor(jobName: string);
|
|
5
5
|
run(tasks: Record<string, unknown>[], options?: {
|
|
@@ -39,4 +39,3 @@ declare class BlJob {
|
|
|
39
39
|
}): Promise<JobExecution>;
|
|
40
40
|
}
|
|
41
41
|
export declare const blJob: (jobName: string) => BlJob;
|
|
42
|
-
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Client } from "@hey-api/client-fetch";
|
|
1
2
|
import { SandboxConfiguration } from "./types.js";
|
|
2
3
|
export declare class ResponseError extends Error {
|
|
3
4
|
response: Response;
|
|
@@ -7,12 +8,18 @@ export declare class ResponseError extends Error {
|
|
|
7
8
|
}
|
|
8
9
|
export declare class SandboxAction {
|
|
9
10
|
protected sandbox: SandboxConfiguration;
|
|
11
|
+
private _h2Client;
|
|
10
12
|
constructor(sandbox: SandboxConfiguration);
|
|
11
13
|
get name(): string;
|
|
12
14
|
get fallbackUrl(): string | null;
|
|
13
15
|
get externalUrl(): string;
|
|
14
16
|
get internalUrl(): string;
|
|
15
|
-
get client():
|
|
17
|
+
get client(): Client;
|
|
18
|
+
/**
|
|
19
|
+
* Routes through the H2 session when available, falling back to
|
|
20
|
+
* globalThis.fetch. Uses a direct H2 path that avoids Request allocation.
|
|
21
|
+
*/
|
|
22
|
+
protected h2Fetch(input: string | URL, init?: RequestInit): Promise<Response>;
|
|
16
23
|
get forcedUrl(): string | import("url").URL | null;
|
|
17
24
|
get url(): string;
|
|
18
25
|
handleResponseError(response: Response, data: unknown, error: unknown): void;
|
|
@@ -137,9 +137,16 @@ export type ProcessRequest = {
|
|
|
137
137
|
env?: {
|
|
138
138
|
[key: string]: string;
|
|
139
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* Disable scale-to-zero while process runs. Default timeout is 600s (10 minutes). Set timeout to 0 for infinite.
|
|
142
|
+
*/
|
|
143
|
+
keepAlive?: boolean;
|
|
140
144
|
maxRestarts?: number;
|
|
141
145
|
name?: string;
|
|
142
146
|
restartOnFailure?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Timeout in seconds. When keepAlive is true, defaults to 600s (10 minutes). Set to 0 for infinite (no auto-kill).
|
|
149
|
+
*/
|
|
143
150
|
timeout?: number;
|
|
144
151
|
waitForCompletion?: boolean;
|
|
145
152
|
waitForPorts?: Array<number>;
|
|
@@ -149,6 +156,10 @@ export type ProcessResponse = {
|
|
|
149
156
|
command: string;
|
|
150
157
|
completedAt: string;
|
|
151
158
|
exitCode: number;
|
|
159
|
+
/**
|
|
160
|
+
* Whether scale-to-zero is disabled for this process
|
|
161
|
+
*/
|
|
162
|
+
keepAlive?: boolean;
|
|
152
163
|
logs: string;
|
|
153
164
|
maxRestarts?: number;
|
|
154
165
|
name: string;
|
|
@@ -12,6 +12,7 @@ export declare class CodeInterpreter extends SandboxInstance {
|
|
|
12
12
|
safe?: boolean;
|
|
13
13
|
}): Promise<CodeInterpreter>;
|
|
14
14
|
get _jupyterUrl(): string;
|
|
15
|
+
private _fetch;
|
|
15
16
|
static OutputMessage: {
|
|
16
17
|
new (text: string, timestamp: number | null, isStderr: boolean): {
|
|
17
18
|
text: string;
|
|
@@ -18,12 +18,18 @@ export declare class SandboxInstance {
|
|
|
18
18
|
codegen: SandboxCodegen;
|
|
19
19
|
system: SandboxSystem;
|
|
20
20
|
drives: SandboxDrive;
|
|
21
|
+
h2Session: any;
|
|
21
22
|
constructor(sandbox: SandboxConfiguration);
|
|
22
23
|
get metadata(): import("../client/types.gen.js").Metadata;
|
|
23
24
|
get status(): import("../client/types.gen.js").Status | undefined;
|
|
24
25
|
get events(): import("../client/types.gen.js").CoreEvents | undefined;
|
|
25
26
|
get spec(): import("../client/types.gen.js").SandboxSpec;
|
|
26
27
|
get lastUsedAt(): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Warm and attach an H2 session based on the sandbox's region.
|
|
30
|
+
* Shared by create(), get(), list(), and update helpers.
|
|
31
|
+
*/
|
|
32
|
+
private static attachH2Session;
|
|
27
33
|
get expiresIn(): number | undefined;
|
|
28
34
|
wait({ maxWait, interval }?: {
|
|
29
35
|
maxWait?: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type http2 from "http2";
|
|
1
2
|
import { Port, Sandbox, SandboxLifecycle, VolumeAttachment, SandboxNetwork } from "../client/types.gen";
|
|
2
3
|
import { PostProcessResponse, ProcessRequest } from "./client";
|
|
3
4
|
export interface SessionCreateOptions {
|
|
@@ -24,6 +25,7 @@ export type SandboxConfiguration = {
|
|
|
24
25
|
forceUrl?: string;
|
|
25
26
|
headers?: Record<string, string>;
|
|
26
27
|
params?: Record<string, string>;
|
|
28
|
+
h2Session?: http2.ClientHttp2Session | null;
|
|
27
29
|
} & Sandbox;
|
|
28
30
|
export type SandboxUpdateMetadata = {
|
|
29
31
|
labels?: Record<string, string>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Function } from "../client/client.js";
|
|
2
2
|
import { ToolOptions } from "./mcpTool.js";
|
|
3
3
|
import { Tool } from "./types.js";
|
|
4
|
+
export { McpTool } from "./mcpTool.js";
|
|
4
5
|
export type { ToolOptions };
|
|
5
6
|
export declare const getTool: (name: string, options?: number | ToolOptions) => Promise<Tool[]>;
|
|
6
7
|
export declare class BLTools {
|