@deepagents/context 2.1.0 → 2.3.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 +845 -112
- 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.map +1 -1
- package/dist/lib/sandbox/agent-os-sandbox.d.ts +5 -1
- package/dist/lib/sandbox/agent-os-sandbox.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 +9 -4
- package/dist/lib/sandbox/docker-sandbox-errors.d.ts.map +1 -1
- package/dist/lib/sandbox/docker-sandbox.d.ts +24 -1
- package/dist/lib/sandbox/docker-sandbox.d.ts.map +1 -1
- package/dist/lib/sandbox/file-events.d.ts +10 -1
- package/dist/lib/sandbox/file-events.d.ts.map +1 -1
- package/dist/lib/sandbox/index.d.ts +1 -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/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 +7 -3
- package/dist/lib/sandbox/container-tool.d.ts +0 -190
- package/dist/lib/sandbox/container-tool.d.ts.map +0 -1
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import type { CreateBashToolOptions } from 'bash-tool';
|
|
2
|
-
import { type DockerResources, type DockerSandboxVolume } from './docker-sandbox.ts';
|
|
3
|
-
import type { Installer } from './installers/installer.ts';
|
|
4
|
-
import type { AgentSandbox, SkillUploadInput } from './types.ts';
|
|
5
|
-
/**
|
|
6
|
-
* Base options shared by RuntimeContainerToolOptions and DockerfileContainerToolOptions.
|
|
7
|
-
*/
|
|
8
|
-
interface BaseContainerToolOptions extends Omit<CreateBashToolOptions, 'sandbox' | 'uploadDirectory'> {
|
|
9
|
-
/** Bind paths or Docker-managed volumes to attach to the container. */
|
|
10
|
-
volumes?: DockerSandboxVolume[];
|
|
11
|
-
/** Resource limits for the container */
|
|
12
|
-
resources?: DockerResources;
|
|
13
|
-
/** Environment variables to set in the container */
|
|
14
|
-
env?: Record<string, string>;
|
|
15
|
-
/**
|
|
16
|
-
* Skill directories to upload into the container at startup. Each entry's
|
|
17
|
-
* contents are copied to `sandbox` and parsed into `sandbox.skills`.
|
|
18
|
-
*/
|
|
19
|
-
skills?: SkillUploadInput[];
|
|
20
|
-
/**
|
|
21
|
-
* Stable container name suffix. When set, the container is named
|
|
22
|
-
* `sandbox-<name>`; subsequent calls with the same `name` attach to the
|
|
23
|
-
* running (or stopped) container instead of creating a new one — skipping
|
|
24
|
-
* installers, volume setup, and env. Otherwise a randomized
|
|
25
|
-
* `sandbox-<8hex>` name is used per call.
|
|
26
|
-
*/
|
|
27
|
-
name?: string;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Options for container tool using RuntimeStrategy.
|
|
31
|
-
* Installs packages/binaries at container runtime.
|
|
32
|
-
*/
|
|
33
|
-
export interface RuntimeContainerToolOptions extends BaseContainerToolOptions {
|
|
34
|
-
/** Docker image to use (default: 'alpine:latest') */
|
|
35
|
-
image?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Ordered list of installers run after the container starts.
|
|
38
|
-
*
|
|
39
|
-
* Built-in factory helpers:
|
|
40
|
-
* - `pkg([...])` — OS packages (apk/apt-get auto-detected)
|
|
41
|
-
* - `urlBinary({ name, url, binaryPath? })` — pre-built binary from a URL
|
|
42
|
-
* - `npm(name, { ensureRuntime?, version? })` — global npm install
|
|
43
|
-
* - `pip(name, { ensureRuntime?, version? })` — pip install
|
|
44
|
-
* - `githubRelease({ owner, repo, version, name, asset })` — GitHub release asset
|
|
45
|
-
*
|
|
46
|
-
* For anything else, subclass `Installer` and pass an instance directly.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* import { pkg, urlBinary, npm } from '@deepagents/context';
|
|
51
|
-
*
|
|
52
|
-
* createContainerTool({
|
|
53
|
-
* installers: [
|
|
54
|
-
* pkg(['curl', 'jq']),
|
|
55
|
-
* npm('prettier', { ensureRuntime: true }),
|
|
56
|
-
* ],
|
|
57
|
-
* });
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
installers?: Installer[];
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Options for container tool using DockerfileStrategy.
|
|
64
|
-
* Builds custom image from Dockerfile (with caching).
|
|
65
|
-
*/
|
|
66
|
-
export interface DockerfileContainerToolOptions extends BaseContainerToolOptions {
|
|
67
|
-
/** Dockerfile content (if contains newlines) or path to Dockerfile */
|
|
68
|
-
dockerfile: string;
|
|
69
|
-
/** Build context directory (default: '.') */
|
|
70
|
-
context?: string;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Options for container tool using ComposeStrategy.
|
|
74
|
-
* Manages multi-container environments via Docker Compose.
|
|
75
|
-
*/
|
|
76
|
-
export interface ComposeContainerToolOptions extends Omit<CreateBashToolOptions, 'sandbox' | 'uploadDirectory'> {
|
|
77
|
-
/** Path to docker-compose.yml file */
|
|
78
|
-
compose: string;
|
|
79
|
-
/** Service name to execute commands in (required) */
|
|
80
|
-
service: string;
|
|
81
|
-
/** Resource limits for the container */
|
|
82
|
-
resources?: DockerResources;
|
|
83
|
-
/**
|
|
84
|
-
* Skill directories to upload into the container at startup. Each entry's
|
|
85
|
-
* contents are copied to `sandbox` and parsed into `sandbox.skills`.
|
|
86
|
-
*/
|
|
87
|
-
skills?: SkillUploadInput[];
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Union type for container tool options.
|
|
91
|
-
* - RuntimeContainerToolOptions: Runtime package/binary installation
|
|
92
|
-
* - DockerfileContainerToolOptions: Pre-built images from Dockerfile
|
|
93
|
-
* - ComposeContainerToolOptions: Multi-container environments via Docker Compose
|
|
94
|
-
*/
|
|
95
|
-
export type ContainerToolOptions = RuntimeContainerToolOptions | DockerfileContainerToolOptions | ComposeContainerToolOptions;
|
|
96
|
-
/**
|
|
97
|
-
* Creates a bash tool that runs in a Docker container.
|
|
98
|
-
*
|
|
99
|
-
* This is a high-level wrapper that combines `createDockerSandbox()` and
|
|
100
|
-
* `createBashTool()` into a single call. It provides a convenient way to
|
|
101
|
-
* get a bash tool that executes real binaries in an isolated container.
|
|
102
|
-
*
|
|
103
|
-
* Supports three strategies:
|
|
104
|
-
* - **RuntimeStrategy**: Uses existing image, installs packages/binaries at runtime
|
|
105
|
-
* - **DockerfileStrategy**: Builds custom image from Dockerfile (with caching)
|
|
106
|
-
* - **ComposeStrategy**: Multi-container environments via Docker Compose
|
|
107
|
-
*
|
|
108
|
-
* The optional `skills` input makes the sandbox the single source of truth for
|
|
109
|
-
* skills: files are uploaded into the container and `sandbox.skills` is
|
|
110
|
-
* populated from on-disk `SKILL.md` frontmatter.
|
|
111
|
-
*
|
|
112
|
-
* @example RuntimeStrategy (default)
|
|
113
|
-
* ```typescript
|
|
114
|
-
* import { createContainerTool, pkg } from '@deepagents/context';
|
|
115
|
-
*
|
|
116
|
-
* const sandbox = await createContainerTool({
|
|
117
|
-
* installers: [pkg(['curl', 'jq'])],
|
|
118
|
-
* volumes: [{
|
|
119
|
-
* type: 'bind',
|
|
120
|
-
* hostPath: process.cwd(),
|
|
121
|
-
* containerPath: '/workspace',
|
|
122
|
-
* readOnly: false,
|
|
123
|
-
* }],
|
|
124
|
-
* });
|
|
125
|
-
*
|
|
126
|
-
* // Use with AI SDK
|
|
127
|
-
* const response = await generateText({
|
|
128
|
-
* model: yourModel,
|
|
129
|
-
* tools: sandbox.tools,
|
|
130
|
-
* prompt: 'Fetch the weather data and parse it with jq',
|
|
131
|
-
* });
|
|
132
|
-
*
|
|
133
|
-
* // Clean up when done
|
|
134
|
-
* await sandbox.sandbox.dispose();
|
|
135
|
-
* ```
|
|
136
|
-
*
|
|
137
|
-
* @example RuntimeStrategy with skills
|
|
138
|
-
* ```typescript
|
|
139
|
-
* const sandbox = await createContainerTool({
|
|
140
|
-
* installers: [pkg(['curl', 'jq'])],
|
|
141
|
-
* skills: [
|
|
142
|
-
* { host: './skills', sandbox: '/workspace/skills' },
|
|
143
|
-
* ],
|
|
144
|
-
* });
|
|
145
|
-
*
|
|
146
|
-
* context.set(role('...'), skills(sandbox));
|
|
147
|
-
* ```
|
|
148
|
-
*
|
|
149
|
-
* @example DockerfileStrategy
|
|
150
|
-
* ```typescript
|
|
151
|
-
* const sandbox = await createContainerTool({
|
|
152
|
-
* dockerfile: `
|
|
153
|
-
* FROM python:3.11-slim
|
|
154
|
-
* RUN pip install pandas numpy
|
|
155
|
-
* `,
|
|
156
|
-
* context: '.',
|
|
157
|
-
* volumes: [{
|
|
158
|
-
* type: 'bind',
|
|
159
|
-
* hostPath: process.cwd(),
|
|
160
|
-
* containerPath: '/workspace',
|
|
161
|
-
* }],
|
|
162
|
-
* });
|
|
163
|
-
* ```
|
|
164
|
-
*
|
|
165
|
-
* @example ComposeStrategy
|
|
166
|
-
* ```typescript
|
|
167
|
-
* const sandbox = await createContainerTool({
|
|
168
|
-
* compose: './docker-compose.yml',
|
|
169
|
-
* service: 'app',
|
|
170
|
-
* });
|
|
171
|
-
* // Commands run in the 'app' service, can reach other services by name
|
|
172
|
-
* await sandbox.sandbox.dispose(); // Stops ALL services
|
|
173
|
-
* ```
|
|
174
|
-
*
|
|
175
|
-
* @example With hooks for logging
|
|
176
|
-
* ```typescript
|
|
177
|
-
* const sandbox = await createContainerTool({
|
|
178
|
-
* installers: [pkg(['python3'])],
|
|
179
|
-
* onBeforeBashCall: ({ command }) => {
|
|
180
|
-
* console.log('Running:', command);
|
|
181
|
-
* },
|
|
182
|
-
* onAfterBashCall: ({ command, result }) => {
|
|
183
|
-
* console.log(`Exit code: ${result.exitCode}`);
|
|
184
|
-
* },
|
|
185
|
-
* });
|
|
186
|
-
* ```
|
|
187
|
-
*/
|
|
188
|
-
export declare function createContainerTool(options?: ContainerToolOptions): Promise<AgentSandbox>;
|
|
189
|
-
export {};
|
|
190
|
-
//# sourceMappingURL=container-tool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"container-tool.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/container-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAGvD,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,mBAAmB,EAIzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjE;;GAEG;AACH,UAAU,wBAAyB,SAAQ,IAAI,CAC7C,qBAAqB,EACrB,SAAS,GAAG,iBAAiB,CAC9B;IACC,uEA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