zeitlich 0.2.1 → 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 (46) hide show
  1. package/README.md +36 -33
  2. package/dist/index.cjs +445 -385
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +25 -42
  5. package/dist/index.d.ts +25 -42
  6. package/dist/index.js +415 -362
  7. package/dist/index.js.map +1 -1
  8. package/dist/{workflow-CCoHnc3B.d.cts → workflow-D-2vp4Pq.d.cts} +456 -253
  9. package/dist/{workflow-CCoHnc3B.d.ts → workflow-D-2vp4Pq.d.ts} +456 -253
  10. package/dist/workflow.cjs +339 -272
  11. package/dist/workflow.cjs.map +1 -1
  12. package/dist/workflow.d.cts +4 -3
  13. package/dist/workflow.d.ts +4 -3
  14. package/dist/workflow.js +315 -252
  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 +17 -11
  19. package/src/lib/session.ts +69 -86
  20. package/src/lib/state-manager.ts +9 -2
  21. package/src/lib/thread-manager.ts +45 -37
  22. package/src/lib/tool-router.ts +338 -116
  23. package/src/lib/types.ts +110 -28
  24. package/src/tools/ask-user-question/handler.ts +6 -6
  25. package/src/tools/ask-user-question/tool.ts +3 -2
  26. package/src/tools/bash/bash.test.ts +32 -32
  27. package/src/tools/bash/handler.ts +9 -9
  28. package/src/tools/bash/tool.ts +3 -2
  29. package/src/tools/edit/handler.ts +78 -123
  30. package/src/tools/edit/tool.ts +3 -2
  31. package/src/tools/glob/handler.ts +17 -48
  32. package/src/tools/glob/tool.ts +3 -2
  33. package/src/tools/grep/tool.ts +3 -2
  34. package/src/tools/{read → read-file}/tool.ts +3 -2
  35. package/src/tools/task/handler.ts +19 -9
  36. package/src/tools/task/tool.ts +3 -10
  37. package/src/tools/task-create/handler.ts +11 -20
  38. package/src/tools/task-create/tool.ts +3 -2
  39. package/src/tools/task-get/handler.ts +9 -14
  40. package/src/tools/task-get/tool.ts +3 -2
  41. package/src/tools/task-list/handler.ts +7 -12
  42. package/src/tools/task-list/tool.ts +3 -2
  43. package/src/tools/task-update/handler.ts +9 -16
  44. package/src/tools/task-update/tool.ts +3 -2
  45. package/src/tools/{write → write-file}/tool.ts +5 -6
  46. package/src/workflow.ts +25 -19
package/dist/index.d.cts CHANGED
@@ -1,12 +1,14 @@
1
- import { A as AgentResponse, a as ActivityToolHandler, b as AskUserQuestionToolSchemaType, G as GlobToolSchemaType, E as EditToolSchemaType } from './workflow-CCoHnc3B.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 SubagentInput, T as TaskCreateToolSchemaType, M as TaskGetToolSchemaType, N as TaskHandlerResult, O as TaskStatus, Q as TaskToolSchemaType, U as TaskUpdateToolSchemaType, V as ToolArgs, W as ToolCallResult, X as ToolCallResultUnion, Y as ToolDefinition, Z as ToolHandler, _ as ToolHandlerContext, $ as ToolHandlerResponse, a0 as ToolMap, a1 as ToolMessageContent, a2 as ToolNames, a3 as ToolResult, a4 as ToolResultConfig, a5 as ToolRouter, a6 as ToolWithHandler, a7 as WorkflowTask, a8 as WriteToolSchemaType, a9 as ZeitlichAgentConfig, aa as ZeitlichSession, ab as ZeitlichSharedActivities, ac as askUserQuestionTool, ad as bashTool, ae as bashToolSchemaType, af as createAgentStateManager, ag as createSession, ah as createSharedActivities, ai as createTaskCreateHandler, aj as createTaskGetHandler, ak as createTaskListHandler, al as createTaskTool, am as createTaskUpdateHandler, an as createToolRouter, ao as editTool, ap as globTool, aq as grepTool, ar as handleBashTool, as as hasNoOtherToolCalls, at as isTerminalStatus, au as readTool, av as taskCreateTool, aw as taskGetTool, ax as taskListTool, ay as taskUpdateTool, az as writeTool } from './workflow-CCoHnc3B.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';
11
+ import '@temporalio/common';
10
12
 
