digital-tasks 2.3.0 → 2.4.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/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +9 -0
- package/dist/client.d.ts +202 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +85 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -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 +531 -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 +415 -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 +386 -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 +383 -0
- package/dist/task.js.map +1 -0
- package/dist/types.d.ts +405 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +23 -0
- package/dist/types.js.map +1 -0
- package/dist/worker.d.ts +264 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +656 -0
- package/dist/worker.js.map +1 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC Client for digital-tasks
|
|
3
|
+
*
|
|
4
|
+
* Connects to a deployed digital-tasks worker via rpc.do,
|
|
5
|
+
* providing a fully typed client for remote task management.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createTaskClient } from 'digital-tasks/client'
|
|
10
|
+
*
|
|
11
|
+
* const tasks = createTaskClient('https://digital-tasks.workers.dev')
|
|
12
|
+
* const task = await tasks.create({ name: 'My Task', description: 'Do something', priority: 'high' })
|
|
13
|
+
* await tasks.execute(task.id)
|
|
14
|
+
* await tasks.complete(task.id, { result: 'done' })
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @packageDocumentation
|
|
18
|
+
*/
|
|
19
|
+
export type TaskStatus = 'pending' | 'scheduled' | 'queued' | 'blocked' | 'in_progress' | 'completed' | 'failed' | 'cancelled';
|
|
20
|
+
export type TaskPriority = 'low' | 'normal' | 'high' | 'urgent' | 'critical';
|
|
21
|
+
export interface WorkerRef {
|
|
22
|
+
type: 'agent' | 'human' | 'team' | 'any';
|
|
23
|
+
id: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface TaskDependency {
|
|
27
|
+
type: 'blocked_by';
|
|
28
|
+
taskId: string;
|
|
29
|
+
satisfied: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface TaskProgress {
|
|
32
|
+
percent: number;
|
|
33
|
+
step?: string;
|
|
34
|
+
updatedAt: Date;
|
|
35
|
+
}
|
|
36
|
+
export interface TaskAssignment {
|
|
37
|
+
worker: WorkerRef;
|
|
38
|
+
assignedAt: Date;
|
|
39
|
+
}
|
|
40
|
+
export interface TaskData<TInput = unknown, TOutput = unknown> {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
description: string;
|
|
44
|
+
status: TaskStatus;
|
|
45
|
+
priority: TaskPriority;
|
|
46
|
+
input?: TInput;
|
|
47
|
+
output?: TOutput;
|
|
48
|
+
error?: string;
|
|
49
|
+
scheduledFor?: Date;
|
|
50
|
+
deadline?: Date;
|
|
51
|
+
createdAt: Date;
|
|
52
|
+
startedAt?: Date;
|
|
53
|
+
completedAt?: Date;
|
|
54
|
+
progress?: TaskProgress;
|
|
55
|
+
dependencies?: TaskDependency[];
|
|
56
|
+
assignment?: TaskAssignment;
|
|
57
|
+
metadata?: Record<string, unknown>;
|
|
58
|
+
}
|
|
59
|
+
export interface CreateTaskOptions<TInput = unknown> {
|
|
60
|
+
id?: string;
|
|
61
|
+
name: string;
|
|
62
|
+
description: string;
|
|
63
|
+
priority?: TaskPriority;
|
|
64
|
+
input?: TInput;
|
|
65
|
+
scheduledFor?: Date;
|
|
66
|
+
deadline?: Date;
|
|
67
|
+
tags?: string[];
|
|
68
|
+
metadata?: Record<string, unknown>;
|
|
69
|
+
dependencies?: string[];
|
|
70
|
+
}
|
|
71
|
+
export interface ScheduleOptions {
|
|
72
|
+
priority?: TaskPriority;
|
|
73
|
+
}
|
|
74
|
+
export interface ExecuteOptions {
|
|
75
|
+
worker?: WorkerRef;
|
|
76
|
+
}
|
|
77
|
+
export interface ListOptions {
|
|
78
|
+
status?: TaskStatus | TaskStatus[];
|
|
79
|
+
priority?: TaskPriority;
|
|
80
|
+
tags?: string[];
|
|
81
|
+
search?: string;
|
|
82
|
+
sortBy?: 'createdAt' | 'priority';
|
|
83
|
+
sortOrder?: 'asc' | 'desc';
|
|
84
|
+
limit?: number;
|
|
85
|
+
offset?: number;
|
|
86
|
+
}
|
|
87
|
+
export interface EnqueueOptions {
|
|
88
|
+
delaySeconds?: number;
|
|
89
|
+
}
|
|
90
|
+
export interface TaskStats {
|
|
91
|
+
total: number;
|
|
92
|
+
byStatus: Record<string, number>;
|
|
93
|
+
byPriority: Record<string, number>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The RPC API surface exposed by the digital-tasks worker.
|
|
97
|
+
*
|
|
98
|
+
* This interface mirrors the methods on TaskServiceCore (worker.ts)
|
|
99
|
+
* and is used to type the RPC client proxy.
|
|
100
|
+
*/
|
|
101
|
+
export interface TaskServiceAPI {
|
|
102
|
+
/** Create a new task */
|
|
103
|
+
create(options: CreateTaskOptions): Promise<TaskData>;
|
|
104
|
+
/** Schedule a task for future execution */
|
|
105
|
+
schedule(taskId: string, scheduledFor: Date, options?: ScheduleOptions): Promise<TaskData>;
|
|
106
|
+
/** Start task execution */
|
|
107
|
+
execute(taskId: string, options?: ExecuteOptions): Promise<TaskData>;
|
|
108
|
+
/** Complete a task with output */
|
|
109
|
+
complete(taskId: string, output: unknown): Promise<TaskData>;
|
|
110
|
+
/** Fail a task with error */
|
|
111
|
+
fail(taskId: string, error: string | Error): Promise<TaskData>;
|
|
112
|
+
/** Get task status */
|
|
113
|
+
getStatus(taskId: string): Promise<TaskData | null>;
|
|
114
|
+
/** Update task progress */
|
|
115
|
+
updateProgress(taskId: string, percent: number, step?: string): Promise<TaskData>;
|
|
116
|
+
/** Cancel a task */
|
|
117
|
+
cancel(taskId: string, reason?: string): Promise<boolean>;
|
|
118
|
+
/** List tasks with optional filtering */
|
|
119
|
+
list(options?: ListOptions): Promise<TaskData[]>;
|
|
120
|
+
/** Get task statistics */
|
|
121
|
+
getStats(): Promise<TaskStats>;
|
|
122
|
+
/** Retry a failed task */
|
|
123
|
+
retry(taskId: string): Promise<TaskData>;
|
|
124
|
+
/** Get tasks that are ready for execution */
|
|
125
|
+
getReadyTasks(): Promise<TaskData[]>;
|
|
126
|
+
/** Get tasks that depend on a given task */
|
|
127
|
+
getDependants(taskId: string): Promise<TaskData[]>;
|
|
128
|
+
/** Enqueue a task for background processing */
|
|
129
|
+
enqueue(taskId: string, options?: EnqueueOptions): Promise<TaskData>;
|
|
130
|
+
/** Dequeue and start the next task */
|
|
131
|
+
dequeue(): Promise<TaskData | null>;
|
|
132
|
+
/** Execute a task with AI */
|
|
133
|
+
executeWithAI(taskId: string): Promise<TaskData>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Options for creating a task client
|
|
137
|
+
*/
|
|
138
|
+
export interface TaskClientOptions {
|
|
139
|
+
/** Authentication token or API key */
|
|
140
|
+
token?: string;
|
|
141
|
+
/** Custom headers to include with requests */
|
|
142
|
+
headers?: Record<string, string>;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Create a typed RPC client for the digital-tasks worker.
|
|
146
|
+
*
|
|
147
|
+
* @param url - The URL of the deployed digital-tasks worker
|
|
148
|
+
* @param options - Optional configuration (auth token, custom headers)
|
|
149
|
+
* @returns A fully typed RPC client proxy
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* import { createTaskClient } from 'digital-tasks/client'
|
|
154
|
+
*
|
|
155
|
+
* // Connect to a deployed worker
|
|
156
|
+
* const tasks = createTaskClient('https://digital-tasks.workers.dev')
|
|
157
|
+
*
|
|
158
|
+
* // Create and manage tasks
|
|
159
|
+
* const task = await tasks.create({
|
|
160
|
+
* name: 'Analyze data',
|
|
161
|
+
* description: 'Run data analysis pipeline',
|
|
162
|
+
* priority: 'high',
|
|
163
|
+
* })
|
|
164
|
+
*
|
|
165
|
+
* // Execute the task
|
|
166
|
+
* await tasks.execute(task.id)
|
|
167
|
+
*
|
|
168
|
+
* // Track progress
|
|
169
|
+
* await tasks.updateProgress(task.id, 50, 'Processing...')
|
|
170
|
+
*
|
|
171
|
+
* // Complete with output
|
|
172
|
+
* await tasks.complete(task.id, { results: [1, 2, 3] })
|
|
173
|
+
*
|
|
174
|
+
* // List all completed tasks
|
|
175
|
+
* const completed = await tasks.list({ status: 'completed' })
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* // With authentication
|
|
181
|
+
* const tasks = createTaskClient('https://digital-tasks.workers.dev', {
|
|
182
|
+
* token: 'my-api-key',
|
|
183
|
+
* })
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export declare function createTaskClient(url?: string, options?: TaskClientOptions): TaskServiceAPI;
|
|
187
|
+
/**
|
|
188
|
+
* Default task client connected to digital-tasks.workers.dev
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* import client from 'digital-tasks/client'
|
|
193
|
+
*
|
|
194
|
+
* const task = await client.create({
|
|
195
|
+
* name: 'Quick task',
|
|
196
|
+
* description: 'A task using the default client',
|
|
197
|
+
* })
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
declare const client: TaskServiceAPI;
|
|
201
|
+
export default client;
|
|
202
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAQH,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,WAAW,GACX,QAAQ,GACR,SAAS,GACT,aAAa,GACb,WAAW,GACX,QAAQ,GACR,WAAW,CAAA;AAEf,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAA;AAE5E,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAA;IACxC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,IAAI,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,SAAS,CAAA;IACjB,UAAU,EAAE,IAAI,CAAA;CACjB;AAED,MAAM,WAAW,QAAQ,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IAC3D,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,UAAU,CAAA;IAClB,QAAQ,EAAE,YAAY,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,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EAAE,cAAmC,CAAA;AAEjD,eAAe,MAAM,CAAA"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC Client for digital-tasks
|
|
3
|
+
*
|
|
4
|
+
* Connects to a deployed digital-tasks worker via rpc.do,
|
|
5
|
+
* providing a fully typed client for remote task management.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createTaskClient } from 'digital-tasks/client'
|
|
10
|
+
*
|
|
11
|
+
* const tasks = createTaskClient('https://digital-tasks.workers.dev')
|
|
12
|
+
* const task = await tasks.create({ name: 'My Task', description: 'Do something', priority: 'high' })
|
|
13
|
+
* await tasks.execute(task.id)
|
|
14
|
+
* await tasks.complete(task.id, { result: 'done' })
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @packageDocumentation
|
|
18
|
+
*/
|
|
19
|
+
import { RPC, http } from 'rpc.do';
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Client Factory
|
|
22
|
+
// ============================================================================
|
|
23
|
+
/** Default worker URL for digital-tasks */
|
|
24
|
+
const DEFAULT_URL = 'https://digital-tasks.workers.dev';
|
|
25
|
+
/**
|
|
26
|
+
* Create a typed RPC client for the digital-tasks worker.
|
|
27
|
+
*
|
|
28
|
+
* @param url - The URL of the deployed digital-tasks worker
|
|
29
|
+
* @param options - Optional configuration (auth token, custom headers)
|
|
30
|
+
* @returns A fully typed RPC client proxy
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { createTaskClient } from 'digital-tasks/client'
|
|
35
|
+
*
|
|
36
|
+
* // Connect to a deployed worker
|
|
37
|
+
* const tasks = createTaskClient('https://digital-tasks.workers.dev')
|
|
38
|
+
*
|
|
39
|
+
* // Create and manage tasks
|
|
40
|
+
* const task = await tasks.create({
|
|
41
|
+
* name: 'Analyze data',
|
|
42
|
+
* description: 'Run data analysis pipeline',
|
|
43
|
+
* priority: 'high',
|
|
44
|
+
* })
|
|
45
|
+
*
|
|
46
|
+
* // Execute the task
|
|
47
|
+
* await tasks.execute(task.id)
|
|
48
|
+
*
|
|
49
|
+
* // Track progress
|
|
50
|
+
* await tasks.updateProgress(task.id, 50, 'Processing...')
|
|
51
|
+
*
|
|
52
|
+
* // Complete with output
|
|
53
|
+
* await tasks.complete(task.id, { results: [1, 2, 3] })
|
|
54
|
+
*
|
|
55
|
+
* // List all completed tasks
|
|
56
|
+
* const completed = await tasks.list({ status: 'completed' })
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // With authentication
|
|
62
|
+
* const tasks = createTaskClient('https://digital-tasks.workers.dev', {
|
|
63
|
+
* token: 'my-api-key',
|
|
64
|
+
* })
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export function createTaskClient(url = DEFAULT_URL, options) {
|
|
68
|
+
return RPC(http(url, options?.token));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Default task client connected to digital-tasks.workers.dev
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* import client from 'digital-tasks/client'
|
|
76
|
+
*
|
|
77
|
+
* const task = await client.create({
|
|
78
|
+
* name: 'Quick task',
|
|
79
|
+
* description: 'A task using the default client',
|
|
80
|
+
* })
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
const client = createTaskClient();
|
|
84
|
+
export default client;
|
|
85
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAiLlC,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E,2CAA2C;AAC3C,MAAM,WAAW,GAAG,mCAAmC,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAc,WAAW,EACzB,OAA2B;IAE3B,OAAO,GAAG,CAAiB,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;AACvD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,GAAmB,gBAAgB,EAAE,CAAA;AAEjD,eAAe,MAAM,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* digital-tasks - Task management primitives for digital workers
|
|
3
|
+
*
|
|
4
|
+
* Task = Tool + metadata (status, progress, assignment, dependencies)
|
|
5
|
+
*
|
|
6
|
+
* Every task wraps a Tool (a callable Verb of type code, generative,
|
|
7
|
+
* agentic, or human) with lifecycle management, worker assignment, and
|
|
8
|
+
* dependency tracking. The `function` field is a deprecated alias for
|
|
9
|
+
* `tool` retained for backward compatibility.
|
|
10
|
+
*
|
|
11
|
+
* ## Quick Start
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Task, createTask, taskQueue } from 'digital-tasks'
|
|
15
|
+
*
|
|
16
|
+
* // Create a task from a Tool
|
|
17
|
+
* const task = await createTask({
|
|
18
|
+
* tool: {
|
|
19
|
+
* type: 'generative',
|
|
20
|
+
* name: 'summarize',
|
|
21
|
+
* args: { text: 'The text to summarize' },
|
|
22
|
+
* output: 'string',
|
|
23
|
+
* promptTemplate: 'Summarize: {{text}}',
|
|
24
|
+
* },
|
|
25
|
+
* input: { text: 'Long article...' },
|
|
26
|
+
* priority: 'high',
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* // Start and complete
|
|
30
|
+
* await startTask(task.id, { type: 'agent', id: 'agent_1' })
|
|
31
|
+
* await completeTask(task.id, 'Summary of the article...')
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* ## Projects with Parallel/Sequential Tasks
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { createProject, task, parallel, sequential, toMarkdown } from 'digital-tasks'
|
|
38
|
+
*
|
|
39
|
+
* const project = createProject({
|
|
40
|
+
* name: 'Launch Feature',
|
|
41
|
+
* tasks: [
|
|
42
|
+
* parallel(
|
|
43
|
+
* task('Design mockups'),
|
|
44
|
+
* task('Write tech spec'),
|
|
45
|
+
* ),
|
|
46
|
+
* sequential(
|
|
47
|
+
* task('Implement backend'),
|
|
48
|
+
* task('Implement frontend'),
|
|
49
|
+
* task('Write tests'),
|
|
50
|
+
* ),
|
|
51
|
+
* ],
|
|
52
|
+
* })
|
|
53
|
+
*
|
|
54
|
+
* // Convert to markdown
|
|
55
|
+
* const md = toMarkdown(project)
|
|
56
|
+
* // # Launch Feature
|
|
57
|
+
* // - [ ] Design mockups
|
|
58
|
+
* // - [ ] Write tech spec
|
|
59
|
+
* // 1. [ ] Implement backend
|
|
60
|
+
* // 2. [ ] Implement frontend
|
|
61
|
+
* // 3. [ ] Write tests
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @packageDocumentation
|
|
65
|
+
*/
|
|
66
|
+
export type * from './types.js';
|
|
67
|
+
export type { Task, AnyTask, TaskStatus, TaskPriority, TaskQueue, TaskQueueOptions, TaskResult, WorkerRef, WorkerType, TaskDependency, TaskDep, DependencyType, TaskProgress, TaskEvent, Comment, CreateTaskOptions, UpdateTaskOptions, TaskQuery, TaskQueueStats, Action, FunctionDefinition, CodeFunctionDefinition, GenerativeFunctionDefinition, AgenticFunctionDefinition, HumanFunctionDefinition, } from './types.js';
|
|
68
|
+
export { taskQueue, createTaskQueue } from './queue.js';
|
|
69
|
+
export { createTask, getTask, startTask, updateProgress, completeTask, failTask, cancelTask, addComment, createSubtask, getSubtasks, waitForTask, } from './task.js';
|
|
70
|
+
export type { ExecutionMode, FunctionType, TaskNode, TaskDefinition, ParallelGroup, SequentialGroup, Project, ProjectStatus, CreateProjectOptions, } from './project.js';
|
|
71
|
+
export { task, parallel, sequential, createProject, workflow, materializeProject, getDependants, getDependencies, getReadyTasks, hasCycles, sortTasks, } from './project.js';
|
|
72
|
+
export type { SerializeOptions } from './markdown.js';
|
|
73
|
+
export { parseMarkdown, toMarkdown, syncStatusFromMarkdown } from './markdown.js';
|
|
74
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;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,OAAO,EACP,cAAc,EACd,YAAY,EACZ,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,cAAc,EAEd,MAAM,EAEN,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,EAAE,aAAa,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* digital-tasks - Task management primitives for digital workers
|
|
3
|
+
*
|
|
4
|
+
* Task = Tool + metadata (status, progress, assignment, dependencies)
|
|
5
|
+
*
|
|
6
|
+
* Every task wraps a Tool (a callable Verb of type code, generative,
|
|
7
|
+
* agentic, or human) with lifecycle management, worker assignment, and
|
|
8
|
+
* dependency tracking. The `function` field is a deprecated alias for
|
|
9
|
+
* `tool` retained for backward compatibility.
|
|
10
|
+
*
|
|
11
|
+
* ## Quick Start
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Task, createTask, taskQueue } from 'digital-tasks'
|
|
15
|
+
*
|
|
16
|
+
* // Create a task from a Tool
|
|
17
|
+
* const task = await createTask({
|
|
18
|
+
* tool: {
|
|
19
|
+
* type: 'generative',
|
|
20
|
+
* name: 'summarize',
|
|
21
|
+
* args: { text: 'The text to summarize' },
|
|
22
|
+
* output: 'string',
|
|
23
|
+
* promptTemplate: 'Summarize: {{text}}',
|
|
24
|
+
* },
|
|
25
|
+
* input: { text: 'Long article...' },
|
|
26
|
+
* priority: 'high',
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* // Start and complete
|
|
30
|
+
* await startTask(task.id, { type: 'agent', id: 'agent_1' })
|
|
31
|
+
* await completeTask(task.id, 'Summary of the article...')
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* ## Projects with Parallel/Sequential Tasks
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { createProject, task, parallel, sequential, toMarkdown } from 'digital-tasks'
|
|
38
|
+
*
|
|
39
|
+
* const project = createProject({
|
|
40
|
+
* name: 'Launch Feature',
|
|
41
|
+
* tasks: [
|
|
42
|
+
* parallel(
|
|
43
|
+
* task('Design mockups'),
|
|
44
|
+
* task('Write tech spec'),
|
|
45
|
+
* ),
|
|
46
|
+
* sequential(
|
|
47
|
+
* task('Implement backend'),
|
|
48
|
+
* task('Implement frontend'),
|
|
49
|
+
* task('Write tests'),
|
|
50
|
+
* ),
|
|
51
|
+
* ],
|
|
52
|
+
* })
|
|
53
|
+
*
|
|
54
|
+
* // Convert to markdown
|
|
55
|
+
* const md = toMarkdown(project)
|
|
56
|
+
* // # Launch Feature
|
|
57
|
+
* // - [ ] Design mockups
|
|
58
|
+
* // - [ ] Write tech spec
|
|
59
|
+
* // 1. [ ] Implement backend
|
|
60
|
+
* // 2. [ ] Implement frontend
|
|
61
|
+
* // 3. [ ] Write tests
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @packageDocumentation
|
|
65
|
+
*/
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// Task Queue
|
|
68
|
+
// ============================================================================
|
|
69
|
+
export { taskQueue, createTaskQueue } from './queue.js';
|
|
70
|
+
// ============================================================================
|
|
71
|
+
// Task Management
|
|
72
|
+
// ============================================================================
|
|
73
|
+
export { createTask, getTask, startTask, updateProgress, completeTask, failTask, cancelTask, addComment, createSubtask, getSubtasks, waitForTask, } from './task.js';
|
|
74
|
+
export { task, parallel, sequential, createProject, workflow, materializeProject, getDependants, getDependencies, getReadyTasks, hasCycles, sortTasks, } from './project.js';
|
|
75
|
+
export { parseMarkdown, toMarkdown, syncStatusFromMarkdown } from './markdown.js';
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAsCH,+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,EAAE,aAAa,EAAE,UAAU,EAAE,sBAAsB,EAAE,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,EAOR,MAAM,cAAc,CAAA;AA0PrB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CA4FvD;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;AAiFD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAwBnF;AAMD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CA6DlF"}
|