zeitlich 0.2.0 → 0.2.2
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 +5 -2
- package/dist/index.cjs +268 -129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +244 -109
- package/dist/index.js.map +1 -1
- package/dist/{workflow-uVNF7zoe.d.cts → workflow-BQf5EfNN.d.cts} +236 -55
- package/dist/{workflow-uVNF7zoe.d.ts → workflow-BQf5EfNN.d.ts} +236 -55
- package/dist/workflow.cjs +237 -107
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +4 -2
- package/dist/workflow.d.ts +4 -2
- package/dist/workflow.js +214 -86
- package/dist/workflow.js.map +1 -1
- package/package.json +6 -7
- package/src/index.ts +3 -0
- package/src/lib/session.ts +50 -24
- package/src/lib/state-manager.ts +9 -2
- package/src/lib/tool-router.ts +205 -23
- package/src/lib/types.ts +79 -4
- package/src/tools/ask-user-question/handler.ts +1 -1
- package/src/tools/bash/bash.test.ts +31 -31
- package/src/tools/bash/handler.ts +18 -9
- package/src/tools/bash/tool.ts +19 -3
- package/src/tools/edit/handler.ts +14 -14
- package/src/tools/glob/handler.ts +4 -4
- package/src/tools/task/handler.ts +17 -7
- package/src/tools/task/tool.ts +1 -1
- package/src/tools/task-create/handler.ts +7 -10
- package/src/tools/task-get/handler.ts +4 -4
- package/src/tools/task-list/handler.ts +2 -2
- package/src/tools/task-update/handler.ts +4 -4
- package/src/workflow.ts +3 -1
- package/tsup.config.ts +3 -1
|
@@ -1,13 +1,93 @@
|
|
|
1
|
+
import Redis from 'ioredis';
|
|
1
2
|
import { $InferMessageContent, MessageStructure, StoredMessage, MessageContent } from '@langchain/core/messages';
|
|
2
3
|
import z, { z as z$1 } from 'zod';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
4
|
+
import * as _temporalio_common from '@temporalio/common';
|
|
5
|
+
import { BashOptions } from 'just-bash';
|
|
6
|
+
import { Workflow } from '@temporalio/workflow';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Content for a tool message response.
|
|
8
10
|
* Can be a simple string or complex content parts (text, images, cache points, etc.)
|
|
9
11
|
*/
|
|
10
12
|
type ToolMessageContent = $InferMessageContent<MessageStructure, "tool">;
|
|
13
|
+
interface ThreadManagerConfig {
|
|
14
|
+
redis: Redis;
|
|
15
|
+
threadId: string;
|
|
16
|
+
/** Thread key, defaults to 'messages' */
|
|
17
|
+
key?: string;
|
|
18
|
+
}
|
|
19
|
+
interface ThreadManager {
|
|
20
|
+
/** Append a system message to the thread */
|
|
21
|
+
appendSystemMessage(content: string): Promise<void>;
|
|
22
|
+
/** Initialize an empty thread */
|
|
23
|
+
initialize(): Promise<void>;
|
|
24
|
+
/** Load all messages from the thread */
|
|
25
|
+
load(): Promise<StoredMessage[]>;
|
|
26
|
+
/** Append messages to the thread */
|
|
27
|
+
append(messages: StoredMessage[]): Promise<void>;
|
|
28
|
+
/** Delete the thread */
|
|
29
|
+
delete(): Promise<void>;
|
|
30
|
+
/** Create a SystemMessage (returns StoredMessage for storage) */
|
|
31
|
+
createSystemMessage(content: string): StoredMessage;
|
|
32
|
+
/** Create a HumanMessage (returns StoredMessage for storage) */
|
|
33
|
+
createHumanMessage(content: string | MessageContent): StoredMessage;
|
|
34
|
+
/** Create an AIMessage with optional additional kwargs */
|
|
35
|
+
createAIMessage(content: string | MessageContent, kwargs?: {
|
|
36
|
+
header?: string;
|
|
37
|
+
options?: string[];
|
|
38
|
+
multiSelect?: boolean;
|
|
39
|
+
}): StoredMessage;
|
|
40
|
+
/** Create a ToolMessage */
|
|
41
|
+
createToolMessage(content: ToolMessageContent, toolCallId: string): StoredMessage;
|
|
42
|
+
/** Create and append a HumanMessage */
|
|
43
|
+
appendHumanMessage(content: string | MessageContent): Promise<void>;
|
|
44
|
+
/** Create and append a ToolMessage */
|
|
45
|
+
appendToolMessage(content: ToolMessageContent, toolCallId: string): Promise<void>;
|
|
46
|
+
/** Create and append an AIMessage */
|
|
47
|
+
appendAIMessage(content: string | MessageContent): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates a thread manager for handling conversation state in Redis.
|
|
51
|
+
*/
|
|
52
|
+
declare function createThreadManager(config: ThreadManagerConfig): ThreadManager;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Creates a Task tool configured with the available subagents.
|
|
56
|
+
*
|
|
57
|
+
* @param subagents - Array of subagent configurations (must have at least one)
|
|
58
|
+
* @returns A tool definition with dynamic schema based on available subagents
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* const taskTool = createTaskTool([
|
|
62
|
+
* {
|
|
63
|
+
* name: "researcher",
|
|
64
|
+
* description: "Researches topics and gathers information",
|
|
65
|
+
* workflow: "researcherWorkflow",
|
|
66
|
+
* resultSchema: z.object({ findings: z.string() }),
|
|
67
|
+
* },
|
|
68
|
+
* ]);
|
|
69
|
+
*/
|
|
70
|
+
declare function createTaskTool<T extends SubagentConfig[]>(subagents: T): {
|
|
71
|
+
name: string;
|
|
72
|
+
description: string;
|
|
73
|
+
schema: z.ZodObject<{
|
|
74
|
+
subagent: z.ZodEnum<Record<string, string>>;
|
|
75
|
+
description: z.ZodString;
|
|
76
|
+
prompt: z.ZodString;
|
|
77
|
+
}>;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Infer the schema type for a task tool created with specific subagents
|
|
81
|
+
*/
|
|
82
|
+
type TaskToolSchemaType<T extends SubagentConfig[]> = z.infer<ReturnType<typeof createTaskTool<T>>["schema"]>;
|
|
83
|
+
/**
|
|
84
|
+
* Generic task tool schema type (when subagent names are not known at compile time)
|
|
85
|
+
*/
|
|
86
|
+
type GenericTaskToolSchemaType = {
|
|
87
|
+
subagent: string;
|
|
88
|
+
description: string;
|
|
89
|
+
prompt: string;
|
|
90
|
+
};
|
|
11
91
|
|
|
12
92
|
/**
|
|
13
93
|
* JSON primitive types that Temporal can serialize
|
|
@@ -80,9 +160,10 @@ interface AgentStateManager<TCustom extends JsonSerializable<TCustom>> {
|
|
|
80
160
|
setTask(task: WorkflowTask): void;
|
|
81
161
|
/** Delete a task by ID */
|
|
82
162
|
deleteTask(id: string): boolean;
|
|
83
|
-
/** Set the tools */
|
|
163
|
+
/** Set the tools (converts Zod schemas to JSON Schema for serialization) */
|
|
84
164
|
setTools(newTools: ToolDefinition[]): void;
|
|
85
165
|
}
|
|
166
|
+
declare const getStateQuery: _temporalio_common.QueryDefinition<BaseAgentState, [], string>;
|
|
86
167
|
/**
|
|
87
168
|
* Creates an agent state manager for tracking workflow state.
|
|
88
169
|
*
|
|
@@ -125,10 +206,7 @@ type TaskCreateToolSchemaType = z.infer<typeof taskCreateTool.schema>;
|
|
|
125
206
|
* @example
|
|
126
207
|
* const handler = createTaskCreateHandler(stateManager, uuid4);
|
|
127
208
|
*/
|
|
128
|
-
declare function createTaskCreateHandler<TCustom extends JsonSerializable<TCustom>>(
|
|
129
|
-
stateManager: AgentStateManager<TCustom>;
|
|
130
|
-
idGenerator: () => string;
|
|
131
|
-
}): (args: TaskCreateToolSchemaType) => ToolHandlerResponse<WorkflowTask>;
|
|
209
|
+
declare function createTaskCreateHandler<TCustom extends JsonSerializable<TCustom>>(stateManager: AgentStateManager<TCustom>): (args: TaskCreateToolSchemaType) => ToolHandlerResponse<WorkflowTask>;
|
|
132
210
|
|
|
133
211
|
declare const bashTool: {
|
|
134
212
|
name: "Bash";
|
|
@@ -145,7 +223,9 @@ type BashExecOut = {
|
|
|
145
223
|
stderr: string;
|
|
146
224
|
stdout: string;
|
|
147
225
|
};
|
|
148
|
-
|
|
226
|
+
/** BashOptions with `fs` required */
|
|
227
|
+
type BashToolOptions = Required<Pick<BashOptions, "fs">> & Omit<BashOptions, "fs">;
|
|
228
|
+
declare const handleBashTool: (bashOptions: BashToolOptions) => ActivityToolHandler<bashToolSchemaType, BashExecOut | null>;
|
|
149
229
|
|
|
150
230
|
/**
|
|
151
231
|
* A tool definition with a name, description, and Zod schema for arguments.
|
|
@@ -169,6 +249,8 @@ interface ToolWithHandler<TName extends string = string, TSchema extends z$1.Zod
|
|
|
169
249
|
handler: ToolHandler<z$1.infer<TSchema>, TResult, TContext>;
|
|
170
250
|
strict?: boolean;
|
|
171
251
|
max_uses?: number;
|
|
252
|
+
/** Per-tool lifecycle hooks (run in addition to global hooks) */
|
|
253
|
+
hooks?: ToolHooks<z$1.infer<TSchema>, TResult>;
|
|
172
254
|
}
|
|
173
255
|
/**
|
|
174
256
|
* A map of tool keys to tool definitions with handlers.
|
|
@@ -180,6 +262,7 @@ type ToolMap = Record<string, {
|
|
|
180
262
|
handler: (args: any, context: any) => ToolHandlerResponse<any> | Promise<ToolHandlerResponse<any>>;
|
|
181
263
|
strict?: boolean;
|
|
182
264
|
max_uses?: number;
|
|
265
|
+
hooks?: ToolHooks<any, any>;
|
|
183
266
|
}>;
|
|
184
267
|
/**
|
|
185
268
|
* Extract the tool names from a tool map (uses the tool's name property, not the key).
|
|
@@ -216,10 +299,10 @@ type AppendToolResultFn = (config: ToolResultConfig) => Promise<void>;
|
|
|
216
299
|
* Contains the content for the tool message and the result to return from processToolCalls.
|
|
217
300
|
*/
|
|
218
301
|
interface ToolHandlerResponse<TResult> {
|
|
219
|
-
/** Content
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
|
|
302
|
+
/** Content sent back to the LLM as the tool call response */
|
|
303
|
+
toolResponse: ToolMessageContent;
|
|
304
|
+
/** Data returned to the workflow and hooks for further processing */
|
|
305
|
+
data: TResult | null;
|
|
223
306
|
}
|
|
224
307
|
/**
|
|
225
308
|
* Context passed to tool handlers for additional data beyond tool args.
|
|
@@ -279,7 +362,7 @@ type ToolResult<T extends ToolMap, TName extends ToolNames<T>> = Extract<T[keyof
|
|
|
279
362
|
interface ToolCallResult<TName extends string = string, TResult = unknown> {
|
|
280
363
|
toolCallId: string;
|
|
281
364
|
name: TName;
|
|
282
|
-
|
|
365
|
+
data: TResult | null;
|
|
283
366
|
}
|
|
284
367
|
/**
|
|
285
368
|
* Options for creating a tool router.
|
|
@@ -403,6 +486,70 @@ interface ToolRouter<T extends ToolMap> {
|
|
|
403
486
|
* ```
|
|
404
487
|
*/
|
|
405
488
|
declare function createToolRouter<T extends ToolMap>(options: ToolRouterOptions<T>): ToolRouter<T>;
|
|
489
|
+
/**
|
|
490
|
+
* Identity function that creates a generic inference context for a tool definition.
|
|
491
|
+
* TypeScript infers TResult from the handler and flows it to hooks automatically.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```typescript
|
|
495
|
+
* tools: {
|
|
496
|
+
* AskUser: defineTool({
|
|
497
|
+
* ...askUserTool,
|
|
498
|
+
* handler: handleAskUser,
|
|
499
|
+
* hooks: {
|
|
500
|
+
* onPostToolUse: ({ result }) => {
|
|
501
|
+
* // result is correctly typed as the handler's return data type
|
|
502
|
+
* },
|
|
503
|
+
* },
|
|
504
|
+
* }),
|
|
505
|
+
* }
|
|
506
|
+
* ```
|
|
507
|
+
*/
|
|
508
|
+
declare function defineTool<TName extends string, TSchema extends z$1.ZodType, TResult, TContext = ToolHandlerContext>(tool: ToolWithHandler<TName, TSchema, TResult, TContext>): ToolWithHandler<TName, TSchema, TResult, TContext>;
|
|
509
|
+
/**
|
|
510
|
+
* Identity function that provides full type inference for subagent configurations.
|
|
511
|
+
* Verifies the workflow function's input parameters match the configured context,
|
|
512
|
+
* and properly types the lifecycle hooks with Task tool args and inferred result type.
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* ```ts
|
|
516
|
+
* // With typed context — workflow must accept { prompt, context }
|
|
517
|
+
* const researcher = defineSubagent({
|
|
518
|
+
* name: "researcher",
|
|
519
|
+
* description: "Researches topics",
|
|
520
|
+
* workflow: researcherWorkflow, // (input: { prompt: string; context: { apiKey: string } }) => Promise<...>
|
|
521
|
+
* context: { apiKey: "..." },
|
|
522
|
+
* resultSchema: z.object({ findings: z.string() }),
|
|
523
|
+
* hooks: {
|
|
524
|
+
* onPostExecution: ({ result }) => {
|
|
525
|
+
* // result is typed as { findings: string }
|
|
526
|
+
* },
|
|
527
|
+
* },
|
|
528
|
+
* });
|
|
529
|
+
*
|
|
530
|
+
* // Without context — workflow only needs { prompt }
|
|
531
|
+
* const writer = defineSubagent({
|
|
532
|
+
* name: "writer",
|
|
533
|
+
* description: "Writes content",
|
|
534
|
+
* workflow: writerWorkflow, // (input: { prompt: string }) => Promise<...>
|
|
535
|
+
* resultSchema: z.object({ content: z.string() }),
|
|
536
|
+
* });
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
declare function defineSubagent<TResult extends z$1.ZodType = z$1.ZodType, TContext extends Record<string, unknown> = Record<string, unknown>>(config: Omit<SubagentConfig<TResult>, "hooks" | "workflow" | "context"> & {
|
|
540
|
+
workflow: string | ((input: {
|
|
541
|
+
prompt: string;
|
|
542
|
+
context: TContext;
|
|
543
|
+
}) => Promise<any>);
|
|
544
|
+
context: TContext;
|
|
545
|
+
hooks?: SubagentHooks<GenericTaskToolSchemaType, z$1.infer<TResult>>;
|
|
546
|
+
}): SubagentConfig<TResult>;
|
|
547
|
+
declare function defineSubagent<TResult extends z$1.ZodType = z$1.ZodType>(config: Omit<SubagentConfig<TResult>, "hooks" | "workflow"> & {
|
|
548
|
+
workflow: string | ((input: {
|
|
549
|
+
prompt: string;
|
|
550
|
+
}) => Promise<any>);
|
|
551
|
+
hooks?: SubagentHooks<GenericTaskToolSchemaType, z$1.infer<TResult>>;
|
|
552
|
+
}): SubagentConfig<TResult>;
|
|
406
553
|
/**
|
|
407
554
|
* Utility to check if there were no tool calls besides a specific one
|
|
408
555
|
*/
|
|
@@ -416,7 +563,7 @@ type AgentStatus = "RUNNING" | "WAITING_FOR_INPUT" | "COMPLETED" | "FAILED" | "C
|
|
|
416
563
|
* Base state that all agents must have
|
|
417
564
|
*/
|
|
418
565
|
interface BaseAgentState {
|
|
419
|
-
tools:
|
|
566
|
+
tools: SerializableToolDefinition[];
|
|
420
567
|
status: AgentStatus;
|
|
421
568
|
version: number;
|
|
422
569
|
turns: number;
|
|
@@ -490,6 +637,18 @@ interface ZeitlichAgentConfig<T extends ToolMap> {
|
|
|
490
637
|
[K in keyof BuildInToolDefinitions]?: BuildInToolDefinitions[K]["handler"];
|
|
491
638
|
};
|
|
492
639
|
}
|
|
640
|
+
/**
|
|
641
|
+
* A JSON-serializable tool definition for state storage.
|
|
642
|
+
* Uses a plain JSON Schema object instead of a live Zod instance,
|
|
643
|
+
* so it survives Temporal serialization without losing constraints (min, max, etc.).
|
|
644
|
+
*/
|
|
645
|
+
interface SerializableToolDefinition {
|
|
646
|
+
name: string;
|
|
647
|
+
description: string;
|
|
648
|
+
schema: Record<string, unknown>;
|
|
649
|
+
strict?: boolean;
|
|
650
|
+
max_uses?: number;
|
|
651
|
+
}
|
|
493
652
|
/**
|
|
494
653
|
* Configuration passed to runAgent activity
|
|
495
654
|
*/
|
|
@@ -521,12 +680,43 @@ interface SubagentConfig<TResult extends z$1.ZodType = z$1.ZodType> {
|
|
|
521
680
|
name: string;
|
|
522
681
|
/** Description shown to the parent agent explaining what this subagent does */
|
|
523
682
|
description: string;
|
|
524
|
-
/** Temporal workflow type name (used with executeChild) */
|
|
525
|
-
|
|
683
|
+
/** Temporal workflow function or type name (used with executeChild) */
|
|
684
|
+
workflow: string | Workflow;
|
|
526
685
|
/** Optional task queue - defaults to parent's queue if not specified */
|
|
527
686
|
taskQueue?: string;
|
|
528
687
|
/** Optional Zod schema to validate the child workflow's result. If omitted, result is passed through as-is. */
|
|
529
688
|
resultSchema?: TResult;
|
|
689
|
+
/** Optional static context passed to the subagent on every invocation */
|
|
690
|
+
context?: Record<string, unknown>;
|
|
691
|
+
/** Per-subagent lifecycle hooks */
|
|
692
|
+
hooks?: SubagentHooks;
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Per-subagent lifecycle hooks - defined on a SubagentConfig.
|
|
696
|
+
* Runs in addition to global hooks (global pre → subagent pre → execute → subagent post → global post).
|
|
697
|
+
*/
|
|
698
|
+
interface SubagentHooks<TArgs = unknown, TResult = unknown> {
|
|
699
|
+
/** Called before this subagent executes - can skip or modify args */
|
|
700
|
+
onPreExecution?: (ctx: {
|
|
701
|
+
args: TArgs;
|
|
702
|
+
threadId: string;
|
|
703
|
+
turn: number;
|
|
704
|
+
}) => PreToolUseHookResult | Promise<PreToolUseHookResult>;
|
|
705
|
+
/** Called after this subagent executes successfully */
|
|
706
|
+
onPostExecution?: (ctx: {
|
|
707
|
+
args: TArgs;
|
|
708
|
+
result: TResult;
|
|
709
|
+
threadId: string;
|
|
710
|
+
turn: number;
|
|
711
|
+
durationMs: number;
|
|
712
|
+
}) => void | Promise<void>;
|
|
713
|
+
/** Called when this subagent execution fails */
|
|
714
|
+
onExecutionFailure?: (ctx: {
|
|
715
|
+
args: TArgs;
|
|
716
|
+
error: Error;
|
|
717
|
+
threadId: string;
|
|
718
|
+
turn: number;
|
|
719
|
+
}) => PostToolUseFailureHookResult | Promise<PostToolUseFailureHookResult>;
|
|
530
720
|
}
|
|
531
721
|
/**
|
|
532
722
|
* Input passed to child workflows when spawned as subagents
|
|
@@ -534,6 +724,8 @@ interface SubagentConfig<TResult extends z$1.ZodType = z$1.ZodType> {
|
|
|
534
724
|
interface SubagentInput {
|
|
535
725
|
/** The prompt/task from the parent agent */
|
|
536
726
|
prompt: string;
|
|
727
|
+
/** Optional context parameters passed from the parent agent */
|
|
728
|
+
context?: Record<string, unknown>;
|
|
537
729
|
}
|
|
538
730
|
/**
|
|
539
731
|
* Status of a workflow task
|
|
@@ -667,6 +859,33 @@ interface SessionEndHookContext {
|
|
|
667
859
|
* SessionEnd hook - called when session ends
|
|
668
860
|
*/
|
|
669
861
|
type SessionEndHook = (ctx: SessionEndHookContext) => void | Promise<void>;
|
|
862
|
+
/**
|
|
863
|
+
* Per-tool lifecycle hooks - defined directly on a tool definition.
|
|
864
|
+
* Runs in addition to global hooks (global pre → tool pre → execute → tool post → global post).
|
|
865
|
+
*/
|
|
866
|
+
interface ToolHooks<TArgs = unknown, TResult = unknown> {
|
|
867
|
+
/** Called before this tool executes - can skip or modify args */
|
|
868
|
+
onPreToolUse?: (ctx: {
|
|
869
|
+
args: TArgs;
|
|
870
|
+
threadId: string;
|
|
871
|
+
turn: number;
|
|
872
|
+
}) => PreToolUseHookResult | Promise<PreToolUseHookResult>;
|
|
873
|
+
/** Called after this tool executes successfully */
|
|
874
|
+
onPostToolUse?: (ctx: {
|
|
875
|
+
args: TArgs;
|
|
876
|
+
result: TResult | null;
|
|
877
|
+
threadId: string;
|
|
878
|
+
turn: number;
|
|
879
|
+
durationMs: number;
|
|
880
|
+
}) => void | Promise<void>;
|
|
881
|
+
/** Called when this tool execution fails */
|
|
882
|
+
onPostToolUseFailure?: (ctx: {
|
|
883
|
+
args: TArgs;
|
|
884
|
+
error: Error;
|
|
885
|
+
threadId: string;
|
|
886
|
+
turn: number;
|
|
887
|
+
}) => PostToolUseFailureHookResult | Promise<PostToolUseFailureHookResult>;
|
|
888
|
+
}
|
|
670
889
|
/**
|
|
671
890
|
* Combined hooks interface for session lifecycle
|
|
672
891
|
*/
|
|
@@ -703,44 +922,6 @@ interface SessionLifecycleHooks {
|
|
|
703
922
|
}
|
|
704
923
|
declare const createSession: <T extends ToolMap>({ threadId, agentName, maxTurns, metadata, runAgent, baseSystemPrompt, instructionsPrompt, buildContextMessage, buildFileTree, subagents, tools, processToolsInParallel, buildInTools, hooks, }: ZeitlichAgentConfig<T>) => Promise<ZeitlichSession>;
|
|
705
924
|
|
|
706
|
-
/**
|
|
707
|
-
* Creates a Task tool configured with the available subagents.
|
|
708
|
-
*
|
|
709
|
-
* @param subagents - Array of subagent configurations (must have at least one)
|
|
710
|
-
* @returns A tool definition with dynamic schema based on available subagents
|
|
711
|
-
*
|
|
712
|
-
* @example
|
|
713
|
-
* const taskTool = createTaskTool([
|
|
714
|
-
* {
|
|
715
|
-
* name: "researcher",
|
|
716
|
-
* description: "Researches topics and gathers information",
|
|
717
|
-
* workflowType: "researcherWorkflow",
|
|
718
|
-
* resultSchema: z.object({ findings: z.string() }),
|
|
719
|
-
* },
|
|
720
|
-
* ]);
|
|
721
|
-
*/
|
|
722
|
-
declare function createTaskTool<T extends SubagentConfig[]>(subagents: T): {
|
|
723
|
-
name: string;
|
|
724
|
-
description: string;
|
|
725
|
-
schema: z.ZodObject<{
|
|
726
|
-
subagent: z.ZodEnum<Record<string, string>>;
|
|
727
|
-
description: z.ZodString;
|
|
728
|
-
prompt: z.ZodString;
|
|
729
|
-
}>;
|
|
730
|
-
};
|
|
731
|
-
/**
|
|
732
|
-
* Infer the schema type for a task tool created with specific subagents
|
|
733
|
-
*/
|
|
734
|
-
type TaskToolSchemaType<T extends SubagentConfig[]> = z.infer<ReturnType<typeof createTaskTool<T>>["schema"]>;
|
|
735
|
-
/**
|
|
736
|
-
* Generic task tool schema type (when subagent names are not known at compile time)
|
|
737
|
-
*/
|
|
738
|
-
type GenericTaskToolSchemaType = {
|
|
739
|
-
subagent: string;
|
|
740
|
-
description: string;
|
|
741
|
-
prompt: string;
|
|
742
|
-
};
|
|
743
|
-
|
|
744
925
|
/**
|
|
745
926
|
* Result from a task handler execution
|
|
746
927
|
*/
|
|
@@ -938,4 +1119,4 @@ type TaskUpdateToolSchemaType = z.infer<typeof taskUpdateTool.schema>;
|
|
|
938
1119
|
*/
|
|
939
1120
|
declare function createTaskUpdateHandler<TCustom extends JsonSerializable<TCustom>>(stateManager: AgentStateManager<TCustom>): (args: TaskUpdateToolSchemaType) => ToolHandlerResponse<WorkflowTask | null>;
|
|
940
1121
|
|
|
941
|
-
export { type
|
|
1122
|
+
export { type ToolHandlerContext as $, type AgentResponse as A, type BaseAgentState as B, type SessionExitReason as C, type SessionLifecycleHooks as D, type EditToolSchemaType as E, type SessionStartHook as F, type GlobToolSchemaType as G, type SessionStartHookContext as H, type InferToolResults as I, type JsonPrimitive as J, type SubagentConfig as K, type SubagentHooks as L, type SubagentInput as M, type TaskGetToolSchemaType as N, type TaskHandlerResult as O, type ParsedToolCall as P, type TaskStatus as Q, type RawToolCall as R, type SessionEndHook as S, type TaskCreateToolSchemaType as T, type TaskToolSchemaType as U, type TaskUpdateToolSchemaType as V, type ToolArgs as W, type ToolCallResult as X, type ToolCallResultUnion as Y, type ToolDefinition as Z, type ToolHandler as _, type ActivityToolHandler 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, readTool as aA, taskCreateTool as aB, taskGetTool as aC, taskListTool as aD, taskUpdateTool as aE, writeTool as aF, type WriteToolSchemaType as aa, type ZeitlichAgentConfig as ab, type ZeitlichSession as ac, type ZeitlichSharedActivities as ad, askUserQuestionTool as ae, bashTool as af, type bashToolSchemaType as ag, createAgentStateManager as ah, createSession as ai, createSharedActivities as aj, createTaskCreateHandler as ak, createTaskGetHandler as al, createTaskListHandler as am, createTaskTool as an, createTaskUpdateHandler as ao, createThreadManager as ap, createToolRouter as aq, defineSubagent as ar, defineTool as as, editTool as at, getStateQuery as au, globTool as av, grepTool as aw, handleBashTool as ax, hasNoOtherToolCalls as ay, isTerminalStatus as az, type AskUserQuestionToolSchemaType as b, AGENT_HANDLER_NAMES as c, type AgentFile as d, type AgentState as e, type AgentStateManager as f, type AgentStatus as g, type AppendToolResultFn as h, type GenericTaskToolSchemaType as i, type GrepToolSchemaType as j, type JsonSerializable as k, type JsonValue as l, type ParsedToolCallUnion as m, type PostToolUseFailureHook as n, type PostToolUseFailureHookContext as o, type PostToolUseFailureHookResult as p, type PostToolUseHook as q, type PostToolUseHookContext as r, type PreToolUseHook as s, type PreToolUseHookContext as t, type PreToolUseHookResult as u, type ProcessToolCallsContext as v, type ReadToolSchemaType as w, type RunAgentActivity as x, type RunAgentConfig as y, type SessionEndHookContext as z };
|