zeitlich 0.2.21 → 0.2.23

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 (129) hide show
  1. package/README.md +303 -105
  2. package/dist/adapters/sandbox/daytona/index.cjs +7 -1
  3. package/dist/adapters/sandbox/daytona/index.cjs.map +1 -1
  4. package/dist/adapters/sandbox/daytona/index.d.cts +3 -1
  5. package/dist/adapters/sandbox/daytona/index.d.ts +3 -1
  6. package/dist/adapters/sandbox/daytona/index.js +7 -1
  7. package/dist/adapters/sandbox/daytona/index.js.map +1 -1
  8. package/dist/adapters/sandbox/daytona/workflow.cjs +33 -0
  9. package/dist/adapters/sandbox/daytona/workflow.cjs.map +1 -0
  10. package/dist/adapters/sandbox/daytona/workflow.d.cts +27 -0
  11. package/dist/adapters/sandbox/daytona/workflow.d.ts +27 -0
  12. package/dist/adapters/sandbox/daytona/workflow.js +31 -0
  13. package/dist/adapters/sandbox/daytona/workflow.js.map +1 -0
  14. package/dist/adapters/sandbox/inmemory/index.cjs +18 -1
  15. package/dist/adapters/sandbox/inmemory/index.cjs.map +1 -1
  16. package/dist/adapters/sandbox/inmemory/index.d.cts +4 -2
  17. package/dist/adapters/sandbox/inmemory/index.d.ts +4 -2
  18. package/dist/adapters/sandbox/inmemory/index.js +18 -1
  19. package/dist/adapters/sandbox/inmemory/index.js.map +1 -1
  20. package/dist/adapters/sandbox/inmemory/workflow.cjs +33 -0
  21. package/dist/adapters/sandbox/inmemory/workflow.cjs.map +1 -0
  22. package/dist/adapters/sandbox/inmemory/workflow.d.cts +25 -0
  23. package/dist/adapters/sandbox/inmemory/workflow.d.ts +25 -0
  24. package/dist/adapters/sandbox/inmemory/workflow.js +31 -0
  25. package/dist/adapters/sandbox/inmemory/workflow.js.map +1 -0
  26. package/dist/adapters/sandbox/virtual/index.cjs +36 -9
  27. package/dist/adapters/sandbox/virtual/index.cjs.map +1 -1
  28. package/dist/adapters/sandbox/virtual/index.d.cts +8 -5
  29. package/dist/adapters/sandbox/virtual/index.d.ts +8 -5
  30. package/dist/adapters/sandbox/virtual/index.js +36 -9
  31. package/dist/adapters/sandbox/virtual/index.js.map +1 -1
  32. package/dist/adapters/sandbox/virtual/workflow.cjs +33 -0
  33. package/dist/adapters/sandbox/virtual/workflow.cjs.map +1 -0
  34. package/dist/adapters/sandbox/virtual/workflow.d.cts +27 -0
  35. package/dist/adapters/sandbox/virtual/workflow.d.ts +27 -0
  36. package/dist/adapters/sandbox/virtual/workflow.js +31 -0
  37. package/dist/adapters/sandbox/virtual/workflow.js.map +1 -0
  38. package/dist/adapters/thread/google-genai/index.cjs +9 -1
  39. package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
  40. package/dist/adapters/thread/google-genai/index.d.cts +31 -19
  41. package/dist/adapters/thread/google-genai/index.d.ts +31 -19
  42. package/dist/adapters/thread/google-genai/index.js +9 -1
  43. package/dist/adapters/thread/google-genai/index.js.map +1 -1
  44. package/dist/adapters/thread/google-genai/workflow.cjs +33 -0
  45. package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -0
  46. package/dist/adapters/thread/google-genai/workflow.d.cts +32 -0
  47. package/dist/adapters/thread/google-genai/workflow.d.ts +32 -0
  48. package/dist/adapters/thread/google-genai/workflow.js +31 -0
  49. package/dist/adapters/thread/google-genai/workflow.js.map +1 -0
  50. package/dist/adapters/thread/langchain/index.cjs +9 -1
  51. package/dist/adapters/thread/langchain/index.cjs.map +1 -1
  52. package/dist/adapters/thread/langchain/index.d.cts +27 -16
  53. package/dist/adapters/thread/langchain/index.d.ts +27 -16
  54. package/dist/adapters/thread/langchain/index.js +9 -1
  55. package/dist/adapters/thread/langchain/index.js.map +1 -1
  56. package/dist/adapters/thread/langchain/workflow.cjs +33 -0
  57. package/dist/adapters/thread/langchain/workflow.cjs.map +1 -0
  58. package/dist/adapters/thread/langchain/workflow.d.cts +32 -0
  59. package/dist/adapters/thread/langchain/workflow.d.ts +32 -0
  60. package/dist/adapters/thread/langchain/workflow.js +31 -0
  61. package/dist/adapters/thread/langchain/workflow.js.map +1 -0
  62. package/dist/index.cjs +282 -90
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +38 -16
  65. package/dist/index.d.ts +38 -16
  66. package/dist/index.js +281 -87
  67. package/dist/index.js.map +1 -1
  68. package/dist/queries-DModcWRy.d.cts +44 -0
  69. package/dist/queries-byD0jr1Y.d.ts +44 -0
  70. package/dist/{types-BkAYmc96.d.ts → types-B50pBPEV.d.ts} +190 -38
  71. package/dist/{types-YbL7JpEA.d.cts → types-Bll19FZJ.d.cts} +7 -0
  72. package/dist/{types-YbL7JpEA.d.ts → types-Bll19FZJ.d.ts} +7 -0
  73. package/dist/{queries-6Avfh74U.d.ts → types-BuXdFhaZ.d.cts} +7 -48
  74. package/dist/{types-BMRzfELQ.d.cts → types-ChAMwU3q.d.cts} +17 -1
  75. package/dist/{types-BMRzfELQ.d.ts → types-ChAMwU3q.d.ts} +17 -1
  76. package/dist/{types-CES_30qx.d.cts → types-DQW8l7pY.d.cts} +190 -38
  77. package/dist/{queries-CHa2iv_I.d.cts → types-GZ76HZSj.d.ts} +7 -48
  78. package/dist/workflow.cjs +244 -86
  79. package/dist/workflow.cjs.map +1 -1
  80. package/dist/workflow.d.cts +54 -65
  81. package/dist/workflow.d.ts +54 -65
  82. package/dist/workflow.js +243 -83
  83. package/dist/workflow.js.map +1 -1
  84. package/package.json +54 -2
  85. package/src/adapters/sandbox/daytona/filesystem.ts +1 -1
  86. package/src/adapters/sandbox/daytona/index.ts +8 -0
  87. package/src/adapters/sandbox/daytona/proxy.ts +56 -0
  88. package/src/adapters/sandbox/e2b/filesystem.ts +147 -0
  89. package/src/adapters/sandbox/e2b/index.ts +164 -0
  90. package/src/adapters/sandbox/e2b/types.ts +23 -0
  91. package/src/adapters/sandbox/inmemory/index.ts +27 -3
  92. package/src/adapters/sandbox/inmemory/proxy.ts +53 -0
  93. package/src/adapters/sandbox/virtual/filesystem.ts +41 -17
  94. package/src/adapters/sandbox/virtual/provider.ts +9 -1
  95. package/src/adapters/sandbox/virtual/proxy.ts +53 -0
  96. package/src/adapters/sandbox/virtual/types.ts +9 -4
  97. package/src/adapters/thread/google-genai/activities.ts +51 -17
  98. package/src/adapters/thread/google-genai/index.ts +1 -0
  99. package/src/adapters/thread/google-genai/proxy.ts +61 -0
  100. package/src/adapters/thread/langchain/activities.ts +47 -14
  101. package/src/adapters/thread/langchain/index.ts +1 -0
  102. package/src/adapters/thread/langchain/proxy.ts +61 -0
  103. package/src/lib/lifecycle.ts +57 -0
  104. package/src/lib/sandbox/manager.ts +52 -6
  105. package/src/lib/sandbox/sandbox.test.ts +12 -11
  106. package/src/lib/sandbox/types.ts +31 -4
  107. package/src/lib/session/index.ts +4 -5
  108. package/src/lib/session/session-edge-cases.integration.test.ts +491 -66
  109. package/src/lib/session/session.integration.test.ts +92 -80
  110. package/src/lib/session/session.ts +108 -96
  111. package/src/lib/session/types.ts +87 -17
  112. package/src/lib/subagent/define.ts +6 -5
  113. package/src/lib/subagent/handler.ts +148 -16
  114. package/src/lib/subagent/index.ts +4 -0
  115. package/src/lib/subagent/register.ts +10 -3
  116. package/src/lib/subagent/signals.ts +8 -0
  117. package/src/lib/subagent/subagent.integration.test.ts +893 -128
  118. package/src/lib/subagent/tool.ts +2 -2
  119. package/src/lib/subagent/types.ts +84 -21
  120. package/src/lib/subagent/workflow.ts +83 -12
  121. package/src/lib/tool-router/router-edge-cases.integration.test.ts +4 -1
  122. package/src/lib/tool-router/router.integration.test.ts +141 -5
  123. package/src/lib/tool-router/router.ts +13 -3
  124. package/src/lib/tool-router/types.ts +7 -0
  125. package/src/lib/workflow.test.ts +104 -27
  126. package/src/lib/workflow.ts +37 -19
  127. package/src/tools/bash/bash.test.ts +16 -7
  128. package/src/workflow.ts +11 -14
  129. package/tsup.config.ts +6 -0
