@deepagents/context 3.1.0 → 4.1.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 +57 -19
- package/dist/browser.js +48 -64
- package/dist/browser.js.map +3 -3
- package/dist/index.js +2004 -1479
- package/dist/index.js.map +4 -4
- package/dist/lib/agent.d.ts.map +1 -1
- package/dist/lib/chain-summary.d.ts.map +1 -1
- package/dist/lib/engine.d.ts +3 -3
- package/dist/lib/engine.d.ts.map +1 -1
- package/dist/lib/fragments/message/user.d.ts +51 -92
- package/dist/lib/fragments/message/user.d.ts.map +1 -1
- package/dist/lib/sandbox/agent-os-sandbox.d.ts.map +1 -1
- package/dist/lib/sandbox/apple-container-sandbox-errors.d.ts +44 -0
- package/dist/lib/sandbox/apple-container-sandbox-errors.d.ts.map +1 -0
- package/dist/lib/sandbox/apple-container-sandbox.d.ts +122 -0
- package/dist/lib/sandbox/apple-container-sandbox.d.ts.map +1 -0
- package/dist/lib/sandbox/bash-tool.d.ts +9 -28
- package/dist/lib/sandbox/bash-tool.d.ts.map +1 -1
- package/dist/lib/sandbox/cli-process.d.ts +24 -0
- package/dist/lib/sandbox/cli-process.d.ts.map +1 -0
- package/dist/lib/sandbox/container-engine.d.ts +149 -0
- package/dist/lib/sandbox/container-engine.d.ts.map +1 -0
- package/dist/lib/sandbox/container-sandbox-errors.d.ts +10 -0
- package/dist/lib/sandbox/container-sandbox-errors.d.ts.map +1 -0
- package/dist/lib/sandbox/container-sandbox.d.ts +90 -0
- package/dist/lib/sandbox/container-sandbox.d.ts.map +1 -0
- package/dist/lib/sandbox/daytona-sandbox.d.ts.map +1 -1
- package/dist/lib/sandbox/docker-sandbox-errors.d.ts +2 -2
- package/dist/lib/sandbox/docker-sandbox-errors.d.ts.map +1 -1
- package/dist/lib/sandbox/docker-sandbox.d.ts +122 -189
- package/dist/lib/sandbox/docker-sandbox.d.ts.map +1 -1
- package/dist/lib/sandbox/index.d.ts +6 -1
- package/dist/lib/sandbox/index.d.ts.map +1 -1
- package/dist/lib/sandbox/installers/bin.d.ts.map +1 -1
- package/dist/lib/sandbox/installers/index.d.ts +7 -7
- package/dist/lib/sandbox/installers/index.d.ts.map +1 -1
- package/dist/lib/sandbox/installers/installer.d.ts +0 -5
- package/dist/lib/sandbox/installers/installer.d.ts.map +1 -1
- package/dist/lib/sandbox/installers/url-binary.d.ts.map +1 -1
- package/dist/lib/sandbox/shell-quote.d.ts +10 -0
- package/dist/lib/sandbox/shell-quote.d.ts.map +1 -0
- package/dist/lib/sandbox/strace/file-change.d.ts +21 -0
- package/dist/lib/sandbox/strace/file-change.d.ts.map +1 -0
- package/dist/lib/sandbox/strace/file-changes.d.ts +66 -0
- package/dist/lib/sandbox/strace/file-changes.d.ts.map +1 -0
- package/dist/lib/sandbox/strace/index.d.ts +74 -0
- package/dist/lib/sandbox/strace/index.d.ts.map +1 -0
- package/dist/lib/sandbox/strace/index.js +296 -0
- package/dist/lib/sandbox/strace/index.js.map +7 -0
- package/dist/lib/sandbox/types.d.ts +9 -4
- package/dist/lib/sandbox/types.d.ts.map +1 -1
- package/dist/lib/sandbox/virtual-sandbox.d.ts.map +1 -1
- package/dist/lib/save/save-pipeline.d.ts +1 -13
- package/dist/lib/save/save-pipeline.d.ts.map +1 -1
- package/dist/lib/skills/skill-reminder.d.ts +2 -2
- package/dist/lib/skills/skill-reminder.d.ts.map +1 -1
- package/package.json +9 -3
- package/dist/lib/sandbox/file-changes.d.ts +0 -83
- package/dist/lib/sandbox/file-changes.d.ts.map +0 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { ContainerSandboxError } from './container-sandbox-errors.ts';
|
|
2
|
+
import type { InstallerContext } from './installers/installer.ts';
|
|
3
|
+
export interface ContainerErrorFactory {
|
|
4
|
+
serviceNotAvailable(): ContainerSandboxError;
|
|
5
|
+
creation(message: string, image: string, cause?: Error): ContainerSandboxError;
|
|
6
|
+
generic(message: string, containerId?: string): ContainerSandboxError;
|
|
7
|
+
volumePath(source: string, containerPath: string, reason: string): ContainerSandboxError;
|
|
8
|
+
volumeInspect(name: string, reason: string): ContainerSandboxError;
|
|
9
|
+
volumeCreate(name: string, reason: string): ContainerSandboxError;
|
|
10
|
+
volumeRemove(name: string, reason: string): ContainerSandboxError;
|
|
11
|
+
}
|
|
12
|
+
/** Resolved build request handed to {@link ContainerEngine.buildImage}. */
|
|
13
|
+
export interface ImageBuildSpec {
|
|
14
|
+
/** Precomputed content-hash image tag the engine must build. */
|
|
15
|
+
tag: string;
|
|
16
|
+
/** Inline Dockerfile content (contains `\n`) or a path to one. */
|
|
17
|
+
dockerfile: string;
|
|
18
|
+
/** Build context directory. */
|
|
19
|
+
context: string;
|
|
20
|
+
/** Stream build output to the parent stdio instead of buffering it. */
|
|
21
|
+
showBuildLogs: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Platform (Docker `--platform`) / arch (Apple `--arch`). Already folded into
|
|
24
|
+
* `tag` by the strategy; the engine re-reads it for the build flag.
|
|
25
|
+
*/
|
|
26
|
+
identity?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SandboxBindVolume {
|
|
29
|
+
type: 'bind';
|
|
30
|
+
hostPath: string;
|
|
31
|
+
containerPath: string;
|
|
32
|
+
/** Default: `true`. */
|
|
33
|
+
readOnly?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A named volume mount. The superset shape across engines — `driver`/
|
|
37
|
+
* `driverOptions`/`subPath`/`noCopy` are read only by engines that support them
|
|
38
|
+
* (Docker); engines without a pluggable driver model (Apple) ignore them.
|
|
39
|
+
*/
|
|
40
|
+
export interface SandboxNamedVolume {
|
|
41
|
+
type: 'volume';
|
|
42
|
+
name: string;
|
|
43
|
+
containerPath: string;
|
|
44
|
+
/** Default: `true`. */
|
|
45
|
+
readOnly?: boolean;
|
|
46
|
+
/** Default: `'external'`. */
|
|
47
|
+
lifecycle?: 'external' | 'managed';
|
|
48
|
+
/** Volume driver used when `lifecycle` is `'managed'` (Docker `--driver`). */
|
|
49
|
+
driver?: string;
|
|
50
|
+
/** Volume driver options used when `lifecycle` is `'managed'`. */
|
|
51
|
+
driverOptions?: Record<string, string>;
|
|
52
|
+
subPath?: string;
|
|
53
|
+
noCopy?: boolean;
|
|
54
|
+
/** Default: `true` for managed volumes created by this sandbox. */
|
|
55
|
+
removeOnDispose?: boolean;
|
|
56
|
+
}
|
|
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
|
+
/**
|
|
66
|
+
* The options the shared skeleton is allowed to read. Each engine extends this
|
|
67
|
+
* with its own dialect knobs (Docker's security/network/…; Apple's `arch`),
|
|
68
|
+
* which only its own engine methods see — the skeleton is typed to this common
|
|
69
|
+
* subset and physically cannot read them.
|
|
70
|
+
*/
|
|
71
|
+
export interface CommonSandboxOptions {
|
|
72
|
+
volumes?: SandboxVolume[];
|
|
73
|
+
resources?: SandboxResources;
|
|
74
|
+
env?: Record<string, string>;
|
|
75
|
+
/**
|
|
76
|
+
* Stable identity suffix. When provided, the container is named
|
|
77
|
+
* `sandbox-<name>` instead of a randomized `sandbox-<8hex>`. If a container
|
|
78
|
+
* with that name already exists, the sandbox attaches to it (installers,
|
|
79
|
+
* volume preparation, and env are skipped); if it exists but is stopped, it is
|
|
80
|
+
* started first; otherwise it is created fresh. Must match `/^[A-Za-z0-9_.-]+$/`.
|
|
81
|
+
*
|
|
82
|
+
* Warning: `dispose()` stops (and `--rm` removes) the container regardless of
|
|
83
|
+
* whether it was created or attached to. If two callers in the same process
|
|
84
|
+
* share a name, the first `dispose()` destroys the container the other is
|
|
85
|
+
* still using.
|
|
86
|
+
*/
|
|
87
|
+
name?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Args appended after the image at run time.
|
|
90
|
+
* - `undefined` (default): `['tail', '-f', '/dev/null']` keep-alive so a bare
|
|
91
|
+
* image stays up for installers and `executeCommand`.
|
|
92
|
+
* - `[]` or `null`: nothing is appended; the image's own `CMD`/`ENTRYPOINT`
|
|
93
|
+
* runs as declared.
|
|
94
|
+
* - A non-empty array: appended verbatim, overriding the image `CMD`.
|
|
95
|
+
*/
|
|
96
|
+
command?: readonly string[] | null;
|
|
97
|
+
/** Working directory inside the container (default `'/workspace'`). */
|
|
98
|
+
workdir?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The CLI dialect seam. Captures everything that differs between container
|
|
102
|
+
* runtimes (binary, run/exec arg flags, status parsing, error-string detection,
|
|
103
|
+
* workdir bootstrap, image build) so one shared strategy can orchestrate any
|
|
104
|
+
* engine. Generic over `TOpts` so each engine reads its own dialect-specific run
|
|
105
|
+
* knobs off the resolved options while the skeleton only ever supplies the
|
|
106
|
+
* common subset. Implemented by `dockerEngine` (docker-sandbox.ts) and
|
|
107
|
+
* `appleEngine` (apple-container-sandbox.ts).
|
|
108
|
+
*/
|
|
109
|
+
export interface ContainerEngine<TOpts extends CommonSandboxOptions = CommonSandboxOptions> {
|
|
110
|
+
readonly cli: string;
|
|
111
|
+
/**
|
|
112
|
+
* Build the `<cli> run` argv from resolved options. The shared skeleton
|
|
113
|
+
* supplies `image`, `containerId`, and `workdir`; every other flag is the
|
|
114
|
+
* engine's own dialect read off `opts`.
|
|
115
|
+
*/
|
|
116
|
+
runArgs(image: string, containerId: string, opts: TOpts, workdir: string): string[];
|
|
117
|
+
execArgs(containerId: string, command: string, options?: {
|
|
118
|
+
cwd?: string;
|
|
119
|
+
env?: Record<string, string>;
|
|
120
|
+
}): string[];
|
|
121
|
+
inspectArgs(containerId: string): string[];
|
|
122
|
+
mountArg(volume: SandboxVolume): string;
|
|
123
|
+
parseStatus(status: string): 'running' | 'stopped' | 'absent';
|
|
124
|
+
volumeCreateArgs(volume: SandboxNamedVolume): string[];
|
|
125
|
+
errorMessage(error: unknown): string;
|
|
126
|
+
isServiceDown(message: string): boolean;
|
|
127
|
+
isMissingContainer(message: string): boolean;
|
|
128
|
+
isMissingVolume(message: string): boolean;
|
|
129
|
+
isNameConflict(message: string): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Ensure `workdir` exists before any `exec` runs in it. Docker's `run -w`
|
|
132
|
+
* auto-creates the workdir (no-op here); Apple's per-exec `--cwd` fails on a
|
|
133
|
+
* missing dir, so its engine bootstraps it with `mkdir -p`.
|
|
134
|
+
*/
|
|
135
|
+
ensureWorkdir(containerId: string, workdir: string): Promise<void>;
|
|
136
|
+
/** Image used when no `image` option is given. */
|
|
137
|
+
readonly defaultImage: string;
|
|
138
|
+
/**
|
|
139
|
+
* Build the installer context that drives this engine's post-start installer
|
|
140
|
+
* phase (`pkg`/`npm`/`pip`/…) over the engine's own `exec`.
|
|
141
|
+
*/
|
|
142
|
+
createInstallerContext(containerId: string, image: string): InstallerContext;
|
|
143
|
+
/** Whether image `tag` already exists locally (so the build can be skipped). */
|
|
144
|
+
imageExists(tag: string): Promise<boolean>;
|
|
145
|
+
/** Build the image described by `spec`. The engine owns the build dialect. */
|
|
146
|
+
buildImage(spec: ImageBuildSpec): Promise<void>;
|
|
147
|
+
readonly errors: ContainerErrorFactory;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=container-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-engine.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/container-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,WAAW,qBAAqB;IACpC,mBAAmB,IAAI,qBAAqB,CAAC;IAC7C,QAAQ,C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`container`). Catch this to handle any backend's failure uniformly; catch a
|
|
4
|
+
* specific subclass (e.g. {@link DockerSandboxError}) for engine-specific cases.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ContainerSandboxError extends Error {
|
|
7
|
+
readonly containerId?: string;
|
|
8
|
+
constructor(message: string, containerId?: string);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=container-sandbox-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-sandbox-errors.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/container-sandbox-errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;CAKlD"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type CommandResult } from 'bash-tool';
|
|
2
|
+
import type { CommonSandboxOptions, ContainerEngine, SandboxVolume } from './container-engine.ts';
|
|
3
|
+
import { type Installer } from './installers/installer.ts';
|
|
4
|
+
import type { DisposableSandbox, ExecuteCommandOptions, SandboxProcess, SpawnOptions } from './types.ts';
|
|
5
|
+
interface StrategyContext {
|
|
6
|
+
containerId: string;
|
|
7
|
+
image: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Template Method base for sandbox creation strategies, shared across engines.
|
|
11
|
+
* Subclasses choose the image and define post-start configuration; the base owns
|
|
12
|
+
* container lifecycle, exec, and file I/O, delegating every CLI dialect to the
|
|
13
|
+
* injected {@link ContainerEngine}. Typed to {@link CommonSandboxOptions} so the
|
|
14
|
+
* skeleton can never read an engine-only knob.
|
|
15
|
+
*/
|
|
16
|
+
export declare abstract class ContainerSandboxStrategy<TOpts extends CommonSandboxOptions = CommonSandboxOptions> {
|
|
17
|
+
protected context: StrategyContext;
|
|
18
|
+
protected engine: ContainerEngine<TOpts>;
|
|
19
|
+
protected opts: TOpts;
|
|
20
|
+
protected volumes: SandboxVolume[];
|
|
21
|
+
protected name?: string;
|
|
22
|
+
protected workdir: string;
|
|
23
|
+
private createdVolumes;
|
|
24
|
+
constructor(opts: TOpts, engine: ContainerEngine<TOpts>);
|
|
25
|
+
create(): Promise<DisposableSandbox>;
|
|
26
|
+
private namedContainerId;
|
|
27
|
+
protected defaultContainerId(): string;
|
|
28
|
+
protected acquireContainer(image: string): Promise<{
|
|
29
|
+
containerId: string;
|
|
30
|
+
attached: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
private startStoppedContainer;
|
|
33
|
+
protected inspectContainer(containerId: string): Promise<'running' | 'stopped' | 'absent'>;
|
|
34
|
+
protected prepareVolumes(): Promise<void>;
|
|
35
|
+
protected validateVolumes(): void;
|
|
36
|
+
private validateMountValue;
|
|
37
|
+
protected buildRunArgs(image: string, containerId: string): string[];
|
|
38
|
+
private inspectVolume;
|
|
39
|
+
private volumeExists;
|
|
40
|
+
private createVolume;
|
|
41
|
+
private cleanupCreatedVolumes;
|
|
42
|
+
private cleanupCreatedVolumesAfterFailure;
|
|
43
|
+
private engineErrorMessage;
|
|
44
|
+
private isServiceDown;
|
|
45
|
+
protected startContainer(image: string, containerId: string): Promise<void>;
|
|
46
|
+
protected stopContainer(containerId: string): Promise<void>;
|
|
47
|
+
protected exec(command: string, options?: ExecuteCommandOptions): Promise<CommandResult>;
|
|
48
|
+
protected spawnProcess(command: string, options?: SpawnOptions): SandboxProcess;
|
|
49
|
+
protected createSandboxMethods(): DisposableSandbox;
|
|
50
|
+
protected abstract getImage(): Promise<string>;
|
|
51
|
+
protected abstract configure(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Starts a vanilla image and runs the supplied installers in order. Shared by
|
|
55
|
+
* both engines — the post-start installer context comes from
|
|
56
|
+
* `engine.createInstallerContext`, so the same class drives `docker exec` and
|
|
57
|
+
* `container exec`.
|
|
58
|
+
*/
|
|
59
|
+
export declare class RuntimeStrategy<TOpts extends CommonSandboxOptions = CommonSandboxOptions> extends ContainerSandboxStrategy<TOpts> {
|
|
60
|
+
private image;
|
|
61
|
+
private installers;
|
|
62
|
+
constructor(opts: TOpts, engine: ContainerEngine<TOpts>, mode: {
|
|
63
|
+
image: string;
|
|
64
|
+
installers: Installer[];
|
|
65
|
+
});
|
|
66
|
+
protected getImage(): Promise<string>;
|
|
67
|
+
protected configure(): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Builds a custom image from a Dockerfile (content-hash caching), delegating the
|
|
71
|
+
* build invocation to `engine.buildImage`. Shared by both engines — the tag
|
|
72
|
+
* computation and existence check are common; only the build dialect differs.
|
|
73
|
+
* Runs no post-start configuration — the Dockerfile defines the image.
|
|
74
|
+
*/
|
|
75
|
+
export declare class ContainerfileStrategy<TOpts extends CommonSandboxOptions = CommonSandboxOptions> extends ContainerSandboxStrategy<TOpts> {
|
|
76
|
+
private dockerfile;
|
|
77
|
+
private dockerContext;
|
|
78
|
+
private showBuildLogs;
|
|
79
|
+
private identity?;
|
|
80
|
+
constructor(opts: TOpts, engine: ContainerEngine<TOpts>, mode: {
|
|
81
|
+
dockerfile: string;
|
|
82
|
+
context: string;
|
|
83
|
+
showBuildLogs: boolean;
|
|
84
|
+
identity?: string;
|
|
85
|
+
});
|
|
86
|
+
protected getImage(): Promise<string>;
|
|
87
|
+
protected configure(): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
export {};
|
|
90
|
+
//# sourceMappingURL=container-sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/container-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAW/C,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EAEf,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,OAAO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AAO,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daytona-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/daytona-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,OAAO,EAER,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"daytona-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/daytona-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,OAAO,EAER,MAAM,cAAc,CAAC;AAKtB,OAAO,KAAK,EACV,iBAAiB,EAKlB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,2BAA2B,kBAAkB,CAAC;AAM3D,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,S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wBAAsB,oBAAoB,CACxC,MAAM,EAAE,OAAO,EACf,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,iBAAiB,CAAC,CAyB5B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ContainerSandboxError } from './container-sandbox-errors.ts';
|
|
2
|
+
export declare class DockerSandboxError extends ContainerSandboxError {
|
|
3
3
|
constructor(message: string, containerId?: string);
|
|
4
4
|
}
|
|
5
5
|
export declare class DockerNotAvailableError extends DockerSandboxError {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker-sandbox-errors.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/docker-sandbox-errors.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"docker-sandbox-errors.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/docker-sandbox-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,qBAAa,kBAAmB,SAAQ,qBAAqB;gBAC/C,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;CAIlD;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,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