zeitlich 0.2.11 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +313 -126
  2. package/dist/adapters/langchain/index.cjs +270 -0
  3. package/dist/adapters/langchain/index.cjs.map +1 -0
  4. package/dist/adapters/langchain/index.d.cts +132 -0
  5. package/dist/adapters/langchain/index.d.ts +132 -0
  6. package/dist/adapters/langchain/index.js +265 -0
  7. package/dist/adapters/langchain/index.js.map +1 -0
  8. package/dist/index.cjs +89 -209
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +62 -46
  11. package/dist/index.d.ts +62 -46
  12. package/dist/index.js +88 -208
  13. package/dist/index.js.map +1 -1
  14. package/dist/{workflow-BhjsEQc1.d.cts → model-invoker-y_zlyMqu.d.cts} +45 -482
  15. package/dist/{workflow-BhjsEQc1.d.ts → model-invoker-y_zlyMqu.d.ts} +45 -482
  16. package/dist/thread-manager-qc0g5Rvd.d.cts +39 -0
  17. package/dist/thread-manager-qc0g5Rvd.d.ts +39 -0
  18. package/dist/workflow.cjs +59 -27
  19. package/dist/workflow.cjs.map +1 -1
  20. package/dist/workflow.d.cts +459 -6
  21. package/dist/workflow.d.ts +459 -6
  22. package/dist/workflow.js +60 -29
  23. package/dist/workflow.js.map +1 -1
  24. package/package.json +17 -2
  25. package/src/adapters/langchain/activities.ts +120 -0
  26. package/src/adapters/langchain/index.ts +38 -0
  27. package/src/adapters/langchain/model-invoker.ts +102 -0
  28. package/src/adapters/langchain/thread-manager.ts +142 -0
  29. package/src/index.ts +24 -23
  30. package/src/lib/fs.ts +25 -0
  31. package/src/lib/model-invoker.ts +15 -75
  32. package/src/lib/session.ts +52 -21
  33. package/src/lib/state-manager.ts +23 -5
  34. package/src/lib/thread-id.ts +25 -0
  35. package/src/lib/thread-manager.ts +18 -142
  36. package/src/lib/tool-router.ts +12 -18
  37. package/src/lib/types.ts +26 -10
  38. package/src/lib/workflow-helpers.ts +50 -0
  39. package/src/tools/ask-user-question/handler.ts +25 -1
  40. package/src/tools/bash/handler.ts +13 -0
  41. package/src/tools/subagent/handler.ts +16 -5
  42. package/src/tools/subagent/tool.ts +34 -15
  43. package/src/workflow.ts +26 -7
  44. package/tsup.config.ts +1 -0
  45. package/src/activities.ts +0 -91
  46. package/src/plugin.ts +0 -28
@@ -1,76 +1,5 @@
1
- import { QueryDefinition, proxyActivities } from '@temporalio/workflow';
2
- import Redis from 'ioredis';
3
- import { $InferMessageContent, MessageStructure, StoredMessage, MessageContent } from '@langchain/core/messages';
4
1
  import z, { z as z$1 } from 'zod';
5
2
  import { Duration } from '@temporalio/common';
6
- import { UpdateDefinition } from '@temporalio/common/lib/interfaces';
7
-
8
- /**
9
- * Content for a tool message response.
10
- * Can be a simple string or complex content parts (text, images, cache points, etc.)
11
- */
12
- type ToolMessageContent = $InferMessageContent<MessageStructure, "tool">;
13
- interface ThreadManagerConfig<T = StoredMessage> {
14
- redis: Redis;
15
- threadId: string;
16
- /** Thread key, defaults to 'messages' */
17
- key?: string;
18
- /** Custom serializer, defaults to JSON.stringify */
19
- serialize?: (message: T) => string;
20
- /** Custom deserializer, defaults to JSON.parse */
21
- deserialize?: (raw: string) => T;
22
- /**
23
- * Extract a unique id from a message for idempotent appends.
24
- * When provided, `append` uses an atomic Lua script to skip duplicate writes.
25
- * Defaults to `StoredMessage.data.id` for the standard ThreadManager.
26
- */
27
- idOf?: (message: T) => string;
28
- }
29
- /** Generic thread manager for any message type */
30
- interface BaseThreadManager<T> {
31
- /** Initialize an empty thread */
32
- initialize(): Promise<void>;
33
- /** Load all messages from the thread */
34
- load(): Promise<T[]>;
35
- /**
36
- * Append messages to the thread.
37
- * When `idOf` is configured, appends are idempotent — retries with the
38
- * same message ids are atomically skipped via a Redis Lua script.
39
- */
40
- append(messages: T[]): Promise<void>;
41
- /** Delete the thread */
42
- delete(): Promise<void>;
43
- }
44
- /** Thread manager with StoredMessage convenience helpers */
45
- interface ThreadManager extends BaseThreadManager<StoredMessage> {
46
- /** Create a HumanMessage (returns StoredMessage for storage) */
47
- createHumanMessage(content: string | MessageContent): StoredMessage;
48
- /** Create a SystemMessage (returns StoredMessage for storage) */
49
- createSystemMessage(content: string): StoredMessage;
50
- /** Create an AIMessage with optional additional kwargs */
51
- createAIMessage(content: string | MessageContent, kwargs?: {
52
- header?: string;
53
- options?: string[];
54
- multiSelect?: boolean;
55
- }): StoredMessage;
56
- /** Create a ToolMessage */
57
- createToolMessage(content: ToolMessageContent, toolCallId: string): StoredMessage;
58
- /** Create and append a HumanMessage */
59
- appendHumanMessage(content: string | MessageContent): Promise<void>;
60
- /** Create and append a SystemMessage */
61
- appendSystemMessage(content: string): Promise<void>;
62
- /** Create and append a ToolMessage */
63
- appendToolMessage(content: ToolMessageContent, toolCallId: string): Promise<void>;
64
- /** Create and append an AIMessage */
65
- appendAIMessage(content: string | MessageContent): Promise<void>;
66
- }
67
- /**
68
- * Creates a thread manager for handling conversation state in Redis.
69
- * Without generic args, returns a full ThreadManager with StoredMessage helpers.
70
- * With a custom type T, returns a BaseThreadManager<T>.
71
- */
72
- declare function createThreadManager(config: ThreadManagerConfig): ThreadManager;
73
- declare function createThreadManager<T>(config: ThreadManagerConfig<T>): BaseThreadManager<T>;
74
3
 