@@ -1,5 +1,5 @@
1
1
  import { BashOptions } from 'just-bash';
2
- import { S as Sandbox, a as SandboxFileSystem, b as SandboxProvider, c as SandboxCapabilities, d as SandboxCreateOptions, e as SandboxCreateResult, f as SandboxSnapshot } from '../../../types-BMRzfELQ.js';
2
+ import { S as Sandbox, a as SandboxFileSystem, b as SandboxProvider, c as SandboxCapabilities, d as SandboxCreateOptions, e as SandboxCreateResult, f as SandboxSnapshot } from '../../../types-ChAMwU3q.js';
3
3
  import '@temporalio/common';
4
4
 
5
5
  interface InMemorySandboxOptions {
@@ -14,14 +14,16 @@ type InMemorySandbox = Sandbox & {
14
14
  };
15
15
  declare class InMemorySandboxProvider implements SandboxProvider {
16
16
  private defaultOptions?;
17
- readonly id = "inmemory";
17
+ readonly id = "inMemory";
18
18
  readonly capabilities: SandboxCapabilities;
19
19
  private sandboxes;
20
20
  constructor(defaultOptions?: InMemorySandboxOptions | undefined);
21
21
  get(id: string): Promise<Sandbox>;
22
22
  destroy(id: string): Promise<void>;
23
+ pause(_sandboxId: string, _ttlSeconds?: number): Promise<void>;
23
24
  create(options?: SandboxCreateOptions): Promise<SandboxCreateResult>;
24
25
  snapshot(sandboxId: string): Promise<SandboxSnapshot>;
26
+ fork(sandboxId: string): Promise<Sandbox>;
25
27
  restore(snapshot: SandboxSnapshot): Promise<Sandbox>;
26
28
  }
27
29
 
@@ -101,7 +101,7 @@ var InMemorySandboxProvider = class {
101
101
  constructor(defaultOptions) {
102
102
  this.defaultOptions = defaultOptions;
103
103
  }
104
- id = "inmemory";
104
+ id = "inMemory";
105
105
  capabilities = {
106
106
  filesystem: true,
107
107
  execution: true,
@@ -120,6 +120,8 @@ var InMemorySandboxProvider = class {
120
120
  this.sandboxes.delete(id);
121
121
  }
122
122
  }
123
+ async pause(_sandboxId, _ttlSeconds) {
124
+ }
123
125
  async create(options) {
124
126
  const id = options?.id ?? getShortId();
125
127
  const initialFiles = {};
@@ -155,6 +157,21 @@ var InMemorySandboxProvider = class {
155
157
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
156
158
  };
157
159
  }
160
+ async fork(sandboxId) {
161
+ const sandbox = await this.get(sandboxId);
162
+ const entries = await sandbox.fs.readdirWithFileTypes("/");
163
+ const initialFiles = {};
164
+ for (const entry of entries) {
165
+ if (entry.isFile) {
166
+ initialFiles[entry.name] = await sandbox.fs.readFileBuffer(entry.name);
167
+ }
168
+ }
169
+ const newSandbox = await this.create({
170
+ id: getShortId(),
171
+ initialFiles
172
+ });
173
+ return newSandbox.sandbox;
174
+ }
158
175
  async restore(snapshot) {
159
176
  const { files } = snapshot.data;
160
177
  const initialFiles = {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/sandbox/types.ts","../../../../src/lib/thread/id.ts","../../../../src/adapters/sandbox/inmemory/index.ts"],"names":[],"mappings":";;;;;AAiKO,IAAM,oBAAA,GAAN,cAAmC,kBAAA,CAAmB;AAAA,EAC3D,YAAY,SAAA,EAAmB;AAC7B,IAAA,KAAA,CAAM,CAAA,mBAAA,EAAsB,SAAS,CAAA,CAAA,EAAI,sBAAA,EAAwB,IAAI,CAAA;AAAA,EACvE;AACF,CAAA;ACnKA,IAAM,MAAA,GACJ,gEAAA;AAaK,SAAS,UAAA,CAAW,SAAS,EAAA,EAAY;AAC9C,EAAA,MAAM,GAAA,GAAM,KAAA,EAAM,CAAE,OAAA,CAAQ,MAAM,EAAE,CAAA;AACpC,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,MAAA,EAAQ,CAAA,EAAA,EAAK;AAC/B,IAAA,MAAM,IAAA,GAAO,QAAA,CAAS,GAAA,CAAI,KAAA,CAAM,CAAA,GAAI,GAAG,CAAA,GAAI,CAAA,GAAI,CAAC,CAAA,EAAG,EAAE,CAAA;AACrD,IAAA,MAAA,IAAU,MAAA,CAAO,IAAA,GAAO,MAAA,CAAO,MAAM,CAAA;AAAA,EACvC;AACA,EAAA,OAAO,MAAA;AACT;;;ACGA,SAAS,YAAY,EAAA,EAAoC;AACvD,EAAA,MAAM,aAAA,GAAgB,GAAA;AACtB,E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,CAAK;AAAA,KACP;AACA,IAAA,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,OAAA,CAAQ,EAAA,EAAI,OAAO,CAAA;AACtC,IAAA,OAAO,OAAA;AAAA,EACT;AACF","file":"index.js","sourcesContent":["// ============================================================================\n// Sandbox Filesystem\n// ============================================================================\n\nexport interface DirentEntry {\n name: string;\n isFile: boolean;\n isDirectory: boolean;\n isSymbolicLink: boolean;\n}\n\nexport interface FileStat {\n isFile: boolean;\n isDirectory: boolean;\n isSymbolicLink: boolean;\n size: number;\n mtime: Date;\n}\n\n/**\n * Provider-agnostic filesystem interface.\n *\n * Implementations that don't support a method should throw\n * {@link SandboxNotSupportedError}.\n */\nexport interface SandboxFileSystem {\n /** Base directory used when resolving relative paths. */\n readonly workspaceBase: string;\n readFile(path: string): Promise<string>;\n readFileBuffer(path: string): Promise<Uint8Array>;\n writeFile(path: string, content: string | Uint8Array): Promise<void>;\n appendFile(path: string, content: string | Uint8Array): Promise<void>;\n exists(path: string): Promise<boolean>;\n stat(path: string): Promise<FileStat>;\n mkdir(path: string, options?: { recursive?: boolean }): Promise<void>;\n readdir(path: string): Promise<string[]>;\n readdirWithFileTypes(path: string): Promise<DirentEntry[]>;\n rm(path: string, options?: { recursive?: boolean; force?: boolean }): Promise<void>;\n cp(src: string, dest: string, options?: { recursive?: boolean }): Promise<void>;\n mv(src: string, dest: string): Promise<void>;\n readlink(path: string): Promise<string>;\n resolvePath(base: string, path: string): string;\n}\n\n// ============================================================================\n// Execution\n// ============================================================================\n\nexport interface ExecOptions {\n timeout?: number;\n cwd?: string;\n env?: Record<string, string>;\n}\n\nexport interface ExecResult {\n exitCode: number;\n stdout: string;\n stderr: string;\n}\n\n// ============================================================================\n// Capabilities\n// ============================================================================\n\nexport interface SandboxCapabilities {\n /** Sandbox supports filesystem operations */\n filesystem: boolean;\n /** Sandbox supports shell/command execution */\n execution: boolean;\n /** Sandbox state can be persisted and restored */\n persistence: boolean;\n}\n\n// ============================================================================\n// Sandbox\n// ============================================================================\n\nexport interface Sandbox {\n readonly id: string;\n readonly capabilities: SandboxCapabilities;\n readonly fs: SandboxFileSystem;\n\n exec(command: string, options?: ExecOptions): Promise<ExecResult>;\n destroy(): Promise<void>;\n}\n\n// ============================================================================\n// Snapshots\n// ============================================================================\n\nexport interface SandboxSnapshot {\n sandboxId: string;\n providerId: string;\n /** Provider-specific serialised state */\n data: unknown;\n createdAt: string;\n}\n\n// ============================================================================\n// Provider\n// ============================================================================\n\nexport interface SandboxCreateOptions {\n /** Preferred sandbox ID (provider may ignore) */\n id?: string;\n /** Seed the filesystem with these files */\n initialFiles?: Record<string, string | Uint8Array>;\n /** Environment variables available inside the sandbox */\n env?: Record<string, string>;\n}\n\nexport interface SandboxCreateResult {\n sandbox: Sandbox;\n /** Optional state to merge into the workflow's `AgentState` via the session. */\n stateUpdate?: Record<string, unknown>;\n}\n\nexport interface SandboxProvider<\n TOptions extends SandboxCreateOptions = SandboxCreateOptions,\n TSandbox extends Sandbox = Sandbox,\n> {\n readonly id: string;\n readonly capabilities: SandboxCapabilities;\n\n create(options?: TOptions): Promise<SandboxCreateResult>;\n get(sandboxId: string): Promise<TSandbox>;\n destroy(sandboxId: string): Promise<void>;\n snapshot(sandboxId: string): Promise<SandboxSnapshot>;\n restore(snapshot: SandboxSnapshot): Promise<Sandbox>;\n}\n\n// ============================================================================\n// SandboxOps — workflow-side activity interface (like ThreadOps)\n// ============================================================================\n\nexport interface SandboxOps<\n TOptions extends SandboxCreateOptions = SandboxCreateOptions,\n> {\n createSandbox(\n options?: TOptions,\n ): Promise<{ sandboxId: string; stateUpdate?: Record<string, unknown> }>;\n destroySandbox(sandboxId: string): Promise<void>;\n snapshotSandbox(sandboxId: string): Promise<SandboxSnapshot>;\n}\n\n// ============================================================================\n// Errors\n// ============================================================================\n\nimport { ApplicationFailure } from \"@temporalio/common\";\n\nexport class SandboxNotSupportedError extends ApplicationFailure {\n constructor(operation: string) {\n super(\n `Sandbox does not support: ${operation}`,\n \"SandboxNotSupportedError\",\n true,\n );\n }\n}\n\nexport class SandboxNotFoundError extends ApplicationFailure {\n constructor(sandboxId: string) {\n super(`Sandbox not found: ${sandboxId}`, \"SandboxNotFoundError\", true);\n }\n}\n","import { uuid4 } from \"@temporalio/workflow\";\n\nconst BASE62 =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n\n/**\n * Generate a compact, workflow-deterministic identifier.\n *\n * Uses Temporal's `uuid4()` internally (seeded by the workflow's RNG),\n * then re-encodes the hex bytes into a base-62 alphabet for a shorter,\n * more token-efficient identifier (~3 tokens vs ~10 for a full UUID).\n *\n * Suitable for thread IDs, child workflow IDs, or any workflow-scoped identifier.\n *\n * @param length - Number of base-62 characters (default 12, ~71 bits of entropy)\n */\nexport function getShortId(length = 12): string {\n const hex = uuid4().replace(/-/g, \"\");\n let result = \"\";\n for (let i = 0; i < length; i++) {\n const byte = parseInt(hex.slice(i * 2, i * 2 + 2), 16);\n result += BASE62[byte % BASE62.length];\n }\n return result;\n}\n","import {\n Bash,\n InMemoryFs,\n type BashOptions,\n type IFileSystem,\n type InitialFiles,\n} from \"just-bash\";\nimport type {\n Sandbox,\n SandboxCapabilities,\n SandboxCreateOptions,\n SandboxCreateResult,\n SandboxFileSystem,\n SandboxProvider,\n SandboxSnapshot,\n ExecOptions,\n ExecResult,\n DirentEntry,\n FileStat,\n} from \"../../../lib/sandbox/types\";\nimport { SandboxNotFoundError } from \"../../../lib/sandbox/types\";\nimport { getShortId } from \"../../../lib/thread/id\";\n\n// ============================================================================\n// Adapter: IFileSystem → SandboxFileSystem\n// ============================================================================\n\nfunction toSandboxFs(fs: IFileSystem): SandboxFileSystem {\n const workspaceBase = \"/\";\n const normalisePath = (path: string): string => fs.resolvePath(workspaceBase, path);\n\n return {\n workspaceBase,\n readFile: (path) => fs.readFile(normalisePath(path)),\n readFileBuffer: (path) => fs.readFileBuffer(normalisePath(path)),\n writeFile: (path, content) => fs.writeFile(normalisePath(path), content),\n appendFile: (path, content) => fs.appendFile(normalisePath(path), content),\n exists: (path) => fs.exists(normalisePath(path)),\n stat: async (path): Promise<FileStat> => {\n const s = await fs.stat(normalisePath(path));\n return {\n isFile: s.isFile,\n isDirectory: s.isDirectory,\n isSymbolicLink: s.isSymbolicLink,\n size: s.size,\n mtime: s.mtime,\n };\n },\n mkdir: (path, opts) => fs.mkdir(normalisePath(path), opts),\n readdir: (path) => fs.readdir(normalisePath(path)),\n readdirWithFileTypes: async (path): Promise<DirentEntry[]> => {\n const dirPath = normalisePath(path);\n if (!fs.readdirWithFileTypes) {\n const names = await fs.readdir(dirPath);\n return Promise.all(\n names.map(async (name) => {\n const childPath = fs.resolvePath(dirPath, name);\n const s = await fs.stat(childPath);\n return {\n name,\n isFile: s.isFile,\n isDirectory: s.isDirectory,\n isSymbolicLink: s.isSymbolicLink,\n };\n })\n );\n }\n return fs.readdirWithFileTypes(dirPath);\n },\n rm: (path, opts) => fs.rm(normalisePath(path), opts),\n cp: (src, dest, opts) => fs.cp(normalisePath(src), normalisePath(dest), opts),\n mv: (src, dest) => fs.mv(normalisePath(src), normalisePath(dest)),\n readlink: (path) => fs.readlink(normalisePath(path)),\n resolvePath: (base, p) => fs.resolvePath(normalisePath(base), p),\n };\n}\n\n// ============================================================================\n// InMemorySandbox\n// ============================================================================\n\nexport interface InMemorySandboxOptions {\n /** Options forwarded to `just-bash` `Bash` (minus `fs` which is managed) */\n bashOptions?: Omit<BashOptions, \"fs\">;\n}\n\n/**\n * An in-memory {@link Sandbox} backed by `just-bash`.\n */\nexport type InMemorySandbox = Sandbox & { fs: SandboxFileSystem };\n\nclass InMemorySandboxImpl implements Sandbox {\n readonly capabilities: SandboxCapabilities = {\n filesystem: true,\n execution: true,\n persistence: true,\n };\n\n readonly fs: SandboxFileSystem;\n private bashOptions: Omit<BashOptions, \"fs\">;\n\n constructor(\n readonly id: string,\n private justBashFs: IFileSystem,\n options?: InMemorySandboxOptions\n ) {\n this.fs = toSandboxFs(justBashFs);\n this.bashOptions = {\n executionLimits: { maxStringLength: 52_428_800 },\n ...options?.bashOptions,\n };\n }\n\n async exec(command: string, _options?: ExecOptions): Promise<ExecResult> {\n const bash = new Bash({ ...this.bashOptions, fs: this.justBashFs });\n const { exitCode, stderr, stdout } = await bash.exec(command);\n return { exitCode, stdout, stderr };\n }\n\n async destroy(): Promise<void> {\n // In-memory: nothing to clean up\n }\n\n /** Expose the underlying IFileSystem for snapshot serialisation */\n _getJustBashFs(): IFileSystem {\n return this.justBashFs;\n }\n}\n\n// ============================================================================\n// InMemorySandboxProvider\n// ============================================================================\n\nexport class InMemorySandboxProvider implements SandboxProvider {\n readonly id = \"inmemory\";\n readonly capabilities: SandboxCapabilities = {\n filesystem: true,\n execution: true,\n persistence: true,\n };\n\n private sandboxes = new Map<string, InMemorySandboxImpl>();\n\n constructor(private defaultOptions?: InMemorySandboxOptions) {}\n\n async get(id: string): Promise<Sandbox> {\n const sandbox = this.sandboxes.get(id);\n if (!sandbox) throw new SandboxNotFoundError(id);\n return sandbox;\n }\n\n async destroy(id: string): Promise<void> {\n const sandbox = this.sandboxes.get(id);\n if (sandbox) {\n await sandbox.destroy();\n this.sandboxes.delete(id);\n }\n }\n\n async create(options?: SandboxCreateOptions): Promise<SandboxCreateResult> {\n const id = options?.id ?? getShortId();\n const initialFiles: InitialFiles = {};\n\n if (options?.initialFiles) {\n for (const [path, content] of Object.entries(options.initialFiles)) {\n initialFiles[path] = content;\n }\n }\n\n const fs = new InMemoryFs(initialFiles);\n const sandbox = new InMemorySandboxImpl(id, fs, this.defaultOptions);\n this.sandboxes.set(id, sandbox);\n return { sandbox };\n }\n\n async snapshot(sandboxId: string): Promise<SandboxSnapshot> {\n const sandbox = this.sandboxes.get(sandboxId);\n if (!sandbox) throw new SandboxNotFoundError(sandboxId);\n\n const fs = sandbox._getJustBashFs();\n const paths = fs.getAllPaths();\n const files: Record<string, string> = {};\n\n for (const p of paths) {\n try {\n const stat = await fs.stat(p);\n if (stat.isFile) {\n files[p] = await fs.readFile(p);\n }\n } catch {\n // skip entries that can't be read (e.g. broken symlinks)\n }\n }\n\n return {\n sandboxId,\n providerId: this.id,\n data: { files },\n createdAt: new Date().toISOString(),\n };\n }\n\n async restore(snapshot: SandboxSnapshot): Promise<Sandbox> {\n const { files } = snapshot.data as { files: Record<string, string> };\n const initialFiles: InitialFiles = {};\n for (const [path, content] of Object.entries(files)) {\n initialFiles[path] = content;\n }\n\n const fs = new InMemoryFs(initialFiles);\n const sandbox = new InMemorySandboxImpl(\n snapshot.sandboxId,\n fs,\n this.defaultOptions\n );\n this.sandboxes.set(sandbox.id, sandbox);\n return sandbox;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../../src/lib/sandbox/types.ts","../../../../src/lib/thread/id.ts","../../../../src/adapters/sandbox/inmemory/index.ts"],"names":[],"mappings":";;;;;AA4LO,IAAM,oBAAA,GAAN,cAAmC,kBAAA,CAAmB;AAAA,EAC3D,YAAY,SAAA,EAAmB;AAC7B,IAAA,KAAA,CAAM,CAAA,mBAAA,EAAsB,SAAS,CAAA,CAAA,EAAI,sBAAA,EAAwB,IAAI,CAAA;AAAA,EACvE;AACF,CAAA;AC9LA,IAAM,MAAA,GACJ,gEAAA;AAaK,SAAS,UAAA,CAAW,SAAS,EAAA,EAAY;AAC9C,EAAA,MAAM,GAAA,GAAM,KAAA,EAAM,CAAE,OAAA,CAAQ,MAAM,EAAE,CAAA;AACpC,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,MAAA,EAAQ,CAAA,EAAA,EAAK;AAC/B,IAAA,MAAM,IAAA,GAAO,QAAA,CAAS,GAAA,CAAI,KAAA,CAAM,CAAA,GAAI,GAAG,CAAA,GAAI,CAAA,GAAI,CAAC,CAAA,EAAG,EAAE,CAAA;AACrD,IAAA,MAAA,IAAU,MAAA,CAAO,IAAA,GAAO,MAAA,CAAO,MAAM,CAAA;AAAA,E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,MAAA,IAAI,MAAM,MAAA,EAAQ;AAChB,QAAA,YAAA,CAAa,KAAA,CAAM,IAAI,CAAA,GAAI,MAAM,QAAQ,EAAA,CAAG,cAAA,CAAe,MAAM,IAAI,CAAA;AAAA,MACvE;AAAA,IACF;AAEA,IAAA,MAAM,UAAA,GAAa,MAAM,IAAA,CAAK,MAAA,CAAO;AAAA,MACnC,IAAI,UAAA,EAAW;AAAA,MACf;AAAA,KACD,CAAA;AACD,IAAA,OAAO,UAAA,CAAW,OAAA;AAAA,EACpB;AAAA,EAEA,MAAM,QAAQ,QAAA,EAA6C;AACzD,IAAA,MAAM,EAAE,KAAA,EAAM,GAAI,QAAA,CAAS,IAAA;AAC3B,IAAA,MAAM,eAA6B,EAAC;AACpC,IAAA,KAAA,MAAW,CAAC,IAAA,EAAM,OAAO,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AACnD,MAAA,YAAA,CAAa,IAAI,CAAA,GAAI,OAAA;AAAA,IACvB;AAEA,IAAA,MAAM,EAAA,GAAK,IAAI,UAAA,CAAW,YAAY,CAAA;AACtC,IAAA,MAAM,UAAU,IAAI,mBAAA;AAAA,MAClB,QAAA,CAAS,SAAA;AAAA,MACT,EAAA;AAAA,MACA,IAAA,CAAK;AAAA,KACP;AACA,IAAA,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,OAAA,CAAQ,EAAA,EAAI,OAAO,CAAA;AACtC,IAAA,OAAO,OAAA;AAAA,EACT;AACF","file":"index.js","sourcesContent":["// ============================================================================\n// Sandbox Filesystem\n// ============================================================================\n\nexport interface DirentEntry {\n name: string;\n isFile: boolean;\n isDirectory: boolean;\n isSymbolicLink: boolean;\n}\n\nexport interface FileStat {\n isFile: boolean;\n isDirectory: boolean;\n isSymbolicLink: boolean;\n size: number;\n mtime: Date;\n}\n\n/**\n * Provider-agnostic filesystem interface.\n *\n * Implementations that don't support a method should throw\n * {@link SandboxNotSupportedError}.\n */\nexport interface SandboxFileSystem {\n /** Base directory used when resolving relative paths. */\n readonly workspaceBase: string;\n readFile(path: string): Promise<string>;\n readFileBuffer(path: string): Promise<Uint8Array>;\n writeFile(path: string, content: string | Uint8Array): Promise<void>;\n appendFile(path: string, content: string | Uint8Array): Promise<void>;\n exists(path: string): Promise<boolean>;\n stat(path: string): Promise<FileStat>;\n mkdir(path: string, options?: { recursive?: boolean }): Promise<void>;\n readdir(path: string): Promise<string[]>;\n readdirWithFileTypes(path: string): Promise<DirentEntry[]>;\n rm(\n path: string,\n options?: { recursive?: boolean; force?: boolean }\n ): Promise<void>;\n cp(\n src: string,\n dest: string,\n options?: { recursive?: boolean }\n ): Promise<void>;\n mv(src: string, dest: string): Promise<void>;\n readlink(path: string): Promise<string>;\n resolvePath(base: string, path: string): string;\n}\n\n// ============================================================================\n// Execution\n// ============================================================================\n\nexport interface ExecOptions {\n timeout?: number;\n cwd?: string;\n env?: Record<string, string>;\n}\n\nexport interface ExecResult {\n exitCode: number;\n stdout: string;\n stderr: string;\n}\n\n// ============================================================================\n// Capabilities\n// ============================================================================\n\nexport interface SandboxCapabilities {\n /** Sandbox supports filesystem operations */\n filesystem: boolean;\n /** Sandbox supports shell/command execution */\n execution: boolean;\n /** Sandbox state can be persisted and restored */\n persistence: boolean;\n}\n\n// ============================================================================\n// Sandbox\n// ============================================================================\n\nexport interface Sandbox {\n readonly id: string;\n readonly capabilities: SandboxCapabilities;\n readonly fs: SandboxFileSystem;\n\n exec(command: string, options?: ExecOptions): Promise<ExecResult>;\n destroy(): Promise<void>;\n}\n\n// ============================================================================\n// Snapshots\n// ============================================================================\n\nexport interface SandboxSnapshot {\n sandboxId: string;\n providerId: string;\n /** Provider-specific serialised state */\n data: unknown;\n createdAt: string;\n}\n\n// ============================================================================\n// Provider\n// ============================================================================\n\nexport interface SandboxCreateOptions {\n /** Preferred sandbox ID (provider may ignore) */\n id?: string;\n /** Seed the filesystem with these files */\n initialFiles?: Record<string, string | Uint8Array>;\n /** Environment variables available inside the sandbox */\n env?: Record<string, string>;\n}\n\nexport interface SandboxCreateResult {\n sandbox: Sandbox;\n /** Optional state to merge into the workflow's `AgentState` via the session. */\n stateUpdate?: Record<string, unknown>;\n}\n\nexport interface SandboxProvider<\n TOptions extends SandboxCreateOptions = SandboxCreateOptions,\n TSandbox extends Sandbox = Sandbox,\n> {\n readonly id: string;\n readonly capabilities: SandboxCapabilities;\n\n create(options?: TOptions): Promise<SandboxCreateResult>;\n get(sandboxId: string): Promise<TSandbox>;\n destroy(sandboxId: string): Promise<void>;\n pause(sandboxId: string, ttlSeconds?: number): Promise<void>;\n snapshot(sandboxId: string): Promise<SandboxSnapshot>;\n restore(snapshot: SandboxSnapshot): Promise<Sandbox>;\n fork(sandboxId: string): Promise<Sandbox>;\n}\n\n// ============================================================================\n// SandboxOps — workflow-side activity interface (like ThreadOps)\n// ============================================================================\n\nexport interface SandboxOps<\n TOptions extends SandboxCreateOptions = SandboxCreateOptions,\n> {\n createSandbox(\n options?: TOptions\n ): Promise<{ sandboxId: string; stateUpdate?: Record<string, unknown> }>;\n destroySandbox(sandboxId: string): Promise<void>;\n pauseSandbox(sandboxId: string): Promise<void>;\n snapshotSandbox(sandboxId: string): Promise<SandboxSnapshot>;\n forkSandbox(sandboxId: string): Promise<string>;\n}\n\n/**\n * Maps generic {@link SandboxOps} method names to adapter-prefixed names.\n *\n * @example\n * ```typescript\n * type InMemOps = PrefixedSandboxOps<\"inMemory\">;\n * // → { inMemoryCreateSandbox, inMemoryDestroySandbox, inMemorySnapshotSandbox }\n * ```\n */\nexport type PrefixedSandboxOps<\n TPrefix extends string,\n TOptions extends SandboxCreateOptions = SandboxCreateOptions,\n> = {\n [K in keyof SandboxOps<TOptions> as `${TPrefix}${Capitalize<K & string>}`]: SandboxOps<TOptions>[K];\n};\n\n// ============================================================================\n// Errors\n// ============================================================================\n\nimport { ApplicationFailure } from \"@temporalio/common\";\n\nexport class SandboxNotSupportedError extends ApplicationFailure {\n constructor(operation: string) {\n super(\n `Sandbox does not support: ${operation}`,\n \"SandboxNotSupportedError\",\n true\n );\n }\n}\n\nexport class SandboxNotFoundError extends ApplicationFailure {\n constructor(sandboxId: string) {\n super(`Sandbox not found: ${sandboxId}`, \"SandboxNotFoundError\", true);\n }\n}\n","import { uuid4 } from \"@temporalio/workflow\";\n\nconst BASE62 =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n\n/**\n * Generate a compact, workflow-deterministic identifier.\n *\n * Uses Temporal's `uuid4()` internally (seeded by the workflow's RNG),\n * then re-encodes the hex bytes into a base-62 alphabet for a shorter,\n * more token-efficient identifier (~3 tokens vs ~10 for a full UUID).\n *\n * Suitable for thread IDs, child workflow IDs, or any workflow-scoped identifier.\n *\n * @param length - Number of base-62 characters (default 12, ~71 bits of entropy)\n */\nexport function getShortId(length = 12): string {\n const hex = uuid4().replace(/-/g, \"\");\n let result = \"\";\n for (let i = 0; i < length; i++) {\n const byte = parseInt(hex.slice(i * 2, i * 2 + 2), 16);\n result += BASE62[byte % BASE62.length];\n }\n return result;\n}\n","import {\n Bash,\n InMemoryFs,\n type BashOptions,\n type IFileSystem,\n type InitialFiles,\n} from \"just-bash\";\nimport type {\n Sandbox,\n SandboxCapabilities,\n SandboxCreateOptions,\n SandboxCreateResult,\n SandboxFileSystem,\n SandboxProvider,\n SandboxSnapshot,\n ExecOptions,\n ExecResult,\n DirentEntry,\n FileStat,\n} from \"../../../lib/sandbox/types\";\nimport { SandboxNotFoundError } from \"../../../lib/sandbox/types\";\nimport { getShortId } from \"../../../lib/thread/id\";\n\n// ============================================================================\n// Adapter: IFileSystem → SandboxFileSystem\n// ============================================================================\n\nfunction toSandboxFs(fs: IFileSystem): SandboxFileSystem {\n const workspaceBase = \"/\";\n const normalisePath = (path: string): string =>\n fs.resolvePath(workspaceBase, path);\n\n return {\n workspaceBase,\n readFile: (path) => fs.readFile(normalisePath(path)),\n readFileBuffer: (path) => fs.readFileBuffer(normalisePath(path)),\n writeFile: (path, content) => fs.writeFile(normalisePath(path), content),\n appendFile: (path, content) => fs.appendFile(normalisePath(path), content),\n exists: (path) => fs.exists(normalisePath(path)),\n stat: async (path): Promise<FileStat> => {\n const s = await fs.stat(normalisePath(path));\n return {\n isFile: s.isFile,\n isDirectory: s.isDirectory,\n isSymbolicLink: s.isSymbolicLink,\n size: s.size,\n mtime: s.mtime,\n };\n },\n mkdir: (path, opts) => fs.mkdir(normalisePath(path), opts),\n readdir: (path) => fs.readdir(normalisePath(path)),\n readdirWithFileTypes: async (path): Promise<DirentEntry[]> => {\n const dirPath = normalisePath(path);\n if (!fs.readdirWithFileTypes) {\n const names = await fs.readdir(dirPath);\n return Promise.all(\n names.map(async (name) => {\n const childPath = fs.resolvePath(dirPath, name);\n const s = await fs.stat(childPath);\n return {\n name,\n isFile: s.isFile,\n isDirectory: s.isDirectory,\n isSymbolicLink: s.isSymbolicLink,\n };\n })\n );\n }\n return fs.readdirWithFileTypes(dirPath);\n },\n rm: (path, opts) => fs.rm(normalisePath(path), opts),\n cp: (src, dest, opts) =>\n fs.cp(normalisePath(src), normalisePath(dest), opts),\n mv: (src, dest) => fs.mv(normalisePath(src), normalisePath(dest)),\n readlink: (path) => fs.readlink(normalisePath(path)),\n resolvePath: (base, p) => fs.resolvePath(normalisePath(base), p),\n };\n}\n\n// ============================================================================\n// InMemorySandbox\n// ============================================================================\n\nexport interface InMemorySandboxOptions {\n /** Options forwarded to `just-bash` `Bash` (minus `fs` which is managed) */\n bashOptions?: Omit<BashOptions, \"fs\">;\n}\n\n/**\n * An in-memory {@link Sandbox} backed by `just-bash`.\n */\nexport type InMemorySandbox = Sandbox & { fs: SandboxFileSystem };\n\nclass InMemorySandboxImpl implements Sandbox {\n readonly capabilities: SandboxCapabilities = {\n filesystem: true,\n execution: true,\n persistence: true,\n };\n\n readonly fs: SandboxFileSystem;\n private bashOptions: Omit<BashOptions, \"fs\">;\n\n constructor(\n readonly id: string,\n private justBashFs: IFileSystem,\n options?: InMemorySandboxOptions\n ) {\n this.fs = toSandboxFs(justBashFs);\n this.bashOptions = {\n executionLimits: { maxStringLength: 52_428_800 },\n ...options?.bashOptions,\n };\n }\n\n async exec(command: string, _options?: ExecOptions): Promise<ExecResult> {\n const bash = new Bash({ ...this.bashOptions, fs: this.justBashFs });\n const { exitCode, stderr, stdout } = await bash.exec(command);\n return { exitCode, stdout, stderr };\n }\n\n async destroy(): Promise<void> {\n // In-memory: nothing to clean up\n }\n\n /** Expose the underlying IFileSystem for snapshot serialisation */\n _getJustBashFs(): IFileSystem {\n return this.justBashFs;\n }\n}\n\n// ============================================================================\n// InMemorySandboxProvider\n// ============================================================================\n\nexport class InMemorySandboxProvider implements SandboxProvider {\n readonly id = \"inMemory\";\n readonly capabilities: SandboxCapabilities = {\n filesystem: true,\n execution: true,\n persistence: true,\n };\n\n private sandboxes = new Map<string, InMemorySandboxImpl>();\n\n constructor(private defaultOptions?: InMemorySandboxOptions) {}\n\n async get(id: string): Promise<Sandbox> {\n const sandbox = this.sandboxes.get(id);\n if (!sandbox) throw new SandboxNotFoundError(id);\n return sandbox;\n }\n\n async destroy(id: string): Promise<void> {\n const sandbox = this.sandboxes.get(id);\n if (sandbox) {\n await sandbox.destroy();\n this.sandboxes.delete(id);\n }\n }\n\n async pause(_sandboxId: string, _ttlSeconds?: number): Promise<void> {\n // In-memory: nothing to pause\n }\n\n async create(options?: SandboxCreateOptions): Promise<SandboxCreateResult> {\n const id = options?.id ?? getShortId();\n const initialFiles: InitialFiles = {};\n\n if (options?.initialFiles) {\n for (const [path, content] of Object.entries(options.initialFiles)) {\n initialFiles[path] = content;\n }\n }\n\n const fs = new InMemoryFs(initialFiles);\n const sandbox = new InMemorySandboxImpl(id, fs, this.defaultOptions);\n this.sandboxes.set(id, sandbox);\n return { sandbox };\n }\n\n async snapshot(sandboxId: string): Promise<SandboxSnapshot> {\n const sandbox = this.sandboxes.get(sandboxId);\n if (!sandbox) throw new SandboxNotFoundError(sandboxId);\n\n const fs = sandbox._getJustBashFs();\n const paths = fs.getAllPaths();\n const files: Record<string, string> = {};\n\n for (const p of paths) {\n try {\n const stat = await fs.stat(p);\n if (stat.isFile) {\n files[p] = await fs.readFile(p);\n }\n } catch {\n // skip entries that can't be read (e.g. broken symlinks)\n }\n }\n\n return {\n sandboxId,\n providerId: this.id,\n data: { files },\n createdAt: new Date().toISOString(),\n };\n }\n\n async fork(sandboxId: string): Promise<Sandbox> {\n const sandbox = await this.get(sandboxId);\n\n const entries = await sandbox.fs.readdirWithFileTypes(\"/\");\n const initialFiles: Record<string, Uint8Array> = {};\n for (const entry of entries) {\n if (entry.isFile) {\n initialFiles[entry.name] = await sandbox.fs.readFileBuffer(entry.name);\n }\n }\n\n const newSandbox = await this.create({\n id: getShortId(),\n initialFiles,\n });\n return newSandbox.sandbox;\n }\n\n async restore(snapshot: SandboxSnapshot): Promise<Sandbox> {\n const { files } = snapshot.data as { files: Record<string, string> };\n const initialFiles: InitialFiles = {};\n for (const [path, content] of Object.entries(files)) {\n initialFiles[path] = content;\n }\n\n const fs = new InMemoryFs(initialFiles);\n const sandbox = new InMemorySandboxImpl(\n snapshot.sandboxId,\n fs,\n this.defaultOptions\n );\n this.sandboxes.set(sandbox.id, sandbox);\n return sandbox;\n }\n}\n"]}
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var workflow = require('@temporalio/workflow');
4
+
5
+ // src/adapters/sandbox/inmemory/proxy.ts
6
+ var ADAPTER_PREFIX = "inMemory";
7
+ function proxyInMemorySandboxOps(scope, options) {
8
+ const resolvedScope = scope ?? workflow.workflowInfo().workflowType;
9
+ const acts = workflow.proxyActivities(
10
+ options ?? {
11
+ startToCloseTimeout: "30s",
12
+ retry: {
13
+ maximumAttempts: 3,
14
+ initialInterval: "2s",
15
+ maximumInterval: "30s",
16
+ backoffCoefficient: 2
17
+ }
18
+ }
19
+ );
20
+ const prefix = `${ADAPTER_PREFIX}${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;
21
+ const p = (key) => `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;
22
+ return {
23
+ createSandbox: acts[p("createSandbox")],
24
+ destroySandbox: acts[p("destroySandbox")],
25
+ pauseSandbox: acts[p("pauseSandbox")],
26
+ snapshotSandbox: acts[p("snapshotSandbox")],
27
+ forkSandbox: acts[p("forkSandbox")]
28
+ };
29
+ }
30
+
31
+ exports.proxyInMemorySandboxOps = proxyInMemorySandboxOps;
32
+ //# sourceMappingURL=workflow.cjs.map
33
+ //# sourceMappingURL=workflow.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/adapters/sandbox/inmemory/proxy.ts"],"names":["workflowInfo","proxyActivities"],"mappings":";;;;;AAoBA,IAAM,cAAA,GAAiB,UAAA;AAEhB,SAAS,uBAAA,CACd,OACA,OAAA,EACY;AACZ,EAAA,MAAM,aAAA,GAAgB,KAAA,IAASA,qBAAA,EAAa,CAAE,YAAA;AAG9C,EAAA,MAAM,IAAA,GAAOC,wBAAA;AAAA,IACX,OAAA,IAAW;AAAA,MACT,mBAAA,EAAqB,KAAA;AAAA,MACrB,KAAA,EAAO;AAAA,QACL,eAAA,EAAiB,CAAA;AAAA,QACjB,eAAA,EAAiB,IAAA;AAAA,QACjB,eAAA,EAAiB,KAAA;AAAA,QACjB,kBAAA,EAAoB;AAAA;AACtB;AACF,GACF;AAEA,EAAA,MAAM,MAAA,GAAS,CAAA,EAAG,cAAc,CAAA,EAAG,cAAc,MAAA,CAAO,CAAC,CAAA,CAAE,WAAA,EAAa,CAAA,EAAG,aAAA,CAAc,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AACjG,EAAA,MAAM,IAAI,CAAC,GAAA,KACT,CAAA,EAAG,MAAM,GAAG,GAAA,CAAI,MAAA,CAAO,CAAC,CAAA,CAAE,aAAa,CAAA,EAAG,GAAA,CAAI,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAExD,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,IAAA,CAAK,CAAA,CAAE,eAAe,CAAC,CAAA;AAAA,IACtC,cAAA,EAAgB,IAAA,CAAK,CAAA,CAAE,gBAAgB,CAAC,CAAA;AAAA,IACxC,YAAA,EAAc,IAAA,CAAK,CAAA,CAAE,cAAc,CAAC,CAAA;AAAA,IACpC,eAAA,EAAiB,IAAA,CAAK,CAAA,CAAE,iBAAiB,CAAC,CAAA;AAAA,IAC1C,WAAA,EAAa,IAAA,CAAK,CAAA,CAAE,aAAa,CAAC;AAAA,GACpC;AACF","file":"workflow.cjs","sourcesContent":["/**\n * Workflow-safe proxy for in-memory sandbox operations.\n *\n * Import this from `zeitlich/adapters/sandbox/inmemory/workflow`\n * in your Temporal workflow files.\n *\n * By default the scope is derived from `workflowInfo().workflowType`,\n * so activities are automatically namespaced per workflow.\n *\n * @example\n * ```typescript\n * import { proxyInMemorySandboxOps } from 'zeitlich/adapters/sandbox/inmemory/workflow';\n *\n * // Auto-scoped to the current workflow name\n * const sandbox = proxyInMemorySandboxOps();\n * ```\n */\nimport { proxyActivities, workflowInfo } from \"@temporalio/workflow\";\nimport type { SandboxOps } from \"../../../lib/sandbox/types\";\n\nconst ADAPTER_PREFIX = \"inMemory\";\n\nexport function proxyInMemorySandboxOps(\n scope?: string,\n options?: Parameters<typeof proxyActivities>[0]\n): SandboxOps {\n const resolvedScope = scope ?? workflowInfo().workflowType;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const acts = proxyActivities<Record<string, (...args: any[]) => any>>(\n options ?? {\n startToCloseTimeout: \"30s\",\n retry: {\n maximumAttempts: 3,\n initialInterval: \"2s\",\n maximumInterval: \"30s\",\n backoffCoefficient: 2,\n },\n }\n );\n\n const prefix = `${ADAPTER_PREFIX}${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;\n const p = (key: string): string =>\n `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;\n\n return {\n createSandbox: acts[p(\"createSandbox\")],\n destroySandbox: acts[p(\"destroySandbox\")],\n pauseSandbox: acts[p(\"pauseSandbox\")],\n snapshotSandbox: acts[p(\"snapshotSandbox\")],\n forkSandbox: acts[p(\"forkSandbox\")],\n } as SandboxOps;\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import { proxyActivities } from '@temporalio/workflow';
2
+ import { g as SandboxOps } from '../../../types-ChAMwU3q.cjs';
3
+ import '@temporalio/common';
4
+
5
+ /**
6
+ * Workflow-safe proxy for in-memory sandbox operations.
7
+ *
8
+ * Import this from `zeitlich/adapters/sandbox/inmemory/workflow`
9
+ * in your Temporal workflow files.
10
+ *
11
+ * By default the scope is derived from `workflowInfo().workflowType`,
12
+ * so activities are automatically namespaced per workflow.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { proxyInMemorySandboxOps } from 'zeitlich/adapters/sandbox/inmemory/workflow';
17
+ *
18
+ * // Auto-scoped to the current workflow name
19
+ * const sandbox = proxyInMemorySandboxOps();
20
+ * ```
21
+ */
22
+
23
+ declare function proxyInMemorySandboxOps(scope?: string, options?: Parameters<typeof proxyActivities>[0]): SandboxOps;
24
+
25
+ export { proxyInMemorySandboxOps };
@@ -0,0 +1,25 @@
1
+ import { proxyActivities } from '@temporalio/workflow';
2
+ import { g as SandboxOps } from '../../../types-ChAMwU3q.js';
3
+ import '@temporalio/common';
4
+
5
+ /**
6
+ * Workflow-safe proxy for in-memory sandbox operations.
7
+ *
8
+ * Import this from `zeitlich/adapters/sandbox/inmemory/workflow`
9
+ * in your Temporal workflow files.
10
+ *
11
+ * By default the scope is derived from `workflowInfo().workflowType`,
12
+ * so activities are automatically namespaced per workflow.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { proxyInMemorySandboxOps } from 'zeitlich/adapters/sandbox/inmemory/workflow';
17
+ *
18
+ * // Auto-scoped to the current workflow name
19
+ * const sandbox = proxyInMemorySandboxOps();
20
+ * ```
21
+ */
22
+
23
+ declare function proxyInMemorySandboxOps(scope?: string, options?: Parameters<typeof proxyActivities>[0]): SandboxOps;
24
+
25
+ export { proxyInMemorySandboxOps };
@@ -0,0 +1,31 @@
1
+ import { workflowInfo, proxyActivities } from '@temporalio/workflow';
2
+
3
+ // src/adapters/sandbox/inmemory/proxy.ts
4
+ var ADAPTER_PREFIX = "inMemory";
5
+ function proxyInMemorySandboxOps(scope, options) {
6
+ const resolvedScope = scope ?? workflowInfo().workflowType;
7
+ const acts = proxyActivities(
8
+ options ?? {
9
+ startToCloseTimeout: "30s",
10
+ retry: {
11
+ maximumAttempts: 3,
12
+ initialInterval: "2s",
13
+ maximumInterval: "30s",
14
+ backoffCoefficient: 2
15
+ }
16
+ }
17
+ );
18
+ const prefix = `${ADAPTER_PREFIX}${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;
19
+ const p = (key) => `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;
20
+ return {
21
+ createSandbox: acts[p("createSandbox")],
22
+ destroySandbox: acts[p("destroySandbox")],
23
+ pauseSandbox: acts[p("pauseSandbox")],
24
+ snapshotSandbox: acts[p("snapshotSandbox")],
25
+ forkSandbox: acts[p("forkSandbox")]
26
+ };
27
+ }
28
+
29
+ export { proxyInMemorySandboxOps };
30
+ //# sourceMappingURL=workflow.js.map
31
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/adapters/sandbox/inmemory/proxy.ts"],"names":[],"mappings":";;;AAoBA,IAAM,cAAA,GAAiB,UAAA;AAEhB,SAAS,uBAAA,CACd,OACA,OAAA,EACY;AACZ,EAAA,MAAM,aAAA,GAAgB,KAAA,IAAS,YAAA,EAAa,CAAE,YAAA;AAG9C,EAAA,MAAM,IAAA,GAAO,eAAA;AAAA,IACX,OAAA,IAAW;AAAA,MACT,mBAAA,EAAqB,KAAA;AAAA,MACrB,KAAA,EAAO;AAAA,QACL,eAAA,EAAiB,CAAA;AAAA,QACjB,eAAA,EAAiB,IAAA;AAAA,QACjB,eAAA,EAAiB,KAAA;AAAA,QACjB,kBAAA,EAAoB;AAAA;AACtB;AACF,GACF;AAEA,EAAA,MAAM,MAAA,GAAS,CAAA,EAAG,cAAc,CAAA,EAAG,cAAc,MAAA,CAAO,CAAC,CAAA,CAAE,WAAA,EAAa,CAAA,EAAG,aAAA,CAAc,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AACjG,EAAA,MAAM,IAAI,CAAC,GAAA,KACT,CAAA,EAAG,MAAM,GAAG,GAAA,CAAI,MAAA,CAAO,CAAC,CAAA,CAAE,aAAa,CAAA,EAAG,GAAA,CAAI,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAExD,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,IAAA,CAAK,CAAA,CAAE,eAAe,CAAC,CAAA;AAAA,IACtC,cAAA,EAAgB,IAAA,CAAK,CAAA,CAAE,gBAAgB,CAAC,CAAA;AAAA,IACxC,YAAA,EAAc,IAAA,CAAK,CAAA,CAAE,cAAc,CAAC,CAAA;AAAA,IACpC,eAAA,EAAiB,IAAA,CAAK,CAAA,CAAE,iBAAiB,CAAC,CAAA;AAAA,IAC1C,WAAA,EAAa,IAAA,CAAK,CAAA,CAAE,aAAa,CAAC;AAAA,GACpC;AACF","file":"workflow.js","sourcesContent":["/**\n * Workflow-safe proxy for in-memory sandbox operations.\n *\n * Import this from `zeitlich/adapters/sandbox/inmemory/workflow`\n * in your Temporal workflow files.\n *\n * By default the scope is derived from `workflowInfo().workflowType`,\n * so activities are automatically namespaced per workflow.\n *\n * @example\n * ```typescript\n * import { proxyInMemorySandboxOps } from 'zeitlich/adapters/sandbox/inmemory/workflow';\n *\n * // Auto-scoped to the current workflow name\n * const sandbox = proxyInMemorySandboxOps();\n * ```\n */\nimport { proxyActivities, workflowInfo } from \"@temporalio/workflow\";\nimport type { SandboxOps } from \"../../../lib/sandbox/types\";\n\nconst ADAPTER_PREFIX = \"inMemory\";\n\nexport function proxyInMemorySandboxOps(\n scope?: string,\n options?: Parameters<typeof proxyActivities>[0]\n): SandboxOps {\n const resolvedScope = scope ?? workflowInfo().workflowType;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const acts = proxyActivities<Record<string, (...args: any[]) => any>>(\n options ?? {\n startToCloseTimeout: \"30s\",\n retry: {\n maximumAttempts: 3,\n initialInterval: \"2s\",\n maximumInterval: \"30s\",\n backoffCoefficient: 2,\n },\n }\n );\n\n const prefix = `${ADAPTER_PREFIX}${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;\n const p = (key: string): string =>\n `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;\n\n return {\n createSandbox: acts[p(\"createSandbox\")],\n destroySandbox: acts[p(\"destroySandbox\")],\n pauseSandbox: acts[p(\"pauseSandbox\")],\n snapshotSandbox: acts[p(\"snapshotSandbox\")],\n forkSandbox: acts[p(\"forkSandbox\")],\n } as SandboxOps;\n}\n"]}
@@ -63,12 +63,12 @@ var VirtualSandboxFileSystem = class {
63
63
  async readFile(path) {
64
64
  const entry = this.entries.get(normalisePath(path, this.workspaceBase));
65
65
  if (!entry) throw new Error(`ENOENT: no such file: ${path}`);
66
- return this.resolver.readFile(entry.id, this.ctx);
66
+ return this.resolver.readFile(entry.id, this.ctx, entry.metadata);
67
67
  }
68
68
  async readFileBuffer(path) {
69
69
  const entry = this.entries.get(normalisePath(path, this.workspaceBase));
70
70
  if (!entry) throw new Error(`ENOENT: no such file: ${path}`);
71
- return this.resolver.readFileBuffer(entry.id, this.ctx);
71
+ return this.resolver.readFileBuffer(entry.id, this.ctx, entry.metadata);
72
72
  }
73
73
  // --------------------------------------------------------------------------
74
74
  // Metadata operations — pure, resolved from the tree
@@ -141,7 +141,12 @@ var VirtualSandboxFileSystem = class {
141
141
  const norm = normalisePath(path, this.workspaceBase);
142
142
  const existing = this.entries.get(norm);
143
143
  if (existing) {
144
- await this.resolver.writeFile(existing.id, content, this.ctx);
144
+ await this.resolver.writeFile(
145
+ existing.id,
146
+ content,
147
+ this.ctx,
148
+ existing.metadata
149
+ );
145
150
  const size = typeof content === "string" ? new TextEncoder().encode(content).byteLength : content.byteLength;
146
151
  const updated = {
147
152
  ...existing,
@@ -164,9 +169,18 @@ var VirtualSandboxFileSystem = class {
164
169
  if (!existing) {
165
170
  return this.writeFile(path, content);
166
171
  }
167
- const current = await this.resolver.readFile(existing.id, this.ctx);
172
+ const current = await this.resolver.readFile(
173
+ existing.id,
174
+ this.ctx,
175
+ existing.metadata
176
+ );
168
177
  const appended = typeof content === "string" ? current + content : current + new TextDecoder().decode(content);
169
- await this.resolver.writeFile(existing.id, appended, this.ctx);
178
+ await this.resolver.writeFile(
179
+ existing.id,
180
+ appended,
181
+ this.ctx,
182
+ existing.metadata
183
+ );
170
184
  const size = new TextEncoder().encode(appended).byteLength;
171
185
  const updated = {
172
186
  ...existing,
@@ -194,7 +208,7 @@ var VirtualSandboxFileSystem = class {
194
208
  const norm = normalisePath(path, this.workspaceBase);
195
209
  const entry = this.entries.get(norm);
196
210
  if (entry) {
197
- await this.resolver.deleteFile(entry.id, this.ctx);
211
+ await this.resolver.deleteFile(entry.id, this.ctx, entry.metadata);
198
212
  this.entries.delete(norm);
199
213
  this.mutations.push({ type: "remove", path: norm });
200
214
  return;
@@ -206,7 +220,7 @@ var VirtualSandboxFileSystem = class {
206
220
  const prefix = norm === "/" ? "/" : norm + "/";
207
221
  for (const [p, e] of this.entries) {
208
222
  if (p.startsWith(prefix)) {
209
- await this.resolver.deleteFile(e.id, this.ctx);
223
+ await this.resolver.deleteFile(e.id, this.ctx, e.metadata);
210
224
  this.entries.delete(p);
211
225
  this.mutations.push({ type: "remove", path: p });
212
226
  }
@@ -226,7 +240,11 @@ var VirtualSandboxFileSystem = class {
226
240
  const normDest = normalisePath(dest, this.workspaceBase);
227
241
  const entry = this.entries.get(normSrc);
228
242
  if (entry) {
229
- const content = await this.resolver.readFile(entry.id, this.ctx);
243
+ const content = await this.resolver.readFile(
244
+ entry.id,
245
+ this.ctx,
246
+ entry.metadata
247
+ );
230
248
  await this.writeFile(normDest, content);
231
249
  return;
232
250
  }
@@ -240,7 +258,11 @@ var VirtualSandboxFileSystem = class {
240
258
  for (const [p, e] of this.entries) {
241
259
  if (p.startsWith(prefix)) {
242
260
  const relative = p.slice(normSrc.length);
243
- const content = await this.resolver.readFile(e.id, this.ctx);
261
+ const content = await this.resolver.readFile(
262
+ e.id,
263
+ this.ctx,
264
+ e.metadata
265
+ );
244
266
  await this.writeFile(normDest + relative, content);
245
267
  }
246
268
  }
@@ -325,6 +347,11 @@ var VirtualSandboxProvider = class {
325
347
  }
326
348
  async destroy() {
327
349
  }
350
+ async pause() {
351
+ }
352
+ async fork(_sandboxId) {
353
+ throw new Error("Not implemented");
354
+ }
328
355
  async snapshot() {
329
356
  throw new SandboxNotSupportedError(
330
357
  "snapshot (virtual sandbox state lives in workflow AgentState)"