zeitlich 0.1.1 → 0.2.1

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 (58) hide show
  1. package/README.md +168 -180
  2. package/dist/index.cjs +1337 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +128 -0
  5. package/dist/index.d.ts +51 -75
  6. package/dist/index.js +764 -1091
  7. package/dist/index.js.map +1 -1
  8. package/dist/workflow-CCoHnc3B.d.cts +943 -0
  9. package/dist/workflow-CCoHnc3B.d.ts +943 -0
  10. package/dist/workflow.cjs +930 -0
  11. package/dist/workflow.cjs.map +1 -0
  12. package/dist/workflow.d.cts +5 -0
  13. package/dist/workflow.d.ts +2 -1
  14. package/dist/workflow.js +559 -423
  15. package/dist/workflow.js.map +1 -1
  16. package/package.json +14 -13
  17. package/src/activities.ts +112 -0
  18. package/src/index.ts +49 -0
  19. package/src/lib/fs.ts +80 -0
  20. package/src/lib/model-invoker.ts +75 -0
  21. package/src/lib/session.ts +216 -0
  22. package/src/lib/state-manager.ts +268 -0
  23. package/src/lib/thread-manager.ts +169 -0
  24. package/src/lib/tool-router.ts +717 -0
  25. package/src/lib/types.ts +354 -0
  26. package/src/plugin.ts +28 -0
  27. package/src/tools/ask-user-question/handler.ts +25 -0
  28. package/src/tools/ask-user-question/tool.ts +46 -0
  29. package/src/tools/bash/bash.test.ts +104 -0
  30. package/src/tools/bash/handler.ts +45 -0
  31. package/src/tools/bash/tool.ts +36 -0
  32. package/src/tools/edit/handler.ts +156 -0
  33. package/src/tools/edit/tool.ts +39 -0
  34. package/src/tools/glob/handler.ts +62 -0
  35. package/src/tools/glob/tool.ts +27 -0
  36. package/src/tools/grep/tool.ts +45 -0
  37. package/src/tools/read/tool.ts +33 -0
  38. package/src/tools/task/handler.ts +75 -0
  39. package/src/tools/task/tool.ts +96 -0
  40. package/src/tools/task-create/handler.ts +49 -0
  41. package/src/tools/task-create/tool.ts +66 -0
  42. package/src/tools/task-get/handler.ts +38 -0
  43. package/src/tools/task-get/tool.ts +11 -0
  44. package/src/tools/task-list/handler.ts +33 -0
  45. package/src/tools/task-list/tool.ts +9 -0
  46. package/src/tools/task-update/handler.ts +79 -0
  47. package/src/tools/task-update/tool.ts +20 -0
  48. package/src/tools/write/tool.ts +26 -0
  49. package/src/workflow.ts +138 -0
  50. package/tsup.config.ts +22 -0
  51. package/dist/index.d.mts +0 -152
  52. package/dist/index.mjs +0 -1587
  53. package/dist/index.mjs.map +0 -1
  54. package/dist/workflow-7_MT-5-w.d.mts +0 -1203
  55. package/dist/workflow-7_MT-5-w.d.ts +0 -1203
  56. package/dist/workflow.d.mts +0 -4
  57. package/dist/workflow.mjs +0 -739
  58. package/dist/workflow.mjs.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { T as ToolDefinition, I as InvocationConfig, A as AgentResponse, a as ActivityToolHandler, b as AskUserQuestionToolSchemaType, F as FileSystemProvider, c as FileNode, G as GlobToolSchemaType, d as GrepToolSchemaType, e as GrepMatch, R as ReadToolSchemaType, f as FileContent, W as WriteToolSchemaType, E as EditToolSchemaType } from './workflow-7_MT-5-w.js';
