zeitlich 0.2.19 → 0.2.21
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/dist/adapters/sandbox/daytona/index.cjs +25 -10
- package/dist/adapters/sandbox/daytona/index.cjs.map +1 -1
- package/dist/adapters/sandbox/daytona/index.d.cts +4 -1
- package/dist/adapters/sandbox/daytona/index.d.ts +4 -1
- package/dist/adapters/sandbox/daytona/index.js +25 -10
- package/dist/adapters/sandbox/daytona/index.js.map +1 -1
- package/dist/adapters/sandbox/virtual/index.d.cts +4 -3
- package/dist/adapters/sandbox/virtual/index.d.ts +4 -3
- package/dist/adapters/thread/google-genai/index.cjs +69 -24
- package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/index.d.cts +10 -10
- package/dist/adapters/thread/google-genai/index.d.ts +10 -10
- package/dist/adapters/thread/google-genai/index.js +69 -24
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/langchain/index.cjs +76 -69
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +11 -11
- package/dist/adapters/thread/langchain/index.d.ts +11 -11
- package/dist/adapters/thread/langchain/index.js +76 -69
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/index.cjs +198 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -14
- package/dist/index.d.ts +14 -14
- package/dist/index.js +198 -118
- package/dist/index.js.map +1 -1
- package/dist/{queries-D8T4pEeu.d.ts → queries-6Avfh74U.d.ts} +1 -1
- package/dist/{queries-D22uWTOb.d.cts → queries-CHa2iv_I.d.cts} +1 -1
- package/dist/{types-CxWLeJTB.d.ts → types-BkAYmc96.d.ts} +6 -6
- package/dist/{types-CCfJb5Jl.d.cts → types-CES_30qx.d.cts} +6 -6
- package/dist/{types-DjT78Sdp.d.cts → types-YbL7JpEA.d.cts} +4 -2
- package/dist/{types-DjT78Sdp.d.ts → types-YbL7JpEA.d.ts} +4 -2
- package/dist/workflow.cjs +68 -34
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +16 -12
- package/dist/workflow.d.ts +16 -12
- package/dist/workflow.js +68 -34
- package/dist/workflow.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/sandbox/daytona/filesystem.ts +21 -12
- package/src/adapters/sandbox/daytona/index.ts +24 -23
- package/src/adapters/thread/google-genai/activities.ts +11 -9
- package/src/adapters/thread/google-genai/model-invoker.ts +6 -11
- package/src/adapters/thread/google-genai/thread-manager.ts +44 -29
- package/src/adapters/thread/langchain/activities.ts +6 -4
- package/src/adapters/thread/langchain/thread-manager.ts +55 -27
- package/src/lib/session/session-edge-cases.integration.test.ts +20 -2
- package/src/lib/session/session.integration.test.ts +16 -2
- package/src/lib/session/session.ts +7 -5
- package/src/lib/session/types.ts +9 -3
- package/src/lib/subagent/handler.ts +1 -1
- package/src/lib/subagent/subagent.integration.test.ts +5 -4
- package/src/lib/subagent/tool.ts +1 -1
- package/src/lib/thread/index.ts +0 -1
- package/src/lib/tool-router/auto-append-sandbox.integration.test.ts +20 -21
- package/src/lib/tool-router/auto-append.ts +3 -2
- package/src/lib/tool-router/router-edge-cases.integration.test.ts +64 -23
- package/src/lib/tool-router/router.integration.test.ts +60 -23
- package/src/lib/tool-router/router.ts +58 -29
- package/src/lib/tool-router/types.ts +12 -7
- package/src/lib/workflow.test.ts +18 -6
- package/src/lib/workflow.ts +13 -3
- package/src/tools/task-create/handler.ts +3 -6
- package/src/workflow.ts +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { BashArgs, FileEditArgs, GlobArgs, FileReadArgs, FileWriteArgs } from './workflow.cjs';
|
|
2
|
-
export { AskUserQuestionArgs, GrepArgs, ReadSkillArgs, SubagentArgs, TaskCreateArgs, TaskGetArgs, TaskListArgs, TaskUpdateArgs, WorkflowInput, WorkflowSessionInput, applyVirtualTreeMutations, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createToolRouter, defineSubagent, defineSubagentWorkflow, defineTool, defineWorkflow, editTool, formatVirtualFileTree, getShortId, globTool, grepTool, hasNoOtherToolCalls, parseSkillFile, proxyDefaultThreadOps, proxySandboxOps, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool } from './workflow.cjs';
|
|
3
|
-
import { S as SkillProvider, b as SkillMetadata, c as Skill } from './types-
|
|
4
|
-
export { A as AgentResponse, d as AgentState, e as AgentStateManager, H as Hooks, J as JsonPrimitive, f as JsonSerializable, g as JsonValue, M as ModelInvoker, a as ModelInvokerConfig, P as PostHumanMessageAppendHook, h as PostHumanMessageAppendHookContext, i as PreHumanMessageAppendHook, j as PreHumanMessageAppendHookContext, R as RunAgentActivity, k as SessionConfig, l as SessionEndHook, m as SessionEndHookContext, n as SessionStartHook, o as SessionStartHookContext, p as SubagentConfig, q as SubagentDefinition, r as SubagentHandlerResponse, s as SubagentHooks, t as SubagentSessionInput, u as SubagentWorkflow, v as SubagentWorkflowInput, T as ThreadOps, Z as ZeitlichSession } from './types-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export { l as AgentConfig, m as AgentFile, h as AgentStatus, n as AppendToolResultFn, C as ContentPart, I as InferToolResults, M as MessageContent, o as ParsedToolCall, p as ParsedToolCallUnion, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, d as PostToolUseFailureHookResult, s as PostToolUseHook, t as PostToolUseHookContext, u as PreToolUseHook, v as PreToolUseHookContext, P as PreToolUseHookResult, w as ProcessToolCallsContext, e as RawToolCall, x as SerializableToolDefinition, S as SessionExitReason, y as TaskStatus, f as TokenUsage, z as ToolArgs, D as ToolCallResult, k as ToolCallResultUnion, i as ToolDefinition, E as ToolHandler, F as ToolHooks, a as ToolMap, T as ToolMessageContent, G as ToolNames, H as ToolResult, J as ToolRouter, b as ToolRouterHooks, K as ToolWithHandler, W as WorkflowTask, L as isTerminalStatus } from './types-DjT78Sdp.cjs';
|
|
2
|
+
export { AskUserQuestionArgs, GrepArgs, ReadSkillArgs, SubagentArgs, TaskCreateArgs, TaskGetArgs, TaskListArgs, TaskUpdateArgs, WorkflowConfig, WorkflowInput, WorkflowSessionInput, applyVirtualTreeMutations, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createToolRouter, defineSubagent, defineSubagentWorkflow, defineTool, defineWorkflow, editTool, formatVirtualFileTree, getShortId, globTool, grepTool, hasNoOtherToolCalls, parseSkillFile, proxyDefaultThreadOps, proxySandboxOps, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool } from './workflow.cjs';
|
|
3
|
+
import { S as SkillProvider, b as SkillMetadata, c as Skill } from './types-CES_30qx.cjs';
|
|
4
|
+
export { A as AgentResponse, d as AgentState, e as AgentStateManager, H as Hooks, J as JsonPrimitive, f as JsonSerializable, g as JsonValue, M as ModelInvoker, a as ModelInvokerConfig, P as PostHumanMessageAppendHook, h as PostHumanMessageAppendHookContext, i as PreHumanMessageAppendHook, j as PreHumanMessageAppendHookContext, R as RunAgentActivity, k as SessionConfig, l as SessionEndHook, m as SessionEndHookContext, n as SessionStartHook, o as SessionStartHookContext, p as SubagentConfig, q as SubagentDefinition, r as SubagentHandlerResponse, s as SubagentHooks, t as SubagentSessionInput, u as SubagentWorkflow, v as SubagentWorkflowInput, T as ThreadOps, Z as ZeitlichSession } from './types-CES_30qx.cjs';
|
|
5
|
+
import { R as RouterContext, j as ToolResultConfig, A as ActivityToolHandler, c as ToolHandlerResponse, B as BaseAgentState, g as RunAgentConfig } from './types-YbL7JpEA.cjs';
|
|
6
|
+
export { l as AgentConfig, m as AgentFile, h as AgentStatus, n as AppendToolResultFn, C as ContentPart, I as InferToolResults, M as MessageContent, o as ParsedToolCall, p as ParsedToolCallUnion, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, d as PostToolUseFailureHookResult, s as PostToolUseHook, t as PostToolUseHookContext, u as PreToolUseHook, v as PreToolUseHookContext, P as PreToolUseHookResult, w as ProcessToolCallsContext, e as RawToolCall, x as SerializableToolDefinition, S as SessionExitReason, y as TaskStatus, f as TokenUsage, z as ToolArgs, D as ToolCallResult, k as ToolCallResultUnion, i as ToolDefinition, E as ToolHandler, F as ToolHooks, a as ToolMap, T as ToolMessageContent, G as ToolNames, H as ToolResult, J as ToolRouter, b as ToolRouterHooks, K as ToolWithHandler, W as WorkflowTask, L as isTerminalStatus } from './types-YbL7JpEA.cjs';
|
|
8
7
|
import { S as Sandbox, a as SandboxFileSystem, d as SandboxCreateOptions, b as SandboxProvider, f as SandboxSnapshot, g as SandboxOps, E as ExecResult } from './types-BMRzfELQ.cjs';
|
|
9
8
|
export { h as ExecOptions, c as SandboxCapabilities, e as SandboxCreateResult, D as SandboxDirentEntry, F as SandboxFileStat, i as SandboxNotFoundError, j as SandboxNotSupportedError } from './types-BMRzfELQ.cjs';
|
|
10
9
|
import { WorkflowClient } from '@temporalio/client';
|
|
11
|
-
export { c as FileEntry, F as FileEntryMetadata, a as FileResolver, T as TreeMutation, f as VirtualFileTree, h as VirtualSandboxState, i as filesWithMimeType, j as hasDirectory, k as hasFileWithMimeType } from './queries-
|
|
10
|
+
export { c as FileEntry, F as FileEntryMetadata, a as FileResolver, T as TreeMutation, f as VirtualFileTree, h as VirtualSandboxState, i as filesWithMimeType, j as hasDirectory, k as hasFileWithMimeType } from './queries-CHa2iv_I.cjs';
|
|
11
|
+
import { T as ThreadManagerConfig, B as BaseThreadManager } from './types-35POpVfa.cjs';
|
|
12
12
|
import '@temporalio/workflow';
|
|
13
13
|
import 'zod';
|
|
14
14
|
import '@temporalio/common';
|
|
15
15
|
import '@temporalio/common/lib/interfaces';
|
|
16
16
|
import 'ioredis';
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Creates a generic thread manager for handling conversation state in Redis.
|
|
20
|
-
* Framework-agnostic — works with any serializable message type.
|
|
21
|
-
*/
|
|
22
|
-
declare function createThreadManager<T>(config: ThreadManagerConfig<T>): BaseThreadManager<T>;
|
|
23
|
-
|
|
24
18
|
/**
|
|
25
19
|
* Wraps a tool handler to automatically append its result directly to the
|
|
26
20
|
* thread and sets `resultAppended: true` on the response.
|
|
@@ -48,7 +42,7 @@ declare function createThreadManager<T>(config: ThreadManagerConfig<T>): BaseThr
|
|
|
48
42
|
* );
|
|
49
43
|
* ```
|
|
50
44
|
*/
|
|
51
|
-
declare function withAutoAppend<TArgs, TResult, TContext extends RouterContext = RouterContext>(threadHandler: (config: ToolResultConfig) => Promise<void>, handler: ActivityToolHandler<TArgs, TResult, TContext>): ActivityToolHandler<TArgs, TResult, TContext>;
|
|
45
|
+
declare function withAutoAppend<TArgs, TResult, TContext extends RouterContext = RouterContext>(threadHandler: (id: string, config: ToolResultConfig) => Promise<void>, handler: ActivityToolHandler<TArgs, TResult, TContext>): ActivityToolHandler<TArgs, TResult, TContext>;
|
|
52
46
|
|
|
53
47
|
/**
|
|
54
48
|
* Extended router context with a resolved {@link Sandbox} instance.
|
|
@@ -183,6 +177,12 @@ declare class FileSystemSkillProvider implements SkillProvider {
|
|
|
183
177
|
private discoverSkillDirs;
|
|
184
178
|
}
|
|
185
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Creates a generic thread manager for handling conversation state in Redis.
|
|
182
|
+
* Framework-agnostic — works with any serializable message type.
|
|
183
|
+
*/
|
|
184
|
+
declare function createThreadManager<T>(config: ThreadManagerConfig<T>): BaseThreadManager<T>;
|
|
185
|
+
|
|
186
186
|
/**
|
|
187
187
|
* Stateless facade over a {@link SandboxProvider}.
|
|
188
188
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { BashArgs, FileEditArgs, GlobArgs, FileReadArgs, FileWriteArgs } from './workflow.js';
|
|
2
|
-
export { AskUserQuestionArgs, GrepArgs, ReadSkillArgs, SubagentArgs, TaskCreateArgs, TaskGetArgs, TaskListArgs, TaskUpdateArgs, WorkflowInput, WorkflowSessionInput, applyVirtualTreeMutations, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createToolRouter, defineSubagent, defineSubagentWorkflow, defineTool, defineWorkflow, editTool, formatVirtualFileTree, getShortId, globTool, grepTool, hasNoOtherToolCalls, parseSkillFile, proxyDefaultThreadOps, proxySandboxOps, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool } from './workflow.js';
|
|
3
|
-
import { S as SkillProvider, b as SkillMetadata, c as Skill } from './types-
|
|
4
|
-
export { A as AgentResponse, d as AgentState, e as AgentStateManager, H as Hooks, J as JsonPrimitive, f as JsonSerializable, g as JsonValue, M as ModelInvoker, a as ModelInvokerConfig, P as PostHumanMessageAppendHook, h as PostHumanMessageAppendHookContext, i as PreHumanMessageAppendHook, j as PreHumanMessageAppendHookContext, R as RunAgentActivity, k as SessionConfig, l as SessionEndHook, m as SessionEndHookContext, n as SessionStartHook, o as SessionStartHookContext, p as SubagentConfig, q as SubagentDefinition, r as SubagentHandlerResponse, s as SubagentHooks, t as SubagentSessionInput, u as SubagentWorkflow, v as SubagentWorkflowInput, T as ThreadOps, Z as ZeitlichSession } from './types-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export { l as AgentConfig, m as AgentFile, h as AgentStatus, n as AppendToolResultFn, C as ContentPart, I as InferToolResults, M as MessageContent, o as ParsedToolCall, p as ParsedToolCallUnion, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, d as PostToolUseFailureHookResult, s as PostToolUseHook, t as PostToolUseHookContext, u as PreToolUseHook, v as PreToolUseHookContext, P as PreToolUseHookResult, w as ProcessToolCallsContext, e as RawToolCall, x as SerializableToolDefinition, S as SessionExitReason, y as TaskStatus, f as TokenUsage, z as ToolArgs, D as ToolCallResult, k as ToolCallResultUnion, i as ToolDefinition, E as ToolHandler, F as ToolHooks, a as ToolMap, T as ToolMessageContent, G as ToolNames, H as ToolResult, J as ToolRouter, b as ToolRouterHooks, K as ToolWithHandler, W as WorkflowTask, L as isTerminalStatus } from './types-DjT78Sdp.js';
|
|
2
|
+
export { AskUserQuestionArgs, GrepArgs, ReadSkillArgs, SubagentArgs, TaskCreateArgs, TaskGetArgs, TaskListArgs, TaskUpdateArgs, WorkflowConfig, WorkflowInput, WorkflowSessionInput, applyVirtualTreeMutations, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createToolRouter, defineSubagent, defineSubagentWorkflow, defineTool, defineWorkflow, editTool, formatVirtualFileTree, getShortId, globTool, grepTool, hasNoOtherToolCalls, parseSkillFile, proxyDefaultThreadOps, proxySandboxOps, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool } from './workflow.js';
|
|
3
|
+
import { S as SkillProvider, b as SkillMetadata, c as Skill } from './types-BkAYmc96.js';
|
|
4
|
+
export { A as AgentResponse, d as AgentState, e as AgentStateManager, H as Hooks, J as JsonPrimitive, f as JsonSerializable, g as JsonValue, M as ModelInvoker, a as ModelInvokerConfig, P as PostHumanMessageAppendHook, h as PostHumanMessageAppendHookContext, i as PreHumanMessageAppendHook, j as PreHumanMessageAppendHookContext, R as RunAgentActivity, k as SessionConfig, l as SessionEndHook, m as SessionEndHookContext, n as SessionStartHook, o as SessionStartHookContext, p as SubagentConfig, q as SubagentDefinition, r as SubagentHandlerResponse, s as SubagentHooks, t as SubagentSessionInput, u as SubagentWorkflow, v as SubagentWorkflowInput, T as ThreadOps, Z as ZeitlichSession } from './types-BkAYmc96.js';
|
|
5
|
+
import { R as RouterContext, j as ToolResultConfig, A as ActivityToolHandler, c as ToolHandlerResponse, B as BaseAgentState, g as RunAgentConfig } from './types-YbL7JpEA.js';
|
|
6
|
+
export { l as AgentConfig, m as AgentFile, h as AgentStatus, n as AppendToolResultFn, C as ContentPart, I as InferToolResults, M as MessageContent, o as ParsedToolCall, p as ParsedToolCallUnion, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, d as PostToolUseFailureHookResult, s as PostToolUseHook, t as PostToolUseHookContext, u as PreToolUseHook, v as PreToolUseHookContext, P as PreToolUseHookResult, w as ProcessToolCallsContext, e as RawToolCall, x as SerializableToolDefinition, S as SessionExitReason, y as TaskStatus, f as TokenUsage, z as ToolArgs, D as ToolCallResult, k as ToolCallResultUnion, i as ToolDefinition, E as ToolHandler, F as ToolHooks, a as ToolMap, T as ToolMessageContent, G as ToolNames, H as ToolResult, J as ToolRouter, b as ToolRouterHooks, K as ToolWithHandler, W as WorkflowTask, L as isTerminalStatus } from './types-YbL7JpEA.js';
|
|
8
7
|
import { S as Sandbox, a as SandboxFileSystem, d as SandboxCreateOptions, b as SandboxProvider, f as SandboxSnapshot, g as SandboxOps, E as ExecResult } from './types-BMRzfELQ.js';
|
|
9
8
|
export { h as ExecOptions, c as SandboxCapabilities, e as SandboxCreateResult, D as SandboxDirentEntry, F as SandboxFileStat, i as SandboxNotFoundError, j as SandboxNotSupportedError } from './types-BMRzfELQ.js';
|
|
10
9
|
import { WorkflowClient } from '@temporalio/client';
|
|
11
|
-
export { c as FileEntry, F as FileEntryMetadata, a as FileResolver, T as TreeMutation, f as VirtualFileTree, h as VirtualSandboxState, i as filesWithMimeType, j as hasDirectory, k as hasFileWithMimeType } from './queries-
|
|
10
|
+
export { c as FileEntry, F as FileEntryMetadata, a as FileResolver, T as TreeMutation, f as VirtualFileTree, h as VirtualSandboxState, i as filesWithMimeType, j as hasDirectory, k as hasFileWithMimeType } from './queries-6Avfh74U.js';
|
|
11
|
+
import { T as ThreadManagerConfig, B as BaseThreadManager } from './types-35POpVfa.js';
|
|
12
12
|
import '@temporalio/workflow';
|
|
13
13
|
import 'zod';
|
|
14
14
|
import '@temporalio/common';
|
|
15
15
|
import '@temporalio/common/lib/interfaces';
|
|
16
16
|
import 'ioredis';
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Creates a generic thread manager for handling conversation state in Redis.
|
|
20
|
-
* Framework-agnostic — works with any serializable message type.
|
|
21
|
-
*/
|
|
22
|
-
declare function createThreadManager<T>(config: ThreadManagerConfig<T>): BaseThreadManager<T>;
|
|
23
|
-
|
|
24
18
|
/**
|
|
25
19
|
* Wraps a tool handler to automatically append its result directly to the
|
|
26
20
|
* thread and sets `resultAppended: true` on the response.
|
|
@@ -48,7 +42,7 @@ declare function createThreadManager<T>(config: ThreadManagerConfig<T>): BaseThr
|
|
|
48
42
|
* );
|
|
49
43
|
* ```
|
|
50
44
|
*/
|
|
51
|
-
declare function withAutoAppend<TArgs, TResult, TContext extends RouterContext = RouterContext>(threadHandler: (config: ToolResultConfig) => Promise<void>, handler: ActivityToolHandler<TArgs, TResult, TContext>): ActivityToolHandler<TArgs, TResult, TContext>;
|
|
45
|
+
declare function withAutoAppend<TArgs, TResult, TContext extends RouterContext = RouterContext>(threadHandler: (id: string, config: ToolResultConfig) => Promise<void>, handler: ActivityToolHandler<TArgs, TResult, TContext>): ActivityToolHandler<TArgs, TResult, TContext>;
|
|
52
46
|
|
|
53
47
|
/**
|
|
54
48
|
* Extended router context with a resolved {@link Sandbox} instance.
|
|
@@ -183,6 +177,12 @@ declare class FileSystemSkillProvider implements SkillProvider {
|
|
|
183
177
|
private discoverSkillDirs;
|
|
184
178
|
}
|
|
185
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Creates a generic thread manager for handling conversation state in Redis.
|
|
182
|
+
* Framework-agnostic — works with any serializable message type.
|
|
183
|
+
*/
|
|
184
|
+
declare function createThreadManager<T>(config: ThreadManagerConfig<T>): BaseThreadManager<T>;
|
|
185
|
+
|
|
186
186
|
/**
|
|
187
187
|
* Stateless facade over a {@link SandboxProvider}.
|
|
188
188
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { uuid4, setHandler, defineUpdate, ApplicationFailure, condition, proxyActivities, defineQuery, workflowInfo, executeChild } from '@temporalio/workflow';
|
|
2
2
|
import z14, { z } from 'zod';
|
|
3
|
+
import { randomUUID, randomFillSync } from 'crypto';
|
|
3
4
|
import { ApplicationFailure as ApplicationFailure$1 } from '@temporalio/common';
|
|
4
5
|
import { join } from 'path';
|
|
5
6
|
import { Context } from '@temporalio/activity';
|
|
@@ -53,7 +54,10 @@ function createToolRouter(options) {
|
|
|
53
54
|
turn
|
|
54
55
|
});
|
|
55
56
|
if (r?.fallbackContent !== void 0)
|
|
56
|
-
return {
|
|
57
|
+
return {
|
|
58
|
+
content: r.fallbackContent,
|
|
59
|
+
result: { error: errorStr, recovered: true }
|
|
60
|
+
};
|
|
57
61
|
if (r?.suppress)
|
|
58
62
|
return {
|
|
59
63
|
content: JSON.stringify({ error: errorStr, suppressed: true }),
|
|
@@ -68,7 +72,10 @@ function createToolRouter(options) {
|
|
|
68
72
|
turn
|
|
69
73
|
});
|
|
70
74
|
if (r?.fallbackContent !== void 0)
|
|
71
|
-
return {
|
|
75
|
+
return {
|
|
76
|
+
content: r.fallbackContent,
|
|
77
|
+
result: { error: errorStr, recovered: true }
|
|
78
|
+
};
|
|
72
79
|
if (r?.suppress)
|
|
73
80
|
return {
|
|
74
81
|
content: JSON.stringify({ error: errorStr, suppressed: true }),
|
|
@@ -102,11 +109,14 @@ function createToolRouter(options) {
|
|
|
102
109
|
const tool = toolMap.get(toolCall.name);
|
|
103
110
|
const preResult = await runPreHooks(toolCall, tool, turn);
|
|
104
111
|
if (preResult.skip) {
|
|
105
|
-
await appendToolResult({
|
|
112
|
+
await appendToolResult(uuid4(), {
|
|
106
113
|
threadId: options.threadId,
|
|
107
114
|
toolCallId: toolCall.id,
|
|
108
115
|
toolName: toolCall.name,
|
|
109
|
-
content: JSON.stringify({
|
|
116
|
+
content: JSON.stringify({
|
|
117
|
+
skipped: true,
|
|
118
|
+
reason: "Skipped by PreToolUse hook"
|
|
119
|
+
})
|
|
110
120
|
});
|
|
111
121
|
return null;
|
|
112
122
|
}
|
|
@@ -134,24 +144,43 @@ function createToolRouter(options) {
|
|
|
134
144
|
content = JSON.stringify(result, null, 2);
|
|
135
145
|
}
|
|
136
146
|
} catch (error) {
|
|
137
|
-
const recovery = await runFailureHooks(
|
|
147
|
+
const recovery = await runFailureHooks(
|
|
148
|
+
toolCall,
|
|
149
|
+
tool,
|
|
150
|
+
error,
|
|
151
|
+
effectiveArgs,
|
|
152
|
+
turn
|
|
153
|
+
);
|
|
138
154
|
result = recovery.result;
|
|
139
155
|
content = recovery.content;
|
|
140
156
|
}
|
|
141
157
|
if (!resultAppended) {
|
|
142
|
-
|
|
158
|
+
const config = {
|
|
143
159
|
threadId: options.threadId,
|
|
144
160
|
toolCallId: toolCall.id,
|
|
145
161
|
toolName: toolCall.name,
|
|
146
162
|
content
|
|
147
|
-
}
|
|
163
|
+
};
|
|
164
|
+
await appendToolResult.executeWithOptions(
|
|
165
|
+
{
|
|
166
|
+
summary: `Append ${toolCall.name} result`
|
|
167
|
+
},
|
|
168
|
+
[uuid4(), config]
|
|
169
|
+
);
|
|
148
170
|
}
|
|
149
171
|
const toolResult = {
|
|
150
172
|
toolCallId: toolCall.id,
|
|
151
173
|
name: toolCall.name,
|
|
152
174
|
data: result
|
|
153
175
|
};
|
|
154
|
-
await runPostHooks(
|
|
176
|
+
await runPostHooks(
|
|
177
|
+
toolCall,
|
|
178
|
+
tool,
|
|
179
|
+
toolResult,
|
|
180
|
+
effectiveArgs,
|
|
181
|
+
turn,
|
|
182
|
+
Date.now() - startTime
|
|
183
|
+
);
|
|
155
184
|
return toolResult;
|
|
156
185
|
}
|
|
157
186
|
return {
|
|
@@ -194,9 +223,7 @@ function createToolRouter(options) {
|
|
|
194
223
|
const sandboxId = context?.sandboxId;
|
|
195
224
|
if (options.parallel) {
|
|
196
225
|
const results2 = await Promise.all(
|
|
197
|
-
toolCalls.map(
|
|
198
|
-
(tc) => processToolCall(tc, turn, sandboxId)
|
|
199
|
-
)
|
|
226
|
+
toolCalls.map((tc) => processToolCall(tc, turn, sandboxId))
|
|
200
227
|
);
|
|
201
228
|
return results2.filter(
|
|
202
229
|
(r) => r !== null
|
|
@@ -204,11 +231,7 @@ function createToolRouter(options) {
|
|
|
204
231
|
}
|
|
205
232
|
const results = [];
|
|
206
233
|
for (const toolCall of toolCalls) {
|
|
207
|
-
const result = await processToolCall(
|
|
208
|
-
toolCall,
|
|
209
|
-
turn,
|
|
210
|
-
sandboxId
|
|
211
|
-
);
|
|
234
|
+
const result = await processToolCall(toolCall, turn, sandboxId);
|
|
212
235
|
if (result !== null) {
|
|
213
236
|
results.push(result);
|
|
214
237
|
}
|
|
@@ -225,19 +248,29 @@ function createToolRouter(options) {
|
|
|
225
248
|
threadId: options.threadId,
|
|
226
249
|
toolCallId: toolCall.id,
|
|
227
250
|
toolName: toolCall.name,
|
|
228
|
-
...context?.sandboxId !== void 0 && {
|
|
251
|
+
...context?.sandboxId !== void 0 && {
|
|
252
|
+
sandboxId: context.sandboxId
|
|
253
|
+
}
|
|
229
254
|
};
|
|
230
255
|
const response = await handler(
|
|
231
256
|
toolCall.args,
|
|
232
257
|
routerContext
|
|
233
258
|
);
|
|
234
259
|
if (!response.resultAppended) {
|
|
235
|
-
await appendToolResult(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
260
|
+
await appendToolResult.executeWithOptions(
|
|
261
|
+
{
|
|
262
|
+
summary: `Append ${toolCall.name} result`
|
|
263
|
+
},
|
|
264
|
+
[
|
|
265
|
+
uuid4(),
|
|
266
|
+
{
|
|
267
|
+
threadId: options.threadId,
|
|
268
|
+
toolCallId: toolCall.id,
|
|
269
|
+
toolName: toolCall.name,
|
|
270
|
+
content: response.toolResponse
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
);
|
|
241
274
|
}
|
|
242
275
|
return {
|
|
243
276
|
toolCallId: toolCall.id,
|
|
@@ -312,7 +345,7 @@ function createSubagentTool(subagents) {
|
|
|
312
345
|
const schema = hasThreadContinuation ? z14.object({
|
|
313
346
|
...baseFields,
|
|
314
347
|
threadId: z14.string().nullable().describe(
|
|
315
|
-
"Thread ID to continue an existing conversation, or null to start a new one"
|
|
348
|
+
"Thread ID to continue an existing conversation from the same subagent, or null to start a new one"
|
|
316
349
|
)
|
|
317
350
|
}) : z14.object(baseFields);
|
|
318
351
|
return {
|
|
@@ -369,7 +402,7 @@ function createSubagentHandler(subagents) {
|
|
|
369
402
|
if (config.allowThreadContinuation && childThreadId) {
|
|
370
403
|
finalToolResponse = typeof toolResponse === "string" ? `${toolResponse}
|
|
371
404
|
|
|
372
|
-
[Thread ID: ${childThreadId}]` : toolResponse;
|
|
405
|
+
[${config.agentName} Thread ID: ${childThreadId}]` : toolResponse;
|
|
373
406
|
}
|
|
374
407
|
return {
|
|
375
408
|
toolResponse: finalToolResponse,
|
|
@@ -465,8 +498,6 @@ function buildSkillRegistration(skills) {
|
|
|
465
498
|
handler: createReadSkillHandler(skills)
|
|
466
499
|
};
|
|
467
500
|
}
|
|
468
|
-
|
|
469
|
-
// src/lib/session/session.ts
|
|
470
501
|
var createSession = async ({
|
|
471
502
|
threadId: providedThreadId,
|
|
472
503
|
agentName,
|
|
@@ -536,7 +567,7 @@ var createSession = async ({
|
|
|
536
567
|
threadId
|
|
537
568
|
});
|
|
538
569
|
}
|
|
539
|
-
await appendHumanMessage(threadId, message);
|
|
570
|
+
await appendHumanMessage(threadId, uuid4(), message);
|
|
540
571
|
if (hooks.onPostHumanMessageAppend) {
|
|
541
572
|
await hooks.onPostHumanMessageAppend({
|
|
542
573
|
message,
|
|
@@ -573,12 +604,12 @@ var createSession = async ({
|
|
|
573
604
|
nonRetryable: true
|
|
574
605
|
});
|
|
575
606
|
}
|
|
576
|
-
await appendSystemMessage(threadId, systemPrompt);
|
|
607
|
+
await appendSystemMessage(threadId, uuid4(), systemPrompt);
|
|
577
608
|
} else {
|
|
578
609
|
await initializeThread(threadId);
|
|
579
610
|
}
|
|
580
611
|
}
|
|
581
|
-
await appendHumanMessage(threadId, await buildContextMessage());
|
|
612
|
+
await appendHumanMessage(threadId, uuid4(), await buildContextMessage());
|
|
582
613
|
let exitReason = "completed";
|
|
583
614
|
try {
|
|
584
615
|
while (stateManager.isRunning() && !stateManager.isTerminal() && stateManager.getTurns() < maxTurns) {
|
|
@@ -608,7 +639,7 @@ var createSession = async ({
|
|
|
608
639
|
try {
|
|
609
640
|
parsedToolCalls.push(toolRouter.parseToolCall(tc));
|
|
610
641
|
} catch (error) {
|
|
611
|
-
await appendToolResult({
|
|
642
|
+
await appendToolResult(uuid4(), {
|
|
612
643
|
threadId,
|
|
613
644
|
toolCallId: tc.id ?? "",
|
|
614
645
|
toolName: tc.name,
|
|
@@ -692,8 +723,8 @@ function proxySandboxOps(options) {
|
|
|
692
723
|
}
|
|
693
724
|
|
|
694
725
|
// src/lib/workflow.ts
|
|
695
|
-
function defineWorkflow(fn) {
|
|
696
|
-
|
|
726
|
+
function defineWorkflow(config, fn) {
|
|
727
|
+
const workflow = async (input, workflowInput = {}) => {
|
|
697
728
|
const sessionInput = {
|
|
698
729
|
...workflowInput.previousThreadId && {
|
|
699
730
|
threadId: workflowInput.previousThreadId,
|
|
@@ -703,89 +734,8 @@ function defineWorkflow(fn) {
|
|
|
703
734
|
};
|
|
704
735
|
return fn(input, sessionInput);
|
|
705
736
|
};
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
// src/lib/thread/manager.ts
|
|
709
|
-
var THREAD_TTL_SECONDS = 60 * 60 * 24 * 90;
|
|
710
|
-
var APPEND_IDEMPOTENT_SCRIPT = `
|
|
711
|
-
if redis.call('EXISTS', KEYS[1]) == 1 then
|
|
712
|
-
return 0
|
|
713
|
-
end
|
|
714
|
-
for i = 2, #ARGV do
|
|
715
|
-
redis.call('RPUSH', KEYS[2], ARGV[i])
|
|
716
|
-
end
|
|
717
|
-
redis.call('EXPIRE', KEYS[2], tonumber(ARGV[1]))
|
|
718
|
-
redis.call('SET', KEYS[1], '1', 'EX', tonumber(ARGV[1]))
|
|
719
|
-
return 1
|
|
720
|
-
`;
|
|
721
|
-
function getThreadKey(threadId, key) {
|
|
722
|
-
return `thread:${threadId}:${key}`;
|
|
723
|
-
}
|
|
724
|
-
function createThreadManager(config) {
|
|
725
|
-
const {
|
|
726
|
-
redis,
|
|
727
|
-
threadId,
|
|
728
|
-
key = "messages",
|
|
729
|
-
serialize = (m) => JSON.stringify(m),
|
|
730
|
-
deserialize = (raw) => JSON.parse(raw),
|
|
731
|
-
idOf
|
|
732
|
-
} = config;
|
|
733
|
-
const redisKey = getThreadKey(threadId, key);
|
|
734
|
-
const metaKey = getThreadKey(threadId, `${key}:meta`);
|
|
735
|
-
async function assertThreadExists() {
|
|
736
|
-
const exists = await redis.exists(metaKey);
|
|
737
|
-
if (!exists) {
|
|
738
|
-
throw new Error(`Thread "${threadId}" (key: ${key}) does not exist`);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
return {
|
|
742
|
-
async initialize() {
|
|
743
|
-
await redis.del(redisKey);
|
|
744
|
-
await redis.set(metaKey, "1", "EX", THREAD_TTL_SECONDS);
|
|
745
|
-
},
|
|
746
|
-
async load() {
|
|
747
|
-
await assertThreadExists();
|
|
748
|
-
const data = await redis.lrange(redisKey, 0, -1);
|
|
749
|
-
return data.map(deserialize);
|
|
750
|
-
},
|
|
751
|
-
async append(messages) {
|
|
752
|
-
if (messages.length === 0) return;
|
|
753
|
-
await assertThreadExists();
|
|
754
|
-
if (idOf) {
|
|
755
|
-
const dedupId = messages.map(idOf).join(":");
|
|
756
|
-
const dedupKey = getThreadKey(threadId, `dedup:${dedupId}`);
|
|
757
|
-
await redis.eval(
|
|
758
|
-
APPEND_IDEMPOTENT_SCRIPT,
|
|
759
|
-
2,
|
|
760
|
-
dedupKey,
|
|
761
|
-
redisKey,
|
|
762
|
-
String(THREAD_TTL_SECONDS),
|
|
763
|
-
...messages.map(serialize)
|
|
764
|
-
);
|
|
765
|
-
} else {
|
|
766
|
-
await redis.rpush(redisKey, ...messages.map(serialize));
|
|
767
|
-
await redis.expire(redisKey, THREAD_TTL_SECONDS);
|
|
768
|
-
}
|
|
769
|
-
},
|
|
770
|
-
async fork(newThreadId) {
|
|
771
|
-
await assertThreadExists();
|
|
772
|
-
const data = await redis.lrange(redisKey, 0, -1);
|
|
773
|
-
const forked = createThreadManager({
|
|
774
|
-
...config,
|
|
775
|
-
threadId: newThreadId
|
|
776
|
-
});
|
|
777
|
-
await forked.initialize();
|
|
778
|
-
if (data.length > 0) {
|
|
779
|
-
const newKey = getThreadKey(newThreadId, key);
|
|
780
|
-
await redis.rpush(newKey, ...data);
|
|
781
|
-
await redis.expire(newKey, THREAD_TTL_SECONDS);
|
|
782
|
-
}
|
|
783
|
-
return forked;
|
|
784
|
-
},
|
|
785
|
-
async delete() {
|
|
786
|
-
await redis.del(redisKey, metaKey);
|
|
787
|
-
}
|
|
788
|
-
};
|
|
737
|
+
Object.defineProperty(workflow, "name", { value: config.name });
|
|
738
|
+
return workflow;
|
|
789
739
|
}
|
|
790
740
|
|
|
791
741
|
// src/lib/types.ts
|
|
@@ -949,11 +899,56 @@ function createAgentStateManager({
|
|
|
949
899
|
};
|
|
950
900
|
}
|
|
951
901
|
|
|
902
|
+
// node_modules/uuid/dist/esm/stringify.js
|
|
903
|
+
var byteToHex = [];
|
|
904
|
+
for (let i = 0; i < 256; ++i) {
|
|
905
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
906
|
+
}
|
|
907
|
+
function unsafeStringify(arr, offset = 0) {
|
|
908
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
909
|
+
}
|
|
910
|
+
var rnds8Pool = new Uint8Array(256);
|
|
911
|
+
var poolPtr = rnds8Pool.length;
|
|
912
|
+
function rng() {
|
|
913
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
|
914
|
+
randomFillSync(rnds8Pool);
|
|
915
|
+
poolPtr = 0;
|
|
916
|
+
}
|
|
917
|
+
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
918
|
+
}
|
|
919
|
+
var native_default = { randomUUID };
|
|
920
|
+
|
|
921
|
+
// node_modules/uuid/dist/esm/v4.js
|
|
922
|
+
function v4(options, buf, offset) {
|
|
923
|
+
if (native_default.randomUUID && !buf && !options) {
|
|
924
|
+
return native_default.randomUUID();
|
|
925
|
+
}
|
|
926
|
+
options = options || {};
|
|
927
|
+
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
928
|
+
if (rnds.length < 16) {
|
|
929
|
+
throw new Error("Random bytes length must be >= 16");
|
|
930
|
+
}
|
|
931
|
+
rnds[6] = rnds[6] & 15 | 64;
|
|
932
|
+
rnds[8] = rnds[8] & 63 | 128;
|
|
933
|
+
if (buf) {
|
|
934
|
+
offset = offset || 0;
|
|
935
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
936
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
937
|
+
}
|
|
938
|
+
for (let i = 0; i < 16; ++i) {
|
|
939
|
+
buf[offset + i] = rnds[i];
|
|
940
|
+
}
|
|
941
|
+
return buf;
|
|
942
|
+
}
|
|
943
|
+
return unsafeStringify(rnds);
|
|
944
|
+
}
|
|
945
|
+
var v4_default = v4;
|
|
946
|
+
|
|
952
947
|
// src/lib/tool-router/auto-append.ts
|
|
953
948
|
function withAutoAppend(threadHandler, handler) {
|
|
954
949
|
return async (args, context) => {
|
|
955
950
|
const response = await handler(args, context);
|
|
956
|
-
await threadHandler({
|
|
951
|
+
await threadHandler(v4_default(), {
|
|
957
952
|
threadId: context.threadId,
|
|
958
953
|
toolCallId: context.toolCallId,
|
|
959
954
|
toolName: context.toolName,
|
|
@@ -1384,10 +1379,12 @@ var taskCreateTool = {
|
|
|
1384
1379
|
metadata: z14.record(z14.string(), z14.string()).describe("Arbitrary key-value pairs for tracking")
|
|
1385
1380
|
})
|
|
1386
1381
|
};
|
|
1382
|
+
|
|
1383
|
+
// src/tools/task-create/handler.ts
|
|
1387
1384
|
function createTaskCreateHandler(stateManager) {
|
|
1388
1385
|
return (args) => {
|
|
1389
1386
|
const task = {
|
|
1390
|
-
id:
|
|
1387
|
+
id: getShortId(),
|
|
1391
1388
|
subject: args.subject,
|
|
1392
1389
|
description: args.description,
|
|
1393
1390
|
activeForm: args.activeForm,
|
|
@@ -1619,6 +1616,89 @@ var FileSystemSkillProvider = class {
|
|
|
1619
1616
|
return dirs;
|
|
1620
1617
|
}
|
|
1621
1618
|
};
|
|
1619
|
+
|
|
1620
|
+
// src/lib/thread/manager.ts
|
|
1621
|
+
var THREAD_TTL_SECONDS = 60 * 60 * 24 * 90;
|
|
1622
|
+
var APPEND_IDEMPOTENT_SCRIPT = `
|
|
1623
|
+
if redis.call('EXISTS', KEYS[1]) == 1 then
|
|
1624
|
+
return 0
|
|
1625
|
+
end
|
|
1626
|
+
for i = 2, #ARGV do
|
|
1627
|
+
redis.call('RPUSH', KEYS[2], ARGV[i])
|
|
1628
|
+
end
|
|
1629
|
+
redis.call('EXPIRE', KEYS[2], tonumber(ARGV[1]))
|
|
1630
|
+
redis.call('SET', KEYS[1], '1', 'EX', tonumber(ARGV[1]))
|
|
1631
|
+
return 1
|
|
1632
|
+
`;
|
|
1633
|
+
function getThreadKey(threadId, key) {
|
|
1634
|
+
return `thread:${threadId}:${key}`;
|
|
1635
|
+
}
|
|
1636
|
+
function createThreadManager(config) {
|
|
1637
|
+
const {
|
|
1638
|
+
redis,
|
|
1639
|
+
threadId,
|
|
1640
|
+
key = "messages",
|
|
1641
|
+
serialize = (m) => JSON.stringify(m),
|
|
1642
|
+
deserialize = (raw) => JSON.parse(raw),
|
|
1643
|
+
idOf
|
|
1644
|
+
} = config;
|
|
1645
|
+
const redisKey = getThreadKey(threadId, key);
|
|
1646
|
+
const metaKey = getThreadKey(threadId, `${key}:meta`);
|
|
1647
|
+
async function assertThreadExists() {
|
|
1648
|
+
const exists = await redis.exists(metaKey);
|
|
1649
|
+
if (!exists) {
|
|
1650
|
+
throw new Error(`Thread "${threadId}" (key: ${key}) does not exist`);
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
return {
|
|
1654
|
+
async initialize() {
|
|
1655
|
+
await redis.del(redisKey);
|
|
1656
|
+
await redis.set(metaKey, "1", "EX", THREAD_TTL_SECONDS);
|
|
1657
|
+
},
|
|
1658
|
+
async load() {
|
|
1659
|
+
await assertThreadExists();
|
|
1660
|
+
const data = await redis.lrange(redisKey, 0, -1);
|
|
1661
|
+
return data.map(deserialize);
|
|
1662
|
+
},
|
|
1663
|
+
async append(messages) {
|
|
1664
|
+
if (messages.length === 0) return;
|
|
1665
|
+
await assertThreadExists();
|
|
1666
|
+
if (idOf) {
|
|
1667
|
+
const dedupId = messages.map(idOf).join(":");
|
|
1668
|
+
const dedupKey = getThreadKey(threadId, `dedup:${dedupId}`);
|
|
1669
|
+
await redis.eval(
|
|
1670
|
+
APPEND_IDEMPOTENT_SCRIPT,
|
|
1671
|
+
2,
|
|
1672
|
+
dedupKey,
|
|
1673
|
+
redisKey,
|
|
1674
|
+
String(THREAD_TTL_SECONDS),
|
|
1675
|
+
...messages.map(serialize)
|
|
1676
|
+
);
|
|
1677
|
+
} else {
|
|
1678
|
+
await redis.rpush(redisKey, ...messages.map(serialize));
|
|
1679
|
+
await redis.expire(redisKey, THREAD_TTL_SECONDS);
|
|
1680
|
+
}
|
|
1681
|
+
},
|
|
1682
|
+
async fork(newThreadId) {
|
|
1683
|
+
await assertThreadExists();
|
|
1684
|
+
const data = await redis.lrange(redisKey, 0, -1);
|
|
1685
|
+
const forked = createThreadManager({
|
|
1686
|
+
...config,
|
|
1687
|
+
threadId: newThreadId
|
|
1688
|
+
});
|
|
1689
|
+
await forked.initialize();
|
|
1690
|
+
if (data.length > 0) {
|
|
1691
|
+
const newKey = getThreadKey(newThreadId, key);
|
|
1692
|
+
await redis.rpush(newKey, ...data);
|
|
1693
|
+
await redis.expire(newKey, THREAD_TTL_SECONDS);
|
|
1694
|
+
}
|
|
1695
|
+
return forked;
|
|
1696
|
+
},
|
|
1697
|
+
async delete() {
|
|
1698
|
+
await redis.del(redisKey, metaKey);
|
|
1699
|
+
}
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1622
1702
|
async function queryParentWorkflowState(client) {
|
|
1623
1703
|
const { workflowExecution } = Context.current().info;
|
|
1624
1704
|
const handle = client.getHandle(
|