veryfront 0.1.576 → 0.1.578
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/esm/deno.js +1 -1
- package/esm/src/proxy/handler.d.ts.map +1 -1
- package/esm/src/proxy/handler.js +4 -1
- package/esm/src/sandbox/agent-service-tools.d.ts +10 -10
- package/esm/src/sandbox/agent-service-tools.d.ts.map +1 -1
- package/esm/src/sandbox/agent-service-tools.js +24 -24
- package/esm/src/sandbox/index.d.ts +2 -2
- package/esm/src/sandbox/index.d.ts.map +1 -1
- package/esm/src/sandbox/lazy-sandbox.d.ts +9 -9
- package/esm/src/sandbox/lazy-sandbox.d.ts.map +1 -1
- package/esm/src/sandbox/lazy-sandbox.js +44 -43
- package/esm/src/sandbox/sandbox.d.ts +13 -13
- package/esm/src/sandbox/sandbox.d.ts.map +1 -1
- package/esm/src/sandbox/sandbox.js +27 -27
- package/esm/src/sandbox/types.d.ts +10 -10
- package/esm/src/sandbox/types.d.ts.map +1 -1
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/src/proxy/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,kCAAkC,CAAC;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAuCnD;;;;;GAKG;AACH,wBAAgB,iCAAiC,IAAI,IAAI,CAExD;AAED,eAAO,MAAM,sBAAsB,0MAYzB,CAAC;AAqHX,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,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E,OAAO,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAwB7E"}
|
package/esm/src/proxy/handler.js
CHANGED
|
@@ -288,7 +288,10 @@ export function createProxyHandler(options) {
|
|
|
288
288
|
if (!returnPath.startsWith("/") || returnPath.includes("://")) {
|
|
289
289
|
returnPath = "/";
|
|
290
290
|
}
|
|
291
|
-
|
|
291
|
+
const isHostedProductionDeployment = url.hostname.endsWith(".production.veryfront.org") ||
|
|
292
|
+
url.hostname.endsWith(".production.veryfront.com");
|
|
293
|
+
const returnTarget = isHostedProductionDeployment ? url.toString() : returnPath;
|
|
294
|
+
return `https://veryfront.com/sign-in?from=${encodeURIComponent(returnTarget)}`;
|
|
292
295
|
}
|
|
293
296
|
function makeProjectNotFoundContext(base, message, token) {
|
|
294
297
|
return makeErrorContext(base, 404, message, token, undefined, "project-not-found");
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BackgroundCommand, BackgroundCommandOutput, ExecOptions } from "./sandbox.js";
|
|
2
2
|
import { type LazySandboxOptions } from "./lazy-sandbox.js";
|
|
3
3
|
import { type BashToolSandboxLike, type CreateSandboxBashTool, type SandboxShellToolSet } from "./shell-tools.js";
|
|
4
|
-
/** Public API contract for agent service sandbox
|
|
5
|
-
export interface
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
/** Public API contract for agent service sandbox background command client. */
|
|
5
|
+
export interface AgentServiceSandboxBackgroundCommandClient {
|
|
6
|
+
startBackgroundCommand(command: string): Promise<BackgroundCommand>;
|
|
7
|
+
getBackgroundCommand(commandId: string): Promise<BackgroundCommand>;
|
|
8
|
+
getBackgroundCommandOutput(commandId: string): Promise<BackgroundCommandOutput>;
|
|
9
|
+
cancelBackgroundCommand(commandId: string): Promise<BackgroundCommand>;
|
|
10
10
|
}
|
|
11
11
|
/** Public API contract for agent service sandbox client. */
|
|
12
|
-
export interface AgentServiceSandboxClient extends BashToolSandboxLike,
|
|
12
|
+
export interface AgentServiceSandboxClient extends BashToolSandboxLike, AgentServiceSandboxBackgroundCommandClient {
|
|
13
13
|
ensure(): Promise<void>;
|
|
14
14
|
close(): Promise<void>;
|
|
15
15
|
readonly isActive: boolean;
|
|
@@ -38,8 +38,8 @@ export declare function createProjectScopedExecOptions(projectReference: string
|
|
|
38
38
|
export declare function createAgentServiceSandboxClient(input?: AgentServiceSandboxClientOptions): AgentServiceSandboxClient;
|
|
39
39
|
/** Create agent service sandbox tools. */
|
|
40
40
|
export declare function createAgentServiceSandboxTools(input: AgentServiceSandboxToolsOptions): Promise<AgentServiceSandboxToolsResult>;
|
|
41
|
-
/** Public API contract for hosted sandbox
|
|
42
|
-
export type
|
|
41
|
+
/** Public API contract for hosted sandbox background command client. */
|
|
42
|
+
export type HostedSandboxBackgroundCommandClient = AgentServiceSandboxBackgroundCommandClient;
|
|
43
43
|
/** Public API contract for hosted sandbox client. */
|
|
44
44
|
export type HostedSandboxClient = AgentServiceSandboxClient;
|
|
45
45
|
/** Options accepted by hosted sandbox client. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-service-tools.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/agent-service-tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"agent-service-tools.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/agent-service-tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAE1B,KAAK,mBAAmB,EACzB,MAAM,kBAAkB,CAAC;AAM1B,+EAA+E;AAC/E,MAAM,WAAW,0CAA0C;IACzD,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAA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AsB,8BAA8B,CAClD,KAAK,EAAE,+BAA+B,GACrC,OAAO,CAAC,8BAA8B,CAAC,CAoCzC;AAED,wEAAwE;AACxE,MAAM,MAAM,oCAAoC,GAAG,0CAA0C,CAAC;AAC9F,qDAAqD;AACrD,MAAM,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAC5D,iDAAiD;AACjD,MAAM,MAAM,0BAA0B,GAAG,gCAAgC,CAAC;AAC1E,gDAAgD;AAChD,MAAM,MAAM,yBAAyB,GAAG,+BAA+B,CAAC;AACxE,iDAAiD;AACjD,MAAM,MAAM,wBAAwB,GAAG,8BAA8B,CAAC;AAEtE,oCAAoC;AACpC,eAAO,MAAM,yBAAyB,wCAAkC,CAAC;AACzE,mCAAmC;AACnC,eAAO,MAAM,wBAAwB,uCAAiC,CAAC"}
|
|
@@ -42,7 +42,7 @@ export function createAgentServiceSandboxClient(input = {}) {
|
|
|
42
42
|
const getProjectId = input.getProjectId ?? (() => input.projectId);
|
|
43
43
|
const sandbox = new LazySandbox({ ...input, getProjectId });
|
|
44
44
|
const getExecOptions = () => createProjectScopedExecOptions(getProjectId());
|
|
45
|
-
const
|
|
45
|
+
const getBackgroundCommandExecOptions = () => ({
|
|
46
46
|
...getExecOptions(),
|
|
47
47
|
cwd: SANDBOX_WORKING_DIRECTORY,
|
|
48
48
|
});
|
|
@@ -53,10 +53,10 @@ export function createAgentServiceSandboxClient(input = {}) {
|
|
|
53
53
|
},
|
|
54
54
|
readFile: (path) => sandbox.readFile(path),
|
|
55
55
|
writeFiles: (files) => sandbox.writeFiles(files.map((file) => normalizeSandboxWriteFile(file))),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
startBackgroundCommand: (command) => sandbox.startBackgroundCommand(unwrapSandboxWorkingDirectoryCommand(command), getBackgroundCommandExecOptions()),
|
|
57
|
+
getBackgroundCommand: (commandId) => sandbox.getBackgroundCommand(commandId),
|
|
58
|
+
getBackgroundCommandOutput: (commandId) => sandbox.getBackgroundCommandOutput(commandId),
|
|
59
|
+
cancelBackgroundCommand: (commandId) => sandbox.cancelBackgroundCommand(commandId),
|
|
60
60
|
close: () => sandbox.close(),
|
|
61
61
|
get isActive() {
|
|
62
62
|
return sandbox.isActive;
|
|
@@ -69,11 +69,11 @@ export function createAgentServiceSandboxClient(input = {}) {
|
|
|
69
69
|
},
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
const
|
|
72
|
+
const getStartBackgroundCommandInputSchema = defineSchema((v) => v.object({
|
|
73
73
|
command: v.string().describe("Single shell command to run asynchronously in the sandbox"),
|
|
74
74
|
}));
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
const getBackgroundCommandIdInputSchema = defineSchema((v) => v.object({
|
|
76
|
+
commandId: v.string().describe("Sandbox background command ID"),
|
|
77
77
|
}));
|
|
78
78
|
/** Create agent service sandbox tools. */
|
|
79
79
|
export async function createAgentServiceSandboxTools(input) {
|
|
@@ -81,25 +81,25 @@ export async function createAgentServiceSandboxTools(input) {
|
|
|
81
81
|
const shellTools = await createSandboxShellTools(sandbox, input.createBashTool);
|
|
82
82
|
const tools = {
|
|
83
83
|
...shellTools,
|
|
84
|
-
|
|
85
|
-
description: "Start a long-running sandbox command as an async
|
|
86
|
-
inputSchema:
|
|
87
|
-
execute: async ({ command }) => await sandbox.
|
|
84
|
+
start_background_command: tool({
|
|
85
|
+
description: "Start a long-running sandbox command as an async background command. Use this instead of bash for durable shell operations.",
|
|
86
|
+
inputSchema: getStartBackgroundCommandInputSchema(),
|
|
87
|
+
execute: async ({ command }) => await sandbox.startBackgroundCommand(command),
|
|
88
88
|
}),
|
|
89
|
-
|
|
90
|
-
description: "Get the current status for an async sandbox command
|
|
91
|
-
inputSchema:
|
|
92
|
-
execute: async ({
|
|
89
|
+
get_background_command: tool({
|
|
90
|
+
description: "Get the current status for an async sandbox background command. Use this for polling while a long-running command is still running.",
|
|
91
|
+
inputSchema: getBackgroundCommandIdInputSchema(),
|
|
92
|
+
execute: async ({ commandId }) => await sandbox.getBackgroundCommand(commandId),
|
|
93
93
|
}),
|
|
94
|
-
|
|
95
|
-
description: "Get the captured stdout/stderr and terminal metadata for an async sandbox command
|
|
96
|
-
inputSchema:
|
|
97
|
-
execute: async ({
|
|
94
|
+
get_background_command_output: tool({
|
|
95
|
+
description: "Get the captured stdout/stderr and terminal metadata for an async sandbox background command. Prefer calling this after the command reaches a terminal state.",
|
|
96
|
+
inputSchema: getBackgroundCommandIdInputSchema(),
|
|
97
|
+
execute: async ({ commandId }) => await sandbox.getBackgroundCommandOutput(commandId),
|
|
98
98
|
}),
|
|
99
|
-
|
|
100
|
-
description: "Cancel a running async sandbox command
|
|
101
|
-
inputSchema:
|
|
102
|
-
execute: async ({
|
|
99
|
+
cancel_background_command: tool({
|
|
100
|
+
description: "Cancel a running async sandbox background command.",
|
|
101
|
+
inputSchema: getBackgroundCommandIdInputSchema(),
|
|
102
|
+
execute: async ({ commandId }) => await sandbox.cancelBackgroundCommand(commandId),
|
|
103
103
|
}),
|
|
104
104
|
};
|
|
105
105
|
return {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
19
|
import "../../_dnt.polyfills.js";
|
|
20
|
-
export { type
|
|
20
|
+
export { type BackgroundCommand, type BackgroundCommandHeartbeatStatus, type BackgroundCommandOutput, type BackgroundCommandStatus, type ExecOptions, type ExecResult, type ExecStreamEvent, Sandbox, type SandboxAttachment, type SandboxListOptions, type SandboxListResult, type SandboxOptions, type SandboxSession, } from "./sandbox.js";
|
|
21
21
|
export { LazySandbox, type LazySandboxOptions, resolveDefaultSandboxRuntimeEndpoint, } from "./lazy-sandbox.js";
|
|
22
22
|
export { type BashToolSandboxLike, type CreateSandboxBashTool, createSandboxShellTools, normalizeBashToolSet, renameSandboxFileTools, type SandboxShellToolDefinition, type SandboxShellToolSet, } from "./shell-tools.js";
|
|
23
|
-
export { type
|
|
23
|
+
export { type AgentServiceSandboxBackgroundCommandClient, type AgentServiceSandboxClient, type AgentServiceSandboxClientOptions, type AgentServiceSandboxToolsOptions, type AgentServiceSandboxToolsResult, createAgentServiceSandboxClient, createAgentServiceSandboxTools, createHostedSandboxClient, createHostedSandboxTools, createProjectScopedExecOptions, type HostedSandboxBackgroundCommandClient, type HostedSandboxClient, type HostedSandboxClientOptions, type HostedSandboxToolsOptions, type HostedSandboxToolsResult, unwrapSandboxWorkingDirectoryCommand, } from "./agent-service-tools.js";
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,yBAAyB,CAAC;AAGjC,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,yBAAyB,CAAC;AAGjC,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,gCAAgC,EACrC,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,OAAO,EACP,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,KAAK,kBAAkB,EACvB,oCAAoC,GACrC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,0CAA0C,EAC/C,KAAK,yBAAyB,EAC9B,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,KAAK,8BAA8B,EACnC,+BAA+B,EAC/B,8BAA8B,EAC9B,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC9B,KAAK,oCAAoC,EACzC,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,oCAAoC,GACrC,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type BackgroundCommand, type BackgroundCommandOutput, type ExecOptions, type ExecResult, type ExecStreamEvent, type SandboxOptions } from "./types.js";
|
|
2
2
|
/** Options accepted by lazy sandbox. */
|
|
3
3
|
export interface LazySandboxOptions extends SandboxOptions {
|
|
4
4
|
getProjectId?: () => string | null | undefined;
|
|
@@ -41,7 +41,7 @@ export declare class LazySandbox {
|
|
|
41
41
|
private heartbeatPromise;
|
|
42
42
|
private heartbeatTimer;
|
|
43
43
|
private lastHeartbeatAt;
|
|
44
|
-
private readonly
|
|
44
|
+
private readonly activeBackgroundCommandEndpoints;
|
|
45
45
|
constructor(options?: LazySandboxOptions);
|
|
46
46
|
ensure(): Promise<void>;
|
|
47
47
|
executeCommand(command: string, options?: ExecOptions): Promise<ExecResult>;
|
|
@@ -51,11 +51,11 @@ export declare class LazySandbox {
|
|
|
51
51
|
path: string;
|
|
52
52
|
content: string;
|
|
53
53
|
}>): Promise<void>;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
startBackgroundCommand(command: string, options?: ExecOptions): Promise<BackgroundCommand>;
|
|
55
|
+
getBackgroundCommand(commandId: string): Promise<BackgroundCommand>;
|
|
56
|
+
getBackgroundCommandOutput(commandId: string): Promise<BackgroundCommandOutput>;
|
|
57
|
+
listBackgroundCommands(): Promise<BackgroundCommand[]>;
|
|
58
|
+
cancelBackgroundCommand(commandId: string): Promise<BackgroundCommand>;
|
|
59
59
|
heartbeat(force?: boolean): Promise<void>;
|
|
60
60
|
close(): Promise<void>;
|
|
61
61
|
get id(): string | null;
|
|
@@ -72,8 +72,8 @@ export declare class LazySandbox {
|
|
|
72
72
|
private resolveProjectId;
|
|
73
73
|
private resetSessionState;
|
|
74
74
|
private resolveExecOptions;
|
|
75
|
-
private
|
|
76
|
-
private
|
|
75
|
+
private resolveBackgroundCommandEndpoint;
|
|
76
|
+
private updateTrackedBackgroundCommand;
|
|
77
77
|
private startExec;
|
|
78
78
|
private fetchExecStart;
|
|
79
79
|
private fetchControl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-sandbox.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/lazy-sandbox.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"lazy-sandbox.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/lazy-sandbox.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAE5B,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAEpB,wCAAwC;AACxC,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,YAAY,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,sBAAsB,CAAC,EAAE,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,gCAAgC;IAU9C,OAAO,CAAC,8BAA8B;YAmBxB,SAAS;YAkCT,cAAc;YAId,YAAY;IAI1B,OAAO,CAAC,qBAAqB;YAIf,gCAAgC;IAQ9C,OAAO,CAAC,sBAAsB;IAO9B,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,WAAW;CAMpB"}
|
|
@@ -58,7 +58,7 @@ export class LazySandbox {
|
|
|
58
58
|
heartbeatPromise = null;
|
|
59
59
|
heartbeatTimer = null;
|
|
60
60
|
lastHeartbeatAt = 0;
|
|
61
|
-
|
|
61
|
+
activeBackgroundCommandEndpoints = new Map();
|
|
62
62
|
constructor(options = {}) {
|
|
63
63
|
this.apiUrl = resolveSandboxApiUrl(options);
|
|
64
64
|
this.authToken = resolveSandboxAuthToken(options);
|
|
@@ -172,86 +172,86 @@ export class LazySandbox {
|
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
async
|
|
175
|
+
async startBackgroundCommand(command, options) {
|
|
176
176
|
await this.touchSession();
|
|
177
177
|
const endpoint = this.resolveRuntimeEndpoint();
|
|
178
|
-
const res = await this.fetchControl(`${endpoint}/exec/
|
|
178
|
+
const res = await this.fetchControl(`${endpoint}/exec/commands`, {
|
|
179
179
|
method: "POST",
|
|
180
180
|
headers: this.jsonHeaders(),
|
|
181
181
|
body: JSON.stringify({ command, ...this.resolveExecOptions(options) }),
|
|
182
182
|
});
|
|
183
183
|
if (!res.ok) {
|
|
184
184
|
throw REQUEST_ERROR.create({
|
|
185
|
-
detail: `Start command
|
|
185
|
+
detail: `Start background command failed: ${res.status} ${await res.text()}`,
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
|
-
const
|
|
189
|
-
this.
|
|
190
|
-
return
|
|
188
|
+
const backgroundCommand = mapBackgroundCommand(await res.json());
|
|
189
|
+
this.updateTrackedBackgroundCommand(backgroundCommand, endpoint);
|
|
190
|
+
return backgroundCommand;
|
|
191
191
|
}
|
|
192
|
-
async
|
|
193
|
-
const endpoint = await this.
|
|
194
|
-
const res = await this.fetchControl(`${endpoint}/exec/
|
|
192
|
+
async getBackgroundCommand(commandId) {
|
|
193
|
+
const endpoint = await this.resolveBackgroundCommandEndpoint(commandId);
|
|
194
|
+
const res = await this.fetchControl(`${endpoint}/exec/commands/${commandId}`, {
|
|
195
195
|
headers: this.authHeaders(),
|
|
196
196
|
});
|
|
197
197
|
if (!res.ok) {
|
|
198
198
|
throw REQUEST_ERROR.create({
|
|
199
|
-
detail: `Get command
|
|
199
|
+
detail: `Get background command failed: ${res.status} ${await res.text()}`,
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
|
-
const
|
|
203
|
-
this.
|
|
204
|
-
return
|
|
202
|
+
const backgroundCommand = mapBackgroundCommand(await res.json());
|
|
203
|
+
this.updateTrackedBackgroundCommand(backgroundCommand, endpoint);
|
|
204
|
+
return backgroundCommand;
|
|
205
205
|
}
|
|
206
|
-
async
|
|
207
|
-
const endpoint = await this.
|
|
208
|
-
const res = await this.fetchControl(`${endpoint}/exec/
|
|
206
|
+
async getBackgroundCommandOutput(commandId) {
|
|
207
|
+
const endpoint = await this.resolveBackgroundCommandEndpoint(commandId);
|
|
208
|
+
const res = await this.fetchControl(`${endpoint}/exec/commands/${commandId}/output`, {
|
|
209
209
|
headers: this.authHeaders(),
|
|
210
210
|
});
|
|
211
211
|
if (!res.ok) {
|
|
212
212
|
throw REQUEST_ERROR.create({
|
|
213
|
-
detail: `Get command
|
|
213
|
+
detail: `Get background command output failed: ${res.status} ${await res.text()}`,
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
const json = await res.json();
|
|
217
217
|
const output = {
|
|
218
|
-
...
|
|
218
|
+
...mapBackgroundCommand(json),
|
|
219
219
|
stdout: json.stdout,
|
|
220
220
|
stderr: json.stderr,
|
|
221
221
|
stdoutTruncated: json.stdout_truncated,
|
|
222
222
|
stderrTruncated: json.stderr_truncated,
|
|
223
223
|
};
|
|
224
|
-
this.
|
|
224
|
+
this.updateTrackedBackgroundCommand(output, endpoint);
|
|
225
225
|
return output;
|
|
226
226
|
}
|
|
227
|
-
async
|
|
227
|
+
async listBackgroundCommands() {
|
|
228
228
|
await this.ensure();
|
|
229
|
-
const res = await this.fetchControl(`${this.requireEndpoint()}/exec/
|
|
229
|
+
const res = await this.fetchControl(`${this.requireEndpoint()}/exec/commands`, {
|
|
230
230
|
headers: this.authHeaders(),
|
|
231
231
|
});
|
|
232
232
|
if (!res.ok) {
|
|
233
233
|
throw REQUEST_ERROR.create({
|
|
234
|
-
detail: `List
|
|
234
|
+
detail: `List background commands failed: ${res.status} ${await res.text()}`,
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
237
|
const json = await res.json();
|
|
238
|
-
const
|
|
239
|
-
return
|
|
238
|
+
const commands = Array.isArray(json) ? json : (json.commands ?? []);
|
|
239
|
+
return commands.map((command) => mapBackgroundCommand(command));
|
|
240
240
|
}
|
|
241
|
-
async
|
|
242
|
-
const endpoint = await this.
|
|
243
|
-
const res = await this.fetchControl(`${endpoint}/exec/
|
|
241
|
+
async cancelBackgroundCommand(commandId) {
|
|
242
|
+
const endpoint = await this.resolveBackgroundCommandEndpoint(commandId);
|
|
243
|
+
const res = await this.fetchControl(`${endpoint}/exec/commands/${commandId}/cancel`, {
|
|
244
244
|
method: "POST",
|
|
245
245
|
headers: this.authHeaders(),
|
|
246
246
|
});
|
|
247
247
|
if (!res.ok) {
|
|
248
248
|
throw REQUEST_ERROR.create({
|
|
249
|
-
detail: `Cancel command
|
|
249
|
+
detail: `Cancel background command failed: ${res.status} ${await res.text()}`,
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
|
-
const
|
|
253
|
-
this.
|
|
254
|
-
return
|
|
252
|
+
const backgroundCommand = mapBackgroundCommand(await res.json());
|
|
253
|
+
this.updateTrackedBackgroundCommand(backgroundCommand, endpoint);
|
|
254
|
+
return backgroundCommand;
|
|
255
255
|
}
|
|
256
256
|
async heartbeat(force = false) {
|
|
257
257
|
const currentSessionId = this.sessionId;
|
|
@@ -273,7 +273,7 @@ export class LazySandbox {
|
|
|
273
273
|
});
|
|
274
274
|
if (!res.ok) {
|
|
275
275
|
if (this.sessionId === currentSessionId) {
|
|
276
|
-
if (this.
|
|
276
|
+
if (this.activeBackgroundCommandEndpoints.size === 0) {
|
|
277
277
|
await this.deleteSession(currentSessionId);
|
|
278
278
|
this.resetSessionState(currentSessionId);
|
|
279
279
|
}
|
|
@@ -407,8 +407,9 @@ export class LazySandbox {
|
|
|
407
407
|
await this.heartbeat();
|
|
408
408
|
}
|
|
409
409
|
startHeartbeatLoop() {
|
|
410
|
-
if (!this.sessionId || this.heartbeatTimer || this.
|
|
410
|
+
if (!this.sessionId || this.heartbeatTimer || this.activeBackgroundCommandEndpoints.size > 0) {
|
|
411
411
|
return;
|
|
412
|
+
}
|
|
412
413
|
this.heartbeatTimer = dntShim.setInterval(() => {
|
|
413
414
|
void this.heartbeat().catch(() => {
|
|
414
415
|
// next operation will reprovision
|
|
@@ -439,7 +440,7 @@ export class LazySandbox {
|
|
|
439
440
|
resetSessionState(sessionId) {
|
|
440
441
|
if (!sessionId || this.sessionId === sessionId) {
|
|
441
442
|
this.stopHeartbeatLoop();
|
|
442
|
-
this.
|
|
443
|
+
this.activeBackgroundCommandEndpoints.clear();
|
|
443
444
|
this.endpoint = null;
|
|
444
445
|
this.sessionId = null;
|
|
445
446
|
this.sessionProjectId = null;
|
|
@@ -451,24 +452,24 @@ export class LazySandbox {
|
|
|
451
452
|
const projectReference = options?.projectReference ?? this.resolveProjectId() ?? undefined;
|
|
452
453
|
return projectReference ? { ...options, projectReference } : options;
|
|
453
454
|
}
|
|
454
|
-
async
|
|
455
|
-
const trackedEndpoint = this.
|
|
455
|
+
async resolveBackgroundCommandEndpoint(commandId) {
|
|
456
|
+
const trackedEndpoint = this.activeBackgroundCommandEndpoints.get(commandId);
|
|
456
457
|
if (trackedEndpoint) {
|
|
457
458
|
return trackedEndpoint;
|
|
458
459
|
}
|
|
459
460
|
await this.ensure();
|
|
460
461
|
return this.resolveRuntimeEndpoint();
|
|
461
462
|
}
|
|
462
|
-
|
|
463
|
-
if (
|
|
464
|
-
this.
|
|
463
|
+
updateTrackedBackgroundCommand(backgroundCommand, endpoint) {
|
|
464
|
+
if (backgroundCommand.status === "running") {
|
|
465
|
+
this.activeBackgroundCommandEndpoints.set(backgroundCommand.id, endpoint);
|
|
465
466
|
this.stopHeartbeatLoop();
|
|
466
467
|
return;
|
|
467
468
|
}
|
|
468
|
-
if (!this.
|
|
469
|
+
if (!this.activeBackgroundCommandEndpoints.delete(backgroundCommand.id)) {
|
|
469
470
|
return;
|
|
470
471
|
}
|
|
471
|
-
if (this.
|
|
472
|
+
if (this.activeBackgroundCommandEndpoints.size === 0 && this.endpoint) {
|
|
472
473
|
this.startHeartbeatLoop();
|
|
473
474
|
}
|
|
474
475
|
}
|
|
@@ -568,7 +569,7 @@ async function fetchWithTimeout(url, timeoutMs, init = {}) {
|
|
|
568
569
|
clearTimeout(timeout);
|
|
569
570
|
}
|
|
570
571
|
}
|
|
571
|
-
function
|
|
572
|
+
function mapBackgroundCommand(json) {
|
|
572
573
|
return {
|
|
573
574
|
id: json.id,
|
|
574
575
|
status: json.status,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LazySandbox, type LazySandboxOptions } from "./lazy-sandbox.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { BackgroundCommand, BackgroundCommandOutput, ExecOptions, ExecResult, ExecStreamEvent, SandboxAttachment, SandboxListOptions, SandboxListResult, SandboxOptions } from "./types.js";
|
|
3
3
|
export { resolveSandboxApiUrl, resolveSandboxAuthToken } from "./config.js";
|
|
4
|
-
export type {
|
|
4
|
+
export type { BackgroundCommand, BackgroundCommandHeartbeatStatus, BackgroundCommandOutput, BackgroundCommandStatus, ExecOptions, ExecResult, ExecStreamEvent, SandboxAttachment, SandboxListOptions, SandboxListResult, SandboxOptions, SandboxSession, } from "./types.js";
|
|
5
5
|
/** Client for isolated ephemeral compute environments with command execution and file I/O. */
|
|
6
6
|
export declare class Sandbox {
|
|
7
7
|
private endpoint;
|
|
@@ -33,17 +33,17 @@ export declare class Sandbox {
|
|
|
33
33
|
path: string;
|
|
34
34
|
content: string;
|
|
35
35
|
}>): Promise<void>;
|
|
36
|
-
/** Start an async command
|
|
37
|
-
|
|
38
|
-
/** Get the status of an async command
|
|
39
|
-
|
|
40
|
-
/** Get the output of an async command
|
|
41
|
-
|
|
42
|
-
/** List all
|
|
43
|
-
|
|
44
|
-
/** Cancel an async command
|
|
45
|
-
|
|
46
|
-
private static
|
|
36
|
+
/** Start an async background command in the sandbox. */
|
|
37
|
+
startBackgroundCommand(command: string, options?: ExecOptions): Promise<BackgroundCommand>;
|
|
38
|
+
/** Get the status of an async background command. */
|
|
39
|
+
getBackgroundCommand(commandId: string): Promise<BackgroundCommand>;
|
|
40
|
+
/** Get the output of an async background command. */
|
|
41
|
+
getBackgroundCommandOutput(commandId: string): Promise<BackgroundCommandOutput>;
|
|
42
|
+
/** List all background commands in the sandbox. */
|
|
43
|
+
listBackgroundCommands(): Promise<BackgroundCommand[]>;
|
|
44
|
+
/** Cancel an async background command. */
|
|
45
|
+
cancelBackgroundCommand(commandId: string): Promise<BackgroundCommand>;
|
|
46
|
+
private static mapBackgroundCommand;
|
|
47
47
|
/** Send a heartbeat to prevent idle timeout. */
|
|
48
48
|
heartbeat(): Promise<void>;
|
|
49
49
|
/** Close the sandbox session and mark for deletion. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/sandbox.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/sandbox.ts"],"names":[],"mappings":"AAgBA,OAAO,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C;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BhB"}
|
|
@@ -199,9 +199,9 @@ export class Sandbox {
|
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
/** Start an async command
|
|
203
|
-
async
|
|
204
|
-
const res = await fetch(`${this.endpoint}/exec/
|
|
202
|
+
/** Start an async background command in the sandbox. */
|
|
203
|
+
async startBackgroundCommand(command, options) {
|
|
204
|
+
const res = await fetch(`${this.endpoint}/exec/commands`, {
|
|
205
205
|
method: "POST",
|
|
206
206
|
headers: {
|
|
207
207
|
Authorization: `Bearer ${this.authToken}`,
|
|
@@ -211,70 +211,70 @@ export class Sandbox {
|
|
|
211
211
|
});
|
|
212
212
|
if (!res.ok) {
|
|
213
213
|
throw REQUEST_ERROR.create({
|
|
214
|
-
detail: `Start command
|
|
214
|
+
detail: `Start background command failed: ${res.status} ${await res.text()}`,
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
|
-
return Sandbox.
|
|
217
|
+
return Sandbox.mapBackgroundCommand(await res.json());
|
|
218
218
|
}
|
|
219
|
-
/** Get the status of an async command
|
|
220
|
-
async
|
|
221
|
-
const res = await fetch(`${this.endpoint}/exec/
|
|
219
|
+
/** Get the status of an async background command. */
|
|
220
|
+
async getBackgroundCommand(commandId) {
|
|
221
|
+
const res = await fetch(`${this.endpoint}/exec/commands/${commandId}`, {
|
|
222
222
|
headers: { Authorization: `Bearer ${this.authToken}` },
|
|
223
223
|
});
|
|
224
224
|
if (!res.ok) {
|
|
225
225
|
throw REQUEST_ERROR.create({
|
|
226
|
-
detail: `Get command
|
|
226
|
+
detail: `Get background command failed: ${res.status} ${await res.text()}`,
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
|
-
return Sandbox.
|
|
229
|
+
return Sandbox.mapBackgroundCommand(await res.json());
|
|
230
230
|
}
|
|
231
|
-
/** Get the output of an async command
|
|
232
|
-
async
|
|
233
|
-
const res = await fetch(`${this.endpoint}/exec/
|
|
231
|
+
/** Get the output of an async background command. */
|
|
232
|
+
async getBackgroundCommandOutput(commandId) {
|
|
233
|
+
const res = await fetch(`${this.endpoint}/exec/commands/${commandId}/output`, {
|
|
234
234
|
headers: { Authorization: `Bearer ${this.authToken}` },
|
|
235
235
|
});
|
|
236
236
|
if (!res.ok) {
|
|
237
237
|
throw REQUEST_ERROR.create({
|
|
238
|
-
detail: `Get command
|
|
238
|
+
detail: `Get background command output failed: ${res.status} ${await res.text()}`,
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
const json = await res.json();
|
|
242
242
|
return {
|
|
243
|
-
...Sandbox.
|
|
243
|
+
...Sandbox.mapBackgroundCommand(json),
|
|
244
244
|
stdout: json.stdout,
|
|
245
245
|
stderr: json.stderr,
|
|
246
246
|
stdoutTruncated: json.stdout_truncated,
|
|
247
247
|
stderrTruncated: json.stderr_truncated,
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
|
-
/** List all
|
|
251
|
-
async
|
|
252
|
-
const res = await fetch(`${this.endpoint}/exec/
|
|
250
|
+
/** List all background commands in the sandbox. */
|
|
251
|
+
async listBackgroundCommands() {
|
|
252
|
+
const res = await fetch(`${this.endpoint}/exec/commands`, {
|
|
253
253
|
headers: { Authorization: `Bearer ${this.authToken}` },
|
|
254
254
|
});
|
|
255
255
|
if (!res.ok) {
|
|
256
256
|
throw REQUEST_ERROR.create({
|
|
257
|
-
detail: `List
|
|
257
|
+
detail: `List background commands failed: ${res.status} ${await res.text()}`,
|
|
258
258
|
});
|
|
259
259
|
}
|
|
260
260
|
const json = await res.json();
|
|
261
|
-
const
|
|
262
|
-
return
|
|
261
|
+
const commands = Array.isArray(json) ? json : (json.commands ?? []);
|
|
262
|
+
return commands.map((command) => Sandbox.mapBackgroundCommand(command));
|
|
263
263
|
}
|
|
264
|
-
/** Cancel an async command
|
|
265
|
-
async
|
|
266
|
-
const res = await fetch(`${this.endpoint}/exec/
|
|
264
|
+
/** Cancel an async background command. */
|
|
265
|
+
async cancelBackgroundCommand(commandId) {
|
|
266
|
+
const res = await fetch(`${this.endpoint}/exec/commands/${commandId}/cancel`, {
|
|
267
267
|
method: "POST",
|
|
268
268
|
headers: { Authorization: `Bearer ${this.authToken}` },
|
|
269
269
|
});
|
|
270
270
|
if (!res.ok) {
|
|
271
271
|
throw REQUEST_ERROR.create({
|
|
272
|
-
detail: `Cancel command
|
|
272
|
+
detail: `Cancel background command failed: ${res.status} ${await res.text()}`,
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
|
-
return Sandbox.
|
|
275
|
+
return Sandbox.mapBackgroundCommand(await res.json());
|
|
276
276
|
}
|
|
277
|
-
static
|
|
277
|
+
static mapBackgroundCommand(json) {
|
|
278
278
|
return {
|
|
279
279
|
id: json.id,
|
|
280
280
|
status: json.status,
|
|
@@ -30,25 +30,25 @@ export interface ExecStreamEvent {
|
|
|
30
30
|
data?: string;
|
|
31
31
|
exitCode?: number;
|
|
32
32
|
}
|
|
33
|
-
/** Status of an async command
|
|
34
|
-
export type
|
|
35
|
-
/** Heartbeat health status for a command
|
|
36
|
-
export type
|
|
37
|
-
/** An async command
|
|
38
|
-
export interface
|
|
33
|
+
/** Status of an async background command. */
|
|
34
|
+
export type BackgroundCommandStatus = "running" | "completed" | "failed" | "canceled";
|
|
35
|
+
/** Heartbeat health status for a background command. */
|
|
36
|
+
export type BackgroundCommandHeartbeatStatus = "disabled" | "healthy" | "degraded";
|
|
37
|
+
/** An async background command running in a sandbox. */
|
|
38
|
+
export interface BackgroundCommand {
|
|
39
39
|
id: string;
|
|
40
|
-
status:
|
|
40
|
+
status: BackgroundCommandStatus;
|
|
41
41
|
exitCode: number | null;
|
|
42
42
|
signal: string | null;
|
|
43
43
|
startedAt: string;
|
|
44
44
|
finishedAt: string | null;
|
|
45
|
-
heartbeatStatus:
|
|
45
|
+
heartbeatStatus: BackgroundCommandHeartbeatStatus;
|
|
46
46
|
lastHeartbeatAt: string | null;
|
|
47
47
|
lastHeartbeatError: string | null;
|
|
48
48
|
heartbeatFailureCount: number;
|
|
49
49
|
}
|
|
50
|
-
/** A command
|
|
51
|
-
export interface
|
|
50
|
+
/** A background command with its captured output. */
|
|
51
|
+
export interface BackgroundCommandOutput extends BackgroundCommand {
|
|
52
52
|
stdout: string;
|
|
53
53
|
stderr: string;
|
|
54
54
|
stdoutTruncated: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/types.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,8GAA8G;IAC9G,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,8CAA8C;AAC9C,MAAM,WAAW,cAAc;IAC7B,kGAAkG;IAClG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,oEAAoE;AACpE,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"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