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.
- package/README.md +168 -180
- package/dist/index.cjs +1337 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +128 -0
- package/dist/index.d.ts +51 -75
- package/dist/index.js +764 -1091
- package/dist/index.js.map +1 -1
- package/dist/workflow-CCoHnc3B.d.cts +943 -0
- package/dist/workflow-CCoHnc3B.d.ts +943 -0
- package/dist/workflow.cjs +930 -0
- package/dist/workflow.cjs.map +1 -0
- package/dist/workflow.d.cts +5 -0
- package/dist/workflow.d.ts +2 -1
- package/dist/workflow.js +559 -423
- package/dist/workflow.js.map +1 -1
- package/package.json +14 -13
- package/src/activities.ts +112 -0
- package/src/index.ts +49 -0
- package/src/lib/fs.ts +80 -0
- package/src/lib/model-invoker.ts +75 -0
- package/src/lib/session.ts +216 -0
- package/src/lib/state-manager.ts +268 -0
- package/src/lib/thread-manager.ts +169 -0
- package/src/lib/tool-router.ts +717 -0
- package/src/lib/types.ts +354 -0
- package/src/plugin.ts +28 -0
- package/src/tools/ask-user-question/handler.ts +25 -0
- package/src/tools/ask-user-question/tool.ts +46 -0
- package/src/tools/bash/bash.test.ts +104 -0
- package/src/tools/bash/handler.ts +45 -0
- package/src/tools/bash/tool.ts +36 -0
- package/src/tools/edit/handler.ts +156 -0
- package/src/tools/edit/tool.ts +39 -0
- package/src/tools/glob/handler.ts +62 -0
- package/src/tools/glob/tool.ts +27 -0
- package/src/tools/grep/tool.ts +45 -0
- package/src/tools/read/tool.ts +33 -0
- package/src/tools/task/handler.ts +75 -0
- package/src/tools/task/tool.ts +96 -0
- package/src/tools/task-create/handler.ts +49 -0
- package/src/tools/task-create/tool.ts +66 -0
- package/src/tools/task-get/handler.ts +38 -0
- package/src/tools/task-get/tool.ts +11 -0
- package/src/tools/task-list/handler.ts +33 -0
- package/src/tools/task-list/tool.ts +9 -0
- package/src/tools/task-update/handler.ts +79 -0
- package/src/tools/task-update/tool.ts +20 -0
- package/src/tools/write/tool.ts +26 -0
- package/src/workflow.ts +138 -0
- package/tsup.config.ts +22 -0
- package/dist/index.d.mts +0 -152
- package/dist/index.mjs +0 -1587
- package/dist/index.mjs.map +0 -1
- package/dist/workflow-7_MT-5-w.d.mts +0 -1203
- package/dist/workflow-7_MT-5-w.d.ts +0 -1203
- package/dist/workflow.d.mts +0 -4
- package/dist/workflow.mjs +0 -739
- package/dist/workflow.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
[](https://www.npmjs.org/package/zeitlich)
|
|
2
|
+
[](https://npm-stat.com/charts.html?package=zeitlich)
|
|
3
|
+
|
|
1
4
|
# Zeitlich
|
|
2
5
|
|
|
3
6
|
> **⚠️ Experimental Beta**: This library is under active development. APIs and interfaces may change between versions. Use in production at your own risk.
|
|
@@ -48,8 +51,7 @@ const google = new ChatGoogleGenerativeAI({ model: "gemini-1.5-pro" });
|
|
|
48
51
|
|
|
49
52
|
// Pass to invokeModel in your activity
|
|
50
53
|
return {
|
|
51
|
-
runAgent: (config,
|
|
52
|
-
invokeModel(redis, { ...config, tools }, anthropic, invocationConfig),
|
|
54
|
+
runAgent: (config) => invokeModel(redis, config, anthropic),
|
|
53
55
|
};
|
|
54
56
|
```
|
|
55
57
|
|
|
@@ -82,10 +84,10 @@ Zeitlich provides two entry points to work with Temporal's workflow sandboxing:
|
|
|
82
84
|
|
|
83
85
|
```typescript
|
|
84
86
|
// In workflow files - no external dependencies (Redis, LangChain, etc.)
|
|
85
|
-
import { createSession,
|
|
87
|
+
import { createSession, createAgentStateManager, askUserQuestionTool } from 'zeitlich/workflow';
|
|
86
88
|
|
|
87
89
|
// In activity files and worker setup - full functionality
|
|
88
|
-
import { ZeitlichPlugin, invokeModel,
|
|
90
|
+
import { ZeitlichPlugin, invokeModel, toTree } from 'zeitlich';
|
|
89
91
|
```
|
|
90
92
|
|
|
91
93
|
**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.
|
|
@@ -109,8 +111,6 @@ export const searchTool: ToolDefinition<"Search", typeof searchSchema> = {
|
|
|
109
111
|
query: z.string().describe("The search query"),
|
|
110
112
|
}),
|
|
111
113
|
};
|
|
112
|
-
|
|
113
|
-
export const tools = { Search: searchTool };
|
|
114
114
|
```
|
|
115
115
|
|
|
116
116
|
### 2. Create Activities
|
|
@@ -119,7 +119,6 @@ export const tools = { Search: searchTool };
|
|
|
119
119
|
import type Redis from "ioredis";
|
|
120
120
|
import { ChatAnthropic } from "@langchain/anthropic";
|
|
121
121
|
import { invokeModel } from "zeitlich";
|
|
122
|
-
import { tools } from "./tools";
|
|
123
122
|
|
|
124
123
|
export const createActivities = (redis: Redis) => {
|
|
125
124
|
const model = new ChatAnthropic({
|
|
@@ -128,70 +127,52 @@ export const createActivities = (redis: Redis) => {
|
|
|
128
127
|
});
|
|
129
128
|
|
|
130
129
|
return {
|
|
131
|
-
runAgent: (config,
|
|
132
|
-
invokeModel(
|
|
133
|
-
redis,
|
|
134
|
-
{ ...config, tools: Object.values(tools) },
|
|
135
|
-
model,
|
|
136
|
-
invocationConfig
|
|
137
|
-
),
|
|
130
|
+
runAgent: (config) => invokeModel(redis, config, model),
|
|
138
131
|
|
|
139
132
|
handleSearchResult: async ({ args }) => {
|
|
140
|
-
// Your tool implementation
|
|
141
133
|
const results = await performSearch(args.query);
|
|
142
134
|
return { result: { results } };
|
|
143
135
|
},
|
|
144
136
|
};
|
|
145
137
|
};
|
|
138
|
+
|
|
139
|
+
export type MyActivities = ReturnType<typeof createActivities>;
|
|
146
140
|
```
|
|
147
141
|
|
|
148
142
|
### 3. Create the Workflow
|
|
149
143
|
|
|
150
144
|
```typescript
|
|
151
145
|
import { proxyActivities, workflowInfo } from "@temporalio/workflow";
|
|
152
|
-
import {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
createPromptManager,
|
|
156
|
-
createToolRegistry,
|
|
157
|
-
createToolRouter,
|
|
158
|
-
} from "zeitlich/workflow";
|
|
159
|
-
import type { ZeitlichSharedActivities } from "zeitlich/workflow";
|
|
160
|
-
import { tools } from "./tools";
|
|
146
|
+
import { createAgentStateManager, createSession } from "zeitlich/workflow";
|
|
147
|
+
import { searchTool } from "./tools";
|
|
148
|
+
import type { MyActivities } from "./activities";
|
|
161
149
|
|
|
162
150
|
const { runAgent, handleSearchResult } = proxyActivities<MyActivities>({
|
|
163
151
|
startToCloseTimeout: "30m",
|
|
164
152
|
});
|
|
165
153
|
|
|
166
|
-
const { appendToolResult } = proxyActivities<ZeitlichSharedActivities>({
|
|
167
|
-
startToCloseTimeout: "30m",
|
|
168
|
-
});
|
|
169
|
-
|
|
170
154
|
export async function myAgentWorkflow({ prompt }: { prompt: string }) {
|
|
171
155
|
const { runId } = workflowInfo();
|
|
172
156
|
|
|
173
|
-
const stateManager = createAgentStateManager({
|
|
174
|
-
initialState: { prompt },
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
const toolRegistry = createToolRegistry(tools);
|
|
157
|
+
const stateManager = createAgentStateManager({});
|
|
178
158
|
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const promptManager = createPromptManager({
|
|
159
|
+
const session = await createSession({
|
|
160
|
+
threadId: runId,
|
|
161
|
+
agentName: "my-agent",
|
|
162
|
+
maxTurns: 20,
|
|
163
|
+
runAgent,
|
|
185
164
|
baseSystemPrompt: "You are a helpful assistant.",
|
|
165
|
+
instructionsPrompt: "Help the user with their request.",
|
|
186
166
|
buildContextMessage: () => [{ type: "text", text: prompt }],
|
|
167
|
+
tools: {
|
|
168
|
+
Search: {
|
|
169
|
+
...searchTool,
|
|
170
|
+
handler: handleSearchResult,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
187
173
|
});
|
|
188
174
|
|
|
189
|
-
|
|
190
|
-
{ threadId: runId, agentName: "my-agent", maxTurns: 20 },
|
|
191
|
-
{ runAgent, promptManager, toolRouter, toolRegistry }
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
await session.runSession(prompt, stateManager);
|
|
175
|
+
await session.runSession({ stateManager });
|
|
195
176
|
return stateManager.getCurrentState();
|
|
196
177
|
}
|
|
197
178
|
```
|
|
@@ -232,65 +213,72 @@ Manages workflow state with automatic versioning and status tracking:
|
|
|
232
213
|
import { createAgentStateManager } from "zeitlich/workflow";
|
|
233
214
|
|
|
234
215
|
const stateManager = createAgentStateManager({
|
|
235
|
-
|
|
216
|
+
customField: "value",
|
|
236
217
|
});
|
|
237
218
|
|
|
238
219
|
// State operations
|
|
239
220
|
stateManager.set("customField", "new value");
|
|
221
|
+
stateManager.get("customField"); // Get current value
|
|
240
222
|
stateManager.complete(); // Mark as COMPLETED
|
|
241
223
|
stateManager.waitForInput(); // Mark as WAITING_FOR_INPUT
|
|
242
224
|
stateManager.isRunning(); // Check if RUNNING
|
|
243
225
|
stateManager.isTerminal(); // Check if COMPLETED/FAILED/CANCELLED
|
|
244
226
|
```
|
|
245
227
|
|
|
246
|
-
###
|
|
228
|
+
### Tools with Handlers
|
|
247
229
|
|
|
248
|
-
|
|
230
|
+
Define tools with their handlers inline in `createSession`:
|
|
249
231
|
|
|
250
232
|
```typescript
|
|
251
|
-
import {
|
|
233
|
+
import { z } from "zod";
|
|
234
|
+
import type { ToolDefinition } from "zeitlich/workflow";
|
|
252
235
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
236
|
+
// Define tool schema
|
|
237
|
+
const searchTool: ToolDefinition<"Search", typeof searchSchema> = {
|
|
238
|
+
name: "Search",
|
|
239
|
+
description: "Search for information",
|
|
240
|
+
schema: z.object({ query: z.string() }),
|
|
241
|
+
};
|
|
257
242
|
|
|
258
|
-
//
|
|
259
|
-
const
|
|
260
|
-
//
|
|
261
|
-
|
|
243
|
+
// In workflow - combine tool definition with handler
|
|
244
|
+
const session = await createSession({
|
|
245
|
+
// ... other config
|
|
246
|
+
tools: {
|
|
247
|
+
Search: {
|
|
248
|
+
...searchTool,
|
|
249
|
+
handler: handleSearchResult, // Activity that implements the tool
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
});
|
|
262
253
|
```
|
|
263
254
|
|
|
264
|
-
###
|
|
255
|
+
### Lifecycle Hooks
|
|
265
256
|
|
|
266
|
-
|
|
257
|
+
Add hooks for tool execution and session lifecycle:
|
|
267
258
|
|
|
268
259
|
```typescript
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
260
|
+
const session = await createSession({
|
|
261
|
+
// ... other config
|
|
262
|
+
hooks: {
|
|
263
|
+
onPreToolUse: ({ toolCall }) => {
|
|
264
|
+
console.log(`Executing ${toolCall.name}`);
|
|
265
|
+
return {}; // Can return { skip: true } or { modifiedArgs: {...} }
|
|
266
|
+
},
|
|
267
|
+
onPostToolUse: ({ toolCall, result, durationMs }) => {
|
|
268
|
+
console.log(`${toolCall.name} completed in ${durationMs}ms`);
|
|
269
|
+
// Access stateManager here to update state based on results
|
|
270
|
+
},
|
|
271
|
+
onPostToolUseFailure: ({ toolCall, error }) => {
|
|
272
|
+
return { fallbackContent: "Tool failed, please try again" };
|
|
273
|
+
},
|
|
274
|
+
onSessionStart: ({ threadId, agentName }) => {
|
|
275
|
+
console.log(`Session started: ${agentName}`);
|
|
276
|
+
},
|
|
277
|
+
onSessionEnd: ({ exitReason, turns }) => {
|
|
278
|
+
console.log(`Session ended: ${exitReason} after ${turns} turns`);
|
|
287
279
|
},
|
|
288
280
|
},
|
|
289
|
-
|
|
290
|
-
Search: handleSearchResult,
|
|
291
|
-
Calculate: handleCalculateResult,
|
|
292
|
-
}
|
|
293
|
-
);
|
|
281
|
+
});
|
|
294
282
|
```
|
|
295
283
|
|
|
296
284
|
### Subagents
|
|
@@ -298,83 +286,71 @@ const router = createToolRouter(
|
|
|
298
286
|
Spawn child agents as Temporal child workflows:
|
|
299
287
|
|
|
300
288
|
```typescript
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
const { tools, taskHandler } = withSubagentSupport(baseTools, {
|
|
289
|
+
const session = await createSession({
|
|
290
|
+
// ... other config
|
|
305
291
|
subagents: [
|
|
306
292
|
{
|
|
307
293
|
name: "researcher",
|
|
308
294
|
description: "Researches topics and returns findings",
|
|
309
295
|
workflowType: "researcherWorkflow",
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: "code-reviewer",
|
|
299
|
+
description: "Reviews code for quality and best practices",
|
|
300
|
+
workflowType: "codeReviewerWorkflow",
|
|
314
301
|
},
|
|
315
302
|
],
|
|
316
303
|
});
|
|
317
|
-
|
|
318
|
-
// Include taskHandler in your tool router
|
|
319
|
-
const router = createToolRouter(
|
|
320
|
-
{ registry, threadId, appendToolResult },
|
|
321
|
-
{ ...handlers, Task: taskHandler }
|
|
322
|
-
);
|
|
323
304
|
```
|
|
324
305
|
|
|
306
|
+
The `Task` tool is automatically added when subagents are configured, allowing the agent to spawn child workflows.
|
|
307
|
+
|
|
325
308
|
### Filesystem Utilities
|
|
326
309
|
|
|
327
|
-
Built-in support for file operations
|
|
310
|
+
Built-in support for file operations. Use `buildFileTree` to generate a file tree string that's included in the agent's context:
|
|
328
311
|
|
|
329
312
|
```typescript
|
|
330
|
-
// In
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
313
|
+
// In activities
|
|
314
|
+
export const createActivities = () => ({
|
|
315
|
+
generateFileTree: async (): Promise<string> => {
|
|
316
|
+
// Return a formatted file tree string
|
|
317
|
+
return toTree("/path/to/workspace");
|
|
318
|
+
},
|
|
319
|
+
});
|
|
337
320
|
|
|
338
|
-
// In
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
} from "zeitlich";
|
|
321
|
+
// In workflow
|
|
322
|
+
const session = await createSession({
|
|
323
|
+
// ... other config
|
|
324
|
+
buildFileTree: generateFileTree, // Called at session start
|
|
325
|
+
});
|
|
326
|
+
```
|
|
345
327
|
|
|
346
|
-
|
|
347
|
-
const provider = InMemoryFileSystemProvider.fromTextFiles(
|
|
348
|
-
fileTree,
|
|
349
|
-
fileContents
|
|
350
|
-
);
|
|
351
|
-
|
|
352
|
-
// Create tool handlers
|
|
353
|
-
const handlers = {
|
|
354
|
-
Glob: createGlobHandler({ provider, scopedNodes: fileTree }),
|
|
355
|
-
Grep: createGrepHandler({ provider, scopedNodes: fileTree }),
|
|
356
|
-
FileRead: createReadHandler({ provider, scopedNodes: fileTree }),
|
|
357
|
-
};
|
|
328
|
+
For more advanced file operations, use the built-in tool handlers:
|
|
358
329
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
330
|
+
```typescript
|
|
331
|
+
import { globHandler, editHandler, toTree } from "zeitlich";
|
|
332
|
+
|
|
333
|
+
export const createActivities = () => ({
|
|
334
|
+
generateFileTree: () => toTree("/workspace"),
|
|
335
|
+
handleGlob: (args) => globHandler(args),
|
|
336
|
+
handleEdit: (args) => editHandler(args, { basePath: "/workspace" }),
|
|
362
337
|
});
|
|
363
338
|
```
|
|
364
339
|
|
|
365
340
|
### Built-in Tools
|
|
366
341
|
|
|
367
|
-
Zeitlich provides ready-to-use tool definitions and handlers for common agent operations.
|
|
342
|
+
Zeitlich provides ready-to-use tool definitions and handlers for common agent operations.
|
|
368
343
|
|
|
369
|
-
| Tool | Description
|
|
370
|
-
| ----------------- |
|
|
371
|
-
| `
|
|
372
|
-
| `
|
|
373
|
-
| `
|
|
374
|
-
| `Glob` | Search for files matching a glob pattern
|
|
375
|
-
| `Grep` | Search file contents with regex patterns
|
|
376
|
-
| `
|
|
377
|
-
| `
|
|
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 |
|
|
353
|
+
| `Task` | Launch subagents as child workflows (see [Subagents](#subagents)) |
|
|
378
354
|
|
|
379
355
|
```typescript
|
|
380
356
|
// Import tool definitions in workflows
|
|
@@ -384,59 +360,74 @@ import {
|
|
|
384
360
|
editTool,
|
|
385
361
|
globTool,
|
|
386
362
|
grepTool,
|
|
363
|
+
bashTool,
|
|
387
364
|
askUserQuestionTool,
|
|
388
365
|
} from "zeitlich/workflow";
|
|
389
366
|
|
|
390
367
|
// Import handlers in activities
|
|
391
368
|
import {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
createGrepHandler,
|
|
369
|
+
editHandler,
|
|
370
|
+
globHandler,
|
|
371
|
+
handleBashTool,
|
|
372
|
+
handleAskUserQuestionToolResult,
|
|
397
373
|
} from "zeitlich";
|
|
398
374
|
```
|
|
399
375
|
|
|
376
|
+
Built-in tools can be added via `buildInTools` (for tools with special handling like Bash) or as regular tools:
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
const session = await createSession({
|
|
380
|
+
// ... other config
|
|
381
|
+
tools: {
|
|
382
|
+
AskUserQuestion: {
|
|
383
|
+
...askUserQuestionTool,
|
|
384
|
+
handler: handleAskUserQuestionToolResult,
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
buildInTools: {
|
|
388
|
+
Bash: handleBashToolResult,
|
|
389
|
+
},
|
|
390
|
+
});
|
|
391
|
+
```
|
|
392
|
+
|
|
400
393
|
## API Reference
|
|
401
394
|
|
|
402
395
|
### Workflow Entry Point (`zeitlich/workflow`)
|
|
403
396
|
|
|
404
397
|
Safe for use in Temporal workflow files:
|
|
405
398
|
|
|
406
|
-
| Export | Description
|
|
407
|
-
| ------------------------- |
|
|
408
|
-
| `createSession` | Creates an agent session
|
|
409
|
-
| `createAgentStateManager` | Creates a state manager for workflow state
|
|
410
|
-
| `
|
|
411
|
-
| `
|
|
412
|
-
|
|
|
413
|
-
| `
|
|
414
|
-
|
|
|
415
|
-
| Tool definitions | `askUserQuestionTool`, `globTool`, `grepTool`, `readTool`, `writeTool`, `editTool` |
|
|
416
|
-
| Types | All TypeScript types and interfaces |
|
|
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 |
|
|
405
|
+
| Tool definitions | `askUserQuestionTool`, `globTool`, `grepTool`, `readTool`, `writeTool`, `editTool`, `bashTool` |
|
|
406
|
+
| Task tools | `taskCreateTool`, `taskGetTool`, `taskListTool`, `taskUpdateTool` for workflow task management |
|
|
407
|
+
| Types | All TypeScript types and interfaces |
|
|
417
408
|
|
|
418
409
|
### Activity Entry Point (`zeitlich`)
|
|
419
410
|
|
|
420
411
|
For use in activities, worker setup, and Node.js code:
|
|
421
412
|
|
|
422
|
-
| Export
|
|
423
|
-
|
|
|
424
|
-
| `ZeitlichPlugin`
|
|
425
|
-
| `createSharedActivities`
|
|
426
|
-
| `invokeModel`
|
|
427
|
-
| `
|
|
428
|
-
|
|
|
429
|
-
| `BaseFileSystemProvider` | Base class for custom providers |
|
|
430
|
-
| Tool handlers | `createGlobHandler`, `createGrepHandler`, `createReadHandler`, `createWriteHandler`, `createEditHandler` |
|
|
413
|
+
| Export | Description |
|
|
414
|
+
| -------------------------------- | ------------------------------------------------------ |
|
|
415
|
+
| `ZeitlichPlugin` | Temporal worker plugin that registers shared activities |
|
|
416
|
+
| `createSharedActivities` | Creates thread management activities |
|
|
417
|
+
| `invokeModel` | Core LLM invocation utility (requires Redis + LangChain) |
|
|
418
|
+
| `toTree` | Generate file tree string from a directory path |
|
|
419
|
+
| Tool handlers | `globHandler`, `editHandler`, `handleBashTool`, `handleAskUserQuestionToolResult` |
|
|
431
420
|
|
|
432
421
|
### Types
|
|
433
422
|
|
|
434
|
-
| Export
|
|
435
|
-
|
|
|
436
|
-
| `AgentStatus`
|
|
437
|
-
| `ToolDefinition`
|
|
438
|
-
| `
|
|
439
|
-
| `
|
|
423
|
+
| Export | Description |
|
|
424
|
+
| ----------------------- | ---------------------------------------------------------------------------- |
|
|
425
|
+
| `AgentStatus` | `"RUNNING" \| "WAITING_FOR_INPUT" \| "COMPLETED" \| "FAILED" \| "CANCELLED"` |
|
|
426
|
+
| `ToolDefinition` | Tool definition with name, description, and Zod schema |
|
|
427
|
+
| `ToolWithHandler` | Tool definition combined with its handler |
|
|
428
|
+
| `SubagentConfig` | Configuration for subagent workflows |
|
|
429
|
+
| `SessionLifecycleHooks` | Lifecycle hooks interface |
|
|
430
|
+
| `AgentState` | Generic agent state type |
|
|
440
431
|
|
|
441
432
|
## Architecture
|
|
442
433
|
|
|
@@ -450,24 +441,19 @@ For use in activities, worker setup, and Node.js code:
|
|
|
450
441
|
│ │ │
|
|
451
442
|
│ ┌──────────────────────────────────────────────────────────┐ │
|
|
452
443
|
│ │ Workflow │ │
|
|
453
|
-
│ │ ┌────────────────┐
|
|
454
|
-
│ │ │ State Manager │ │
|
|
455
|
-
│ │ │ • Status │ │
|
|
456
|
-
│ │ │ • Turns │ │
|
|
457
|
-
│ │ │ • Custom state │ │
|
|
458
|
-
│ │ └────────────────┘
|
|
459
|
-
│ │
|
|
460
|
-
│ │ ┌────────────────┐ ┌─────────────┐ ┌──────────────┐ │ │
|
|
461
|
-
│ │ │ Prompt Manager │ │Tool Registry│ │ Subagents │ │ │
|
|
462
|
-
│ │ │ • System prompt│ │ • Parsing │ │ • Child WFs │ │ │
|
|
463
|
-
│ │ │ • Context │ │ • Validation│ │ • Results │ │ │
|
|
464
|
-
│ │ └────────────────┘ └─────────────┘ └──────────────┘ │ │
|
|
444
|
+
│ │ ┌────────────────┐ ┌───────────────────────────────┐ │ │
|
|
445
|
+
│ │ │ State Manager │ │ Session │ │ │
|
|
446
|
+
│ │ │ • Status │ │ • Agent loop │ │ │
|
|
447
|
+
│ │ │ • Turns │ │ • Tool routing & hooks │ │ │
|
|
448
|
+
│ │ │ • Custom state │ │ • Prompts (system, context) │ │ │
|
|
449
|
+
│ │ └────────────────┘ │ • Subagent coordination │ │ │
|
|
450
|
+
│ │ └───────────────────────────────────┘ │ │
|
|
465
451
|
│ └──────────────────────────────────────────────────────────┘ │
|
|
466
452
|
│ │ │
|
|
467
453
|
│ ┌──────────────────────────────────────────────────────────┐ │
|
|
468
454
|
│ │ Activities │ │
|
|
469
455
|
│ │ • runAgent (LLM invocation) │ │
|
|
470
|
-
│ │ • Tool handlers
|
|
456
|
+
│ │ • Tool handlers (search, file ops, bash, etc.) │ │
|
|
471
457
|
│ └──────────────────────────────────────────────────────────┘ │
|
|
472
458
|
└─────────────────────────────────────────────────────────────────┘
|
|
473
459
|
│
|
|
@@ -489,6 +475,8 @@ For use in activities, worker setup, and Node.js code:
|
|
|
489
475
|
|
|
490
476
|
Contributions are welcome! Please open an issue or submit a PR.
|
|
491
477
|
|
|
478
|
+
For maintainers: see [RELEASING.md](./RELEASING.md) for the release process.
|
|
479
|
+
|
|
492
480
|
## License
|
|
493
481
|
|
|
494
482
|
MIT © [Bead Technologies Inc.](https://usebead.ai)
|