zeitlich 0.2.31 → 0.2.33
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 +11 -10
- package/dist/{activities-DRSdt8Y3.d.ts → activities-YBD5BaHh.d.ts} +6 -5
- package/dist/{activities-qPkJDAiq.d.cts → activities-fnX8-vhR.d.cts} +6 -5
- package/dist/adapters/thread/anthropic/index.cjs +19 -47
- package/dist/adapters/thread/anthropic/index.cjs.map +1 -1
- package/dist/adapters/thread/anthropic/index.d.cts +12 -11
- package/dist/adapters/thread/anthropic/index.d.ts +12 -11
- package/dist/adapters/thread/anthropic/index.js +19 -47
- package/dist/adapters/thread/anthropic/index.js.map +1 -1
- package/dist/adapters/thread/anthropic/workflow.cjs +1 -0
- package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -1
- package/dist/adapters/thread/anthropic/workflow.d.cts +4 -4
- package/dist/adapters/thread/anthropic/workflow.d.ts +4 -4
- package/dist/adapters/thread/anthropic/workflow.js +1 -0
- package/dist/adapters/thread/anthropic/workflow.js.map +1 -1
- package/dist/adapters/thread/google-genai/index.cjs +34 -53
- package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/index.d.cts +8 -8
- package/dist/adapters/thread/google-genai/index.d.ts +8 -8
- package/dist/adapters/thread/google-genai/index.js +34 -53
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.cjs +1 -0
- package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.d.cts +4 -4
- package/dist/adapters/thread/google-genai/workflow.d.ts +4 -4
- package/dist/adapters/thread/google-genai/workflow.js +1 -0
- package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
- package/dist/adapters/thread/langchain/index.cjs +47 -24
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +13 -10
- package/dist/adapters/thread/langchain/index.d.ts +13 -10
- package/dist/adapters/thread/langchain/index.js +47 -24
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/adapters/thread/langchain/workflow.cjs +1 -0
- package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
- package/dist/adapters/thread/langchain/workflow.d.cts +4 -4
- package/dist/adapters/thread/langchain/workflow.d.ts +4 -4
- package/dist/adapters/thread/langchain/workflow.js +1 -0
- package/dist/adapters/thread/langchain/workflow.js.map +1 -1
- package/dist/index.cjs +42 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -13
- package/dist/index.d.ts +28 -13
- package/dist/index.js +41 -10
- package/dist/index.js.map +1 -1
- package/dist/{proxy-BkvkV2oU.d.ts → proxy-Br4unLTC.d.ts} +1 -1
- package/dist/{proxy-BDQ3Rj6R.d.cts → proxy-CTCYWjkr.d.cts} +1 -1
- package/dist/{thread-manager-BLgvv9Gf.d.cts → thread-manager-CUubPYPH.d.cts} +1 -1
- package/dist/{thread-manager-DowU4ntB.d.cts → thread-manager-Cv_BR28i.d.cts} +1 -1
- package/dist/{thread-manager-Cv82H1wi.d.ts → thread-manager-DKWxHUzD.d.ts} +1 -1
- package/dist/{thread-manager-HsAYkyAV.d.ts → thread-manager-YJLoc1vH.d.ts} +1 -1
- package/dist/{types-CjeGWQm1.d.cts → types-Bpq5fDI5.d.cts} +7 -4
- package/dist/{types-D6UKZZtj.d.ts → types-BxiT8w9d.d.ts} +1 -1
- package/dist/{types-BmS-Huc0.d.ts → types-CheCTLeV.d.ts} +7 -4
- package/dist/{types-e_38QaKo.d.cts → types-NJDyMyUx.d.cts} +1 -1
- package/dist/{workflow-CTcrPZAV.d.ts → workflow-D9nNERvs.d.ts} +30 -2
- package/dist/{workflow-CNshfqSO.d.cts → workflow-Od9vx5Jk.d.cts} +30 -2
- package/dist/workflow.cjs +22 -1
- 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 +22 -2
- package/dist/workflow.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/thread/anthropic/activities.ts +14 -3
- package/src/adapters/thread/anthropic/model-invoker.ts +15 -8
- package/src/adapters/thread/google-genai/activities.ts +18 -3
- package/src/adapters/thread/google-genai/model-invoker.ts +24 -14
- package/src/adapters/thread/langchain/activities.ts +14 -3
- package/src/adapters/thread/langchain/model-invoker.ts +63 -35
- package/src/index.ts +1 -0
- package/src/lib/activity.ts +36 -9
- package/src/lib/model/helpers.ts +1 -0
- package/src/lib/model/index.ts +1 -0
- package/src/lib/model/proxy.ts +50 -0
- package/src/lib/model/types.ts +3 -2
- package/src/lib/session/session-edge-cases.integration.test.ts +6 -0
- package/src/lib/session/session.integration.test.ts +3 -0
- package/src/lib/session/session.ts +4 -0
- package/src/lib/session/types.ts +7 -0
- package/src/lib/thread/proxy.ts +1 -0
- package/src/lib/types.ts +1 -0
- package/src/lib/virtual-fs/manager.ts +3 -3
- package/src/lib/virtual-fs/proxy.ts +3 -3
- package/src/lib/virtual-fs/types.ts +1 -2
- package/src/lib/virtual-fs/with-virtual-fs.ts +4 -4
- package/src/workflow.ts +3 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
2
|
import Anthropic from '@anthropic-ai/sdk';
|
|
3
|
-
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-
|
|
3
|
+
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-NJDyMyUx.cjs';
|
|
4
4
|
|
|
5
5
|
/** SDK-native content type for Anthropic human messages */
|
|
6
6
|
type AnthropicContent = string | Anthropic.Messages.ContentBlockParam[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
2
|
import { MessageContent, StoredMessage, BaseMessage } from '@langchain/core/messages';
|
|
3
|
-
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-
|
|
3
|
+
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-NJDyMyUx.cjs';
|
|
4
4
|
|
|
5
5
|
/** SDK-native content type for LangChain human messages */
|
|
6
6
|
type LangChainContent = string | MessageContent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
2
|
import { MessageContent, StoredMessage, BaseMessage } from '@langchain/core/messages';
|
|
3
|
-
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-
|
|
3
|
+
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BxiT8w9d.js';
|
|
4
4
|
|
|
5
5
|
/** SDK-native content type for LangChain human messages */
|
|
6
6
|
type LangChainContent = string | MessageContent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
2
|
import Anthropic from '@anthropic-ai/sdk';
|
|
3
|
-
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-
|
|
3
|
+
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BxiT8w9d.js';
|
|
4
4
|
|
|
5
5
|
/** SDK-native content type for Anthropic human messages */
|
|
6
6
|
type AnthropicContent = string | Anthropic.Messages.ContentBlockParam[];
|
|
@@ -578,8 +578,7 @@ type PrefixedVirtualFsOps<TPrefix extends string, TCtx = unknown, TMeta = FileEn
|
|
|
578
578
|
*/
|
|
579
579
|
interface VirtualFsState<TCtx = unknown, TMeta = FileEntryMetadata> {
|
|
580
580
|
fileTree: FileEntry<TMeta>[];
|
|
581
|
-
|
|
582
|
-
workspaceBase?: string;
|
|
581
|
+
virtualFsCtx: TCtx;
|
|
583
582
|
/** In-memory file contents keyed by path, bypassing the resolver (e.g. skill resources). */
|
|
584
583
|
inlineFiles?: Record<string, string>;
|
|
585
584
|
}
|
|
@@ -608,6 +607,7 @@ interface BaseAgentState {
|
|
|
608
607
|
fileTree: FileEntry[];
|
|
609
608
|
/** In-memory file contents keyed by path, bypassing the resolver (e.g. skill resources). */
|
|
610
609
|
inlineFiles?: Record<string, string>;
|
|
610
|
+
virtualFsCtx?: unknown;
|
|
611
611
|
systemPrompt?: string;
|
|
612
612
|
totalInputTokens: number;
|
|
613
613
|
totalOutputTokens: number;
|
|
@@ -1055,8 +1055,9 @@ interface ModelInvokerConfig {
|
|
|
1055
1055
|
}
|
|
1056
1056
|
/**
|
|
1057
1057
|
* Generic model invocation contract.
|
|
1058
|
-
* Implementations load the thread, call the LLM,
|
|
1059
|
-
*
|
|
1058
|
+
* Implementations load the thread, call the LLM, and return a normalised
|
|
1059
|
+
* AgentResponse. The caller (workflow) is responsible for appending the
|
|
1060
|
+
* response to the thread with a deterministic ID.
|
|
1060
1061
|
*
|
|
1061
1062
|
* Framework adapters (e.g. `zeitlich/langchain`) provide concrete
|
|
1062
1063
|
* implementations of this type.
|
|
@@ -1078,6 +1079,8 @@ interface ThreadOps<TContent = string> {
|
|
|
1078
1079
|
appendHumanMessage(threadId: string, id: string, content: TContent, threadKey?: string): Promise<void>;
|
|
1079
1080
|
/** Append a tool result to the thread */
|
|
1080
1081
|
appendToolResult(id: string, config: ToolResultConfig): Promise<void>;
|
|
1082
|
+
/** Append the model's response to the thread */
|
|
1083
|
+
appendAgentMessage(threadId: string, id: string, message: unknown, threadKey?: string): Promise<void>;
|
|
1081
1084
|
/** Append a system message to the thread */
|
|
1082
1085
|
appendSystemMessage(threadId: string, id: string, content: string, threadKey?: string): Promise<void>;
|
|
1083
1086
|
/** Copy all messages from sourceThreadId into a new thread at targetThreadId */
|
|
@@ -578,8 +578,7 @@ type PrefixedVirtualFsOps<TPrefix extends string, TCtx = unknown, TMeta = FileEn
|
|
|
578
578
|
*/
|
|
579
579
|
interface VirtualFsState<TCtx = unknown, TMeta = FileEntryMetadata> {
|
|
580
580
|
fileTree: FileEntry<TMeta>[];
|
|
581
|
-
|
|
582
|
-
workspaceBase?: string;
|
|
581
|
+
virtualFsCtx: TCtx;
|
|
583
582
|
/** In-memory file contents keyed by path, bypassing the resolver (e.g. skill resources). */
|
|
584
583
|
inlineFiles?: Record<string, string>;
|
|
585
584
|
}
|
|
@@ -608,6 +607,7 @@ interface BaseAgentState {
|
|
|
608
607
|
fileTree: FileEntry[];
|
|
609
608
|
/** In-memory file contents keyed by path, bypassing the resolver (e.g. skill resources). */
|
|
610
609
|
inlineFiles?: Record<string, string>;
|
|
610
|
+
virtualFsCtx?: unknown;
|
|
611
611
|
systemPrompt?: string;
|
|
612
612
|
totalInputTokens: number;
|
|
613
613
|
totalOutputTokens: number;
|
|
@@ -1055,8 +1055,9 @@ interface ModelInvokerConfig {
|
|
|
1055
1055
|
}
|
|
1056
1056
|
/**
|
|
1057
1057
|
* Generic model invocation contract.
|
|
1058
|
-
* Implementations load the thread, call the LLM,
|
|
1059
|
-
*
|
|
1058
|
+
* Implementations load the thread, call the LLM, and return a normalised
|
|
1059
|
+
* AgentResponse. The caller (workflow) is responsible for appending the
|
|
1060
|
+
* response to the thread with a deterministic ID.
|
|
1060
1061
|
*
|
|
1061
1062
|
* Framework adapters (e.g. `zeitlich/langchain`) provide concrete
|
|
1062
1063
|
* implementations of this type.
|
|
@@ -1078,6 +1079,8 @@ interface ThreadOps<TContent = string> {
|
|
|
1078
1079
|
appendHumanMessage(threadId: string, id: string, content: TContent, threadKey?: string): Promise<void>;
|
|
1079
1080
|
/** Append a tool result to the thread */
|
|
1080
1081
|
appendToolResult(id: string, config: ToolResultConfig): Promise<void>;
|
|
1082
|
+
/** Append the model's response to the thread */
|
|
1083
|
+
appendAgentMessage(threadId: string, id: string, message: unknown, threadKey?: string): Promise<void>;
|
|
1081
1084
|
/** Append a system message to the thread */
|
|
1082
1085
|
appendSystemMessage(threadId: string, id: string, content: string, threadKey?: string): Promise<void>;
|
|
1083
1086
|
/** Copy all messages from sourceThreadId into a new thread at targetThreadId */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ao as ToolMap, _ as SessionConfig, az as ZeitlichSession, Y as SandboxShutdown, ag as ThreadInit, X as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aB as ToolRouterOptions, ar as ToolRouter, R as RouterContext, J as JsonValue, at as ToolWithHandler, v as ParsedToolCallUnion, ap as ToolNames, a6 as SubagentDefinition, a9 as SubagentHooks, aa as SubagentSandboxConfig, a5 as SubagentConfig, ab as SubagentSandboxShutdown, ac as SubagentSessionInput, a7 as SubagentFnResult, a3 as SessionStartHook, $ as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a1 as SessionExitReason, ah as TokenUsage, F as FileEntryMetadata, av as VirtualFileTree, j as TreeMutation, r as FileEntry, aw as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, am as ToolHandler, ay as WorkflowTask, c as ActivityToolHandler } from './types-
|
|
1
|
+
import { ao as ToolMap, _ as SessionConfig, az as ZeitlichSession, Y as SandboxShutdown, ag as ThreadInit, X as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aB as ToolRouterOptions, ar as ToolRouter, R as RouterContext, J as JsonValue, at as ToolWithHandler, v as ParsedToolCallUnion, ap as ToolNames, a6 as SubagentDefinition, a9 as SubagentHooks, aa as SubagentSandboxConfig, a5 as SubagentConfig, ab as SubagentSandboxShutdown, ac as SubagentSessionInput, a7 as SubagentFnResult, a3 as SessionStartHook, $ as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a1 as SessionExitReason, ah as TokenUsage, e as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, av as VirtualFileTree, j as TreeMutation, r as FileEntry, aw as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, am as ToolHandler, ay as WorkflowTask, c as ActivityToolHandler } from './types-CheCTLeV.js';
|
|
2
2
|
import { g as SandboxOps } from './types-AujBIMMn.js';
|
|
3
3
|
import z$1, { z } from 'zod';
|
|
4
4
|
import { Sinks, proxyActivities } from '@temporalio/workflow';
|
|
@@ -405,6 +405,34 @@ interface ZeitlichObservabilitySinks extends Sinks {
|
|
|
405
405
|
};
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
+
/**
|
|
409
|
+
* Workflow-safe proxy for runAgent activities with LLM-optimised defaults.
|
|
410
|
+
*
|
|
411
|
+
* Resolves the activity name from the scope using the same convention as
|
|
412
|
+
* {@link createRunAgentActivity}: `run<Scope>`.
|
|
413
|
+
* When no scope is provided, defaults to `workflowInfo().workflowType`.
|
|
414
|
+
*
|
|
415
|
+
* Import this from `zeitlich/workflow` in your Temporal workflow files.
|
|
416
|
+
*
|
|
417
|
+
* @typeParam M - SDK-native message type (e.g. `StoredMessage` for LangChain,
|
|
418
|
+
* `Anthropic.Messages.Message` for Anthropic, `Content` for Google GenAI).
|
|
419
|
+
* Must be provided for `SessionResult.finalMessage` to be correctly typed.
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```typescript
|
|
423
|
+
* import { proxyRunAgent } from 'zeitlich/workflow';
|
|
424
|
+
* import type { StoredMessage } from '@langchain/core/messages';
|
|
425
|
+
*
|
|
426
|
+
* // Auto-scoped to the current workflow name
|
|
427
|
+
* const runAgent = proxyRunAgent<StoredMessage>();
|
|
428
|
+
*
|
|
429
|
+
* // Explicit scope for subagents
|
|
430
|
+
* const runResearcher = proxyRunAgent<StoredMessage>("Researcher");
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
|
|
434
|
+
declare function proxyRunAgent<M = unknown>(scope?: string, options?: Parameters<typeof proxyActivities>[0]): (config: RunAgentConfig) => Promise<AgentResponse<M>>;
|
|
435
|
+
|
|
408
436
|
/**
|
|
409
437
|
* Apply a list of {@link TreeMutation}s to the `fileTree` stored in a state
|
|
410
438
|
* manager instance, updating it in place and returning the new tree.
|
|
@@ -747,4 +775,4 @@ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQue
|
|
|
747
775
|
}[];
|
|
748
776
|
}>;
|
|
749
777
|
|
|
750
|
-
export {
|
|
778
|
+
export { proxyRunAgent as $, type AskUserQuestionArgs as A, type BashArgs as B, createTaskListHandler as C, createTaskUpdateHandler as D, createToolRouter as E, type FileEditArgs as F, type GlobArgs as G, defineSubagent as H, defineSubagentWorkflow as I, defineTool as J, defineWorkflow as K, editTool as L, filesWithMimeType as M, formatVirtualFileTree as N, type ObservabilityHooks as O, getShortId as P, globTool as Q, type ReadSkillArgs as R, type SessionEndedEvent as S, type TaskCreateArgs as T, grepTool as U, hasDirectory as V, type WorkflowConfig as W, hasFileWithMimeType as X, hasNoOtherToolCalls as Y, type ZeitlichObservabilitySinks as Z, parseSkillFile as _, type FileReadArgs as a, proxyVirtualFsOps as a0, readFileTool as a1, taskCreateTool as a2, taskGetTool as a3, taskListTool as a4, taskUpdateTool as a5, writeFileTool as a6, type FileWriteArgs as b, type FileTreeAccessor as c, type GrepArgs as d, type SessionStartedEvent as e, type SubagentArgs as f, type TaskGetArgs as g, type TaskListArgs as h, type TaskUpdateArgs as i, type ToolExecutedEvent as j, type TurnCompletedEvent as k, type WorkflowInput as l, type WorkflowSessionInput as m, applyVirtualTreeMutations as n, askUserQuestionTool as o, bashTool as p, composeHooks as q, createAgentStateManager as r, createAskUserQuestionHandler as s, createBashToolDescription as t, createObservabilityHooks as u, createReadSkillHandler as v, createReadSkillTool as w, createSession as x, createTaskCreateHandler as y, createTaskGetHandler as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ao as ToolMap, _ as SessionConfig, az as ZeitlichSession, Y as SandboxShutdown, ag as ThreadInit, X as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aB as ToolRouterOptions, ar as ToolRouter, R as RouterContext, J as JsonValue, at as ToolWithHandler, v as ParsedToolCallUnion, ap as ToolNames, a6 as SubagentDefinition, a9 as SubagentHooks, aa as SubagentSandboxConfig, a5 as SubagentConfig, ab as SubagentSandboxShutdown, ac as SubagentSessionInput, a7 as SubagentFnResult, a3 as SessionStartHook, $ as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a1 as SessionExitReason, ah as TokenUsage, F as FileEntryMetadata, av as VirtualFileTree, j as TreeMutation, r as FileEntry, aw as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, am as ToolHandler, ay as WorkflowTask, c as ActivityToolHandler } from './types-
|
|
1
|
+
import { ao as ToolMap, _ as SessionConfig, az as ZeitlichSession, Y as SandboxShutdown, ag as ThreadInit, X as SandboxInit, t as JsonSerializable, B as BaseAgentState, o as AgentStateManager, aB as ToolRouterOptions, ar as ToolRouter, R as RouterContext, J as JsonValue, at as ToolWithHandler, v as ParsedToolCallUnion, ap as ToolNames, a6 as SubagentDefinition, a9 as SubagentHooks, aa as SubagentSandboxConfig, a5 as SubagentConfig, ab as SubagentSandboxShutdown, ac as SubagentSessionInput, a7 as SubagentFnResult, a3 as SessionStartHook, $ as SessionEndHook, D as PostToolUseHook, y as PostToolUseFailureHook, a1 as SessionExitReason, ah as TokenUsage, e as RunAgentConfig, A as AgentResponse, F as FileEntryMetadata, av as VirtualFileTree, j as TreeMutation, r as FileEntry, aw as VirtualFsOps, g as SkillMetadata, h as Skill, b as ToolHandlerResponse, am as ToolHandler, ay as WorkflowTask, c as ActivityToolHandler } from './types-Bpq5fDI5.cjs';
|
|
2
2
|
import { g as SandboxOps } from './types-AujBIMMn.cjs';
|
|
3
3
|
import z$1, { z } from 'zod';
|
|
4
4
|
import { Sinks, proxyActivities } from '@temporalio/workflow';
|
|
@@ -405,6 +405,34 @@ interface ZeitlichObservabilitySinks extends Sinks {
|
|
|
405
405
|
};
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
+
/**
|
|
409
|
+
* Workflow-safe proxy for runAgent activities with LLM-optimised defaults.
|
|
410
|
+
*
|
|
411
|
+
* Resolves the activity name from the scope using the same convention as
|
|
412
|
+
* {@link createRunAgentActivity}: `run<Scope>`.
|
|
413
|
+
* When no scope is provided, defaults to `workflowInfo().workflowType`.
|
|
414
|
+
*
|
|
415
|
+
* Import this from `zeitlich/workflow` in your Temporal workflow files.
|
|
416
|
+
*
|
|
417
|
+
* @typeParam M - SDK-native message type (e.g. `StoredMessage` for LangChain,
|
|
418
|
+
* `Anthropic.Messages.Message` for Anthropic, `Content` for Google GenAI).
|
|
419
|
+
* Must be provided for `SessionResult.finalMessage` to be correctly typed.
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```typescript
|
|
423
|
+
* import { proxyRunAgent } from 'zeitlich/workflow';
|
|
424
|
+
* import type { StoredMessage } from '@langchain/core/messages';
|
|
425
|
+
*
|
|
426
|
+
* // Auto-scoped to the current workflow name
|
|
427
|
+
* const runAgent = proxyRunAgent<StoredMessage>();
|
|
428
|
+
*
|
|
429
|
+
* // Explicit scope for subagents
|
|
430
|
+
* const runResearcher = proxyRunAgent<StoredMessage>("Researcher");
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
|
|
434
|
+
declare function proxyRunAgent<M = unknown>(scope?: string, options?: Parameters<typeof proxyActivities>[0]): (config: RunAgentConfig) => Promise<AgentResponse<M>>;
|
|
435
|
+
|
|
408
436
|
/**
|
|
409
437
|
* Apply a list of {@link TreeMutation}s to the `fileTree` stored in a state
|
|
410
438
|
* manager instance, updating it in place and returning the new tree.
|
|
@@ -747,4 +775,4 @@ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQue
|
|
|
747
775
|
}[];
|
|
748
776
|
}>;
|
|
749
777
|
|
|
750
|
-
export {
|
|
778
|
+
export { proxyRunAgent as $, type AskUserQuestionArgs as A, type BashArgs as B, createTaskListHandler as C, createTaskUpdateHandler as D, createToolRouter as E, type FileEditArgs as F, type GlobArgs as G, defineSubagent as H, defineSubagentWorkflow as I, defineTool as J, defineWorkflow as K, editTool as L, filesWithMimeType as M, formatVirtualFileTree as N, type ObservabilityHooks as O, getShortId as P, globTool as Q, type ReadSkillArgs as R, type SessionEndedEvent as S, type TaskCreateArgs as T, grepTool as U, hasDirectory as V, type WorkflowConfig as W, hasFileWithMimeType as X, hasNoOtherToolCalls as Y, type ZeitlichObservabilitySinks as Z, parseSkillFile as _, type FileReadArgs as a, proxyVirtualFsOps as a0, readFileTool as a1, taskCreateTool as a2, taskGetTool as a3, taskListTool as a4, taskUpdateTool as a5, writeFileTool as a6, type FileWriteArgs as b, type FileTreeAccessor as c, type GrepArgs as d, type SessionStartedEvent as e, type SubagentArgs as f, type TaskGetArgs as g, type TaskListArgs as h, type TaskUpdateArgs as i, type ToolExecutedEvent as j, type TurnCompletedEvent as k, type WorkflowInput as l, type WorkflowSessionInput as m, applyVirtualTreeMutations as n, askUserQuestionTool as o, bashTool as p, composeHooks as q, createAgentStateManager as r, createAskUserQuestionHandler as s, createBashToolDescription as t, createObservabilityHooks as u, createReadSkillHandler as v, createReadSkillTool as w, createSession as x, createTaskCreateHandler as y, createTaskGetHandler as z };
|
package/dist/workflow.cjs
CHANGED
|
@@ -731,6 +731,7 @@ async function createSession({
|
|
|
731
731
|
appendHumanMessage,
|
|
732
732
|
initializeThread,
|
|
733
733
|
appendSystemMessage,
|
|
734
|
+
appendAgentMessage,
|
|
734
735
|
forkThread
|
|
735
736
|
} = threadOps;
|
|
736
737
|
const plugins = [];
|
|
@@ -852,6 +853,7 @@ async function createSession({
|
|
|
852
853
|
] : result.fileTree;
|
|
853
854
|
stateManager.mergeUpdate({
|
|
854
855
|
fileTree,
|
|
856
|
+
virtualFsCtx: virtualFsConfig.ctx,
|
|
855
857
|
...skillFiles && { inlineFiles: skillFiles }
|
|
856
858
|
});
|
|
857
859
|
}
|
|
@@ -905,6 +907,7 @@ async function createSession({
|
|
|
905
907
|
agentName,
|
|
906
908
|
metadata
|
|
907
909
|
});
|
|
910
|
+
await appendAgentMessage(threadId, workflow.uuid4(), message, threadKey);
|
|
908
911
|
if (usage) {
|
|
909
912
|
stateManager.updateUsage(usage);
|
|
910
913
|
}
|
|
@@ -1331,6 +1334,23 @@ function composeHooks(...fns) {
|
|
|
1331
1334
|
return lastResult;
|
|
1332
1335
|
};
|
|
1333
1336
|
}
|
|
1337
|
+
function proxyRunAgent(scope, options) {
|
|
1338
|
+
const resolvedScope = scope ?? workflow.workflowInfo().workflowType;
|
|
1339
|
+
const name = `run${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;
|
|
1340
|
+
const acts = workflow.proxyActivities(
|
|
1341
|
+
options ?? {
|
|
1342
|
+
startToCloseTimeout: "10m",
|
|
1343
|
+
heartbeatTimeout: "1m",
|
|
1344
|
+
retry: {
|
|
1345
|
+
maximumAttempts: 3,
|
|
1346
|
+
initialInterval: "10s",
|
|
1347
|
+
maximumInterval: "2m",
|
|
1348
|
+
backoffCoefficient: 3
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
);
|
|
1352
|
+
return acts[name];
|
|
1353
|
+
}
|
|
1334
1354
|
var SandboxNotSupportedError = class extends common.ApplicationFailure {
|
|
1335
1355
|
constructor(operation) {
|
|
1336
1356
|
super(
|
|
@@ -1470,7 +1490,7 @@ function proxyVirtualFsOps(scope, options) {
|
|
|
1470
1490
|
}
|
|
1471
1491
|
}
|
|
1472
1492
|
);
|
|
1473
|
-
const prefix = resolvedScope
|
|
1493
|
+
const prefix = `virtualFs${resolvedScope.charAt(0).toUpperCase()}${resolvedScope.slice(1)}`;
|
|
1474
1494
|
const p = (key) => `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;
|
|
1475
1495
|
return {
|
|
1476
1496
|
resolveFileTree: acts[p("resolveFileTree")]
|
|
@@ -1934,6 +1954,7 @@ exports.hasFileWithMimeType = hasFileWithMimeType;
|
|
|
1934
1954
|
exports.hasNoOtherToolCalls = hasNoOtherToolCalls;
|
|
1935
1955
|
exports.isTerminalStatus = isTerminalStatus;
|
|
1936
1956
|
exports.parseSkillFile = parseSkillFile;
|
|
1957
|
+
exports.proxyRunAgent = proxyRunAgent;
|
|
1937
1958
|
exports.proxyVirtualFsOps = proxyVirtualFsOps;
|
|
1938
1959
|
exports.readFileTool = readFileTool;
|
|
1939
1960
|
exports.taskCreateTool = taskCreateTool;
|