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
package/dist/index.d.cts CHANGED
@@ -1,60 +1,38 @@
1
- import { A as AgentResponse, a as ActivityToolHandler, G as GlobArgs, F as FileEditArgs, B as BashArgs, S as SkillProvider, b as SkillMetadata, c as Skill } from './workflow-BhjsEQc1.cjs';
2
- export { d as AgentConfig, e as AgentFile, f as AgentState, g as AgentStateManager, h as AgentStatus, i as AppendToolResultFn, j as AskUserQuestionArgs, k as BaseAgentState, l as BaseThreadManager, m as FileReadArgs, n as FileWriteArgs, o as GrepArgs, I as InferToolResults, J as JsonPrimitive, p as JsonSerializable, q as JsonValue, P as ParsedToolCall, r as ParsedToolCallUnion, s as PostToolUseFailureHook, t as PostToolUseFailureHookContext, u as PostToolUseFailureHookResult, v as PostToolUseHook, w as PostToolUseHookContext, x as PreToolUseHook, y as PreToolUseHookContext, z as PreToolUseHookResult, C as ProcessToolCallsContext, R as RawToolCall, D as ReadSkillArgs, E as RunAgentActivity, H as RunAgentConfig, K as SessionEndHook, L as SessionEndHookContext, M as SessionExitReason, N as SessionLifecycleHooks, O as SessionStartHook, Q as SessionStartHookContext, T as SubagentArgs, U as SubagentConfig, V as SubagentHooks, W as SubagentInput, X as SubagentWorkflow, Y as TaskCreateArgs, Z as TaskGetArgs, _ as TaskListArgs, $ as TaskStatus, a0 as TaskUpdateArgs, a1 as ThreadManager, a2 as ThreadManagerConfig, a3 as ThreadOps, a4 as ToolArgs, a5 as ToolCallResult, a6 as ToolCallResultUnion, a7 as ToolDefinition, a8 as ToolHandler, a9 as ToolHandlerContext, aa as ToolHandlerResponse, ab as ToolHooks, ac as ToolMap, ad as ToolMessageContent, ae as ToolNames, af as ToolResult, ag as ToolResultConfig, ah as ToolRouter, ai as ToolWithHandler, aj as WorkflowTask, ak as ZeitlichSession, al as ZeitlichSharedActivities, am as agentQueryName, an as agentStateChangeUpdateName, ao as askUserQuestionTool, ap as bashTool, aq as createAgentStateManager, ar as createAskUserQuestionHandler, as as createBashToolDescription, at as createReadSkillHandler, au as createReadSkillTool, av as createSession, aw as createSharedActivities, ax as createSubagentTool, ay as createTaskCreateHandler, az as createTaskGetHandler, aA as createTaskListHandler, aB as createTaskUpdateHandler, aC as createThreadManager, aD as createToolRouter, aE as defineSubagent, aF as defineTool, aG as editTool, aH as globTool, aI as grepTool, aJ as hasNoOtherToolCalls, aK as isTerminalStatus, aL as parseSkillFile, aM as proxyDefaultThreadOps, aN as readFileTool, aO as taskCreateTool, aP as taskGetTool, aQ as taskListTool, aR as taskUpdateTool, aS as withAutoAppend, aT as writeFileTool } from './workflow-BhjsEQc1.cjs';
3
- import { SimplePlugin } from '@temporalio/plugin';
4
- import Redis from 'ioredis';
1
+ import { GlobArgs, FileEditArgs, BashArgs } from './workflow.cjs';
2
+ export { AgentState, AgentStateManager, AskUserQuestionArgs, FileReadArgs, FileWriteArgs, GrepArgs, JsonPrimitive, JsonSerializable, JsonValue, ReadSkillArgs, SessionLifecycleHooks, TaskCreateArgs, TaskGetArgs, TaskListArgs, TaskUpdateArgs, ZeitlichSession, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, editTool, getShortId, globTool, grepTool, parseSkillFile, proxyDefaultThreadOps, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool } from './workflow.cjs';
3
+ import { M as ModelInvoker, R as RunAgentConfig, A as AgentResponse, b as ActivityToolHandler, S as SkillProvider, c as SkillMetadata, d as Skill } from './model-invoker-y_zlyMqu.cjs';
4
+ export { e as AgentConfig, f as AgentFile, g as AgentStatus, h as AppendToolResultFn, B as BaseAgentState, C as ContentPart, H as Hooks, I as InferToolResults, i as MessageContent, a as ModelInvokerConfig, P as ParsedToolCall, j as ParsedToolCallUnion, k as PostHumanMessageAppendHook, l as PostHumanMessageAppendHookContext, m as PostToolUseFailureHook, n as PostToolUseFailureHookContext, o as PostToolUseFailureHookResult, p as PostToolUseHook, q as PostToolUseHookContext, r as PreHumanMessageAppendHook, s as PreHumanMessageAppendHookContext, t as PreToolUseHook, u as PreToolUseHookContext, v as PreToolUseHookResult, w as ProcessToolCallsContext, x as RawToolCall, y as RunAgentActivity, z as SessionConfig, D as SessionEndHook, E as SessionEndHookContext, F as SessionExitReason, G as SessionStartHook, J as SessionStartHookContext, K as SubagentArgs, L as SubagentConfig, N as SubagentHooks, O as SubagentInput, Q as SubagentWorkflow, U as TaskStatus, T as ThreadOps, V as TokenUsage, W as ToolArgs, X as ToolCallResult, Y as ToolCallResultUnion, Z as ToolDefinition, _ as ToolHandler, $ as ToolHandlerContext, a0 as ToolHandlerResponse, a1 as ToolHooks, a2 as ToolMap, a3 as ToolMessageContent, a4 as ToolNames, a5 as ToolResult, a6 as ToolResultConfig, a7 as ToolRouter, a8 as ToolWithHandler, a9 as WorkflowTask, aa as agentQueryName, ab as agentStateChangeUpdateName, ac as createSubagentTool, ad as createToolRouter, ae as defineSubagent, af as defineTool, ag as hasNoOtherToolCalls, ah as isTerminalStatus, ai as withAutoAppend } from './model-invoker-y_zlyMqu.cjs';
5
+ export { B as BaseThreadManager, T as ThreadManagerConfig, c as createThreadManager } from './thread-manager-qc0g5Rvd.cjs';
5
6
  import { WorkflowClient } from '@temporalio/client';
