zeitlich 0.2.47 → 0.2.49
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.
- package/README.md +2 -0
- package/dist/{activities-CPwKoUlD.d.cts → activities-7OcT_vdR.d.cts} +3 -3
- package/dist/{activities-DlaBxNID.d.ts → activities-zG_FBoY2.d.ts} +3 -3
- package/dist/adapters/thread/anthropic/index.d.cts +5 -5
- package/dist/adapters/thread/anthropic/index.d.ts +5 -5
- package/dist/adapters/thread/anthropic/workflow.d.cts +5 -5
- package/dist/adapters/thread/anthropic/workflow.d.ts +5 -5
- package/dist/adapters/thread/google-genai/index.d.cts +5 -5
- package/dist/adapters/thread/google-genai/index.d.ts +5 -5
- package/dist/adapters/thread/google-genai/workflow.d.cts +6 -6
- package/dist/adapters/thread/google-genai/workflow.d.ts +6 -6
- package/dist/adapters/thread/langchain/index.d.cts +5 -5
- package/dist/adapters/thread/langchain/index.d.ts +5 -5
- package/dist/adapters/thread/langchain/workflow.d.cts +5 -5
- package/dist/adapters/thread/langchain/workflow.d.ts +5 -5
- package/dist/{cold-store-Z2wvK2cV.d.cts → cold-store-CkWoNtMh.d.cts} +1 -1
- package/dist/{cold-store-BDgJpwLI.d.ts → cold-store-DKMAO1Dd.d.ts} +1 -1
- package/dist/index.cjs +76 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +76 -10
- package/dist/index.js.map +1 -1
- package/dist/{proxy-CDh3Rsa7.d.cts → proxy-B7CWEV-T.d.cts} +1 -1
- package/dist/{proxy-Du8ggERu.d.ts → proxy-ByFHMVRX.d.ts} +1 -1
- package/dist/{thread-manager-DtHYws2F.d.ts → thread-manager-7AW4rhfu.d.ts} +2 -2
- package/dist/{thread-manager-D8zKNFZ9.d.cts → thread-manager-B9rtMEVn.d.cts} +2 -2
- package/dist/{thread-manager-BjoYYXgd.d.cts → thread-manager-Cibe0X5m.d.cts} +2 -2
- package/dist/{thread-manager-Dw96FKH1.d.ts → thread-manager-nK-WcFzM.d.ts} +2 -2
- package/dist/{types-BMJrsHo0.d.cts → types-BR-k7h0e.d.cts} +1 -1
- package/dist/{types-CtdOquo3.d.ts → types-DO4Tkwxo.d.ts} +1 -1
- package/dist/{types-qQVZfhoT.d.ts → types-DeVNWqlb.d.ts} +54 -0
- package/dist/{types-DNEl5uxQ.d.cts → types-XUUFvrJ9.d.cts} +54 -0
- package/dist/{workflow-BH9ImDGq.d.cts → workflow-KbGsxpfh.d.cts} +1 -1
- package/dist/{workflow-Cdw3-RNB.d.ts → workflow-uhOIj9D-.d.ts} +1 -1
- package/dist/workflow.cjs +76 -10
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +2 -2
- package/dist/workflow.d.ts +2 -2
- package/dist/workflow.js +76 -10
- package/dist/workflow.js.map +1 -1
- package/package.json +6 -6
- package/src/lib/lifecycle.ts +13 -1
- package/src/lib/session/session-edge-cases.integration.test.ts +44 -0
- package/src/lib/session/session.ts +26 -0
- package/src/lib/subagent/handler.ts +55 -6
- package/src/lib/subagent/subagent.integration.test.ts +239 -2
- package/src/lib/tool-router/router-edge-cases.integration.test.ts +36 -0
- package/src/lib/tool-router/router.ts +29 -3
- package/src/lib/tool-router/types.ts +43 -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-
|
|
4
|
-
import { C as ColdThreadStore } from './cold-store-
|
|
5
|
-
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-
|
|
3
|
+
import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler } from './types-XUUFvrJ9.cjs';
|
|
4
|
+
import { C as ColdThreadStore } from './cold-store-CkWoNtMh.cjs';
|
|
5
|
+
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BR-k7h0e.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-
|
|
4
|
-
import { C as ColdThreadStore } from './cold-store-
|
|
5
|
-
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-
|
|
3
|
+
import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler } from './types-DeVNWqlb.js';
|
|
4
|
+
import { C as ColdThreadStore } from './cold-store-DKMAO1Dd.js';
|
|
5
|
+
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-DO4Tkwxo.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-
|
|
6
|
-
import { C as ColdThreadStore } from '../../../cold-store-
|
|
7
|
-
import { A as AnthropicContent, a as AnthropicThreadManagerHooks } from '../../../thread-manager-
|
|
8
|
-
export { b as AnthropicInvocationPayload, c as AnthropicThreadManager, d as AnthropicThreadManagerConfig, S as StoredMessage, e as createAnthropicThreadManager } from '../../../thread-manager-
|
|
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-XUUFvrJ9.cjs';
|
|
6
|
+
import { C as ColdThreadStore } from '../../../cold-store-CkWoNtMh.cjs';
|
|
7
|
+
import { A as AnthropicContent, a as AnthropicThreadManagerHooks } from '../../../thread-manager-B9rtMEVn.cjs';
|
|
8
|
+
export { b as AnthropicInvocationPayload, c as AnthropicThreadManager, d as AnthropicThreadManagerConfig, S as StoredMessage, e as createAnthropicThreadManager } from '../../../thread-manager-B9rtMEVn.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-
|
|
15
|
+
import '../../../types-BR-k7h0e.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-
|
|
6
|
-
import { C as ColdThreadStore } from '../../../cold-store-
|
|
7
|
-
import { A as AnthropicContent, a as AnthropicThreadManagerHooks } from '../../../thread-manager-
|
|
8
|
-
export { b as AnthropicInvocationPayload, c as AnthropicThreadManager, d as AnthropicThreadManagerConfig, S as StoredMessage, e as createAnthropicThreadManager } from '../../../thread-manager-
|
|
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-DeVNWqlb.js';
|
|
6
|
+
import { C as ColdThreadStore } from '../../../cold-store-DKMAO1Dd.js';
|
|
7
|
+
import { A as AnthropicContent, a as AnthropicThreadManagerHooks } from '../../../thread-manager-7AW4rhfu.js';
|
|
8
|
+
export { b as AnthropicInvocationPayload, c as AnthropicThreadManager, d as AnthropicThreadManagerConfig, S as StoredMessage, e as createAnthropicThreadManager } from '../../../thread-manager-7AW4rhfu.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-
|
|
15
|
+
import '../../../types-DO4Tkwxo.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-
|
|
3
|
-
import { A as AnthropicContent } from '../../../thread-manager-
|
|
4
|
-
import { c as createThreadOpsProxy } from '../../../proxy-
|
|
5
|
-
export { T as ThreadOpsProxyOptions } from '../../../proxy-
|
|
2
|
+
import { T as ThreadOps } from '../../../types-XUUFvrJ9.cjs';
|
|
3
|
+
import { A as AnthropicContent } from '../../../thread-manager-B9rtMEVn.cjs';
|
|
4
|
+
import { c as createThreadOpsProxy } from '../../../proxy-B7CWEV-T.cjs';
|
|
5
|
+
export { T as ThreadOpsProxyOptions } from '../../../proxy-B7CWEV-T.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-
|
|
13
|
+
import '../../../types-BR-k7h0e.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-
|
|
3
|
-
import { A as AnthropicContent } from '../../../thread-manager-
|
|
4
|
-
import { c as createThreadOpsProxy } from '../../../proxy-
|
|
5
|
-
export { T as ThreadOpsProxyOptions } from '../../../proxy-
|
|
2
|
+
import { T as ThreadOps } from '../../../types-DeVNWqlb.js';
|
|
3
|
+
import { A as AnthropicContent } from '../../../thread-manager-7AW4rhfu.js';
|
|
4
|
+
import { c as createThreadOpsProxy } from '../../../proxy-ByFHMVRX.js';
|
|
5
|
+
export { T as ThreadOpsProxyOptions } from '../../../proxy-ByFHMVRX.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-
|
|
13
|
+
import '../../../types-DO4Tkwxo.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-
|
|
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-
|
|
2
|
+
import { G as GoogleGenAIThreadManagerHooks } from '../../../activities-7OcT_vdR.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-7OcT_vdR.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-
|
|
7
|
-
import '../../../cold-store-
|
|
6
|
+
import { M as ModelInvokerConfig, A as AgentResponse } from '../../../types-XUUFvrJ9.cjs';
|
|
7
|
+
import '../../../cold-store-CkWoNtMh.cjs';
|
|
8
8
|
import '@aws-sdk/client-s3';
|
|
9
|
-
import '../../../types-
|
|
9
|
+
import '../../../types-BR-k7h0e.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-
|
|
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-
|
|
2
|
+
import { G as GoogleGenAIThreadManagerHooks } from '../../../activities-zG_FBoY2.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-zG_FBoY2.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-
|
|
7
|
-
import '../../../cold-store-
|
|
6
|
+
import { M as ModelInvokerConfig, A as AgentResponse } from '../../../types-DeVNWqlb.js';
|
|
7
|
+
import '../../../cold-store-DKMAO1Dd.js';
|
|
8
8
|
import '@aws-sdk/client-s3';
|
|
9
|
-
import '../../../types-
|
|
9
|
+
import '../../../types-DO4Tkwxo.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-
|
|
3
|
-
import { c as GoogleGenAIContent } from '../../../activities-
|
|
4
|
-
import { c as createThreadOpsProxy } from '../../../proxy-
|
|
5
|
-
export { T as ThreadOpsProxyOptions } from '../../../proxy-
|
|
2
|
+
import { T as ThreadOps } from '../../../types-XUUFvrJ9.cjs';
|
|
3
|
+
import { c as GoogleGenAIContent } from '../../../activities-7OcT_vdR.cjs';
|
|
4
|
+
import { c as createThreadOpsProxy } from '../../../proxy-B7CWEV-T.cjs';
|
|
5
|
+
export { T as ThreadOpsProxyOptions } from '../../../proxy-B7CWEV-T.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-
|
|
13
|
+
import '../../../cold-store-CkWoNtMh.cjs';
|
|
14
14
|
import '@aws-sdk/client-s3';
|
|
15
|
-
import '../../../types-
|
|
15
|
+
import '../../../types-BR-k7h0e.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-
|
|
3
|
-
import { c as GoogleGenAIContent } from '../../../activities-
|
|
4
|
-
import { c as createThreadOpsProxy } from '../../../proxy-
|
|
5
|
-
export { T as ThreadOpsProxyOptions } from '../../../proxy-
|
|
2
|
+
import { T as ThreadOps } from '../../../types-DeVNWqlb.js';
|
|
3
|
+
import { c as GoogleGenAIContent } from '../../../activities-zG_FBoY2.js';
|
|
4
|
+
import { c as createThreadOpsProxy } from '../../../proxy-ByFHMVRX.js';
|
|
5
|
+
export { T as ThreadOpsProxyOptions } from '../../../proxy-ByFHMVRX.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-
|
|
13
|
+
import '../../../cold-store-DKMAO1Dd.js';
|
|
14
14
|
import '@aws-sdk/client-s3';
|
|
15
|
-
import '../../../types-
|
|
15
|
+
import '../../../types-DO4Tkwxo.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-
|
|
6
|
-
import { C as ColdThreadStore } from '../../../cold-store-
|
|
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-XUUFvrJ9.cjs';
|
|
6
|
+
import { C as ColdThreadStore } from '../../../cold-store-CkWoNtMh.cjs';
|
|
7
7
|
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
8
|
-
import { L as LangChainContent, a as LangChainThreadManagerHooks } from '../../../thread-manager-
|
|
9
|
-
export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-
|
|
8
|
+
import { L as LangChainContent, a as LangChainThreadManagerHooks } from '../../../thread-manager-Cibe0X5m.cjs';
|
|
9
|
+
export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-Cibe0X5m.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-
|
|
16
|
+
import '../../../types-BR-k7h0e.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-
|
|
6
|
-
import { C as ColdThreadStore } from '../../../cold-store-
|
|
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-DeVNWqlb.js';
|
|
6
|
+
import { C as ColdThreadStore } from '../../../cold-store-DKMAO1Dd.js';
|
|
7
7
|
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
8
|
-
import { L as LangChainContent, a as LangChainThreadManagerHooks } from '../../../thread-manager-
|
|
9
|
-
export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-
|
|
8
|
+
import { L as LangChainContent, a as LangChainThreadManagerHooks } from '../../../thread-manager-nK-WcFzM.js';
|
|
9
|
+
export { b as LangChainInvocationPayload, c as LangChainThreadManager, d as LangChainThreadManagerConfig, e as createLangChainThreadManager } from '../../../thread-manager-nK-WcFzM.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-
|
|
16
|
+
import '../../../types-DO4Tkwxo.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-
|
|
3
|
-
import { L as LangChainContent } from '../../../thread-manager-
|
|
4
|
-
import { c as createThreadOpsProxy } from '../../../proxy-
|
|
5
|
-
export { T as ThreadOpsProxyOptions } from '../../../proxy-
|
|
2
|
+
import { T as ThreadOps } from '../../../types-XUUFvrJ9.cjs';
|
|
3
|
+
import { L as LangChainContent } from '../../../thread-manager-Cibe0X5m.cjs';
|
|
4
|
+
import { c as createThreadOpsProxy } from '../../../proxy-B7CWEV-T.cjs';
|
|
5
|
+
export { T as ThreadOpsProxyOptions } from '../../../proxy-B7CWEV-T.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-
|
|
13
|
+
import '../../../types-BR-k7h0e.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-
|
|
3
|
-
import { L as LangChainContent } from '../../../thread-manager-
|
|
4
|
-
import { c as createThreadOpsProxy } from '../../../proxy-
|
|
5
|
-
export { T as ThreadOpsProxyOptions } from '../../../proxy-
|
|
2
|
+
import { T as ThreadOps } from '../../../types-DeVNWqlb.js';
|
|
3
|
+
import { L as LangChainContent } from '../../../thread-manager-nK-WcFzM.js';
|
|
4
|
+
import { c as createThreadOpsProxy } from '../../../proxy-ByFHMVRX.js';
|
|
5
|
+
export { T as ThreadOpsProxyOptions } from '../../../proxy-ByFHMVRX.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-
|
|
13
|
+
import '../../../types-DO4Tkwxo.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Workflow-safe proxy for LangChain thread operations.
|
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, persistThreadState) {
|
|
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,9 @@ 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 },
|
|
171
|
+
...persistThreadState !== void 0 && { persistThreadState }
|
|
170
172
|
};
|
|
171
173
|
const response = await tool.handler(
|
|
172
174
|
effectiveArgs,
|
|
@@ -293,6 +295,8 @@ function createToolRouter(options) {
|
|
|
293
295
|
}
|
|
294
296
|
const turn = context?.turn ?? 0;
|
|
295
297
|
const sandboxId = context?.sandboxId;
|
|
298
|
+
const assistantMessageId = context?.assistantMessageId;
|
|
299
|
+
const persistThreadState = context?.persistThreadState;
|
|
296
300
|
let rewindSignal;
|
|
297
301
|
if (options.parallel) {
|
|
298
302
|
const scope = new workflow.CancellationScope({ cancellable: true });
|
|
@@ -305,7 +309,14 @@ function createToolRouter(options) {
|
|
|
305
309
|
const outcomes = await scope.run(
|
|
306
310
|
async () => Promise.allSettled(
|
|
307
311
|
toolCalls.map(
|
|
308
|
-
(tc) => processToolCall(
|
|
312
|
+
(tc) => processToolCall(
|
|
313
|
+
tc,
|
|
314
|
+
turn,
|
|
315
|
+
sandboxId,
|
|
316
|
+
onRewindRequested,
|
|
317
|
+
assistantMessageId,
|
|
318
|
+
persistThreadState
|
|
319
|
+
)
|
|
309
320
|
)
|
|
310
321
|
)
|
|
311
322
|
);
|
|
@@ -325,7 +336,14 @@ function createToolRouter(options) {
|
|
|
325
336
|
}
|
|
326
337
|
const results = [];
|
|
327
338
|
for (const toolCall of toolCalls) {
|
|
328
|
-
const outcome = await processToolCall(
|
|
339
|
+
const outcome = await processToolCall(
|
|
340
|
+
toolCall,
|
|
341
|
+
turn,
|
|
342
|
+
sandboxId,
|
|
343
|
+
void 0,
|
|
344
|
+
assistantMessageId,
|
|
345
|
+
persistThreadState
|
|
346
|
+
);
|
|
329
347
|
if (outcome.kind === "rewind") {
|
|
330
348
|
rewindSignal = outcome.signal;
|
|
331
349
|
break;
|
|
@@ -349,6 +367,12 @@ function createToolRouter(options) {
|
|
|
349
367
|
toolName: toolCall.name,
|
|
350
368
|
...context?.sandboxId !== void 0 && {
|
|
351
369
|
sandboxId: context.sandboxId
|
|
370
|
+
},
|
|
371
|
+
...context?.assistantMessageId !== void 0 && {
|
|
372
|
+
assistantMessageId: context.assistantMessageId
|
|
373
|
+
},
|
|
374
|
+
...context?.persistThreadState !== void 0 && {
|
|
375
|
+
persistThreadState: context.persistThreadState
|
|
352
376
|
}
|
|
353
377
|
};
|
|
354
378
|
const response = await handler(
|
|
@@ -575,13 +599,26 @@ function createSubagentHandler(subagents) {
|
|
|
575
599
|
const threadMode = config.thread ?? "new";
|
|
576
600
|
const allowsContinuation = threadMode !== "new";
|
|
577
601
|
const newThreadSource = config.newThreadSource ?? "new";
|
|
578
|
-
const
|
|
602
|
+
const usingParentFallback = allowsContinuation && !args.threadId && newThreadSource === "from-parent";
|
|
603
|
+
const continuationThreadId = !allowsContinuation ? void 0 : args.threadId ?? (usingParentFallback ? context.threadId : void 0);
|
|
579
604
|
let thread;
|
|
580
605
|
if (continuationThreadId) {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
606
|
+
if (threadMode === "fork") {
|
|
607
|
+
thread = {
|
|
608
|
+
mode: "fork",
|
|
609
|
+
threadId: continuationThreadId,
|
|
610
|
+
...usingParentFallback && context.assistantMessageId ? {
|
|
611
|
+
truncateAfterFork: {
|
|
612
|
+
fromMessageId: context.assistantMessageId
|
|
613
|
+
}
|
|
614
|
+
} : {}
|
|
615
|
+
};
|
|
616
|
+
} else {
|
|
617
|
+
thread = {
|
|
618
|
+
mode: "continue",
|
|
619
|
+
threadId: continuationThreadId
|
|
620
|
+
};
|
|
621
|
+
}
|
|
585
622
|
}
|
|
586
623
|
let sandbox;
|
|
587
624
|
let sandboxShutdownOverride;
|
|
@@ -693,6 +730,17 @@ function createSubagentHandler(subagents) {
|
|
|
693
730
|
if (isSnapshotBaseCreator) {
|
|
694
731
|
snapshotBaseCreatorAgent.set(childWorkflowId, config.agentName);
|
|
695
732
|
}
|
|
733
|
+
if (continuationThreadId && continuationThreadId === context.threadId && context.persistThreadState) {
|
|
734
|
+
try {
|
|
735
|
+
await context.persistThreadState();
|
|
736
|
+
} catch (err) {
|
|
737
|
+
workflow.log.warn("failed to persist parent thread state for subagent", {
|
|
738
|
+
subagent: config.agentName,
|
|
739
|
+
childWorkflowId,
|
|
740
|
+
error: err instanceof Error ? err.message : String(err)
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
}
|
|
696
744
|
workflow.log.info("subagent spawned", {
|
|
697
745
|
subagent: config.agentName,
|
|
698
746
|
childWorkflowId,
|
|
@@ -1042,6 +1090,7 @@ async function createSession(config) {
|
|
|
1042
1090
|
appendSystemMessage,
|
|
1043
1091
|
appendAgentMessage,
|
|
1044
1092
|
forkThread,
|
|
1093
|
+
truncateThread,
|
|
1045
1094
|
loadThreadState,
|
|
1046
1095
|
saveThreadState,
|
|
1047
1096
|
hydrateThread,
|
|
@@ -1191,6 +1240,10 @@ async function createSession(config) {
|
|
|
1191
1240
|
if (threadMode === "fork" && sourceThreadId) {
|
|
1192
1241
|
await hydrateThread(sourceThreadId, threadKey);
|
|
1193
1242
|
await forkThread(sourceThreadId, threadId, threadKey);
|
|
1243
|
+
const truncate = threadInit.truncateAfterFork;
|
|
1244
|
+
if (truncate?.fromMessageId) {
|
|
1245
|
+
await truncateThread(threadId, truncate.fromMessageId, threadKey);
|
|
1246
|
+
}
|
|
1194
1247
|
const forkedSlice = await loadThreadState(threadId, threadKey);
|
|
1195
1248
|
if (forkedSlice) rehydrateFromSlice(forkedSlice);
|
|
1196
1249
|
} else if (threadMode === "continue") {
|
|
@@ -1320,7 +1373,20 @@ async function createSession(config) {
|
|
|
1320
1373
|
parsedToolCalls,
|
|
1321
1374
|
{
|
|
1322
1375
|
turn: currentTurn,
|
|
1323
|
-
...sandboxId !== void 0 && { sandboxId }
|
|
1376
|
+
...sandboxId !== void 0 && { sandboxId },
|
|
1377
|
+
...assistantId !== void 0 && {
|
|
1378
|
+
assistantMessageId: assistantId
|
|
1379
|
+
},
|
|
1380
|
+
// Hand handlers a way to persist the parent's slice
|
|
1381
|
+
// mid-loop (subagents that fork or continue the parent's
|
|
1382
|
+
// thread need this — otherwise the child loads a stale
|
|
1383
|
+
// snapshot from the prior session, since `saveThreadState`
|
|
1384
|
+
// would otherwise only run in the `finally` below).
|
|
1385
|
+
persistThreadState: () => saveThreadState(
|
|
1386
|
+
threadId,
|
|
1387
|
+
stateManager.getPersistedSlice(),
|
|
1388
|
+
threadKey
|
|
1389
|
+
)
|
|
1324
1390
|
}
|
|
1325
1391
|
);
|
|
1326
1392
|
for (const result of toolCallResults) {
|