@blaxel/core 0.2.49-dev.213 → 0.2.49-dev1
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/agents/index.d.ts +15 -0
- package/dist/agents/index.js +109 -0
- package/dist/authentication/apikey.d.ts +10 -0
- package/dist/authentication/apikey.js +24 -0
- package/dist/authentication/clientcredentials.d.ts +17 -0
- package/dist/authentication/clientcredentials.js +85 -0
- package/dist/authentication/credentials.d.ts +6 -0
- package/dist/authentication/credentials.js +17 -0
- package/dist/authentication/deviceMode.d.ts +15 -0
- package/dist/authentication/deviceMode.js +70 -0
- package/dist/authentication/index.d.ts +3 -0
- package/dist/authentication/index.js +62 -0
- package/dist/authentication/types.d.ts +9 -0
- package/dist/authentication/types.js +2 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cache/index.js +26 -0
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/agents/index.js +2 -2
- package/dist/cjs/authentication/clientcredentials.js +1 -4
- package/dist/cjs/client/responseInterceptor.js +53 -0
- package/dist/cjs/client/sdk.gen.js +143 -3
- package/dist/cjs/common/autoload.js +7 -0
- package/dist/cjs/common/env.js +3 -0
- package/dist/cjs/common/internal.js +0 -40
- package/dist/cjs/common/settings.js +2 -5
- package/dist/cjs/common/version.js +6 -0
- package/dist/cjs/common/webhook.js +101 -0
- package/dist/cjs/jobs/executions.js +119 -0
- package/dist/cjs/jobs/jobs.js +2 -2
- package/dist/cjs/sandbox/action.js +2 -1
- package/dist/cjs/sandbox/index.js +1 -0
- package/dist/cjs/sandbox/interpreter.js +400 -0
- package/dist/cjs/sandbox/sandbox.js +10 -67
- package/dist/cjs/tools/mcpTool.js +2 -6
- package/dist/cjs/types/client/responseInterceptor.d.ts +12 -0
- package/dist/cjs/types/client/sdk.gen.d.ts +41 -1
- package/dist/cjs/types/client/types.gen.d.ts +599 -16
- package/dist/cjs/types/common/internal.d.ts +0 -2
- package/dist/cjs/types/common/settings.d.ts +0 -1
- package/dist/cjs/types/common/version.d.ts +2 -0
- package/dist/cjs/types/common/webhook.d.ts +89 -0
- package/dist/cjs/types/jobs/executions.d.ts +42 -0
- package/dist/cjs/types/sandbox/client/sdk.gen.d.ts +1 -1
- package/dist/cjs/types/sandbox/index.d.ts +1 -0
- package/dist/cjs/types/sandbox/interpreter.d.ts +71 -0
- package/dist/cjs/types/sandbox/sandbox.d.ts +6 -12
- package/dist/cjs/types/sandbox/types.d.ts +0 -3
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/agents/index.js +2 -2
- package/dist/cjs-browser/authentication/clientcredentials.js +1 -4
- package/dist/cjs-browser/client/responseInterceptor.js +53 -0
- package/dist/cjs-browser/client/sdk.gen.js +143 -3
- package/dist/cjs-browser/common/autoload.js +7 -0
- package/dist/cjs-browser/common/env.js +3 -0
- package/dist/cjs-browser/common/internal.js +0 -40
- package/dist/cjs-browser/common/settings.js +2 -5
- package/dist/cjs-browser/common/version.js +6 -0
- package/dist/cjs-browser/common/webhook.js +101 -0
- package/dist/cjs-browser/jobs/executions.js +119 -0
- package/dist/cjs-browser/jobs/jobs.js +2 -2
- package/dist/cjs-browser/sandbox/action.js +2 -1
- package/dist/cjs-browser/sandbox/index.js +1 -0
- package/dist/cjs-browser/sandbox/interpreter.js +400 -0
- package/dist/cjs-browser/sandbox/sandbox.js +10 -67
- package/dist/cjs-browser/tools/mcpTool.js +2 -6
- package/dist/cjs-browser/types/client/responseInterceptor.d.ts +12 -0
- package/dist/cjs-browser/types/client/sdk.gen.d.ts +41 -1
- package/dist/cjs-browser/types/client/types.gen.d.ts +599 -16
- package/dist/cjs-browser/types/common/internal.d.ts +0 -2
- package/dist/cjs-browser/types/common/settings.d.ts +0 -1
- package/dist/cjs-browser/types/common/version.d.ts +2 -0
- package/dist/cjs-browser/types/common/webhook.d.ts +89 -0
- package/dist/cjs-browser/types/jobs/executions.d.ts +42 -0
- package/dist/cjs-browser/types/sandbox/client/sdk.gen.d.ts +1 -1
- package/dist/cjs-browser/types/sandbox/index.d.ts +1 -0
- package/dist/cjs-browser/types/sandbox/interpreter.d.ts +71 -0
- package/dist/cjs-browser/types/sandbox/sandbox.d.ts +6 -12
- package/dist/cjs-browser/types/sandbox/types.d.ts +0 -3
- package/dist/client/authentication.d.ts +25 -0
- package/dist/client/authentication.js +15 -0
- package/dist/client/client.d.ts +2 -0
- package/dist/client/client.gen.d.ts +12 -0
- package/dist/client/client.gen.js +8 -0
- package/dist/{cjs/sandbox/websocket/index.js → client/client.js} +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +19 -0
- package/dist/client/interceptors.d.ts +3 -0
- package/dist/client/interceptors.js +17 -0
- package/dist/client/sdk.gen.d.ts +499 -0
- package/dist/client/sdk.gen.js +1751 -0
- package/dist/client/types.gen.d.ts +4546 -0
- package/dist/client/types.gen.js +4 -0
- package/dist/common/autoload.d.ts +3 -0
- package/dist/common/autoload.js +27 -0
- package/dist/common/env.d.ts +5 -0
- package/dist/common/env.js +42 -0
- package/dist/common/errors.d.ts +1 -0
- package/dist/common/errors.js +17 -0
- package/dist/common/internal.d.ts +4 -0
- package/dist/common/internal.js +188 -0
- package/dist/common/internal.test.d.ts +1 -0
- package/dist/common/internal.test.js +39 -0
- package/dist/common/logger.d.ts +25 -0
- package/dist/common/logger.js +69 -0
- package/dist/common/node.d.ts +5 -0
- package/dist/common/node.js +26 -0
- package/dist/common/settings.d.ts +31 -0
- package/dist/common/settings.js +170 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/agents/index.js +3 -3
- package/dist/esm/authentication/clientcredentials.js +1 -4
- package/dist/esm/client/responseInterceptor.js +49 -0
- package/dist/esm/client/sdk.gen.js +132 -0
- package/dist/esm/common/autoload.js +7 -0
- package/dist/esm/common/env.js +3 -0
- package/dist/esm/common/internal.js +0 -38
- package/dist/esm/common/settings.js +2 -5
- package/dist/esm/common/version.js +3 -0
- package/dist/esm/common/webhook.js +97 -0
- package/dist/esm/jobs/executions.js +114 -0
- package/dist/esm/jobs/jobs.js +3 -3
- package/dist/esm/sandbox/action.js +3 -2
- package/dist/esm/sandbox/index.js +1 -0
- package/dist/esm/sandbox/interpreter.js +396 -0
- package/dist/esm/sandbox/sandbox.js +10 -67
- package/dist/esm/tools/mcpTool.js +3 -7
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/agents/index.js +3 -3
- package/dist/esm-browser/authentication/clientcredentials.js +1 -4
- package/dist/esm-browser/client/responseInterceptor.js +49 -0
- package/dist/esm-browser/client/sdk.gen.js +132 -0
- package/dist/esm-browser/common/autoload.js +7 -0
- package/dist/esm-browser/common/env.js +3 -0
- package/dist/esm-browser/common/internal.js +0 -38
- package/dist/esm-browser/common/settings.js +2 -5
- package/dist/esm-browser/common/version.js +3 -0
- package/dist/esm-browser/common/webhook.js +97 -0
- package/dist/esm-browser/jobs/executions.js +114 -0
- package/dist/esm-browser/jobs/jobs.js +3 -3
- package/dist/esm-browser/sandbox/action.js +3 -2
- package/dist/esm-browser/sandbox/index.js +1 -0
- package/dist/esm-browser/sandbox/interpreter.js +396 -0
- package/dist/esm-browser/sandbox/sandbox.js +10 -67
- package/dist/esm-browser/tools/mcpTool.js +3 -7
- package/dist/index.browser.test.d.ts +1 -0
- package/dist/index.browser.test.js +45 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +33 -0
- package/dist/jobs/index.d.ts +3 -0
- package/dist/jobs/index.js +19 -0
- package/dist/jobs/jobs.d.ts +13 -0
- package/dist/jobs/jobs.js +90 -0
- package/dist/jobs/start.d.ts +1 -0
- package/dist/jobs/start.js +66 -0
- package/dist/jobs/types.d.ts +3 -0
- package/dist/jobs/types.js +2 -0
- package/dist/mcp/client.d.ts +28 -0
- package/dist/mcp/client.js +247 -0
- package/dist/{cjs-browser/types/sandbox/websocket → mcp}/index.d.ts +1 -0
- package/dist/{cjs-browser/sandbox/websocket → mcp}/index.js +1 -0
- package/dist/mcp/server.d.ts +24 -0
- package/dist/mcp/server.js +213 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.js +31 -0
- package/dist/sandbox/action.d.ts +19 -0
- package/dist/sandbox/action.js +84 -0
- package/dist/sandbox/client/client.gen.d.ts +12 -0
- package/dist/sandbox/client/client.gen.js +6 -0
- package/dist/sandbox/client/index.d.ts +2 -0
- package/dist/sandbox/client/index.js +19 -0
- package/dist/sandbox/client/sdk.gen.d.ts +101 -0
- package/dist/sandbox/client/sdk.gen.js +289 -0
- package/dist/sandbox/client/types.gen.d.ts +578 -0
- package/dist/sandbox/client/types.gen.js +3 -0
- package/dist/{cjs/types/sandbox/filesystem/filesystem-ws.d.ts → sandbox/filesystem/filesystem.d.ts} +6 -18
- package/dist/sandbox/filesystem/filesystem.js +276 -0
- package/dist/sandbox/filesystem/index.d.ts +2 -0
- package/dist/sandbox/filesystem/index.js +18 -0
- package/dist/sandbox/filesystem/types.d.ts +15 -0
- package/dist/sandbox/filesystem/types.js +2 -0
- package/dist/sandbox/index.d.ts +4 -0
- package/dist/sandbox/index.js +36 -0
- package/dist/sandbox/network/index.d.ts +1 -0
- package/dist/sandbox/network/index.js +17 -0
- package/dist/sandbox/network/network.d.ts +5 -0
- package/dist/sandbox/network/network.js +10 -0
- package/dist/sandbox/preview.d.ts +37 -0
- package/dist/sandbox/preview.js +148 -0
- package/dist/sandbox/process/index.d.ts +1 -0
- package/dist/sandbox/process/index.js +17 -0
- package/dist/sandbox/process/process.d.ts +24 -0
- package/dist/sandbox/process/process.js +189 -0
- package/dist/sandbox/sandbox.d.ts +33 -0
- package/dist/sandbox/sandbox.js +178 -0
- package/dist/sandbox/session.d.ts +27 -0
- package/dist/sandbox/session.js +123 -0
- package/dist/sandbox/types.d.ts +51 -0
- package/dist/sandbox/types.js +81 -0
- package/dist/telemetry/telemetry.d.ts +62 -0
- package/dist/telemetry/telemetry.js +80 -0
- package/dist/tools/index.d.ts +11 -0
- package/dist/tools/index.js +52 -0
- package/dist/tools/mcpTool.d.ts +28 -0
- package/dist/tools/mcpTool.js +218 -0
- package/dist/tools/types.d.ts +8 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/zodSchema.d.ts +9 -0
- package/dist/tools/zodSchema.js +50 -0
- package/dist/volume/index.d.ts +23 -0
- package/dist/volume/index.js +113 -0
- package/package.json +2 -2
- package/dist/cjs/sandbox/codegen/codegen-ws.js +0 -30
- package/dist/cjs/sandbox/filesystem/filesystem-ws.js +0 -106
- package/dist/cjs/sandbox/network/network-ws.js +0 -12
- package/dist/cjs/sandbox/process/process-ws.js +0 -139
- package/dist/cjs/sandbox/websocket/client.js +0 -269
- package/dist/cjs/types/sandbox/codegen/codegen-ws.d.ts +0 -10
- package/dist/cjs/types/sandbox/network/network-ws.d.ts +0 -7
- package/dist/cjs/types/sandbox/process/process-ws.d.ts +0 -27
- package/dist/cjs/types/sandbox/websocket/client.d.ts +0 -48
- package/dist/cjs/types/sandbox/websocket/index.d.ts +0 -1
- package/dist/cjs-browser/sandbox/codegen/codegen-ws.js +0 -30
- package/dist/cjs-browser/sandbox/filesystem/filesystem-ws.js +0 -106
- package/dist/cjs-browser/sandbox/network/network-ws.js +0 -12
- package/dist/cjs-browser/sandbox/process/process-ws.js +0 -139
- package/dist/cjs-browser/sandbox/websocket/client.js +0 -269
- package/dist/cjs-browser/types/sandbox/codegen/codegen-ws.d.ts +0 -10
- package/dist/cjs-browser/types/sandbox/filesystem/filesystem-ws.d.ts +0 -35
- package/dist/cjs-browser/types/sandbox/network/network-ws.d.ts +0 -7
- package/dist/cjs-browser/types/sandbox/process/process-ws.d.ts +0 -27
- package/dist/cjs-browser/types/sandbox/websocket/client.d.ts +0 -48
- package/dist/esm/sandbox/codegen/codegen-ws.js +0 -26
- package/dist/esm/sandbox/filesystem/filesystem-ws.js +0 -102
- package/dist/esm/sandbox/network/network-ws.js +0 -8
- package/dist/esm/sandbox/process/process-ws.js +0 -135
- package/dist/esm/sandbox/websocket/client.js +0 -265
- package/dist/esm/sandbox/websocket/index.js +0 -1
- package/dist/esm-browser/sandbox/codegen/codegen-ws.js +0 -26
- package/dist/esm-browser/sandbox/filesystem/filesystem-ws.js +0 -102
- package/dist/esm-browser/sandbox/network/network-ws.js +0 -8
- package/dist/esm-browser/sandbox/process/process-ws.js +0 -135
- package/dist/esm-browser/sandbox/websocket/client.js +0 -265
- package/dist/esm-browser/sandbox/websocket/index.js +0 -1
|
@@ -2,5 +2,3 @@ export declare function getAlphanumericLimitedHash(input: string, maxSize?: numb
|
|
|
2
2
|
export declare function getGlobalUniqueHash(workspace: string, type: string, name: string): string;
|
|
3
3
|
export declare function pluralize(type: string): string;
|
|
4
4
|
export declare function getForcedUrl(type: string, name: string): import("url").URL | null;
|
|
5
|
-
export declare function getWorkloadTypeShort(type: string): string;
|
|
6
|
-
export declare function generateInternalUrl(workspace: string, type: string, name: string, env: string, protocol: string, hostname: string, blCloud: boolean, workspaceId: string): string;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook signature verification for async-sidecar callbacks
|
|
3
|
+
*/
|
|
4
|
+
export interface WebhookVerificationOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The raw request body as a string
|
|
7
|
+
*/
|
|
8
|
+
body: string;
|
|
9
|
+
/**
|
|
10
|
+
* The X-Blaxel-Signature header value (format: "sha256=<hex_digest>")
|
|
11
|
+
*/
|
|
12
|
+
signature: string;
|
|
13
|
+
/**
|
|
14
|
+
* The secret key used to sign the webhook (same as CALLBACK_SECRET in async-sidecar)
|
|
15
|
+
*/
|
|
16
|
+
secret: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional: The X-Blaxel-Timestamp header value for replay attack prevention
|
|
19
|
+
*/
|
|
20
|
+
timestamp?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional: Maximum age of the webhook in seconds (default: 300 = 5 minutes)
|
|
23
|
+
*/
|
|
24
|
+
maxAge?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface AsyncSidecarCallback {
|
|
27
|
+
status_code: number;
|
|
28
|
+
response_body: string;
|
|
29
|
+
response_length: number;
|
|
30
|
+
timestamp: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Verify the HMAC-SHA256 signature of a webhook callback from async-sidecar
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { verifyWebhookSignature } from '@blaxel/core';
|
|
38
|
+
*
|
|
39
|
+
* // In your Express endpoint
|
|
40
|
+
* app.post('/webhook', express.text({ type: 'application/json' }), (req, res) => {
|
|
41
|
+
* const isValid = verifyWebhookSignature({
|
|
42
|
+
* body: req.body,
|
|
43
|
+
* signature: req.headers['x-blaxel-signature'] as string,
|
|
44
|
+
* secret: process.env.CALLBACK_SECRET!
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* if (!isValid) {
|
|
48
|
+
* return res.status(401).json({ error: 'Invalid signature' });
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* const data = JSON.parse(req.body);
|
|
52
|
+
* // Process callback...
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param options - Verification options
|
|
57
|
+
* @returns true if the signature is valid, false otherwise
|
|
58
|
+
*/
|
|
59
|
+
export declare function verifyWebhookSignature(options: WebhookVerificationOptions): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Helper to verify webhook from Express request object
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* import { verifyWebhookFromRequest } from '@blaxel/core';
|
|
66
|
+
* import express from 'express';
|
|
67
|
+
*
|
|
68
|
+
* app.use(express.text({ type: 'application/json' }));
|
|
69
|
+
*
|
|
70
|
+
* app.post('/webhook', (req, res) => {
|
|
71
|
+
* if (!verifyWebhookFromRequest(req, process.env.CALLBACK_SECRET!)) {
|
|
72
|
+
* return res.status(401).json({ error: 'Invalid signature' });
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
* const data = JSON.parse(req.body);
|
|
76
|
+
* console.log('Received callback:', data);
|
|
77
|
+
* res.json({ received: true });
|
|
78
|
+
* });
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @param request - Express request object (must use express.text() middleware)
|
|
82
|
+
* @param secret - The callback secret
|
|
83
|
+
* @param maxAge - Optional maximum age in seconds (default: 300)
|
|
84
|
+
* @returns true if the signature is valid, false otherwise
|
|
85
|
+
*/
|
|
86
|
+
export declare function verifyWebhookFromRequest(request: {
|
|
87
|
+
body: string;
|
|
88
|
+
headers: Record<string, string | string[] | undefined>;
|
|
89
|
+
}, secret: string, maxAge?: number): boolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CreateJobExecutionRequest, JobExecution } from "../client/types.gen.js";
|
|
2
|
+
/**
|
|
3
|
+
* JobExecutionHelper provides convenient methods for working with job executions
|
|
4
|
+
*/
|
|
5
|
+
export declare class JobExecutionHelper {
|
|
6
|
+
private jobName;
|
|
7
|
+
constructor(jobName: string);
|
|
8
|
+
/**
|
|
9
|
+
* Create a new job execution and return the execution ID
|
|
10
|
+
*/
|
|
11
|
+
create(request: CreateJobExecutionRequest): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Get a specific job execution by ID
|
|
14
|
+
*/
|
|
15
|
+
get(executionId: string): Promise<JobExecution>;
|
|
16
|
+
/**
|
|
17
|
+
* List all executions for the job
|
|
18
|
+
*/
|
|
19
|
+
list(): Promise<JobExecution[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Get the status of a specific execution
|
|
22
|
+
*/
|
|
23
|
+
getStatus(executionId: string): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Delete a specific job execution
|
|
26
|
+
*/
|
|
27
|
+
delete(executionId: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Wait for an execution to complete
|
|
30
|
+
* @param executionId The execution ID to wait for
|
|
31
|
+
* @param options.maxWait Maximum time to wait in milliseconds (default: 5 minutes)
|
|
32
|
+
* @param options.interval Polling interval in milliseconds (default: 2 seconds)
|
|
33
|
+
*/
|
|
34
|
+
waitForCompletion(executionId: string, options?: {
|
|
35
|
+
maxWait?: number;
|
|
36
|
+
interval?: number;
|
|
37
|
+
}): Promise<JobExecution>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Factory function to create a JobExecutionHelper
|
|
41
|
+
*/
|
|
42
|
+
export declare const jobExecutions: (jobName: string) => JobExecutionHelper;
|
|
@@ -123,7 +123,7 @@ export declare const deleteFilesystemByPath: <ThrowOnError extends boolean = fal
|
|
|
123
123
|
* Get file or directory information
|
|
124
124
|
* Get content of a file or listing of a directory. Use Accept header to control response format for files.
|
|
125
125
|
*/
|
|
126
|
-
export declare const getFilesystemByPath: <ThrowOnError extends boolean = false>(options: Options<GetFilesystemByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").
|
|
126
|
+
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 | Blob | import("./types.gen").File, import("./types.gen").ErrorResponse, ThrowOnError>;
|
|
127
127
|
/**
|
|
128
128
|
* Create or update a file or directory
|
|
129
129
|
* Create or update a file or directory
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Sandbox, SandboxLifecycle, Port } from "../client/types.gen.js";
|
|
2
|
+
import { SandboxInstance } from "./sandbox.js";
|
|
3
|
+
import { SandboxConfiguration, SandboxCreateConfiguration } from "./types.js";
|
|
4
|
+
export declare class CodeInterpreter extends SandboxInstance {
|
|
5
|
+
static readonly DEFAULT_IMAGE = "blaxel/jupyter-server";
|
|
6
|
+
static readonly DEFAULT_PORTS: Port[];
|
|
7
|
+
static readonly DEFAULT_LIFECYCLE: SandboxLifecycle;
|
|
8
|
+
private _sandboxConfig;
|
|
9
|
+
constructor(sandbox: SandboxConfiguration);
|
|
10
|
+
static get(sandboxName: string): Promise<CodeInterpreter>;
|
|
11
|
+
static create(sandbox?: Sandbox | SandboxCreateConfiguration | Record<string, any> | null, { safe }?: {
|
|
12
|
+
safe?: boolean;
|
|
13
|
+
}): Promise<CodeInterpreter>;
|
|
14
|
+
get _jupyterUrl(): string;
|
|
15
|
+
static OutputMessage: {
|
|
16
|
+
new (text: string, timestamp: number | null, isStderr: boolean): {
|
|
17
|
+
text: string;
|
|
18
|
+
timestamp: number | null;
|
|
19
|
+
isStderr: boolean;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
static Result: {
|
|
23
|
+
new (kwargs?: Record<string, unknown>): {
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
static ExecutionError: {
|
|
28
|
+
new (name: string, value: any, traceback: any): {
|
|
29
|
+
name: string;
|
|
30
|
+
value: any;
|
|
31
|
+
traceback: any;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
static Logs: {
|
|
35
|
+
new (): {
|
|
36
|
+
stdout: string[];
|
|
37
|
+
stderr: string[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
static Execution: {
|
|
41
|
+
new (): {
|
|
42
|
+
results: InstanceType<typeof CodeInterpreter.Result>[];
|
|
43
|
+
logs: InstanceType<typeof CodeInterpreter.Logs>;
|
|
44
|
+
error: InstanceType<typeof CodeInterpreter.ExecutionError> | null;
|
|
45
|
+
executionCount: number | null;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
static Context: {
|
|
49
|
+
new (id: string): {
|
|
50
|
+
id: string;
|
|
51
|
+
};
|
|
52
|
+
fromJson(data: Record<string, any>): InstanceType<typeof CodeInterpreter.Context>;
|
|
53
|
+
};
|
|
54
|
+
private _parseOutput;
|
|
55
|
+
runCode(code: string, options?: {
|
|
56
|
+
language?: string | null;
|
|
57
|
+
context?: InstanceType<typeof CodeInterpreter.Context> | null;
|
|
58
|
+
onStdout?: (msg: InstanceType<typeof CodeInterpreter.OutputMessage>) => void;
|
|
59
|
+
onStderr?: (msg: InstanceType<typeof CodeInterpreter.OutputMessage>) => void;
|
|
60
|
+
onResult?: (result: InstanceType<typeof CodeInterpreter.Result>) => void;
|
|
61
|
+
onError?: (error: InstanceType<typeof CodeInterpreter.ExecutionError>) => void;
|
|
62
|
+
envs?: Record<string, string> | null;
|
|
63
|
+
timeout?: number | null;
|
|
64
|
+
requestTimeout?: number | null;
|
|
65
|
+
}): Promise<InstanceType<typeof CodeInterpreter.Execution>>;
|
|
66
|
+
createCodeContext(options?: {
|
|
67
|
+
cwd?: string | null;
|
|
68
|
+
language?: string | null;
|
|
69
|
+
requestTimeout?: number | null;
|
|
70
|
+
}): Promise<InstanceType<typeof CodeInterpreter.Context>>;
|
|
71
|
+
}
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import { Sandbox as SandboxModel } from "../client/index.js";
|
|
2
2
|
import { SandboxFileSystem } from "./filesystem/index.js";
|
|
3
|
-
import { SandboxFileSystemWebSocket } from "./filesystem/filesystem-ws.js";
|
|
4
3
|
import { SandboxNetwork } from "./network/index.js";
|
|
5
|
-
import { SandboxNetworkWebSocket } from "./network/network-ws.js";
|
|
6
4
|
import { SandboxPreviews } from "./preview.js";
|
|
7
5
|
import { SandboxProcess } from "./process/index.js";
|
|
8
|
-
import { SandboxProcessWebSocket } from "./process/process-ws.js";
|
|
9
6
|
import { SandboxCodegen } from "./codegen/index.js";
|
|
10
|
-
import { SandboxCodegenWebSocket } from "./codegen/codegen-ws.js";
|
|
11
7
|
import { SandboxSessions } from "./session.js";
|
|
12
8
|
import { SandboxConfiguration, SandboxCreateConfiguration, SandboxUpdateMetadata, SessionWithToken } from "./types.js";
|
|
13
9
|
export declare class SandboxInstance {
|
|
14
10
|
private sandbox;
|
|
15
|
-
fs: SandboxFileSystem
|
|
16
|
-
network: SandboxNetwork
|
|
17
|
-
process: SandboxProcess
|
|
11
|
+
fs: SandboxFileSystem;
|
|
12
|
+
network: SandboxNetwork;
|
|
13
|
+
process: SandboxProcess;
|
|
18
14
|
previews: SandboxPreviews;
|
|
19
15
|
sessions: SandboxSessions;
|
|
20
|
-
codegen: SandboxCodegen
|
|
21
|
-
private wsClient?;
|
|
16
|
+
codegen: SandboxCodegen;
|
|
22
17
|
constructor(sandbox: SandboxConfiguration);
|
|
23
18
|
get metadata(): import("../client/types.gen.js").Metadata | undefined;
|
|
24
19
|
get status(): string | undefined;
|
|
@@ -28,13 +23,12 @@ export declare class SandboxInstance {
|
|
|
28
23
|
maxWait?: number;
|
|
29
24
|
interval?: number;
|
|
30
25
|
}): Promise<this>;
|
|
31
|
-
closeConnection(): void;
|
|
32
26
|
static create(sandbox?: SandboxModel | SandboxCreateConfiguration, { safe }?: {
|
|
33
27
|
safe?: boolean;
|
|
34
28
|
}): Promise<SandboxInstance>;
|
|
35
|
-
static get(sandboxName: string
|
|
29
|
+
static get(sandboxName: string): Promise<SandboxInstance>;
|
|
36
30
|
static list(): Promise<SandboxInstance[]>;
|
|
37
|
-
static delete(sandboxName: string
|
|
31
|
+
static delete(sandboxName: string): Promise<SandboxModel>;
|
|
38
32
|
static updateMetadata(sandboxName: string, metadata: SandboxUpdateMetadata): Promise<SandboxInstance>;
|
|
39
33
|
static createIfNotExists(sandbox: SandboxModel | SandboxCreateConfiguration): Promise<SandboxInstance>;
|
|
40
34
|
static fromSession(session: SessionWithToken): Promise<SandboxInstance>;
|
|
@@ -20,12 +20,10 @@ export interface VolumeBinding {
|
|
|
20
20
|
mountPath: string;
|
|
21
21
|
readOnly?: boolean;
|
|
22
22
|
}
|
|
23
|
-
export type ConnectionType = "http" | "websocket";
|
|
24
23
|
export type SandboxConfiguration = {
|
|
25
24
|
forceUrl?: string;
|
|
26
25
|
headers?: Record<string, string>;
|
|
27
26
|
params?: Record<string, string>;
|
|
28
|
-
connectionType?: ConnectionType;
|
|
29
27
|
} & Sandbox;
|
|
30
28
|
export type SandboxUpdateMetadata = {
|
|
31
29
|
labels?: Record<string, string>;
|
|
@@ -43,7 +41,6 @@ export type SandboxCreateConfiguration = {
|
|
|
43
41
|
region?: string;
|
|
44
42
|
lifecycle?: SandboxLifecycle;
|
|
45
43
|
snapshotEnabled?: boolean;
|
|
46
|
-
connectionType?: ConnectionType;
|
|
47
44
|
};
|
|
48
45
|
export declare function normalizePorts(ports?: (Port | Record<string, any>)[]): Port[] | undefined;
|
|
49
46
|
export declare function normalizeEnvs(envs?: EnvVar[]): EnvVar[] | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { OptionsLegacyParser } from "@hey-api/client-fetch";
|
|
2
|
+
type OauthTokenData = {
|
|
3
|
+
body: {
|
|
4
|
+
grant_type: 'client_credentials' | 'refresh_token' | 'device_code';
|
|
5
|
+
client_id?: string;
|
|
6
|
+
client_secret?: string;
|
|
7
|
+
device_code?: string;
|
|
8
|
+
refresh_token?: string;
|
|
9
|
+
};
|
|
10
|
+
authenticated?: boolean;
|
|
11
|
+
};
|
|
12
|
+
type OauthTokenResponse = {
|
|
13
|
+
access_token: string;
|
|
14
|
+
refresh_token: string;
|
|
15
|
+
expires_in: number;
|
|
16
|
+
token_type: string;
|
|
17
|
+
};
|
|
18
|
+
type OauthTokenError = {
|
|
19
|
+
error: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Get a new oauth token
|
|
23
|
+
*/
|
|
24
|
+
export declare const oauthToken: <ThrowOnError extends boolean = false>(options: OptionsLegacyParser<OauthTokenData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<OauthTokenResponse, OauthTokenError, ThrowOnError>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.oauthToken = void 0;
|
|
4
|
+
const client_gen_js_1 = require("./client.gen.js");
|
|
5
|
+
/**
|
|
6
|
+
* Get a new oauth token
|
|
7
|
+
*/
|
|
8
|
+
const oauthToken = (options) => {
|
|
9
|
+
options.authenticated = false;
|
|
10
|
+
return client_gen_js_1.client.post({
|
|
11
|
+
...options,
|
|
12
|
+
url: '/oauth/token',
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
exports.oauthToken = oauthToken;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ClientOptions } from './types.gen';
|
|
2
|
+
import { type Config, type ClientOptions as DefaultClientOptions } from '@hey-api/client-fetch';
|
|
3
|
+
/**
|
|
4
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
5
|
+
* and the returned object will become the client's initial configuration.
|
|
6
|
+
*
|
|
7
|
+
* You may want to initialize your client this way instead of calling
|
|
8
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
9
|
+
* to ensure your client always has the correct values.
|
|
10
|
+
*/
|
|
11
|
+
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
|
|
12
|
+
export declare const client: import("@hey-api/client-fetch").Client;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.client = void 0;
|
|
5
|
+
const client_fetch_1 = require("@hey-api/client-fetch");
|
|
6
|
+
exports.client = (0, client_fetch_1.createClient)((0, client_fetch_1.createConfig)({
|
|
7
|
+
baseUrl: 'https://api.blaxel.ai/v0'
|
|
8
|
+
}));
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./index.js"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
18
|
+
__exportStar(require("./types.gen.js"), exports);
|
|
19
|
+
__exportStar(require("./sdk.gen.js"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.interceptors = void 0;
|
|
4
|
+
const settings_js_1 = require("../common/settings.js");
|
|
5
|
+
exports.interceptors = [
|
|
6
|
+
// Authentication interceptor
|
|
7
|
+
async (request, options) => {
|
|
8
|
+
if (options.authenticated === false) {
|
|
9
|
+
return request;
|
|
10
|
+
}
|
|
11
|
+
await settings_js_1.settings.authenticate();
|
|
12
|
+
for (const header in settings_js_1.settings.headers) {
|
|
13
|
+
request.headers.set(header, settings_js_1.settings.headers[header]);
|
|
14
|
+
}
|
|
15
|
+
return request;
|
|
16
|
+
},
|
|
17
|
+
];
|