75
4
  /**
76
5
  * Skill metadata — the lightweight subset loaded at startup for all skills.
@@ -112,6 +41,7 @@ interface SkillProvider {
112
41
  getSkill(name: string): Promise<Skill>;
113
42
  }
114
43
 
44
+ declare const SUBAGENT_TOOL_NAME: "Subagent";
115
45
  /**
116
46
  * Creates a Subagent tool configured with the available subagents.
117
47
  *
@@ -129,13 +59,9 @@ interface SkillProvider {
129
59
  * ]);
130
60
  */
131
61
  declare function createSubagentTool<T extends SubagentConfig[]>(subagents: T): {
132
- name: string;
133
- description: string;
134
- schema: z.ZodObject<{
135
- subagent: z.ZodEnum<Record<string, string>>;
136
- description: z.ZodString;
137
- prompt: z.ZodString;
138
- }>;
62
+ readonly name: typeof SUBAGENT_TOOL_NAME;
63
+ readonly description: string;
64
+ readonly schema: z.ZodObject<z.ZodRawShape>;
139
65
  };
140
66
  /**
141
67
  * Subagent tool args type (when subagent names are not known at compile time)
@@ -144,6 +70,7 @@ type SubagentArgs = {
144
70
  subagent: string;
145
71
  description: string;
146
72
  prompt: string;
73
+ threadId?: string;
147
74
  };
148
75
 
149
76
  /**
@@ -242,6 +169,8 @@ interface ToolHandlerResponse<TResult = null> {
242
169
  resultAppended?: boolean;
243
170
  /** Token usage from the tool execution (e.g. child agent invocations) */
244
171
  usage?: TokenUsage;
172
+ /** Thread ID used by the handler (surfaced to the LLM for subagent thread continuation) */
173
+ threadId?: string;
245
174
  }
246
175
  /**
247
176
  * Context passed to tool handlers for additional data beyond tool args.
@@ -494,14 +423,14 @@ declare function defineSubagent<TResult extends z$1.ZodType = z$1.ZodType, TCont
494
423
  workflow: string | ((input: {
495
424
  prompt: string;
496
425
  context: TContext;
497
- }) => Promise<any>);
426
+ }) => Promise<ToolHandlerResponse<z$1.infer<TResult> | null>>);
498
427
  context: TContext;
499
428
  hooks?: SubagentHooks<SubagentArgs, z$1.infer<TResult>>;
500
429
  }): SubagentConfig<TResult>;
501
430
  declare function defineSubagent<TResult extends z$1.ZodType = z$1.ZodType>(config: Omit<SubagentConfig<TResult>, "hooks" | "workflow"> & {
502
431
  workflow: string | ((input: {
503
432
  prompt: string;
504
- }) => Promise<any>);
433
+ }) => Promise<ToolHandlerResponse<z$1.infer<TResult> | null>>);
505
434
  hooks?: SubagentHooks<SubagentArgs, z$1.infer<TResult>>;
506
435
  }): SubagentConfig<TResult>;
507
436
  /**
@@ -509,6 +438,15 @@ declare function defineSubagent<TResult extends z$1.ZodType = z$1.ZodType>(confi
509
438
  */
