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/test/task.test.ts
CHANGED
|
@@ -35,13 +35,15 @@ describe('Task Management', () => {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const task = await createTask({
|
|
38
|
-
|
|
38
|
+
tool: func,
|
|
39
39
|
input: { text: 'Long article content...' },
|
|
40
40
|
priority: 'high',
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
expect(task).toBeDefined()
|
|
44
44
|
expect(task.id).toMatch(/^task_/)
|
|
45
|
+
expect(task.tool).toEqual(func)
|
|
46
|
+
// Legacy `function` alias still populated during deprecation window
|
|
45
47
|
expect(task.function).toEqual(func)
|
|
46
48
|
expect(task.priority).toBe('high')
|
|
47
49
|
expect(task.status).toBe('queued')
|
|
@@ -60,11 +62,11 @@ describe('Task Management', () => {
|
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
const task = await createTask({
|
|
63
|
-
|
|
65
|
+
tool: func,
|
|
64
66
|
priority: 'normal',
|
|
65
67
|
})
|
|
66
68
|
|
|
67
|
-
expect(task.
|
|
69
|
+
expect(task.tool?.type).toBe('code')
|
|
68
70
|
expect(task.allowedWorkers).toEqual(['any'])
|
|
69
71
|
})
|
|
70
72
|
|
|
@@ -79,7 +81,7 @@ describe('Task Management', () => {
|
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
const task = await createTask({
|
|
82
|
-
|
|
84
|
+
tool: func,
|
|
83
85
|
})
|
|
84
86
|
|
|
85
87
|
expect(task.allowedWorkers).toEqual(['human'])
|
|
@@ -95,7 +97,7 @@ describe('Task Management', () => {
|
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
const task = await createTask({
|
|
98
|
-
|
|
100
|
+
tool: func,
|
|
99
101
|
})
|
|
100
102
|
|
|
101
103
|
expect(task.allowedWorkers).toEqual(['agent'])
|
|
@@ -109,9 +111,9 @@ describe('Task Management', () => {
|
|
|
109
111
|
output: 'string',
|
|
110
112
|
}
|
|
111
113
|
|
|
112
|
-
const task1 = await createTask({
|
|
114
|
+
const task1 = await createTask({ tool: func })
|
|
113
115
|
const task2 = await createTask({
|
|
114
|
-
|
|
116
|
+
tool: { ...func, name: 'task2' },
|
|
115
117
|
dependencies: [task1.id],
|
|
116
118
|
})
|
|
117
119
|
|
|
@@ -137,7 +139,7 @@ describe('Task Management', () => {
|
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
const task = await createTask({
|
|
140
|
-
|
|
142
|
+
tool: func,
|
|
141
143
|
assignTo: worker,
|
|
142
144
|
})
|
|
143
145
|
|
|
@@ -157,7 +159,7 @@ describe('Task Management', () => {
|
|
|
157
159
|
const scheduledFor = new Date(Date.now() + 60000)
|
|
158
160
|
|
|
159
161
|
const task = await createTask({
|
|
160
|
-
|
|
162
|
+
tool: func,
|
|
161
163
|
scheduledFor,
|
|
162
164
|
})
|
|
163
165
|
|
|
@@ -174,7 +176,7 @@ describe('Task Management', () => {
|
|
|
174
176
|
}
|
|
175
177
|
|
|
176
178
|
const task = await createTask({
|
|
177
|
-
|
|
179
|
+
tool: func,
|
|
178
180
|
tags: ['urgent', 'frontend'],
|
|
179
181
|
metadata: { source: 'api', version: '1.0' },
|
|
180
182
|
})
|
|
@@ -182,6 +184,57 @@ describe('Task Management', () => {
|
|
|
182
184
|
expect(task.tags).toEqual(['urgent', 'frontend'])
|
|
183
185
|
expect(task.metadata).toEqual({ source: 'api', version: '1.0' })
|
|
184
186
|
})
|
|
187
|
+
|
|
188
|
+
it('should set Action supertype fields ($type, verb, tool alias)', async () => {
|
|
189
|
+
const func: FunctionDefinition = {
|
|
190
|
+
type: 'generative',
|
|
191
|
+
name: 'summarize',
|
|
192
|
+
args: { text: 'text' },
|
|
193
|
+
output: 'string',
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const task = await createTask({ tool: func })
|
|
197
|
+
|
|
198
|
+
// $type discriminator
|
|
199
|
+
expect(task.$type).toBe('Task')
|
|
200
|
+
// verb defaults to underlying function name
|
|
201
|
+
expect(task.verb).toBe('summarize')
|
|
202
|
+
// `tool` is canonical; legacy `function` alias mirrors it during
|
|
203
|
+
// the deprecation window (CONTEXT.md vocabulary migration).
|
|
204
|
+
expect(task.tool).toBe(task.function)
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
it('should accept GitHub-issue-shaped fields', async () => {
|
|
208
|
+
const func: FunctionDefinition = {
|
|
209
|
+
type: 'generative',
|
|
210
|
+
name: 'review-pr',
|
|
211
|
+
args: {},
|
|
212
|
+
output: 'string',
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const assignees: WorkerRef[] = [
|
|
216
|
+
{ type: 'human', id: 'user_1', name: 'Alice' },
|
|
217
|
+
{ type: 'human', id: 'user_2', name: 'Bob' },
|
|
218
|
+
]
|
|
219
|
+
|
|
220
|
+
const task = await createTask({
|
|
221
|
+
tool: func,
|
|
222
|
+
title: 'Review PR #42',
|
|
223
|
+
body: '## Summary\n\nReview the proposed change to the auth flow.',
|
|
224
|
+
labels: ['review', 'auth'],
|
|
225
|
+
project: 'sprint-12',
|
|
226
|
+
assignees,
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
expect(task.title).toBe('Review PR #42')
|
|
230
|
+
expect(task.body).toContain('Review the proposed change')
|
|
231
|
+
expect(task.labels).toEqual(['review', 'auth'])
|
|
232
|
+
expect(task.project).toBe('sprint-12')
|
|
233
|
+
expect(task.assignees).toEqual(assignees)
|
|
234
|
+
// First assignee becomes primary `assignment`
|
|
235
|
+
expect(task.assignment?.worker).toEqual(assignees[0])
|
|
236
|
+
expect(task.status).toBe('assigned')
|
|
237
|
+
})
|
|
185
238
|
})
|
|
186
239
|
|
|
187
240
|
describe('getTask()', () => {
|
|
@@ -193,7 +246,7 @@ describe('Task Management', () => {
|
|
|
193
246
|
output: 'string',
|
|
194
247
|
}
|
|
195
248
|
|
|
196
|
-
const created = await createTask({
|
|
249
|
+
const created = await createTask({ tool: func })
|
|
197
250
|
const retrieved = await getTask(created.id)
|
|
198
251
|
|
|
199
252
|
expect(retrieved).toBeDefined()
|
|
@@ -215,7 +268,7 @@ describe('Task Management', () => {
|
|
|
215
268
|
output: 'string',
|
|
216
269
|
}
|
|
217
270
|
|
|
218
|
-
const task = await createTask({
|
|
271
|
+
const task = await createTask({ tool: func })
|
|
219
272
|
const worker: WorkerRef = { type: 'agent', id: 'agent_1', name: 'Worker' }
|
|
220
273
|
|
|
221
274
|
const started = await startTask(task.id, worker)
|
|
@@ -241,7 +294,7 @@ describe('Task Management', () => {
|
|
|
241
294
|
output: 'string',
|
|
242
295
|
}
|
|
243
296
|
|
|
244
|
-
const task = await createTask({
|
|
297
|
+
const task = await createTask({ tool: func })
|
|
245
298
|
const updated = await updateProgress(task.id, 50, 'Processing data')
|
|
246
299
|
|
|
247
300
|
expect(updated).toBeDefined()
|
|
@@ -259,7 +312,7 @@ describe('Task Management', () => {
|
|
|
259
312
|
output: 'string',
|
|
260
313
|
}
|
|
261
314
|
|
|
262
|
-
const task = await createTask({
|
|
315
|
+
const task = await createTask({ tool: func })
|
|
263
316
|
const worker: WorkerRef = { type: 'agent', id: 'agent_1' }
|
|
264
317
|
await startTask(task.id, worker)
|
|
265
318
|
|
|
@@ -287,7 +340,7 @@ describe('Task Management', () => {
|
|
|
287
340
|
output: 'string',
|
|
288
341
|
}
|
|
289
342
|
|
|
290
|
-
const task = await createTask({
|
|
343
|
+
const task = await createTask({ tool: func })
|
|
291
344
|
const result = await failTask(task.id, 'Something went wrong')
|
|
292
345
|
|
|
293
346
|
expect(result.success).toBe(false)
|
|
@@ -303,7 +356,7 @@ describe('Task Management', () => {
|
|
|
303
356
|
output: 'string',
|
|
304
357
|
}
|
|
305
358
|
|
|
306
|
-
const task = await createTask({
|
|
359
|
+
const task = await createTask({ tool: func })
|
|
307
360
|
const error = new Error('Error object message')
|
|
308
361
|
const result = await failTask(task.id, error)
|
|
309
362
|
|
|
@@ -321,7 +374,7 @@ describe('Task Management', () => {
|
|
|
321
374
|
output: 'string',
|
|
322
375
|
}
|
|
323
376
|
|
|
324
|
-
const task = await createTask({
|
|
377
|
+
const task = await createTask({ tool: func })
|
|
325
378
|
const cancelled = await cancelTask(task.id, 'No longer needed')
|
|
326
379
|
|
|
327
380
|
expect(cancelled).toBe(true)
|
|
@@ -345,13 +398,13 @@ describe('Task Management', () => {
|
|
|
345
398
|
output: 'string',
|
|
346
399
|
}
|
|
347
400
|
|
|
348
|
-
const task = await createTask({
|
|
401
|
+
const task = await createTask({ tool: func })
|
|
349
402
|
const author: WorkerRef = { type: 'human', id: 'user_1', name: 'John' }
|
|
350
403
|
|
|
351
404
|
const updated = await addComment(task.id, 'This is a comment', author)
|
|
352
405
|
|
|
353
406
|
expect(updated).toBeDefined()
|
|
354
|
-
const commentEvent = updated!.events?.find(e => e.type === 'comment')
|
|
407
|
+
const commentEvent = updated!.events?.find((e) => e.type === 'comment')
|
|
355
408
|
expect(commentEvent).toBeDefined()
|
|
356
409
|
expect(commentEvent!.message).toBe('This is a comment')
|
|
357
410
|
expect(commentEvent!.actor).toEqual(author)
|
|
@@ -367,10 +420,10 @@ describe('Task Management', () => {
|
|
|
367
420
|
output: 'string',
|
|
368
421
|
}
|
|
369
422
|
|
|
370
|
-
const parent = await createTask({
|
|
423
|
+
const parent = await createTask({ tool: func })
|
|
371
424
|
|
|
372
425
|
const subtask = await createSubtask(parent.id, {
|
|
373
|
-
|
|
426
|
+
tool: {
|
|
374
427
|
type: 'generative',
|
|
375
428
|
name: 'subtask',
|
|
376
429
|
args: {},
|
|
@@ -391,13 +444,13 @@ describe('Task Management', () => {
|
|
|
391
444
|
output: 'string',
|
|
392
445
|
}
|
|
393
446
|
|
|
394
|
-
const parent = await createTask({
|
|
447
|
+
const parent = await createTask({ tool: func })
|
|
395
448
|
|
|
396
449
|
await createSubtask(parent.id, {
|
|
397
|
-
|
|
450
|
+
tool: { type: 'generative', name: 'sub1', args: {}, output: 'string' },
|
|
398
451
|
})
|
|
399
452
|
await createSubtask(parent.id, {
|
|
400
|
-
|
|
453
|
+
tool: { type: 'generative', name: 'sub2', args: {}, output: 'string' },
|
|
401
454
|
})
|
|
402
455
|
|
|
403
456
|
const subtasks = await getSubtasks(parent.id)
|
|
@@ -414,7 +467,7 @@ describe('Task Management', () => {
|
|
|
414
467
|
output: 'string',
|
|
415
468
|
}
|
|
416
469
|
|
|
417
|
-
const task = await createTask({
|
|
470
|
+
const task = await createTask({ tool: func })
|
|
418
471
|
await completeTask(task.id, 'done')
|
|
419
472
|
|
|
420
473
|
const result = await waitForTask(task.id, { timeout: 1000 })
|
|
@@ -431,7 +484,7 @@ describe('Task Management', () => {
|
|
|
431
484
|
output: 'string',
|
|
432
485
|
}
|
|
433
486
|
|
|
434
|
-
const task = await createTask({
|
|
487
|
+
const task = await createTask({ tool: func })
|
|
435
488
|
await failTask(task.id, 'task failed')
|
|
436
489
|
|
|
437
490
|
const result = await waitForTask(task.id, { timeout: 1000 })
|
|
@@ -447,7 +500,7 @@ describe('Task Management', () => {
|
|
|
447
500
|
output: 'string',
|
|
448
501
|
}
|
|
449
502
|
|
|
450
|
-
const task = await createTask({
|
|
503
|
+
const task = await createTask({ tool: func })
|
|
451
504
|
await cancelTask(task.id)
|
|
452
505
|
|
|
453
506
|
const result = await waitForTask(task.id, { timeout: 1000 })
|