zeitlich 0.2.47 → 0.2.48

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 (50) hide show
  1. package/README.md +2 -0
  2. package/dist/{activities-CPwKoUlD.d.cts → activities-BlQR5gX4.d.cts} +3 -3
  3. package/dist/{activities-DlaBxNID.d.ts → activities-DCaIPQBT.d.ts} +3 -3
  4. package/dist/adapters/thread/anthropic/index.d.cts +5 -5
  5. package/dist/adapters/thread/anthropic/index.d.ts +5 -5
  6. package/dist/adapters/thread/anthropic/workflow.d.cts +5 -5
  7. package/dist/adapters/thread/anthropic/workflow.d.ts +5 -5
  8. package/dist/adapters/thread/google-genai/index.d.cts +5 -5
  9. package/dist/adapters/thread/google-genai/index.d.ts +5 -5
  10. package/dist/adapters/thread/google-genai/workflow.d.cts +6 -6
  11. package/dist/adapters/thread/google-genai/workflow.d.ts +6 -6
  12. package/dist/adapters/thread/langchain/index.d.cts +5 -5
  13. package/dist/adapters/thread/langchain/index.d.ts +5 -5
  14. package/dist/adapters/thread/langchain/workflow.d.cts +5 -5
  15. package/dist/adapters/thread/langchain/workflow.d.ts +5 -5
  16. package/dist/{cold-store-Z2wvK2cV.d.cts → cold-store-UL13Sstw.d.cts} +1 -1
  17. package/dist/{cold-store-BDgJpwLI.d.ts → cold-store-aD4TSKlU.d.ts} +1 -1
  18. package/dist/index.cjs +48 -10
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +8 -8
  21. package/dist/index.d.ts +8 -8
  22. package/dist/index.js +48 -10
  23. package/dist/index.js.map +1 -1
  24. package/dist/{proxy-CDh3Rsa7.d.cts → proxy-BAty3CWM.d.cts} +1 -1
  25. package/dist/{proxy-Du8ggERu.d.ts → proxy-mbnwBhHw.d.ts} +1 -1
  26. package/dist/{thread-manager-Dw96FKH1.d.ts → thread-manager-CICj68PI.d.ts} +2 -2
  27. package/dist/{thread-manager-BjoYYXgd.d.cts → thread-manager-DsXvJ5cJ.d.cts} +2 -2
  28. package/dist/{thread-manager-DtHYws2F.d.ts → thread-manager-DtEtbUkp.d.ts} +2 -2
  29. package/dist/{thread-manager-D8zKNFZ9.d.cts → thread-manager-R6c3lnJy.d.cts} +2 -2
  30. package/dist/{types-BMJrsHo0.d.cts → types-DDLPnxBh.d.cts} +1 -1
  31. package/dist/{types-CtdOquo3.d.ts → types-DF4wzWQG.d.ts} +1 -1
  32. package/dist/{types-DNEl5uxQ.d.cts → types-DWeyCTYK.d.cts} +31 -0
  33. package/dist/{types-qQVZfhoT.d.ts → types-DwBYd0ij.d.ts} +31 -0
  34. package/dist/{workflow-BH9ImDGq.d.cts → workflow-DVNPR7eX.d.cts} +1 -1
  35. package/dist/{workflow-Cdw3-RNB.d.ts → workflow-DdaU7_j4.d.ts} +1 -1
  36. package/dist/workflow.cjs +48 -10
  37. package/dist/workflow.cjs.map +1 -1
  38. package/dist/workflow.d.cts +2 -2
  39. package/dist/workflow.d.ts +2 -2
  40. package/dist/workflow.js +48 -10
  41. package/dist/workflow.js.map +1 -1
  42. package/package.json +6 -6
  43. package/src/lib/lifecycle.ts +13 -1
  44. package/src/lib/session/session-edge-cases.integration.test.ts +44 -0
  45. package/src/lib/session/session.ts +15 -0
  46. package/src/lib/subagent/handler.ts +32 -6
  47. package/src/lib/subagent/subagent.integration.test.ts +41 -2
  48. package/src/lib/tool-router/router-edge-cases.integration.test.ts +36 -0
  49. package/src/lib/tool-router/router.ts +21 -3
  50. package/src/lib/tool-router/types.ts +20 -0
