zeitlich 0.2.27 → 0.2.28

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 (74) hide show
  1. package/dist/{activities-DE3_q9yq.d.ts → activities-3xj_fEJK.d.ts} +3 -3
  2. package/dist/{activities-p8PDlRIK.d.cts → activities-BzYq6jf7.d.cts} +3 -3
  3. package/dist/adapters/sandbox/e2b/index.cjs +230 -0
  4. package/dist/adapters/sandbox/e2b/index.cjs.map +1 -0
  5. package/dist/adapters/sandbox/e2b/index.d.cts +77 -0
  6. package/dist/adapters/sandbox/e2b/index.d.ts +77 -0
  7. package/dist/adapters/sandbox/e2b/index.js +227 -0
  8. package/dist/adapters/sandbox/e2b/index.js.map +1 -0
  9. package/dist/adapters/sandbox/e2b/workflow.cjs +33 -0
  10. package/dist/adapters/sandbox/e2b/workflow.cjs.map +1 -0
  11. package/dist/adapters/sandbox/e2b/workflow.d.cts +27 -0
  12. package/dist/adapters/sandbox/e2b/workflow.d.ts +27 -0
  13. package/dist/adapters/sandbox/e2b/workflow.js +31 -0
  14. package/dist/adapters/sandbox/e2b/workflow.js.map +1 -0
  15. package/dist/adapters/sandbox/virtual/index.d.cts +4 -4
  16. package/dist/adapters/sandbox/virtual/index.d.ts +4 -4
  17. package/dist/adapters/sandbox/virtual/workflow.d.cts +2 -2
  18. package/dist/adapters/sandbox/virtual/workflow.d.ts +2 -2
  19. package/dist/adapters/thread/anthropic/index.d.cts +5 -5
  20. package/dist/adapters/thread/anthropic/index.d.ts +5 -5
  21. package/dist/adapters/thread/anthropic/workflow.d.cts +5 -5
  22. package/dist/adapters/thread/anthropic/workflow.d.ts +5 -5
  23. package/dist/adapters/thread/google-genai/index.d.cts +5 -5
  24. package/dist/adapters/thread/google-genai/index.d.ts +5 -5
  25. package/dist/adapters/thread/google-genai/workflow.d.cts +5 -5
  26. package/dist/adapters/thread/google-genai/workflow.d.ts +5 -5
  27. package/dist/adapters/thread/langchain/index.cjs +22 -10
  28. package/dist/adapters/thread/langchain/index.cjs.map +1 -1
  29. package/dist/adapters/thread/langchain/index.d.cts +12 -9
  30. package/dist/adapters/thread/langchain/index.d.ts +12 -9
  31. package/dist/adapters/thread/langchain/index.js +22 -10
  32. package/dist/adapters/thread/langchain/index.js.map +1 -1
  33. package/dist/adapters/thread/langchain/workflow.d.cts +5 -5
  34. package/dist/adapters/thread/langchain/workflow.d.ts +5 -5
  35. package/dist/index.cjs +27 -16
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +8 -8
  38. package/dist/index.d.ts +8 -8
  39. package/dist/index.js +27 -16
  40. package/dist/index.js.map +1 -1
  41. package/dist/{proxy-BK1ydQt0.d.ts → proxy-7e7v8ccg.d.ts} +1 -1
  42. package/dist/{proxy-BMAsMHdp.d.cts → proxy-CsB8r0RR.d.cts} +1 -1
  43. package/dist/{queries-DwnE2bu3.d.cts → queries-DVnukByF.d.cts} +1 -1
  44. package/dist/{queries-BCgJ9Sr5.d.ts → queries-kjlvsUfz.d.ts} +1 -1
  45. package/dist/{thread-manager-Bh9x847n.d.ts → thread-manager-B5qA4v7V.d.ts} +1 -1
  46. package/dist/{thread-manager-dzaJHQEA.d.ts → thread-manager-D8C5QvLi.d.ts} +1 -1
  47. package/dist/{thread-manager-BlHua5_v.d.cts → thread-manager-DFJ3sKKU.d.cts} +1 -1
  48. package/dist/{thread-manager-Bz8txKKj.d.cts → thread-manager-DdVFl1IY.d.cts} +1 -1
  49. package/dist/{types-CIkYBoF8.d.ts → types-BZ75HpYd.d.ts} +1 -1
  50. package/dist/{types-mCVxKIZb.d.cts → types-BclYm5Ic.d.cts} +0 -4
  51. package/dist/{types-mCVxKIZb.d.ts → types-BclYm5Ic.d.ts} +0 -4
  52. package/dist/{types-DRnz-OZp.d.cts → types-BgsAwN3L.d.cts} +1 -1
  53. package/dist/{types-CvJyXDYt.d.ts → types-BtqbM1bO.d.ts} +1 -1
  54. package/dist/{types-DSOefLpY.d.cts → types-BuCEZ4dF.d.cts} +1 -1
  55. package/dist/{types-BfIQABzu.d.cts → types-HbjqzyJH.d.cts} +1 -1
  56. package/dist/{types-DFUNSYbj.d.ts → types-yU5AINiP.d.ts} +1 -1
  57. package/dist/workflow.cjs +27 -16
  58. package/dist/workflow.cjs.map +1 -1
  59. package/dist/workflow.d.cts +7 -7
  60. package/dist/workflow.d.ts +7 -7
  61. package/dist/workflow.js +27 -16
  62. package/dist/workflow.js.map +1 -1
  63. package/package.json +21 -1
  64. package/src/adapters/sandbox/e2b/proxy.ts +56 -0
  65. package/src/adapters/thread/langchain/hooks.test.ts +195 -0
  66. package/src/adapters/thread/langchain/hooks.ts +29 -12
  67. package/src/lib/.env +1 -0
  68. package/src/lib/session/session.ts +16 -5
  69. package/src/lib/subagent/handler.ts +5 -2
  70. package/src/lib/subagent/register.ts +7 -2
  71. package/src/lib/tool-router/router.ts +2 -5
  72. package/src/lib/tool-router/types.ts +0 -4
  73. package/src/tools/bash/.env +1 -0
  74. package/tsup.config.ts +3 -0
