zeitlich 0.2.2 → 0.2.3

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 (45) hide show
  1. package/README.md +34 -31
  2. package/dist/index.cjs +305 -361
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +24 -43
  5. package/dist/index.d.ts +24 -43
  6. package/dist/index.js +277 -336
  7. package/dist/index.js.map +1 -1
  8. package/dist/{workflow-BQf5EfNN.d.cts → workflow-D-2vp4Pq.d.cts} +265 -241
  9. package/dist/{workflow-BQf5EfNN.d.ts → workflow-D-2vp4Pq.d.ts} +265 -241
  10. package/dist/workflow.cjs +206 -253
  11. package/dist/workflow.cjs.map +1 -1
  12. package/dist/workflow.d.cts +2 -3
  13. package/dist/workflow.d.ts +2 -3
  14. package/dist/workflow.js +182 -231
  15. package/dist/workflow.js.map +1 -1
  16. package/package.json +3 -2
  17. package/src/activities.ts +1 -14
  18. package/src/index.ts +14 -11
  19. package/src/lib/session.ts +56 -99
  20. package/src/lib/thread-manager.ts +45 -37
  21. package/src/lib/tool-router.ts +143 -103
  22. package/src/lib/types.ts +32 -25
  23. package/src/tools/ask-user-question/handler.ts +5 -5
  24. package/src/tools/ask-user-question/tool.ts +3 -2
  25. package/src/tools/bash/bash.test.ts +12 -12
  26. package/src/tools/bash/handler.ts +5 -5
  27. package/src/tools/bash/tool.ts +3 -2
  28. package/src/tools/edit/handler.ts +78 -123
  29. package/src/tools/edit/tool.ts +3 -2
  30. package/src/tools/glob/handler.ts +17 -48
  31. package/src/tools/glob/tool.ts +3 -2
  32. package/src/tools/grep/tool.ts +3 -2
  33. package/src/tools/{read → read-file}/tool.ts +3 -2
  34. package/src/tools/task/handler.ts +2 -2
  35. package/src/tools/task/tool.ts +2 -9
  36. package/src/tools/task-create/handler.ts +5 -11
  37. package/src/tools/task-create/tool.ts +3 -2
  38. package/src/tools/task-get/handler.ts +5 -10
  39. package/src/tools/task-get/tool.ts +3 -2
  40. package/src/tools/task-list/handler.ts +5 -10
  41. package/src/tools/task-list/tool.ts +3 -2
  42. package/src/tools/task-update/handler.ts +5 -12
  43. package/src/tools/task-update/tool.ts +3 -2
  44. package/src/tools/{write → write-file}/tool.ts +5 -6
  45. package/src/workflow.ts +23 -19
