@deepagents/context 0.39.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.
Files changed (121) hide show
  1. package/README.md +44 -11
  2. package/dist/browser.js +171 -15
  3. package/dist/browser.js.map +3 -3
  4. package/dist/index.d.ts +6 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +3037 -1573
  7. package/dist/index.js.map +4 -4
  8. package/dist/lib/agent.d.ts +6 -0
  9. package/dist/lib/agent.d.ts.map +1 -1
  10. package/dist/lib/chain-summary.d.ts +18 -0
  11. package/dist/lib/chain-summary.d.ts.map +1 -0
  12. package/dist/lib/engine.d.ts +25 -6
  13. package/dist/lib/engine.d.ts.map +1 -1
  14. package/dist/lib/fragments/message/user.d.ts +21 -2
  15. package/dist/lib/fragments/message/user.d.ts.map +1 -1
  16. package/dist/lib/fragments.d.ts +8 -3
  17. package/dist/lib/fragments.d.ts.map +1 -1
  18. package/dist/lib/resolvers/async-resolver.d.ts +8 -0
  19. package/dist/lib/resolvers/async-resolver.d.ts.map +1 -0
  20. package/dist/lib/resolvers/function-resolver.d.ts +8 -0
  21. package/dist/lib/resolvers/function-resolver.d.ts.map +1 -0
  22. package/dist/lib/resolvers/generator-resolver.d.ts +13 -0
  23. package/dist/lib/resolvers/generator-resolver.d.ts.map +1 -0
  24. package/dist/lib/resolvers/index.d.ts +10 -0
  25. package/dist/lib/resolvers/index.d.ts.map +1 -0
  26. package/dist/lib/resolvers/iterable-resolver.d.ts +12 -0
  27. package/dist/lib/resolvers/iterable-resolver.d.ts.map +1 -0
  28. package/dist/lib/resolvers/loader-resolver.d.ts +13 -0
  29. package/dist/lib/resolvers/loader-resolver.d.ts.map +1 -0
  30. package/dist/lib/resolvers/promise-resolver.d.ts +7 -0
  31. package/dist/lib/resolvers/promise-resolver.d.ts.map +1 -0
  32. package/dist/lib/resolvers/types.d.ts +45 -0
  33. package/dist/lib/resolvers/types.d.ts.map +1 -0
  34. package/dist/lib/sandbox/abort.d.ts +24 -0
  35. package/dist/lib/sandbox/abort.d.ts.map +1 -0
  36. package/dist/lib/sandbox/agent-os-sandbox.d.ts +3 -6
  37. package/dist/lib/sandbox/agent-os-sandbox.d.ts.map +1 -1
  38. package/dist/lib/sandbox/ast-utils.d.ts +5 -2
  39. package/dist/lib/sandbox/ast-utils.d.ts.map +1 -1
  40. package/dist/lib/sandbox/bash-tool.d.ts +29 -16
  41. package/dist/lib/sandbox/bash-tool.d.ts.map +1 -1
  42. package/dist/lib/sandbox/container-tool.d.ts +47 -21
  43. package/dist/lib/sandbox/container-tool.d.ts.map +1 -1
  44. package/dist/lib/sandbox/docker-sandbox-errors.d.ts +74 -0
  45. package/dist/lib/sandbox/docker-sandbox-errors.d.ts.map +1 -0
  46. package/dist/lib/sandbox/docker-sandbox.d.ts +148 -371
  47. package/dist/lib/sandbox/docker-sandbox.d.ts.map +1 -1
  48. package/dist/lib/sandbox/file-events.d.ts +24 -38
  49. package/dist/lib/sandbox/file-events.d.ts.map +1 -1
  50. package/dist/lib/sandbox/index.d.ts +3 -7
  51. package/dist/lib/sandbox/index.d.ts.map +1 -1
  52. package/dist/lib/sandbox/installers/github-release.d.ts +46 -0
  53. package/dist/lib/sandbox/installers/github-release.d.ts.map +1 -0
  54. package/dist/lib/sandbox/installers/index.d.ts +7 -0
  55. package/dist/lib/sandbox/installers/index.d.ts.map +1 -0
  56. package/dist/lib/sandbox/installers/installer.d.ts +44 -0
  57. package/dist/lib/sandbox/installers/installer.d.ts.map +1 -0
  58. package/dist/lib/sandbox/installers/npm.d.ts +32 -0
  59. package/dist/lib/sandbox/installers/npm.d.ts.map +1 -0
  60. package/dist/lib/sandbox/installers/package-manager.d.ts +19 -0
  61. package/dist/lib/sandbox/installers/package-manager.d.ts.map +1 -0
  62. package/dist/lib/sandbox/installers/pip.d.ts +37 -0
  63. package/dist/lib/sandbox/installers/pip.d.ts.map +1 -0
  64. package/dist/lib/sandbox/installers/url-binary.d.ts +41 -0
  65. package/dist/lib/sandbox/installers/url-binary.d.ts.map +1 -0
  66. package/dist/lib/sandbox/subcommand.d.ts +11 -11
  67. package/dist/lib/sandbox/subcommand.d.ts.map +1 -1
  68. package/dist/lib/sandbox/types.d.ts +51 -6
  69. package/dist/lib/sandbox/types.d.ts.map +1 -1
  70. package/dist/lib/sandbox/upload-skills.d.ts +6 -0
  71. package/dist/lib/sandbox/upload-skills.d.ts.map +1 -1
  72. package/dist/lib/sandbox/virtual-sandbox.d.ts +10 -0
  73. package/dist/lib/sandbox/virtual-sandbox.d.ts.map +1 -0
  74. package/dist/lib/save/reminder-target-handler.d.ts +36 -0
  75. package/dist/lib/save/reminder-target-handler.d.ts.map +1 -0
  76. package/dist/lib/save/save-pipeline.d.ts +28 -0
  77. package/dist/lib/save/save-pipeline.d.ts.map +1 -0
  78. package/dist/lib/save/tool-output-target-handler.d.ts +7 -0
  79. package/dist/lib/save/tool-output-target-handler.d.ts.map +1 -0
  80. package/dist/lib/save/user-target-handler.d.ts +7 -0
  81. package/dist/lib/save/user-target-handler.d.ts.map +1 -0
  82. package/dist/lib/stream/change-source.d.ts +11 -0
  83. package/dist/lib/stream/change-source.d.ts.map +1 -0
  84. package/dist/lib/stream/ddl.stream.postgres-notify.d.ts +3 -0
  85. package/dist/lib/stream/ddl.stream.postgres-notify.d.ts.map +1 -0
  86. package/dist/lib/stream/ddl.stream.postgres.d.ts +2 -0
  87. package/dist/lib/stream/ddl.stream.postgres.d.ts.map +1 -0
  88. package/dist/lib/stream/polling-change-source.d.ts +27 -0
  89. package/dist/lib/stream/polling-change-source.d.ts.map +1 -0
  90. package/dist/lib/stream/polling-policy.d.ts +0 -1
  91. package/dist/lib/stream/polling-policy.d.ts.map +1 -1
  92. package/dist/lib/stream/postgres-notify-change-source.d.ts +15 -0
  93. package/dist/lib/stream/postgres-notify-change-source.d.ts.map +1 -0
  94. package/dist/lib/stream/postgres.stream-store.d.ts +29 -0
  95. package/dist/lib/stream/postgres.stream-store.d.ts.map +1 -0
  96. package/dist/lib/stream/stream-manager.d.ts +8 -27
  97. package/dist/lib/stream/stream-manager.d.ts.map +1 -1
  98. package/dist/lib/ui-message-guards.d.ts +10 -0
  99. package/dist/lib/ui-message-guards.d.ts.map +1 -0
  100. package/package.json +4 -17
  101. package/dist/lib/sandbox/extension.d.ts +0 -39
  102. package/dist/lib/sandbox/extension.d.ts.map +0 -1
  103. package/dist/lib/sandbox/openapi/demo.d.ts +0 -2
  104. package/dist/lib/sandbox/openapi/demo.d.ts.map +0 -1
  105. package/dist/lib/sandbox/openapi/extension.d.ts +0 -19
  106. package/dist/lib/sandbox/openapi/extension.d.ts.map +0 -1
  107. package/dist/lib/sandbox/openapi/format.d.ts +0 -11
  108. package/dist/lib/sandbox/openapi/format.d.ts.map +0 -1
  109. package/dist/lib/sandbox/openapi/schema.d.ts +0 -9
  110. package/dist/lib/sandbox/openapi/schema.d.ts.map +0 -1
  111. package/dist/lib/sandbox/openapi/skill/index.d.ts +0 -6
  112. package/dist/lib/sandbox/openapi/skill/index.d.ts.map +0 -1
  113. package/dist/lib/sandbox/openapi/skill/index.js +0 -14
  114. package/dist/lib/sandbox/openapi/skill/index.js.map +0 -7
  115. package/dist/lib/sandbox/openapi/skill/openapi-cli/SKILL.md +0 -109
  116. package/dist/lib/sandbox/openapi/validate.d.ts +0 -7
  117. package/dist/lib/sandbox/openapi/validate.d.ts.map +0 -1
  118. package/dist/lib/sandbox/routing-sandbox.d.ts +0 -28
  119. package/dist/lib/sandbox/routing-sandbox.d.ts.map +0 -1
  120. package/dist/lib/sandboxes/openai.d.ts +0 -6
  121. package/dist/lib/sandboxes/openai.d.ts.map +0 -1