6
- import { BaseChatModel, BaseChatModelCallOptions, BindToolsInput } from '@langchain/core/language_models/chat_models';
7
7
  import { IFileSystem, BashOptions } from 'just-bash';
8
8
  import '@temporalio/workflow';
9
- import '@langchain/core/messages';
9
+ import '@temporalio/common/lib/interfaces';
10
10
  import 'zod';
11
11
  import '@temporalio/common';
12
- import '@temporalio/common/lib/interfaces';
12
+ import 'ioredis';
13
13
 
14
14
  /**
15
- * Options for the Zeitlich plugin
16
- *
17
- * @experimental The Zeitlich plugin is an experimental feature; APIs may change without notice.
15
+ * Query the parent workflow's state from within an activity.
16
+ * Resolves the workflow handle from the current activity context.
18
17
  */
19
- interface ZeitlichPluginOptions {
20
- redis: Redis;
21
- }
18
+ declare function queryParentWorkflowState<T>(client: WorkflowClient, queryName: string): Promise<T>;
22
19
  /**
23
- * A Temporal plugin that integrates Zeitlich for use in workflows.
24
- * This plugin creates shared activities for thread management.
25
- * Workflow-specific activities (like runAgent) should be created separately.
20
+ * Wraps a `ModelInvoker` into a `RunAgentActivity` by automatically
21
+ * loading tool definitions from the parent workflow state via query.
26
22
  *
27
- * @experimental The Zeitlich plugin is an experimental feature; APIs may change without notice.
28
- */
29
- declare class ZeitlichPlugin extends SimplePlugin {
30
- constructor(options: ZeitlichPluginOptions);
31
- }
32
-
33
- /**
34
- * Configuration for invoking the model
35
- */
36
- interface InvokeModelConfig {
37
- threadId: string;
38
- agentName: string;
39
- }
40
- /**
41
- * Core model invocation logic - shared utility for workflow-specific activities
23
+ * This is the generic bridge between any provider-specific model invoker
24
+ * and the session's `runAgent` contract.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * import { createRunAgentActivity } from 'zeitlich';
29
+ * import { createLangChainModelInvoker } from 'zeitlich/adapters/langchain';
42
30
  *
43
- * @param options - Named options object
44
- * @param options.redis - Redis client for thread management
45
- * @param options.config - Model invocation configuration (threadId, agentName)
46
- * @param options.model - Pre-instantiated LangChain chat model
47
- * @param options.client - Temporal WorkflowClient for querying workflow state
48
- * @returns Agent response with message and metadata
31
+ * const invoker = createLangChainModelInvoker({ redis, model });
32
+ * return { runAgent: createRunAgentActivity(client, invoker) };
33
+ * ```
49
34
  */
