@smithers-orchestrator/sandbox 0.16.9 → 0.17.0
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/package.json +12 -8
- package/src/ExecuteSandboxOptions.ts +33 -4
- package/src/execute.js +4 -2
- package/src/index.d.ts +28 -4
- package/src/transport.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithers-orchestrator/sandbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Sandbox bundle, execution, and transport integration for Smithers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -20,13 +20,17 @@
|
|
|
20
20
|
"src/"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
25
|
-
"
|
|
26
|
-
"@smithers-orchestrator/
|
|
27
|
-
"@smithers-orchestrator/
|
|
28
|
-
"@smithers-orchestrator/
|
|
29
|
-
"@smithers-orchestrator/
|
|
23
|
+
"@effect/cluster": "^0.58.0",
|
|
24
|
+
"@effect/rpc": "^0.75.0",
|
|
25
|
+
"effect": "^3.21.1",
|
|
26
|
+
"@smithers-orchestrator/components": "0.17.0",
|
|
27
|
+
"@smithers-orchestrator/db": "0.17.0",
|
|
28
|
+
"@smithers-orchestrator/driver": "0.17.0",
|
|
29
|
+
"@smithers-orchestrator/engine": "0.17.0",
|
|
30
|
+
"@smithers-orchestrator/errors": "0.17.0",
|
|
31
|
+
"@smithers-orchestrator/graph": "0.17.0",
|
|
32
|
+
"@smithers-orchestrator/observability": "0.17.0",
|
|
33
|
+
"@smithers-orchestrator/scheduler": "0.17.0"
|
|
30
34
|
},
|
|
31
35
|
"devDependencies": {
|
|
32
36
|
"@types/bun": "latest",
|
|
@@ -1,12 +1,41 @@
|
|
|
1
|
-
import type { SmithersWorkflow } from "@smithers-orchestrator/components/SmithersWorkflow";
|
|
2
|
-
import type { ChildWorkflowDefinition } from "@smithers-orchestrator/engine/child-workflow";
|
|
3
1
|
import type { SandboxRuntime } from "./SandboxRuntime.ts";
|
|
4
2
|
|
|
3
|
+
export type SandboxWorkflow = {
|
|
4
|
+
db?: unknown;
|
|
5
|
+
build: (ctx: unknown) => unknown;
|
|
6
|
+
opts?: Record<string, unknown>;
|
|
7
|
+
schemaRegistry?: unknown;
|
|
8
|
+
zodToKeyName?: unknown;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type SandboxChildWorkflowDefinition =
|
|
12
|
+
| SandboxWorkflow
|
|
13
|
+
| (() => SandboxWorkflow | unknown);
|
|
14
|
+
|
|
15
|
+
export type ExecuteSandboxChildWorkflowOptions = {
|
|
16
|
+
workflow: SandboxChildWorkflowDefinition;
|
|
17
|
+
input?: unknown;
|
|
18
|
+
runId?: string;
|
|
19
|
+
parentRunId?: string;
|
|
20
|
+
rootDir?: string;
|
|
21
|
+
allowNetwork?: boolean;
|
|
22
|
+
maxOutputBytes?: number;
|
|
23
|
+
toolTimeoutMs?: number;
|
|
24
|
+
workflowPath?: string;
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type ExecuteSandboxChildWorkflow = (
|
|
29
|
+
parentWorkflow: SandboxWorkflow | undefined,
|
|
30
|
+
options: ExecuteSandboxChildWorkflowOptions,
|
|
31
|
+
) => Promise<{ runId: string; status: string; output: unknown }>;
|
|
32
|
+
|
|
5
33
|
export type ExecuteSandboxOptions = {
|
|
6
|
-
parentWorkflow?:
|
|
34
|
+
parentWorkflow?: SandboxWorkflow;
|
|
7
35
|
sandboxId: string;
|
|
8
36
|
runtime?: SandboxRuntime;
|
|
9
|
-
workflow:
|
|
37
|
+
workflow: SandboxChildWorkflowDefinition;
|
|
38
|
+
executeChildWorkflow: ExecuteSandboxChildWorkflow;
|
|
10
39
|
input?: unknown;
|
|
11
40
|
rootDir: string;
|
|
12
41
|
allowNetwork: boolean;
|
package/src/execute.js
CHANGED
|
@@ -7,7 +7,6 @@ import { nowMs } from "@smithers-orchestrator/scheduler/nowMs";
|
|
|
7
7
|
import { SmithersError } from "@smithers-orchestrator/errors/SmithersError";
|
|
8
8
|
import { errorToJson } from "@smithers-orchestrator/errors/errorToJson";
|
|
9
9
|
import { requireTaskRuntime } from "@smithers-orchestrator/driver/task-runtime";
|
|
10
|
-
import { executeChildWorkflow } from "@smithers-orchestrator/engine/child-workflow";
|
|
11
10
|
import { validateSandboxBundle, writeSandboxBundle } from "./bundle.js";
|
|
12
11
|
import { SandboxTransport, layerForSandboxRuntime, resolveSandboxRuntime, } from "./transport.js";
|
|
13
12
|
/** @typedef {import("./ExecuteSandboxOptions.ts").ExecuteSandboxOptions} ExecuteSandboxOptions */
|
|
@@ -222,8 +221,11 @@ export async function executeSandbox(options) {
|
|
|
222
221
|
stage: "executing",
|
|
223
222
|
progress: 40,
|
|
224
223
|
});
|
|
224
|
+
if (typeof options.executeChildWorkflow !== "function") {
|
|
225
|
+
throw new SmithersError("INVALID_INPUT", `Sandbox ${options.sandboxId} is missing a child workflow executor.`, { sandboxId: options.sandboxId });
|
|
226
|
+
}
|
|
225
227
|
const childStartedMs = performance.now();
|
|
226
|
-
const child = await executeChildWorkflow(options.parentWorkflow, {
|
|
228
|
+
const child = await options.executeChildWorkflow(options.parentWorkflow, {
|
|
227
229
|
workflow: options.workflow,
|
|
228
230
|
input: options.input,
|
|
229
231
|
parentRunId: runtime.runId,
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import * as _smithers_observability_SmithersEvent from '@smithers-orchestrator/observability/SmithersEvent';
|
|
2
|
-
import { SmithersWorkflow } from '@smithers-orchestrator/components/SmithersWorkflow';
|
|
3
|
-
import { ChildWorkflowDefinition } from '@smithers-orchestrator/engine/child-workflow';
|
|
4
2
|
import { Context, Effect, Layer } from 'effect';
|
|
5
3
|
import { SmithersError } from '@smithers-orchestrator/errors/SmithersError';
|
|
6
4
|
|
|
@@ -90,11 +88,37 @@ type SandboxTransportService = {
|
|
|
90
88
|
readonly cleanup: (handle: SandboxHandle) => Effect.Effect<void, SmithersError>;
|
|
91
89
|
};
|
|
92
90
|
|
|
91
|
+
type SandboxWorkflow = {
|
|
92
|
+
db?: unknown;
|
|
93
|
+
build: (ctx: unknown) => unknown;
|
|
94
|
+
opts?: Record<string, unknown>;
|
|
95
|
+
schemaRegistry?: unknown;
|
|
96
|
+
zodToKeyName?: unknown;
|
|
97
|
+
};
|
|
98
|
+
type SandboxChildWorkflowDefinition = SandboxWorkflow | (() => SandboxWorkflow | unknown);
|
|
99
|
+
type ExecuteSandboxChildWorkflowOptions = {
|
|
100
|
+
workflow: SandboxChildWorkflowDefinition;
|
|
101
|
+
input?: unknown;
|
|
102
|
+
runId?: string;
|
|
103
|
+
parentRunId?: string;
|
|
104
|
+
rootDir?: string;
|
|
105
|
+
allowNetwork?: boolean;
|
|
106
|
+
maxOutputBytes?: number;
|
|
107
|
+
toolTimeoutMs?: number;
|
|
108
|
+
workflowPath?: string;
|
|
109
|
+
signal?: AbortSignal;
|
|
110
|
+
};
|
|
111
|
+
type ExecuteSandboxChildWorkflow = (parentWorkflow: SandboxWorkflow | undefined, options: ExecuteSandboxChildWorkflowOptions) => Promise<{
|
|
112
|
+
runId: string;
|
|
113
|
+
status: string;
|
|
114
|
+
output: unknown;
|
|
115
|
+
}>;
|
|
93
116
|
type ExecuteSandboxOptions$1 = {
|
|
94
|
-
parentWorkflow?:
|
|
117
|
+
parentWorkflow?: SandboxWorkflow;
|
|
95
118
|
sandboxId: string;
|
|
96
119
|
runtime?: SandboxRuntime$1;
|
|
97
|
-
workflow:
|
|
120
|
+
workflow: SandboxChildWorkflowDefinition;
|
|
121
|
+
executeChildWorkflow: ExecuteSandboxChildWorkflow;
|
|
98
122
|
input?: unknown;
|
|
99
123
|
rootDir: string;
|
|
100
124
|
allowNetwork: boolean;
|
package/src/transport.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { Context, Effect, Layer } from "effect";
|
|
9
9
|
import { CodeplaneSandboxExecutorLive, DockerSandboxExecutorLive, } from "./effect/http-runner.js";
|
|
10
|
-
import {
|
|
10
|
+
import { makeSandboxTransportServiceEffect, } from "./effect/sandbox-entity.js";
|
|
11
11
|
import { BubblewrapSandboxExecutorLive } from "./effect/socket-runner.js";
|
|
12
12
|
import {} from "@smithers-orchestrator/errors/SmithersError";
|
|
13
13
|
/** @typedef {import("./SandboxRuntime.ts").SandboxRuntime} SandboxRuntime */
|