510
439
  declare function hasNoOtherToolCalls<T extends ToolMap>(toolCalls: ParsedToolCallUnion<T>[], excludeName: ToolNames<T>): boolean;
511
440
 
441
+ /** A single content part within a structured message (text, image, etc.) */
442
+ type ContentPart = {
443
+ type: string;
444
+ [key: string]: unknown;
445
+ };
446
+ /** Message content — plain string or an array of structured content parts */
447
+ type MessageContent = string | ContentPart[];
448
+ /** Content returned by a tool handler */
449
+ type ToolMessageContent = MessageContent;
512
450
  /**
513
451
  * Agent execution status
514
452
  */
@@ -526,7 +464,7 @@ interface BaseAgentState {
526
464
  totalInputTokens: number;
527
465
  totalOutputTokens: number;
528
466
  cachedWriteTokens: number;
529
- cachedReadtTokens: number;
467
+ cachedReadTokens: number;
530
468
  }
531
469
  /**
532
470
  * File representation for agent workflows
@@ -553,7 +491,7 @@ interface TokenUsage {
553
491
  /**
554
492
  * Agent response from LLM invocation
555
493
  */
556
- interface AgentResponse<M = StoredMessage> {
494
+ interface AgentResponse<M = unknown> {
557
495
  message: M;
558
496
  rawToolCalls: RawToolCall[];
559
497
  usage?: TokenUsage;
@@ -561,7 +499,6 @@ interface AgentResponse<M = StoredMessage> {
561
499
  /**
562
500
  * Thread operations required by a session.
563
501
  * Consumers provide these — typically by wrapping Temporal activities.
564
- * Use `proxyDefaultThreadOps()` for the default StoredMessage implementation.
565
502
  */
566
503
  interface ThreadOps {
567
504
  /** Initialize an empty thread */
@@ -585,9 +522,9 @@ interface AgentConfig {
585
522
  /**
586
523
  * Configuration for a Zeitlich agent session
587
524
  */
588
- interface SessionConfig<T extends ToolMap, M = StoredMessage> {
589
- /** The thread ID to use for the session */
590
- threadId: string;
525
+ interface SessionConfig<T extends ToolMap, M = unknown> {
526
+ /** The thread ID to use for the session (defaults to a short generated ID) */
527
+ threadId?: string;
591
528
  /** Metadata for the session */
592
529
  metadata?: Record<string, unknown>;
593
530
  /** Whether to append the system prompt as message to the thread */
@@ -613,6 +550,8 @@ interface SessionConfig<T extends ToolMap, M = StoredMessage> {
613
550
  * Returns MessageContent array for the initial HumanMessage.
614
551
  */
615
552
  buildContextMessage: () => MessageContent | Promise<MessageContent>;
553
+ /** When true, skip thread initialization and system prompt — append only the new human message to the existing thread. */
554
+ continueThread?: boolean;
616
555
  /** How long to wait for input before cancelling the workflow */
617
556
  waitForInputTimeout?: Duration;
618
557
  }
@@ -640,7 +579,7 @@ interface RunAgentConfig extends AgentConfig {
640
579
  /**
641
580
  * Type signature for workflow-specific runAgent activity
642
581
  */
643
- type RunAgentActivity<M = StoredMessage> = (config: RunAgentConfig) => Promise<AgentResponse<M>>;
582
+ type RunAgentActivity<M = unknown> = (config: RunAgentConfig) => Promise<AgentResponse<M>>;
644
583
  /**
645
584
  * Configuration for appending a tool result
646
585
  */
@@ -652,7 +591,7 @@ interface ToolResultConfig {
652
591
  /** Content for the tool message (string or complex content parts) */
653
592
  content: ToolMessageContent;
654
593
  }
655
- type SubagentWorkflow<TResult extends z$1.ZodType = z$1.ZodType> = (input: SubagentInput) => Promise<ToolHandlerResponse<TResult | null>>;
594
+ type SubagentWorkflow<TResult extends z$1.ZodType = z$1.ZodType> = (input: SubagentInput) => Promise<ToolHandlerResponse<z$1.infer<TResult> | null>>;
656
595
  /**
657
596
  * Configuration for a subagent that can be spawned by the parent workflow.
658
597
  *
@@ -673,6 +612,8 @@ interface SubagentConfig<TResult extends z$1.ZodType = z$1.ZodType> {
673
612
  resultSchema?: TResult;
674
613
  /** Optional static context passed to the subagent on every invocation */
675
614
  context?: Record<string, unknown>;
615
+ /** Allow the parent agent to pass a threadId for this subagent to continue (default: false) */
616
+ allowThreadContinuation?: boolean;
676
617
  /** Per-subagent lifecycle hooks */
677
618
  hooks?: SubagentHooks;
678
619
  }
@@ -711,6 +652,8 @@ interface SubagentInput {
711
652
  prompt: string;
712
653
  /** Optional context parameters passed from the parent agent */
713
654
  context?: Record<string, unknown>;
655
+ /** When set, the subagent should continue this thread instead of starting a new one */
656
+ threadId?: string;
714
657
  }
715
658
  /**
716
659
  * Status of a workflow task
@@ -926,404 +869,24 @@ declare const agentStateChangeUpdateName: (agentName: string) => `waitFor${strin
926
869
  declare function isTerminalStatus(status: AgentStatus): boolean;
927
870
 
928
871
  /**
929
- * JSON primitive types that Temporal can serialize
872
+ * Configuration passed to a ModelInvoker.
873
+ * Includes the full agent state so adapters can read tools, system prompt,
874
+ * token usage, or any custom state fields for model configuration.
930
875
  */
931
- type JsonPrimitive = string | number | boolean | null | undefined;
932
- /**
933
- * JSON-serializable value (recursive type for Temporal compatibility)
934
- */
935
- type JsonValue = JsonPrimitive | JsonValue[] | {
936
- [key: string]: JsonValue;
937
- };
938
- /**
939
- * Type constraint ensuring T only contains JSON-serializable values.
940
- * Use this for custom state to ensure Temporal workflow compatibility.
941
- *
942
- * Allows: primitives, arrays, plain objects, and JsonValue
943
- * Rejects: functions, symbols, undefined, class instances with methods
944
- */
945
- type JsonSerializable<T> = {
946
- [K in keyof T]: T[K] extends JsonValue ? T[K] : T[K] extends JsonPrimitive ? T[K] : T[K] extends (infer U)[] ? U extends JsonValue ? T[K] : JsonSerializable<U>[] : T[K] extends object ? JsonSerializable<T[K]> : never;
947
- };
948
- /**
949
- * Full state type combining base state with custom state
950
- */
951
- type AgentState<TCustom extends JsonSerializable<TCustom>> = BaseAgentState & TCustom;
952
- /**
953
- * Agent state manager interface
954
- * Note: Temporal handlers must be set up in the workflow file due to
955
- * Temporal's workflow isolation requirements. This manager provides
956
- * the state and helpers needed for those handlers.
957
- */
958
- interface AgentStateManager<TCustom extends JsonSerializable<TCustom>> {
959
- /** Typed query definition registered for this agent's state */
960
- readonly stateQuery: QueryDefinition<AgentState<TCustom>>;
961
- /** Typed update definition registered for waiting on this agent's state change */
962
- readonly stateChangeUpdate: UpdateDefinition<AgentState<TCustom>, [number]>;
963
- /** Get current status */
964
- getStatus(): AgentStatus;
965
- /** Check if agent is running */
966
- isRunning(): boolean;
967
- /** Check if agent is in terminal state */
968
- isTerminal(): boolean;
969
- /** Get current state version */
970
- getVersion(): number;
971
- /** Set status to RUNNING */
972
- run(): void;
973
- /** Set status to WAITING_FOR_INPUT */
974
- waitForInput(): void;
975
- /** Set status to COMPLETED */
976
- complete(): void;
977
- /** Set status to FAILED */
978
- fail(): void;
979
- /** Set status to CANCELLED */
980
- cancel(): void;
981
- /** Increment state version (call after state changes) */
982
- incrementVersion(): void;
983
- /** Increment turns (call after each turn) */
984
- incrementTurns(): void;
985
- /** Get current turns */
986
- getTurns(): number;
987
- /** Get the system prompt */
988
- getSystemPrompt(): string | undefined;
989
- /** Set the system prompt */
990
- setSystemPrompt(newSystemPrompt: string): void;
991
- /** Get a custom state value by key */
992
- get<K extends keyof TCustom>(key: K): TCustom[K];
993
- /** Set a custom state value by key */
994
- set<K extends keyof TCustom>(key: K, value: TCustom[K]): void;
995
- /** Get full state for query handler */
996
- getCurrentState(): AgentState<TCustom>;
997
- /** Check if should return from waitForStateChange */
998
- shouldReturnFromWait(lastKnownVersion: number): boolean;
999
- /** Get all tasks */
1000
- getTasks(): WorkflowTask[];
1001
- /** Get a task by ID */
1002
- getTask(id: string): WorkflowTask | undefined;
1003
- /** Add or update a task */
1004
- setTask(task: WorkflowTask): void;
1005
- /** Delete a task by ID */
1006
- deleteTask(id: string): boolean;
1007
- /** Set the tools (converts Zod schemas to JSON Schema for serialization) */
1008
- setTools(newTools: ToolDefinition[]): void;
1009
- /** Update the usage */
1010
- updateUsage(usage: {
1011
- inputTokens?: number;
1012
- outputTokens?: number;
1013
- cachedWriteTokens?: number;
1014
- cachedReadTokens?: number;
1015
- reasonTokens?: number;
1016
- }): void;
1017
- /** Get the total usage */
1018
- getTotalUsage(): {
1019
- totalInputTokens: number;
1020
- totalOutputTokens: number;
1021
- totalCachedWriteTokens: number;
1022
- totalCachedReadTokens: number;
1023
- totalReasonTokens: number;
1024
- turns: number;
1025
- };
1026
- }
1027
- /**
1028
- * Creates an agent state manager for tracking workflow state.
1029
- *
1030
- * @param initialState - Optional initial values for base and custom state
1031
- * Base state defaults: status="RUNNING", version=0, turns=0, tasks=empty, fileTree=[]
1032
- *
1033
- * Note: Due to Temporal's workflow isolation, handlers must be set up
1034
- * in the workflow file using defineQuery/defineUpdate and setHandler.
1035
- * This manager provides the state and logic needed for those handlers.
1036
- */
1037
- declare function createAgentStateManager<TCustom extends JsonSerializable<TCustom> = Record<string, never>>({ initialState, agentName, }: {
1038
- initialState?: Partial<BaseAgentState> & TCustom;
876
+ interface ModelInvokerConfig {
877
+ threadId: string;
1039
878
  agentName: string;
1040
- }): AgentStateManager<TCustom>;
1041
-
1042
- interface ZeitlichSession<M = unknown> {
1043
- runSession<T extends JsonSerializable<T>>(args: {
1044
- stateManager: AgentStateManager<T>;
1045
- }): Promise<{
1046
- finalMessage: M | null;
1047
- exitReason: SessionExitReason;
1048
- usage: ReturnType<AgentStateManager<T>["getTotalUsage"]>;
1049
- }>;
1050
- }
1051
- /**
1052
- * Session-level hooks for lifecycle events
1053
- */
1054
- interface SessionLifecycleHooks {
1055
- /** Called when session starts */
1056
- onSessionStart?: SessionStartHook;
1057
- /** Called when session ends */
1058
- onSessionEnd?: SessionEndHook;
1059
- }
1060
- declare const createSession: <T extends ToolMap, M = unknown>({ threadId, agentName, maxTurns, metadata, runAgent, threadOps, buildContextMessage, subagents, skills, tools, processToolsInParallel, hooks, appendSystemPrompt, waitForInputTimeout, }: SessionConfig<T, M> & AgentConfig) => Promise<ZeitlichSession<M>>;
1061
- /**
1062
- * Proxy the default ZeitlichSharedActivities as ThreadOps<StoredMessage>.
1063
- * Call this in workflow code for the standard LangChain/StoredMessage setup.
1064
- *
1065
- * @example
1066
- * ```typescript
1067
- * const session = await createSession({
1068
- * threadOps: proxyDefaultThreadOps(),
1069
- * // ...
1070
- * });
1071
- * ```
1072
- */
1073
- declare function proxyDefaultThreadOps(options?: Parameters<typeof proxyActivities>[0]): ThreadOps;
1074
-
1075
- /**
1076
- * Parse a SKILL.md file into its frontmatter fields and markdown body.
1077
- *
1078
- * Handles the limited YAML subset used by the agentskills.io spec:
1079
- * flat key-value pairs plus one-level nested `metadata` map.
1080
- * No external YAML dependency required.
1081
- */
1082
- declare function parseSkillFile(raw: string): {
1083
- frontmatter: SkillMetadata;
1084
- body: string;
1085
- };
1086
-
1087
- /**
1088
- * Creates a ReadSkill tool configured with the available skills.
1089
- * The tool description embeds skill metadata so the agent discovers
1090
- * skills purely through the tool definition.
1091
- */
1092
- declare function createReadSkillTool(skills: Skill[]): {
1093
- name: string;
1094
- description: string;
1095
- schema: z.ZodObject<{
1096
- skill_name: z.ZodEnum<Record<string, string>>;
1097
- }>;
1098
- };
1099
- type ReadSkillArgs = {
1100
- skill_name: string;
1101
- };
1102
-
1103
- /**
1104
- * Creates a ReadSkill handler that looks up skills from an in-memory array.
1105
- * Runs directly in the workflow (like task tools) — no activity needed.
1106
- */
1107
- declare function createReadSkillHandler(skills: Skill[]): (args: ReadSkillArgs) => ToolHandlerResponse<null>;
1108
-
1109
- /**
1110
- * Shared Zeitlich activities - thread management and message handling
1111
- * Note: runAgent is workflow-specific and should be created per-workflow
1112
- */
1113
- interface ZeitlichSharedActivities {
1114
- /**
1115
- * Append a tool result to the thread.
1116
- * Handles JSON serialization and optional cache points.
1117
- */
1118
- appendToolResult(config: ToolResultConfig): Promise<void>;
1119
- /**
1120
- * Initialize an empty thread.
1121
- */
1122
- initializeThread(threadId: string): Promise<void>;
1123
- /**
1124
- * Append messages to a thread.
1125
- */
1126
- appendThreadMessages(threadId: string, messages: StoredMessage[]): Promise<void>;
1127
- /**
1128
- * Append a human message to a thread.
1129
- */
1130
- appendHumanMessage(threadId: string, content: string | MessageContent): Promise<void>;
1131
- /**
1132
- * Append a system message to a thread.
1133
- */
1134
- appendSystemMessage(threadId: string, content: string): Promise<void>;
879
+ state: BaseAgentState;
880
+ metadata?: Record<string, unknown>;
1135
881
  }
1136
882
  /**
1137
- * Creates shared Temporal activities for thread management
1138
- *
1139
- * @returns An object containing the shared activity functions
883
+ * Generic model invocation contract.
884
+ * Implementations load the thread, call the LLM, append the response,
885
+ * and return a normalised AgentResponse.
1140
886
  *
1141
- * @experimental The Zeitlich integration is an experimental feature; APIs may change without notice.
887
+ * Framework adapters (e.g. `zeitlich/langchain`) provide concrete
888
+ * implementations of this type.
1142
889
  */
1143
- declare function createSharedActivities(redis: Redis): ZeitlichSharedActivities;
1144
-
1145
- declare const globTool: {
1146
- name: "Glob";
1147
- description: string;
1148
- schema: z$1.ZodObject<{
1149
- pattern: z$1.ZodString;
1150
- root: z$1.ZodOptional<z$1.ZodString>;
1151
- }, z$1.core.$strip>;
1152
- strict: true;
1153
- };
1154
- type GlobArgs = z$1.infer<typeof globTool.schema>;
1155
-
1156
- declare const grepTool: {
1157
- name: "Grep";
1158
- description: string;
1159
- schema: z$1.ZodObject<{
1160
- pattern: z$1.ZodString;
1161
- ignoreCase: z$1.ZodOptional<z$1.ZodBoolean>;
1162
- maxMatches: z$1.ZodOptional<z$1.ZodNumber>;
1163
- includePatterns: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
1164
- excludePatterns: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
1165
- contextLines: z$1.ZodOptional<z$1.ZodNumber>;
1166
- }, z$1.core.$strip>;
1167
- strict: true;
1168
- };
1169
- type GrepArgs = z$1.infer<typeof grepTool.schema>;
1170
-
1171
- declare const readFileTool: {
1172
- name: "FileRead";
1173
- description: string;
1174
- schema: z$1.ZodObject<{
1175
- path: z$1.ZodString;
1176
- offset: z$1.ZodOptional<z$1.ZodNumber>;
1177
- limit: z$1.ZodOptional<z$1.ZodNumber>;
1178
- }, z$1.core.$strip>;
1179
- strict: true;
1180
- };
1181
- type FileReadArgs = z$1.infer<typeof readFileTool.schema>;
1182
-
1183
- declare const writeFileTool: {
1184
- name: "FileWrite";
1185
- description: string;
1186
- schema: z$1.ZodObject<{
1187
- file_path: z$1.ZodString;
1188
- content: z$1.ZodString;
1189
- }, z$1.core.$strip>;
1190
- strict: true;
1191
- };
1192
- type FileWriteArgs = z$1.infer<typeof writeFileTool.schema>;
1193
-
1194
- declare const editTool: {
1195
- name: "FileEdit";
1196
- description: string;
1197
- schema: z$1.ZodObject<{
1198
- file_path: z$1.ZodString;
1199
- old_string: z$1.ZodString;
1200
- new_string: z$1.ZodString;
1201
- replace_all: z$1.ZodOptional<z$1.ZodBoolean>;
1202
- }, z$1.core.$strip>;
1203
- strict: true;
1204
- };
1205
- type FileEditArgs = z$1.infer<typeof editTool.schema>;
1206
-
1207
- declare const taskCreateTool: {
1208
- name: "TaskCreate";
1209
- description: string;
1210
- schema: z.ZodObject<{
1211
- subject: z.ZodString;
1212
- description: z.ZodString;
1213
- activeForm: z.ZodString;
1214
- metadata: z.ZodRecord<z.ZodString, z.ZodString>;
1215
- }, z.core.$strip>;
1216
- };
1217
- type TaskCreateArgs = z.infer<typeof taskCreateTool.schema>;
1218
-
1219
- /**
1220
- * Creates a TaskCreate handler that adds tasks to the workflow state.
1221
- *
1222
- * @param stateManager - State manager containing tasks state
1223
- * @returns A ToolHandler for TaskCreate tool calls
1224
- */
1225
- declare function createTaskCreateHandler<TCustom extends JsonSerializable<TCustom>>(stateManager: AgentStateManager<TCustom>): ToolHandler<TaskCreateArgs, WorkflowTask>;
1226
-
1227
- declare const taskGetTool: {
1228
- name: "TaskGet";
1229
- description: string;
1230
- schema: z.ZodObject<{
1231
- taskId: z.ZodString;
1232
- }, z.core.$strip>;
1233
- };
1234
- type TaskGetArgs = z.infer<typeof taskGetTool.schema>;
1235
-
1236
- /**
1237
- * Creates a TaskGet handler that retrieves a task by ID.
1238
- *
1239
- * @param stateManager - State manager containing tasks state
1240
- * @returns A ToolHandler for TaskGet tool calls
1241
- */
1242
- declare function createTaskGetHandler<TCustom extends JsonSerializable<TCustom>>(stateManager: AgentStateManager<TCustom>): ToolHandler<TaskGetArgs, WorkflowTask | null>;
1243
-
1244
- declare const taskListTool: {
1245
- name: "TaskList";
1246
- description: string;
1247
- schema: z.ZodObject<{}, z.core.$strip>;
1248
- };
1249
- type TaskListArgs = z.infer<typeof taskListTool.schema>;
1250
-
1251
- /**
1252
- * Creates a TaskList handler that returns all tasks.
1253
- *
1254
- * @param stateManager - State manager containing tasks state
1255
- * @returns A ToolHandler for TaskList tool calls
1256
- */
1257
- declare function createTaskListHandler<TCustom extends JsonSerializable<TCustom>>(stateManager: AgentStateManager<TCustom>): ToolHandler<TaskListArgs, WorkflowTask[]>;
1258
-
1259
- declare const taskUpdateTool: {
1260
- name: "TaskUpdate";
1261
- description: string;
1262
- schema: z.ZodObject<{
1263
- taskId: z.ZodString;
1264
- status: z.ZodEnum<{
1265
- pending: "pending";
1266
- in_progress: "in_progress";
1267
- completed: "completed";
1268
- }>;
1269
- addBlockedBy: z.ZodArray<z.ZodString>;
1270
- addBlocks: z.ZodArray<z.ZodString>;
1271
- }, z.core.$strip>;
1272
- };
1273
- type TaskUpdateArgs = z.infer<typeof taskUpdateTool.schema>;
1274
-
1275
- /**
1276
- * Creates a TaskUpdate handler that modifies task status and dependencies.
1277
- *
1278
- * @param stateManager - State manager containing tasks state
1279
- * @returns A ToolHandler for TaskUpdate tool calls
1280
- */
1281
- declare function createTaskUpdateHandler<TCustom extends JsonSerializable<TCustom>>(stateManager: AgentStateManager<TCustom>): ToolHandler<TaskUpdateArgs, WorkflowTask | null>;
1282
-
1283
- declare const createBashToolDescription: ({ fileTree, }: {
1284
- fileTree: string;
1285
- }) => string;
1286
- declare const bashTool: {
1287
- name: "Bash";
1288
- description: string;
1289
- schema: z.ZodObject<{
1290
- command: z.ZodString;
1291
- }, z.core.$strip>;
1292
- strict: true;
1293
- };
1294
- type BashArgs = z.infer<typeof bashTool.schema>;
1295
-
1296
- declare const askUserQuestionTool: {
1297
- name: "AskUserQuestion";
1298
- description: string;
1299
- schema: z.ZodObject<{
1300
- questions: z.ZodArray<z.ZodObject<{
1301
- question: z.ZodString;
1302
- header: z.ZodString;
1303
- options: z.ZodArray<z.ZodObject<{
1304
- label: z.ZodString;
1305
- description: z.ZodString;
1306
- }, z.core.$strip>>;
1307
- multiSelect: z.ZodBoolean;
1308
- }, z.core.$strip>>;
1309
- }, z.core.$strip>;
1310
- strict: true;
1311
- };
1312
- type AskUserQuestionArgs = z.infer<typeof askUserQuestionTool.schema>;
1313
-
1314
- /**
1315
- * Creates handler for user interaction tool - creates AI messages for display.
1316
- */
1317
- declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQuestionArgs, {
1318
- questions: {
1319
- question: string;
1320
- header: string;
1321
- options: {
1322
- label: string;
1323
- description: string;
1324
- }[];
1325
- multiSelect: boolean;
1326
- }[];
1327
- }>;
890
+ type ModelInvoker<M = unknown> = (config: ModelInvokerConfig) => Promise<AgentResponse<M>>;
1328
891
 
1329
- export { type TaskStatus as $, type AgentResponse as A, type BashArgs as B, type ProcessToolCallsContext as C, type ReadSkillArgs as D, type RunAgentActivity as E, type FileEditArgs as F, type GlobArgs as G, type RunAgentConfig as H, type InferToolResults as I, type JsonPrimitive as J, type SessionEndHook as K, type SessionEndHookContext as L, type SessionExitReason as M, type SessionLifecycleHooks as N, type SessionStartHook as O, type ParsedToolCall as P, type SessionStartHookContext as Q, type RawToolCall as R, type SkillProvider as S, type SubagentArgs as T, type SubagentConfig as U, type SubagentHooks as V, type SubagentInput as W, type SubagentWorkflow as X, type TaskCreateArgs as Y, type TaskGetArgs as Z, type TaskListArgs as _, type ActivityToolHandler as a, type TaskUpdateArgs as a0, type ThreadManager as a1, type ThreadManagerConfig as a2, type ThreadOps as a3, type ToolArgs as a4, type ToolCallResult as a5, type ToolCallResultUnion as a6, type ToolDefinition as a7, type ToolHandler as a8, type ToolHandlerContext as a9, createTaskListHandler as aA, createTaskUpdateHandler as aB, createThreadManager as aC, createToolRouter as aD, defineSubagent as aE, defineTool as aF, editTool as aG, globTool as aH, grepTool as aI, hasNoOtherToolCalls as aJ, isTerminalStatus as aK, parseSkillFile as aL, proxyDefaultThreadOps as aM, readFileTool as aN, taskCreateTool as aO, taskGetTool as aP, taskListTool as aQ, taskUpdateTool as aR, withAutoAppend as aS, writeFileTool as aT, type ToolHandlerResponse as aa, type ToolHooks as ab, type ToolMap as ac, type ToolMessageContent as ad, type ToolNames as ae, type ToolResult as af, type ToolResultConfig as ag, type ToolRouter as ah, type ToolWithHandler as ai, type WorkflowTask as aj, type ZeitlichSession as ak, type ZeitlichSharedActivities as al, agentQueryName as am, agentStateChangeUpdateName as an, askUserQuestionTool as ao, bashTool as ap, createAgentStateManager as aq, createAskUserQuestionHandler as ar, createBashToolDescription as as, createReadSkillHandler as at, createReadSkillTool as au, createSession as av, createSharedActivities as aw, createSubagentTool as ax, createTaskCreateHandler as ay, createTaskGetHandler as az, type SkillMetadata as b, type Skill as c, type AgentConfig as d, type AgentFile as e, type AgentState as f, type AgentStateManager as g, type AgentStatus as h, type AppendToolResultFn as i, type AskUserQuestionArgs as j, type BaseAgentState as k, type BaseThreadManager as l, type FileReadArgs as m, type FileWriteArgs as n, type GrepArgs as o, type JsonSerializable as p, type JsonValue as q, type ParsedToolCallUnion as r, type PostToolUseFailureHook as s, type PostToolUseFailureHookContext as t, type PostToolUseFailureHookResult as u, type PostToolUseHook as v, type PostToolUseHookContext as w, type PreToolUseHook as x, type PreToolUseHookContext as y, type PreToolUseHookResult as z };
892
+ export { type ToolHandlerContext as $, type AgentResponse as A, type BaseAgentState as B, type ContentPart as C, type SessionEndHook as D, type SessionEndHookContext as E, type SessionExitReason as F, type SessionStartHook as G, type Hooks as H, type InferToolResults as I, type SessionStartHookContext as J, type SubagentArgs as K, type SubagentConfig as L, type ModelInvoker as M, type SubagentHooks as N, type SubagentInput as O, type ParsedToolCall as P, type SubagentWorkflow as Q, type RunAgentConfig as R, type SkillProvider as S, type ThreadOps as T, type TaskStatus as U, type TokenUsage as V, type ToolArgs as W, type ToolCallResult as X, type ToolCallResultUnion as Y, type ToolDefinition as Z, type ToolHandler as _, type ModelInvokerConfig as a, type ToolHandlerResponse as a0, type ToolHooks as a1, type ToolMap as a2, type ToolMessageContent as a3, type ToolNames as a4, type ToolResult as a5, type ToolResultConfig as a6, type ToolRouter as a7, type ToolWithHandler as a8, type WorkflowTask as a9, agentQueryName as aa, agentStateChangeUpdateName as ab, createSubagentTool as ac, createToolRouter as ad, defineSubagent as ae, defineTool as af, hasNoOtherToolCalls as ag, isTerminalStatus as ah, withAutoAppend as ai, type ActivityToolHandler as b, type SkillMetadata as c, type Skill as d, type AgentConfig as e, type AgentFile as f, type AgentStatus as g, type AppendToolResultFn as h, type MessageContent as i, type ParsedToolCallUnion as j, type PostHumanMessageAppendHook as k, type PostHumanMessageAppendHookContext as l, type PostToolUseFailureHook as m, type PostToolUseFailureHookContext as n, type PostToolUseFailureHookResult as o, type PostToolUseHook as p, type PostToolUseHookContext as q, type PreHumanMessageAppendHook as r, type PreHumanMessageAppendHookContext as s, type PreToolUseHook as t, type PreToolUseHookContext as u, type PreToolUseHookResult as v, type ProcessToolCallsContext as w, type RawToolCall as x, type RunAgentActivity as y, type SessionConfig as z };