package/README.md CHANGED
@@ -890,6 +890,8 @@ export const researcherSubagent = defineSubagent(researcherWorkflow, {
890
890
 
891
891
  An explicit `threadId` from the parent's tool call always wins; `newThreadSource` only applies when none is provided. The field has no effect with `thread: "new"`.
892
892
 
893
+ When `newThreadSource: "from-parent"` triggers a fork, the parent is mid-tool-call: its assistant message containing the `Subagent` tool_use has been persisted, but the matching `tool_result` hasn't (the subagent is what will produce it). A verbatim fork would leave that orphan `tool_use` at the tail of the child thread — which most model APIs reject on the next call with "unmatched tool_use". The framework handles this automatically: the child session truncates the parent's last assistant message from the forked thread before the first model invocation, so the child sees a well-formed history. No user action is required.
894
+
893
895
  The `sandbox` field accepts `"none"` (default) or an object with `source`, `continuation`, and optional `init`/`shutdown` fields:
894
896
 
895
897
  - `source: "inherit"` — use the parent's sandbox. `continuation: "continue"` shares it directly; `"fork"` forks from it on every call.
@@ -1,8 +1,8 @@
1
1
  import Redis from 'ioredis';
2
2
  import { Part, Content, GoogleGenAI } from '@google/genai';
3
- import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler } from './types-DNEl5uxQ.cjs';
4
- import { C as ColdThreadStore } from './cold-store-Z2wvK2cV.cjs';
5
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BMJrsHo0.cjs';
3
+ import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler } from './types-DWeyCTYK.cjs';
4
+ import { C as ColdThreadStore } from './cold-store-UL13Sstw.cjs';
5
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-DDLPnxBh.cjs';
6
6
  import { A as ADAPTER_ID } from './adapter-id-BB-mmrts.cjs';
7
7
 
8
8
  /** SDK-native content type for Google GenAI human messages */
@@ -1,8 +1,8 @@
1
1
  import Redis from 'ioredis';
2
2
  import { Part, Content, GoogleGenAI } from '@google/genai';
3
- import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler } from './types-qQVZfhoT.js';
4
- import { C as ColdThreadStore } from './cold-store-BDgJpwLI.js';
5
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-CtdOquo3.js';
3
+ import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler } from './types-DwBYd0ij.js';
4
+ import { C as ColdThreadStore } from './cold-store-aD4TSKlU.js';
5
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-DF4wzWQG.js';
6
6
  import { A as ADAPTER_ID } from './adapter-id-BB-mmrts.js';
7
7
 
8
8
  /** SDK-native content type for Google GenAI human messages */
@@ -2,17 +2,17 @@ import { A as ADAPTER_ID } from '../../../adapter-id-CMwVrVqv.cjs';
2
2
  export { a as AdapterId } from '../../../adapter-id-CMwVrVqv.cjs';
3
3
  import Redis from 'ioredis';
4
4
  import Anthropic from '@anthropic-ai/sdk';
5
- import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-DNEl5uxQ.cjs';
6
- import { C as ColdThreadStore } from '../../../cold-store-Z2wvK2cV.cjs';
7
- import { A as AnthropicContent, a as AnthropicThreadManagerHooks } from '../../../thread-manager-D8zKNFZ9.cjs';
8
- export { b as AnthropicInvocationPayload, c as AnthropicThreadManager, d as AnthropicThreadManagerConfig, S as StoredMessage, e as createAnthropicThreadManager } from '../../../thread-manager-D8zKNFZ9.cjs';
5
+ import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-DWeyCTYK.cjs';
6
+ import { C as ColdThreadStore } from '../../../cold-store-UL13Sstw.cjs';
7
+ import { A as AnthropicContent, a as AnthropicThreadManagerHooks } from '../../../thread-manager-R6c3lnJy.cjs';
8
+ export { b as AnthropicInvocationPayload, c as AnthropicThreadManager, d as AnthropicThreadManagerConfig, S as StoredMessage, e as createAnthropicThreadManager } from '../../../thread-manager-R6c3lnJy.cjs';
9
9
  import '@temporalio/workflow';
10
10
  import '@temporalio/common/lib/interfaces';