@@ -1,47 +1,33 @@
1
- import type { BufferEncoding, CpOptions, FileContent, FsStat, IFileSystem, MkdirOptions, RmOptions } from 'just-bash';
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 declare class ObservedFs implements IFileSystem {
21
- #private;
22
- readdirWithFileTypes?: (path: string) => Promise<DirentEntry[]>;
23
- constructor(base: IFileSystem);
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
+ * - If `destination` does not exist in the sandbox at snapshot time, the
26
+ * snapshot is treated as empty (graceful — supports observation rooted at
27
+ * paths that the sandbox will create later). Snapshot command failures
28
+ * (e.g. permission denied, missing `find`) throw `SnapshotFailedError`.
29
+ * - Single-flight by convention. Concurrent `executeCommand` calls are not
30
+ * serialized internally and will produce interleaved diffs.
31
+ */
32
+ export declare function observeSandboxFileEvents(sandbox: DisposableSandbox, options: ObserveOptions): SandboxObserver;
47
33
  //# 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,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,MAAM,EACN,WAAW,EACX,YAAY,EACZ,SAAS,EACV,MAAM,WAAW,CAAC;AAEnB,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC;AAED,UAAU,gBAAgB;IACxB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,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,qBAAa,UAAW,YAAW,WAAW;;IAG5C,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;gBAEpD,IAAI,EAAE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;GAYG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,cAAc,GACtB,eAAe,CAiDjB"}
@@ -1,19 +1,15 @@
1
+ export * from './abort.ts';
1
2
  export * from './agent-os-sandbox.ts';
2
- export * from './ast-utils.ts';
3
3
  export * from './bash-exception.ts';
4
4
  export * from './bash-meta.ts';
5
5
  export * from './bash-tool.ts';
6
- export * from './extension.ts';
7
6
  export * from './file-events.ts';
8
7
  export * from './binary-bridges.ts';
9
8
  export * from './container-tool.ts';
10
9
  export * from './docker-sandbox.ts';
11
- export * from './routing-sandbox.ts';
12
- export * from './openapi/extension.ts';
13
- export * from './openapi/format.ts';
14
- export * from './openapi/schema.ts';
15
- export * from './openapi/validate.ts';
10
+ export * from './installers/index.ts';
16
11
  export * from './subcommand.ts';
17
12
  export * from './types.ts';
18
13
  export * from './upload-skills.ts';
14
+ export * from './virtual-sandbox.ts';
19
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { Installer, type InstallerContext } from './installer.ts';
2
+ export interface GithubReleaseOptions {
3
+ /** GitHub owner (user or org). */
4
+ owner: string;
5
+ /** Repository name. */
6
+ repo: string;
7
+ /** Release tag (e.g. `'v0.15.1'`). */
8
+ version: string;
9
+ /** Final executable name installed under `/usr/local/bin`. */
10
+ name: string;
11
+ /**
12
+ * Build the asset filename for a given container architecture
13
+ * (the result of `uname -m`, e.g. `'x86_64'`, `'aarch64'`).
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * asset: (arch) => `presenterm-0.15.1-${arch}-unknown-linux-musl.tar.gz`
18
+ * ```
19
+ */
20
+ asset: (arch: string) => string;
21
+ /** Path inside an extracted archive, when it differs from `name`. */
22
+ binaryPath?: string;
23
+ }
24
+ export declare class GithubReleaseInstaller extends Installer {
25
+ readonly kind: string;
26
+ readonly options: GithubReleaseOptions;
27
+ constructor(options: GithubReleaseOptions);
28
+ install(ctx: InstallerContext): Promise<void>;
29
+ }
30
+ /**
31
+ * Install a binary from a GitHub release. Resolves arch-specific assets
32
+ * via the `asset(arch)` callback.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * githubRelease({
37
+ * owner: 'mfontanini',
38
+ * repo: 'presenterm',
39
+ * version: 'v0.15.1',
40
+ * name: 'presenterm',
41
+ * asset: (arch) => `presenterm-0.15.1-${arch}-unknown-linux-musl.tar.gz`,
42
+ * });
43
+ * ```
44
+ */
45
+ export declare function githubRelease(options: GithubReleaseOptions): GithubReleaseInstaller;
46
+ //# sourceMappingURL=github-release.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-release.d.ts","sourceRoot":"","sources":["../../../../src/lib/sandbox/installers/github-release.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlE,MAAM,WAAW,oBAAoB;IACnC,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;;OAQG;IACH,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAChC,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,sBAAuB,SAAQ,SAAS;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;gBAE3B,OAAO,EAAE,oBAAoB;IAMnC,OAAO,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAepD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,oBAAoB,GAC5B,sBAAsB,CAExB"}
@@ -0,0 +1,7 @@
1
+ export { Installer, type InstallerContext, type PackageManager, createInstallerContext, isDebianBased, shellQuote, } from './installer.ts';
2
+ export { PackageInstaller, pkg } from './package-manager.ts';
3
+ export { type ArchitectureUrls, type UrlBinaryOptions, UrlBinaryInstaller, urlBinary, } from './url-binary.ts';
4
+ export { type NpmInstallerOptions, NpmInstaller, npm } from './npm.ts';
5
+ export { type PipInstallerOptions, PipInstaller, pip } from './pip.ts';
6
+ export { type GithubReleaseOptions, GithubReleaseInstaller, githubRelease, } from './github-release.ts';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/sandbox/installers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,sBAAsB,EACtB,aAAa,EACb,UAAU,GACX,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,kBAAkB,EAClB,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,mBAAmB,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,KAAK,mBAAmB,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EACL,KAAK,oBAAoB,EACzB,sBAAsB,EACtB,aAAa,GACd,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { type CommandResult } from 'bash-tool';
2
+ export type PackageManager = 'apk' | 'apt-get';
3
+ /**
4
+ * Shared state passed to every installer's `install()` call.
5
+ *
6
+ * The context owns one container's installation lifecycle:
7
+ * - memoised architecture (one `uname -m` per sandbox)
8
+ * - resolved package manager
9
+ * - `apt-get update` runs at most once
10
+ * - idempotent `ensureTool` (cache keyed on install name)
11
+ */
12
+ export interface InstallerContext {
13
+ readonly containerId: string;
14
+ readonly image: string;
15
+ readonly packageManager: PackageManager;
16
+ arch(): Promise<string>;
17
+ exec(command: string): Promise<CommandResult>;
18
+ /**
19
+ * Install OS packages via the container's package manager.
20
+ * `apt-get update` runs at most once per container, then subsequent calls
21
+ * issue install only.
22
+ */
23
+ installPackages(packages: string[]): Promise<void>;
24
+ /**
25
+ * Ensure a tool is callable.
26
+ *
27
+ * @param checkName Binary name probed via `which` (e.g. `'node'`).
28
+ * @param installName Package to install when missing (e.g. `'nodejs'`).
29
+ * Defaults to `checkName` when binary name == package name.
30
+ */
31
+ ensureTool(checkName: string, installName?: string): Promise<void>;
32
+ }
33
+ export declare abstract class Installer {
34
+ abstract readonly kind: string;
35
+ abstract install(ctx: InstallerContext): Promise<void>;
36
+ }
37
+ export declare function isDebianBased(image: string): boolean;
38
+ /**
39
+ * POSIX shell single-quote escape: wrap in `'...'`, replace any embedded
40
+ * `'` with `'\''`. Safe for arbitrary content inside `sh -c`.
41
+ */
42
+ export declare function shellQuote(s: string): string;
43
+ export declare function createInstallerContext(containerId: string, image: string): InstallerContext;
44
+ //# sourceMappingURL=installer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../../../src/lib/sandbox/installers/installer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAQ/C,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,SAAS,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC9C;;;;OAIG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD;;;;;;OAMG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpE;AAED,8BAAsB,SAAS;IAC7B,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CACvD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAKpD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,GACZ,gBAAgB,CAyGlB"}
@@ -0,0 +1,32 @@
1
+ import { Installer, type InstallerContext } from './installer.ts';
2
+ export interface NpmInstallerOptions {
3
+ /**
4
+ * Auto-install `nodejs` + `npm` via the container's package manager when
5
+ * they're missing. Defaults to `false` — fail loudly with `MissingRuntimeError`.
6
+ */
7
+ ensureRuntime?: boolean;
8
+ /** Optional version specifier (e.g. `'5.4.5'`). */
9
+ version?: string;
10
+ }
11
+ export declare class NpmInstaller extends Installer {
12
+ readonly kind: string;
13
+ readonly packageName: string;
14
+ readonly options: NpmInstallerOptions;
15
+ constructor(packageName: string, options?: NpmInstallerOptions);
16
+ install(ctx: InstallerContext): Promise<void>;
17
+ }
18
+ /**
19
+ * Install a globally-available CLI from the npm registry.
20
+ *
21
+ * Default: fails loudly if `node`/`npm` are missing. Pass
22
+ * `{ ensureRuntime: true }` to auto-install them.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * npm('prettier'); // requires node+npm preinstalled
27
+ * npm('prettier', { ensureRuntime: true }); // auto-installs node+npm
28
+ * npm('typescript', { version: '5.4.5' }); // pinned version
29
+ * ```
30
+ */
31
+ export declare function npm(packageName: string, options?: NpmInstallerOptions): NpmInstaller;
32
+ //# sourceMappingURL=npm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npm.d.ts","sourceRoot":"","sources":["../../../../src/lib/sandbox/installers/npm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElE,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD,qBAAa,YAAa,SAAQ,SAAS;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;gBAE1B,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB;IAO5D,OAAO,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBpD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CACjB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,YAAY,CAEd"}
@@ -0,0 +1,19 @@
1
+ import { Installer, type InstallerContext } from './installer.ts';
2
+ export declare class PackageInstaller extends Installer {
3
+ readonly kind: string;
4
+ readonly packages: readonly string[];
5
+ constructor(packages: readonly string[]);
6
+ install(ctx: InstallerContext): Promise<void>;
7
+ }
8
+ /**
9
+ * Install OS packages via the container's native package manager.
10
+ *
11
+ * Auto-detects `apk` (Alpine) vs `apt-get` (Debian/Ubuntu/Node/Python images).
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * createDockerSandbox({ installers: [pkg(['curl', 'jq'])] });
16
+ * ```
17
+ */
18
+ export declare function pkg(packages: readonly string[]): PackageInstaller;
19
+ //# sourceMappingURL=package-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../../../src/lib/sandbox/installers/package-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElE,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;gBAEzB,QAAQ,EAAE,SAAS,MAAM,EAAE;IAOjC,OAAO,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAIpD;AAED;;;;;;;;;GASG;AACH,wBAAgB,GAAG,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,gBAAgB,CAEjE"}
@@ -0,0 +1,37 @@
1
+ import { Installer, type InstallerContext } from './installer.ts';
2
+ export interface PipInstallerOptions {
3
+ /**
4
+ * Auto-install `python3` + pip when missing. Defaults to `false` — fail
5
+ * loudly with `MissingRuntimeError`.
6
+ */
7
+ ensureRuntime?: boolean;
8
+ /** Version specifier (e.g. `'2.31.0'` or `'>=2.0,<3'`). */
9
+ version?: string;
10
+ /**
11
+ * Pass `--break-system-packages` for PEP 668-protected images
12
+ * (recent Debian/Ubuntu). Default `true` since this runs in an ephemeral
13
+ * container where the protection adds no value.
14
+ */
15
+ breakSystemPackages?: boolean;
16
+ }
17
+ export declare class PipInstaller extends Installer {
18
+ readonly kind: string;
19
+ readonly packageName: string;
20
+ readonly options: PipInstallerOptions;
21
+ constructor(packageName: string, options?: PipInstallerOptions);
22
+ install(ctx: InstallerContext): Promise<void>;
23
+ }
24
+ /**
25
+ * Install a Python package via `pip3`.
26
+ *
27
+ * Default: fails loudly if `python3`/`pip3` are missing. Pass
28
+ * `{ ensureRuntime: true }` to auto-install them.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * pip('requests');
33
+ * pip('requests', { version: '2.31.0', ensureRuntime: true });
34
+ * ```
35
+ */
36
+ export declare function pip(packageName: string, options?: PipInstallerOptions): PipInstaller;
37
+ //# sourceMappingURL=pip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pip.d.ts","sourceRoot":"","sources":["../../../../src/lib/sandbox/installers/pip.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElE,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAID,qBAAa,YAAa,SAAQ,SAAS;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;gBAE1B,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB;IAO5D,OAAO,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAsBpD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,GAAG,CACjB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,YAAY,CAEd"}
@@ -0,0 +1,41 @@
1
+ import { Installer, type InstallerContext } from './installer.ts';
2
+ export interface ArchitectureUrls {
3
+ x86_64?: string;
4
+ aarch64?: string;
5
+ armv7l?: string;
6
+ }
7
+ export interface UrlBinaryOptions {
8
+ /** Final executable name installed under `/usr/local/bin`. */
9
+ name: string;
10
+ /** Single URL or arch-keyed map (selected via container's `uname -m`). */
11
+ url: string | ArchitectureUrls;
12
+ /** Path inside an extracted archive, when it differs from `name`. */
13
+ binaryPath?: string;
14
+ }
15
+ export declare class UrlBinaryInstaller extends Installer {
16
+ readonly kind: string;
17
+ readonly options: UrlBinaryOptions;
18
+ constructor(options: UrlBinaryOptions);
19
+ install(ctx: InstallerContext): Promise<void>;
20
+ }
21
+ /**
22
+ * Install a pre-built binary from a URL into `/usr/local/bin`.
23
+ *
24
+ * Supports raw binaries and `.tar.gz`/`.tgz` archives. Picks the correct
25
+ * URL per container architecture when a map is provided. Auto-installs `curl`
26
+ * if needed.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * urlBinary({
31
+ * name: 'presenterm',
32
+ * url: {
33
+ * x86_64: 'https://.../presenterm-x86_64.tar.gz',
34
+ * aarch64: 'https://.../presenterm-aarch64.tar.gz',
35
+ * },
36
+ * });
37
+ * ```
38
+ */
39
+ export declare function urlBinary(options: UrlBinaryOptions): UrlBinaryInstaller;
40
+ export declare function downloadAndInstall(ctx: InstallerContext, name: string, url: string, binaryPath?: string, source?: 'url' | 'github-release'): Promise<void>;
41
+ //# sourceMappingURL=url-binary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-binary.d.ts","sourceRoot":"","sources":["../../../../src/lib/sandbox/installers/url-binary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAc,MAAM,gBAAgB,CAAC;AAE9E,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;IAC/B,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;gBAEvB,OAAO,EAAE,gBAAgB;IAM/B,OAAO,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CASpD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,kBAAkB,CAEvE;AAqBD,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,GAAE,KAAK,GAAG,gBAAwB,GACvC,OAAO,CAAC,IAAI,CAAC,CAkBf"}
@@ -1,5 +1,4 @@
1
- import type { CommandResult } from 'bash-tool';
2
- import type { ExtensionCommand, ExtensionCommandContext } from './extension.ts';
1
+ import { type Command, type CommandContext, type ExecResult } from 'just-bash';
3
2
  /**
4
3
  * Describes one subcommand inside a subcommand group (e.g. `sql run`,
5
4
  * `sql validate`). Each subcommand has usage/description strings used to
@@ -14,21 +13,23 @@ export interface SubcommandDefinition {
14
13
  * the shell parser sees it. Return `null` to leave the raw args unchanged.
15
14
  */
16
15
  repair?: (rawArgs: string) => string | null;
17
- handler: (args: string[], ctx: ExtensionCommandContext) => CommandResult | Promise<CommandResult>;
16
+ handler: (args: string[], ctx: CommandContext) => ExecResult | Promise<ExecResult>;
18
17
  }
