zeitlich 0.2.31 → 0.2.32

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 (82) hide show
  1. package/dist/{activities-qPkJDAiq.d.cts → activities-DA-bQM12.d.cts} +2 -2
  2. package/dist/{activities-DRSdt8Y3.d.ts → activities-FIXVz7DT.d.ts} +2 -2
  3. package/dist/adapters/thread/anthropic/index.cjs +4 -48
  4. package/dist/adapters/thread/anthropic/index.cjs.map +1 -1
  5. package/dist/adapters/thread/anthropic/index.d.cts +6 -6
  6. package/dist/adapters/thread/anthropic/index.d.ts +6 -6
  7. package/dist/adapters/thread/anthropic/index.js +4 -48
  8. package/dist/adapters/thread/anthropic/index.js.map +1 -1
  9. package/dist/adapters/thread/anthropic/workflow.cjs +1 -0
  10. package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -1
  11. package/dist/adapters/thread/anthropic/workflow.d.cts +4 -4
  12. package/dist/adapters/thread/anthropic/workflow.d.ts +4 -4
  13. package/dist/adapters/thread/anthropic/workflow.js +1 -0
  14. package/dist/adapters/thread/anthropic/workflow.js.map +1 -1
  15. package/dist/adapters/thread/google-genai/index.cjs +8 -48
  16. package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
  17. package/dist/adapters/thread/google-genai/index.d.cts +6 -6
  18. package/dist/adapters/thread/google-genai/index.d.ts +6 -6
  19. package/dist/adapters/thread/google-genai/index.js +8 -48
  20. package/dist/adapters/thread/google-genai/index.js.map +1 -1
  21. package/dist/adapters/thread/google-genai/workflow.cjs +1 -0
  22. package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
  23. package/dist/adapters/thread/google-genai/workflow.d.cts +4 -4
  24. package/dist/adapters/thread/google-genai/workflow.d.ts +4 -4
  25. package/dist/adapters/thread/google-genai/workflow.js +1 -0
  26. package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
  27. package/dist/adapters/thread/langchain/index.cjs +5 -1
  28. package/dist/adapters/thread/langchain/index.cjs.map +1 -1
  29. package/dist/adapters/thread/langchain/index.d.cts +6 -5
  30. package/dist/adapters/thread/langchain/index.d.ts +6 -5
  31. package/dist/adapters/thread/langchain/index.js +5 -1
  32. package/dist/adapters/thread/langchain/index.js.map +1 -1
  33. package/dist/adapters/thread/langchain/workflow.cjs +1 -0
  34. package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
  35. package/dist/adapters/thread/langchain/workflow.d.cts +4 -4
  36. package/dist/adapters/thread/langchain/workflow.d.ts +4 -4
  37. package/dist/adapters/thread/langchain/workflow.js +1 -0
  38. package/dist/adapters/thread/langchain/workflow.js.map +1 -1
  39. package/dist/index.cjs +8 -5
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +6 -6
  42. package/dist/index.d.ts +6 -6
  43. package/dist/index.js +8 -5
  44. package/dist/index.js.map +1 -1
  45. package/dist/{proxy-BkvkV2oU.d.ts → proxy-Br4unLTC.d.ts} +1 -1
  46. package/dist/{proxy-BDQ3Rj6R.d.cts → proxy-CTCYWjkr.d.cts} +1 -1
  47. package/dist/{thread-manager-BLgvv9Gf.d.cts → thread-manager-CUubPYPH.d.cts} +1 -1
  48. package/dist/{thread-manager-DowU4ntB.d.cts → thread-manager-Cv_BR28i.d.cts} +1 -1
  49. package/dist/{thread-manager-Cv82H1wi.d.ts → thread-manager-DKWxHUzD.d.ts} +1 -1
  50. package/dist/{thread-manager-HsAYkyAV.d.ts → thread-manager-YJLoc1vH.d.ts} +1 -1
  51. package/dist/{types-CjeGWQm1.d.cts → types-Bpq5fDI5.d.cts} +7 -4
  52. package/dist/{types-D6UKZZtj.d.ts → types-BxiT8w9d.d.ts} +1 -1
  53. package/dist/{types-BmS-Huc0.d.ts → types-CheCTLeV.d.ts} +7 -4
  54. package/dist/{types-e_38QaKo.d.cts → types-NJDyMyUx.d.cts} +1 -1
  55. package/dist/{workflow-CNshfqSO.d.cts → workflow-BWKQcz9d.d.cts} +1 -1
  56. package/dist/{workflow-CTcrPZAV.d.ts → workflow-D8wK7TJY.d.ts} +1 -1
  57. package/dist/workflow.cjs +4 -1
  58. package/dist/workflow.cjs.map +1 -1
  59. package/dist/workflow.d.cts +2 -2
  60. package/dist/workflow.d.ts +2 -2
  61. package/dist/workflow.js +4 -1
  62. package/dist/workflow.js.map +1 -1
  63. package/package.json +1 -1
  64. package/src/adapters/thread/anthropic/activities.ts +10 -0
  65. package/src/adapters/thread/anthropic/model-invoker.ts +2 -5
  66. package/src/adapters/thread/google-genai/activities.ts +14 -0
  67. package/src/adapters/thread/google-genai/model-invoker.ts +2 -5
  68. package/src/adapters/thread/langchain/activities.ts +11 -0
  69. package/src/adapters/thread/langchain/model-invoker.ts +2 -3
  70. package/src/lib/.env +1 -0
  71. package/src/lib/model/types.ts +3 -2
  72. package/src/lib/session/session-edge-cases.integration.test.ts +6 -0
  73. package/src/lib/session/session.integration.test.ts +3 -0
  74. package/src/lib/session/session.ts +4 -0
  75. package/src/lib/session/types.ts +7 -0
  76. package/src/lib/thread/proxy.ts +1 -0
  77. package/src/lib/types.ts +1 -0
  78. package/src/lib/virtual-fs/manager.ts +3 -3
  79. package/src/lib/virtual-fs/proxy.ts +3 -3
  80. package/src/lib/virtual-fs/types.ts +1 -2
  81. package/src/lib/virtual-fs/with-virtual-fs.ts +4 -4
  82. package/src/tools/bash/.env +1 -0