11
11
  import 'zod';
12
12
  import '../../../types-CJ7tCdl6.cjs';
13
13
  import '@temporalio/common';
14
14
  import '@aws-sdk/client-s3';
15
- import '../../../types-BMJrsHo0.cjs';
15
+ import '../../../types-DDLPnxBh.cjs';
16
16
 
17
17
  interface AnthropicPromptCacheOptions {
18
18
  /** TTL for the cache checkpoint. Defaults to 5m. */
@@ -2,17 +2,17 @@ import { A as ADAPTER_ID } from '../../../adapter-id-CMwVrVqv.js';
2
2
  export { a as AdapterId } from '../../../adapter-id-CMwVrVqv.js';
3
3
  import Redis from 'ioredis';
4
4
  import Anthropic from '@anthropic-ai/sdk';
5
- import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-qQVZfhoT.js';
6
- import { C as ColdThreadStore } from '../../../cold-store-BDgJpwLI.js';
7
- import { A as AnthropicContent, a as AnthropicThreadManagerHooks } from '../../../thread-manager-DtHYws2F.js';
8
- export { b as AnthropicInvocationPayload, c as AnthropicThreadManager, d as AnthropicThreadManagerConfig, S as StoredMessage, e as createAnthropicThreadManager } from '../../../thread-manager-DtHYws2F.js';
5
+ import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-DwBYd0ij.js';
6
+ import { C as ColdThreadStore } from '../../../cold-store-aD4TSKlU.js';
7
+ import { A as AnthropicContent, a as AnthropicThreadManagerHooks } from '../../../thread-manager-DtEtbUkp.js';
8
+ export { b as AnthropicInvocationPayload, c as AnthropicThreadManager, d as AnthropicThreadManagerConfig, S as StoredMessage, e as createAnthropicThreadManager } from '../../../thread-manager-DtEtbUkp.js';
9
9
  import '@temporalio/workflow';
10
10
  import '@temporalio/common/lib/interfaces';
11
11
  import 'zod';
12
12
  import '../../../types-CJ7tCdl6.js';
13
13
  import '@temporalio/common';
14
14
  import '@aws-sdk/client-s3';
15
- import '../../../types-CtdOquo3.js';
15
+ import '../../../types-DF4wzWQG.js';
16
16
 
17
17
  interface AnthropicPromptCacheOptions {
18
18
  /** TTL for the cache checkpoint. Defaults to 5m. */
@@ -1,8 +1,8 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-DNEl5uxQ.cjs';
3
- import { A as AnthropicContent } from '../../../thread-manager-D8zKNFZ9.cjs';
4
- import { c as createThreadOpsProxy } from '../../../proxy-CDh3Rsa7.cjs';
5
- export { T as ThreadOpsProxyOptions } from '../../../proxy-CDh3Rsa7.cjs';
2
+ import { T as ThreadOps } from '../../../types-DWeyCTYK.cjs';
3
+ import { A as AnthropicContent } from '../../../thread-manager-R6c3lnJy.cjs';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-BAty3CWM.cjs';
5
+ export { T as ThreadOpsProxyOptions } from '../../../proxy-BAty3CWM.cjs';
6
6
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-CMwVrVqv.cjs';
7
7
  import '@temporalio/common/lib/interfaces';
8
8
  import 'zod';
@@ -10,7 +10,7 @@ import '../../../types-CJ7tCdl6.cjs';
10
10
  import '@temporalio/common';
11
11
  import 'ioredis';
12
12
  import '@anthropic-ai/sdk';
13
- import '../../../types-BMJrsHo0.cjs';
13
+ import '../../../types-DDLPnxBh.cjs';
14
14
 
15
15
  /**
16
16
  * Workflow-safe proxy for Anthropic thread operations.
@@ -1,8 +1,8 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-qQVZfhoT.js';
3
- import { A as AnthropicContent } from '../../../thread-manager-DtHYws2F.js';
4
- import { c as createThreadOpsProxy } from '../../../proxy-Du8ggERu.js';
5
- export { T as ThreadOpsProxyOptions } from '../../../proxy-Du8ggERu.js';
2
+ import { T as ThreadOps } from '../../../types-DwBYd0ij.js';
3
+ import { A as AnthropicContent } from '../../../thread-manager-DtEtbUkp.js';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-mbnwBhHw.js';
5
+ export { T as ThreadOpsProxyOptions } from '../../../proxy-mbnwBhHw.js';
6
6
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-CMwVrVqv.js';
7
7
  import '@temporalio/common/lib/interfaces';
8
8
  import 'zod';
@@ -10,7 +10,7 @@ import '../../../types-CJ7tCdl6.js';
10
10
  import '@temporalio/common';
11
11
  import 'ioredis';
12
12
  import '@anthropic-ai/sdk';
13
- import '../../../types-CtdOquo3.js';
13
+ import '../../../types-DF4wzWQG.js';
14
14
 
15
15
  /**
16
16
  * Workflow-safe proxy for Anthropic thread operations.
@@ -1,12 +1,12 @@
1
1
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-BB-mmrts.cjs';
2
- import { G as GoogleGenAIThreadManagerHooks } from '../../../activities-CPwKoUlD.cjs';
3
- export { a as GoogleGenAIAdapter, b as GoogleGenAIAdapterConfig, c as GoogleGenAIContent, d as GoogleGenAIInvocationPayload, e as GoogleGenAIThreadManager, f as GoogleGenAIThreadManagerConfig, g as GoogleGenAIThreadOps, h as GoogleGenAIToolResponse, S as StoredContent, i as createGoogleGenAIAdapter, j as createGoogleGenAIThreadManager } from '../../../activities-CPwKoUlD.cjs';
2
+ import { G as GoogleGenAIThreadManagerHooks } from '../../../activities-BlQR5gX4.cjs';
3
+ export { a as GoogleGenAIAdapter, b as GoogleGenAIAdapterConfig, c as GoogleGenAIContent, d as GoogleGenAIInvocationPayload, e as GoogleGenAIThreadManager, f as GoogleGenAIThreadManagerConfig, g as GoogleGenAIThreadOps, h as GoogleGenAIToolResponse, S as StoredContent, i as createGoogleGenAIAdapter, j as createGoogleGenAIThreadManager } from '../../../activities-BlQR5gX4.cjs';
4
4
  import Redis from 'ioredis';
5
5
  import { GoogleGenAI, Content } from '@google/genai';
6
- import { M as ModelInvokerConfig, A as AgentResponse } from '../../../types-DNEl5uxQ.cjs';
7
- import '../../../cold-store-Z2wvK2cV.cjs';
6
+ import { M as ModelInvokerConfig, A as AgentResponse } from '../../../types-DWeyCTYK.cjs';
7
+ import '../../../cold-store-UL13Sstw.cjs';
8
8
  import '@aws-sdk/client-s3';
9
- import '../../../types-BMJrsHo0.cjs';
9
+ import '../../../types-DDLPnxBh.cjs';
10
10
  import '@temporalio/workflow';
11
11
  import '@temporalio/common/lib/interfaces';
12
12
  import 'zod';
@@ -1,12 +1,12 @@
1
1
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-BB-mmrts.js';
2
- import { G as GoogleGenAIThreadManagerHooks } from '../../../activities-DlaBxNID.js';
3
- export { a as GoogleGenAIAdapter, b as GoogleGenAIAdapterConfig, c as GoogleGenAIContent, d as GoogleGenAIInvocationPayload, e as GoogleGenAIThreadManager, f as GoogleGenAIThreadManagerConfig, g as GoogleGenAIThreadOps, h as GoogleGenAIToolResponse, S as StoredContent, i as createGoogleGenAIAdapter, j as createGoogleGenAIThreadManager } from '../../../activities-DlaBxNID.js';
2
+ import { G as GoogleGenAIThreadManagerHooks } from '../../../activities-DCaIPQBT.js';
3
+ export { a as GoogleGenAIAdapter, b as GoogleGenAIAdapterConfig, c as GoogleGenAIContent, d as GoogleGenAIInvocationPayload, e as GoogleGenAIThreadManager, f as GoogleGenAIThreadManagerConfig, g as GoogleGenAIThreadOps, h as GoogleGenAIToolResponse, S as StoredContent, i as createGoogleGenAIAdapter, j as createGoogleGenAIThreadManager } from '../../../activities-DCaIPQBT.js';
4
4
  import Redis from 'ioredis';
5
5
  import { GoogleGenAI, Content } from '@google/genai';
6
- import { M as ModelInvokerConfig, A as AgentResponse } from '../../../types-qQVZfhoT.js';
7
- import '../../../cold-store-BDgJpwLI.js';
6
+ import { M as ModelInvokerConfig, A as AgentResponse } from '../../../types-DwBYd0ij.js';
7
+ import '../../../cold-store-aD4TSKlU.js';
8
8
  import '@aws-sdk/client-s3';
9
- import '../../../types-CtdOquo3.js';
9
+ import '../../../types-DF4wzWQG.js';
10
10
  import '@temporalio/workflow';
11
11
  import '@temporalio/common/lib/interfaces';
12
12
  import 'zod';
@@ -1,8 +1,8 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-DNEl5uxQ.cjs';
3
- import { c as GoogleGenAIContent } from '../../../activities-CPwKoUlD.cjs';
4
- import { c as createThreadOpsProxy } from '../../../proxy-CDh3Rsa7.cjs';
5
- export { T as ThreadOpsProxyOptions } from '../../../proxy-CDh3Rsa7.cjs';
2
+ import { T as ThreadOps } from '../../../types-DWeyCTYK.cjs';
3
+ import { c as GoogleGenAIContent } from '../../../activities-BlQR5gX4.cjs';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-BAty3CWM.cjs';
5
+ export { T as ThreadOpsProxyOptions } from '../../../proxy-BAty3CWM.cjs';
6
6
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-BB-mmrts.cjs';
7
7
  import '@temporalio/common/lib/interfaces';
8
8
  import 'zod';
@@ -10,9 +10,9 @@ import '../../../types-CJ7tCdl6.cjs';
10
10
  import '@temporalio/common';
11
11
  import 'ioredis';
12
12
  import '@google/genai';
13
- import '../../../cold-store-Z2wvK2cV.cjs';
13
+ import '../../../cold-store-UL13Sstw.cjs';
14
14
  import '@aws-sdk/client-s3';
15
- import '../../../types-BMJrsHo0.cjs';
15
+ import '../../../types-DDLPnxBh.cjs';
16
16
 
17
17
  /**
18
18
  * Workflow-safe proxy for Google GenAI thread operations.
@@ -1,8 +1,8 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-qQVZfhoT.js';
3
- import { c as GoogleGenAIContent } from '../../../activities-DlaBxNID.js';
4
- import { c as createThreadOpsProxy } from '../../../proxy-Du8ggERu.js';
5
- export { T as ThreadOpsProxyOptions } from '../../../proxy-Du8ggERu.js';
2
+ import { T as ThreadOps } from '../../../types-DwBYd0ij.js';
3
+ import { c as GoogleGenAIContent } from '../../../activities-DCaIPQBT.js';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-mbnwBhHw.js';
5
+ export { T as ThreadOpsProxyOptions } from '../../../proxy-mbnwBhHw.js';
6
6
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-BB-mmrts.js';
7
7
  import '@temporalio/common/lib/interfaces';
8
8
  import 'zod';
@@ -10,9 +10,9 @@ import '../../../types-CJ7tCdl6.js';
10
10
  import '@temporalio/common';
11
11
  import 'ioredis';
12
12
  import '@google/genai';
13
- import '../../../cold-store-BDgJpwLI.js';
13
+ import '../../../cold-store-aD4TSKlU.js';
14
14
  import '@aws-sdk/client-s3';
15
- import '../../../types-CtdOquo3.js';
15
+ import '../../../types-DF4wzWQG.js';
16
16
 
17
17
  /**
18
18
  * Workflow-safe proxy for Google GenAI thread operations.
@@ -2,18 +2,18 @@ import { A as ADAPTER_ID } from '../../../adapter-id-CbY2zeSt.cjs';
2
2
  export { a as AdapterId } from '../../../adapter-id-CbY2zeSt.cjs';
3
3
  import Redis from 'ioredis';
4
4
  import { StoredMessage, MessageContent, BaseMessage } from '@langchain/core/messages';
5
- import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-DNEl5uxQ.cjs';
6
- import { C as ColdThreadStore } from '../../../cold-store-Z2wvK2cV.cjs';
5
+ import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-DWeyCTYK.cjs';
6
+ import { C as ColdThreadStore } from '../../../cold-store-UL13Sstw.cjs';
7
7
  import { BaseChatModel } from '@langchain/core/language_models/chat_models';
8
- import { L as LangChainContent, a as LangChainThreadManagerHooks } from '../../../thread-manager-BjoYYXgd.cjs';
9
- export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-BjoYYXgd.cjs';
8
+ import { L as LangChainContent, a as LangChainThreadManagerHooks } from '../../../thread-manager-DsXvJ5cJ.cjs';
9
+ export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-DsXvJ5cJ.cjs';
10
10
  import '@temporalio/workflow';
11
11
  import '@temporalio/common/lib/interfaces';
12
12
  import 'zod';
13
13
  import '../../../types-CJ7tCdl6.cjs';
14
14
  import '@temporalio/common';
15
15
  import '@aws-sdk/client-s3';
16
- import '../../../types-BMJrsHo0.cjs';
16
+ import '../../../types-DDLPnxBh.cjs';
17
17
 
18
18
  type LangChainThreadOps<TScope extends string = ""> = PrefixedThreadOps<ScopedPrefix<TScope, typeof ADAPTER_ID>, LangChainContent>;
19
19
  interface LangChainAdapterConfig {
@@ -2,18 +2,18 @@ import { A as ADAPTER_ID } from '../../../adapter-id-CbY2zeSt.js';
2
2
  export { a as AdapterId } from '../../../adapter-id-CbY2zeSt.js';
3
3
  import Redis from 'ioredis';
4
4
  import { StoredMessage, MessageContent, BaseMessage } from '@langchain/core/messages';
5
- import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-qQVZfhoT.js';
6
- import { C as ColdThreadStore } from '../../../cold-store-BDgJpwLI.js';
5
+ import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler, M as ModelInvokerConfig, A as AgentResponse } from '../../../types-DwBYd0ij.js';
6
+ import { C as ColdThreadStore } from '../../../cold-store-aD4TSKlU.js';
7
7
  import { BaseChatModel } from '@langchain/core/language_models/chat_models';
8
- import { L as LangChainContent, a as LangChainThreadManagerHooks } from '../../../thread-manager-Dw96FKH1.js';
9
- export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-Dw96FKH1.js';
8
+ import { L as LangChainContent, a as LangChainThreadManagerHooks } from '../../../thread-manager-CICj68PI.js';
9
+ export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-CICj68PI.js';
10
10
  import '@temporalio/workflow';
11
11
  import '@temporalio/common/lib/interfaces';
12
12
  import 'zod';
13
13
  import '../../../types-CJ7tCdl6.js';
14
14
  import '@temporalio/common';
15
15
  import '@aws-sdk/client-s3';
16
- import '../../../types-CtdOquo3.js';
16
+ import '../../../types-DF4wzWQG.js';
17
17
 
18
18
  type LangChainThreadOps<TScope extends string = ""> = PrefixedThreadOps<ScopedPrefix<TScope, typeof ADAPTER_ID>, LangChainContent>;
19
19
  interface LangChainAdapterConfig {
@@ -1,8 +1,8 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-DNEl5uxQ.cjs';
3
- import { L as LangChainContent } from '../../../thread-manager-BjoYYXgd.cjs';
4
- import { c as createThreadOpsProxy } from '../../../proxy-CDh3Rsa7.cjs';
5
- export { T as ThreadOpsProxyOptions } from '../../../proxy-CDh3Rsa7.cjs';
2
+ import { T as ThreadOps } from '../../../types-DWeyCTYK.cjs';
3
+ import { L as LangChainContent } from '../../../thread-manager-DsXvJ5cJ.cjs';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-BAty3CWM.cjs';
5
+ export { T as ThreadOpsProxyOptions } from '../../../proxy-BAty3CWM.cjs';
6
6
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-CbY2zeSt.cjs';
7
7
  import '@temporalio/common/lib/interfaces';
8
8
  import 'zod';
@@ -10,7 +10,7 @@ import '../../../types-CJ7tCdl6.cjs';
10
10
  import '@temporalio/common';
11
11
  import 'ioredis';
12
12
  import '@langchain/core/messages';
13
- import '../../../types-BMJrsHo0.cjs';
13
+ import '../../../types-DDLPnxBh.cjs';
14
14
 
15
15
  /**
16
16
  * Workflow-safe proxy for LangChain thread operations.
@@ -1,8 +1,8 @@
1
1
  import { ActivityInterfaceFor } from '@temporalio/workflow';
2
- import { T as ThreadOps } from '../../../types-qQVZfhoT.js';
3
- import { L as LangChainContent } from '../../../thread-manager-Dw96FKH1.js';
4
- import { c as createThreadOpsProxy } from '../../../proxy-Du8ggERu.js';
5
- export { T as ThreadOpsProxyOptions } from '../../../proxy-Du8ggERu.js';
2
+ import { T as ThreadOps } from '../../../types-DwBYd0ij.js';
3
+ import { L as LangChainContent } from '../../../thread-manager-CICj68PI.js';
4
+ import { c as createThreadOpsProxy } from '../../../proxy-mbnwBhHw.js';
5
+ export { T as ThreadOpsProxyOptions } from '../../../proxy-mbnwBhHw.js';
6
6
  export { A as ADAPTER_ID, a as AdapterId } from '../../../adapter-id-CbY2zeSt.js';
7
7
  import '@temporalio/common/lib/interfaces';
8
8
  import 'zod';
@@ -10,7 +10,7 @@ import '../../../types-CJ7tCdl6.js';
10
10
  import '@temporalio/common';
11
11
  import 'ioredis';
12
12
  import '@langchain/core/messages';
13
- import '../../../types-CtdOquo3.js';
13
+ import '../../../types-DF4wzWQG.js';
14
14
 
15
15
  /**
16
16
  * Workflow-safe proxy for LangChain thread operations.
@@ -1,4 +1,4 @@
1
- import { P as PersistedThreadState } from './types-DNEl5uxQ.cjs';
1
+ import { P as PersistedThreadState } from './types-DWeyCTYK.cjs';
2
2
  import { S3Client } from '@aws-sdk/client-s3';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { P as PersistedThreadState } from './types-qQVZfhoT.js';
1
+ import { P as PersistedThreadState } from './types-DwBYd0ij.js';
2
2
  import { S3Client } from '@aws-sdk/client-s3';
3
3
 
4
4
  /**
package/dist/index.cjs CHANGED
@@ -131,7 +131,7 @@ function createToolRouter(options) {
131
131
  });
132
132
  }
133
133
  }
134
- async function processToolCall(toolCall, turn, sandboxId, onRewindRequested) {
134
+ async function processToolCall(toolCall, turn, sandboxId, onRewindRequested, assistantMessageId) {
135
135
  const startTime = Date.now();
136
136
  const tool = toolMap.get(toolCall.name);
137
137
  const preResult = await runPreHooks(toolCall, tool, turn);
@@ -166,7 +166,8 @@ function createToolRouter(options) {
166
166
  ...options.threadKey && { threadKey: options.threadKey },
167
167
  toolCallId: toolCall.id,
168
168
  toolName: toolCall.name,
169
- ...sandboxId !== void 0 && { sandboxId }
169
+ ...sandboxId !== void 0 && { sandboxId },
170
+ ...assistantMessageId !== void 0 && { assistantMessageId }
170
171
  };
171
172
  const response = await tool.handler(
172
173
  effectiveArgs,
@@ -293,6 +294,7 @@ function createToolRouter(options) {
293
294
  }
294
295
  const turn = context?.turn ?? 0;
295
296
  const sandboxId = context?.sandboxId;
297
+ const assistantMessageId = context?.assistantMessageId;
296
298
  let rewindSignal;
297
299
  if (options.parallel) {
298
300
  const scope = new workflow.CancellationScope({ cancellable: true });
@@ -305,7 +307,13 @@ function createToolRouter(options) {
305
307
  const outcomes = await scope.run(
306
308
  async () => Promise.allSettled(
307
309
  toolCalls.map(
308
- (tc) => processToolCall(tc, turn, sandboxId, onRewindRequested)
310
+ (tc) => processToolCall(
311
+ tc,
312
+ turn,
313
+ sandboxId,
314
+ onRewindRequested,
315
+ assistantMessageId
316
+ )
309
317
  )
310
318
  )
311
319
  );
@@ -325,7 +333,13 @@ function createToolRouter(options) {
325
333
  }
326
334
  const results = [];
327
335
  for (const toolCall of toolCalls) {
328
- const outcome = await processToolCall(toolCall, turn, sandboxId);
336
+ const outcome = await processToolCall(
337
+ toolCall,
338
+ turn,
339
+ sandboxId,
340
+ void 0,
341
+ assistantMessageId
342
+ );
329
343
  if (outcome.kind === "rewind") {
330
344
  rewindSignal = outcome.signal;
331
345
  break;
@@ -349,6 +363,9 @@ function createToolRouter(options) {
349
363
  toolName: toolCall.name,
350
364
  ...context?.sandboxId !== void 0 && {
351
365
  sandboxId: context.sandboxId
366
+ },
367
+ ...context?.assistantMessageId !== void 0 && {
368
+ assistantMessageId: context.assistantMessageId
352
369
  }
353
370
  };
354
371
  const response = await handler(
@@ -575,13 +592,26 @@ function createSubagentHandler(subagents) {
575
592
  const threadMode = config.thread ?? "new";
576
593
  const allowsContinuation = threadMode !== "new";
577
594
  const newThreadSource = config.newThreadSource ?? "new";
578
- const continuationThreadId = !allowsContinuation ? void 0 : args.threadId ?? (newThreadSource === "from-parent" ? context.threadId : void 0);
595
+ const usingParentFallback = allowsContinuation && !args.threadId && newThreadSource === "from-parent";
596
+ const continuationThreadId = !allowsContinuation ? void 0 : args.threadId ?? (usingParentFallback ? context.threadId : void 0);
579
597
  let thread;
580
598
  if (continuationThreadId) {
581
- thread = {
582
- mode: threadMode,
583
- threadId: continuationThreadId
584
- };
599
+ if (threadMode === "fork") {
600
+ thread = {
601
+ mode: "fork",
602
+ threadId: continuationThreadId,
603
+ ...usingParentFallback && context.assistantMessageId ? {
604
+ truncateAfterFork: {
605
+ fromMessageId: context.assistantMessageId
606
+ }
607
+ } : {}
608
+ };
609
+ } else {
610
+ thread = {
611
+ mode: "continue",
612
+ threadId: continuationThreadId
613
+ };
614
+ }
585
615
  }
586
616
  let sandbox;
587
617
  let sandboxShutdownOverride;
@@ -1042,6 +1072,7 @@ async function createSession(config) {
1042
1072
  appendSystemMessage,
1043
1073
  appendAgentMessage,
1044
1074
  forkThread,
1075
+ truncateThread,
1045
1076
  loadThreadState,
1046
1077
  saveThreadState,
1047
1078
  hydrateThread,
@@ -1191,6 +1222,10 @@ async function createSession(config) {
1191
1222
  if (threadMode === "fork" && sourceThreadId) {
1192
1223
  await hydrateThread(sourceThreadId, threadKey);
1193
1224
  await forkThread(sourceThreadId, threadId, threadKey);
1225
+ const truncate = threadInit.truncateAfterFork;
1226
+ if (truncate?.fromMessageId) {
1227
+ await truncateThread(threadId, truncate.fromMessageId, threadKey);
1228
+ }
1194
1229
  const forkedSlice = await loadThreadState(threadId, threadKey);
1195
1230
  if (forkedSlice) rehydrateFromSlice(forkedSlice);
1196
1231
  } else if (threadMode === "continue") {
@@ -1320,7 +1355,10 @@ async function createSession(config) {
1320
1355
  parsedToolCalls,
1321
1356
  {
1322
1357
  turn: currentTurn,
1323
- ...sandboxId !== void 0 && { sandboxId }
1358
+ ...sandboxId !== void 0 && { sandboxId },
1359
+ ...assistantId !== void 0 && {
1360
+ assistantMessageId: assistantId
1361
+ }
1324
1362
  }
1325
1363
  );
1326
1364
  for (const result of toolCallResults) {