zeitlich 0.2.30 → 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 (84) hide show
  1. package/dist/{activities-BeveyY9b.d.cts → activities-DA-bQM12.d.cts} +2 -2
  2. package/dist/{activities-NT3rcw66.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 +34 -7
  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 +34 -7
  44. package/dist/index.js.map +1 -1
  45. package/dist/{proxy-BgswT47M.d.ts → proxy-Br4unLTC.d.ts} +1 -1
  46. package/dist/{proxy-OJihshQF.d.cts → proxy-CTCYWjkr.d.cts} +1 -1
  47. package/dist/{thread-manager-lfN0V-gH.d.cts → thread-manager-CUubPYPH.d.cts} +1 -1
  48. package/dist/{thread-manager-DH0zv05W.d.cts → thread-manager-Cv_BR28i.d.cts} +1 -1
  49. package/dist/{thread-manager-iUplxEZt.d.ts → thread-manager-DKWxHUzD.d.ts} +1 -1
  50. package/dist/{thread-manager-BS477gj8.d.ts → thread-manager-YJLoc1vH.d.ts} +1 -1
  51. package/dist/{types-DVdT5ybA.d.cts → types-Bpq5fDI5.d.cts} +13 -5
  52. package/dist/{types-CCIc7Eam.d.ts → types-BxiT8w9d.d.ts} +1 -1
  53. package/dist/{types-D90Q5aOh.d.ts → types-CheCTLeV.d.ts} +13 -5
  54. package/dist/{types-DgIVPOa1.d.cts → types-NJDyMyUx.d.cts} +1 -1
  55. package/dist/{workflow-Cj4DxGdM.d.cts → workflow-BWKQcz9d.d.cts} +1 -1
  56. package/dist/{workflow-CzrBdCcJ.d.ts → workflow-D8wK7TJY.d.ts} +1 -1
  57. package/dist/workflow.cjs +17 -2
  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 +17 -2
  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 +19 -1
  75. package/src/lib/session/types.ts +7 -0
  76. package/src/lib/thread/proxy.ts +1 -0
  77. package/src/lib/types.ts +3 -0
  78. package/src/lib/virtual-fs/filesystem.ts +15 -0
  79. package/src/lib/virtual-fs/manager.ts +3 -3
  80. package/src/lib/virtual-fs/proxy.ts +3 -3
  81. package/src/lib/virtual-fs/types.ts +3 -2
  82. package/src/lib/virtual-fs/virtual-fs.test.ts +64 -0
  83. package/src/lib/virtual-fs/with-virtual-fs.ts +4 -3
  84. 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-D90Q5aOh.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-DVdT5ybA.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-DgIVPOa1.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-DgIVPOa1.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-CCIc7Eam.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-CCIc7Eam.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[];
@@ -474,7 +474,8 @@ declare class VirtualFileSystem<TCtx = unknown, TMeta = FileEntryMetadata> imple
474
474
  private entries;
475
475
  private directories;
476
476
  private mutations;
477
- constructor(tree: FileEntry<TMeta>[], resolver: FileResolver<TCtx, TMeta>, ctx: TCtx, workspaceBase?: string);
477
+ private inlineFiles;
478
+ constructor(tree: FileEntry<TMeta>[], resolver: FileResolver<TCtx, TMeta>, ctx: TCtx, workspaceBase?: string, inlineFiles?: Record<string, string>);
478
479
  /** Return all mutations accumulated during this invocation. */
479
480
  getMutations(): TreeMutation<TMeta>[];
480
481
  /** Look up a file entry by virtual path. */
@@ -577,8 +578,9 @@ type PrefixedVirtualFsOps<TPrefix extends string, TCtx = unknown, TMeta = FileEn
577
578
  */
578
579
  interface VirtualFsState<TCtx = unknown, TMeta = FileEntryMetadata> {
579
580
  fileTree: FileEntry<TMeta>[];
580
- ctx: TCtx;
581
- workspaceBase?: string;
581
+ virtualFsCtx: TCtx;
582
+ /** In-memory file contents keyed by path, bypassing the resolver (e.g. skill resources). */
583
+ inlineFiles?: Record<string, string>;
582
584
  }
583
585
  /**
584
586
  * Extended router context injected by {@link withVirtualFs}.
@@ -603,6 +605,9 @@ interface BaseAgentState {
603
605
  turns: number;
604
606
  tasks: Map<string, WorkflowTask>;
605
607
  fileTree: FileEntry[];
608
+ /** In-memory file contents keyed by path, bypassing the resolver (e.g. skill resources). */
609
+ inlineFiles?: Record<string, string>;
610
+ virtualFsCtx?: unknown;
606
611
  systemPrompt?: string;
607
612
  totalInputTokens: number;
608
613
  totalOutputTokens: number;
@@ -1050,8 +1055,9 @@ interface ModelInvokerConfig {
1050
1055
  }
1051
1056
  /**
1052
1057
  * Generic model invocation contract.
1053
- * Implementations load the thread, call the LLM, append the response,
1054
- * 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.
1055
1061
  *
1056
1062
  * Framework adapters (e.g. `zeitlich/langchain`) provide concrete
1057
1063
  * implementations of this type.
@@ -1073,6 +1079,8 @@ interface ThreadOps<TContent = string> {
1073
1079
  appendHumanMessage(threadId: string, id: string, content: TContent, threadKey?: string): Promise<void>;
1074
1080
  /** Append a tool result to the thread */
1075
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>;
1076
1084
  /** Append a system message to the thread */
1077
1085
  appendSystemMessage(threadId: string, id: string, content: string, threadKey?: string): Promise<void>;
1078
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-D90Q5aOh.js';
2
+ import { J as JsonValue } from './types-CheCTLeV.js';
3
3
 
4
4
  interface ThreadManagerConfig<T> {
5
5
  redis: Redis;
@@ -474,7 +474,8 @@ declare class VirtualFileSystem<TCtx = unknown, TMeta = FileEntryMetadata> imple
474
474
  private entries;
475
475
  private directories;
476
476
  private mutations;
477
- constructor(tree: FileEntry<TMeta>[], resolver: FileResolver<TCtx, TMeta>, ctx: TCtx, workspaceBase?: string);
477
+ private inlineFiles;
478
+ constructor(tree: FileEntry<TMeta>[], resolver: FileResolver<TCtx, TMeta>, ctx: TCtx, workspaceBase?: string, inlineFiles?: Record<string, string>);
478
479
  /** Return all mutations accumulated during this invocation. */
479
480
  getMutations(): TreeMutation<TMeta>[];
480
481
  /** Look up a file entry by virtual path. */
@@ -577,8 +578,9 @@ type PrefixedVirtualFsOps<TPrefix extends string, TCtx = unknown, TMeta = FileEn
577
578
  */
578
579
  interface VirtualFsState<TCtx = unknown, TMeta = FileEntryMetadata> {
579
580
  fileTree: FileEntry<TMeta>[];
580
- ctx: TCtx;
581
- workspaceBase?: string;
581
+ virtualFsCtx: TCtx;
582
+ /** In-memory file contents keyed by path, bypassing the resolver (e.g. skill resources). */
583
+ inlineFiles?: Record<string, string>;
582
584
  }
583
585
  /**
584
586
  * Extended router context injected by {@link withVirtualFs}.
@@ -603,6 +605,9 @@ interface BaseAgentState {
603
605
  turns: number;
604
606
  tasks: Map<string, WorkflowTask>;
605
607
  fileTree: FileEntry[];
608
+ /** In-memory file contents keyed by path, bypassing the resolver (e.g. skill resources). */
609
+ inlineFiles?: Record<string, string>;
610
+ virtualFsCtx?: unknown;
606
611
  systemPrompt?: string;
607
612
  totalInputTokens: number;
608
613
  totalOutputTokens: number;
@@ -1050,8 +1055,9 @@ interface ModelInvokerConfig {
1050
1055
  }
1051
1056
  /**
1052
1057
  * Generic model invocation contract.
1053
- * Implementations load the thread, call the LLM, append the response,
1054
- * 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.
1055
1061
  *
1056
1062
  * Framework adapters (e.g. `zeitlich/langchain`) provide concrete
1057
1063
  * implementations of this type.
@@ -1073,6 +1079,8 @@ interface ThreadOps<TContent = string> {
1073
1079
  appendHumanMessage(threadId: string, id: string, content: TContent, threadKey?: string): Promise<void>;
1074
1080
  /** Append a tool result to the thread */
1075
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>;
1076
1084
  /** Append a system message to the thread */
1077
1085
  appendSystemMessage(threadId: string, id: string, content: string, threadKey?: string): Promise<void>;
1078
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-DVdT5ybA.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-DVdT5ybA.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-D90Q5aOh.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 = [];
@@ -839,8 +840,21 @@ async function createSession({
839
840
  });
840
841
  }
841
842
  const result = await virtualFsOps.resolveFileTree(virtualFsConfig.ctx);
843
+ const skillFiles = skills ? collectSkillFiles(skills) : void 0;
844
+ const fileTree = skillFiles ? [
845
+ ...result.fileTree,
846
+ ...Object.entries(skillFiles).map(([path, content]) => ({
847
+ id: `skill:${path}`,
848
+ path,
849
+ size: content.length,
850
+ mtime: (/* @__PURE__ */ new Date()).toISOString(),
851
+ metadata: {}
852
+ }))
853
+ ] : result.fileTree;
842
854
  stateManager.mergeUpdate({
843
- fileTree: result.fileTree
855
+ fileTree,
856
+ virtualFsCtx: virtualFsConfig.ctx,
857
+ ...skillFiles && { inlineFiles: skillFiles }
844
858
  });
845
859
  }
846
860
  if (hooks.onSessionStart) {
@@ -893,6 +907,7 @@ async function createSession({
893
907
  agentName,
894
908
  metadata
895
909
  });
910
+ await appendAgentMessage(threadId, workflow.uuid4(), message, threadKey);
896
911
  if (usage) {
897
912
  stateManager.updateUsage(usage);
898
913
  }
@@ -1458,7 +1473,7 @@ function proxyVirtualFsOps(scope, options) {
1458
1473
  }
1459
1474
  }
1460
1475
  );
1461
- const prefix = resolvedScope;
1476
+ const prefix = `virtualFs${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;
1462
1477
  const p = (key) => `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;
1463
1478
  return {
1464
1479
  resolveFileTree: acts[p("resolveFileTree")]