@blaxel/core 0.2.57-dev.31 → 0.2.57-preview.30
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/client/sdk.gen.js +36 -2
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/sandbox/client/sdk.gen.js +1 -1
- package/dist/cjs/sandbox/process/process.js +28 -135
- package/dist/cjs/types/client/sdk.gen.d.ts +11 -1
- package/dist/cjs/types/client/types.gen.d.ts +48 -0
- package/dist/cjs/types/sandbox/client/sdk.gen.d.ts +1 -1
- package/dist/cjs/types/sandbox/client/types.gen.d.ts +0 -2
- package/dist/cjs/types/sandbox/process/process.d.ts +0 -1
- package/dist/cjs/types/sandbox/types.d.ts +0 -2
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/client/sdk.gen.js +36 -2
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/sandbox/client/sdk.gen.js +1 -1
- package/dist/cjs-browser/sandbox/process/process.js +28 -135
- package/dist/cjs-browser/types/client/sdk.gen.d.ts +11 -1
- package/dist/cjs-browser/types/client/types.gen.d.ts +48 -0
- package/dist/cjs-browser/types/sandbox/client/sdk.gen.d.ts +1 -1
- package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +0 -2
- package/dist/cjs-browser/types/sandbox/process/process.d.ts +0 -1
- package/dist/cjs-browser/types/sandbox/types.d.ts +0 -2
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/client/sdk.gen.js +32 -0
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/sandbox/client/sdk.gen.js +1 -1
- package/dist/esm/sandbox/process/process.js +28 -135
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/client/sdk.gen.js +32 -0
- package/dist/esm-browser/common/settings.js +2 -2
- package/dist/esm-browser/sandbox/client/sdk.gen.js +1 -1
- package/dist/esm-browser/sandbox/process/process.js +28 -135
- package/package.json +1 -2
- package/dist/cjs/common/version.js +0 -6
- package/dist/cjs/types/common/version.d.ts +0 -2
- package/dist/cjs-browser/common/version.js +0 -6
- package/dist/cjs-browser/types/common/version.d.ts +0 -2
- package/dist/esm/common/version.js +0 -3
- package/dist/esm-browser/common/version.js +0 -3
|
@@ -1206,6 +1206,38 @@ export const deleteSandboxPreviewToken = (options) => {
|
|
|
1206
1206
|
...options
|
|
1207
1207
|
});
|
|
1208
1208
|
};
|
|
1209
|
+
/**
|
|
1210
|
+
* Start Sandbox
|
|
1211
|
+
* Starts a Sandbox by name.
|
|
1212
|
+
*/
|
|
1213
|
+
export const startSandbox = (options) => {
|
|
1214
|
+
return (options.client ?? _heyApiClient).put({
|
|
1215
|
+
security: [
|
|
1216
|
+
{
|
|
1217
|
+
scheme: 'bearer',
|
|
1218
|
+
type: 'http'
|
|
1219
|
+
}
|
|
1220
|
+
],
|
|
1221
|
+
url: '/sandboxes/{sandboxName}/start',
|
|
1222
|
+
...options
|
|
1223
|
+
});
|
|
1224
|
+
};
|
|
1225
|
+
/**
|
|
1226
|
+
* Stop Sandbox
|
|
1227
|
+
* Stops a Sandbox by name.
|
|
1228
|
+
*/
|
|
1229
|
+
export const stopSandbox = (options) => {
|
|
1230
|
+
return (options.client ?? _heyApiClient).put({
|
|
1231
|
+
security: [
|
|
1232
|
+
{
|
|
1233
|
+
scheme: 'bearer',
|
|
1234
|
+
type: 'http'
|
|
1235
|
+
}
|
|
1236
|
+
],
|
|
1237
|
+
url: '/sandboxes/{sandboxName}/stop',
|
|
1238
|
+
...options
|
|
1239
|
+
});
|
|
1240
|
+
};
|
|
1209
1241
|
/**
|
|
1210
1242
|
* Get workspace service accounts
|
|
1211
1243
|
* Returns a list of all service accounts in the workspace.
|
|
@@ -3,8 +3,8 @@ import { authentication } from "../authentication/index.js";
|
|
|
3
3
|
import { env } from "../common/env.js";
|
|
4
4
|
import { fs, os, path } from "../common/node.js";
|
|
5
5
|
// Build info - these placeholders are replaced at build time by build:replace-imports
|
|
6
|
-
const BUILD_VERSION = "0.2.57-
|
|
7
|
-
const BUILD_COMMIT = "
|
|
6
|
+
const BUILD_VERSION = "0.2.57-preview.30";
|
|
7
|
+
const BUILD_COMMIT = "56d2203f7145b774778210b79f0641b8e3a5e175";
|
|
8
8
|
const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
|
|
9
9
|
// Cache for config.yaml tracking value
|
|
10
10
|
let configTrackingValue = null;
|
|
@@ -495,7 +495,7 @@ export const getProcess = (options) => {
|
|
|
495
495
|
};
|
|
496
496
|
/**
|
|
497
497
|
* Execute a command
|
|
498
|
-
* Execute a command and return process information
|
|
498
|
+
* Execute a command and return process information
|
|
499
499
|
*/
|
|
500
500
|
export const postProcess = (options) => {
|
|
501
501
|
return (options.client ?? _heyApiClient).post({
|
|
@@ -74,36 +74,41 @@ export class SandboxProcess extends SandboxAction {
|
|
|
74
74
|
}
|
|
75
75
|
async exec(process) {
|
|
76
76
|
let onLog;
|
|
77
|
-
let onStdout;
|
|
78
|
-
let onStderr;
|
|
79
77
|
if ('onLog' in process && process.onLog) {
|
|
80
78
|
onLog = process.onLog;
|
|
81
79
|
delete process.onLog;
|
|
82
80
|
}
|
|
83
|
-
if ('onStdout' in process && process.onStdout) {
|
|
84
|
-
onStdout = process.onStdout;
|
|
85
|
-
delete process.onStdout;
|
|
86
|
-
}
|
|
87
|
-
if ('onStderr' in process && process.onStderr) {
|
|
88
|
-
onStderr = process.onStderr;
|
|
89
|
-
delete process.onStderr;
|
|
90
|
-
}
|
|
91
81
|
// Store original wait_for_completion setting
|
|
92
82
|
const shouldWaitForCompletion = process.waitForCompletion;
|
|
93
|
-
//
|
|
94
|
-
if (shouldWaitForCompletion &&
|
|
95
|
-
|
|
83
|
+
// Always start process without wait_for_completion to avoid server-side blocking
|
|
84
|
+
if (shouldWaitForCompletion && onLog) {
|
|
85
|
+
process.waitForCompletion = false;
|
|
86
|
+
}
|
|
87
|
+
const { response, data, error } = await postProcess({
|
|
88
|
+
body: process,
|
|
89
|
+
baseUrl: this.url,
|
|
90
|
+
client: this.client,
|
|
91
|
+
});
|
|
92
|
+
this.handleResponseError(response, data, error);
|
|
93
|
+
let result = data;
|
|
94
|
+
// Handle wait_for_completion with parallel log streaming
|
|
95
|
+
if (shouldWaitForCompletion && onLog) {
|
|
96
|
+
const streamControl = this.streamLogs(result.pid, { onLog });
|
|
97
|
+
try {
|
|
98
|
+
// Wait for process completion
|
|
99
|
+
result = await this.wait(result.pid, { interval: 500, maxWait: 1000 * 60 * 60 });
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
// Clean up log streaming
|
|
103
|
+
if (streamControl) {
|
|
104
|
+
streamControl.close();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
96
107
|
}
|
|
97
108
|
else {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
client: this.client,
|
|
102
|
-
});
|
|
103
|
-
this.handleResponseError(response, data, error);
|
|
104
|
-
const result = data;
|
|
105
|
-
if (onLog || onStdout || onStderr) {
|
|
106
|
-
const streamControl = this.streamLogs(result.pid, { onLog, onStdout, onStderr });
|
|
109
|
+
// For non-blocking execution, set up log streaming immediately if requested
|
|
110
|
+
if (onLog) {
|
|
111
|
+
const streamControl = this.streamLogs(result.pid, { onLog });
|
|
107
112
|
return {
|
|
108
113
|
...result,
|
|
109
114
|
close() {
|
|
@@ -113,120 +118,8 @@ export class SandboxProcess extends SandboxAction {
|
|
|
113
118
|
},
|
|
114
119
|
};
|
|
115
120
|
}
|
|
116
|
-
return result;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async execWithStreaming(processRequest, options) {
|
|
120
|
-
const headers = this.sandbox.forceUrl ? this.sandbox.headers : settings.headers;
|
|
121
|
-
const controller = new AbortController();
|
|
122
|
-
const response = await fetch(`${this.url}/process`, {
|
|
123
|
-
method: 'POST',
|
|
124
|
-
signal: controller.signal,
|
|
125
|
-
headers: {
|
|
126
|
-
...headers,
|
|
127
|
-
'Content-Type': 'application/json',
|
|
128
|
-
'Accept': 'text/event-stream',
|
|
129
|
-
},
|
|
130
|
-
body: JSON.stringify(processRequest),
|
|
131
|
-
});
|
|
132
|
-
if (!response.ok) {
|
|
133
|
-
const errorText = await response.text();
|
|
134
|
-
throw new Error(`Failed to execute process: ${errorText}`);
|
|
135
|
-
}
|
|
136
|
-
const contentType = response.headers.get('Content-Type') || '';
|
|
137
|
-
const isStreaming = contentType.includes('text/plain') || contentType.includes('text/event-stream');
|
|
138
|
-
// Fallback: server doesn't support streaming, use legacy approach
|
|
139
|
-
if (!isStreaming) {
|
|
140
|
-
const data = await response.json();
|
|
141
|
-
// If process already completed (server waited), just return with logs
|
|
142
|
-
if (data.status === 'completed' || data.status === 'failed') {
|
|
143
|
-
// Emit any captured logs through callbacks
|
|
144
|
-
if (data.stdout) {
|
|
145
|
-
for (const line of data.stdout.split('\n').filter(l => l)) {
|
|
146
|
-
options.onStdout?.(line);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (data.stderr) {
|
|
150
|
-
for (const line of data.stderr.split('\n').filter(l => l)) {
|
|
151
|
-
options.onStderr?.(line);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (data.logs) {
|
|
155
|
-
for (const line of data.logs.split('\n').filter(l => l)) {
|
|
156
|
-
options.onLog?.(line);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return {
|
|
160
|
-
...data,
|
|
161
|
-
close: () => { },
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
return {
|
|
165
|
-
...data,
|
|
166
|
-
close: () => { },
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
// Streaming response handling
|
|
170
|
-
if (!response.body) {
|
|
171
|
-
throw new Error('No response body for streaming');
|
|
172
|
-
}
|
|
173
|
-
const reader = response.body.getReader();
|
|
174
|
-
const decoder = new TextDecoder();
|
|
175
|
-
let buffer = '';
|
|
176
|
-
let result = null;
|
|
177
|
-
while (true) {
|
|
178
|
-
const readResult = await reader.read();
|
|
179
|
-
if (readResult.done)
|
|
180
|
-
break;
|
|
181
|
-
if (readResult.value && readResult.value instanceof Uint8Array) {
|
|
182
|
-
buffer += decoder.decode(readResult.value, { stream: true });
|
|
183
|
-
}
|
|
184
|
-
const lines = buffer.split(/\r?\n/);
|
|
185
|
-
buffer = lines.pop();
|
|
186
|
-
for (const line of lines) {
|
|
187
|
-
if (!line || line.startsWith('[keepalive]')) {
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
if (line.startsWith('stdout:')) {
|
|
191
|
-
const content = line.slice(7);
|
|
192
|
-
options.onStdout?.(content);
|
|
193
|
-
options.onLog?.(content);
|
|
194
|
-
}
|
|
195
|
-
else if (line.startsWith('stderr:')) {
|
|
196
|
-
const content = line.slice(7);
|
|
197
|
-
options.onStderr?.(content);
|
|
198
|
-
options.onLog?.(content);
|
|
199
|
-
}
|
|
200
|
-
else if (line.startsWith('result:')) {
|
|
201
|
-
const jsonStr = line.slice(7);
|
|
202
|
-
try {
|
|
203
|
-
result = JSON.parse(jsonStr);
|
|
204
|
-
}
|
|
205
|
-
catch {
|
|
206
|
-
throw new Error(`Failed to parse result JSON: ${jsonStr}`);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
121
|
}
|
|
211
|
-
|
|
212
|
-
if (buffer.trim()) {
|
|
213
|
-
if (buffer.startsWith('result:')) {
|
|
214
|
-
const jsonStr = buffer.slice(7);
|
|
215
|
-
try {
|
|
216
|
-
result = JSON.parse(jsonStr);
|
|
217
|
-
}
|
|
218
|
-
catch {
|
|
219
|
-
throw new Error(`Failed to parse result JSON: ${jsonStr}`);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
if (!result) {
|
|
224
|
-
throw new Error('No result received from streaming response');
|
|
225
|
-
}
|
|
226
|
-
return {
|
|
227
|
-
...result,
|
|
228
|
-
close: () => controller.abort(),
|
|
229
|
-
};
|
|
122
|
+
return { ...result, close: () => { } };
|
|
230
123
|
}
|
|
231
124
|
async wait(identifier, { maxWait = 60000, interval = 1000 } = {}) {
|
|
232
125
|
const startTime = Date.now();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaxel/core",
|
|
3
|
-
"version": "0.2.57-
|
|
3
|
+
"version": "0.2.57-preview.30",
|
|
4
4
|
"description": "Blaxel Core SDK for TypeScript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Blaxel, INC (https://blaxel.ai)",
|
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@hey-api/client-fetch": "^0.10.0",
|
|
55
55
|
"@modelcontextprotocol/sdk": "^1.20.0",
|
|
56
|
-
"@sentry/node": "^10.27.0",
|
|
57
56
|
"axios": "^1.9.0",
|
|
58
57
|
"dotenv": "^16.5.0",
|
|
59
58
|
"form-data": "^4.0.2",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PACKAGE_COMMIT = exports.PACKAGE_VERSION = void 0;
|
|
4
|
-
// This file is auto-generated during build. Do not edit manually.
|
|
5
|
-
exports.PACKAGE_VERSION = "0.2.50";
|
|
6
|
-
exports.PACKAGE_COMMIT = "4a74989dcb65a6ff8d826aed7976436c64554f6a";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PACKAGE_COMMIT = exports.PACKAGE_VERSION = void 0;
|
|
4
|
-
// This file is auto-generated during build. Do not edit manually.
|
|
5
|
-
exports.PACKAGE_VERSION = "0.2.50";
|
|
6
|
-
exports.PACKAGE_COMMIT = "4a74989dcb65a6ff8d826aed7976436c64554f6a";
|