digital-tasks 2.1.1 → 2.3.0
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/CHANGELOG.md +18 -0
- package/README.md +560 -0
- package/package.json +20 -5
- package/src/client.ts +268 -0
- package/src/index.ts +12 -10
- package/src/markdown.ts +63 -48
- package/src/project.ts +57 -42
- package/src/queue.ts +76 -37
- package/src/task.ts +132 -75
- package/src/types.ts +177 -40
- package/src/worker.ts +959 -0
- package/test/project.test.ts +28 -84
- package/test/queue.test.ts +51 -24
- package/test/task.test.ts +80 -27
- package/test/worker.test.ts +1158 -0
- package/tsconfig.json +2 -13
- package/vitest.config.ts +48 -0
- package/wrangler.jsonc +44 -0
- package/.turbo/turbo-build.log +0 -5
- package/dist/function-task.d.ts +0 -319
- package/dist/function-task.d.ts.map +0 -1
- package/dist/function-task.js +0 -286
- package/dist/function-task.js.map +0 -1
- package/dist/index.d.ts +0 -72
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -74
- package/dist/index.js.map +0 -1
- package/dist/markdown.d.ts +0 -112
- package/dist/markdown.d.ts.map +0 -1
- package/dist/markdown.js +0 -510
- package/dist/markdown.js.map +0 -1
- package/dist/project.d.ts +0 -259
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -397
- package/dist/project.js.map +0 -1
- package/dist/queue.d.ts +0 -17
- package/dist/queue.d.ts.map +0 -1
- package/dist/queue.js +0 -347
- package/dist/queue.js.map +0 -1
- package/dist/task.d.ts +0 -69
- package/dist/task.d.ts.map +0 -1
- package/dist/task.js +0 -321
- package/dist/task.js.map +0 -1
- package/dist/types.d.ts +0 -292
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -15
- package/dist/types.js.map +0 -1
- package/src/index.js +0 -73
- package/src/markdown.js +0 -509
- package/src/project.js +0 -396
- package/src/queue.js +0 -346
- package/src/task.js +0 -320
- package/src/types.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# digital-tasks
|
|
2
2
|
|
|
3
|
+
## 2.3.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [9e2779a]
|
|
8
|
+
- ai-functions@2.3.0
|
|
9
|
+
- digital-tools@2.3.0
|
|
10
|
+
- digital-workers@2.3.0
|
|
11
|
+
|
|
12
|
+
## 2.1.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- ai-functions@2.1.3
|
|
18
|
+
- digital-workers@2.1.3
|
|
19
|
+
- digital-tools@2.1.3
|
|
20
|
+
|
|
3
21
|
## 2.1.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
# digital-tasks
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Task management primitives for digital workers (agents and humans).
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
`digital-tasks` provides a comprehensive framework for managing tasks that can be executed by AI agents, humans, or hybrid teams. Every task wraps a function (code, generative, agentic, or human) with lifecycle management, worker assignment, and dependency tracking.
|
|
10
|
+
|
|
11
|
+
**Key concept:** Task = Function + metadata (status, progress, assignment, dependencies)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install digital-tasks
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add digital-tasks
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add digital-tasks
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
### Creating and Managing Tasks
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import {
|
|
33
|
+
createTask,
|
|
34
|
+
startTask,
|
|
35
|
+
updateProgress,
|
|
36
|
+
completeTask,
|
|
37
|
+
taskQueue
|
|
38
|
+
} from 'digital-tasks'
|
|
39
|
+
|
|
40
|
+
// Create a task from a function definition
|
|
41
|
+
const task = await createTask({
|
|
42
|
+
function: {
|
|
43
|
+
type: 'generative',
|
|
44
|
+
name: 'summarize',
|
|
45
|
+
description: 'Summarize text content',
|
|
46
|
+
args: { text: 'The text to summarize' },
|
|
47
|
+
output: 'string',
|
|
48
|
+
},
|
|
49
|
+
input: { text: 'Long article content...' },
|
|
50
|
+
priority: 'high',
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// Start working on the task
|
|
54
|
+
await startTask(task.id, { type: 'agent', id: 'agent_1', name: 'Summarizer' })
|
|
55
|
+
|
|
56
|
+
// Update progress
|
|
57
|
+
await updateProgress(task.id, 50, 'Processing content')
|
|
58
|
+
|
|
59
|
+
// Complete the task
|
|
60
|
+
await completeTask(task.id, 'Summary of the article...')
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Projects with Parallel/Sequential Tasks
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import {
|
|
67
|
+
createProject,
|
|
68
|
+
task,
|
|
69
|
+
parallel,
|
|
70
|
+
sequential,
|
|
71
|
+
toMarkdown
|
|
72
|
+
} from 'digital-tasks'
|
|
73
|
+
|
|
74
|
+
const project = createProject({
|
|
75
|
+
name: 'Launch Feature',
|
|
76
|
+
tasks: [
|
|
77
|
+
parallel(
|
|
78
|
+
task('Design mockups'),
|
|
79
|
+
task('Write tech spec'),
|
|
80
|
+
),
|
|
81
|
+
sequential(
|
|
82
|
+
task('Implement backend'),
|
|
83
|
+
task('Implement frontend'),
|
|
84
|
+
task('Write tests'),
|
|
85
|
+
),
|
|
86
|
+
],
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
// Convert to markdown for display
|
|
90
|
+
const markdown = toMarkdown(project)
|
|
91
|
+
// Output:
|
|
92
|
+
// # Launch Feature
|
|
93
|
+
//
|
|
94
|
+
// - [ ] Design mockups
|
|
95
|
+
// - [ ] Write tech spec
|
|
96
|
+
//
|
|
97
|
+
// 1. [ ] Implement backend
|
|
98
|
+
// 2. [ ] Implement frontend
|
|
99
|
+
// 3. [ ] Write tests
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## API Reference
|
|
103
|
+
|
|
104
|
+
### Task Management
|
|
105
|
+
|
|
106
|
+
#### `createTask(options)`
|
|
107
|
+
|
|
108
|
+
Creates a new task from a function definition.
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
const task = await createTask({
|
|
112
|
+
function: FunctionDefinition, // The function to execute
|
|
113
|
+
input?: unknown, // Input data for the function
|
|
114
|
+
priority?: TaskPriority, // 'low' | 'normal' | 'high' | 'urgent' | 'critical'
|
|
115
|
+
allowedWorkers?: WorkerType[], // 'agent' | 'human' | 'team' | 'any'
|
|
116
|
+
assignTo?: WorkerRef, // Assign to a specific worker
|
|
117
|
+
dependencies?: string[], // Task IDs this task depends on
|
|
118
|
+
scheduledFor?: Date, // Schedule for later execution
|
|
119
|
+
deadline?: Date, // Task deadline
|
|
120
|
+
timeout?: number, // Timeout in milliseconds
|
|
121
|
+
tags?: string[], // Tags for organization
|
|
122
|
+
parentId?: string, // Parent task ID (for subtasks)
|
|
123
|
+
projectId?: string, // Project this task belongs to
|
|
124
|
+
metadata?: Record<string, unknown>
|
|
125
|
+
})
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### `startTask(taskId, worker)`
|
|
129
|
+
|
|
130
|
+
Assigns a worker to a task and starts execution.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
const worker: WorkerRef = { type: 'agent', id: 'agent_1', name: 'Worker' }
|
|
134
|
+
const task = await startTask(taskId, worker)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### `updateProgress(taskId, percent, step?)`
|
|
138
|
+
|
|
139
|
+
Updates the progress of a task.
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
await updateProgress(taskId, 75, 'Finalizing output')
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### `completeTask(taskId, output)`
|
|
146
|
+
|
|
147
|
+
Marks a task as completed with the given output.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
const result = await completeTask(taskId, { summary: 'Task result' })
|
|
151
|
+
// result.success === true
|
|
152
|
+
// result.output contains the output
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### `failTask(taskId, error)`
|
|
156
|
+
|
|
157
|
+
Marks a task as failed with an error.
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
const result = await failTask(taskId, 'Something went wrong')
|
|
161
|
+
// or
|
|
162
|
+
const result = await failTask(taskId, new Error('Something went wrong'))
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### `cancelTask(taskId, reason?)`
|
|
166
|
+
|
|
167
|
+
Cancels a task.
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
const cancelled = await cancelTask(taskId, 'No longer needed')
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### `waitForTask(taskId, options?)`
|
|
174
|
+
|
|
175
|
+
Waits for a task to complete, fail, or be cancelled.
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
const result = await waitForTask(taskId, {
|
|
179
|
+
timeout: 60000, // 60 seconds (default: 5 minutes)
|
|
180
|
+
pollInterval: 1000 // Check every second (default: 1 second)
|
|
181
|
+
})
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### `addComment(taskId, comment, author?)`
|
|
185
|
+
|
|
186
|
+
Adds a comment to a task's event history.
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
await addComment(taskId, 'This is looking good', { type: 'human', id: 'user_1' })
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### `createSubtask(parentTaskId, options)`
|
|
193
|
+
|
|
194
|
+
Creates a subtask of an existing task.
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
const subtask = await createSubtask(parentTaskId, {
|
|
198
|
+
function: { type: 'generative', name: 'subtask', args: {}, output: 'string' }
|
|
199
|
+
})
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### `getSubtasks(parentTaskId)`
|
|
203
|
+
|
|
204
|
+
Gets all subtasks of a parent task.
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
const subtasks = await getSubtasks(parentTaskId)
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Task Queue
|
|
211
|
+
|
|
212
|
+
#### `taskQueue`
|
|
213
|
+
|
|
214
|
+
Global task queue instance.
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
import { taskQueue } from 'digital-tasks'
|
|
218
|
+
|
|
219
|
+
// Query tasks
|
|
220
|
+
const tasks = await taskQueue.query({
|
|
221
|
+
status: 'queued',
|
|
222
|
+
priority: ['high', 'urgent'],
|
|
223
|
+
tags: ['frontend'],
|
|
224
|
+
sortBy: 'priority',
|
|
225
|
+
sortOrder: 'desc'
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
// Get queue statistics
|
|
229
|
+
const stats = await taskQueue.stats()
|
|
230
|
+
// { total, byStatus, byPriority, avgWaitTime, avgCompletionTime }
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### `createTaskQueue(options?)`
|
|
234
|
+
|
|
235
|
+
Creates a new task queue instance.
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
const queue = createTaskQueue({
|
|
239
|
+
name: 'my-queue',
|
|
240
|
+
concurrency: 10,
|
|
241
|
+
defaultTimeout: 300000, // 5 minutes
|
|
242
|
+
persistent: false
|
|
243
|
+
})
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Project DSL
|
|
247
|
+
|
|
248
|
+
#### `task(title, options?)`
|
|
249
|
+
|
|
250
|
+
Creates a task definition for use in projects.
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
const t = task('Implement feature', {
|
|
254
|
+
description: 'Build the new dashboard widget',
|
|
255
|
+
priority: 'high',
|
|
256
|
+
functionType: 'agentic', // 'code' | 'generative' | 'agentic' | 'human'
|
|
257
|
+
assignTo: { type: 'agent', id: 'agent_1' },
|
|
258
|
+
tags: ['feature', 'dashboard'],
|
|
259
|
+
subtasks: [
|
|
260
|
+
task('Write tests'),
|
|
261
|
+
task('Update documentation')
|
|
262
|
+
]
|
|
263
|
+
})
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
#### `parallel(...tasks)`
|
|
267
|
+
|
|
268
|
+
Groups tasks that can run simultaneously.
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
parallel(
|
|
272
|
+
task('Design UI'),
|
|
273
|
+
task('Write API specs'),
|
|
274
|
+
task('Set up infrastructure'),
|
|
275
|
+
)
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
#### `sequential(...tasks)`
|
|
279
|
+
|
|
280
|
+
Groups tasks that must run in order.
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
sequential(
|
|
284
|
+
task('Implement backend'),
|
|
285
|
+
task('Implement frontend'),
|
|
286
|
+
task('Integration testing'),
|
|
287
|
+
)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
#### `createProject(options)`
|
|
291
|
+
|
|
292
|
+
Creates a new project.
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
const project = createProject({
|
|
296
|
+
name: 'Feature Launch',
|
|
297
|
+
description: 'Ship the new dashboard feature',
|
|
298
|
+
tasks: [...],
|
|
299
|
+
defaultMode: 'sequential', // or 'parallel'
|
|
300
|
+
owner: { type: 'human', id: 'user_1', name: 'John' },
|
|
301
|
+
tags: ['q1', 'priority']
|
|
302
|
+
})
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
#### `workflow(name, description?)`
|
|
306
|
+
|
|
307
|
+
Fluent API for building projects.
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
const project = workflow('Feature Launch')
|
|
311
|
+
.parallel(
|
|
312
|
+
task('Design'),
|
|
313
|
+
task('Spec'),
|
|
314
|
+
)
|
|
315
|
+
.then(task('Implement'))
|
|
316
|
+
.then(task('Test'))
|
|
317
|
+
.parallel(
|
|
318
|
+
task('Deploy staging'),
|
|
319
|
+
task('Update docs'),
|
|
320
|
+
)
|
|
321
|
+
.then(task('Deploy production'))
|
|
322
|
+
.build()
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
#### `materializeProject(project)`
|
|
326
|
+
|
|
327
|
+
Converts a project's task definitions into actual Task objects with dependencies.
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
const { project, tasks } = await materializeProject(project)
|
|
331
|
+
// tasks is an array of Task objects ready for execution
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Dependency Graph Utilities
|
|
335
|
+
|
|
336
|
+
#### `getDependants(taskId, allTasks)`
|
|
337
|
+
|
|
338
|
+
Gets all tasks that depend on the given task.
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
341
|
+
const dependants = getDependants('task_1', allTasks)
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
#### `getDependencies(task, allTasks)`
|
|
345
|
+
|
|
346
|
+
Gets all tasks that the given task depends on.
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
const dependencies = getDependencies(task, allTasks)
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
#### `getReadyTasks(allTasks)`
|
|
353
|
+
|
|
354
|
+
Gets tasks that are ready to execute (no unsatisfied dependencies).
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
const ready = getReadyTasks(allTasks)
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
#### `hasCycles(allTasks)`
|
|
361
|
+
|
|
362
|
+
Checks if the task dependency graph contains cycles.
|
|
363
|
+
|
|
364
|
+
```typescript
|
|
365
|
+
if (hasCycles(allTasks)) {
|
|
366
|
+
console.error('Circular dependency detected!')
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
#### `sortTasks(allTasks)`
|
|
371
|
+
|
|
372
|
+
Sorts tasks in topological order (dependencies first).
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
const sorted = sortTasks(allTasks)
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Markdown Integration
|
|
379
|
+
|
|
380
|
+
#### `parseMarkdown(markdown)`
|
|
381
|
+
|
|
382
|
+
Parses a markdown task list into a Project.
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
const markdown = `
|
|
386
|
+
# My Project
|
|
387
|
+
|
|
388
|
+
## Planning (parallel)
|
|
389
|
+
- [ ] Design mockups
|
|
390
|
+
- [ ] Write technical spec
|
|
391
|
+
- [x] Create project board
|
|
392
|
+
|
|
393
|
+
## Implementation (sequential)
|
|
394
|
+
1. [ ] Implement backend API
|
|
395
|
+
2. [-] Implement frontend UI
|
|
396
|
+
- [ ] Create components
|
|
397
|
+
- [ ] Add state management
|
|
398
|
+
3. [ ] Write tests
|
|
399
|
+
`
|
|
400
|
+
|
|
401
|
+
const project = parseMarkdown(markdown)
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
**Markdown Syntax:**
|
|
405
|
+
- `- [ ]` - Unordered/parallel tasks
|
|
406
|
+
- `1. [ ]` - Ordered/sequential tasks
|
|
407
|
+
- `- [x]` - Completed task
|
|
408
|
+
- `- [-]` - In progress task
|
|
409
|
+
- `- [~]` - Blocked task
|
|
410
|
+
- `- [!]` - Failed task
|
|
411
|
+
- `- [/]` - Cancelled task
|
|
412
|
+
- `- [?]` - In review task
|
|
413
|
+
- Indentation (2 spaces) - Subtasks
|
|
414
|
+
- `# Heading` - Project name
|
|
415
|
+
- `## Heading` - Task group/section
|
|
416
|
+
- `## Section (parallel)` or `## Section (sequential)` - Explicit execution mode
|
|
417
|
+
|
|
418
|
+
**Priority markers in task titles:**
|
|
419
|
+
- `!!` - Critical priority
|
|
420
|
+
- `!` - Urgent priority
|
|
421
|
+
- `^` - High priority
|
|
422
|
+
- `v` - Low priority
|
|
423
|
+
|
|
424
|
+
#### `toMarkdown(project, options?)`
|
|
425
|
+
|
|
426
|
+
Serializes a Project to markdown.
|
|
427
|
+
|
|
428
|
+
```typescript
|
|
429
|
+
const markdown = toMarkdown(project, {
|
|
430
|
+
includeStatus: true, // Include status markers (default: true)
|
|
431
|
+
includePriority: false, // Include priority markers (default: false)
|
|
432
|
+
indentSize: 2, // Indent size in spaces (default: 2)
|
|
433
|
+
includeSections: true // Include section headings (default: true)
|
|
434
|
+
})
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
#### `syncStatusFromMarkdown(project, markdown)`
|
|
438
|
+
|
|
439
|
+
Updates task statuses in a project from edited markdown.
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
const updatedProject = syncStatusFromMarkdown(project, editedMarkdown)
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
## Types
|
|
446
|
+
|
|
447
|
+
### Task
|
|
448
|
+
|
|
449
|
+
```typescript
|
|
450
|
+
interface Task<TInput = unknown, TOutput = unknown> {
|
|
451
|
+
id: string
|
|
452
|
+
function: FunctionDefinition<TInput, TOutput>
|
|
453
|
+
status: TaskStatus
|
|
454
|
+
priority: TaskPriority
|
|
455
|
+
input?: TInput
|
|
456
|
+
output?: TOutput
|
|
457
|
+
error?: string
|
|
458
|
+
allowedWorkers?: WorkerType[]
|
|
459
|
+
assignment?: TaskAssignment
|
|
460
|
+
dependencies?: TaskDependency[]
|
|
461
|
+
progress?: TaskProgress
|
|
462
|
+
createdAt: Date
|
|
463
|
+
scheduledFor?: Date
|
|
464
|
+
deadline?: Date
|
|
465
|
+
startedAt?: Date
|
|
466
|
+
completedAt?: Date
|
|
467
|
+
timeout?: number
|
|
468
|
+
parentId?: string
|
|
469
|
+
projectId?: string
|
|
470
|
+
tags?: string[]
|
|
471
|
+
metadata?: Record<string, unknown>
|
|
472
|
+
events?: TaskEvent[]
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### TaskStatus
|
|
477
|
+
|
|
478
|
+
```typescript
|
|
479
|
+
type TaskStatus =
|
|
480
|
+
| 'pending' // Created but not started
|
|
481
|
+
| 'queued' // In queue waiting for worker
|
|
482
|
+
| 'assigned' // Assigned to a worker
|
|
483
|
+
| 'in_progress' // Being worked on
|
|
484
|
+
| 'blocked' // Waiting on dependency
|
|
485
|
+
| 'review' // Awaiting review
|
|
486
|
+
| 'completed' // Successfully finished
|
|
487
|
+
| 'failed' // Failed with error
|
|
488
|
+
| 'cancelled' // Cancelled
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### TaskPriority
|
|
492
|
+
|
|
493
|
+
```typescript
|
|
494
|
+
type TaskPriority = 'low' | 'normal' | 'high' | 'urgent' | 'critical'
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
### WorkerRef
|
|
498
|
+
|
|
499
|
+
```typescript
|
|
500
|
+
interface WorkerRef {
|
|
501
|
+
type: WorkerType // 'agent' | 'human' | 'team' | 'any'
|
|
502
|
+
id: string
|
|
503
|
+
name?: string
|
|
504
|
+
role?: string
|
|
505
|
+
}
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### FunctionDefinition
|
|
509
|
+
|
|
510
|
+
Tasks wrap function definitions from `ai-functions`:
|
|
511
|
+
|
|
512
|
+
```typescript
|
|
513
|
+
// Code function - generates/executes code
|
|
514
|
+
interface CodeFunctionDefinition {
|
|
515
|
+
type: 'code'
|
|
516
|
+
name: string
|
|
517
|
+
args: Record<string, unknown>
|
|
518
|
+
output: string
|
|
519
|
+
code: string
|
|
520
|
+
language: string
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// Generative function - AI generates content (no tools)
|
|
524
|
+
interface GenerativeFunctionDefinition {
|
|
525
|
+
type: 'generative'
|
|
526
|
+
name: string
|
|
527
|
+
description?: string
|
|
528
|
+
args: Record<string, unknown>
|
|
529
|
+
output: string
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// Agentic function - AI with tools in a loop
|
|
533
|
+
interface AgenticFunctionDefinition {
|
|
534
|
+
type: 'agentic'
|
|
535
|
+
name: string
|
|
536
|
+
args: Record<string, unknown>
|
|
537
|
+
output: string
|
|
538
|
+
tools: unknown[]
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// Human function - requires human input
|
|
542
|
+
interface HumanFunctionDefinition {
|
|
543
|
+
type: 'human'
|
|
544
|
+
name: string
|
|
545
|
+
description?: string
|
|
546
|
+
args: Record<string, unknown>
|
|
547
|
+
output: string
|
|
548
|
+
instructions: string
|
|
549
|
+
}
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
## Dependencies
|
|
553
|
+
|
|
554
|
+
- `ai-functions` - Function definition types and utilities
|
|
555
|
+
- `digital-tools` - Tool definitions for agentic functions
|
|
556
|
+
- `digital-workers` - Worker primitives
|
|
557
|
+
|
|
558
|
+
## License
|
|
559
|
+
|
|
560
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "digital-tasks",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Task management primitives for digital workers (agents and humans)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,20 +13,35 @@
|
|
|
13
13
|
"./queue": {
|
|
14
14
|
"import": "./dist/queue.js",
|
|
15
15
|
"types": "./dist/queue.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./worker": {
|
|
18
|
+
"import": "./dist/worker.js",
|
|
19
|
+
"types": "./dist/worker.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./client": {
|
|
22
|
+
"import": "./dist/client.js",
|
|
23
|
+
"types": "./dist/client.d.ts"
|
|
16
24
|
}
|
|
17
25
|
},
|
|
18
26
|
"scripts": {
|
|
19
27
|
"build": "tsc",
|
|
20
28
|
"dev": "tsc --watch",
|
|
21
|
-
"test": "vitest",
|
|
29
|
+
"test": "vitest run",
|
|
22
30
|
"typecheck": "tsc --noEmit",
|
|
23
31
|
"lint": "eslint .",
|
|
24
32
|
"clean": "rm -rf dist"
|
|
25
33
|
},
|
|
26
34
|
"dependencies": {
|
|
27
|
-
"ai-functions": "2.
|
|
28
|
-
"digital-
|
|
29
|
-
"digital-
|
|
35
|
+
"ai-functions": "2.3.0",
|
|
36
|
+
"digital-objects": "1.1.0",
|
|
37
|
+
"digital-tools": "2.3.0",
|
|
38
|
+
"digital-workers": "2.3.0",
|
|
39
|
+
"rpc.do": "^0.1.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@cloudflare/vitest-pool-workers": "^0.8.0",
|
|
43
|
+
"@cloudflare/workers-types": "^4.20250124.0",
|
|
44
|
+
"vitest": "3.0.4"
|
|
30
45
|
},
|
|
31
46
|
"keywords": [
|
|
32
47
|
"ai",
|