@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,33 @@
|
|
|
1
|
+
import { Sandbox as SandboxModel } from "../client/index.js";
|
|
2
|
+
import { SandboxFileSystem } from "./filesystem/index.js";
|
|
3
|
+
import { SandboxNetwork } from "./network/index.js";
|
|
4
|
+
import { SandboxPreviews } from "./preview.js";
|
|
5
|
+
import { SandboxProcess } from "./process/index.js";
|
|
6
|
+
import { SandboxSessions } from "./session.js";
|
|
7
|
+
import { SandboxConfiguration, SandboxCreateConfiguration, SandboxUpdateMetadata, SessionWithToken } from "./types.js";
|
|
8
|
+
export declare class SandboxInstance {
|
|
9
|
+
private sandbox;
|
|
10
|
+
fs: SandboxFileSystem;
|
|
11
|
+
network: SandboxNetwork;
|
|
12
|
+
process: SandboxProcess;
|
|
13
|
+
previews: SandboxPreviews;
|
|
14
|
+
sessions: SandboxSessions;
|
|
15
|
+
constructor(sandbox: SandboxConfiguration);
|
|
16
|
+
get metadata(): import("../client/types.gen.js").Metadata | undefined;
|
|
17
|
+
get status(): string | undefined;
|
|
18
|
+
get events(): import("../client/types.gen.js").CoreEvents | undefined;
|
|
19
|
+
get spec(): import("../client/types.gen.js").SandboxSpec | undefined;
|
|
20
|
+
wait({ maxWait, interval }?: {
|
|
21
|
+
maxWait?: number;
|
|
22
|
+
interval?: number;
|
|
23
|
+
}): Promise<this>;
|
|
24
|
+
static create(sandbox?: SandboxModel | SandboxCreateConfiguration, { safe }?: {
|
|
25
|
+
safe?: boolean;
|
|
26
|
+
}): Promise<SandboxInstance>;
|
|
27
|
+
static get(sandboxName: string): Promise<SandboxInstance>;
|
|
28
|
+
static list(): Promise<SandboxInstance[]>;
|
|
29
|
+
static delete(sandboxName: string): Promise<SandboxModel>;
|
|
30
|
+
static updateMetadata(sandboxName: string, metadata: SandboxUpdateMetadata): Promise<SandboxInstance>;
|
|
31
|
+
static createIfNotExists(sandbox: SandboxModel | SandboxCreateConfiguration): Promise<SandboxInstance>;
|
|
32
|
+
static fromSession(session: SessionWithToken): Promise<SandboxInstance>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Sandbox } from "../client/index.js";
|
|
2
|
+
import { SessionCreateOptions, SessionWithToken } from "./types.js";
|
|
3
|
+
export declare class SandboxSessions {
|
|
4
|
+
private sandbox;
|
|
5
|
+
constructor(sandbox: Sandbox);
|
|
6
|
+
get sandboxName(): string;
|
|
7
|
+
create(options?: SessionCreateOptions): Promise<SessionWithToken>;
|
|
8
|
+
createIfExpired(options?: SessionCreateOptions, delta?: number): Promise<{
|
|
9
|
+
name: string;
|
|
10
|
+
url: string;
|
|
11
|
+
token: string;
|
|
12
|
+
expiresAt: string | Date;
|
|
13
|
+
}>;
|
|
14
|
+
list(): Promise<{
|
|
15
|
+
name: string;
|
|
16
|
+
url: string;
|
|
17
|
+
token: string;
|
|
18
|
+
expiresAt: string | Date;
|
|
19
|
+
}[]>;
|
|
20
|
+
get(name: string): Promise<{
|
|
21
|
+
url: string;
|
|
22
|
+
token: string;
|
|
23
|
+
expiresAt: string | Date;
|
|
24
|
+
}>;
|
|
25
|
+
delete(name: string): Promise<import("../client/types.gen.js").Preview>;
|
|
26
|
+
getToken(previewName: string): Promise<import("../client/types.gen.js").PreviewToken | null>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Port, Sandbox, SandboxLifecycle, VolumeAttachment } from "../client/types.gen";
|
|
2
|
+
import { PostProcessResponse, ProcessRequest } from "./client";
|
|
3
|
+
export interface SessionCreateOptions {
|
|
4
|
+
expiresAt?: Date;
|
|
5
|
+
responseHeaders?: Record<string, string>;
|
|
6
|
+
requestHeaders?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export interface SessionWithToken {
|
|
9
|
+
name: string;
|
|
10
|
+
url: string;
|
|
11
|
+
token: string;
|
|
12
|
+
expiresAt: Date;
|
|
13
|
+
}
|
|
14
|
+
export interface EnvVar {
|
|
15
|
+
name: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}
|
|
18
|
+
export interface VolumeBinding {
|
|
19
|
+
name: string;
|
|
20
|
+
mountPath: string;
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export type SandboxConfiguration = {
|
|
24
|
+
forceUrl?: string;
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
params?: Record<string, string>;
|
|
27
|
+
} & Sandbox;
|
|
28
|
+
export type SandboxUpdateMetadata = {
|
|
29
|
+
labels?: Record<string, string>;
|
|
30
|
+
displayName?: string;
|
|
31
|
+
};
|
|
32
|
+
export type SandboxCreateConfiguration = {
|
|
33
|
+
name?: string;
|
|
34
|
+
image?: string;
|
|
35
|
+
memory?: number;
|
|
36
|
+
ports?: (Port | Record<string, any>)[];
|
|
37
|
+
envs?: EnvVar[];
|
|
38
|
+
volumes?: (VolumeBinding | VolumeAttachment)[];
|
|
39
|
+
ttl?: string;
|
|
40
|
+
expires?: Date;
|
|
41
|
+
region?: string;
|
|
42
|
+
lifecycle?: SandboxLifecycle;
|
|
43
|
+
};
|
|
44
|
+
export declare function normalizePorts(ports?: (Port | Record<string, any>)[]): Port[] | undefined;
|
|
45
|
+
export declare function normalizeEnvs(envs?: EnvVar[]): EnvVar[] | undefined;
|
|
46
|
+
export declare function normalizeVolumes(volumes?: (VolumeBinding | VolumeAttachment)[]): VolumeAttachment[] | undefined;
|
|
47
|
+
export type ProcessRequestWithLog = ProcessRequest & {
|
|
48
|
+
onLog?: (log: string) => void;
|
|
49
|
+
};
|
|
50
|
+
export type ProcessResponseWithLog = PostProcessResponse & {
|
|
51
|
+
close: () => void;
|
|
52
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for creating a span
|
|
3
|
+
*/
|
|
4
|
+
export interface BlaxelSpanOptions {
|
|
5
|
+
/** Key-value attributes to attach to the span */
|
|
6
|
+
attributes?: Record<string, string | number | boolean>;
|
|
7
|
+
/** Parent span context, if any */
|
|
8
|
+
parentContext?: unknown;
|
|
9
|
+
/** Whether this is a root span */
|
|
10
|
+
isRoot?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Represents a telemetry span
|
|
14
|
+
*/
|
|
15
|
+
export interface BlaxelSpan {
|
|
16
|
+
/** Add an attribute to the span */
|
|
17
|
+
setAttribute(key: string, value: string | number | boolean): void;
|
|
18
|
+
/** Add multiple attributes to the span */
|
|
19
|
+
setAttributes(attributes: Record<string, string | number | boolean>): void;
|
|
20
|
+
/** Record an error on the span */
|
|
21
|
+
recordException(error: Error): void;
|
|
22
|
+
/** Set the status of the span */
|
|
23
|
+
setStatus(status: 'ok' | 'error', message?: string): void;
|
|
24
|
+
/** End the span */
|
|
25
|
+
end(): void;
|
|
26
|
+
/** Get the span context (for passing to child spans) */
|
|
27
|
+
getContext(): unknown;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Provider interface for telemetry functionality
|
|
31
|
+
*/
|
|
32
|
+
export interface BlaxelTelemetryProvider {
|
|
33
|
+
/** Create a new span */
|
|
34
|
+
startSpan(name: string, options?: BlaxelSpanOptions): BlaxelSpan;
|
|
35
|
+
/** Flush the telemetry provider */
|
|
36
|
+
flush(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Registry for managing the global telemetry provider
|
|
40
|
+
*/
|
|
41
|
+
declare class TelemetryRegistry {
|
|
42
|
+
private static instance;
|
|
43
|
+
private provider;
|
|
44
|
+
private constructor();
|
|
45
|
+
static getInstance(): TelemetryRegistry;
|
|
46
|
+
/**
|
|
47
|
+
* Register a telemetry provider implementation
|
|
48
|
+
*/
|
|
49
|
+
registerProvider(provider: BlaxelTelemetryProvider): void;
|
|
50
|
+
/**
|
|
51
|
+
* Get the current telemetry provider
|
|
52
|
+
*/
|
|
53
|
+
getProvider(): BlaxelTelemetryProvider;
|
|
54
|
+
}
|
|
55
|
+
export declare const telemetryRegistry: TelemetryRegistry;
|
|
56
|
+
/**
|
|
57
|
+
* Create a span with the registered provider
|
|
58
|
+
*/
|
|
59
|
+
export declare function startSpan(name: string, options?: BlaxelSpanOptions): BlaxelSpan;
|
|
60
|
+
export declare function withSpan<T>(name: string, fn: () => Promise<T>, options?: BlaxelSpanOptions): Promise<T>;
|
|
61
|
+
export declare function flush(): Promise<void>;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Function } from "../client/client.js";
|
|
2
|
+
import { ToolOptions } from "./mcpTool.js";
|
|
3
|
+
import { Tool } from "./types.js";
|
|
4
|
+
export type { ToolOptions };
|
|
5
|
+
export declare const getTool: (name: string, options?: number | ToolOptions) => Promise<Tool[]>;
|
|
6
|
+
export declare class BLTools {
|
|
7
|
+
toolNames: string[];
|
|
8
|
+
constructor(toolNames: string[]);
|
|
9
|
+
}
|
|
10
|
+
export declare const blTools: (names: string[]) => BLTools;
|
|
11
|
+
export declare const blTool: (name: string) => BLTools;
|
|
12
|
+
export declare const getToolMetadata: (tool: string) => Promise<Function | null>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BlaxelMcpClientTransport } from "../mcp/client.js";
|
|
2
|
+
import { Tool } from "./types.js";
|
|
3
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
4
|
+
export type ToolOptions = {
|
|
5
|
+
ms?: number;
|
|
6
|
+
meta?: Record<string, unknown> | undefined;
|
|
7
|
+
transport?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class McpTool {
|
|
10
|
+
private name;
|
|
11
|
+
private type;
|
|
12
|
+
private pluralType;
|
|
13
|
+
private client;
|
|
14
|
+
private transport?;
|
|
15
|
+
private timer?;
|
|
16
|
+
private ms;
|
|
17
|
+
private transportName?;
|
|
18
|
+
private meta;
|
|
19
|
+
private startPromise?;
|
|
20
|
+
constructor(name: string, options?: ToolOptions | number);
|
|
21
|
+
get fallbackUrl(): import("url").URL | null;
|
|
22
|
+
get externalUrl(): import("url").URL;
|
|
23
|
+
get internalUrl(): import("url").URL;
|
|
24
|
+
get forcedUrl(): import("url").URL | null;
|
|
25
|
+
get url(): import("url").URL;
|
|
26
|
+
start(): Promise<void>;
|
|
27
|
+
close(now?: boolean): Promise<void>;
|
|
28
|
+
stopCloseTimer(): void;
|
|
29
|
+
listTools(): Promise<Tool[]>;
|
|
30
|
+
call(toolName: string, args: Record<string, unknown> | undefined): Promise<unknown>;
|
|
31
|
+
getTransport(forcedUrl?: URL): Promise<BlaxelMcpClientTransport | StreamableHTTPClientTransport>;
|
|
32
|
+
}
|
|
33
|
+
export declare const getMcpTool: (name: string, options?: ToolOptions | number) => Promise<Tool[]>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Converts an array of `FunctionSchema` objects into a Zod schema for validation.
|
|
4
|
+
*
|
|
5
|
+
* @param {FunctionSchema} parameters - The parameters to convert.
|
|
6
|
+
* @returns {z.ZodObject<any>} A Zod object schema representing the parameters.
|
|
7
|
+
*/
|
|
8
|
+
export declare const schemaToZodSchema: (schema: FunctionSchema) => z.ZodObject<any>;
|
|
9
|
+
/**
|
|
10
|
+
* Function schema
|
|
11
|
+
*/
|
|
12
|
+
export type FunctionSchema = {
|
|
13
|
+
/**
|
|
14
|
+
* List of schemas that this schema extends
|
|
15
|
+
*/
|
|
16
|
+
allOf?: Array<unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* List of possible schemas, any of which this schema could be
|
|
19
|
+
*/
|
|
20
|
+
anyOf?: Array<unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* Description of the schema
|
|
23
|
+
*/
|
|
24
|
+
description?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Enum values
|
|
27
|
+
*/
|
|
28
|
+
enum?: Array<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Format of the schema
|
|
31
|
+
*/
|
|
32
|
+
format?: string;
|
|
33
|
+
items?: FunctionSchema;
|
|
34
|
+
/**
|
|
35
|
+
* Maximum length for string types
|
|
36
|
+
*/
|
|
37
|
+
maxLength?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Maximum value for number types
|
|
40
|
+
*/
|
|
41
|
+
maximum?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Minimum length for string types
|
|
44
|
+
*/
|
|
45
|
+
minLength?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Minimum value for number types
|
|
48
|
+
*/
|
|
49
|
+
minimum?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Schema that this schema must not be
|
|
52
|
+
*/
|
|
53
|
+
not?: {
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* List of schemas, one of which this schema must be
|
|
58
|
+
*/
|
|
59
|
+
oneOf?: Array<unknown>;
|
|
60
|
+
/**
|
|
61
|
+
* Pattern for string types
|
|
62
|
+
*/
|
|
63
|
+
pattern?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Properties of the schema
|
|
66
|
+
*/
|
|
67
|
+
properties?: {
|
|
68
|
+
[key: string]: FunctionSchema;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Required properties of the schema
|
|
72
|
+
*/
|
|
73
|
+
required?: Array<string>;
|
|
74
|
+
/**
|
|
75
|
+
* Title of the schema
|
|
76
|
+
*/
|
|
77
|
+
title?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Type of the schema
|
|
80
|
+
*/
|
|
81
|
+
type?: string;
|
|
82
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Volume } from "../client/index.js";
|
|
2
|
+
export interface VolumeCreateConfiguration {
|
|
3
|
+
name?: string;
|
|
4
|
+
displayName?: string;
|
|
5
|
+
size?: number;
|
|
6
|
+
region?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class VolumeInstance {
|
|
9
|
+
private volume;
|
|
10
|
+
constructor(volume: Volume);
|
|
11
|
+
get metadata(): import("../client/types.gen.js").Metadata | undefined;
|
|
12
|
+
get spec(): import("../client/types.gen.js").VolumeSpec | undefined;
|
|
13
|
+
get status(): string | undefined;
|
|
14
|
+
get name(): string | undefined;
|
|
15
|
+
get displayName(): string | undefined;
|
|
16
|
+
get size(): number | undefined;
|
|
17
|
+
get region(): string | undefined;
|
|
18
|
+
static create(config: VolumeCreateConfiguration | Volume): Promise<VolumeInstance>;
|
|
19
|
+
static get(volumeName: string): Promise<VolumeInstance>;
|
|
20
|
+
static list(): Promise<VolumeInstance[]>;
|
|
21
|
+
static delete(volumeName: string): Promise<Volume>;
|
|
22
|
+
static createIfNotExists(config: VolumeCreateConfiguration | Volume): Promise<VolumeInstance>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolumeInstance = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const index_js_1 = require("../client/index.js");
|
|
6
|
+
class VolumeInstance {
|
|
7
|
+
volume;
|
|
8
|
+
constructor(volume) {
|
|
9
|
+
this.volume = volume;
|
|
10
|
+
}
|
|
11
|
+
get metadata() {
|
|
12
|
+
return this.volume.metadata;
|
|
13
|
+
}
|
|
14
|
+
get spec() {
|
|
15
|
+
return this.volume.spec;
|
|
16
|
+
}
|
|
17
|
+
get status() {
|
|
18
|
+
return this.volume.status;
|
|
19
|
+
}
|
|
20
|
+
get name() {
|
|
21
|
+
return this.volume.metadata?.name;
|
|
22
|
+
}
|
|
23
|
+
get displayName() {
|
|
24
|
+
return this.volume.metadata?.displayName;
|
|
25
|
+
}
|
|
26
|
+
get size() {
|
|
27
|
+
return this.volume.spec?.size;
|
|
28
|
+
}
|
|
29
|
+
get region() {
|
|
30
|
+
return this.volume.spec?.region;
|
|
31
|
+
}
|
|
32
|
+
static async create(config) {
|
|
33
|
+
const defaultName = `volume-${(0, uuid_1.v4)().replace(/-/g, '').substring(0, 8)}`;
|
|
34
|
+
const defaultSize = 1024; // 1GB in MB
|
|
35
|
+
let volume;
|
|
36
|
+
// Handle VolumeCreateConfiguration or simple config object
|
|
37
|
+
if ('spec' in config && 'metadata' in config) {
|
|
38
|
+
// It's already a Volume object
|
|
39
|
+
volume = config;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// It's a VolumeCreateConfiguration
|
|
43
|
+
const volumeConfig = config;
|
|
44
|
+
volume = {
|
|
45
|
+
metadata: {
|
|
46
|
+
name: volumeConfig.name || defaultName,
|
|
47
|
+
displayName: volumeConfig.displayName || volumeConfig.name || defaultName
|
|
48
|
+
},
|
|
49
|
+
spec: {
|
|
50
|
+
size: volumeConfig.size || defaultSize,
|
|
51
|
+
region: volumeConfig.region
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// Ensure required fields have defaults
|
|
56
|
+
if (!volume.metadata) {
|
|
57
|
+
volume.metadata = { name: defaultName };
|
|
58
|
+
}
|
|
59
|
+
if (!volume.metadata.name) {
|
|
60
|
+
volume.metadata.name = defaultName;
|
|
61
|
+
}
|
|
62
|
+
if (!volume.spec) {
|
|
63
|
+
volume.spec = { size: defaultSize };
|
|
64
|
+
}
|
|
65
|
+
if (!volume.spec.size) {
|
|
66
|
+
volume.spec.size = defaultSize;
|
|
67
|
+
}
|
|
68
|
+
const { data } = await (0, index_js_1.createVolume)({
|
|
69
|
+
body: volume,
|
|
70
|
+
throwOnError: true,
|
|
71
|
+
});
|
|
72
|
+
return new VolumeInstance(data);
|
|
73
|
+
}
|
|
74
|
+
static async get(volumeName) {
|
|
75
|
+
const { data } = await (0, index_js_1.getVolume)({
|
|
76
|
+
path: {
|
|
77
|
+
volumeName,
|
|
78
|
+
},
|
|
79
|
+
throwOnError: true,
|
|
80
|
+
});
|
|
81
|
+
return new VolumeInstance(data);
|
|
82
|
+
}
|
|
83
|
+
static async list() {
|
|
84
|
+
const { data } = await (0, index_js_1.listVolumes)({ throwOnError: true });
|
|
85
|
+
return data.map((volume) => new VolumeInstance(volume));
|
|
86
|
+
}
|
|
87
|
+
static async delete(volumeName) {
|
|
88
|
+
const { data } = await (0, index_js_1.deleteVolume)({
|
|
89
|
+
path: {
|
|
90
|
+
volumeName,
|
|
91
|
+
},
|
|
92
|
+
throwOnError: true,
|
|
93
|
+
});
|
|
94
|
+
return data;
|
|
95
|
+
}
|
|
96
|
+
static async createIfNotExists(config) {
|
|
97
|
+
try {
|
|
98
|
+
return await VolumeInstance.create(config);
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
if (typeof e === "object" && e !== null && "code" in e && (e.code === 409 || e.code === 'VOLUME_ALREADY_EXISTS')) {
|
|
102
|
+
const name = 'name' in config ? config.name : config.metadata?.name;
|
|
103
|
+
if (!name) {
|
|
104
|
+
throw new Error("Volume name is required");
|
|
105
|
+
}
|
|
106
|
+
const volumeInstance = await VolumeInstance.get(name);
|
|
107
|
+
return volumeInstance;
|
|
108
|
+
}
|
|
109
|
+
throw e;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.VolumeInstance = VolumeInstance;
|