@@ -1,5 +1,5 @@
1
1
  import { proxyActivities, ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from './types-CvJyXDYt.js';
2
+ import { T as ThreadOps } from './types-BtqbM1bO.js';
3
3
 
4
4
  /**
5
5
  * Shared proxy helper for thread operations.
@@ -1,5 +1,5 @@
1
1
  import { proxyActivities, ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from './types-DSOefLpY.cjs';
2
+ import { T as ThreadOps } from './types-BuCEZ4dF.cjs';
3
3
 
4
4
  /**
5
5
  * Shared proxy helper for thread operations.
@@ -1,4 +1,4 @@
1
- import { F as FileEntry } from './types-DRnz-OZp.cjs';
1
+ import { F as FileEntry } from './types-BgsAwN3L.cjs';
2
2
 
3
3
  /**
4
4
  * Structural constraint: accepts any `AgentStateManager<T>` whose custom
@@ -1,4 +1,4 @@
1
- import { F as FileEntry } from './types-DFUNSYbj.js';
1
+ import { F as FileEntry } from './types-yU5AINiP.js';
2
2
 
3
3
  /**
4
4
  * Structural constraint: accepts any `AgentStateManager<T>` whose custom
@@ -1,6 +1,6 @@
1
1
  import Redis from 'ioredis';
2
2
  import { MessageContent, StoredMessage, BaseMessage } from '@langchain/core/messages';
3
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-CIkYBoF8.js';
3
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BZ75HpYd.js';
4
4
 
5
5
  /** SDK-native content type for LangChain human messages */
6
6
  type LangChainContent = string | MessageContent;
@@ -1,6 +1,6 @@
1
1
  import Redis from 'ioredis';
2
2
  import Anthropic from '@anthropic-ai/sdk';
3
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-CIkYBoF8.js';
3
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BZ75HpYd.js';
4
4
 
5
5
  /** SDK-native content type for Anthropic human messages */
6
6
  type AnthropicContent = string | Anthropic.Messages.ContentBlockParam[];
@@ -1,6 +1,6 @@
1
1
  import Redis from 'ioredis';
2
2
  import Anthropic from '@anthropic-ai/sdk';
3
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BfIQABzu.cjs';
3
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-HbjqzyJH.cjs';
4
4
 
5
5
  /** SDK-native content type for Anthropic human messages */
6
6
  type AnthropicContent = string | Anthropic.Messages.ContentBlockParam[];
@@ -1,6 +1,6 @@
1
1
  import Redis from 'ioredis';
2
2
  import { MessageContent, StoredMessage, BaseMessage } from '@langchain/core/messages';
3
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BfIQABzu.cjs';
3
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-HbjqzyJH.cjs';
4
4
 
5
5
  /** SDK-native content type for LangChain human messages */
6
6
  type LangChainContent = string | MessageContent;
@@ -1,5 +1,5 @@
1
1
  import Redis from 'ioredis';
2
- import { J as JsonValue } from './types-mCVxKIZb.js';
2
+ import { J as JsonValue } from './types-BclYm5Ic.js';
3
3
 
4
4
  interface ThreadManagerConfig<T> {
5
5
  redis: Redis;
@@ -116,8 +116,6 @@ interface RouterContext {
116
116
  toolCallId: string;
117
117
  toolName: string;
118
118
  sandboxId?: string;
119
- /** Sandbox state update from the provider (passed through for subagent inheritance) */
120
- sandboxStateUpdate?: Record<string, unknown>;
121
119
  }
122
120
  /**
123
121
  * A handler function for a specific tool.
@@ -185,8 +183,6 @@ interface ProcessToolCallsContext {
185
183
  turn?: number;
186
184
  /** Active sandbox ID (when a sandbox is configured for this session) */
187
185
  sandboxId?: string;
188
- /** Sandbox state update from the provider (threaded to subagent handler for inheritance) */
189
- sandboxStateUpdate?: Record<string, unknown>;
190
186
  }
191
187
  /**
192
188
  * Result from PreToolUse hook - can block or modify execution
@@ -116,8 +116,6 @@ interface RouterContext {
116
116
  toolCallId: string;
117
117
  toolName: string;
118
118
  sandboxId?: string;
119
- /** Sandbox state update from the provider (passed through for subagent inheritance) */
120
- sandboxStateUpdate?: Record<string, unknown>;
121
119
  }