50
- declare function invokeModel({ redis, model, client, config: { threadId, agentName }, }: {
51
- redis: Redis;
52
- client: WorkflowClient;
53
- config: InvokeModelConfig;
54
- model: BaseChatModel<BaseChatModelCallOptions & {
55
- tools?: BindToolsInput;
56
- }>;
57
- }): Promise<AgentResponse>;
35
+ declare function createRunAgentActivity<M>(client: WorkflowClient, invoker: ModelInvoker<M>): (config: RunAgentConfig) => Promise<AgentResponse<M>>;
58
36
 
59
37
  /**
60
38
  * Result of a glob operation
@@ -93,8 +71,46 @@ type BashExecOut = {
93
71
  };
94
72
  /** BashOptions with `fs` required */
95
73
  type BashToolOptions = Required<Pick<BashOptions, "fs">> & Omit<BashOptions, "fs">;
74
+ /**
75
+ * Creates a Bash tool handler that executes shell commands in a sandboxed environment.
76
+ *
77
+ * @param bashOptions - Options including a required `fs` (file system implementation from `just-bash`)
78
+ * @returns Activity tool handler for Bash tool calls
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * import { createBashHandler } from 'zeitlich';
83
+ *
84
+ * const bashHandlerActivity = createBashHandler({ fs: inMemoryFileSystem });
85
+ * ```
86
+ */
96
87
  declare const createBashHandler: (bashOptions: BashToolOptions) => ActivityToolHandler<BashArgs, BashExecOut | null>;
97
88
 
