@deepagents/context 7.6.0 → 7.7.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 +5 -5
- package/dist/index.js +497 -1000
- package/dist/index.js.map +4 -4
- package/dist/lib/agent.d.ts +21 -21
- package/dist/lib/agent.d.ts.map +1 -1
- package/dist/lib/sandbox/apple-container-sandbox.d.ts.map +1 -1
- package/dist/lib/sandbox/bash-tool.d.ts +2 -2
- package/dist/lib/sandbox/bash-tool.d.ts.map +1 -1
- package/dist/lib/sandbox/container-engine.d.ts +7 -13
- package/dist/lib/sandbox/container-engine.d.ts.map +1 -1
- package/dist/lib/sandbox/container-sandbox.d.ts +6 -3
- package/dist/lib/sandbox/container-sandbox.d.ts.map +1 -1
- package/dist/lib/sandbox/container-session.d.ts +0 -2
- package/dist/lib/sandbox/container-session.d.ts.map +1 -1
- package/dist/lib/sandbox/daytona-sandbox.d.ts +40 -49
- package/dist/lib/sandbox/daytona-sandbox.d.ts.map +1 -1
- package/dist/lib/sandbox/docker-sandbox.d.ts +21 -120
- package/dist/lib/sandbox/docker-sandbox.d.ts.map +1 -1
- package/dist/lib/sandbox/index.d.ts +0 -1
- package/dist/lib/sandbox/index.d.ts.map +1 -1
- package/dist/lib/sandbox/microsandbox-sandbox.d.ts.map +1 -1
- package/dist/lib/sandbox/session.d.ts +40 -0
- package/dist/lib/sandbox/session.d.ts.map +1 -0
- package/dist/lib/sandbox/strace/file-changes.d.ts +2 -2
- package/dist/lib/sandbox/strace/file-changes.d.ts.map +1 -1
- package/dist/lib/sandbox/types.d.ts +28 -71
- package/dist/lib/sandbox/types.d.ts.map +1 -1
- package/dist/lib/telemetry/file/file-telemetry.d.ts.map +1 -1
- package/dist/lib/telemetry/file/index.js +9 -7
- package/dist/lib/telemetry/file/index.js.map +2 -2
- package/package.json +12 -12
- package/dist/lib/sandbox/legacy-sandbox.d.ts +0 -8
- package/dist/lib/sandbox/legacy-sandbox.d.ts.map +0 -1
- package/dist/lib/sandbox/read-file.d.ts +0 -9
- package/dist/lib/sandbox/read-file.d.ts.map +0 -1
package/dist/lib/agent.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { JSONObject } from '@ai-sdk/provider';
|
|
2
2
|
import type { HasRequiredKey, InferToolSetContext, ToolExecutionOptions } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { type FlexibleSchema, type GenerateTextResult, type InferSchema, Output, type PrepareStepFunction, type StreamTextResult, type StreamTextTransform, type Tool, type ToolLoopAgentSettings, type ToolSet, type UIMessage, type UIMessageChunk, type UIMessageStreamOptions, generateText, streamText } from 'ai';
|
|
3
|
+
import { type FlexibleSchema, type GenerateTextResult, type InferSchema, Output, type PrepareStepFunction, type StreamTextResult, type StreamTextTransform, type Tool, type ToolChoice, type ToolLoopAgentSettings, type ToolSet, type UIMessage, type UIMessageChunk, type UIMessageStreamOptions, generateText, streamText } from 'ai';
|
|
4
4
|
import { type AgentControls, withHostOnlyToolMetadata } from '@deepagents/agent';
|
|
5
5
|
import { type ContextEngine, type PrepareStepInputProvider } from '../index.ts';
|
|
6
6
|
import { type AdvisorResult, type AgentModel, type AsAdvisorOptions } from './advisor.ts';
|
|
7
7
|
import { type Guardrail } from './guardrail.ts';
|
|
8
|
-
import type { AgentSandbox } from './sandbox/types.ts';
|
|
8
|
+
import type { AgentSandbox, SandboxTools } from './sandbox/types.ts';
|
|
9
9
|
export type { AgentControls } from '@deepagents/agent';
|
|
10
10
|
/** Input schema shape accepted by the tool `asTool()` produces. */
|
|
11
11
|
export interface SubagentToolInput {
|
|
@@ -28,7 +28,7 @@ export interface SubagentTool<OUTPUT, CONTEXT> {
|
|
|
28
28
|
execute: (input: SubagentToolInput, options: ToolExecutionOptions<CONTEXT>) => Promise<OUTPUT>;
|
|
29
29
|
}
|
|
30
30
|
type PreparedTools<TOOLS extends ToolSet> = ReturnType<typeof withHostOnlyToolMetadata<TOOLS>>;
|
|
31
|
-
type AgentModelTools<TOOLS extends ToolSet> = PreparedTools<
|
|
31
|
+
type AgentModelTools<TOOLS extends ToolSet, SANDBOX_TOOLS extends SandboxTools> = PreparedTools<SANDBOX_TOOLS & TOOLS>;
|
|
32
32
|
type ToolCallOptions<TOOLS extends ToolSet, OPTIONS> = Pick<ToolLoopAgentSettings<never, TOOLS>, 'toolsContext'> & OPTIONS;
|
|
33
33
|
export type ToolCallArguments<TOOLS extends ToolSet, OPTIONS> = HasRequiredKey<InferToolSetContext<TOOLS>> extends true ? [options: ToolCallOptions<TOOLS, OPTIONS>] : [options?: ToolCallOptions<TOOLS, OPTIONS>];
|
|
34
34
|
type GenerateOptions = {
|
|
@@ -48,17 +48,17 @@ export interface AgentStream<TOOLS extends ToolSet> {
|
|
|
48
48
|
readonly result: ReturnType<typeof streamText<TOOLS>>;
|
|
49
49
|
toUIMessageStream(options?: UIMessageStreamOptions<UIMessage>): ReadableStream<UIMessageChunk>;
|
|
50
50
|
}
|
|
51
|
-
export interface CreateAgent<TOOLS extends ToolSet = {}> extends AgentControls<AgentModelTools<TOOLS>> {
|
|
51
|
+
export interface CreateAgent<TOOLS extends ToolSet = {}, SANDBOX_TOOLS extends SandboxTools = SandboxTools> extends AgentControls<AgentModelTools<TOOLS, SANDBOX_TOOLS>> {
|
|
52
52
|
name: string;
|
|
53
|
-
sandbox: AgentSandbox
|
|
53
|
+
sandbox: AgentSandbox<SANDBOX_TOOLS>;
|
|
54
54
|
context?: ContextEngine;
|
|
55
55
|
tools?: TOOLS;
|
|
56
56
|
model?: AgentModel;
|
|
57
|
-
toolChoice?:
|
|
58
|
-
providerOptions?: Parameters<typeof generateText<AgentModelTools<TOOLS>>>[0]['providerOptions'];
|
|
59
|
-
telemetry?: Parameters<typeof generateText<AgentModelTools<TOOLS>>>[0]['telemetry'];
|
|
60
|
-
runtimeContext?: Parameters<typeof generateText<AgentModelTools<TOOLS>>>[0]['runtimeContext'];
|
|
61
|
-
experimental_toolCallers?: Parameters<typeof generateText<AgentModelTools<TOOLS>>>[0]['experimental_toolCallers'];
|
|
57
|
+
toolChoice?: ToolChoice<AgentModelTools<NoInfer<TOOLS>, SANDBOX_TOOLS>>;
|
|
58
|
+
providerOptions?: Parameters<typeof generateText<AgentModelTools<TOOLS, SANDBOX_TOOLS>>>[0]['providerOptions'];
|
|
59
|
+
telemetry?: Parameters<typeof generateText<AgentModelTools<TOOLS, SANDBOX_TOOLS>>>[0]['telemetry'];
|
|
60
|
+
runtimeContext?: Parameters<typeof generateText<AgentModelTools<TOOLS, SANDBOX_TOOLS>>>[0]['runtimeContext'];
|
|
61
|
+
experimental_toolCallers?: Parameters<typeof generateText<AgentModelTools<TOOLS, SANDBOX_TOOLS>>>[0]['experimental_toolCallers'];
|
|
62
62
|
/**
|
|
63
63
|
* Ends the agent loop. Defaults to {@link DEFAULT_STOP_WHEN}. Raise it for a
|
|
64
64
|
* long agentic run that would otherwise stop mid-task; lower it to bound cost
|
|
@@ -77,21 +77,21 @@ export interface CreateAgent<TOOLS extends ToolSet = {}> extends AgentControls<A
|
|
|
77
77
|
/** Supplies durable user input before sampling and at safe step boundaries. */
|
|
78
78
|
prepareStepInput?: PrepareStepInputProvider;
|
|
79
79
|
/** Native AI SDK step overrides, applied after context reminders and host input. */
|
|
80
|
-
prepareStep?: PrepareStepFunction<AgentModelTools<TOOLS>>;
|
|
80
|
+
prepareStep?: PrepareStepFunction<AgentModelTools<TOOLS, SANDBOX_TOOLS>>;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* Default ceiling for the agent loop. Kept in one place so the entry points
|
|
84
84
|
* cannot drift; callers override it with `stopWhen` on `agent()`.
|
|
85
85
|
*/
|
|
86
86
|
export declare const DEFAULT_STOP_WHEN: import("ai").StopCondition<any, any>;
|
|
87
|
-
declare class Agent<TOOLS extends ToolSet> {
|
|
87
|
+
declare class Agent<TOOLS extends ToolSet, SANDBOX_TOOLS extends SandboxTools> {
|
|
88
88
|
#private;
|
|
89
|
-
readonly tools: AgentModelTools<TOOLS>;
|
|
89
|
+
readonly tools: AgentModelTools<TOOLS, SANDBOX_TOOLS>;
|
|
90
90
|
readonly context?: ContextEngine;
|
|
91
91
|
readonly model?: AgentModel;
|
|
92
|
-
readonly sandbox: AgentSandbox
|
|
93
|
-
constructor(options: CreateAgent<TOOLS>);
|
|
94
|
-
generate(...[options]: ToolCallArguments<AgentModelTools<TOOLS>, GenerateOptions>): Promise<GenerateTextResult<AgentModelTools<TOOLS>, any, Output.Output<string, string, unknown>>>;
|
|
92
|
+
readonly sandbox: AgentSandbox<SANDBOX_TOOLS>;
|
|
93
|
+
constructor(options: CreateAgent<TOOLS, SANDBOX_TOOLS>);
|
|
94
|
+
generate(...[options]: ToolCallArguments<AgentModelTools<TOOLS, SANDBOX_TOOLS>, GenerateOptions>): Promise<GenerateTextResult<AgentModelTools<TOOLS, SANDBOX_TOOLS>, any, Output.Output<string, string, unknown>>>;
|
|
95
95
|
/**
|
|
96
96
|
* Stream a response from the agent.
|
|
97
97
|
*
|
|
@@ -106,18 +106,18 @@ declare class Agent<TOOLS extends ToolSet> {
|
|
|
106
106
|
* await printer.readableStream(stream.toUIMessageStream());
|
|
107
107
|
* ```
|
|
108
108
|
*/
|
|
109
|
-
stream(...[options]: ToolCallArguments<AgentModelTools<TOOLS>, StreamOptions<AgentModelTools<TOOLS>>>): Promise<AgentStream<AgentModelTools<TOOLS>>>;
|
|
109
|
+
stream(...[options]: ToolCallArguments<AgentModelTools<TOOLS, SANDBOX_TOOLS>, StreamOptions<AgentModelTools<TOOLS, SANDBOX_TOOLS>>>): Promise<AgentStream<AgentModelTools<TOOLS, SANDBOX_TOOLS>>>;
|
|
110
110
|
asTool<T = string>(props?: {
|
|
111
111
|
toolDescription?: string;
|
|
112
|
-
outputExtractor?: (output: Awaited<ReturnType<Agent<TOOLS>['generate']>>) => T | Promise<T>;
|
|
112
|
+
outputExtractor?: (output: Awaited<ReturnType<Agent<TOOLS, SANDBOX_TOOLS>['generate']>>) => T | Promise<T>;
|
|
113
113
|
/** Not sent to the model; surfaces on tool call/result and UI message parts */
|
|
114
114
|
metadata?: JSONObject;
|
|
115
115
|
toModelOutput?: Tool<SubagentToolInput, T | string>['toModelOutput'];
|
|
116
|
-
}): SubagentTool<T | string, InferToolSetContext<AgentModelTools<TOOLS>>>;
|
|
116
|
+
}): SubagentTool<T | string, InferToolSetContext<AgentModelTools<TOOLS, SANDBOX_TOOLS>>>;
|
|
117
117
|
asAdvisor(options?: AsAdvisorOptions): AdvisorResult;
|
|
118
|
-
clone(overrides?: Partial<CreateAgent<TOOLS>>): Agent<TOOLS>;
|
|
118
|
+
clone(overrides?: Partial<CreateAgent<TOOLS, SANDBOX_TOOLS>>): Agent<TOOLS, SANDBOX_TOOLS>;
|
|
119
119
|
}
|
|
120
|
-
export declare function agent<const TOOLS extends ToolSet = {}>(options: CreateAgent<TOOLS>): Agent<TOOLS>;
|
|
120
|
+
export declare function agent<const TOOLS extends ToolSet = {}, SANDBOX_TOOLS extends SandboxTools = SandboxTools>(options: CreateAgent<TOOLS, SANDBOX_TOOLS>): Agent<TOOLS, SANDBOX_TOOLS>;
|
|
121
121
|
/**
|
|
122
122
|
* Options for creating a structured output handler.
|
|
123
123
|
*/
|
package/dist/lib/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/lib/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,MAAM,EACN,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,qBAAqB,EAC1B,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,K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wBG;AACH,MAAM,WAAW,sBAAsB,CACrC,OAAO,SAAS,cAAc,EAC9B,KAAK,SAAS,OAAO;IAErB,QAAQ,CACN,GAAG,IAAI,EAAE,iBAAiB,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,GAChE,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IACjC,MAAM,CACJ,GAAG,IAAI,EAAE,iBAAiB,CACxB,aAAa,CAAC,KAAK,CAAC,EACpB,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CACpC,GACA,OAAO,CACR,gBAAgB,CACd,aAAa,CAAC,KAAK,CAAC,EACpB,GAAG,EACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CACzC,CACF,CAAC;CACH;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,SAAS,cAAc,EAC9B,KAAK,CAAC,KAAK,SAAS,OAAO,GAAG,EAAE,EAEhC,OAAO,EAAE,uBAAuB,CAAC,OAAO,EAAE,KAAK,CAAC,GAC/C,sBAAsB,CAAC,OAAO,EAAE,KAAK,CAAC,CA0GxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apple-container-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/apple-container-sandbox.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,eAAe,EAQhB,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"apple-container-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/apple-container-sandbox.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,eAAe,EAQhB,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAiB,iBAAiB,EAAE,MAAM,YAAY,C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+1,8 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type BashToolkit, type CreateBashToolOptions } from './types.ts';
|
|
2
2
|
/**
|
|
3
3
|
* Build the DeepAgents-owned bash/readFile/writeFile toolkit around a sandbox.
|
|
4
4
|
* The sandbox provides isolation and execution; these tools only translate AI
|
|
5
5
|
* SDK tool calls into that backend contract.
|
|
6
6
|
*/
|
|
7
|
-
export declare function createBashTool(options: CreateBashToolOptions): Promise<
|
|
7
|
+
export declare function createBashTool(options: CreateBashToolOptions): Promise<BashToolkit>;
|
|
8
8
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"bash-tool.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/bash-tool.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,qBAAqB,EAI3B,MAAM,YAAY,CAAC;AAgIpB;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,WAAW,CAAC,CAiItB"}
|
|
@@ -55,22 +55,14 @@ export interface SandboxNamedVolume {
|
|
|
55
55
|
removeOnDispose?: boolean;
|
|
56
56
|
}
|
|
57
57
|
export type SandboxVolume = SandboxBindVolume | SandboxNamedVolume;
|
|
58
|
-
/** Resource limits common to every engine. Engines extend with their own knobs. */
|
|
59
|
-
export interface SandboxResources {
|
|
60
|
-
/** `--memory` — e.g. `'1g'`, `'1024M'`. */
|
|
61
|
-
memory?: string;
|
|
62
|
-
/** `--cpus` — number of CPUs. */
|
|
63
|
-
cpus?: number;
|
|
64
|
-
}
|
|
65
58
|
/**
|
|
66
59
|
* The options the shared skeleton is allowed to read. Each engine extends this
|
|
67
|
-
* with its own dialect knobs (Docker's
|
|
60
|
+
* with its own dialect knobs (Docker's `container` create body; Apple's `arch`),
|
|
68
61
|
* which only its own engine methods see — the skeleton is typed to this common
|
|
69
62
|
* subset and physically cannot read them.
|
|
70
63
|
*/
|
|
71
64
|
export interface CommonSandboxOptions extends SandboxReadinessOptions {
|
|
72
65
|
volumes?: SandboxVolume[];
|
|
73
|
-
resources?: SandboxResources;
|
|
74
66
|
env?: Record<string, string>;
|
|
75
67
|
/**
|
|
76
68
|
* Stable identity suffix. When provided, the container is named
|
|
@@ -79,10 +71,12 @@ export interface CommonSandboxOptions extends SandboxReadinessOptions {
|
|
|
79
71
|
* volume preparation, and env are skipped); if it exists but is stopped, it is
|
|
80
72
|
* started first; otherwise it is created fresh. Must match `/^[A-Za-z0-9_.-]+$/`.
|
|
81
73
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
74
|
+
* Who owns the container follows who created it. A sandbox that created the
|
|
75
|
+
* container owns it: `dispose()` stops it, and `--rm` removes it. A sandbox
|
|
76
|
+
* that attached to an existing container borrows it: `dispose()` closes the
|
|
77
|
+
* connection to the engine and leaves the container running, also when the
|
|
78
|
+
* sandbox started a stopped one. When two sandboxes share a name, the
|
|
79
|
+
* container ends when the one that created it is disposed.
|
|
86
80
|
*/
|
|
87
81
|
name?: string;
|
|
88
82
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-engine.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/container-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAEzE,uFAAuF;AACvF,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,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OAIG;IACH,aAAa,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1E,gFAAgF;IAChF,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,8EAA8E;IAC9E,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,8DAA8D;IAC9D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { CommonSandboxOptions, ContainerEngine, ContainerErrorFactory, EngineContainer, SandboxVolume } from './container-engine.ts';
|
|
2
2
|
import { type Installer } from './installers/installer.ts';
|
|
3
3
|
import type { DisposableSandbox } from './types.ts';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* A container the strategy runs in, and whether an earlier caller created it.
|
|
6
|
+
* An attached container is borrowed: the sandbox never stops it.
|
|
7
|
+
*/
|
|
5
8
|
export interface AcquiredContainer {
|
|
6
9
|
container: EngineContainer;
|
|
7
10
|
attached: boolean;
|
|
@@ -40,10 +43,10 @@ export declare abstract class ContainerSandboxStrategy<TOpts extends CommonSandb
|
|
|
40
43
|
protected validateVolumes(): void;
|
|
41
44
|
private validateMountValue;
|
|
42
45
|
private cleanupCreatedVolumes;
|
|
43
|
-
/** Ends
|
|
46
|
+
/** Ends a container that this sandbox created: stops it, by default. */
|
|
44
47
|
protected release(container: EngineContainer): Promise<void>;
|
|
45
48
|
private assertBashAvailable;
|
|
46
|
-
protected createSandboxMethods(container:
|
|
49
|
+
protected createSandboxMethods({ container, attached, }: AcquiredContainer): DisposableSandbox;
|
|
47
50
|
protected abstract getImage(): Promise<string>;
|
|
48
51
|
protected abstract configure(container: EngineContainer, image: string): Promise<void>;
|
|
49
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/container-sandbox.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAIpD
|
|
1
|
+
{"version":3,"file":"container-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/container-sandbox.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAIpD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,eAAe,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,oBAAoB,EAC1B,MAAM,EAAE,qBAAqB,GAC5B,IAAI,CAON;AAYD;;;;;;;GAOG;AACH,8BAAsB,wBAAwB,CAC5C,KAAK,SAAS,oBAAoB,GAAG,oBAAoB;IAEzD,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IACzC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC;IACtB,SAAS,CAAC,OAAO,EAAE,aAAa,EAAE,CAAC;IACnC,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,cAAc,CAAqB;gBAE/B,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,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H,qBAAa,qBAAqB,CAChC,KAAK,SAAS,oBAAoB,GAAG,oBAAoB,CACzD,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IACvC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,CAAS;gBAGxB,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,EAC9B,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,OAAO,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;cASa,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;cAuB3B,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAC3C"}
|
|
@@ -2,8 +2,6 @@ import { type Experimental_SandboxFileStat } from '@ai-sdk/provider-utils';
|
|
|
2
2
|
import type { ContainerErrorFactory, EngineContainer, EngineProcess } from './container-engine.ts';
|
|
3
3
|
import type { CommandResult, DisposableSandbox } from './types.ts';
|
|
4
4
|
export declare const FILE_STAT_TYPES: readonly ["file", "directory", "other"];
|
|
5
|
-
/** The contract types `encoding` as a string; Node accepts only its own names. */
|
|
6
|
-
export declare function bufferEncoding(encoding?: string): BufferEncoding;
|
|
7
5
|
/** The stat of `path` through a command, for what no engine request reaches. */
|
|
8
6
|
export declare function statOverExec(container: Pick<EngineContainer, 'exec'>, path: string, signal: AbortSignal | undefined): Promise<Experimental_SandboxFileStat | null>;
|
|
9
7
|
/** The bytes of `path` through a command, for what no engine request reaches. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-session.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/container-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,4BAA4B,
|
|
1
|
+
{"version":3,"file":"container-session.d.ts","sourceRoot":"","sources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C5B,IAAI,CAAC,iBAAiB,EAAE,SAAS,GAAG,OAAO,MAAM,CAAC,YAAY,CAAC,CAsGjE"}
|
|
@@ -1,60 +1,51 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import type { DaytonaV2Client } from '@daytona/sdk';
|
|
2
|
+
import type { CreateSandboxOptions } from '@daytona/sdk/v2';
|
|
3
|
+
import type { DisposableSandbox, SandboxReadinessOptions } from './types.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a sandbox. With a `name`, a second create with the same name and
|
|
6
|
+
* options returns the sandbox the first one made, so the name is a
|
|
7
|
+
* get-or-create key; the same name with other options is a conflict.
|
|
8
|
+
*/
|
|
9
|
+
type DaytonaCreateOptions = Omit<CreateSandboxOptions, 'autoDelete' | 'idempotencyKey'> & {
|
|
10
|
+
sandboxId?: never;
|
|
11
|
+
/** A registered image name or `img_…` id. Default: the organization's default Linux image. */
|
|
12
|
+
image?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Attaches to a sandbox that exists. */
|
|
15
|
+
interface DaytonaAttachOptions {
|
|
16
|
+
sandboxId: string;
|
|
14
17
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* Existing Daytona sandbox id or name to attach to.
|
|
18
|
-
*/
|
|
19
|
-
sandboxId?: string;
|
|
18
|
+
type DaytonaTarget = DaytonaCreateOptions | DaytonaAttachOptions;
|
|
19
|
+
export type DaytonaSandboxOptions = SandboxReadinessOptions & {
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* supplied image/snapshot, env vars, volumes, and lifecycle intervals.
|
|
25
|
-
* Incompatible with `sandboxId`. `dispose()` never deletes the sandbox — the
|
|
26
|
-
* caller owns its lifecycle through the supplied client.
|
|
21
|
+
* Per-command timeout in milliseconds for `run` and `spawn`; the command
|
|
22
|
+
* then exits 124. Daytona's deadline counts whole seconds, so it is rounded
|
|
23
|
+
* up to the next second.
|
|
27
24
|
*/
|
|
28
|
-
name?: string;
|
|
29
|
-
user?: string;
|
|
30
|
-
snapshot?: string;
|
|
31
|
-
image?: string;
|
|
32
|
-
language?: string;
|
|
33
|
-
envVars?: Record<string, string>;
|
|
34
|
-
labels?: Record<string, string>;
|
|
35
|
-
public?: boolean;
|
|
36
|
-
resources?: DaytonaResources;
|
|
37
|
-
volumes?: DaytonaVolumeMount[];
|
|
38
|
-
networkAllowList?: string;
|
|
39
|
-
networkBlockAll?: boolean;
|
|
40
|
-
autoStopInterval?: number;
|
|
41
|
-
autoArchiveInterval?: number;
|
|
42
|
-
autoDeleteInterval?: number;
|
|
43
|
-
ephemeral?: boolean;
|
|
44
|
-
createTimeout?: number;
|
|
45
|
-
startTimeout?: number;
|
|
46
|
-
deleteTimeout?: number;
|
|
47
25
|
commandTimeout?: number;
|
|
48
|
-
|
|
49
|
-
}
|
|
26
|
+
} & DaytonaTarget;
|
|
50
27
|
export declare class DaytonaSandboxError extends Error {
|
|
51
28
|
constructor(message: string, cause?: Error);
|
|
52
29
|
}
|
|
53
30
|
export declare class DaytonaCreationError extends DaytonaSandboxError {
|
|
54
31
|
constructor(message: string, cause?: Error);
|
|
55
32
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Creates a sandbox backed by a Daytona v2 sandbox.
|
|
35
|
+
*
|
|
36
|
+
* `dispose()` deletes a sandbox this call created and leaves one it attached
|
|
37
|
+
* to, by `sandboxId` or by a `name` that already had a sandbox. A Linux
|
|
38
|
+
* Daytona sandbox has no stopped state, so delete is its only release.
|
|
39
|
+
*
|
|
40
|
+
* Requires the optional peer dependency `@daytona/sdk`.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const daytona = new Daytona();
|
|
45
|
+
* await using sandbox = await createDaytonaSandbox(daytona.v2, { name: chatId });
|
|
46
|
+
* const result = await sandbox.run({ command: 'echo hello' });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function createDaytonaSandbox(client: DaytonaV2Client, options?: DaytonaSandboxOptions): Promise<DisposableSandbox>;
|
|
50
|
+
export {};
|
|
60
51
|
//# sourceMappingURL=daytona-sandbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daytona-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/daytona-sandbox.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"daytona-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/daytona-sandbox.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EACV,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAkB7E;;;;GAIG;AACH,KAAK,oBAAoB,GAAG,IAAI,CAC9B,oBAAoB,EACpB,YAAY,GAAG,gBAAgB,CAChC,GAAG;IACF,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,8FAA8F;IAC9F,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,yCAAyC;AACzC,UAAU,oBAAoB;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,KAAK,aAAa,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;AAEjE,MAAM,MAAM,qBAAqB,GAAG,uBAAuB,GAAG;IAC5D;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,aAAa,CAAC;AAQlB,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAK3C;AAED,qBAAa,oBAAqB,SAAQ,mBAAmB;gBAC/C,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAI3C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,eAAe,EACvB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,iBAAiB,CAAC,CA4B5B"}
|
|
@@ -1,87 +1,23 @@
|
|
|
1
1
|
import type { Experimental_SandboxFileStat } from '@ai-sdk/provider-utils';
|
|
2
2
|
import { type Container, Docker, type EngineApi, type Environment } from '@zukhruf/docker';
|
|
3
|
-
import type { CommonSandboxOptions, ContainerEngine, ContainerErrorFactory, EngineContainer, EngineExecOptions, EngineProcess, EngineSpawnOptions, ImageBuildSpec, RunResult, SandboxNamedVolume,
|
|
3
|
+
import type { CommonSandboxOptions, ContainerEngine, ContainerErrorFactory, EngineContainer, EngineExecOptions, EngineProcess, EngineSpawnOptions, ImageBuildSpec, RunResult, SandboxNamedVolume, SandboxVolume } from './container-engine.ts';
|
|
4
4
|
import { type AcquiredContainer, ContainerSandboxStrategy } from './container-sandbox.ts';
|
|
5
5
|
import { type Installer, type InstallerContext } from './installers/installer.ts';
|
|
6
6
|
import type { CommandResult, DisposableSandbox } from './types.ts';
|
|
7
7
|
export type { SandboxBindVolume as DockerBindVolume, SandboxNamedVolume as DockerNamedVolume, SandboxVolume as DockerSandboxVolume, } from './container-engine.ts';
|
|
8
8
|
export { ComposeStartError, ContainerCreationError, DockerNotAvailableError, DockerSandboxError, DockerfileBuildError, type InstallErrorOptions, type InstallKind, InstallError, MissingRuntimeError, PackageInstallError, VolumeCreateError, VolumeInspectError, VolumePathError, VolumeRemoveError, } from './docker-sandbox-errors.ts';
|
|
9
|
-
export interface DockerResources extends SandboxResources {
|
|
10
|
-
/**
|
|
11
|
-
* `--memory-swap` — total memory + swap (e.g. `'1g'`). Without it Docker
|
|
12
|
-
* allows swap up to 2× `memory`; set it equal to `memory` to forbid swap
|
|
13
|
-
* entirely. Must be ≥ `memory`.
|
|
14
|
-
*/
|
|
15
|
-
memorySwap?: string;
|
|
16
|
-
/** `--shm-size` — size of `/dev/shm` (e.g. `'64m'`). Raise for Chromium/ML workloads. */
|
|
17
|
-
shmSize?: string;
|
|
18
|
-
/** `--pids-limit` — cap the container's process count (fork-bomb protection). */
|
|
19
|
-
pidsLimit?: number;
|
|
20
|
-
/** `--ulimit` per entry — e.g. `['nofile=1024:2048']`. */
|
|
21
|
-
ulimits?: string[];
|
|
22
|
-
/** `--cpuset-cpus` — CPUs the container may run on, e.g. `'0-1'`. */
|
|
23
|
-
cpusetCpus?: string;
|
|
24
|
-
/** `--cpu-shares` — relative CPU weight under contention. */
|
|
25
|
-
cpuShares?: number;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Container hardening for `docker run`. All optional — omit for the daemon's
|
|
29
|
-
* defaults (shared kernel, root user, writable root filesystem).
|
|
30
|
-
*/
|
|
31
|
-
export interface DockerSecurity {
|
|
32
|
-
/**
|
|
33
|
-
* `--cap-drop` per entry. `['ALL']` drops every Linux capability — the
|
|
34
|
-
* baseline for running untrusted code; re-grant via {@link capAdd}.
|
|
35
|
-
*/
|
|
36
|
-
capDrop?: string[];
|
|
37
|
-
/** `--cap-add` per entry. Re-grant only what's needed after dropping `ALL`. */
|
|
38
|
-
capAdd?: string[];
|
|
39
|
-
/**
|
|
40
|
-
* `--read-only` — mount the container root filesystem read-only. Writes then
|
|
41
|
-
* only land in `tmpfs`/volume mounts; pair with a writable `/workspace`
|
|
42
|
-
* (a {@link tmpfs} entry or volume) or the sandbox's `writeFiles` and the
|
|
43
|
-
* installer phase will fail.
|
|
44
|
-
*/
|
|
45
|
-
readOnly?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* `--user` (`uid[:gid]`) — run as a non-root user. The installer phase
|
|
48
|
-
* (`apk`/`apt`/`npm -g`/`pip`) needs root, so non-root suits a pre-baked
|
|
49
|
-
* Dockerfile image rather than the runtime-image + installers path.
|
|
50
|
-
*/
|
|
51
|
-
user?: string;
|
|
52
|
-
/**
|
|
53
|
-
* `--tmpfs` per entry (e.g. `'/tmp'`, `'/workspace:size=64m'`) — ephemeral,
|
|
54
|
-
* in-memory writable directories. The companion to {@link readOnly}.
|
|
55
|
-
*/
|
|
56
|
-
tmpfs?: string[];
|
|
57
|
-
/**
|
|
58
|
-
* `--security-opt` per entry — e.g. `['seccomp=/path/profile.json']` to apply
|
|
59
|
-
* a custom seccomp profile, or `['no-new-privileges']`.
|
|
60
|
-
*/
|
|
61
|
-
securityOpt?: string[];
|
|
62
|
-
}
|
|
63
|
-
/** Networking for `docker run`. */
|
|
64
|
-
export interface DockerNetwork {
|
|
65
|
-
/**
|
|
66
|
-
* `--network` — e.g. `'none'` (no network at all; strong isolation for
|
|
67
|
-
* untrusted code, but breaks network installers), a custom network name, or
|
|
68
|
-
* `'host'` (shares the host network stack — defeats isolation).
|
|
69
|
-
*/
|
|
70
|
-
mode?: string;
|
|
71
|
-
/** `--publish` per entry — e.g. `['8080:80']` to expose a container port. */
|
|
72
|
-
publish?: string[];
|
|
73
|
-
/** `--dns` per entry — custom DNS servers. */
|
|
74
|
-
dns?: string[];
|
|
75
|
-
/** `--add-host` per entry — e.g. `['db:10.0.0.5']` host-to-IP mappings. */
|
|
76
|
-
addHost?: string[];
|
|
77
|
-
/** `--hostname` — the container hostname. */
|
|
78
|
-
hostname?: string;
|
|
79
|
-
}
|
|
80
9
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
10
|
+
* The part of the Engine API create body that a Docker sandbox passes through:
|
|
11
|
+
* every field the sandbox does not own. The sandbox sets `Image` from `image`
|
|
12
|
+
* or `dockerfile`, `WorkingDir` from `workdir`, `Env` from `env` and `Cmd`
|
|
13
|
+
* from `command`. `HostConfig.AutoRemove` follows who created the container,
|
|
14
|
+
* and `HostConfig.Mounts` comes from `volumes`. `Labels` also go on the managed
|
|
15
|
+
* volumes that the sandbox creates.
|
|
84
16
|
*/
|
|
17
|
+
export type DockerContainerConfig = Omit<EngineApi.ContainerCreateRequest, 'Image' | 'WorkingDir' | 'Env' | 'Cmd' | 'HostConfig'> & {
|
|
18
|
+
HostConfig?: Omit<EngineApi.HostConfig, 'AutoRemove' | 'Mounts'>;
|
|
19
|
+
};
|
|
20
|
+
/** What the Docker engine reads, beside what the shared skeleton reads. */
|
|
85
21
|
export interface DockerCommonOptions extends CommonSandboxOptions {
|
|
86
22
|
/**
|
|
87
23
|
* The environment whose `DOCKER_HOST`, `DOCKER_CONTEXT` and `DOCKER_CONFIG`
|
|
@@ -89,47 +25,20 @@ export interface DockerCommonOptions extends CommonSandboxOptions {
|
|
|
89
25
|
*/
|
|
90
26
|
environment?: Environment;
|
|
91
27
|
volumes?: SandboxVolume[];
|
|
92
|
-
resources?: DockerResources;
|
|
93
28
|
/** Container execution timeout in milliseconds; excludes Docker/SSH connection setup. */
|
|
94
29
|
commandTimeout?: number;
|
|
95
30
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
31
|
+
* The platform of the container (e.g. `'linux/amd64'`), emulated when it
|
|
32
|
+
* differs from the engine's. The Dockerfile strategy also builds for it and
|
|
33
|
+
* folds it into the image-build cache key.
|
|
99
34
|
*/
|
|
100
35
|
platform?: string;
|
|
101
36
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* to run the container inside a lightweight VM with its own guest kernel
|
|
106
|
-
* instead of sharing the host kernel. The runtime must already be installed on
|
|
107
|
-
* the host and registered in the Docker daemon — and the host must have
|
|
108
|
-
* hardware virtualization (`/dev/kvm`); it is not provisioned here.
|
|
109
|
-
*/
|
|
110
|
-
runtime?: string;
|
|
111
|
-
/** Container hardening: capabilities, read-only rootfs, user, tmpfs, security-opt. */
|
|
112
|
-
security?: DockerSecurity;
|
|
113
|
-
/** Networking: network mode, published ports, DNS, host mappings, hostname. */
|
|
114
|
-
network?: DockerNetwork;
|
|
115
|
-
/**
|
|
116
|
-
* `--gpus` — e.g. `'all'`. Requires the nvidia container runtime on the host
|
|
117
|
-
* and is incompatible with a `runtime` such as `'kata-runtime'`.
|
|
37
|
+
* The create body of the container, as `@zukhruf/docker` takes it: limits,
|
|
38
|
+
* capabilities, user, network, devices, OCI runtime. The sandbox adds no
|
|
39
|
+
* limit of its own, so the engine's defaults apply to what this leaves out.
|
|
118
40
|
*/
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* `--device` per entry — expose a host device, e.g. `['/dev/fuse']`. Passed
|
|
122
|
-
* through verbatim; the library never injects a device implicitly.
|
|
123
|
-
*/
|
|
124
|
-
devices?: string[];
|
|
125
|
-
/** `--init` — run an init process as PID 1 that reaps zombie subprocesses. */
|
|
126
|
-
init?: boolean;
|
|
127
|
-
/** `--label` metadata on the container and any managed volumes it creates. */
|
|
128
|
-
labels?: Record<string, string>;
|
|
129
|
-
/** `--sysctl` — kernel parameters, emitted as `key=value` per entry. */
|
|
130
|
-
sysctls?: Record<string, string>;
|
|
131
|
-
/** `--entrypoint` — override the image `ENTRYPOINT`. */
|
|
132
|
-
entrypoint?: string;
|
|
41
|
+
container?: DockerContainerConfig;
|
|
133
42
|
}
|
|
134
43
|
export interface RuntimeSandboxOptions extends DockerCommonOptions {
|
|
135
44
|
/** Docker image to use (default: `'bash:5.3-alpine3.24'`). */
|
|
@@ -161,7 +70,6 @@ export interface ComposeSandboxOptions {
|
|
|
161
70
|
environment?: Environment;
|
|
162
71
|
compose: string;
|
|
163
72
|
service: string;
|
|
164
|
-
resources?: DockerResources;
|
|
165
73
|
/** Container execution timeout in milliseconds; excludes Docker/SSH connection setup. */
|
|
166
74
|
commandTimeout?: number;
|
|
167
75
|
}
|
|
@@ -174,13 +82,6 @@ interface FileLayout {
|
|
|
174
82
|
workdir: string;
|
|
175
83
|
/** Paths only an exec reaches: tmpfs mounts and the kernel filesystems. */
|
|
176
84
|
execOnly: string[];
|
|
177
|
-
/** The container user (`Config.User`): `''` for root, or `user[:group]` by name or ID. */
|
|
178
|
-
user: string;
|
|
179
|
-
}
|
|
180
|
-
/** The IDs that own a file the sandbox writes. */
|
|
181
|
-
interface Owner {
|
|
182
|
-
uid: number;
|
|
183
|
-
gid: number;
|
|
184
85
|
}
|
|
185
86
|
/** A sandbox container on the Docker engine. */
|
|
186
87
|
declare class DockerContainer implements EngineContainer {
|
|
@@ -188,7 +89,7 @@ declare class DockerContainer implements EngineContainer {
|
|
|
188
89
|
readonly name: string;
|
|
189
90
|
readonly workdir: string;
|
|
190
91
|
readonly commandTimeout: number | undefined;
|
|
191
|
-
constructor(name: string, container: Container, layout: FileLayout,
|
|
92
|
+
constructor(name: string, container: Container, layout: FileLayout, commandTimeout: number | undefined, autoRemove: boolean);
|
|
192
93
|
exec(argv: string[], options?: EngineExecOptions): Promise<CommandResult>;
|
|
193
94
|
spawn(argv: string[], options: EngineSpawnOptions): Promise<EngineProcess>;
|
|
194
95
|
readFile(path: string, signal: AbortSignal | undefined): Promise<Uint8Array | null>;
|
|
@@ -219,7 +120,7 @@ export declare class DockerEngine implements ContainerEngine<DockerCommonOptions
|
|
|
219
120
|
*/
|
|
220
121
|
static connect(environment: Environment, commandTimeout: number | undefined): Promise<DockerEngine>;
|
|
221
122
|
/** A sandbox container handle for a container of this engine. */
|
|
222
|
-
container(name: string, container: Container, info: EngineApi.ContainerInspectResponse):
|
|
123
|
+
container(name: string, container: Container, info: EngineApi.ContainerInspectResponse): DockerContainer;
|
|
223
124
|
attach(name: string, image: string): Promise<DockerContainer | undefined>;
|
|
224
125
|
run(image: string, name: string, opts: DockerCommonOptions, workdir: string): Promise<RunResult>;
|
|
225
126
|
volumeExists(name: string): Promise<boolean>;
|
|
@@ -227,13 +128,13 @@ export declare class DockerEngine implements ContainerEngine<DockerCommonOptions
|
|
|
227
128
|
removeVolume(name: string): Promise<void>;
|
|
228
129
|
ensureWorkdir(): Promise<void>;
|
|
229
130
|
imageExists(tag: string): Promise<boolean>;
|
|
131
|
+
/** An inline Dockerfile goes to `docker build -f -` on stdin. */
|
|
230
132
|
buildImage(spec: ImageBuildSpec): Promise<void>;
|
|
231
133
|
dispose(): Promise<void>;
|
|
232
134
|
}
|
|
233
135
|
export interface ComposeStrategyArgs {
|
|
234
136
|
compose: string;
|
|
235
137
|
service: string;
|
|
236
|
-
resources?: DockerResources;
|
|
237
138
|
}
|
|
238
139
|
/**
|
|
239
140
|
* Manages multi-container environments via `docker compose`. Docker-only — the
|