digital-tasks 2.0.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/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +10 -0
- package/dist/function-task.d.ts +319 -0
- package/dist/function-task.d.ts.map +1 -0
- package/dist/function-task.js +286 -0
- package/dist/function-task.js.map +1 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown.d.ts +112 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +510 -0
- package/dist/markdown.js.map +1 -0
- package/dist/project.d.ts +259 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +397 -0
- package/dist/project.js.map +1 -0
- package/dist/queue.d.ts +17 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +347 -0
- package/dist/queue.js.map +1 -0
- package/dist/task.d.ts +69 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +321 -0
- package/dist/task.js.map +1 -0
- package/dist/types.d.ts +292 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/package.json +41 -0
- package/src/index.ts +161 -0
- package/src/markdown.ts +622 -0
- package/src/project.ts +571 -0
- package/src/queue.ts +424 -0
- package/src/task.ts +389 -0
- package/src/types.ts +403 -0
- package/test/markdown.test.ts +550 -0
- package/test/project.test.ts +562 -0
- package/test/queue.test.ts +482 -0
- package/test/task.test.ts +464 -0
- package/tsconfig.json +20 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* digital-tasks - Task management primitives for digital workers
|
|
3
|
+
*
|
|
4
|
+
* Task = Function + metadata (status, progress, assignment, dependencies)
|
|
5
|
+
*
|
|
6
|
+
* Every task wraps a function (code, generative, agentic, or human)
|
|
7
|
+
* with lifecycle management, worker assignment, and dependency tracking.
|
|
8
|
+
*
|
|
9
|
+
* ## Quick Start
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Task, createTask, taskQueue } from 'digital-tasks'
|
|
13
|
+
*
|
|
14
|
+
* // Create a task from a function
|
|
15
|
+
* const task = await createTask({
|
|
16
|
+
* function: {
|
|
17
|
+
* type: 'generative',
|
|
18
|
+
* name: 'summarize',
|
|
19
|
+
* args: { text: 'The text to summarize' },
|
|
20
|
+
* output: 'string',
|
|
21
|
+
* promptTemplate: 'Summarize: {{text}}',
|
|
22
|
+
* },
|
|
23
|
+
* input: { text: 'Long article...' },
|
|
24
|
+
* priority: 'high',
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* // Start and complete
|
|
28
|
+
* await startTask(task.id, { type: 'agent', id: 'agent_1' })
|
|
29
|
+
* await completeTask(task.id, 'Summary of the article...')
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* ## Projects with Parallel/Sequential Tasks
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { createProject, task, parallel, sequential, toMarkdown } from 'digital-tasks'
|
|
36
|
+
*
|
|
37
|
+
* const project = createProject({
|
|
38
|
+
* name: 'Launch Feature',
|
|
39
|
+
* tasks: [
|
|
40
|
+
* parallel(
|
|
41
|
+
* task('Design mockups'),
|
|
42
|
+
* task('Write tech spec'),
|
|
43
|
+
* ),
|
|
44
|
+
* sequential(
|
|
45
|
+
* task('Implement backend'),
|
|
46
|
+
* task('Implement frontend'),
|
|
47
|
+
* task('Write tests'),
|
|
48
|
+
* ),
|
|
49
|
+
* ],
|
|
50
|
+
* })
|
|
51
|
+
*
|
|
52
|
+
* // Convert to markdown
|
|
53
|
+
* const md = toMarkdown(project)
|
|
54
|
+
* // # Launch Feature
|
|
55
|
+
* // - [ ] Design mockups
|
|
56
|
+
* // - [ ] Write tech spec
|
|
57
|
+
* // 1. [ ] Implement backend
|
|
58
|
+
* // 2. [ ] Implement frontend
|
|
59
|
+
* // 3. [ ] Write tests
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @packageDocumentation
|
|
63
|
+
*/
|
|
64
|
+
export type * from './types.js';
|
|
65
|
+
export type { Task, AnyTask, TaskStatus, TaskPriority, TaskQueue, TaskQueueOptions, TaskResult, WorkerRef, WorkerType, TaskDependency, DependencyType, TaskProgress, TaskEvent, CreateTaskOptions, UpdateTaskOptions, TaskQuery, TaskQueueStats, FunctionDefinition, CodeFunctionDefinition, GenerativeFunctionDefinition, AgenticFunctionDefinition, HumanFunctionDefinition, } from './types.js';
|
|
66
|
+
export { taskQueue, createTaskQueue } from './queue.js';
|
|
67
|
+
export { createTask, getTask, startTask, updateProgress, completeTask, failTask, cancelTask, addComment, createSubtask, getSubtasks, waitForTask, } from './task.js';
|
|
68
|
+
export type { ExecutionMode, FunctionType, TaskNode, TaskDefinition, ParallelGroup, SequentialGroup, Project, ProjectStatus, CreateProjectOptions, } from './project.js';
|
|
69
|
+
export { task, parallel, sequential, createProject, workflow, materializeProject, getDependants, getDependencies, getReadyTasks, hasCycles, sortTasks, } from './project.js';
|
|
70
|
+
export type { SerializeOptions } from './markdown.js';
|
|
71
|
+
export { parseMarkdown, toMarkdown, syncStatusFromMarkdown, } from './markdown.js';
|
|
72
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAMH,mBAAmB,YAAY,CAAA;AAE/B,YAAY,EACV,IAAI,EACJ,OAAO,EACP,UAAU,EACV,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,cAAc,EAEd,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,YAAY,CAAA;AAMnB,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAMvD,OAAO,EACL,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,WAAW,CAAA;AAMlB,YAAY,EACV,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,aAAa,EACb,eAAe,EACf,OAAO,EACP,aAAa,EACb,oBAAoB,GACrB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,aAAa,EACb,SAAS,EACT,SAAS,GACV,MAAM,cAAc,CAAA;AAMrB,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,EACL,aAAa,EACb,UAAU,EACV,sBAAsB,GACvB,MAAM,eAAe,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* digital-tasks - Task management primitives for digital workers
|
|
3
|
+
*
|
|
4
|
+
* Task = Function + metadata (status, progress, assignment, dependencies)
|
|
5
|
+
*
|
|
6
|
+
* Every task wraps a function (code, generative, agentic, or human)
|
|
7
|
+
* with lifecycle management, worker assignment, and dependency tracking.
|
|
8
|
+
*
|
|
9
|
+
* ## Quick Start
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Task, createTask, taskQueue } from 'digital-tasks'
|
|
13
|
+
*
|
|
14
|
+
* // Create a task from a function
|
|
15
|
+
* const task = await createTask({
|
|
16
|
+
* function: {
|
|
17
|
+
* type: 'generative',
|
|
18
|
+
* name: 'summarize',
|
|
19
|
+
* args: { text: 'The text to summarize' },
|
|
20
|
+
* output: 'string',
|
|
21
|
+
* promptTemplate: 'Summarize: {{text}}',
|
|
22
|
+
* },
|
|
23
|
+
* input: { text: 'Long article...' },
|
|
24
|
+
* priority: 'high',
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* // Start and complete
|
|
28
|
+
* await startTask(task.id, { type: 'agent', id: 'agent_1' })
|
|
29
|
+
* await completeTask(task.id, 'Summary of the article...')
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* ## Projects with Parallel/Sequential Tasks
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { createProject, task, parallel, sequential, toMarkdown } from 'digital-tasks'
|
|
36
|
+
*
|
|
37
|
+
* const project = createProject({
|
|
38
|
+
* name: 'Launch Feature',
|
|
39
|
+
* tasks: [
|
|
40
|
+
* parallel(
|
|
41
|
+
* task('Design mockups'),
|
|
42
|
+
* task('Write tech spec'),
|
|
43
|
+
* ),
|
|
44
|
+
* sequential(
|
|
45
|
+
* task('Implement backend'),
|
|
46
|
+
* task('Implement frontend'),
|
|
47
|
+
* task('Write tests'),
|
|
48
|
+
* ),
|
|
49
|
+
* ],
|
|
50
|
+
* })
|
|
51
|
+
*
|
|
52
|
+
* // Convert to markdown
|
|
53
|
+
* const md = toMarkdown(project)
|
|
54
|
+
* // # Launch Feature
|
|
55
|
+
* // - [ ] Design mockups
|
|
56
|
+
* // - [ ] Write tech spec
|
|
57
|
+
* // 1. [ ] Implement backend
|
|
58
|
+
* // 2. [ ] Implement frontend
|
|
59
|
+
* // 3. [ ] Write tests
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @packageDocumentation
|
|
63
|
+
*/
|
|
64
|
+
// ============================================================================
|
|
65
|
+
// Task Queue
|
|
66
|
+
// ============================================================================
|
|
67
|
+
export { taskQueue, createTaskQueue } from './queue.js';
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// Task Management
|
|
70
|
+
// ============================================================================
|
|
71
|
+
export { createTask, getTask, startTask, updateProgress, completeTask, failTask, cancelTask, addComment, createSubtask, getSubtasks, waitForTask, } from './task.js';
|
|
72
|
+
export { task, parallel, sequential, createProject, workflow, materializeProject, getDependants, getDependencies, getReadyTasks, hasCycles, sortTasks, } from './project.js';
|
|
73
|
+
export { parseMarkdown, toMarkdown, syncStatusFromMarkdown, } from './markdown.js';
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAkCH,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEvD,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,OAAO,EACL,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,WAAW,CAAA;AAkBlB,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,aAAa,EACb,SAAS,EACT,SAAS,GACV,MAAM,cAAc,CAAA;AAQrB,OAAO,EACL,aAAa,EACb,UAAU,EACV,sBAAsB,GACvB,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown Task List Parser and Serializer
|
|
3
|
+
*
|
|
4
|
+
* Bidirectional conversion between markdown task lists and Task objects.
|
|
5
|
+
*
|
|
6
|
+
* ## Syntax
|
|
7
|
+
*
|
|
8
|
+
* - `- [ ]` = Unordered/parallel tasks (can run simultaneously)
|
|
9
|
+
* - `1. [ ]` = Ordered/sequential tasks (must run in order)
|
|
10
|
+
* - `- [x]` or `1. [x]` = Completed task
|
|
11
|
+
* - `- [-]` = In progress task
|
|
12
|
+
* - `- [~]` = Blocked task
|
|
13
|
+
* - `- [!]` = Failed task
|
|
14
|
+
* - Indentation (2 spaces) = Subtasks
|
|
15
|
+
* - `# Heading` = Project name
|
|
16
|
+
* - `## Heading` = Task group/section
|
|
17
|
+
*
|
|
18
|
+
* ## Example
|
|
19
|
+
*
|
|
20
|
+
* ```markdown
|
|
21
|
+
* # Launch Feature
|
|
22
|
+
*
|
|
23
|
+
* ## Planning (parallel)
|
|
24
|
+
* - [ ] Design mockups
|
|
25
|
+
* - [ ] Write technical spec
|
|
26
|
+
* - [x] Create project board
|
|
27
|
+
*
|
|
28
|
+
* ## Implementation (sequential)
|
|
29
|
+
* 1. [ ] Implement backend API
|
|
30
|
+
* 2. [-] Implement frontend UI
|
|
31
|
+
* - [ ] Create components
|
|
32
|
+
* - [ ] Add state management
|
|
33
|
+
* 3. [ ] Write tests
|
|
34
|
+
*
|
|
35
|
+
* ## Deployment
|
|
36
|
+
* 1. [ ] Deploy to staging
|
|
37
|
+
* 2. [ ] QA testing
|
|
38
|
+
* 3. [ ] Deploy to production
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @packageDocumentation
|
|
42
|
+
*/
|
|
43
|
+
import type { Project } from './project.js';
|
|
44
|
+
/**
|
|
45
|
+
* Parse a markdown string into a Project
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const markdown = `
|
|
50
|
+
* # My Project
|
|
51
|
+
*
|
|
52
|
+
* - [ ] Task 1
|
|
53
|
+
* - [ ] Task 2
|
|
54
|
+
*
|
|
55
|
+
* ## Sequential Work
|
|
56
|
+
* 1. [ ] Step 1
|
|
57
|
+
* 2. [ ] Step 2
|
|
58
|
+
* `
|
|
59
|
+
*
|
|
60
|
+
* const project = parseMarkdown(markdown)
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseMarkdown(markdown: string): Project;
|
|
64
|
+
/**
|
|
65
|
+
* Options for markdown serialization
|
|
66
|
+
*/
|
|
67
|
+
export interface SerializeOptions {
|
|
68
|
+
/** Include status markers (default: true) */
|
|
69
|
+
includeStatus?: boolean;
|
|
70
|
+
/** Include priority markers (default: false) */
|
|
71
|
+
includePriority?: boolean;
|
|
72
|
+
/** Indent size in spaces (default: 2) */
|
|
73
|
+
indentSize?: number;
|
|
74
|
+
/** Include section headings (default: true) */
|
|
75
|
+
includeSections?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Serialize a Project to markdown
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const project = createProject({
|
|
83
|
+
* name: 'My Project',
|
|
84
|
+
* tasks: [
|
|
85
|
+
* parallel(
|
|
86
|
+
* task('Task 1'),
|
|
87
|
+
* task('Task 2'),
|
|
88
|
+
* ),
|
|
89
|
+
* sequential(
|
|
90
|
+
* task('Step 1'),
|
|
91
|
+
* task('Step 2'),
|
|
92
|
+
* ),
|
|
93
|
+
* ],
|
|
94
|
+
* })
|
|
95
|
+
*
|
|
96
|
+
* const markdown = toMarkdown(project)
|
|
97
|
+
* // # My Project
|
|
98
|
+
* //
|
|
99
|
+
* // - [ ] Task 1
|
|
100
|
+
* // - [ ] Task 2
|
|
101
|
+
* //
|
|
102
|
+
* // 1. [ ] Step 1
|
|
103
|
+
* // 2. [ ] Step 2
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare function toMarkdown(project: Project, options?: SerializeOptions): string;
|
|
107
|
+
/**
|
|
108
|
+
* Update task statuses in a project from markdown
|
|
109
|
+
* (Useful for syncing when markdown is edited externally)
|
|
110
|
+
*/
|
|
111
|
+
export declare function syncStatusFromMarkdown(project: Project, markdown: string): Project;
|
|
112
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,KAAK,EACV,OAAO,EAMR,MAAM,cAAc,CAAA;AAqPrB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAwFvD;AAMD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,gDAAgD;IAChD,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,+CAA+C;IAC/C,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AA4ED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAwBnF;AAMD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CA0DT"}
|