19
18
  /**
20
- * Creates an {@link ExtensionCommand} that dispatches to one of several
21
- * subcommand handlers based on the first positional arg. Unknown or missing
22
- * subcommands print an auto-generated usage message to stderr with exit
23
- * code 1.
19
+ * Builds a `Command` for just-bash that dispatches to one of several
20
+ * subcommand handlers based on the first positional arg. Plug it into a
21
+ * `Bash` instance via `customCommands` (or feed it to any sandbox that
22
+ * accepts just-bash custom commands). Unknown or missing subcommands
23
+ * print an auto-generated usage message to stderr with exit code 1.
24
24
  *
25
25
  * @example
26
26
  * const sqlCommand = defineSubcommandGroup('sql', {
27
27
  * run: { usage: 'run "SELECT ..."', description: 'Execute query', handler: ... },
28
28
  * validate: { usage: 'validate "SELECT ..."', description: 'Validate only', handler: ... },
29
29
  * });
30
+ * new Bash({ fs, customCommands: [sqlCommand] });
30
31
  */
31
- export declare function defineSubcommandGroup(name: string, subcommands: Record<string, SubcommandDefinition>): ExtensionCommand;
32
+ export declare function defineSubcommandGroup(name: string, subcommands: Record<string, SubcommandDefinition>): Command;
32
33
  /**
33
34
  * Strips a single layer of matching outer `"` or `'` quotes from a string,
34
35
  * trimming surrounding whitespace. If the input is not wrapped in a matching
@@ -36,9 +37,8 @@ export declare function defineSubcommandGroup(name: string, subcommands: Record<
36
37
  */