122
120
  /**
123
121
  * A handler function for a specific tool.
@@ -185,8 +183,6 @@ interface ProcessToolCallsContext {
185
183
  turn?: number;
186
184
  /** Active sandbox ID (when a sandbox is configured for this session) */
187
185
  sandboxId?: string;
188
- /** Sandbox state update from the provider (threaded to subagent handler for inheritance) */
189
- sandboxStateUpdate?: Record<string, unknown>;
190
186
  }
191
187
  /**
192
188
  * Result from PreToolUse hook - can block or modify execution
@@ -1,5 +1,5 @@
1
1
  import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-ChAMwU3q.cjs';
2
- import { R as RouterContext } from './types-mCVxKIZb.cjs';
2
+ import { R as RouterContext } from './types-BclYm5Ic.cjs';
3
3
 
4
4
  /**
5
5
  * Ephemeral {@link SandboxFileSystem} backed by a {@link FileResolver}.
@@ -1,5 +1,5 @@
1
1
  import { Duration } from '@temporalio/common';
2
- import { a as ToolMap, b as ToolRouterHooks, S as SessionExitReason, J as JsonValue, T as ToolHandlerResponse, P as PreToolUseHookResult, c as PostToolUseFailureHookResult, d as RawToolCall, e as TokenUsage, B as BaseAgentState, f as RunAgentConfig, g as ToolResultConfig, h as ToolCallResultUnion, I as InferToolResults, i as JsonSerializable, j as AgentStateManager } from './types-mCVxKIZb.js';
2
+ import { a as ToolMap, b as ToolRouterHooks, S as SessionExitReason, J as JsonValue, T as ToolHandlerResponse, P as PreToolUseHookResult, c as PostToolUseFailureHookResult, d as RawToolCall, e as TokenUsage, B as BaseAgentState, f as RunAgentConfig, g as ToolResultConfig, h as ToolCallResultUnion, I as InferToolResults, i as JsonSerializable, j as AgentStateManager } from './types-BclYm5Ic.js';
3
3
  import { z } from 'zod';
4
4
  import { g as SandboxOps } from './types-ChAMwU3q.js';
5
5
  import { ActivityInterfaceFor } from '@temporalio/workflow';
@@ -1,5 +1,5 @@
1
1
  import { Duration } from '@temporalio/common';
2
- import { a as ToolMap, b as ToolRouterHooks, S as SessionExitReason, J as JsonValue, T as ToolHandlerResponse, P as PreToolUseHookResult, c as PostToolUseFailureHookResult, d as RawToolCall, e as TokenUsage, B as BaseAgentState, f as RunAgentConfig, g as ToolResultConfig, h as ToolCallResultUnion, I as InferToolResults, i as JsonSerializable, j as AgentStateManager } from './types-mCVxKIZb.cjs';
2
+ import { a as ToolMap, b as ToolRouterHooks, S as SessionExitReason, J as JsonValue, T as ToolHandlerResponse, P as PreToolUseHookResult, c as PostToolUseFailureHookResult, d as RawToolCall, e as TokenUsage, B as BaseAgentState, f as RunAgentConfig, g as ToolResultConfig, h as ToolCallResultUnion, I as InferToolResults, i as JsonSerializable, j as AgentStateManager } from './types-BclYm5Ic.cjs';
3
3
  import { z } from 'zod';
4
4
  import { g as SandboxOps } from './types-ChAMwU3q.cjs';
5
5
  import { ActivityInterfaceFor } from '@temporalio/workflow';
@@ -1,5 +1,5 @@
1
1
  import Redis from 'ioredis';
2
- import { J as JsonValue } from './types-mCVxKIZb.cjs';
2
+ import { J as JsonValue } from './types-BclYm5Ic.cjs';
3
3
 
4
4
  interface ThreadManagerConfig<T> {
5
5
  redis: Redis;
@@ -1,5 +1,5 @@
1
1
  import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-ChAMwU3q.js';
2
- import { R as RouterContext } from './types-mCVxKIZb.js';
2
+ import { R as RouterContext } from './types-BclYm5Ic.js';
3
3
 
4
4
  /**
5
5
  * Ephemeral {@link SandboxFileSystem} backed by a {@link FileResolver}.
package/dist/workflow.cjs CHANGED
@@ -113,7 +113,7 @@ function createToolRouter(options) {
113
113
  });
114
114
  }
115
115
  }
116
- async function processToolCall(toolCall, turn, sandboxId, sandboxStateUpdate) {
116
+ async function processToolCall(toolCall, turn, sandboxId) {
117
117
  const startTime = Date.now();
118
118
  const tool = toolMap.get(toolCall.name);
119
119
  const preResult = await runPreHooks(toolCall, tool, turn);
@@ -142,8 +142,7 @@ function createToolRouter(options) {
142
142
  ...options.threadKey && { threadKey: options.threadKey },
143
143
  toolCallId: toolCall.id,
144
144
  toolName: toolCall.name,
145
- ...sandboxId !== void 0 && { sandboxId },
146
- ...sandboxStateUpdate && { sandboxStateUpdate }
145
+ ...sandboxId !== void 0 && { sandboxId }
147
146
  };
148
147
  const response = await tool.handler(
149
148
  effectiveArgs,
@@ -237,10 +236,9 @@ function createToolRouter(options) {
237
236
  }
238
237
  const turn = context?.turn ?? 0;
239
238
  const sandboxId = context?.sandboxId;
240
- const sandboxStateUpdate = context?.sandboxStateUpdate;
241
239
  if (options.parallel) {
242
240
  const results2 = await Promise.all(
243
- toolCalls.map((tc) => processToolCall(tc, turn, sandboxId, sandboxStateUpdate))
241
+ toolCalls.map((tc) => processToolCall(tc, turn, sandboxId))
244
242
  );
245
243
  return results2.filter(
246
244
  (r) => r !== null
@@ -248,7 +246,7 @@ function createToolRouter(options) {
248
246
  }
249
247
  const results = [];
250
248
  for (const toolCall of toolCalls) {
251
- const result = await processToolCall(toolCall, turn, sandboxId, sandboxStateUpdate);
249
+ const result = await processToolCall(toolCall, turn, sandboxId);
252
250
  if (result !== null) {
253
251
  results.push(result);
254
252
  }
@@ -384,7 +382,7 @@ function resolveSandboxConfig(config) {
384
382
  if (config === "own") return { source: "own" };
385
383
  return { source: "own", shutdown: config.shutdown };
386
384
  }
387
- function createSubagentHandler(subagents) {
385
+ function createSubagentHandler(subagents, options) {
388
386
  const { taskQueue: parentTaskQueue } = workflow.workflowInfo();
389
387
  const childResults = /* @__PURE__ */ new Map();
