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.
- package/README.md +36 -33
- package/dist/index.cjs +445 -385
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -42
- package/dist/index.d.ts +25 -42
- package/dist/index.js +415 -362
- package/dist/index.js.map +1 -1
- package/dist/{workflow-CCoHnc3B.d.cts → workflow-D-2vp4Pq.d.cts} +456 -253
- package/dist/{workflow-CCoHnc3B.d.ts → workflow-D-2vp4Pq.d.ts} +456 -253
- package/dist/workflow.cjs +339 -272
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +4 -3
- package/dist/workflow.d.ts +4 -3
- package/dist/workflow.js +315 -252
- package/dist/workflow.js.map +1 -1
- package/package.json +3 -2
- package/src/activities.ts +1 -14
- package/src/index.ts +17 -11
- package/src/lib/session.ts +69 -86
- package/src/lib/state-manager.ts +9 -2
- package/src/lib/thread-manager.ts +45 -37
- package/src/lib/tool-router.ts +338 -116
- package/src/lib/types.ts +110 -28
- package/src/tools/ask-user-question/handler.ts +6 -6
- package/src/tools/ask-user-question/tool.ts +3 -2
- package/src/tools/bash/bash.test.ts +32 -32
- package/src/tools/bash/handler.ts +9 -9
- package/src/tools/bash/tool.ts +3 -2
- package/src/tools/edit/handler.ts +78 -123
- package/src/tools/edit/tool.ts +3 -2
- package/src/tools/glob/handler.ts +17 -48
- package/src/tools/glob/tool.ts +3 -2
- package/src/tools/grep/tool.ts +3 -2
- package/src/tools/{read → read-file}/tool.ts +3 -2
- package/src/tools/task/handler.ts +19 -9
- package/src/tools/task/tool.ts +3 -10
- package/src/tools/task-create/handler.ts +11 -20
- package/src/tools/task-create/tool.ts +3 -2
- package/src/tools/task-get/handler.ts +9 -14
- package/src/tools/task-get/tool.ts +3 -2
- package/src/tools/task-list/handler.ts +7 -12
- package/src/tools/task-list/tool.ts +3 -2
- package/src/tools/task-update/handler.ts +9 -16
- package/src/tools/task-update/tool.ts +3 -2
- package/src/tools/{write → write-file}/tool.ts +5 -6
- package/src/workflow.ts +25 -19
package/README.md
CHANGED
|
@@ -84,10 +84,14 @@ Zeitlich provides two entry points to work with Temporal's workflow sandboxing:
|
|
|
84
84
|
|
|
85
85
|
```typescript
|
|
86
86
|
// In workflow files - no external dependencies (Redis, LangChain, etc.)
|
|
87
|
-
import {
|
|
87
|
+
import {
|
|
88
|
+
createSession,
|
|
89
|
+
createAgentStateManager,
|
|
90
|
+
askUserQuestionTool,
|
|
91
|
+
} from "zeitlich/workflow";
|
|
88
92
|
|
|
89
93
|
// In activity files and worker setup - full functionality
|
|
90
|
-
import { ZeitlichPlugin, invokeModel, toTree } from
|
|
94
|
+
import { ZeitlichPlugin, invokeModel, toTree } from "zeitlich";
|
|
91
95
|
```
|
|
92
96
|
|
|
93
97
|
**Why?** Temporal workflows run in an isolated V8 sandbox that cannot import modules with Node.js APIs or external dependencies. The `/workflow` entry point contains only pure TypeScript code safe for workflow use.
|
|
@@ -161,8 +165,6 @@ export async function myAgentWorkflow({ prompt }: { prompt: string }) {
|
|
|
161
165
|
agentName: "my-agent",
|
|
162
166
|
maxTurns: 20,
|
|
163
167
|
runAgent,
|
|
164
|
-
baseSystemPrompt: "You are a helpful assistant.",
|
|
165
|
-
instructionsPrompt: "Help the user with their request.",
|
|
166
168
|
buildContextMessage: () => [{ type: "text", text: prompt }],
|
|
167
169
|
tools: {
|
|
168
170
|
Search: {
|
|
@@ -292,12 +294,12 @@ const session = await createSession({
|
|
|
292
294
|
{
|
|
293
295
|
name: "researcher",
|
|
294
296
|
description: "Researches topics and returns findings",
|
|
295
|
-
|
|
297
|
+
workflow: "researcherWorkflow",
|
|
296
298
|
},
|
|
297
299
|
{
|
|
298
300
|
name: "code-reviewer",
|
|
299
301
|
description: "Reviews code for quality and best practices",
|
|
300
|
-
|
|
302
|
+
workflow: "codeReviewerWorkflow",
|
|
301
303
|
},
|
|
302
304
|
],
|
|
303
305
|
});
|
|
@@ -341,15 +343,15 @@ export const createActivities = () => ({
|
|
|
341
343
|
|
|
342
344
|
Zeitlich provides ready-to-use tool definitions and handlers for common agent operations.
|
|
343
345
|
|
|
344
|
-
| Tool | Description
|
|
345
|
-
| ----------------- |
|
|
346
|
-
| `Read` | Read file contents with optional pagination
|
|
347
|
-
| `Write` | Create or overwrite files with new content
|
|
348
|
-
| `Edit` | Edit specific sections of a file by find/replace
|
|
349
|
-
| `Glob` | Search for files matching a glob pattern
|
|
350
|
-
| `Grep` | Search file contents with regex patterns
|
|
351
|
-
| `Bash` | Execute shell commands
|
|
352
|
-
| `AskUserQuestion` | Ask the user questions during execution with structured options
|
|
346
|
+
| Tool | Description |
|
|
347
|
+
| ----------------- | ----------------------------------------------------------------- |
|
|
348
|
+
| `Read` | Read file contents with optional pagination |
|
|
349
|
+
| `Write` | Create or overwrite files with new content |
|
|
350
|
+
| `Edit` | Edit specific sections of a file by find/replace |
|
|
351
|
+
| `Glob` | Search for files matching a glob pattern |
|
|
352
|
+
| `Grep` | Search file contents with regex patterns |
|
|
353
|
+
| `Bash` | Execute shell commands |
|
|
354
|
+
| `AskUserQuestion` | Ask the user questions during execution with structured options |
|
|
353
355
|
| `Task` | Launch subagents as child workflows (see [Subagents](#subagents)) |
|
|
354
356
|
|
|
355
357
|
```typescript
|
|
@@ -373,7 +375,7 @@ import {
|
|
|
373
375
|
} from "zeitlich";
|
|
374
376
|
```
|
|
375
377
|
|
|
376
|
-
|
|
378
|
+
All tools are passed via `tools`. The Bash tool's description is automatically enhanced with the file tree when provided:
|
|
377
379
|
|
|
378
380
|
```typescript
|
|
379
381
|
const session = await createSession({
|
|
@@ -383,9 +385,10 @@ const session = await createSession({
|
|
|
383
385
|
...askUserQuestionTool,
|
|
384
386
|
handler: handleAskUserQuestionToolResult,
|
|
385
387
|
},
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
388
|
+
Bash: {
|
|
389
|
+
...bashTool,
|
|
390
|
+
handler: handleBashTool(bashOptions),
|
|
391
|
+
},
|
|
389
392
|
},
|
|
390
393
|
});
|
|
391
394
|
```
|
|
@@ -396,27 +399,27 @@ const session = await createSession({
|
|
|
396
399
|
|
|
397
400
|
Safe for use in Temporal workflow files:
|
|
398
401
|
|
|
399
|
-
| Export | Description
|
|
400
|
-
| ------------------------- |
|
|
401
|
-
| `createSession` | Creates an agent session with tools, prompts, subagents, and hooks
|
|
402
|
-
| `createAgentStateManager` | Creates a state manager for workflow state
|
|
403
|
-
| `createToolRouter` | Creates a tool router (used internally by session, or for advanced use)
|
|
404
|
-
| `createTaskTool` | Creates the Task tool for subagent support
|
|
402
|
+
| Export | Description |
|
|
403
|
+
| ------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
404
|
+
| `createSession` | Creates an agent session with tools, prompts, subagents, and hooks |
|
|
405
|
+
| `createAgentStateManager` | Creates a state manager for workflow state |
|
|
406
|
+
| `createToolRouter` | Creates a tool router (used internally by session, or for advanced use) |
|
|
407
|
+
| `createTaskTool` | Creates the Task tool for subagent support |
|
|
405
408
|
| Tool definitions | `askUserQuestionTool`, `globTool`, `grepTool`, `readTool`, `writeTool`, `editTool`, `bashTool` |
|
|
406
409
|
| Task tools | `taskCreateTool`, `taskGetTool`, `taskListTool`, `taskUpdateTool` for workflow task management |
|
|
407
|
-
| Types | All TypeScript types and interfaces
|
|
410
|
+
| Types | All TypeScript types and interfaces |
|
|
408
411
|
|
|
409
412
|
### Activity Entry Point (`zeitlich`)
|
|
410
413
|
|
|
411
414
|
For use in activities, worker setup, and Node.js code:
|
|
412
415
|
|
|
413
|
-
| Export
|
|
414
|
-
|
|
|
415
|
-
| `ZeitlichPlugin`
|
|
416
|
-
| `createSharedActivities`
|
|
417
|
-
| `invokeModel`
|
|
418
|
-
| `toTree`
|
|
419
|
-
| Tool handlers
|
|
416
|
+
| Export | Description |
|
|
417
|
+
| ------------------------ | --------------------------------------------------------------------------------- |
|
|
418
|
+
| `ZeitlichPlugin` | Temporal worker plugin that registers shared activities |
|
|
419
|
+
| `createSharedActivities` | Creates thread management activities |
|
|
420
|
+
| `invokeModel` | Core LLM invocation utility (requires Redis + LangChain) |
|
|
421
|
+
| `toTree` | Generate file tree string from a directory path |
|
|
422
|
+
| Tool handlers | `globHandler`, `editHandler`, `handleBashTool`, `handleAskUserQuestionToolResult` |
|
|
420
423
|
|
|
421
424
|
### Types
|
|
422
425
|
|