@@ -1,5 +1,5 @@
1
1
  import { proxyActivities, ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from './types-BmS-Huc0.js';
2
+ import { T as ThreadOps } from './types-CheCTLeV.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-CjeGWQm1.cjs';
2
+ import { T as ThreadOps } from './types-Bpq5fDI5.cjs';
3
3
 
4
4
  /**
5
5
  * Shared proxy helper for thread operations.
@@ -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-e_38QaKo.cjs';
3
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-NJDyMyUx.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-e_38QaKo.cjs';
3
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-NJDyMyUx.cjs';
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 { MessageContent, StoredMessage, BaseMessage } from '@langchain/core/messages';
3
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-D6UKZZtj.js';
3
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BxiT8w9d.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-D6UKZZtj.js';
3
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BxiT8w9d.js';
4
4
 
5
5
  /** SDK-native content type for Anthropic human messages */
6
6
  type AnthropicContent = string | Anthropic.Messages.ContentBlockParam[];
@@ -578,8 +578,7 @@ type PrefixedVirtualFsOps<TPrefix extends string, TCtx = unknown, TMeta = FileEn
578
578
  */
579
579
  interface VirtualFsState<TCtx = unknown, TMeta = FileEntryMetadata> {
580
580
  fileTree: FileEntry<TMeta>[];
581
- ctx: TCtx;
582
- workspaceBase?: string;
581
+ virtualFsCtx: TCtx;
583
582
  /** In-memory file contents keyed by path, bypassing the resolver (e.g. skill resources). */
584
583
  inlineFiles?: Record<string, string>;
585
584
  }
@@ -608,6 +607,7 @@ interface BaseAgentState {
608
607
  fileTree: FileEntry[];
609
608
  /** In-memory file contents keyed by path, bypassing the resolver (e.g. skill resources). */
610
609
  inlineFiles?: Record<string, string>;
610
+ virtualFsCtx?: unknown;
611
611
  systemPrompt?: string;
612
612
  totalInputTokens: number;
613
613
  totalOutputTokens: number;
@@ -1055,8 +1055,9 @@ interface ModelInvokerConfig {
1055
1055
  }
1056
1056
  /**
1057
1057
  * Generic model invocation contract.
1058
- * Implementations load the thread, call the LLM, append the response,
1059
- * and return a normalised AgentResponse.
1058
+ * Implementations load the thread, call the LLM, and return a normalised
1059
+ * AgentResponse. The caller (workflow) is responsible for appending the
1060
+ * response to the thread with a deterministic ID.
1060
1061
  *
1061
1062
  * Framework adapters (e.g. `zeitlich/langchain`) provide concrete
1062
1063
  * implementations of this type.
@@ -1078,6 +1079,8 @@ interface ThreadOps<TContent = string> {
1078
1079
  appendHumanMessage(threadId: string, id: string, content: TContent, threadKey?: string): Promise<void>;
1079
1080
  /** Append a tool result to the thread */
1080
1081
  appendToolResult(id: string, config: ToolResultConfig): Promise<void>;
1082
+ /** Append the model's response to the thread */
1083
+ appendAgentMessage(threadId: string, id: string, message: unknown, threadKey?: string): Promise<void>;
1081
1084
  /** Append a system message to the thread */
1082
1085
  appendSystemMessage(threadId: string, id: string, content: string, threadKey?: string): Promise<void>;
1083
1086
  /** Copy all messages from sourceThreadId into a new thread at targetThreadId */
@@ -1,5 +1,5 @@
1
1
  import Redis from 'ioredis';
2
- import { J as JsonValue } from './types-BmS-Huc0.js';
2
+ import { J as JsonValue } from './types-CheCTLeV.js';
3
3
 
4
4
  interface ThreadManagerConfig<T> {
5
5
  redis: Redis;
@@ -578,8 +578,7 @@ type PrefixedVirtualFsOps<TPrefix extends string, TCtx = unknown, TMeta = FileEn
578
578
  */
579
579
  interface VirtualFsState<TCtx = unknown, TMeta = FileEntryMetadata> {
580
580
  fileTree: FileEntry<TMeta>[];
581
- ctx: TCtx;
582
- workspaceBase?: string;
581
+ virtualFsCtx: TCtx;
583
582
  /** In-memory file contents keyed by path, bypassing the resolver (e.g. skill resources). */
584
583
  inlineFiles?: Record<string, string>;
585
584
  }
@@ -608,6 +607,7 @@ interface BaseAgentState {
608
607
  fileTree: FileEntry[];
609
608
  /** In-memory file contents keyed by path, bypassing the resolver (e.g. skill resources). */
610
609
  inlineFiles?: Record<string, string>;
610
+ virtualFsCtx?: unknown;
611
611
  systemPrompt?: string;
612
612
  totalInputTokens: number;
613
613
  totalOutputTokens: number;
@@ -1055,8 +1055,9 @@ interface ModelInvokerConfig {
1055
1055
  }
1056
1056
  /**
1057
1057
  * Generic model invocation contract.
1058
- * Implementations load the thread, call the LLM, append the response,
1059
- * and return a normalised AgentResponse.
1058
+ * Implementations load the thread, call the LLM, and return a normalised
1059
+ * AgentResponse. The caller (workflow) is responsible for appending the
1060
+ * response to the thread with a deterministic ID.
1060
1061
  *
1061
1062
  * Framework adapters (e.g. `zeitlich/langchain`) provide concrete
1062
1063
  * implementations of this type.
@@ -1078,6 +1079,8 @@ interface ThreadOps<TContent = string> {
1078
1079
  appendHumanMessage(threadId: string, id: string, content: TContent, threadKey?: string): Promise<void>;
1079
1080
  /** Append a tool result to the thread */
1080
1081
  appendToolResult(id: string, config: ToolResultConfig): Promise<void>;
1082
+ /** Append the model's response to the thread */
1083
+ appendAgentMessage(threadId: string, id: string, message: unknown, threadKey?: string): Promise<void>;
1081
1084
  /** Append a system message to the thread */
1082
1085
  appendSystemMessage(threadId: string, id: string, content: string, threadKey?: string): Promise<void>;
1083
1086
  /** Copy all messages from sourceThreadId into a new thread at targetThreadId */
@@ -1,5 +1,5 @@
1
1
  import Redis from 'ioredis';
2
- import { J as JsonValue } from './types-CjeGWQm1.cjs';
2
+ import { J as JsonValue } from './types-Bpq5fDI5.cjs';
3
3
 
4
4
  interface ThreadManagerConfig<T> {
5
5
  redis: Redis;
@@ -1,4 +1,4 @@
1
- import { ao as ToolMap, _ as SessionConfig, az as ZeitlichSession, Y as SandboxShutdown, ag as ThreadInit, X as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aB as ToolRouterOptions, ar as ToolRouter, R as RouterContext, J as JsonValue, at as ToolWithHandler, v as ParsedToolCallUnion, ap as ToolNames, a6 as SubagentDefinition, a9 as SubagentHooks, aa as SubagentSandboxConfig, a5 as SubagentConfig, ab as SubagentSandboxShutdown, ac as SubagentSessionInput, a7 as SubagentFnResult, a3 as SessionStartHook, $ as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a1 as SessionExitReason, ah as TokenUsage, F as FileEntryMetadata, av as VirtualFileTree, j as TreeMutation, r as FileEntry, aw as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, am as ToolHandler, ay as WorkflowTask, c as ActivityToolHandler } from './types-CjeGWQm1.cjs';
1
+ import { ao as ToolMap, _ as SessionConfig, az as ZeitlichSession, Y as SandboxShutdown, ag as ThreadInit, X as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aB as ToolRouterOptions, ar as ToolRouter, R as RouterContext, J as JsonValue, at as ToolWithHandler, v as ParsedToolCallUnion, ap as ToolNames, a6 as SubagentDefinition, a9 as SubagentHooks, aa as SubagentSandboxConfig, a5 as SubagentConfig, ab as SubagentSandboxShutdown, ac as SubagentSessionInput, a7 as SubagentFnResult, a3 as SessionStartHook, $ as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a1 as SessionExitReason, ah as TokenUsage, F as FileEntryMetadata, av as VirtualFileTree, j as TreeMutation, r as FileEntry, aw as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, am as ToolHandler, ay as WorkflowTask, c as ActivityToolHandler } from './types-Bpq5fDI5.cjs';
2
2
  import { g as SandboxOps } from './types-AujBIMMn.cjs';
3
3
  import z$1, { z } from 'zod';
4
4
  import { Sinks, proxyActivities } from '@temporalio/workflow';
@@ -1,4 +1,4 @@
1
- import { ao as ToolMap, _ as SessionConfig, az as ZeitlichSession, Y as SandboxShutdown, ag as ThreadInit, X as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aB as ToolRouterOptions, ar as ToolRouter, R as RouterContext, J as JsonValue, at as ToolWithHandler, v as ParsedToolCallUnion, ap as ToolNames, a6 as SubagentDefinition, a9 as SubagentHooks, aa as SubagentSandboxConfig, a5 as SubagentConfig, ab as SubagentSandboxShutdown, ac as SubagentSessionInput, a7 as SubagentFnResult, a3 as SessionStartHook, $ as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a1 as SessionExitReason, ah as TokenUsage, F as FileEntryMetadata, av as VirtualFileTree, j as TreeMutation, r as FileEntry, aw as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, am as ToolHandler, ay as WorkflowTask, c as ActivityToolHandler } from './types-BmS-Huc0.js';
1
+ import { ao as ToolMap, _ as SessionConfig, az as ZeitlichSession, Y as SandboxShutdown, ag as ThreadInit, X as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aB as ToolRouterOptions, ar as ToolRouter, R as RouterContext, J as JsonValue, at as ToolWithHandler, v as ParsedToolCallUnion, ap as ToolNames, a6 as SubagentDefinition, a9 as SubagentHooks, aa as SubagentSandboxConfig, a5 as SubagentConfig, ab as SubagentSandboxShutdown, ac as SubagentSessionInput, a7 as SubagentFnResult, a3 as SessionStartHook, $ as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a1 as SessionExitReason, ah as TokenUsage, F as FileEntryMetadata, av as VirtualFileTree, j as TreeMutation, r as FileEntry, aw as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, am as ToolHandler, ay as WorkflowTask, c as ActivityToolHandler } from './types-CheCTLeV.js';
2
2
  import { g as SandboxOps } from './types-AujBIMMn.js';
3
3
  import z$1, { z } from 'zod';
4
4
  import { Sinks, proxyActivities } from '@temporalio/workflow';
package/dist/workflow.cjs CHANGED
@@ -731,6 +731,7 @@ async function createSession({
731
731
  appendHumanMessage,
732
732
  initializeThread,
733
733
  appendSystemMessage,
734
+ appendAgentMessage,
734
735
  forkThread
735
736
  } = threadOps;
736
737
  const plugins = [];
@@ -852,6 +853,7 @@ async function createSession({
852
853
  ] : result.fileTree;
853
854
  stateManager.mergeUpdate({
854
855
  fileTree,
856
+ virtualFsCtx: virtualFsConfig.ctx,
855
857
  ...skillFiles && { inlineFiles: skillFiles }
856
858
  });
857
859
  }
@@ -905,6 +907,7 @@ async function createSession({
905
907
  agentName,
906
908
  metadata
907
909
  });
910
+ await appendAgentMessage(threadId, workflow.uuid4(), message, threadKey);
908
911
  if (usage) {
909
912
  stateManager.updateUsage(usage);
910
913
  }
@@ -1470,7 +1473,7 @@ function proxyVirtualFsOps(scope, options) {
1470
1473
  }
1471
1474
  }
1472
1475
  );
1473
- const prefix = resolvedScope;
1476
+ const prefix = `virtualFs${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;
1474
1477
  const p = (key) => `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;
1475
1478
  return {
1476
1479
  resolveFileTree: acts[p("resolveFileTree")]