390
388
  const pendingDestroys = /* @__PURE__ */ new Map();
@@ -416,10 +414,11 @@ function createSubagentHandler(subagents) {
416
414
  }
417
415
  let sandbox;
418
416
  if (sandboxCfg.source === "inherit" && parentSandboxId) {
417
+ const stateUpdate = options?.getSandboxStateForInheritance?.();
419
418
  sandbox = {
420
419
  mode: "inherit",
421
420
  sandboxId: parentSandboxId,
422
- ...context.sandboxStateUpdate && { stateUpdate: context.sandboxStateUpdate }
421
+ ...stateUpdate && { stateUpdate }
423
422
  };
424
423
  } else if (sandboxCfg.source === "own") {
425
424
  const prevSbId = continuationThreadId ? threadSandboxes.get(continuationThreadId) : void 0;
@@ -524,7 +523,7 @@ function createSubagentHandler(subagents) {
524
523
  }
525
524
 
526
525
  // src/lib/subagent/register.ts
527
- function buildSubagentRegistration(subagents) {
526
+ function buildSubagentRegistration(subagents, options) {
528
527
  if (subagents.length === 0) return null;
529
528
  const getEnabled = () => subagents.filter(
530
529
  (s) => typeof s.enabled === "function" ? s.enabled() : s.enabled ?? true
@@ -534,7 +533,9 @@ function buildSubagentRegistration(subagents) {
534
533
  if (s.hooks) subagentHooksMap.set(s.agentName, s.hooks);
535
534
  }
536
535
  const resolveSubagentName = (args) => args.subagent;
537
- const { handler, destroySubagentSandboxes } = createSubagentHandler(subagents);
536
+ const { handler, destroySubagentSandboxes } = createSubagentHandler(subagents, {
537
+ getSandboxStateForInheritance: options?.getSandboxStateForInheritance
538
+ });
538
539
  const registration = {
539
540
  name: SUBAGENT_TOOL_NAME,
540
541
  enabled: () => getEnabled().length > 0,
@@ -699,8 +700,11 @@ async function createSession({
699
700
  } = threadOps;
700
701
  const plugins = [];
701
702
  let destroySubagentSandboxes;
703
+ let sandboxStateGetter;
702
704
  if (subagents) {
703
- const result = buildSubagentRegistration(subagents);
705
+ const result = buildSubagentRegistration(subagents, {
706
+ getSandboxStateForInheritance: () => sandboxStateGetter?.()
707
+ });
704
708
  if (result) {
705
709
  plugins.push(result.registration);
706
710
  destroySubagentSandboxes = result.destroySubagentSandboxes;
@@ -756,12 +760,21 @@ async function createSession({
756
760
  const sandboxMode = sandboxInit?.mode;
757
761
  let sandboxId;
758
762
  let sandboxOwned = false;
759
- let sandboxStateUpdate;
763
+ sandboxStateGetter = () => {
764
+ const fileTree = stateManager.get("fileTree");
765
+ const resolverContext = stateManager.get("resolverContext");
766
+ const workspaceBase = stateManager.get("workspaceBase");
767
+ if (!fileTree && !resolverContext && !workspaceBase) return void 0;
768
+ return {
769
+ ...fileTree !== void 0 && { fileTree },
770
+ ...resolverContext !== void 0 && { resolverContext },
771
+ ...workspaceBase !== void 0 && { workspaceBase }
772
+ };
773
+ };
760
774
  if (sandboxMode === "inherit") {
761
775
  const inheritInit = sandboxInit;
762
776
  sandboxId = inheritInit.sandboxId;
763
777
  if (inheritInit.stateUpdate) {
764
- sandboxStateUpdate = inheritInit.stateUpdate;
765
778
  stateManager.mergeUpdate(inheritInit.stateUpdate);
766
779
  }
767
780
  if (!sandboxOps) {
@@ -798,7 +811,6 @@ async function createSession({
798
811
  sandboxId = result.sandboxId;
799
812
  sandboxOwned = true;
800
813
  if (result.stateUpdate) {
801
- sandboxStateUpdate = result.stateUpdate;
802
814
  stateManager.mergeUpdate(result.stateUpdate);
803
815
  }
804
816
  }
@@ -872,8 +884,7 @@ async function createSession({
872
884
  parsedToolCalls,
873
885
  {
874
886
  turn: currentTurn,
875
- ...sandboxId !== void 0 && { sandboxId },
876
- ...sandboxStateUpdate && { sandboxStateUpdate }
887
+ ...sandboxId !== void 0 && { sandboxId }
877
888
  }
878
889
  );
879
890
  for (const result of toolCallResults) {