@deepagents/context 1.0.0 → 2.2.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/README.md +18 -14
- package/dist/browser.js +37 -2
- package/dist/browser.js.map +3 -3
- package/dist/index.js +1564 -454
- package/dist/index.js.map +4 -4
- package/dist/lib/guardrail.d.ts +2 -6
- package/dist/lib/guardrail.d.ts.map +1 -1
- package/dist/lib/sandbox/abort.d.ts +24 -0
- package/dist/lib/sandbox/abort.d.ts.map +1 -0
- package/dist/lib/sandbox/agent-os-sandbox.d.ts +8 -7
- package/dist/lib/sandbox/agent-os-sandbox.d.ts.map +1 -1
- package/dist/lib/sandbox/bash-tool.d.ts +29 -16
- package/dist/lib/sandbox/bash-tool.d.ts.map +1 -1
- package/dist/lib/sandbox/daytona-sandbox.d.ts +63 -0
- package/dist/lib/sandbox/daytona-sandbox.d.ts.map +1 -0
- package/dist/lib/sandbox/docker-sandbox-errors.d.ts +28 -7
- package/dist/lib/sandbox/docker-sandbox-errors.d.ts.map +1 -1
- package/dist/lib/sandbox/docker-sandbox.d.ts +84 -19
- package/dist/lib/sandbox/docker-sandbox.d.ts.map +1 -1
- package/dist/lib/sandbox/file-events.d.ts +33 -38
- package/dist/lib/sandbox/file-events.d.ts.map +1 -1
- package/dist/lib/sandbox/index.d.ts +2 -1
- package/dist/lib/sandbox/index.d.ts.map +1 -1
- package/dist/lib/sandbox/installers/bin.d.ts +40 -0
- package/dist/lib/sandbox/installers/bin.d.ts.map +1 -0
- package/dist/lib/sandbox/installers/index.d.ts +1 -0
- package/dist/lib/sandbox/installers/index.d.ts.map +1 -1
- package/dist/lib/sandbox/types.d.ts +51 -6
- package/dist/lib/sandbox/types.d.ts.map +1 -1
- package/dist/lib/sandbox/virtual-sandbox.d.ts +2 -2
- package/dist/lib/sandbox/virtual-sandbox.d.ts.map +1 -1
- package/dist/lib/save/save-pipeline.d.ts.map +1 -1
- package/dist/lib/skills/fragments.d.ts +2 -2
- package/dist/lib/store/sqlite.store.d.ts +1 -0
- package/dist/lib/store/sqlite.store.d.ts.map +1 -1
- package/dist/lib/store/store.d.ts +8 -0
- package/dist/lib/store/store.d.ts.map +1 -1
- package/dist/lib/stream/postgres.stream-store.d.ts.map +1 -1
- package/dist/lib/stream/sqlite.stream-store.d.ts.map +1 -1
- package/dist/lib/stream/stream-manager.d.ts +1 -1
- package/dist/lib/stream/stream-manager.d.ts.map +1 -1
- package/dist/lib/stream/stream-store.d.ts +8 -1
- package/dist/lib/stream/stream-store.d.ts.map +1 -1
- package/dist/lib/stream/types.d.ts +7 -0
- package/dist/lib/stream/types.d.ts.map +1 -0
- package/dist/lib/stream-buffer.d.ts.map +1 -1
- package/package.json +8 -12
- package/dist/lib/sandbox/container-tool.d.ts +0 -188
- package/dist/lib/sandbox/container-tool.d.ts.map +0 -1
- package/dist/lib/sandboxes/openai.d.ts +0 -6
- package/dist/lib/sandboxes/openai.d.ts.map +0 -1
package/dist/lib/guardrail.d.ts
CHANGED
|
@@ -34,13 +34,9 @@
|
|
|
34
34
|
* });
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
import type { InferUIMessageChunk, UIDataTypes, UIMessage } from 'ai';
|
|
38
37
|
import type { SkillPathMapping } from './skills/types.ts';
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* This is the full chunk type that includes text-delta, error, reasoning-delta, etc.
|
|
42
|
-
*/
|
|
43
|
-
export type StreamPart = InferUIMessageChunk<UIMessage<unknown, UIDataTypes, Record<string, never>>>;
|
|
38
|
+
import type { StreamPart } from './stream/types.ts';
|
|
39
|
+
export type { StreamPart } from './stream/types.ts';
|
|
44
40
|
/**
|
|
45
41
|
* Result of a guardrail check.
|
|
46
42
|
* - `pass`: The part is allowed through (optionally modified)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guardrail.d.ts","sourceRoot":"","sources":["../../src/lib/guardrail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;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AqBG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAEtD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,eAAe,CAEtD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,SAAS,EAAE,EACvB,OAAO,EAAE,gBAAgB,GACxB,eAAe,CAejB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DisposableSandbox } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Set the ambient abort signal for the duration of `fn`. Inside `fn`,
|
|
4
|
+
* any sandbox call going through `withAbortSignal` will receive this
|
|
5
|
+
* signal via its `executeCommand` options.
|
|
6
|
+
*
|
|
7
|
+
* Use at the boundary where an external abort signal becomes available
|
|
8
|
+
* (e.g. a tool's `execute` callback). The signal then propagates down
|
|
9
|
+
* the decorator chain without explicit parameter threading.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runWithAbortSignal<T>(signal: AbortSignal | undefined, fn: () => Promise<T>): Promise<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Decorator: when `executeCommand` is called without an explicit signal,
|
|
14
|
+
* fills in the ambient signal set by `runWithAbortSignal`. Explicit
|
|
15
|
+
* caller-provided signals take precedence. Has no effect outside a
|
|
16
|
+
* `runWithAbortSignal` scope.
|
|
17
|
+
*
|
|
18
|
+
* Bridges the signature mismatch between upstream `bash-tool` (which
|
|
19
|
+
* calls `sandbox.executeCommand(command)` with no options) and backends
|
|
20
|
+
* that can honor cancellation. The decorator goes between upstream and
|
|
21
|
+
* the inner sandbox.
|
|
22
|
+
*/
|
|
23
|
+
export declare function withAbortSignal(sandbox: DisposableSandbox): DisposableSandbox;
|
|
24
|
+
//# sourceMappingURL=abort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/abort.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAIpD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,iBAAiB,CAqB7E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DisposableSandbox } from './types.ts';
|
|
2
2
|
export declare class AgentOsSandboxError extends Error {
|
|
3
3
|
constructor(message: string);
|
|
4
4
|
}
|
|
@@ -27,16 +27,17 @@ export interface AgentOsSandboxOptions {
|
|
|
27
27
|
*/
|
|
28
28
|
moduleAccessCwd?: string;
|
|
29
29
|
}
|
|
30
|
-
export interface AgentOsSandbox extends Sandbox {
|
|
31
|
-
dispose(): Promise<void>;
|
|
32
|
-
}
|
|
33
30
|
/**
|
|
34
31
|
* Creates a WASM-based sandbox backed by Agent OS.
|
|
35
32
|
*
|
|
36
33
|
* Agent OS runs commands in an in-process WASM virtual machine — no Docker required.
|
|
37
34
|
* Near-zero cold start (~6ms) with real WASM-compiled binaries (coreutils, grep, etc.).
|
|
38
35
|
*
|
|
39
|
-
*
|
|
36
|
+
* Internally, `executeCommand` lowers to `spawn('sh', ['-c', cmd])` so a single
|
|
37
|
+
* code path supports `AbortSignal` (the kernel's `exec(command)` does not return
|
|
38
|
+
* a pid and so cannot be cancelled).
|
|
39
|
+
*
|
|
40
|
+
* @experimental Agent OS is v0.1.1 preview. API may change.
|
|
40
41
|
*
|
|
41
42
|
* Requires optional peer dependencies:
|
|
42
43
|
* - `@rivet-dev/agent-os-core`
|
|
@@ -63,7 +64,7 @@ export interface AgentOsSandbox extends Sandbox {
|
|
|
63
64
|
* await sandbox.dispose();
|
|
64
65
|
* ```
|
|
65
66
|
*/
|
|
66
|
-
export declare function createAgentOsSandbox(options?: AgentOsSandboxOptions): Promise<
|
|
67
|
+
export declare function createAgentOsSandbox(options?: AgentOsSandboxOptions): Promise<DisposableSandbox>;
|
|
67
68
|
/**
|
|
68
69
|
* Run a function with an Agent OS sandbox that auto-disposes on completion.
|
|
69
70
|
*
|
|
@@ -80,5 +81,5 @@ export declare function createAgentOsSandbox(options?: AgentOsSandboxOptions): P
|
|
|
80
81
|
* );
|
|
81
82
|
* ```
|
|
82
83
|
*/
|
|
83
|
-
export declare function useAgentOsSandbox<T>(options: AgentOsSandboxOptions, fn: (sandbox:
|
|
84
|
+
export declare function useAgentOsSandbox<T>(options: AgentOsSandboxOptions, fn: (sandbox: DisposableSandbox) => Promise<T>): Promise<T>;
|
|
84
85
|
//# sourceMappingURL=agent-os-sandbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-os-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/agent-os-sandbox.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-os-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/agent-os-sandbox.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,iBAAiB,EAIlB,MAAM,YAAY,CAAC;AA8BpB,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,wBAAyB,SAAQ,mBAAmB;gBACnD,KAAK,CAAC,EAAE,KAAK;CAO1B;AAED,qBAAa,oBAAqB,SAAQ,mBAAmB;gBAC/C,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAK3C;AAED,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,sCAAsC;IACtC,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACtE,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAwFD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,iBAAiB,CAAC,CAiH5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EACvC,OAAO,EAAE,qBAAqB,EAC9B,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,GAC7C,OAAO,CAAC,CAAC,CAAC,CAOZ"}
|
|
@@ -1,27 +1,40 @@
|
|
|
1
1
|
import { type CreateBashToolOptions } from 'bash-tool';
|
|
2
|
-
import type { AgentSandbox, SkillUploadInput } from './types.ts';
|
|
3
|
-
export interface CreateBashToolWithSkillsOptions extends CreateBashToolOptions {
|
|
2
|
+
import type { AgentSandbox, DisposableSandbox, SkillUploadInput } from './types.ts';
|
|
3
|
+
export interface CreateBashToolWithSkillsOptions extends Omit<CreateBashToolOptions, 'sandbox'> {
|
|
4
|
+
/**
|
|
5
|
+
* Backend satisfying `DisposableSandbox`. Callers pick the backend
|
|
6
|
+
* explicitly via `createVirtualSandbox`, `createDockerSandbox`, or
|
|
7
|
+
* `createAgentOsSandbox`. `@vercel/sandbox` is intentionally not
|
|
8
|
+
* accepted; if it's needed, wrap it to `DisposableSandbox` first.
|
|
9
|
+
*/
|
|
10
|
+
sandbox: DisposableSandbox;
|
|
4
11
|
/**
|
|
5
12
|
* Skill directories to upload into the sandbox at startup. Each entry's
|
|
6
13
|
* contents are copied to `sandbox` (files + subdirectories) and each
|
|
7
14
|
* subdirectory containing a SKILL.md is parsed into `sandbox.skills`.
|
|
8
15
|
*/
|
|
9
16
|
skills?: SkillUploadInput[];
|
|
17
|
+
/**
|
|
18
|
+
* Working directory + file-event observation root. Defaults to
|
|
19
|
+
* `/workspace` (matching upstream `bash-tool`). `drainFileEvents()`
|
|
20
|
+
* reports activity rooted here.
|
|
21
|
+
*/
|
|
22
|
+
destination?: string;
|
|
10
23
|
}
|
|
11
24
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
+
* Composes an `AgentSandbox` from a backend by layering decorators:
|
|
26
|
+
*
|
|
27
|
+
* backend → observeSandboxFileEvents → withBashExceptionCatch
|
|
28
|
+
*
|
|
29
|
+
* The composed sandbox is handed to upstream `bash-tool`; upstream's
|
|
30
|
+
* internal `bash` / `readFile` / `writeFile` tools therefore close over
|
|
31
|
+
* the decorated methods. The outer `bash` tool adds:
|
|
32
|
+
*
|
|
33
|
+
* - `reasoning` input on the schema.
|
|
34
|
+
* - Generic meta channel (`useBashMeta()`): `setHidden(patch)` attaches
|
|
35
|
+
* host-only metadata; `setReminder(text)` surfaces a model-visible
|
|
36
|
+
* nudge. `meta` is stripped from model output via `toModelOutput`.
|
|
37
|
+
* - Single-shot `skills` upload populating `sandbox.skills`.
|
|
25
38
|
*/
|
|
26
|
-
export declare function createBashTool(options
|
|
39
|
+
export declare function createBashTool(options: CreateBashToolWithSkillsOptions): Promise<AgentSandbox>;
|
|
27
40
|
//# sourceMappingURL=bash-tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash-tool.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/bash-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,qBAAqB,EAE3B,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"bash-tool.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/bash-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,qBAAqB,EAE3B,MAAM,WAAW,CAAC;AAOnB,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AA8BpB,MAAM,WAAW,+BAAgC,SAAQ,IAAI,CAC3D,qBAAqB,EACrB,SAAS,CACV;IACC;;;;;OAKG;IACH,OAAO,EAAE,iBAAiB,CAAC;IAC3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC5B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,YAAY,CAAC,CA6FvB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { DisposableSandbox } from './types.ts';
|
|
2
|
+
export declare const DAYTONA_DEFAULT_DESTINATION = "/home/daytona";
|
|
3
|
+
export interface DaytonaResources {
|
|
4
|
+
cpu?: number;
|
|
5
|
+
gpu?: number;
|
|
6
|
+
memory?: number;
|
|
7
|
+
disk?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface DaytonaVolumeMount {
|
|
10
|
+
volumeId: string;
|
|
11
|
+
mountPath: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface DaytonaSandboxOptions {
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
jwtToken?: string;
|
|
17
|
+
organizationId?: string;
|
|
18
|
+
apiUrl?: string;
|
|
19
|
+
target?: string;
|
|
20
|
+
otelEnabled?: boolean;
|
|
21
|
+
experimental?: Record<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Existing Daytona sandbox id or name to attach to. Attached sandboxes are
|
|
24
|
+
* preserved on dispose unless `deleteOnDispose` is explicitly true.
|
|
25
|
+
*/
|
|
26
|
+
sandboxId?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
user?: string;
|
|
29
|
+
snapshot?: string;
|
|
30
|
+
image?: string;
|
|
31
|
+
language?: string;
|
|
32
|
+
envVars?: Record<string, string>;
|
|
33
|
+
labels?: Record<string, string>;
|
|
34
|
+
public?: boolean;
|
|
35
|
+
resources?: DaytonaResources;
|
|
36
|
+
volumes?: DaytonaVolumeMount[];
|
|
37
|
+
networkAllowList?: string;
|
|
38
|
+
networkBlockAll?: boolean;
|
|
39
|
+
autoStopInterval?: number;
|
|
40
|
+
autoArchiveInterval?: number;
|
|
41
|
+
autoDeleteInterval?: number;
|
|
42
|
+
ephemeral?: boolean;
|
|
43
|
+
createTimeout?: number;
|
|
44
|
+
startTimeout?: number;
|
|
45
|
+
deleteTimeout?: number;
|
|
46
|
+
commandTimeout?: number;
|
|
47
|
+
onSnapshotCreateLogs?: (chunk: string) => void;
|
|
48
|
+
deleteOnDispose?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare class DaytonaSandboxError extends Error {
|
|
51
|
+
constructor(message: string, cause?: Error);
|
|
52
|
+
}
|
|
53
|
+
export declare class DaytonaNotAvailableError extends DaytonaSandboxError {
|
|
54
|
+
constructor(cause?: Error);
|
|
55
|
+
}
|
|
56
|
+
export declare class DaytonaCreationError extends DaytonaSandboxError {
|
|
57
|
+
constructor(message: string, cause?: Error);
|
|
58
|
+
}
|
|
59
|
+
export declare class DaytonaCommandError extends DaytonaSandboxError {
|
|
60
|
+
constructor(message: string, cause?: Error);
|
|
61
|
+
}
|
|
62
|
+
export declare function createDaytonaSandbox(options?: DaytonaSandboxOptions): Promise<DisposableSandbox>;
|
|
63
|
+
//# sourceMappingURL=daytona-sandbox.d.ts.map
|
|
@@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AO,CAAC;IACjB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAK3C;AAED,qBAAa,wBAAyB,SAAQ,mBAAmB;gBACnD,KAAK,CAAC,EAAE,KAAK;CAO1B;AAED,qBAAa,oBAAqB,SAAQ,mBAAmB;gBAC/C,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAI3C;AAED,qBAAa,mBAAoB,SAAQ,mBAAmB;gBAC9C,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAI3C;AAED,wBAAsB,oBAAoB,CACxC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,iBAAiB,CAAC,CAsC5B"}
|
|
@@ -17,12 +17,17 @@ export declare class PackageInstallError extends DockerSandboxError {
|
|
|
17
17
|
readonly stderr: string;
|
|
18
18
|
constructor(packages: string[], image: string, packageManager: 'apk' | 'apt-get', stderr: string, containerId?: string);
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Discriminator for `InstallError`. Most values are fetch sources (`'npm'`,
|
|
22
|
+
* `'pypi'`, `'url'`, `'github-release'`); `'bin'` covers the local-filesystem
|
|
23
|
+
* `BinInstaller` which has no remote source.
|
|
24
|
+
*/
|
|
25
|
+
export type InstallKind = 'url' | 'npm' | 'pypi' | 'github-release' | 'bin';
|
|
21
26
|
export interface InstallErrorOptions {
|
|
22
27
|
/** Logical name of the thing being installed (e.g. `'prettier'`, `'presenterm'`). */
|
|
23
28
|
target: string;
|
|
24
|
-
/**
|
|
25
|
-
source:
|
|
29
|
+
/** Installer kind (registry, URL, local binary, …). */
|
|
30
|
+
source: InstallKind;
|
|
26
31
|
/** Underlying failure message (typically stderr). */
|
|
27
32
|
reason: string;
|
|
28
33
|
/** Resolved URL when applicable (URL binary / GitHub release). */
|
|
@@ -31,7 +36,7 @@ export interface InstallErrorOptions {
|
|
|
31
36
|
}
|
|
32
37
|
export declare class InstallError extends DockerSandboxError {
|
|
33
38
|
readonly target: string;
|
|
34
|
-
readonly source:
|
|
39
|
+
readonly source: InstallKind;
|
|
35
40
|
readonly reason: string;
|
|
36
41
|
readonly url?: string;
|
|
37
42
|
constructor(opts: InstallErrorOptions);
|
|
@@ -41,10 +46,26 @@ export declare class MissingRuntimeError extends DockerSandboxError {
|
|
|
41
46
|
readonly required: string[];
|
|
42
47
|
constructor(runtime: string, required: string[], details?: string, containerId?: string);
|
|
43
48
|
}
|
|
44
|
-
export declare class
|
|
45
|
-
readonly
|
|
49
|
+
export declare class VolumePathError extends DockerSandboxError {
|
|
50
|
+
readonly source: string;
|
|
46
51
|
readonly containerPath: string;
|
|
47
|
-
|
|
52
|
+
readonly reason: string;
|
|
53
|
+
constructor(source: string, containerPath: string, reason: string);
|
|
54
|
+
}
|
|
55
|
+
export declare class VolumeInspectError extends DockerSandboxError {
|
|
56
|
+
readonly volume: string;
|
|
57
|
+
readonly reason: string;
|
|
58
|
+
constructor(volume: string, reason: string);
|
|
59
|
+
}
|
|
60
|
+
export declare class VolumeCreateError extends DockerSandboxError {
|
|
61
|
+
readonly volume: string;
|
|
62
|
+
readonly reason: string;
|
|
63
|
+
constructor(volume: string, reason: string);
|
|
64
|
+
}
|
|
65
|
+
export declare class VolumeRemoveError extends DockerSandboxError {
|
|
66
|
+
readonly volume: string;
|
|
67
|
+
readonly reason: string;
|
|
68
|
+
constructor(volume: string, reason: string);
|
|
48
69
|
}
|
|
49
70
|
export declare class DockerfileBuildError extends DockerSandboxError {
|
|
50
71
|
readonly stderr: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker-sandbox-errors.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/docker-sandbox-errors.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;CAKlD;AAED,qBAAa,uBAAwB,SAAQ,kBAAkB;;CAK9D;AAED,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC5D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAM1D;AAED,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,cAAc,EAAE,KAAK,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAGtB,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,KAAK,GAAG,SAAS,EACjC,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,MAAM;CAavB;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C,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAM3C;AAED,qBAAa,oBAAqB,SAAQ,kBAAkB;IAC1D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;CAK3B;AAED,qBAAa,iBAAkB,SAAQ,kBAAkB;IACvD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAMhD"}
|
|
@@ -1,19 +1,58 @@
|
|
|
1
|
-
import { type CommandResult
|
|
1
|
+
import { type CommandResult } from 'bash-tool';
|
|
2
2
|
import { type Installer } from './installers/installer.ts';
|
|
3
|
+
import type { DisposableSandbox, ExecuteCommandOptions, SandboxProcess, SpawnOptions } from './types.ts';
|
|
3
4
|
export type { CommandResult as ExecResult, Sandbox } from 'bash-tool';
|
|
4
|
-
export { ComposeStartError, ContainerCreationError, DockerNotAvailableError, DockerSandboxError, DockerfileBuildError, type InstallErrorOptions, type
|
|
5
|
-
export interface
|
|
5
|
+
export { ComposeStartError, ContainerCreationError, DockerNotAvailableError, DockerSandboxError, DockerfileBuildError, type InstallErrorOptions, type InstallKind, InstallError, MissingRuntimeError, PackageInstallError, VolumeCreateError, VolumeInspectError, VolumePathError, VolumeRemoveError, } from './docker-sandbox-errors.ts';
|
|
6
|
+
export interface DockerBindVolume {
|
|
7
|
+
type: 'bind';
|
|
6
8
|
hostPath: string;
|
|
7
9
|
containerPath: string;
|
|
8
10
|
/** Default: `true`. */
|
|
9
11
|
readOnly?: boolean;
|
|
10
12
|
}
|
|
13
|
+
export interface DockerNamedVolume {
|
|
14
|
+
type: 'volume';
|
|
15
|
+
name: string;
|
|
16
|
+
containerPath: string;
|
|
17
|
+
/** Default: `true`. */
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
/** Default: `'external'`. */
|
|
20
|
+
lifecycle?: 'external' | 'managed';
|
|
21
|
+
/** Docker volume driver used when `lifecycle` is `'managed'`. */
|
|
22
|
+
driver?: string;
|
|
23
|
+
/** Docker volume driver options used when `lifecycle` is `'managed'`. */
|
|
24
|
+
driverOptions?: Record<string, string>;
|
|
25
|
+
subPath?: string;
|
|
26
|
+
noCopy?: boolean;
|
|
27
|
+
/** Default: `true` for managed volumes created by this sandbox. */
|
|
28
|
+
removeOnDispose?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export type DockerSandboxVolume = DockerBindVolume | DockerNamedVolume;
|
|
11
31
|
export interface DockerResources {
|
|
12
32
|
/** e.g. `'1g'`, `'512m'`. */
|
|
13
33
|
memory?: string;
|
|
14
34
|
/** Number of CPUs. */
|
|
15
35
|
cpus?: number;
|
|
16
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Stable identity suffix for the container. When provided, the container
|
|
39
|
+
* is named `sandbox-<name>` instead of getting a randomized
|
|
40
|
+
* `sandbox-<8hex>`. If a container with that name already exists on the
|
|
41
|
+
* host, the sandbox attaches to it: installers, volume preparation, and
|
|
42
|
+
* env are skipped (the pre-existing container is assumed already
|
|
43
|
+
* configured). If it exists but is stopped, it is started first.
|
|
44
|
+
* Otherwise the container is created fresh and installers run as usual.
|
|
45
|
+
*
|
|
46
|
+
* Must match `/^[A-Za-z0-9_.-]+$/`. The full Docker container name
|
|
47
|
+
* (`sandbox-<name>`) is always legal because the prefix begins with an
|
|
48
|
+
* alphanumeric character.
|
|
49
|
+
*
|
|
50
|
+
* Warning: `dispose()` stops (and `--rm` removes) the container regardless
|
|
51
|
+
* of whether it was created or attached to. If two callers in the same
|
|
52
|
+
* process share a name, the first `dispose()` destroys the container the
|
|
53
|
+
* other one is still using.
|
|
54
|
+
*/
|
|
55
|
+
type StableContainerName = string;
|
|
17
56
|
export interface RuntimeSandboxOptions {
|
|
18
57
|
/** Docker image to use (default: `'alpine:latest'`). */
|
|
19
58
|
image?: string;
|
|
@@ -23,18 +62,20 @@ export interface RuntimeSandboxOptions {
|
|
|
23
62
|
* `githubRelease({...})`, or any custom `Installer` subclass.
|
|
24
63
|
*/
|
|
25
64
|
installers?: Installer[];
|
|
26
|
-
|
|
65
|
+
volumes?: DockerSandboxVolume[];
|
|
27
66
|
resources?: DockerResources;
|
|
28
67
|
env?: Record<string, string>;
|
|
68
|
+
name?: StableContainerName;
|
|
29
69
|
}
|
|
30
70
|
export interface DockerfileSandboxOptions {
|
|
31
71
|
/** Inline Dockerfile content (contains `\n`) or a path. */
|
|
32
72
|
dockerfile: string;
|
|
33
73
|
/** Build context directory (default: `'.'`). */
|
|
34
74
|
context?: string;
|
|
35
|
-
|
|
75
|
+
volumes?: DockerSandboxVolume[];
|
|
36
76
|
resources?: DockerResources;
|
|
37
77
|
env?: Record<string, string>;
|
|
78
|
+
name?: StableContainerName;
|
|
38
79
|
}
|
|
39
80
|
export interface ComposeSandboxOptions {
|
|
40
81
|
compose: string;
|
|
@@ -42,9 +83,6 @@ export interface ComposeSandboxOptions {
|
|
|
42
83
|
resources?: DockerResources;
|
|
43
84
|
}
|
|
44
85
|
export type DockerSandboxOptions = RuntimeSandboxOptions | DockerfileSandboxOptions | ComposeSandboxOptions;
|
|
45
|
-
export interface DockerSandbox extends Sandbox {
|
|
46
|
-
dispose(): Promise<void>;
|
|
47
|
-
}
|
|
48
86
|
export declare function isDockerfileOptions(opts: DockerSandboxOptions): opts is DockerfileSandboxOptions;
|
|
49
87
|
export declare function isComposeOptions(opts: DockerSandboxOptions): opts is ComposeSandboxOptions;
|
|
50
88
|
interface StrategyContext {
|
|
@@ -52,9 +90,10 @@ interface StrategyContext {
|
|
|
52
90
|
image: string;
|
|
53
91
|
}
|
|
54
92
|
export interface DockerSandboxStrategyArgs {
|
|
55
|
-
|
|
93
|
+
volumes?: DockerSandboxVolume[];
|
|
56
94
|
resources?: DockerResources;
|
|
57
95
|
env?: Record<string, string>;
|
|
96
|
+
name?: StableContainerName;
|
|
58
97
|
}
|
|
59
98
|
/**
|
|
60
99
|
* Template Method base for sandbox creation strategies. Subclasses choose
|
|
@@ -63,17 +102,41 @@ export interface DockerSandboxStrategyArgs {
|
|
|
63
102
|
*/
|
|
64
103
|
export declare abstract class DockerSandboxStrategy {
|
|
65
104
|
protected context: StrategyContext;
|
|
66
|
-
protected
|
|
105
|
+
protected volumes: DockerSandboxVolume[];
|
|
67
106
|
protected resources: DockerResources;
|
|
68
107
|
protected env: Record<string, string>;
|
|
108
|
+
protected name?: StableContainerName;
|
|
109
|
+
private createdVolumes;
|
|
69
110
|
constructor(args?: DockerSandboxStrategyArgs);
|
|
70
|
-
create(): Promise<
|
|
71
|
-
|
|
111
|
+
create(): Promise<DisposableSandbox>;
|
|
112
|
+
private namedContainerId;
|
|
113
|
+
protected defaultContainerId(): string;
|
|
114
|
+
protected acquireContainer(image: string): Promise<{
|
|
115
|
+
containerId: string;
|
|
116
|
+
attached: boolean;
|
|
117
|
+
}>;
|
|
118
|
+
private startStoppedContainer;
|
|
119
|
+
protected inspectContainer(containerId: string): Promise<'running' | 'stopped' | 'absent'>;
|
|
120
|
+
private isMissingContainerError;
|
|
121
|
+
private isNameConflictError;
|
|
122
|
+
protected prepareVolumes(): Promise<void>;
|
|
123
|
+
protected validateVolumes(): void;
|
|
124
|
+
private validateMountValue;
|
|
72
125
|
protected buildDockerArgs(image: string, containerId: string): string[];
|
|
73
|
-
protected
|
|
126
|
+
protected buildVolumeMountArg(volume: DockerSandboxVolume): string;
|
|
127
|
+
private inspectVolume;
|
|
128
|
+
private volumeExists;
|
|
129
|
+
private createVolume;
|
|
130
|
+
private cleanupCreatedVolumes;
|
|
131
|
+
private cleanupCreatedVolumesAfterFailure;
|
|
132
|
+
private getDockerErrorMessage;
|
|
133
|
+
private isDockerUnavailableError;
|
|
134
|
+
private isMissingVolumeInspectError;
|
|
135
|
+
protected startContainer(image: string, containerId: string): Promise<void>;
|
|
74
136
|
protected stopContainer(containerId: string): Promise<void>;
|
|
75
|
-
protected exec(command: string): Promise<CommandResult>;
|
|
76
|
-
protected
|
|
137
|
+
protected exec(command: string, options?: ExecuteCommandOptions): Promise<CommandResult>;
|
|
138
|
+
protected spawnProcess(command: string, options?: SpawnOptions): SandboxProcess;
|
|
139
|
+
protected createSandboxMethods(): DisposableSandbox;
|
|
77
140
|
protected abstract getImage(): Promise<string>;
|
|
78
141
|
protected abstract configure(): Promise<void>;
|
|
79
142
|
}
|
|
@@ -139,9 +202,11 @@ export declare class ComposeStrategy extends DockerSandboxStrategy {
|
|
|
139
202
|
constructor(args: ComposeStrategyArgs);
|
|
140
203
|
private computeProjectName;
|
|
141
204
|
protected getImage(): Promise<string>;
|
|
142
|
-
protected startContainer(_image: string): Promise<
|
|
205
|
+
protected startContainer(_image: string, _containerId: string): Promise<void>;
|
|
206
|
+
protected defaultContainerId(): string;
|
|
143
207
|
protected configure(): Promise<void>;
|
|
144
|
-
protected exec(command: string): Promise<CommandResult>;
|
|
208
|
+
protected exec(command: string, options?: ExecuteCommandOptions): Promise<CommandResult>;
|
|
209
|
+
protected spawnProcess(command: string, options?: SpawnOptions): SandboxProcess;
|
|
145
210
|
protected stopContainer(_containerId: string): Promise<void>;
|
|
146
211
|
}
|
|
147
212
|
/**
|
|
@@ -179,10 +244,10 @@ export declare class ComposeStrategy extends DockerSandboxStrategy {
|
|
|
179
244
|
* });
|
|
180
245
|
* ```
|
|
181
246
|
*/
|
|
182
|
-
export declare function createDockerSandbox(options?: DockerSandboxOptions): Promise<
|
|
247
|
+
export declare function createDockerSandbox(options?: DockerSandboxOptions): Promise<DisposableSandbox>;
|
|
183
248
|
/**
|
|
184
249
|
* Run a function with a Docker sandbox; the container is disposed on
|
|
185
250
|
* completion (success or thrown).
|
|
186
251
|
*/
|
|
187
|
-
export declare function useSandbox<T>(options: DockerSandboxOptions, fn: (sandbox:
|
|
252
|
+
export declare function useSandbox<T>(options: DockerSandboxOptions, fn: (sandbox: DisposableSandbox) => Promise<T>): Promise<T>;
|
|
188
253
|
//# sourceMappingURL=docker-sandbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/docker-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"docker-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/docker-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAkB/C,OAAO,EACL,KAAK,SAAS,EAEf,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EAErB,cAAc,EACd,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,aAAa,IAAI,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACnC,iEAAiE;IACjE,MAAM,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AO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,aAAa,CAAC;cAkCN,YAAY,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY,GACrB,cAAc;cAkBQ,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAc5E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,iBAAiB,CAAC,CA8B5B;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAChC,OAAO,EAAE,oBAAoB,EAC7B,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,GAC7C,OAAO,CAAC,CAAC,CAAC,CAOZ"}
|
|
@@ -1,47 +1,42 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
interface ReadFileOptions {
|
|
3
|
-
encoding?: BufferEncoding | null;
|
|
4
|
-
}
|
|
5
|
-
interface WriteFileOptions {
|
|
6
|
-
encoding?: BufferEncoding;
|
|
7
|
-
}
|
|
8
|
-
interface DirentEntry {
|
|
9
|
-
name: string;
|
|
10
|
-
isFile: boolean;
|
|
11
|
-
isDirectory: boolean;
|
|
12
|
-
isSymbolicLink: boolean;
|
|
13
|
-
}
|
|
1
|
+
import type { DisposableSandbox } from './types.ts';
|
|
14
2
|
export type FileEventOp = 'read' | 'write' | 'delete' | 'modify';
|
|
15
3
|
export interface FileEvent {
|
|
16
4
|
path: string;
|
|
17
5
|
op: FileEventOp;
|
|
18
6
|
timestamp: number;
|
|
19
7
|
}
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
export interface ObserveOptions {
|
|
9
|
+
destination: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SandboxObserver {
|
|
12
|
+
sandbox: DisposableSandbox;
|
|
24
13
|
drain(): FileEvent[];
|
|
25
|
-
readFile(path: string, options?: ReadFileOptions | BufferEncoding): Promise<string>;
|
|
26
|
-
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
27
|
-
writeFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise<void>;
|
|
28
|
-
appendFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise<void>;
|
|
29
|
-
rm(path: string, options?: RmOptions): Promise<void>;
|
|
30
|
-
cp(src: string, dest: string, options?: CpOptions): Promise<void>;
|
|
31
|
-
mv(src: string, dest: string): Promise<void>;
|
|
32
|
-
symlink(target: string, linkPath: string): Promise<void>;
|
|
33
|
-
link(existingPath: string, newPath: string): Promise<void>;
|
|
34
|
-
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
35
|
-
exists(path: string): Promise<boolean>;
|
|
36
|
-
stat(path: string): Promise<FsStat>;
|
|
37
|
-
lstat(path: string): Promise<FsStat>;
|
|
38
|
-
readdir(path: string): Promise<string[]>;
|
|
39
|
-
readlink(path: string): Promise<string>;
|
|
40
|
-
realpath(path: string): Promise<string>;
|
|
41
|
-
chmod(path: string, mode: number): Promise<void>;
|
|
42
|
-
utimes(path: string, atime: Date, mtime: Date): Promise<void>;
|
|
43
|
-
resolvePath(base: string, path: string): string;
|
|
44
|
-
getAllPaths(): string[];
|
|
45
14
|
}
|
|
46
|
-
export {
|
|
15
|
+
export declare class SnapshotFailedError extends Error {
|
|
16
|
+
readonly stderr: string;
|
|
17
|
+
constructor(message: string, stderr: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Wraps a `Sandbox` with file-event observation rooted at `destination`.
|
|
21
|
+
*
|
|
22
|
+
* - `executeCommand` and `writeFiles` are bracketed by `find -print0` +
|
|
23
|
+
* `sha256sum` snapshots; hash diff produces write/modify/delete events.
|
|
24
|
+
* - `readFile` records a `read` event on success.
|
|
25
|
+
* - `spawn` (when the backend exposes it) is bracketed similarly: the
|
|
26
|
+
* before-snapshot resolves before the inner spawn starts (via a
|
|
27
|
+
* lazy `ReadableStream`), and the returned `exit` Promise resolves only
|
|
28
|
+
* after the after-snapshot is recorded. The after-snapshot runs when the
|
|
29
|
+
* OS reports child exit; data still buffered in stdio after that point
|
|
30
|
+
* is *not* observed — write events for files flushed only on stream
|
|
31
|
+
* close may be missed.
|
|
32
|
+
* - If `destination` does not exist in the sandbox at snapshot time, the
|
|
33
|
+
* snapshot is treated as empty (graceful — supports observation rooted at
|
|
34
|
+
* paths that the sandbox will create later). Snapshot command failures
|
|
35
|
+
* (e.g. permission denied, missing `find`) throw `SnapshotFailedError`
|
|
36
|
+
* from `executeCommand`/`writeFiles`, but are silently dropped on `spawn`
|
|
37
|
+
* because the caller's signal already comes via `exit`.
|
|
38
|
+
* - Single-flight by convention. Concurrent `executeCommand` calls are not
|
|
39
|
+
* serialized internally and will produce interleaved diffs.
|
|
40
|
+
*/
|
|
41
|
+
export declare function observeSandboxFileEvents(sandbox: DisposableSandbox, options: ObserveOptions): SandboxObserver;
|
|
47
42
|
//# sourceMappingURL=file-events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-events.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/file-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"file-events.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/file-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAY,MAAM,YAAY,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjE,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,IAAI,SAAS,EAAE,CAAC;CACtB;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBACZ,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAK5C;AA6ED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,cAAc,GACtB,eAAe,CA0FjB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
export * from './abort.ts';
|
|
1
2
|
export * from './agent-os-sandbox.ts';
|
|
2
3
|
export * from './bash-exception.ts';
|
|
3
4
|
export * from './bash-meta.ts';
|
|
4
5
|
export * from './bash-tool.ts';
|
|
5
6
|
export * from './file-events.ts';
|
|
6
7
|
export * from './binary-bridges.ts';
|
|
7
|
-
export * from './
|
|
8
|
+
export * from './daytona-sandbox.ts';
|
|
8
9
|
export * from './docker-sandbox.ts';
|
|
9
10
|
export * from './installers/index.ts';
|
|
10
11
|
export * from './subcommand.ts';
|