2
- export { g as AGENT_HANDLER_NAMES, h as AgentFile, i as AgentState, j as AgentStateManager, k as AgentStateManagerConfig, l as AgentStatus, m as AppendToolResultFn, B as BackendConfig, n as BaseAgentState, o as BaseFileSystemProvider, C as CompositeFileSystemProvider, p as FileResolver, q as FileSystemToolsConfig, r as FileTreeRenderOptions, s as GenericTaskToolSchemaType, t as GrepOptions, u as InMemoryFileSystemProvider, J as JsonPrimitive, v as JsonSerializable, w as JsonValue, P as ParsedToolCall, x as ParsedToolCallUnion, y as PostToolUseFailureHook, z as PostToolUseFailureHookContext, D as PostToolUseFailureHookResult, H as PostToolUseHook, K as PostToolUseHookContext, L as PreToolUseHook, M as PreToolUseHookContext, N as PreToolUseHookResult, O as ProcessToolCallsContext, Q as PromptManager, S as PromptManagerConfig, U as RawToolCall, V as RunAgentActivity, X as RunAgentConfig, Y as SessionEndHook, Z as SessionEndHookContext, _ as SessionExitReason, $ as SessionHooks, a0 as SessionLifecycleHooks, a1 as SessionStartHook, a2 as SessionStartHookContext, a3 as SubagentConfig, a4 as SubagentInput, a5 as SubagentSupportConfig, a6 as SubagentSupportResult, a7 as TaskHandlerResult, a8 as TaskToolSchemaType, a9 as ToolCallResult, aa as ToolCallResultUnion, ab as ToolHandler, ac as ToolHandlerMap, ad as ToolHandlerResponse, ae as ToolMap, af as ToolMessageContent, ag as ToolNames, ah as ToolRegistry, ai as ToolResultConfig, aj as ToolRouter, ak as ToolRouterHooks, al as ToolRouterOptions, am as ZeitlichAgentConfig, an as ZeitlichSession, ao as ZeitlichSharedActivities, ap as askUserQuestionTool, aq as buildFileTreePrompt, ar as createAgentStateManager, as as createPromptManager, at as createSession, au as createSharedActivities, av as createTaskHandler, aw as createTaskTool, ax as createToolRegistry, ay as createToolRouter, az as editTool, aA as fileContentToMessageContent, aB as findNodeByPath, aC as flattenFileTree, aD as globTool, aE as grepTool, aF as hasNoOtherToolCalls, aG as hasTaskTool, aH as isPathInScope, aI as isTerminalStatus, aJ as readTool, aK as withSubagentSupport, aL as writeTool } from './workflow-7_MT-5-w.js';
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';
3
3
  import { SimplePlugin } from '@temporalio/plugin';
4
4
  import Redis from 'ioredis';
5
+ import { WorkflowClient } from '@temporalio/client';
5
6
  import { BaseChatModel, BaseChatModelCallOptions, BindToolsInput } from '@langchain/core/language_models/chat_models';
6
- import { StoredMessage, ContentBlock } from '@langchain/core/messages';
7
+ import { StoredMessage } from '@langchain/core/messages';
8
+ import { IFileSystem } from 'just-bash';
7
9
  import 'zod';
8
10
 
9
11
  /**
@@ -31,7 +33,6 @@ declare class ZeitlichPlugin extends SimplePlugin {
31
33
  interface InvokeModelConfig {
32
34
  threadId: string;
33
35
  agentName: string;
34
- tools: ToolDefinition[];
35
36
  }
36
37
  /**
37
38
  * Core model invocation logic - shared utility for workflow-specific activities
@@ -42,9 +43,14 @@ interface InvokeModelConfig {
42
43
  * @param invocationConfig - Per-invocation configuration (system prompt, etc.)
43
44
  * @returns Agent response with message and metadata
44
45
  */
45
- declare function invokeModel(redis: Redis, { threadId, agentName, tools }: InvokeModelConfig, model: BaseChatModel<BaseChatModelCallOptions & {
46
- tools?: BindToolsInput;
47
- }>, { systemPrompt }: InvocationConfig): Promise<AgentResponse>;
46
+ declare function invokeModel({ redis, model, client, config: { threadId, agentName }, }: {
47
+ redis: Redis;
48
+ client: WorkflowClient;
49
+ config: InvokeModelConfig;
50
+ model: BaseChatModel<BaseChatModelCallOptions & {
51
+ tools?: BindToolsInput;
52
+ }>;
53
+ }): Promise<AgentResponse>;
48
54
 
49
55
  /**
50
56
  * Handle user interaction tool result - creates AI messages for display.
@@ -53,79 +59,46 @@ declare const handleAskUserQuestionToolResult: ActivityToolHandler<AskUserQuesti
53
59
  chatMessages: StoredMessage[];
54
60
  }>;
55
61
 
56
- interface GlobHandlerConfig {
57
- provider: FileSystemProvider;
58
- scopedNodes: FileNode[];
59
- }
60
62
  /**
61
- * Create a glob handler that searches within the scoped file tree.
63
+ * Result of a glob operation
62
64
  */