89
+ /**
90
+ * Generates a formatted file tree string from an `IFileSystem` instance.
91
+ * Useful for including filesystem context in agent prompts.
92
+ *
93
+ * @param fs - File system implementation (e.g. from `just-bash`)
94
+ * @param opts - Optional configuration for tree generation
95
+ * @param opts.dir - Root directory to start from (defaults to `/`)
96
+ * @param opts.separator - Path separator (`/` or `\\`, defaults to `/`)
97
+ * @param opts.depth - Maximum directory depth (defaults to 10)
98
+ * @param opts.sort - Sort entries alphabetically with directories first (defaults to true)
99
+ * @returns Formatted file tree string
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * import { toTree } from 'zeitlich';
104
+ *
105
+ * const fileTree = await toTree(inMemoryFileSystem);
106
+ * // Returns:
107
+ * // /
108
+ * // ├─ src/
109
+ * // │ ├─ index.ts
110
+ * // │ └─ utils.ts
111
+ * // └─ package.json
112
+ * ```
113
+ */
98
114
  declare const toTree: (fs: IFileSystem, opts?: {
99
115
  dir?: string;
100
116
  separator?: "/" | "\\";
@@ -129,4 +145,4 @@ declare class FileSystemSkillProvider implements SkillProvider {
129
145
  private discoverSkillDirs;
130
146
  }
131
147
 
132
- export { ActivityToolHandler, AgentResponse, BashArgs, FileEditArgs, FileSystemSkillProvider, GlobArgs, type InvokeModelConfig, Skill, SkillMetadata, SkillProvider, ZeitlichPlugin, type ZeitlichPluginOptions, createBashHandler, createEditHandler, createGlobHandler, invokeModel, toTree };
148
+ export { ActivityToolHandler, AgentResponse, BashArgs, FileEditArgs, FileSystemSkillProvider, GlobArgs, ModelInvoker, RunAgentConfig, Skill, SkillMetadata, SkillProvider, createBashHandler, createEditHandler, createGlobHandler, createRunAgentActivity, queryParentWorkflowState, toTree };
package/dist/index.d.ts CHANGED
@@ -1,60 +1,38 @@
1
- import { A as AgentResponse, a as ActivityToolHandler, G as GlobArgs, F as FileEditArgs, B as BashArgs, S as SkillProvider, b as SkillMetadata, c as Skill } from './workflow-BhjsEQc1.js';
2
- export { d as AgentConfig, e as AgentFile, f as AgentState, g as AgentStateManager, h as AgentStatus, i as AppendToolResultFn, j as AskUserQuestionArgs, k as BaseAgentState, l as BaseThreadManager, m as FileReadArgs, n as FileWriteArgs, o as GrepArgs, I as InferToolResults, J as JsonPrimitive, p as JsonSerializable, q as JsonValue, P as ParsedToolCall, r as ParsedToolCallUnion, s as PostToolUseFailureHook, t as PostToolUseFailureHookContext, u as PostToolUseFailureHookResult, v as PostToolUseHook, w as PostToolUseHookContext, x as PreToolUseHook, y as PreToolUseHookContext, z as PreToolUseHookResult, C as ProcessToolCallsContext, R as RawToolCall, D as ReadSkillArgs, E as RunAgentActivity, H as RunAgentConfig, K as SessionEndHook, L as SessionEndHookContext, M as SessionExitReason, N as SessionLifecycleHooks, O as SessionStartHook, Q as SessionStartHookContext, T as SubagentArgs, U as SubagentConfig, V as SubagentHooks, W as SubagentInput, X as SubagentWorkflow, Y as TaskCreateArgs, Z as TaskGetArgs, _ as TaskListArgs, $ as TaskStatus, a0 as TaskUpdateArgs, a1 as ThreadManager, a2 as ThreadManagerConfig, a3 as ThreadOps, a4 as ToolArgs, a5 as ToolCallResult, a6 as ToolCallResultUnion, a7 as ToolDefinition, a8 as ToolHandler, a9 as ToolHandlerContext, aa as ToolHandlerResponse, ab as ToolHooks, ac as ToolMap, ad as ToolMessageContent, ae as ToolNames, af as ToolResult, ag as ToolResultConfig, ah as ToolRouter, ai as ToolWithHandler, aj as WorkflowTask, ak as ZeitlichSession, al as ZeitlichSharedActivities, am as agentQueryName, an as agentStateChangeUpdateName, ao as askUserQuestionTool, ap as bashTool, aq as createAgentStateManager, ar as createAskUserQuestionHandler, as as createBashToolDescription, at as createReadSkillHandler, au as createReadSkillTool, av as createSession, aw as createSharedActivities, ax as createSubagentTool, ay as createTaskCreateHandler, az as createTaskGetHandler, aA as createTaskListHandler, aB as createTaskUpdateHandler, aC as createThreadManager, aD as createToolRouter, aE as defineSubagent, aF as defineTool, aG as editTool, aH as globTool, aI as grepTool, aJ as hasNoOtherToolCalls, aK as isTerminalStatus, aL as parseSkillFile, aM as proxyDefaultThreadOps, aN as readFileTool, aO as taskCreateTool, aP as taskGetTool, aQ as taskListTool, aR as taskUpdateTool, aS as withAutoAppend, aT as writeFileTool } from './workflow-BhjsEQc1.js';
3
- import { SimplePlugin } from '@temporalio/plugin';
4
- import Redis from 'ioredis';
1
+ import { GlobArgs, FileEditArgs, BashArgs } from './workflow.js';
2
+ export { AgentState, AgentStateManager, AskUserQuestionArgs, FileReadArgs, FileWriteArgs, GrepArgs, JsonPrimitive, JsonSerializable, JsonValue, ReadSkillArgs, SessionLifecycleHooks, TaskCreateArgs, TaskGetArgs, TaskListArgs, TaskUpdateArgs, ZeitlichSession, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashToolDescription, createReadSkillHandler, createReadSkillTool, createSession, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, editTool, getShortId, globTool, grepTool, parseSkillFile, proxyDefaultThreadOps, readFileTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, writeFileTool } from './workflow.js';
3
+ import { M as ModelInvoker, R as RunAgentConfig, A as AgentResponse, b as ActivityToolHandler, S as SkillProvider, c as SkillMetadata, d as Skill } from './model-invoker-y_zlyMqu.js';
4
+ export { e as AgentConfig, f as AgentFile, g as AgentStatus, h as AppendToolResultFn, B as BaseAgentState, C as ContentPart, H as Hooks, I as InferToolResults, i as MessageContent, a as ModelInvokerConfig, P as ParsedToolCall, j as ParsedToolCallUnion, k as PostHumanMessageAppendHook, l as PostHumanMessageAppendHookContext, m as PostToolUseFailureHook, n as PostToolUseFailureHookContext, o as PostToolUseFailureHookResult, p as PostToolUseHook, q as PostToolUseHookContext, r as PreHumanMessageAppendHook, s as PreHumanMessageAppendHookContext, t as PreToolUseHook, u as PreToolUseHookContext, v as PreToolUseHookResult, w as ProcessToolCallsContext, x as RawToolCall, y as RunAgentActivity, z as SessionConfig, D as SessionEndHook, E as SessionEndHookContext, F as SessionExitReason, G as SessionStartHook, J as SessionStartHookContext, K as SubagentArgs, L as SubagentConfig, N as SubagentHooks, O as SubagentInput, Q as SubagentWorkflow, U as TaskStatus, T as ThreadOps, V as TokenUsage, W as ToolArgs, X as ToolCallResult, Y as ToolCallResultUnion, Z as ToolDefinition, _ as ToolHandler, $ as ToolHandlerContext, a0 as ToolHandlerResponse, a1 as ToolHooks, a2 as ToolMap, a3 as ToolMessageContent, a4 as ToolNames, a5 as ToolResult, a6 as ToolResultConfig, a7 as ToolRouter, a8 as ToolWithHandler, a9 as WorkflowTask, aa as agentQueryName, ab as agentStateChangeUpdateName, ac as createSubagentTool, ad as createToolRouter, ae as defineSubagent, af as defineTool, ag as hasNoOtherToolCalls, ah as isTerminalStatus, ai as withAutoAppend } from './model-invoker-y_zlyMqu.js';
5
+ export { B as BaseThreadManager, T as ThreadManagerConfig, c as createThreadManager } from './thread-manager-qc0g5Rvd.js';
5
6
  import { WorkflowClient } from '@temporalio/client';
6
- import { BaseChatModel, BaseChatModelCallOptions, BindToolsInput } from '@langchain/core/language_models/chat_models';
7
7
  import { IFileSystem, BashOptions } from 'just-bash';
8
8
  import '@temporalio/workflow';
9
- import '@langchain/core/messages';
9
+ import '@temporalio/common/lib/interfaces';
10
10
  import 'zod';
11
11
  import '@temporalio/common';
12
- import '@temporalio/common/lib/interfaces';
12
+ import 'ioredis';
13
13
 
14
14
  /**
15
- * Options for the Zeitlich plugin
16
- *
17
- * @experimental The Zeitlich plugin is an experimental feature; APIs may change without notice.
15
+ * Query the parent workflow's state from within an activity.
16
+ * Resolves the workflow handle from the current activity context.
18
17
  */
19
- interface ZeitlichPluginOptions {
20
- redis: Redis;
21
- }
18
+ declare function queryParentWorkflowState<T>(client: WorkflowClient, queryName: string): Promise<T>;
22
19
  /**
23
- * A Temporal plugin that integrates Zeitlich for use in workflows.
24
- * This plugin creates shared activities for thread management.
25
- * Workflow-specific activities (like runAgent) should be created separately.
20
+ * Wraps a `ModelInvoker` into a `RunAgentActivity` by automatically
21
+ * loading tool definitions from the parent workflow state via query.
26
22
  *
27
- * @experimental The Zeitlich plugin is an experimental feature; APIs may change without notice.
28
- */
29
- declare class ZeitlichPlugin extends SimplePlugin {
30
- constructor(options: ZeitlichPluginOptions);
31
- }
32
-
33
- /**
34
- * Configuration for invoking the model
35
- */
36
- interface InvokeModelConfig {
37
- threadId: string;
38
- agentName: string;
39
- }
40
- /**
41
- * Core model invocation logic - shared utility for workflow-specific activities
23
+ * This is the generic bridge between any provider-specific model invoker
24
+ * and the session's `runAgent` contract.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * import { createRunAgentActivity } from 'zeitlich';
29
+ * import { createLangChainModelInvoker } from 'zeitlich/adapters/langchain';
42
30
  *
43
- * @param options - Named options object
44
- * @param options.redis - Redis client for thread management
45
- * @param options.config - Model invocation configuration (threadId, agentName)
46
- * @param options.model - Pre-instantiated LangChain chat model
47
- * @param options.client - Temporal WorkflowClient for querying workflow state
48
- * @returns Agent response with message and metadata
31
+ * const invoker = createLangChainModelInvoker({ redis, model });
32
+ * return { runAgent: createRunAgentActivity(client, invoker) };
33
+ * ```
49
34
  */
50
- declare function invokeModel({ redis, model, client, config: { threadId, agentName }, }: {
51
- redis: Redis;
52
- client: WorkflowClient;
53
- config: InvokeModelConfig;
54
- model: BaseChatModel<BaseChatModelCallOptions & {
55
- tools?: BindToolsInput;
56
- }>;
57
- }): Promise<AgentResponse>;
35
+ declare function createRunAgentActivity<M>(client: WorkflowClient, invoker: ModelInvoker<M>): (config: RunAgentConfig) => Promise<AgentResponse<M>>;
58
36
 
59
37
  /**
60
38
  * Result of a glob operation
@@ -93,8 +71,46 @@ type BashExecOut = {
93
71
  };
94
72
  /** BashOptions with `fs` required */
95
73
  type BashToolOptions = Required<Pick<BashOptions, "fs">> & Omit<BashOptions, "fs">;
74
+ /**
75
+ * Creates a Bash tool handler that executes shell commands in a sandboxed environment.
76
+ *
77
+ * @param bashOptions - Options including a required `fs` (file system implementation from `just-bash`)
78
+ * @returns Activity tool handler for Bash tool calls
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * import { createBashHandler } from 'zeitlich';
83
+ *
84
+ * const bashHandlerActivity = createBashHandler({ fs: inMemoryFileSystem });
85
+ * ```
86
+ */
96
87
  declare const createBashHandler: (bashOptions: BashToolOptions) => ActivityToolHandler<BashArgs, BashExecOut | null>;
97
88
 
89
+ /**
90
+ * Generates a formatted file tree string from an `IFileSystem` instance.
91
+ * Useful for including filesystem context in agent prompts.
92
+ *
93
+ * @param fs - File system implementation (e.g. from `just-bash`)
94
+ * @param opts - Optional configuration for tree generation
95
+ * @param opts.dir - Root directory to start from (defaults to `/`)
96
+ * @param opts.separator - Path separator (`/` or `\\`, defaults to `/`)
97
+ * @param opts.depth - Maximum directory depth (defaults to 10)
98
+ * @param opts.sort - Sort entries alphabetically with directories first (defaults to true)
99
+ * @returns Formatted file tree string
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * import { toTree } from 'zeitlich';
104
+ *
105
+ * const fileTree = await toTree(inMemoryFileSystem);
106
+ * // Returns:
107
+ * // /
108
+ * // ├─ src/
109
+ * // │ ├─ index.ts
110
+ * // │ └─ utils.ts
111
+ * // └─ package.json
112
+ * ```
113
+ */
98
114
  declare const toTree: (fs: IFileSystem, opts?: {
99
115
  dir?: string;
100
116
  separator?: "/" | "\\";
@@ -129,4 +145,4 @@ declare class FileSystemSkillProvider implements SkillProvider {
129
145
  private discoverSkillDirs;
130
146
  }
131
147
 
132
- export { ActivityToolHandler, AgentResponse, BashArgs, FileEditArgs, FileSystemSkillProvider, GlobArgs, type InvokeModelConfig, Skill, SkillMetadata, SkillProvider, ZeitlichPlugin, type ZeitlichPluginOptions, createBashHandler, createEditHandler, createGlobHandler, invokeModel, toTree };
148
+ export { ActivityToolHandler, AgentResponse, BashArgs, FileEditArgs, FileSystemSkillProvider, GlobArgs, ModelInvoker, RunAgentConfig, Skill, SkillMetadata, SkillProvider, createBashHandler, createEditHandler, createGlobHandler, createRunAgentActivity, queryParentWorkflowState, toTree };