11
13
  /**
12
14
  * Options for the Zeitlich plugin
@@ -53,9 +55,9 @@ declare function invokeModel({ redis, model, client, config: { threadId, agentNa
53
55
  }): Promise<AgentResponse>;
54
56
 
55
57
  /**
56
- * Handle user interaction tool result - creates AI messages for display.
58
+ * Creates handler for user interaction tool - creates AI messages for display.
57
59
  */
58
- declare const handleAskUserQuestionToolResult: ActivityToolHandler<AskUserQuestionToolSchemaType, {
60
+ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQuestionArgs, {
59
61
  chatMessages: StoredMessage[];
60
62
  }>;
61
63
 
@@ -66,19 +68,12 @@ interface GlobResult {
66
68
  files: string[];
67
69
  }
68
70
  /**
69
- * Glob handler response
70
- */
71
- interface GlobHandlerResponse {
72
- content: string;
73
- result: GlobResult;
74
- }
75
- /**
76
- * Glob handler that searches within the scoped file tree.
71
+ * Creates a glob handler that searches within the scoped file tree.
77
72
  *
78
- * @param args - Tool arguments (pattern, root)
79
- * @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
80
75
  */
81
- declare function globHandler(_args: GlobToolSchemaType, fs: IFileSystem): Promise<GlobHandlerResponse>;
76
+ declare function createGlobHandler(fs: IFileSystem): ActivityToolHandler<GlobArgs, GlobResult>;
82
77
 
83
78
  /**
84
79
  * Result of an edit operation
@@ -89,33 +84,21 @@ interface EditResult {
89
84
  replacements: number;
90
85
  }
91
86
  /**
92
- * Edit handler response
93
- */
94
- interface EditHandlerResponse {
95
- content: string;
96
- result: EditResult;
97
- }
98
- /**
99
- * Options for edit handler
100
- */
101
- interface EditHandlerOptions {
102
- /**
103
- * Set of file paths that have been read in this session.
104
- * Required for enforcing read-before-write policy.
105
- */
106
- readFiles: Set<string>;
107
- /**
108
- * If true, skip the read-before-write check (not recommended)
109
- */
110
- skipReadCheck?: boolean;
111
- }
112
- /**
113
- * Edit handler that edits files within the scoped file tree.
87
+ * Creates an edit handler that edits files within the scoped file tree.
114
88
  *
115
- * @param args - Tool arguments (file_path, old_string, new_string, replace_all)
116
- * @param options - Additional options (readFiles, skipReadCheck)
89
+ * @param fs - File system implementation for I/O operations
90
+ * @returns An ActivityToolHandler for edit tool calls
117
91
  */
118
- 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>;
119
102
 
120
103
  declare const toTree: (fs: IFileSystem, opts?: {
121
104
  dir?: string;
@@ -125,4 +108,4 @@ declare const toTree: (fs: IFileSystem, opts?: {
125
108
  sort?: boolean;
126
109
  }) => Promise<string>;
127
110
 
128
- 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,12 +1,14 @@
1
- import { A as AgentResponse, a as ActivityToolHandler, b as AskUserQuestionToolSchemaType, G as GlobToolSchemaType, E as EditToolSchemaType } from './workflow-CCoHnc3B.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 SubagentInput, T as TaskCreateToolSchemaType, M as TaskGetToolSchemaType, N as TaskHandlerResult, O as TaskStatus, Q as TaskToolSchemaType, U as TaskUpdateToolSchemaType, V as ToolArgs, W as ToolCallResult, X as ToolCallResultUnion, Y as ToolDefinition, Z as ToolHandler, _ as ToolHandlerContext, $ as ToolHandlerResponse, a0 as ToolMap, a1 as ToolMessageContent, a2 as ToolNames, a3 as ToolResult, a4 as ToolResultConfig, a5 as ToolRouter, a6 as ToolWithHandler, a7 as WorkflowTask, a8 as WriteToolSchemaType, a9 as ZeitlichAgentConfig, aa as ZeitlichSession, ab as ZeitlichSharedActivities, ac as askUserQuestionTool, ad as bashTool, ae as bashToolSchemaType, af as createAgentStateManager, ag as createSession, ah as createSharedActivities, ai as createTaskCreateHandler, aj as createTaskGetHandler, ak as createTaskListHandler, al as createTaskTool, am as createTaskUpdateHandler, an as createToolRouter, ao as editTool, ap as globTool, aq as grepTool, ar as handleBashTool, as as hasNoOtherToolCalls, at as isTerminalStatus, au as readTool, av as taskCreateTool, aw as taskGetTool, ax as taskListTool, ay as taskUpdateTool, az as writeTool } from './workflow-CCoHnc3B.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';
11
+ import '@temporalio/common';
10
12
 
11
13
  /**
12
14
  * Options for the Zeitlich plugin
@@ -53,9 +55,9 @@ declare function invokeModel({ redis, model, client, config: { threadId, agentNa
53
55
  }): Promise<AgentResponse>;
54
56
 
55
57
  /**
56
- * Handle user interaction tool result - creates AI messages for display.
58
+ * Creates handler for user interaction tool - creates AI messages for display.
57
59
  */
58
- declare const handleAskUserQuestionToolResult: ActivityToolHandler<AskUserQuestionToolSchemaType, {
60
+ declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQuestionArgs, {
59
61
  chatMessages: StoredMessage[];
60
62
  }>;
61
63
 
@@ -66,19 +68,12 @@ interface GlobResult {
66
68
  files: string[];
67
69
  }
68
70
  /**
69
- * Glob handler response
70
- */
71
- interface GlobHandlerResponse {
72
- content: string;
73
- result: GlobResult;
74
- }
75
- /**
76
- * Glob handler that searches within the scoped file tree.
71
+ * Creates a glob handler that searches within the scoped file tree.
77
72
  *
78
- * @param args - Tool arguments (pattern, root)
79
- * @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
80
75
  */
81
- declare function globHandler(_args: GlobToolSchemaType, fs: IFileSystem): Promise<GlobHandlerResponse>;
76
+ declare function createGlobHandler(fs: IFileSystem): ActivityToolHandler<GlobArgs, GlobResult>;
82
77
 
83
78
  /**
84
79
  * Result of an edit operation
@@ -89,33 +84,21 @@ interface EditResult {
89
84
  replacements: number;
90
85
  }
91
86
  /**
92
- * Edit handler response
93
- */
94
- interface EditHandlerResponse {
95
- content: string;
96
- result: EditResult;
97
- }
98
- /**
99
- * Options for edit handler
100
- */
101
- interface EditHandlerOptions {
102
- /**
103
- * Set of file paths that have been read in this session.
104
- * Required for enforcing read-before-write policy.
105
- */
106
- readFiles: Set<string>;
107
- /**
108
- * If true, skip the read-before-write check (not recommended)
109
- */
110
- skipReadCheck?: boolean;
111
- }
112
- /**
113
- * Edit handler that edits files within the scoped file tree.
87
+ * Creates an edit handler that edits files within the scoped file tree.
114
88
  *
115
- * @param args - Tool arguments (file_path, old_string, new_string, replace_all)
116
- * @param options - Additional options (readFiles, skipReadCheck)
89
+ * @param fs - File system implementation for I/O operations
90
+ * @returns An ActivityToolHandler for edit tool calls
117
91
  */
118
- 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>;
119
102
 
120
103
  declare const toTree: (fs: IFileSystem, opts?: {
121
104
  dir?: string;
@@ -125,4 +108,4 @@ declare const toTree: (fs: IFileSystem, opts?: {
125
108
  sort?: boolean;
126
109
  }) => Promise<string>;
127
110
 
128
- 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 };