digital-tasks 2.1.3 → 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 +9 -0
- package/README.md +560 -0
- package/package.json +29 -14
- 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 -4
- package/LICENSE +0 -21
- 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/tsconfig.json
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"lib": ["ES2022"],
|
|
7
|
-
"outDir": "dist",
|
|
8
4
|
"rootDir": "src",
|
|
9
|
-
"
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"declarationMap": true,
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
"resolveJsonModule": true
|
|
5
|
+
"outDir": "dist"
|
|
17
6
|
},
|
|
18
7
|
"include": ["src/**/*"],
|
|
19
8
|
"exclude": ["node_modules", "dist", "test"]
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config'
|
|
2
|
+
|
|
3
|
+
export default defineWorkersConfig({
|
|
4
|
+
test: {
|
|
5
|
+
// CRITICAL: Limit concurrency to prevent resource exhaustion
|
|
6
|
+
maxConcurrency: 1,
|
|
7
|
+
maxWorkers: 1,
|
|
8
|
+
minWorkers: 1,
|
|
9
|
+
fileParallelism: false,
|
|
10
|
+
|
|
11
|
+
poolOptions: {
|
|
12
|
+
workers: {
|
|
13
|
+
wrangler: { configPath: './wrangler.jsonc' },
|
|
14
|
+
miniflare: {
|
|
15
|
+
compatibilityDate: '2025-01-20',
|
|
16
|
+
compatibilityFlags: ['nodejs_compat_v2'],
|
|
17
|
+
durableObjects: {
|
|
18
|
+
TASK_STATE: 'TaskStateDO',
|
|
19
|
+
},
|
|
20
|
+
queueProducers: {
|
|
21
|
+
TASK_QUEUE: { queueName: 'task-queue' },
|
|
22
|
+
},
|
|
23
|
+
queueConsumers: {
|
|
24
|
+
'task-queue': {},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
include: ['src/**/*.test.ts', 'test/**/*.test.ts'],
|
|
31
|
+
testTimeout: 60000, // AI calls can take time
|
|
32
|
+
hookTimeout: 30000,
|
|
33
|
+
|
|
34
|
+
// Coverage configuration
|
|
35
|
+
coverage: {
|
|
36
|
+
provider: 'v8',
|
|
37
|
+
reporter: ['text', 'json', 'html'],
|
|
38
|
+
include: ['src/**/*.ts'],
|
|
39
|
+
exclude: ['**/*.test.ts', '**/__tests__/**', '**/node_modules/**'],
|
|
40
|
+
thresholds: {
|
|
41
|
+
statements: 65,
|
|
42
|
+
branches: 60,
|
|
43
|
+
functions: 60,
|
|
44
|
+
lines: 65,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
})
|
package/wrangler.jsonc
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Wrangler configuration for digital-tasks worker tests
|
|
3
|
+
// Used by @cloudflare/vitest-pool-workers for testing
|
|
4
|
+
//
|
|
5
|
+
// The default export (TaskService) extends WorkerEntrypoint
|
|
6
|
+
// All public methods are automatically exposed via RPC
|
|
7
|
+
|
|
8
|
+
"name": "digital-tasks",
|
|
9
|
+
"main": "src/worker.ts",
|
|
10
|
+
"compatibility_date": "2025-01-20",
|
|
11
|
+
"compatibility_flags": ["nodejs_compat_v2"],
|
|
12
|
+
|
|
13
|
+
// AI binding for Cloudflare Workers AI
|
|
14
|
+
// Enables real AI Gateway access in tests for AI-powered task execution
|
|
15
|
+
"ai": {
|
|
16
|
+
"binding": "AI"
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
// Durable Objects for task state persistence
|
|
20
|
+
"durable_objects": {
|
|
21
|
+
"bindings": [
|
|
22
|
+
{ "name": "TASK_STATE", "class_name": "TaskStateDO" }
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
// Migrations for Durable Objects
|
|
27
|
+
"migrations": [
|
|
28
|
+
{ "tag": "v1", "new_classes": ["TaskStateDO"] }
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
// Queue bindings for task scheduling and background processing
|
|
32
|
+
"queues": {
|
|
33
|
+
"producers": [
|
|
34
|
+
{ "binding": "TASK_QUEUE", "queue": "task-queue" }
|
|
35
|
+
],
|
|
36
|
+
"consumers": [
|
|
37
|
+
{ "queue": "task-queue", "max_batch_size": 10, "max_batch_timeout": 30 }
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
// Environment variables placeholder
|
|
42
|
+
// Actual values come from .dev.vars in local development
|
|
43
|
+
"vars": {}
|
|
44
|
+
}
|
package/.turbo/turbo-build.log
DELETED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 .org.ai
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/function-task.d.ts
DELETED
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function-Task Integration
|
|
3
|
-
*
|
|
4
|
-
* Connects the task system with ai-functions Function definitions.
|
|
5
|
-
* Every task is essentially a function call with typed inputs/outputs.
|
|
6
|
-
*
|
|
7
|
-
* ## Function Types
|
|
8
|
-
*
|
|
9
|
-
* Tasks can execute different function types:
|
|
10
|
-
* - **Code**: Generates executable code
|
|
11
|
-
* - **Generative**: AI generates text/objects (no tools)
|
|
12
|
-
* - **Agentic**: AI with tools in a loop
|
|
13
|
-
* - **Human**: Requires human input/approval
|
|
14
|
-
*
|
|
15
|
-
* ## Data Flow
|
|
16
|
-
*
|
|
17
|
-
* Tasks form a typed DAG where outputs flow to dependent task inputs:
|
|
18
|
-
*
|
|
19
|
-
* ```ts
|
|
20
|
-
* const workflow = defineWorkflow({
|
|
21
|
-
* name: 'Data Pipeline',
|
|
22
|
-
* tasks: {
|
|
23
|
-
* fetchData: generativeTask({
|
|
24
|
-
* prompt: 'Fetch user data from API',
|
|
25
|
-
* output: z.object({ users: z.array(z.object({ name: z.string() })) }),
|
|
26
|
-
* }),
|
|
27
|
-
* processData: codeTask({
|
|
28
|
-
* input: (ctx) => ctx.outputs.fetchData, // Type-safe reference
|
|
29
|
-
* language: 'typescript',
|
|
30
|
-
* description: 'Filter active users',
|
|
31
|
-
* }),
|
|
32
|
-
* reviewResults: humanTask({
|
|
33
|
-
* input: (ctx) => ctx.outputs.processData,
|
|
34
|
-
* channel: 'slack',
|
|
35
|
-
* instructions: 'Review the processed user list',
|
|
36
|
-
* }),
|
|
37
|
-
* },
|
|
38
|
-
* // Dependencies inferred from input references
|
|
39
|
-
* })
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @packageDocumentation
|
|
43
|
-
*/
|
|
44
|
-
import type { FunctionDefinition, AIFunctionDefinition, CodeLanguage, HumanChannel } from 'ai-functions';
|
|
45
|
-
import type { AnyTask, TaskStatus, TaskPriority, WorkerRef } from './types.js';
|
|
46
|
-
/**
|
|
47
|
-
* The type of function that executes this task
|
|
48
|
-
*/
|
|
49
|
-
export type FunctionTaskType = 'code' | 'generative' | 'agentic' | 'human';
|
|
50
|
-
/**
|
|
51
|
-
* Base function task - a task that executes a function
|
|
52
|
-
*/
|
|
53
|
-
export interface FunctionTask<TInput = unknown, TOutput = unknown> {
|
|
54
|
-
/** Task ID */
|
|
55
|
-
id: string;
|
|
56
|
-
/** Task name */
|
|
57
|
-
name: string;
|
|
58
|
-
/** Task description */
|
|
59
|
-
description?: string;
|
|
60
|
-
/** Function type */
|
|
61
|
-
functionType: FunctionTaskType;
|
|
62
|
-
/** Function definition (if pre-defined) */
|
|
63
|
-
functionRef?: string;
|
|
64
|
-
/** Inline function definition */
|
|
65
|
-
definition?: FunctionDefinition<TInput, TOutput>;
|
|
66
|
-
/** Input value or resolver */
|
|
67
|
-
input?: TInput | InputResolver<TInput>;
|
|
68
|
-
/** Expected output type (for type inference) */
|
|
69
|
-
outputType?: TOutput;
|
|
70
|
-
/** Task priority */
|
|
71
|
-
priority?: TaskPriority;
|
|
72
|
-
/** Assigned worker */
|
|
73
|
-
assignTo?: WorkerRef;
|
|
74
|
-
/** Tags */
|
|
75
|
-
tags?: string[];
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Input resolver - gets input from workflow context
|
|
79
|
-
*/
|
|
80
|
-
export type InputResolver<T> = (context: WorkflowContext) => T | Promise<T>;
|
|
81
|
-
/**
|
|
82
|
-
* Workflow execution context
|
|
83
|
-
*/
|
|
84
|
-
export interface WorkflowContext {
|
|
85
|
-
/** Outputs from completed tasks */
|
|
86
|
-
outputs: Record<string, unknown>;
|
|
87
|
-
/** Get typed output from a specific task */
|
|
88
|
-
getOutput: <T>(taskId: string) => T | undefined;
|
|
89
|
-
/** Workflow metadata */
|
|
90
|
-
metadata: Record<string, unknown>;
|
|
91
|
-
/** Current user/worker */
|
|
92
|
-
worker?: WorkerRef;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Code task - generates executable code
|
|
96
|
-
*/
|
|
97
|
-
export interface CodeTask<TInput = unknown, TOutput = string> extends FunctionTask<TInput, TOutput> {
|
|
98
|
-
functionType: 'code';
|
|
99
|
-
/** Target programming language */
|
|
100
|
-
language?: CodeLanguage;
|
|
101
|
-
/** Code generation instructions */
|
|
102
|
-
instructions?: string;
|
|
103
|
-
/** Include tests */
|
|
104
|
-
includeTests?: boolean;
|
|
105
|
-
/** Include examples */
|
|
106
|
-
includeExamples?: boolean;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Generative task - AI generates content (no tools)
|
|
110
|
-
*/
|
|
111
|
-
export interface GenerativeTask<TInput = unknown, TOutput = unknown> extends FunctionTask<TInput, TOutput> {
|
|
112
|
-
functionType: 'generative';
|
|
113
|
-
/** Prompt template */
|
|
114
|
-
prompt: string;
|
|
115
|
-
/** System prompt */
|
|
116
|
-
system?: string;
|
|
117
|
-
/** Model to use */
|
|
118
|
-
model?: string;
|
|
119
|
-
/** Temperature */
|
|
120
|
-
temperature?: number;
|
|
121
|
-
/** Output schema (for structured output) */
|
|
122
|
-
outputSchema?: unknown;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Agentic task - AI with tools in a loop
|
|
126
|
-
*/
|
|
127
|
-
export interface AgenticTask<TInput = unknown, TOutput = unknown> extends FunctionTask<TInput, TOutput> {
|
|
128
|
-
functionType: 'agentic';
|
|
129
|
-
/** Agent instructions */
|
|
130
|
-
instructions: string;
|
|
131
|
-
/** Available tools */
|
|
132
|
-
tools?: AIFunctionDefinition[];
|
|
133
|
-
/** Tool names (if using registry) */
|
|
134
|
-
toolNames?: string[];
|
|
135
|
-
/** Maximum iterations */
|
|
136
|
-
maxIterations?: number;
|
|
137
|
-
/** Model to use */
|
|
138
|
-
model?: string;
|
|
139
|
-
/** Stream intermediate results */
|
|
140
|
-
stream?: boolean;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Human task - requires human input
|
|
144
|
-
*/
|
|
145
|
-
export interface HumanTask<TInput = unknown, TOutput = unknown> extends FunctionTask<TInput, TOutput> {
|
|
146
|
-
functionType: 'human';
|
|
147
|
-
/** Interaction channel */
|
|
148
|
-
channel: HumanChannel;
|
|
149
|
-
/** Instructions for the human */
|
|
150
|
-
instructions: string;
|
|
151
|
-
/** Timeout in ms */
|
|
152
|
-
timeout?: number;
|
|
153
|
-
/** Who should handle this */
|
|
154
|
-
assignee?: string;
|
|
155
|
-
/** Expected response schema */
|
|
156
|
-
responseSchema?: unknown;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Union of all function task types
|
|
160
|
-
*/
|
|
161
|
-
export type AnyFunctionTask = CodeTask | GenerativeTask | AgenticTask | HumanTask;
|
|
162
|
-
/**
|
|
163
|
-
* Create a code task
|
|
164
|
-
*
|
|
165
|
-
* @example
|
|
166
|
-
* ```ts
|
|
167
|
-
* const task = codeTask({
|
|
168
|
-
* name: 'Generate API client',
|
|
169
|
-
* language: 'typescript',
|
|
170
|
-
* instructions: 'Generate a type-safe API client from OpenAPI spec',
|
|
171
|
-
* input: { spec: openApiSpec },
|
|
172
|
-
* })
|
|
173
|
-
* ```
|
|
174
|
-
*/
|
|
175
|
-
export declare function codeTask<TInput = unknown, TOutput = string>(options: Omit<CodeTask<TInput, TOutput>, 'id' | 'functionType'>): CodeTask<TInput, TOutput>;
|
|
176
|
-
/**
|
|
177
|
-
* Create a generative task
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```ts
|
|
181
|
-
* const task = generativeTask({
|
|
182
|
-
* name: 'Summarize document',
|
|
183
|
-
* prompt: 'Summarize the following document: {{document}}',
|
|
184
|
-
* outputSchema: { summary: 'string', keyPoints: ['string'] },
|
|
185
|
-
* })
|
|
186
|
-
* ```
|
|
187
|
-
*/
|
|
188
|
-
export declare function generativeTask<TInput = unknown, TOutput = unknown>(options: Omit<GenerativeTask<TInput, TOutput>, 'id' | 'functionType'>): GenerativeTask<TInput, TOutput>;
|
|
189
|
-
/**
|
|
190
|
-
* Create an agentic task
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* ```ts
|
|
194
|
-
* const task = agenticTask({
|
|
195
|
-
* name: 'Research topic',
|
|
196
|
-
* instructions: 'Research the given topic and compile a report',
|
|
197
|
-
* tools: [searchTool, fetchTool, extractTool],
|
|
198
|
-
* maxIterations: 10,
|
|
199
|
-
* })
|
|
200
|
-
* ```
|
|
201
|
-
*/
|
|
202
|
-
export declare function agenticTask<TInput = unknown, TOutput = unknown>(options: Omit<AgenticTask<TInput, TOutput>, 'id' | 'functionType'>): AgenticTask<TInput, TOutput>;
|
|
203
|
-
/**
|
|
204
|
-
* Create a human task
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* ```ts
|
|
208
|
-
* const task = humanTask({
|
|
209
|
-
* name: 'Review PR',
|
|
210
|
-
* channel: 'slack',
|
|
211
|
-
* instructions: 'Review the code changes and approve or request changes',
|
|
212
|
-
* responseSchema: { approved: 'boolean', feedback: 'string' },
|
|
213
|
-
* })
|
|
214
|
-
* ```
|
|
215
|
-
*/
|
|
216
|
-
export declare function humanTask<TInput = unknown, TOutput = unknown>(options: Omit<HumanTask<TInput, TOutput>, 'id' | 'functionType'>): HumanTask<TInput, TOutput>;
|
|
217
|
-
/**
|
|
218
|
-
* Workflow definition with typed task graph
|
|
219
|
-
*/
|
|
220
|
-
export interface TypedWorkflow<TTasks extends Record<string, AnyFunctionTask> = Record<string, AnyFunctionTask>> {
|
|
221
|
-
/** Workflow ID */
|
|
222
|
-
id: string;
|
|
223
|
-
/** Workflow name */
|
|
224
|
-
name: string;
|
|
225
|
-
/** Workflow description */
|
|
226
|
-
description?: string;
|
|
227
|
-
/** Tasks in the workflow */
|
|
228
|
-
tasks: TTasks;
|
|
229
|
-
/** Explicit dependencies (if not using input resolvers) */
|
|
230
|
-
dependencies?: Array<{
|
|
231
|
-
task: keyof TTasks;
|
|
232
|
-
dependsOn: keyof TTasks | Array<keyof TTasks>;
|
|
233
|
-
}>;
|
|
234
|
-
/** Execution mode for tasks without explicit dependencies */
|
|
235
|
-
defaultMode?: 'parallel' | 'sequential';
|
|
236
|
-
/** Workflow metadata */
|
|
237
|
-
metadata?: Record<string, unknown>;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Options for defining a typed workflow
|
|
241
|
-
*/
|
|
242
|
-
export interface DefineWorkflowOptions<TTasks extends Record<string, AnyFunctionTask>> {
|
|
243
|
-
name: string;
|
|
244
|
-
description?: string;
|
|
245
|
-
tasks: TTasks;
|
|
246
|
-
dependencies?: TypedWorkflow<TTasks>['dependencies'];
|
|
247
|
-
defaultMode?: 'parallel' | 'sequential';
|
|
248
|
-
metadata?: Record<string, unknown>;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Create a typed workflow with automatic dependency inference
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* ```ts
|
|
255
|
-
* const contentPipeline = Workflow({
|
|
256
|
-
* name: 'Content Pipeline',
|
|
257
|
-
* tasks: {
|
|
258
|
-
* research: agenticTask({
|
|
259
|
-
* name: 'Research topic',
|
|
260
|
-
* instructions: 'Research AI trends',
|
|
261
|
-
* tools: [searchTool],
|
|
262
|
-
* }),
|
|
263
|
-
* outline: generativeTask({
|
|
264
|
-
* name: 'Create outline',
|
|
265
|
-
* prompt: 'Create outline from research',
|
|
266
|
-
* input: (ctx) => ctx.getOutput('research'),
|
|
267
|
-
* }),
|
|
268
|
-
* draft: generativeTask({
|
|
269
|
-
* name: 'Write draft',
|
|
270
|
-
* prompt: 'Write article from outline',
|
|
271
|
-
* input: (ctx) => ctx.getOutput('outline'),
|
|
272
|
-
* }),
|
|
273
|
-
* review: humanTask({
|
|
274
|
-
* name: 'Review article',
|
|
275
|
-
* channel: 'web',
|
|
276
|
-
* instructions: 'Review and approve the article',
|
|
277
|
-
* input: (ctx) => ctx.getOutput('draft'),
|
|
278
|
-
* }),
|
|
279
|
-
* },
|
|
280
|
-
* })
|
|
281
|
-
* ```
|
|
282
|
-
*/
|
|
283
|
-
export declare function Workflow<TTasks extends Record<string, AnyFunctionTask>>(options: DefineWorkflowOptions<TTasks>): TypedWorkflow<TTasks>;
|
|
284
|
-
/**
|
|
285
|
-
* Workflow execution state
|
|
286
|
-
*/
|
|
287
|
-
export interface WorkflowExecutionState {
|
|
288
|
-
/** Workflow ID */
|
|
289
|
-
workflowId: string;
|
|
290
|
-
/** Current status */
|
|
291
|
-
status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
292
|
-
/** Task statuses */
|
|
293
|
-
taskStatuses: Record<string, TaskStatus>;
|
|
294
|
-
/** Task outputs */
|
|
295
|
-
outputs: Record<string, unknown>;
|
|
296
|
-
/** Execution context */
|
|
297
|
-
context: WorkflowContext;
|
|
298
|
-
/** Start time */
|
|
299
|
-
startedAt?: Date;
|
|
300
|
-
/** End time */
|
|
301
|
-
completedAt?: Date;
|
|
302
|
-
/** Current task being executed */
|
|
303
|
-
currentTask?: string;
|
|
304
|
-
/** Error if failed */
|
|
305
|
-
error?: string;
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Convert a function task to a base Task
|
|
309
|
-
*/
|
|
310
|
-
export declare function functionTaskToTask(functionTask: AnyFunctionTask): Partial<AnyTask>;
|
|
311
|
-
/**
|
|
312
|
-
* Infer dependencies from input resolvers
|
|
313
|
-
*/
|
|
314
|
-
export declare function inferDependencies<TTasks extends Record<string, AnyFunctionTask>>(workflow: TypedWorkflow<TTasks>): Map<string, string[]>;
|
|
315
|
-
/**
|
|
316
|
-
* Get execution order for a workflow (topological sort)
|
|
317
|
-
*/
|
|
318
|
-
export declare function getExecutionOrder<TTasks extends Record<string, AnyFunctionTask>>(workflow: TypedWorkflow<TTasks>): string[][];
|
|
319
|
-
//# sourceMappingURL=function-task.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"function-task.d.ts","sourceRoot":"","sources":["../src/function-task.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAKlB,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACb,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAEV,OAAO,EACP,UAAU,EACV,YAAY,EAEZ,SAAS,EACV,MAAM,YAAY,CAAA;AAMnB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,CAAA;AAE1E;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IAC/D,cAAc;IACd,EAAE,EAAE,MAAM,CAAA;IACV,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oBAAoB;IACpB,YAAY,EAAE,gBAAgB,CAAA;IAC9B,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iCAAiC;IACjC,UAAU,CAAC,EAAE,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChD,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;IACtC,gDAAgD;IAChD,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,oBAAoB;IACpB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,WAAW;IACX,IAAI,CAAC,EAA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