@blaxel/core 0.2.47-preview.104 → 0.2.47-preview.106
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/common/settings.js +2 -2
- package/dist/cjs/sandbox/client/sdk.gen.js +173 -36
- package/dist/cjs/sandbox/codegen/codegen.js +31 -0
- package/dist/cjs/sandbox/codegen/index.js +17 -0
- package/dist/cjs/sandbox/filesystem/filesystem.js +28 -1
- package/dist/cjs/sandbox/index.js +4 -1
- package/dist/cjs/sandbox/sandbox.js +4 -1
- package/dist/cjs/types/sandbox/client/sdk.gen.d.ts +74 -13
- package/dist/cjs/types/sandbox/client/types.gen.d.ts +203 -50
- package/dist/cjs/types/sandbox/codegen/codegen.d.ts +8 -0
- package/dist/cjs/types/sandbox/codegen/index.d.ts +1 -0
- package/dist/cjs/types/sandbox/filesystem/filesystem.d.ts +5 -1
- package/dist/cjs/types/sandbox/index.d.ts +2 -1
- package/dist/cjs/types/sandbox/sandbox.d.ts +2 -0
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/sandbox/client/sdk.gen.js +173 -36
- package/dist/cjs-browser/sandbox/codegen/codegen.js +31 -0
- package/dist/cjs-browser/sandbox/codegen/index.js +17 -0
- package/dist/cjs-browser/sandbox/filesystem/filesystem.js +28 -1
- package/dist/cjs-browser/sandbox/index.js +4 -1
- package/dist/cjs-browser/sandbox/sandbox.js +4 -1
- package/dist/cjs-browser/types/sandbox/client/sdk.gen.d.ts +74 -13
- package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +203 -50
- package/dist/cjs-browser/types/sandbox/codegen/codegen.d.ts +8 -0
- package/dist/cjs-browser/types/sandbox/codegen/index.d.ts +1 -0
- package/dist/cjs-browser/types/sandbox/filesystem/filesystem.d.ts +5 -1
- package/dist/cjs-browser/types/sandbox/index.d.ts +2 -1
- package/dist/cjs-browser/types/sandbox/sandbox.d.ts +2 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/sandbox/client/sdk.gen.js +164 -33
- package/dist/esm/sandbox/codegen/codegen.js +27 -0
- package/dist/esm/sandbox/codegen/index.js +1 -0
- package/dist/esm/sandbox/filesystem/filesystem.js +28 -1
- package/dist/esm/sandbox/index.js +2 -1
- package/dist/esm/sandbox/sandbox.js +4 -1
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/common/settings.js +2 -2
- package/dist/esm-browser/sandbox/client/sdk.gen.js +164 -33
- package/dist/esm-browser/sandbox/codegen/codegen.js +27 -0
- package/dist/esm-browser/sandbox/codegen/index.js +1 -0
- package/dist/esm-browser/sandbox/filesystem/filesystem.js +28 -1
- package/dist/esm-browser/sandbox/index.js +2 -1
- package/dist/esm-browser/sandbox/sandbox.js +4 -1
- package/package.json +2 -2
|
@@ -1,5 +1,168 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
import { client as _heyApiClient } from "./client.gen.js";
|
|
3
|
+
/**
|
|
4
|
+
* Welcome message
|
|
5
|
+
* Returns a welcome message with links to documentation
|
|
6
|
+
*/
|
|
7
|
+
export const delete_ = (options) => {
|
|
8
|
+
return (options?.client ?? _heyApiClient).delete({
|
|
9
|
+
security: [
|
|
10
|
+
{
|
|
11
|
+
scheme: 'bearer',
|
|
12
|
+
type: 'http'
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
url: '/',
|
|
16
|
+
...options
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Welcome message
|
|
21
|
+
* Returns a welcome message with links to documentation
|
|
22
|
+
*/
|
|
23
|
+
export const get = (options) => {
|
|
24
|
+
return (options?.client ?? _heyApiClient).get({
|
|
25
|
+
security: [
|
|
26
|
+
{
|
|
27
|
+
scheme: 'bearer',
|
|
28
|
+
type: 'http'
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
url: '/',
|
|
32
|
+
...options
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Welcome message
|
|
37
|
+
* Returns a welcome message with links to documentation
|
|
38
|
+
*/
|
|
39
|
+
export const options = (options) => {
|
|
40
|
+
return (options?.client ?? _heyApiClient).options({
|
|
41
|
+
security: [
|
|
42
|
+
{
|
|
43
|
+
scheme: 'bearer',
|
|
44
|
+
type: 'http'
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
url: '/',
|
|
48
|
+
...options
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Welcome message
|
|
53
|
+
* Returns a welcome message with links to documentation
|
|
54
|
+
*/
|
|
55
|
+
export const patch = (options) => {
|
|
56
|
+
return (options?.client ?? _heyApiClient).patch({
|
|
57
|
+
security: [
|
|
58
|
+
{
|
|
59
|
+
scheme: 'bearer',
|
|
60
|
+
type: 'http'
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
url: '/',
|
|
64
|
+
...options
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Welcome message
|
|
69
|
+
* Returns a welcome message with links to documentation
|
|
70
|
+
*/
|
|
71
|
+
export const post = (options) => {
|
|
72
|
+
return (options?.client ?? _heyApiClient).post({
|
|
73
|
+
security: [
|
|
74
|
+
{
|
|
75
|
+
scheme: 'bearer',
|
|
76
|
+
type: 'http'
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
url: '/',
|
|
80
|
+
...options
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Welcome message
|
|
85
|
+
* Returns a welcome message with links to documentation
|
|
86
|
+
*/
|
|
87
|
+
export const put = (options) => {
|
|
88
|
+
return (options?.client ?? _heyApiClient).put({
|
|
89
|
+
security: [
|
|
90
|
+
{
|
|
91
|
+
scheme: 'bearer',
|
|
92
|
+
type: 'http'
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
url: '/',
|
|
96
|
+
...options
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Apply code edit
|
|
101
|
+
* Uses the configured LLM provider (Relace or Morph) to apply a code edit to the original content.
|
|
102
|
+
*
|
|
103
|
+
* To use this endpoint as an agent tool, follow these guidelines:
|
|
104
|
+
*
|
|
105
|
+
* Use this tool to make an edit to an existing file. This will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.
|
|
106
|
+
*
|
|
107
|
+
* When writing the edit, you should specify each edit in sequence, with the special comment "// ... existing code ..." to represent unchanged code in between edited lines.
|
|
108
|
+
*
|
|
109
|
+
* Example format:
|
|
110
|
+
* // ... existing code ...
|
|
111
|
+
* FIRST_EDIT
|
|
112
|
+
* // ... existing code ...
|
|
113
|
+
* SECOND_EDIT
|
|
114
|
+
* // ... existing code ...
|
|
115
|
+
* THIRD_EDIT
|
|
116
|
+
* // ... existing code ...
|
|
117
|
+
*
|
|
118
|
+
* You should still bias towards repeating as few lines of the original file as possible to convey the change. But, each edit should contain minimally sufficient context of unchanged lines around the code you're editing to resolve ambiguity.
|
|
119
|
+
*
|
|
120
|
+
* DO NOT omit spans of pre-existing code (or comments) without using the "// ... existing code ..." comment to indicate its absence. If you omit the existing code comment, the model may inadvertently delete these lines.
|
|
121
|
+
*
|
|
122
|
+
* If you plan on deleting a section, you must provide context before and after to delete it. If the initial code is "Block 1\nBlock 2\nBlock 3", and you want to remove Block 2, you would output "// ... existing code ...\nBlock 1\nBlock 3\n// ... existing code ...".
|
|
123
|
+
*
|
|
124
|
+
* Make sure it is clear what the edit should be, and where it should be applied. Make edits to a file in a single edit_file call instead of multiple edit_file calls to the same file. The apply model can handle many distinct edits at once.
|
|
125
|
+
*/
|
|
126
|
+
export const putCodegenFastapplyByPath = (options) => {
|
|
127
|
+
return (options.client ?? _heyApiClient).put({
|
|
128
|
+
security: [
|
|
129
|
+
{
|
|
130
|
+
scheme: 'bearer',
|
|
131
|
+
type: 'http'
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
url: '/codegen/fastapply/{path}',
|
|
135
|
+
...options,
|
|
136
|
+
headers: {
|
|
137
|
+
'Content-Type': 'application/json',
|
|
138
|
+
...options?.headers
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Code reranking/semantic search
|
|
144
|
+
* Uses Relace's code reranking model to find the most relevant files for a given query. This is useful as a first pass in agentic exploration to narrow down the search space.
|
|
145
|
+
*
|
|
146
|
+
* Based on: https://docs.relace.ai/docs/code-reranker/agent
|
|
147
|
+
*
|
|
148
|
+
* Query Construction: The query can be a short question or a more detailed conversation with the user request included. For a first pass, use the full conversation; for subsequent calls, use more targeted questions.
|
|
149
|
+
*
|
|
150
|
+
* Token Limit and Score Threshold: For 200k token context models like Claude 4 Sonnet, recommended defaults are scoreThreshold=0.5 and tokenLimit=30000.
|
|
151
|
+
*
|
|
152
|
+
* The response will be a list of file paths and contents ordered from most relevant to least relevant.
|
|
153
|
+
*/
|
|
154
|
+
export const getCodegenRerankingByPath = (options) => {
|
|
155
|
+
return (options.client ?? _heyApiClient).get({
|
|
156
|
+
security: [
|
|
157
|
+
{
|
|
158
|
+
scheme: 'bearer',
|
|
159
|
+
type: 'http'
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
url: '/codegen/reranking/{path}',
|
|
163
|
+
...options
|
|
164
|
+
});
|
|
165
|
+
};
|
|
3
166
|
/**
|
|
4
167
|
* Delete file or directory
|
|
5
168
|
* Delete a file or directory
|
|
@@ -18,7 +181,7 @@ export const deleteFilesystemByPath = (options) => {
|
|
|
18
181
|
};
|
|
19
182
|
/**
|
|
20
183
|
* Get file or directory information
|
|
21
|
-
* Get content of a file or listing of a directory
|
|
184
|
+
* Get content of a file or listing of a directory. Use Accept header to control response format for files.
|
|
22
185
|
*/
|
|
23
186
|
export const getFilesystemByPath = (options) => {
|
|
24
187
|
return (options.client ?? _heyApiClient).get({
|
|
@@ -236,35 +399,3 @@ export const getWatchFilesystemByPath = (options) => {
|
|
|
236
399
|
...options
|
|
237
400
|
});
|
|
238
401
|
};
|
|
239
|
-
/**
|
|
240
|
-
* Stream process logs in real time via WebSocket
|
|
241
|
-
* Streams the stdout and stderr output of a process in real time as JSON messages.
|
|
242
|
-
*/
|
|
243
|
-
export const getWsProcessByIdentifierLogsStream = (options) => {
|
|
244
|
-
return (options.client ?? _heyApiClient).get({
|
|
245
|
-
security: [
|
|
246
|
-
{
|
|
247
|
-
scheme: 'bearer',
|
|
248
|
-
type: 'http'
|
|
249
|
-
}
|
|
250
|
-
],
|
|
251
|
-
url: '/ws/process/{identifier}/logs/stream',
|
|
252
|
-
...options
|
|
253
|
-
});
|
|
254
|
-
};
|
|
255
|
-
/**
|
|
256
|
-
* Stream file modification events in a directory via WebSocket
|
|
257
|
-
* Streams JSON events of modified files in the given directory. Closes when the client disconnects.
|
|
258
|
-
*/
|
|
259
|
-
export const getWsWatchFilesystemByPath = (options) => {
|
|
260
|
-
return (options.client ?? _heyApiClient).get({
|
|
261
|
-
security: [
|
|
262
|
-
{
|
|
263
|
-
scheme: 'bearer',
|
|
264
|
-
type: 'http'
|
|
265
|
-
}
|
|
266
|
-
],
|
|
267
|
-
url: '/ws/watch/filesystem/{path}',
|
|
268
|
-
...options
|
|
269
|
-
});
|
|
270
|
-
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SandboxAction } from "../action.js";
|
|
2
|
+
import { getCodegenRerankingByPath, putCodegenFastapplyByPath } from "../client/sdk.gen.js";
|
|
3
|
+
export class SandboxCodegen extends SandboxAction {
|
|
4
|
+
constructor(sandbox) {
|
|
5
|
+
super(sandbox);
|
|
6
|
+
}
|
|
7
|
+
async fastapply(path, codeEdit, model) {
|
|
8
|
+
const result = await putCodegenFastapplyByPath({
|
|
9
|
+
path: { path },
|
|
10
|
+
body: { codeEdit, model },
|
|
11
|
+
baseUrl: this.url,
|
|
12
|
+
client: this.client,
|
|
13
|
+
});
|
|
14
|
+
this.handleResponseError(result.response, result.data, result.error);
|
|
15
|
+
return result.data;
|
|
16
|
+
}
|
|
17
|
+
async reranking(path, query, scoreThreshold, tokenLimit, filePattern) {
|
|
18
|
+
const result = await getCodegenRerankingByPath({
|
|
19
|
+
path: { path },
|
|
20
|
+
query: { query, scoreThreshold, tokenLimit, filePattern },
|
|
21
|
+
baseUrl: this.url,
|
|
22
|
+
client: this.client,
|
|
23
|
+
});
|
|
24
|
+
this.handleResponseError(result.response, result.data, result.error);
|
|
25
|
+
return result.data;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./codegen.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { settings } from "../../common/settings.js";
|
|
2
2
|
import { SandboxAction } from "../action.js";
|
|
3
3
|
import { deleteFilesystemByPath, getFilesystemByPath, getWatchFilesystemByPath, putFilesystemByPath } from "../client/index.js";
|
|
4
|
+
import { readFile, writeFile } from "fs/promises";
|
|
4
5
|
export class SandboxFileSystem extends SandboxAction {
|
|
5
6
|
process;
|
|
6
7
|
constructor(sandbox, process) {
|
|
@@ -46,6 +47,10 @@ export class SandboxFileSystem extends SandboxAction {
|
|
|
46
47
|
// Convert Uint8Array to Blob
|
|
47
48
|
fileBlob = new Blob([content]);
|
|
48
49
|
}
|
|
50
|
+
else if (typeof content === 'string') {
|
|
51
|
+
const buffer = await readFile(content);
|
|
52
|
+
fileBlob = new Blob([buffer]);
|
|
53
|
+
}
|
|
49
54
|
else {
|
|
50
55
|
throw new Error("Unsupported content type");
|
|
51
56
|
}
|
|
@@ -107,6 +112,28 @@ export class SandboxFileSystem extends SandboxAction {
|
|
|
107
112
|
}
|
|
108
113
|
throw new Error("Unsupported file type");
|
|
109
114
|
}
|
|
115
|
+
async readBinary(path) {
|
|
116
|
+
path = this.formatPath(path);
|
|
117
|
+
const { response, data, error } = await getFilesystemByPath({
|
|
118
|
+
path: { path },
|
|
119
|
+
baseUrl: this.url,
|
|
120
|
+
client: this.client,
|
|
121
|
+
headers: {
|
|
122
|
+
'Accept': 'application/octet-stream',
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
this.handleResponseError(response, data, error);
|
|
126
|
+
if (typeof data === 'string') {
|
|
127
|
+
return new Blob([data]);
|
|
128
|
+
}
|
|
129
|
+
return data;
|
|
130
|
+
}
|
|
131
|
+
async download(src, destinationPath, { mode = 0o644 } = {}) {
|
|
132
|
+
const blob = await this.readBinary(src);
|
|
133
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
134
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
135
|
+
await writeFile(destinationPath, buffer, { mode: mode ?? 0o644 });
|
|
136
|
+
}
|
|
110
137
|
async rm(path, recursive = false) {
|
|
111
138
|
path = this.formatPath(path);
|
|
112
139
|
const { response, data, error } = await deleteFilesystemByPath({
|
|
@@ -197,7 +224,7 @@ export class SandboxFileSystem extends SandboxAction {
|
|
|
197
224
|
filePath = fileEvent.path + "/" + fileEvent.name;
|
|
198
225
|
}
|
|
199
226
|
const content = await this.read(filePath);
|
|
200
|
-
await callback({ ...fileEvent, content });
|
|
227
|
+
await callback({ ...fileEvent, content: content });
|
|
201
228
|
}
|
|
202
229
|
catch {
|
|
203
230
|
await callback({ ...fileEvent, content: undefined });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export {
|
|
2
2
|
/* Export SDK functions */
|
|
3
|
-
deleteFilesystemByPath, deleteNetworkProcessByPidMonitor, deleteProcessByIdentifier, deleteProcessByIdentifierKill, getFilesystemByPath, getNetworkProcessByPidPorts, getProcess, getProcessByIdentifier, getProcessByIdentifierLogs, getProcessByIdentifierLogsStream, postNetworkProcessByPidMonitor, postProcess, putFilesystemByPath } from "./client/index.js";
|
|
3
|
+
deleteFilesystemByPath, deleteNetworkProcessByPidMonitor, deleteProcessByIdentifier, deleteProcessByIdentifierKill, getFilesystemByPath, getNetworkProcessByPidPorts, putCodegenFastapplyByPath, getCodegenRerankingByPath, getProcess, getProcessByIdentifier, getProcessByIdentifierLogs, getProcessByIdentifierLogsStream, postNetworkProcessByPidMonitor, postProcess, putFilesystemByPath } from "./client/index.js";
|
|
4
4
|
export * from "./filesystem/index.js";
|
|
5
|
+
export * from "./codegen/index.js";
|
|
5
6
|
export * from "./sandbox.js";
|
|
6
7
|
export * from "./types.js";
|
|
7
8
|
// Re-export everything from client except ClientOptions to avoid conflict
|
|
@@ -5,6 +5,7 @@ import { SandboxFileSystem } from "./filesystem/index.js";
|
|
|
5
5
|
import { SandboxNetwork } from "./network/index.js";
|
|
6
6
|
import { SandboxPreviews } from "./preview.js";
|
|
7
7
|
import { SandboxProcess } from "./process/index.js";
|
|
8
|
+
import { SandboxCodegen } from "./codegen/index.js";
|
|
8
9
|
import { SandboxSessions } from "./session.js";
|
|
9
10
|
import { normalizeEnvs, normalizePorts, normalizeVolumes } from "./types.js";
|
|
10
11
|
export class SandboxInstance {
|
|
@@ -14,6 +15,7 @@ export class SandboxInstance {
|
|
|
14
15
|
process;
|
|
15
16
|
previews;
|
|
16
17
|
sessions;
|
|
18
|
+
codegen;
|
|
17
19
|
constructor(sandbox) {
|
|
18
20
|
this.sandbox = sandbox;
|
|
19
21
|
this.process = new SandboxProcess(sandbox);
|
|
@@ -21,6 +23,7 @@ export class SandboxInstance {
|
|
|
21
23
|
this.network = new SandboxNetwork(sandbox);
|
|
22
24
|
this.previews = new SandboxPreviews(sandbox);
|
|
23
25
|
this.sessions = new SandboxSessions(sandbox);
|
|
26
|
+
this.codegen = new SandboxCodegen(sandbox);
|
|
24
27
|
}
|
|
25
28
|
get metadata() {
|
|
26
29
|
return this.sandbox.metadata;
|
|
@@ -41,7 +44,7 @@ export class SandboxInstance {
|
|
|
41
44
|
}
|
|
42
45
|
static async create(sandbox, { safe = true } = {}) {
|
|
43
46
|
const defaultName = `sandbox-${uuidv4().replace(/-/g, '').substring(0, 8)}`;
|
|
44
|
-
const defaultImage = `blaxel/base:latest`;
|
|
47
|
+
const defaultImage = `blaxel/base-image:latest`;
|
|
45
48
|
const defaultMemory = 4096;
|
|
46
49
|
// Handle SandboxCreateConfiguration or simple dict with name/image/memory/ports/envs/volumes keys
|
|
47
50
|
if (!sandbox ||
|