package/dist/index.d.cts CHANGED
@@ -1,14 +1,14 @@
1
- import { A as AgentResponse, a as ActivityToolHandler, b as AskUserQuestionToolSchemaType, G as GlobToolSchemaType, E as EditToolSchemaType } from './workflow-BQf5EfNN.cjs';
2
- export { c as AGENT_HANDLER_NAMES, d as AgentFile, e as AgentState, f as AgentStateManager, g as AgentStatus, h as AppendToolResultFn, B as BaseAgentState, i as GenericTaskToolSchemaType, j as GrepToolSchemaType, I as InferToolResults, J as JsonPrimitive, k as JsonSerializable, l as JsonValue, P as ParsedToolCall, m as ParsedToolCallUnion, n as PostToolUseFailureHook, o as PostToolUseFailureHookContext, p as PostToolUseFailureHookResult, q as PostToolUseHook, r as PostToolUseHookContext, s as PreToolUseHook, t as PreToolUseHookContext, u as PreToolUseHookResult, v as ProcessToolCallsContext, R as RawToolCall, w as ReadToolSchemaType, x as RunAgentActivity, y as RunAgentConfig, S as SessionEndHook, z as SessionEndHookContext, C as SessionExitReason, D as SessionLifecycleHooks, F as SessionStartHook, H as SessionStartHookContext, K as SubagentConfig, L as SubagentHooks, M as SubagentInput, T as TaskCreateToolSchemaType, N as TaskGetToolSchemaType, O as TaskHandlerResult, Q as TaskStatus, U as TaskToolSchemaType, V as TaskUpdateToolSchemaType, 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 WriteToolSchemaType, ab as ZeitlichAgentConfig, ac as ZeitlichSession, ad as ZeitlichSharedActivities, ae as askUserQuestionTool, af as bashTool, ag as bashToolSchemaType, ah as createAgentStateManager, ai as createSession, aj as createSharedActivities, ak as createTaskCreateHandler, al as createTaskGetHandler, am as createTaskListHandler, an as createTaskTool, ao as createTaskUpdateHandler, ap as createThreadManager, aq as createToolRouter, ar as defineSubagent, as as defineTool, at as editTool, au as getStateQuery, av as globTool, aw as grepTool, ax as handleBashTool, ay as hasNoOtherToolCalls, az as isTerminalStatus, aA as readTool, aB as taskCreateTool, aC as taskGetTool, aD as taskListTool, aE as taskUpdateTool, aF as writeTool } from './workflow-BQf5EfNN.cjs';
1
+ import { A as AgentResponse, a as ActivityToolHandler, b as AskUserQuestionArgs, G as GlobArgs, F as FileEditArgs, B as BashArgs } from './workflow-D-2vp4Pq.cjs';
2
+ export { c as AGENT_HANDLER_NAMES, d as AgentFile, e as AgentState, f as AgentStateManager, g as AgentStatus, h as AppendToolResultFn, i as BaseAgentState, j as BaseThreadManager, k as FileReadArgs, l as FileWriteArgs, m as GrepArgs, I as InferToolResults, J as JsonPrimitive, n as JsonSerializable, o as JsonValue, P as ParsedToolCall, p as ParsedToolCallUnion, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, s as PostToolUseFailureHookResult, t as PostToolUseHook, u as PostToolUseHookContext, v as PreToolUseHook, w as PreToolUseHookContext, x as PreToolUseHookResult, y as ProcessToolCallsContext, R as RawToolCall, z as RunAgentActivity, C as RunAgentConfig, S as SessionEndHook, D as SessionEndHookContext, E as SessionExitReason, H as SessionLifecycleHooks, K as SessionStartHook, L as SessionStartHookContext, M as SubagentConfig, N as SubagentHooks, O as SubagentInput, T as TaskArgs, Q as TaskCreateArgs, U as TaskGetArgs, V as TaskHandlerResult, W as TaskListArgs, X as TaskStatus, Y as TaskUpdateArgs, Z as ThreadManager, _ as ThreadManagerConfig, $ as ThreadOps, a0 as ToolArgs, a1 as ToolCallResult, a2 as ToolCallResultUnion, a3 as ToolDefinition, a4 as ToolHandler, a5 as ToolHandlerContext, a6 as ToolHandlerResponse, a7 as ToolHooks, a8 as ToolMap, a9 as ToolMessageContent, aa as ToolNames, ab as ToolResult, ac as ToolResultConfig, ad as ToolRouter, ae as ToolWithHandler, af as WorkflowTask, ag as ZeitlichAgentConfig, ah as ZeitlichSession, ai as ZeitlichSharedActivities, aj as askUserQuestionTool, ak as bashTool, al as createAgentStateManager, am as createBashToolDescription, an as createSession, ao as createSharedActivities, ap as createTaskCreateHandler, aq as createTaskGetHandler, ar as createTaskListHandler, as as createTaskTool, at as createTaskUpdateHandler, au as createThreadManager, av as createToolRouter, aw as defineSubagent, ax as defineTool, ay as editTool, az as getStateQuery, aA as globTool, aB as grepTool, aC as hasNoOtherToolCalls, aD as isTerminalStatus, aE as proxyDefaultThreadOps, aF as readTool, aG as taskCreateTool, aH as taskGetTool, aI as taskListTool, aJ as taskUpdateTool, aK as withAutoAppend, aL as writeTool } from './workflow-D-2vp4Pq.cjs';
3
3
  import { SimplePlugin } from '@temporalio/plugin';