63
- declare function createGlobHandler(config: GlobHandlerConfig): (args: GlobToolSchemaType) => Promise<{
64
- content: string;
65
- result: {
66
- files: FileNode[];
67
- };
68
- }>;
69
-
70
- interface GrepHandlerConfig {
71
- provider: FileSystemProvider;
72
- scopedNodes: FileNode[];
65
+ interface GlobResult {
66
+ files: string[];
73
67
  }
74
68
  /**
75
- * Create a grep handler that searches within the scoped file tree.
69
+ * Glob handler response
76
70
  */
77
- declare function createGrepHandler(config: GrepHandlerConfig): (args: GrepToolSchemaType) => Promise<{
71
+ interface GlobHandlerResponse {
78
72
  content: string;
79
- result: {
80
- matches: GrepMatch[];
81
- };
82
- }>;
83
-
84
- interface ReadHandlerConfig {
85
- provider: FileSystemProvider;
86
- scopedNodes: FileNode[];
73
+ result: GlobResult;
87
74
  }
88
75
  /**
89
- * Create a read handler that reads files within the scoped file tree.
76
+ * Glob handler that searches within the scoped file tree.
77
+ *
78
+ * @param args - Tool arguments (pattern, root)
79
+ * @param provider - FileSystemProvider for I/O operations
90
80
  */
91
- declare function createReadHandler(config: ReadHandlerConfig): (args: ReadToolSchemaType) => Promise<{
92
- content: ContentBlock[];
93
- result: {
94
- path: string;
95
- content: FileContent;
96
- };
97
- }>;
81
+ declare function globHandler(_args: GlobToolSchemaType, fs: IFileSystem): Promise<GlobHandlerResponse>;
98
82
 
99
- interface WriteHandlerConfig {
100
- provider: FileSystemProvider;
101
- scopedNodes: FileNode[];
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
- interface WriteResult {
83
+ /**
84
+ * Result of an edit operation
85
+ */
86
+ interface EditResult {
113
87
  path: string;
114
88
  success: boolean;
115
- created: boolean;
116
- bytesWritten: number;
89
+ replacements: number;
117
90
  }
118
91
  /**
119
- * Create a write handler that writes files within the scoped file tree.
92
+ * Edit handler response
120
93
  */
121
- declare function createWriteHandler(config: WriteHandlerConfig): (args: WriteToolSchemaType) => Promise<{
94
+ interface EditHandlerResponse {
122
95
  content: string;
123
- result: WriteResult;
124
- }>;
125
-
126
- interface EditHandlerConfig {
127
- provider: FileSystemProvider;
128
- scopedNodes: FileNode[];
96
+ result: EditResult;
97
+ }
98
+ /**
99
+ * Options for edit handler
100
+ */
101
+ interface EditHandlerOptions {
129
102
  /**
130
103
  * Set of file paths that have been read in this session.
131
104
  * Required for enforcing read-before-write policy.
@@ -136,17 +109,20 @@ interface EditHandlerConfig {
136
109
  */
137
110
  skipReadCheck?: boolean;
138
111
  }
139
- interface EditResult {
140
- path: string;
141
- success: boolean;
142
- replacements: number;
143
- }
144
112
  /**
145
- * Create an edit handler that edits files within the scoped file tree.
113
+ * Edit handler that edits files within the scoped file tree.
114
+ *
115
+ * @param args - Tool arguments (file_path, old_string, new_string, replace_all)
116
+ * @param options - Additional options (readFiles, skipReadCheck)
146
117
  */
147
- declare function createEditHandler(config: EditHandlerConfig): (args: EditToolSchemaType) => Promise<{
148
- content: string;
149
- result: EditResult;
150
- }>;
118
+ declare function editHandler(args: EditToolSchemaType, fs: IFileSystem): Promise<EditHandlerResponse>;
119
+
120
+ declare const toTree: (fs: IFileSystem, opts?: {
121
+ dir?: string;
122
+ separator?: "/" | "\\";
123
+ depth?: number;
124
+ tab?: string;
125
+ sort?: boolean;
126
+ }) => Promise<string>;
151
127
 
152
- export { ActivityToolHandler, AgentResponse, AskUserQuestionToolSchemaType, type EditHandlerConfig, type EditResult, EditToolSchemaType, FileContent, FileNode, FileSystemProvider, type GlobHandlerConfig, GlobToolSchemaType, type GrepHandlerConfig, GrepMatch, GrepToolSchemaType, InvocationConfig, type InvokeModelConfig, type ReadHandlerConfig, ReadToolSchemaType, ToolDefinition, type WriteHandlerConfig, type WriteResult, WriteToolSchemaType, ZeitlichPlugin, type ZeitlichPluginOptions, createEditHandler, createGlobHandler, createGrepHandler, createReadHandler, createWriteHandler, handleAskUserQuestionToolResult, invokeModel };
128
+ export { ActivityToolHandler, AgentResponse, AskUserQuestionToolSchemaType, type EditHandlerOptions, type EditHandlerResponse, type EditResult, EditToolSchemaType, GlobToolSchemaType, type InvokeModelConfig, ZeitlichPlugin, type ZeitlichPluginOptions, editHandler, globHandler, handleAskUserQuestionToolResult, invokeModel, toTree };