@deepagents/context 1.0.0 → 2.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.
@@ -1,7 +1,50 @@
1
1
  import type { Tool } from 'ai';
2
- import type { BashToolkit, CommandResult } from 'bash-tool';
2
+ import type { BashToolkit, CommandResult, Sandbox as UpstreamSandbox } from 'bash-tool';
3
3
  import type { SkillPathMapping } from '../skills/types.ts';
4
4
  import type { FileEvent } from './file-events.ts';
5
+ /**
6
+ * Options accepted by `DisposableSandbox.executeCommand`. Currently only
7
+ * `signal` (cooperative cancellation); shaped as an object so we can add
8
+ * more without breaking backends.
9
+ */
10
+ export interface ExecuteCommandOptions {
11
+ signal?: AbortSignal;
12
+ }
13
+ export interface SpawnOptions {
14
+ signal?: AbortSignal;
15
+ env?: Record<string, string>;
16
+ cwd?: string;
17
+ }
18
+ export interface ExitInfo {
19
+ code: number | null;
20
+ signal: NodeJS.Signals | null;
21
+ /** Convenience for `code === 0`. */
22
+ success: boolean;
23
+ }
24
+ export interface SandboxProcess {
25
+ readonly stdout: ReadableStream<Uint8Array>;
26
+ readonly stderr: ReadableStream<Uint8Array>;
27
+ readonly exit: Promise<ExitInfo>;
28
+ }
29
+ /**
30
+ * Sandbox contract used throughout this package: upstream's three-method
31
+ * shape plus a lifecycle hook, with `executeCommand` widened to accept
32
+ * optional cancellation. Every backend (virtual, docker, agent-os)
33
+ * implements this so callers can dispose uniformly. Backends that honor
34
+ * `options.signal` forward it to their runner; others ignore. Pure
35
+ * backends with no external resources (e.g. virtual-sandbox) supply a
36
+ * no-op `dispose()`.
37
+ *
38
+ * `spawn` is optional: only backends that can honestly expose unbuffered
39
+ * stdio (e.g. docker-sandbox) implement it. Callers feature-detect with
40
+ * `if (!sandbox.spawn) ...` — no silent fallback that aggregates output
41
+ * and flushes on completion.
42
+ */
43
+ export interface DisposableSandbox extends Omit<UpstreamSandbox, 'executeCommand'> {
44
+ executeCommand(command: string, options?: ExecuteCommandOptions): Promise<CommandResult>;
45
+ spawn?(command: string, options?: SpawnOptions): SandboxProcess;
46
+ dispose(): Promise<void>;
47
+ }
5
48
  /**
6
49
  * Declarative skill upload: a host directory whose contents are copied into
7
50
  * the sandbox at startup. The factory also parses each skill's frontmatter
@@ -29,18 +72,20 @@ export type WrappedBashTool = Tool<BashToolInput, CommandResult>;
29
72
  * the `skills()` fragment. The `bash` tool is widened to require a
30
73
  * `reasoning` input on every call.
31
74
  */
32
- export interface AgentSandbox extends Omit<BashToolkit, 'bash' | 'tools'> {
75
+ export interface AgentSandbox extends Omit<BashToolkit, 'bash' | 'tools' | 'sandbox'> {
33
76
  /** Discovered skills — empty array if none were configured. */
34
77
  skills: SkillPathMapping[];
35
78
  bash: WrappedBashTool;
36
79
  tools: Omit<BashToolkit['tools'], 'bash'> & {
37
80
  bash: WrappedBashTool;
38
81
  };
82
+ sandbox: DisposableSandbox;
39
83
  /**
40
- * Drain and return file events observed since the last call. Attached by
41
- * callers who composed an `ObservedFs` into their backend; omitted
42
- * otherwise. The chat pipeline reads this via optional chaining.
84
+ * Drain and return file events observed since the last `drain()`. The
85
+ * observation root is the `destination` passed to `createBashTool`; every
86
+ * `executeCommand` / `writeFiles` call is bracketed by a snapshot, and
87
+ * `readFile` records a `read` event.
43
88
  */
44
- drainFileEvents?(): FileEvent[];
89
+ drainFileEvents(): FileEvent[];
45
90
  }
46
91
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;GAIG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EAAE,gBAAgB,EAAE,CAAC;IAC3B,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,GAAG;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IACtE,OAAO,EAAE,iBAAiB,CAAC;IAC3B;;;;;OAKG;IACH,eAAe,IAAI,SAAS,EAAE,CAAC;CAChC"}
@@ -1,10 +1,10 @@
1
- import type { Sandbox } from 'bash-tool';
2
1
  import { type CustomCommand, type IFileSystem } from 'just-bash';
2
+ import type { DisposableSandbox } from './types.ts';
3
3
  export interface CreateVirtualSandboxOptions {
4
4
  fs: IFileSystem;
5
5
  cwd?: string;
6
6
  env?: Record<string, string>;
7
7
  customCommands?: CustomCommand[];
8
8
  }
9
- export declare function createVirtualSandbox(options: CreateVirtualSandboxOptions): Promise<Sandbox>;
9
+ export declare function createVirtualSandbox(options: CreateVirtualSandboxOptions): Promise<DisposableSandbox>;
10
10
  //# sourceMappingURL=virtual-sandbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/virtual-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAQ,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAEvE,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,WAAW,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,OAAO,CAAC,CAiClB"}
1
+ {"version":3,"file":"virtual-sandbox.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/virtual-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAEvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,WAAW,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,iBAAiB,CAAC,CAsC5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepagents/context",
3
- "version": "1.0.0",
3
+ "version": "2.1.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,28 +43,20 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ai-sdk/groq": "^3.0.36",
46
- "@ai-sdk/openai": "^3.0.54",
47
- "@ai-sdk/openai-compatible": "^2.0.42",
48
46
  "@ai-sdk/provider": "^3.0.10",
49
- "@clack/prompts": "^1.3.0",
50
- "@deepagents/agent": "1.0.0",
51
- "@sdk-it/rpc": "^0.40.0",
52
- "@sdk-it/spec": "^0.40.0",
47
+ "@deepagents/agent": "2.1.0",
53
48
  "ai": "^6.0.174",
54
49
  "bash-tool": "^1.3.16",
55
50
  "chalk": "^5.6.0",
56
51
  "dedent": "^1.7.0",
57
52
  "gpt-tokenizer": "^3.4.0",
58
- "just-bash": "^2.14.2",
59
- "lodash-es": "^4.17.21",
53
+ "just-bash": "^3.0.0",
60
54
  "nano-spawn": "^2.0.0",
61
- "openai": "^6.25.0",
62
55
  "pluralize": "^8.0.0",
63
56
  "stringcase": "^4.3.1",
64
57
  "tiny-tfidf": "^1.0.0",
65
58
  "yaml": "^2.8.0",
66
- "zod": "^3.25.76 || ^4.0.0",
67
- "zod-to-json-schema": "^3.25.1"
59
+ "zod": "^3.25.76 || ^4.0.0"
68
60
  },
69
61
  "devDependencies": {
70
62
  "@types/debug": "^4.1.12",
@@ -1,6 +0,0 @@
1
- export declare class OpenAISandbox {
2
- #private;
3
- uploadSkill(): void;
4
- listSkills(): void;
5
- }
6
- //# sourceMappingURL=openai.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/lib/sandboxes/openai.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAa;;IAExB,WAAW;IAGX,UAAU;CAGX"}