37
38
  export declare function stripQuoteArtifacts(raw: string): string;
38
39
  /**
39
- * Pre-parse repair for a subcommand's raw arg string. Fires when the
40
- * surrounding command fails to parse (via `buildSubcommandRepair`). Strips
41
- * any leading/trailing quote, escapes inner single quotes with the POSIX
40
+ * Pre-parse repair for a subcommand's raw arg string. Strips any
41
+ * leading/trailing quote, escapes inner single quotes with the POSIX
42
42
  * `'\''` idiom, and wraps the result in single quotes so the shell parser
43
43
  * will treat the payload as an opaque literal on the next pass.
44
44
  *
@@ -1 +1 @@
1
- {"version":3,"file":"subcommand.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/subcommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC5C,OAAO,EAAE,CACP,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,uBAAuB,KACzB,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC7C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GACh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,EAAE,oBAAoB,CAAC,IAO1B,KAAK,MAAM,KAAG,MAAM,CA2B5C"}
@@ -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;AACH,MAAM,WAAW,gBAAgB;IAC/B,6EAA6E;IAC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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,6 +1,12 @@
1
1
  import type { Sandbox } from 'bash-tool';
2
2
  import type { SkillPathMapping } from '../skills/types.ts';
3
3
  import type { SkillUploadInput } from './types.ts';
4
+ /**
5
+ * Discover skill metadata and map each host SKILL.md path to its sandbox path
6
+ * without uploading any files. Later inputs override earlier ones when the same
7
+ * skill name appears twice.
8
+ */
9
+ export declare function discoverSkillMappings(inputs: SkillUploadInput[]): SkillPathMapping[];
4
10
  /**
5
11
  * Discover skills under each host directory, write all non-dotfile, non-symlink
6
12
  * files into the sandbox under the mapped path, and return the discovered
@@ -1 +1 @@
1
- {"version":3,"file":"upload-skills.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/upload-skills.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAenD;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,gBAAgB,EAAE,GACzB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAqC7B"}
1
+ {"version":3,"file":"upload-skills.d.ts","sourceRoot":"","sources":["../../../src/lib/sandbox/upload-skills.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAenD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,gBAAgB,EAAE,GACzB,gBAAgB,EAAE,CAwBpB;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,gBAAgB,EAAE,GACzB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAqB7B"}
@@ -0,0 +1,10 @@
1
+ import { type CustomCommand, type IFileSystem } from 'just-bash';
2
+ import type { DisposableSandbox } from './types.ts';
3
+ export interface CreateVirtualSandboxOptions {
4
+ fs: IFileSystem;
5
+ cwd?: string;
6
+ env?: Record<string, string>;
7
+ customCommands?: CustomCommand[];
8
+ }
9
+ export declare function createVirtualSandbox(options: CreateVirtualSandboxOptions): Promise<DisposableSandbox>;
10
+ //# sourceMappingURL=virtual-sandbox.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,36 @@
1
+ import type { UIMessage } from 'ai';
2
+ import type { ChainSummary } from '../chain-summary.ts';
3
+ import type { ContextFragment } from '../fragments.ts';
4
+ import type { ConditionalReminder, ReminderResolution, ReminderTarget, WhenContext } from '../fragments/message/user.ts';
5
+ export type BaseWhenCtx = Omit<WhenContext, 'content' | 'currentMessage' | 'lastAssistantMessage' | 'lastAssistantMessages'>;
6
+ export interface PreparedCarrier {
7
+ message: UIMessage;
8
+ fragmentIndex: number;
9
+ }
10
+ export interface ReminderHandlerInput {
11
+ pending: ContextFragment[];
12
+ base: BaseWhenCtx;
13
+ chain: ChainSummary;
14
+ sharedUserMessage?: UIMessage & {
15
+ role: 'user';
16
+ };
17
+ }
18
+ export interface ReminderApplyInput {
19
+ pending: ContextFragment[];
20
+ carrier: PreparedCarrier;
21
+ fired: ConditionalReminder[];
22
+ resolved: ReminderResolution[];
23
+ }
24
+ export interface PreparedHandler {
25
+ whenCtx: WhenContext;
26
+ carrier: PreparedCarrier;
27
+ sharedUserMessage?: UIMessage & {
28
+ role: 'user';
29
+ };
30
+ }
31
+ export interface ReminderTargetHandler {
32
+ readonly target: ReminderTarget;
33
+ prepare(input: ReminderHandlerInput): PreparedHandler | null;
34
+ apply(input: ReminderApplyInput): void;
35
+ }
36
+ //# sourceMappingURL=reminder-target-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reminder-target-handler.d.ts","sourceRoot":"","sources":["../../../src/lib/save/reminder-target-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAEpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAEtC,MAAM,MAAM,WAAW,GAAG,IAAI,CAC5B,WAAW,EACT,SAAS,GACT,gBAAgB,GAChB,sBAAsB,GACtB,uBAAuB,CAC1B,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,SAAS,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;IACpB,iBAAiB,CAAC,EAAE,SAAS,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,OAAO,EAAE,eAAe,CAAC;IACzB,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,QAAQ,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,eAAe,CAAC;IACzB,iBAAiB,CAAC,EAAE,SAAS,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,OAAO,CAAC,KAAK,EAAE,oBAAoB,GAAG,eAAe,GAAG,IAAI,CAAC;IAC7D,KAAK,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACxC"}
@@ -0,0 +1,28 @@
1
+ import type { ChainSummary } from '../chain-summary.ts';
2
+ import type { ContextFragment } from '../fragments.ts';
3
+ import type { ContextStore } from '../store/store.ts';
4
+ import type { BaseWhenCtx, ReminderTargetHandler } from './reminder-target-handler.ts';
5
+ export interface SavePipelineEngine {
6
+ readonly store: ContextStore;
7
+ readonly chatId: string;
8
+ readonly branchName: string;
9
+ getActiveBranch(): {
10
+ id: string;
11
+ headMessageId: string | null;
12
+ };
13
+ commitHead(headMessageId: string): Promise<void>;
14
+ rewindForUpdate(parentId: string): Promise<void>;
15
+ getChainSummary(): Promise<ChainSummary>;
16
+ buildBaseWhenCtx(chain: ChainSummary): BaseWhenCtx;
17
+ }
18
+ export interface SaveResult {
19
+ headMessageId: string | undefined;
20
+ }
21
+ export declare class SavePipeline {
22
+ #private;
23
+ constructor(engine: SavePipelineEngine, pending: ContextFragment[], fragments: ContextFragment[]);
24
+ applyUpdateBranching(shouldBranch: boolean): Promise<this>;
25
+ evaluateReminders(handlers: ReminderTargetHandler[]): Promise<this>;
26
+ persist(): Promise<SaveResult>;
27
+ }
28
+ //# sourceMappingURL=save-pipeline.d.ts.map