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.
- package/README.md +2 -0
- package/dist/{activities-CPwKoUlD.d.cts → activities-BlQR5gX4.d.cts} +3 -3
- package/dist/{activities-DlaBxNID.d.ts → activities-DCaIPQBT.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-UL13Sstw.d.cts} +1 -1
- package/dist/{cold-store-BDgJpwLI.d.ts → cold-store-aD4TSKlU.d.ts} +1 -1
- package/dist/index.cjs +48 -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 +48 -10
- package/dist/index.js.map +1 -1
- package/dist/{proxy-CDh3Rsa7.d.cts → proxy-BAty3CWM.d.cts} +1 -1
- package/dist/{proxy-Du8ggERu.d.ts → proxy-mbnwBhHw.d.ts} +1 -1
- package/dist/{thread-manager-Dw96FKH1.d.ts → thread-manager-CICj68PI.d.ts} +2 -2
- package/dist/{thread-manager-BjoYYXgd.d.cts → thread-manager-DsXvJ5cJ.d.cts} +2 -2
- package/dist/{thread-manager-DtHYws2F.d.ts → thread-manager-DtEtbUkp.d.ts} +2 -2
- package/dist/{thread-manager-D8zKNFZ9.d.cts → thread-manager-R6c3lnJy.d.cts} +2 -2
- package/dist/{types-BMJrsHo0.d.cts → types-DDLPnxBh.d.cts} +1 -1
- package/dist/{types-CtdOquo3.d.ts → types-DF4wzWQG.d.ts} +1 -1
- package/dist/{types-DNEl5uxQ.d.cts → types-DWeyCTYK.d.cts} +31 -0
- package/dist/{types-qQVZfhoT.d.ts → types-DwBYd0ij.d.ts} +31 -0
- package/dist/{workflow-BH9ImDGq.d.cts → workflow-DVNPR7eX.d.cts} +1 -1
- package/dist/{workflow-Cdw3-RNB.d.ts → workflow-DdaU7_j4.d.ts} +1 -1
- package/dist/workflow.cjs +48 -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 +48 -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 +15 -0
- package/src/lib/subagent/handler.ts +32 -6
- package/src/lib/subagent/subagent.integration.test.ts +41 -2
- package/src/lib/tool-router/router-edge-cases.integration.test.ts +36 -0
- package/src/lib/tool-router/router.ts +21 -3
- 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-
|
|
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-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-
|
|
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-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-
|
|
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-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-
|
|
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-
|
|
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-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-
|
|
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-
|
|
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-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-
|
|
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-
|
|
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-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-
|
|
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-
|
|
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-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-
|
|
7
|
-
import '../../../cold-store-
|
|
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-
|
|
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-
|
|
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-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-
|
|
7
|
-
import '../../../cold-store-
|
|
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-
|
|
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-
|
|
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-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-
|
|
13
|
+
import '../../../cold-store-UL13Sstw.cjs';
|
|
14
14
|
import '@aws-sdk/client-s3';
|
|
15
|
-
import '../../../types-
|
|
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-
|
|
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-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-
|
|
13
|
+
import '../../../cold-store-aD4TSKlU.js';
|
|
14
14
|
import '@aws-sdk/client-s3';
|
|
15
|
-
import '../../../types-
|
|
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-
|
|
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-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-
|
|
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-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-
|
|
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-
|
|
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-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-
|
|
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-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-
|
|
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-
|
|
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-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-
|
|
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-
|
|
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-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-
|
|
13
|
+
import '../../../types-DF4wzWQG.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) {
|
|
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(
|
|
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(
|
|
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
|
|
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
|
-
|
|
582
|
-
|
|
583
|
-
|
|
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) {
|