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/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "digital-tasks",
3
+ "version": "2.0.1",
4
+ "description": "Task management primitives for digital workers (agents and humans)",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./queue": {
14
+ "import": "./dist/queue.js",
15
+ "types": "./dist/queue.d.ts"
16
+ }
17
+ },
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "dev": "tsc --watch",
21
+ "test": "vitest",
22
+ "typecheck": "tsc --noEmit",
23
+ "lint": "eslint .",
24
+ "clean": "rm -rf dist"
25
+ },
26
+ "dependencies": {
27
+ "ai-functions": "workspace:*",
28
+ "digital-tools": "workspace:*",
29
+ "digital-workers": "workspace:*",
30
+ "rpc.do": "^0.1.0"
31
+ },
32
+ "keywords": [
33
+ "ai",
34
+ "tasks",
35
+ "queue",
36
+ "workers",
37
+ "agents",
38
+ "primitives"
39
+ ],
40
+ "license": "MIT"
41
+ }
package/src/index.ts ADDED
@@ -0,0 +1,161 @@
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
+ // ============================================================================
66
+ // Core Types
67
+ // ============================================================================
68
+
69
+ export type * from './types.js'
70
+
71
+ export type {
72
+ Task,
73
+ AnyTask,
74
+ TaskStatus,
75
+ TaskPriority,
76
+ TaskQueue,
77
+ TaskQueueOptions,
78
+ TaskResult,
79
+ WorkerRef,
80
+ WorkerType,
81
+ TaskDependency,
82
+ DependencyType,
83
+ TaskProgress,
84
+ TaskEvent,
85
+ CreateTaskOptions,
86
+ UpdateTaskOptions,
87
+ TaskQuery,
88
+ TaskQueueStats,
89
+ // Function types (re-exported from ai-functions)
90
+ FunctionDefinition,
91
+ CodeFunctionDefinition,
92
+ GenerativeFunctionDefinition,
93
+ AgenticFunctionDefinition,
94
+ HumanFunctionDefinition,
95
+ } from './types.js'
96
+
97
+ // ============================================================================
98
+ // Task Queue
99
+ // ============================================================================
100
+
101
+ export { taskQueue, createTaskQueue } from './queue.js'
102
+
103
+ // ============================================================================
104
+ // Task Management
105
+ // ============================================================================
106
+
107
+ export {
108
+ createTask,
109
+ getTask,
110
+ startTask,
111
+ updateProgress,
112
+ completeTask,
113
+ failTask,
114
+ cancelTask,
115
+ addComment,
116
+ createSubtask,
117
+ getSubtasks,
118
+ waitForTask,
119
+ } from './task.js'
120
+
121
+ // ============================================================================
122
+ // Project & Workflow DSL
123
+ // ============================================================================
124
+
125
+ export type {
126
+ ExecutionMode,
127
+ FunctionType,
128
+ TaskNode,
129
+ TaskDefinition,
130
+ ParallelGroup,
131
+ SequentialGroup,
132
+ Project,
133
+ ProjectStatus,
134
+ CreateProjectOptions,
135
+ } from './project.js'
136
+
137
+ export {
138
+ task,
139
+ parallel,
140
+ sequential,
141
+ createProject,
142
+ workflow,
143
+ materializeProject,
144
+ getDependants,
145
+ getDependencies,
146
+ getReadyTasks,
147
+ hasCycles,
148
+ sortTasks,
149
+ } from './project.js'
150
+
151
+ // ============================================================================
152
+ // Markdown Integration
153
+ // ============================================================================
154
+
155
+ export type { SerializeOptions } from './markdown.js'
156
+
157
+ export {
158
+ parseMarkdown,
159
+ toMarkdown,
160
+ syncStatusFromMarkdown,
161
+ } from './markdown.js'