4
4
  import Redis from 'ioredis';
5
5
  import { WorkflowClient } from '@temporalio/client';
6
6
  import { BaseChatModel, BaseChatModelCallOptions, BindToolsInput } from '@langchain/core/language_models/chat_models';
7
7
  import { StoredMessage } from '@langchain/core/messages';
8
- import { IFileSystem } from 'just-bash';
8
+ import { IFileSystem, BashOptions } from 'just-bash';
9
+ import '@temporalio/workflow';
9
10
  import 'zod';
10
11
  import '@temporalio/common';
11
- import '@temporalio/workflow';
12
12
 
13
13
  /**
14
14
  * Options for the Zeitlich plugin
@@ -55,9 +55,9 @@ declare function invokeModel({ redis, model, client, config: { threadId, agentNa
55
55
  }): Promise<AgentResponse>;
56
56
 
57
57
  /**
58
- * Handle user interaction tool result - creates AI messages for display.
58
+ * Creates handler for user interaction tool - creates AI messages for display.
59
59
  */
60
- declare const handleAskUserQuestionToolResult: ActivityToolHandler<AskUserQuestionToolSchemaType, {
60
+ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQuestionArgs, {
61
61
  chatMessages: StoredMessage[];
62
62
  }>;
63
63
 
@@ -68,19 +68,12 @@ interface GlobResult {
68
68
  files: string[];
69
69
  }
70
70
  /**
71
- * Glob handler response
72
- */
73
- interface GlobHandlerResponse {
74
- toolResponse: string;
75
- data: GlobResult;
76
- }
77
- /**
78
- * Glob handler that searches within the scoped file tree.
71
+ * Creates a glob handler that searches within the scoped file tree.
79
72
  *
80
- * @param args - Tool arguments (pattern, root)
81
- * @param provider - FileSystemProvider for I/O operations
73
+ * @param fs - File system implementation for I/O operations
74
+ * @returns An ActivityToolHandler for glob tool calls
82
75
  */
83
- declare function globHandler(_args: GlobToolSchemaType, fs: IFileSystem): Promise<GlobHandlerResponse>;
76
+ declare function createGlobHandler(fs: IFileSystem): ActivityToolHandler<GlobArgs, GlobResult>;
84
77
 
85
78
  /**
86
79
  * Result of an edit operation
@@ -91,33 +84,21 @@ interface EditResult {
91
84
  replacements: number;
92
85
  }
93
86
  /**
94
- * Edit handler response
95
- */
96
- interface EditHandlerResponse {
97
- toolResponse: string;
98
- data: EditResult;
99
- }
100
- /**
101
- * Options for edit handler
102
- */
103
- interface EditHandlerOptions {
104
- /**
105
- * Set of file paths that have been read in this session.
106
- * Required for enforcing read-before-write policy.
107
- */
108
- readFiles: Set<string>;
109
- /**
110
- * If true, skip the read-before-write check (not recommended)
111
- */
112
- skipReadCheck?: boolean;
113
- }
114
- /**
115
- * Edit handler that edits files within the scoped file tree.
87
+ * Creates an edit handler that edits files within the scoped file tree.
116
88
  *
117
- * @param args - Tool arguments (file_path, old_string, new_string, replace_all)
118
- * @param options - Additional options (readFiles, skipReadCheck)
89
+ * @param fs - File system implementation for I/O operations
90
+ * @returns An ActivityToolHandler for edit tool calls
119
91
  */
120
- declare function editHandler(args: EditToolSchemaType, fs: IFileSystem): Promise<EditHandlerResponse>;
92
+ declare function createEditHandler(fs: IFileSystem): ActivityToolHandler<FileEditArgs, EditResult>;
93
+
94
+ type BashExecOut = {
95
+ exitCode: number;
96
+ stderr: string;
97
+ stdout: string;
98
+ };
99
+ /** BashOptions with `fs` required */
100
+ type BashToolOptions = Required<Pick<BashOptions, "fs">> & Omit<BashOptions, "fs">;
101
+ declare const createBashHandler: (bashOptions: BashToolOptions) => ActivityToolHandler<BashArgs, BashExecOut | null>;
121
102
 
122
103
  declare const toTree: (fs: IFileSystem, opts?: {
123
104
  dir?: string;
@@ -127,4 +108,4 @@ declare const toTree: (fs: IFileSystem, opts?: {
127
108
  sort?: boolean;
128
109
  }) => Promise<string>;
129
110
 
130
- export { ActivityToolHandler, AgentResponse, AskUserQuestionToolSchemaType, type EditHandlerOptions, type EditHandlerResponse, type EditResult, EditToolSchemaType, GlobToolSchemaType, type InvokeModelConfig, ZeitlichPlugin, type ZeitlichPluginOptions, editHandler, globHandler, handleAskUserQuestionToolResult, invokeModel, toTree };
111
+ export { ActivityToolHandler, AgentResponse, AskUserQuestionArgs, BashArgs, FileEditArgs, GlobArgs, type InvokeModelConfig, ZeitlichPlugin, type ZeitlichPluginOptions, createAskUserQuestionHandler, createBashHandler, createEditHandler, createGlobHandler, invokeModel, toTree };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { A as AgentResponse, a as ActivityToolHandler, b as AskUserQuestionToolSchemaType, G as GlobToolSchemaType, E as EditToolSchemaType } from './workflow-BQf5EfNN.js';
2
- export { c as AGENT_HANDLER_NAMES, d as AgentFile, e as AgentState, f as AgentStateManager, g as AgentStatus, h as AppendToolResultFn, B as BaseAgentState, i as GenericTaskToolSchemaType, j as GrepToolSchemaType, I as InferToolResults, J as JsonPrimitive, k as JsonSerializable, l as JsonValue, P as ParsedToolCall, m as ParsedToolCallUnion, n as PostToolUseFailureHook, o as PostToolUseFailureHookContext, p as PostToolUseFailureHookResult, q as PostToolUseHook, r as PostToolUseHookContext, s as PreToolUseHook, t as PreToolUseHookContext, u as PreToolUseHookResult, v as ProcessToolCallsContext, R as RawToolCall, w as ReadToolSchemaType, x as RunAgentActivity, y as RunAgentConfig, S as SessionEndHook, z as SessionEndHookContext, C as SessionExitReason, D as SessionLifecycleHooks, F as SessionStartHook, H as SessionStartHookContext, K as SubagentConfig, L as SubagentHooks, M as SubagentInput, T as TaskCreateToolSchemaType, N as TaskGetToolSchemaType, O as TaskHandlerResult, Q as TaskStatus, U as TaskToolSchemaType, V as TaskUpdateToolSchemaType, 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 WriteToolSchemaType, ab as ZeitlichAgentConfig, ac as ZeitlichSession, ad as ZeitlichSharedActivities, ae as askUserQuestionTool, af as bashTool, ag as bashToolSchemaType, ah as createAgentStateManager, ai as createSession, aj as createSharedActivities, ak as createTaskCreateHandler, al as createTaskGetHandler, am as createTaskListHandler, an as createTaskTool, ao as createTaskUpdateHandler, ap as createThreadManager, aq as createToolRouter, ar as defineSubagent, as as defineTool, at as editTool, au as getStateQuery, av as globTool, aw as grepTool, ax as handleBashTool, ay as hasNoOtherToolCalls, az as isTerminalStatus, aA as readTool, aB as taskCreateTool, aC as taskGetTool, aD as taskListTool, aE as taskUpdateTool, aF as writeTool } from './workflow-BQf5EfNN.js';
1
+ import { A as AgentResponse, a as ActivityToolHandler, b as AskUserQuestionArgs, G as GlobArgs, F as FileEditArgs, B as BashArgs } from './workflow-D-2vp4Pq.js';
2
+ export { c as AGENT_HANDLER_NAMES, d as AgentFile, e as AgentState, f as AgentStateManager, g as AgentStatus, h as AppendToolResultFn, i as BaseAgentState, j as BaseThreadManager, k as FileReadArgs, l as FileWriteArgs, m as GrepArgs, I as InferToolResults, J as JsonPrimitive, n as JsonSerializable, o as JsonValue, P as ParsedToolCall, p as ParsedToolCallUnion, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, s as PostToolUseFailureHookResult, t as PostToolUseHook, u as PostToolUseHookContext, v as PreToolUseHook, w as PreToolUseHookContext, x as PreToolUseHookResult, y as ProcessToolCallsContext, R as RawToolCall, z as RunAgentActivity, C as RunAgentConfig, S as SessionEndHook, D as SessionEndHookContext, E as SessionExitReason, H as SessionLifecycleHooks, K as SessionStartHook, L as SessionStartHookContext, M as SubagentConfig, N as SubagentHooks, O as SubagentInput, T as TaskArgs, Q as TaskCreateArgs, U as TaskGetArgs, V as TaskHandlerResult, W as TaskListArgs, X as TaskStatus, Y as TaskUpdateArgs, Z as ThreadManager, _ as ThreadManagerConfig, $ as ThreadOps, a0 as ToolArgs, a1 as ToolCallResult, a2 as ToolCallResultUnion, a3 as ToolDefinition, a4 as ToolHandler, a5 as ToolHandlerContext, a6 as ToolHandlerResponse, a7 as ToolHooks, a8 as ToolMap, a9 as ToolMessageContent, aa as ToolNames, ab as ToolResult, ac as ToolResultConfig, ad as ToolRouter, ae as ToolWithHandler, af as WorkflowTask, ag as ZeitlichAgentConfig, ah as ZeitlichSession, ai as ZeitlichSharedActivities, aj as askUserQuestionTool, ak as bashTool, al as createAgentStateManager, am as createBashToolDescription, an as createSession, ao as createSharedActivities, ap as createTaskCreateHandler, aq as createTaskGetHandler, ar as createTaskListHandler, as as createTaskTool, at as createTaskUpdateHandler, au as createThreadManager, av as createToolRouter, aw as defineSubagent, ax as defineTool, ay as editTool, az as getStateQuery, aA as globTool, aB as grepTool, aC as hasNoOtherToolCalls, aD as isTerminalStatus, aE as proxyDefaultThreadOps, aF as readTool, aG as taskCreateTool, aH as taskGetTool, aI as taskListTool, aJ as taskUpdateTool, aK as withAutoAppend, aL as writeTool } from './workflow-D-2vp4Pq.js';
3
3
  import { SimplePlugin } from '@temporalio/plugin';
4
4
  import Redis from 'ioredis';
5
5
  import { WorkflowClient } from '@temporalio/client';
6
6
  import { BaseChatModel, BaseChatModelCallOptions, BindToolsInput } from '@langchain/core/language_models/chat_models';
7
7
  import { StoredMessage } from '@langchain/core/messages';
8
- import { IFileSystem } from 'just-bash';
8
+ import { IFileSystem, BashOptions } from 'just-bash';
9
+ import '@temporalio/workflow';
9
10
  import 'zod';
10
11
  import '@temporalio/common';
11
- import '@temporalio/workflow';
12
12
 
13
13
  /**
14
14
  * Options for the Zeitlich plugin
@@ -55,9 +55,9 @@ declare function invokeModel({ redis, model, client, config: { threadId, agentNa
55
55
  }): Promise<AgentResponse>;
56
56
 
57
57
  /**
58
- * Handle user interaction tool result - creates AI messages for display.
58
+ * Creates handler for user interaction tool - creates AI messages for display.
59
59
  */
60
- declare const handleAskUserQuestionToolResult: ActivityToolHandler<AskUserQuestionToolSchemaType, {
60
+ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQuestionArgs, {
61
61
  chatMessages: StoredMessage[];
62
62
  }>;
63
63
 
@@ -68,19 +68,12 @@ interface GlobResult {
68
68
  files: string[];
69
69
  }
70
70
  /**
71
- * Glob handler response
72
- */
73
- interface GlobHandlerResponse {
74
- toolResponse: string;
75
- data: GlobResult;
76
- }
77
- /**
78
- * Glob handler that searches within the scoped file tree.
71
+ * Creates a glob handler that searches within the scoped file tree.
79
72
  *
80
- * @param args - Tool arguments (pattern, root)
81
- * @param provider - FileSystemProvider for I/O operations
73
+ * @param fs - File system implementation for I/O operations
74
+ * @returns An ActivityToolHandler for glob tool calls
82
75
  */
83
- declare function globHandler(_args: GlobToolSchemaType, fs: IFileSystem): Promise<GlobHandlerResponse>;
76
+ declare function createGlobHandler(fs: IFileSystem): ActivityToolHandler<GlobArgs, GlobResult>;
84
77
 
85
78
  /**
86
79
  * Result of an edit operation
@@ -91,33 +84,21 @@ interface EditResult {
91
84
  replacements: number;
92
85
  }
93
86
  /**
94
- * Edit handler response
95
- */
96
- interface EditHandlerResponse {
97
- toolResponse: string;
98
- data: EditResult;
99
- }
100
- /**
101
- * Options for edit handler
102
- */
103
- interface EditHandlerOptions {
104
- /**
105
- * Set of file paths that have been read in this session.
106
- * Required for enforcing read-before-write policy.
107
- */
108
- readFiles: Set<string>;
109
- /**
110
- * If true, skip the read-before-write check (not recommended)
111
- */
112
- skipReadCheck?: boolean;
113
- }
114
- /**
115
- * Edit handler that edits files within the scoped file tree.
87
+ * Creates an edit handler that edits files within the scoped file tree.
116
88
  *
117
- * @param args - Tool arguments (file_path, old_string, new_string, replace_all)
118
- * @param options - Additional options (readFiles, skipReadCheck)
89
+ * @param fs - File system implementation for I/O operations
90
+ * @returns An ActivityToolHandler for edit tool calls
119
91
  */
120
- declare function editHandler(args: EditToolSchemaType, fs: IFileSystem): Promise<EditHandlerResponse>;
92
+ declare function createEditHandler(fs: IFileSystem): ActivityToolHandler<FileEditArgs, EditResult>;
93
+
94
+ type BashExecOut = {
95
+ exitCode: number;
96
+ stderr: string;
97
+ stdout: string;
98
+ };
99
+ /** BashOptions with `fs` required */
100
+ type BashToolOptions = Required<Pick<BashOptions, "fs">> & Omit<BashOptions, "fs">;
101
+ declare const createBashHandler: (bashOptions: BashToolOptions) => ActivityToolHandler<BashArgs, BashExecOut | null>;
121
102
 
122
103
  declare const toTree: (fs: IFileSystem, opts?: {
123
104
  dir?: string;
@@ -127,4 +108,4 @@ declare const toTree: (fs: IFileSystem, opts?: {
127
108
  sort?: boolean;
128
109
  }) => Promise<string>;
129
110
 
130
- export { ActivityToolHandler, AgentResponse, AskUserQuestionToolSchemaType, type EditHandlerOptions, type EditHandlerResponse, type EditResult, EditToolSchemaType, GlobToolSchemaType, type InvokeModelConfig, ZeitlichPlugin, type ZeitlichPluginOptions, editHandler, globHandler, handleAskUserQuestionToolResult, invokeModel, toTree };
111
+ export { ActivityToolHandler, AgentResponse, AskUserQuestionArgs, BashArgs, FileEditArgs, GlobArgs, type InvokeModelConfig, ZeitlichPlugin, type ZeitlichPluginOptions, createAskUserQuestionHandler, createBashHandler, createEditHandler, createGlobHandler, invokeModel, toTree };