@dexto/orchestration 1.5.8
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/LICENSE +44 -0
- package/dist/agent-controller.cjs +265 -0
- package/dist/agent-controller.d.cts +116 -0
- package/dist/agent-controller.d.ts +116 -0
- package/dist/agent-controller.js +241 -0
- package/dist/condition-engine.cjs +276 -0
- package/dist/condition-engine.d.cts +87 -0
- package/dist/condition-engine.d.ts +87 -0
- package/dist/condition-engine.js +252 -0
- package/dist/index.cjs +57 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +32 -0
- package/dist/signal-bus.cjs +186 -0
- package/dist/signal-bus.d.cts +78 -0
- package/dist/signal-bus.d.ts +78 -0
- package/dist/signal-bus.js +162 -0
- package/dist/task-registry.cjs +345 -0
- package/dist/task-registry.d.cts +124 -0
- package/dist/task-registry.d.ts +124 -0
- package/dist/task-registry.js +321 -0
- package/dist/tools/check-task.cjs +65 -0
- package/dist/tools/check-task.d.cts +56 -0
- package/dist/tools/check-task.d.ts +56 -0
- package/dist/tools/check-task.js +40 -0
- package/dist/tools/index.cjs +51 -0
- package/dist/tools/index.d.cts +10 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.js +19 -0
- package/dist/tools/list-tasks.cjs +80 -0
- package/dist/tools/list-tasks.d.cts +64 -0
- package/dist/tools/list-tasks.d.ts +64 -0
- package/dist/tools/list-tasks.js +55 -0
- package/dist/tools/start-task.cjs +149 -0
- package/dist/tools/start-task.d.cts +102 -0
- package/dist/tools/start-task.d.ts +102 -0
- package/dist/tools/start-task.js +123 -0
- package/dist/tools/types.cjs +16 -0
- package/dist/tools/types.d.cts +30 -0
- package/dist/tools/types.d.ts +30 -0
- package/dist/tools/types.js +0 -0
- package/dist/tools/wait-for.cjs +116 -0
- package/dist/tools/wait-for.d.cts +74 -0
- package/dist/tools/wait-for.d.ts +74 -0
- package/dist/tools/wait-for.js +91 -0
- package/dist/types.cjs +16 -0
- package/dist/types.d.cts +165 -0
- package/dist/types.d.ts +165 -0
- package/dist/types.js +0 -0
- package/package.json +38 -0
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Types
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the agent orchestration layer.
|
|
5
|
+
* Defines tasks, signals, wait conditions, and agent states.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Task result from agent or process execution
|
|
9
|
+
*/
|
|
10
|
+
interface TaskResult {
|
|
11
|
+
success: boolean;
|
|
12
|
+
response?: string;
|
|
13
|
+
error?: string;
|
|
14
|
+
agentId?: string;
|
|
15
|
+
tokenUsage?: {
|
|
16
|
+
input: number;
|
|
17
|
+
output: number;
|
|
18
|
+
total: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Process result from shell command execution
|
|
23
|
+
*/
|
|
24
|
+
interface ProcessResult {
|
|
25
|
+
stdout: string;
|
|
26
|
+
stderr: string;
|
|
27
|
+
exitCode: number;
|
|
28
|
+
duration?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Task types - discriminated union of different background task kinds
|
|
32
|
+
*/
|
|
33
|
+
type Task = {
|
|
34
|
+
type: 'agent';
|
|
35
|
+
taskId: string;
|
|
36
|
+
agentId: string;
|
|
37
|
+
taskDescription: string;
|
|
38
|
+
promise: Promise<TaskResult>;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'process';
|
|
41
|
+
taskId: string;
|
|
42
|
+
processId: string;
|
|
43
|
+
command: string;
|
|
44
|
+
promise: Promise<ProcessResult>;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'generic';
|
|
47
|
+
taskId: string;
|
|
48
|
+
description: string;
|
|
49
|
+
promise: Promise<unknown>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Task lifecycle status
|
|
53
|
+
*/
|
|
54
|
+
type TaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
55
|
+
/**
|
|
56
|
+
* Entry in the task registry tracking a background task
|
|
57
|
+
*/
|
|
58
|
+
interface TaskEntry {
|
|
59
|
+
task: Task;
|
|
60
|
+
status: TaskStatus;
|
|
61
|
+
startedAt: Date;
|
|
62
|
+
completedAt?: Date;
|
|
63
|
+
result?: unknown;
|
|
64
|
+
error?: string;
|
|
65
|
+
/** If true, auto-trigger agent turn on completion */
|
|
66
|
+
notify?: boolean;
|
|
67
|
+
/** Timeout handle for this task (if set) */
|
|
68
|
+
timeoutHandle: ReturnType<typeof setTimeout> | undefined;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Signal types - events that trigger state transitions
|
|
72
|
+
*/
|
|
73
|
+
type Signal = {
|
|
74
|
+
type: 'task:completed';
|
|
75
|
+
taskId: string;
|
|
76
|
+
result: unknown;
|
|
77
|
+
} | {
|
|
78
|
+
type: 'task:failed';
|
|
79
|
+
taskId: string;
|
|
80
|
+
error: string;
|
|
81
|
+
} | {
|
|
82
|
+
type: 'task:cancelled';
|
|
83
|
+
taskId: string;
|
|
84
|
+
} | {
|
|
85
|
+
type: 'timeout';
|
|
86
|
+
conditionId: string;
|
|
87
|
+
} | {
|
|
88
|
+
type: 'user:input';
|
|
89
|
+
content: string;
|
|
90
|
+
sessionId: string;
|
|
91
|
+
} | {
|
|
92
|
+
type: 'external';
|
|
93
|
+
source: string;
|
|
94
|
+
data: unknown;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Extract signal type string
|
|
98
|
+
*/
|
|
99
|
+
type SignalType = Signal['type'];
|
|
100
|
+
/**
|
|
101
|
+
* Wait conditions - composable conditions for suspension
|
|
102
|
+
*/
|
|
103
|
+
type WaitCondition = {
|
|
104
|
+
type: 'task';
|
|
105
|
+
taskId: string;
|
|
106
|
+
} | {
|
|
107
|
+
type: 'any';
|
|
108
|
+
conditions: WaitCondition[];
|
|
109
|
+
} | {
|
|
110
|
+
type: 'all';
|
|
111
|
+
conditions: WaitCondition[];
|
|
112
|
+
} | {
|
|
113
|
+
type: 'timeout';
|
|
114
|
+
ms: number;
|
|
115
|
+
conditionId: string;
|
|
116
|
+
} | {
|
|
117
|
+
type: 'race';
|
|
118
|
+
task: WaitCondition;
|
|
119
|
+
timeout: WaitCondition;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Agent loop states
|
|
123
|
+
*/
|
|
124
|
+
type AgentState = 'idle' | 'processing' | 'waiting';
|
|
125
|
+
/**
|
|
126
|
+
* Task info returned by list/check operations (without internal promise)
|
|
127
|
+
*/
|
|
128
|
+
interface TaskInfo {
|
|
129
|
+
taskId: string;
|
|
130
|
+
type: Task['type'];
|
|
131
|
+
status: TaskStatus;
|
|
132
|
+
startedAt: Date;
|
|
133
|
+
completedAt?: Date;
|
|
134
|
+
duration?: number;
|
|
135
|
+
description?: string;
|
|
136
|
+
result?: unknown;
|
|
137
|
+
error?: string;
|
|
138
|
+
cancelReason?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Filter options for listing tasks
|
|
142
|
+
*/
|
|
143
|
+
interface TaskFilter {
|
|
144
|
+
status?: TaskStatus | TaskStatus[];
|
|
145
|
+
type?: Task['type'];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Result from waiting on a condition
|
|
149
|
+
*/
|
|
150
|
+
interface WaitResult {
|
|
151
|
+
signal: Signal;
|
|
152
|
+
/** For 'all' conditions, contains all signals */
|
|
153
|
+
allSignals?: Signal[];
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Options for registering a task
|
|
157
|
+
*/
|
|
158
|
+
interface RegisterTaskOptions {
|
|
159
|
+
/** Auto-trigger agent turn on completion */
|
|
160
|
+
notify?: boolean;
|
|
161
|
+
/** Timeout in milliseconds */
|
|
162
|
+
timeout?: number;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export type { AgentState, ProcessResult, RegisterTaskOptions, Signal, SignalType, Task, TaskEntry, TaskFilter, TaskInfo, TaskResult, TaskStatus, WaitCondition, WaitResult };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Types
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the agent orchestration layer.
|
|
5
|
+
* Defines tasks, signals, wait conditions, and agent states.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Task result from agent or process execution
|
|
9
|
+
*/
|
|
10
|
+
interface TaskResult {
|
|
11
|
+
success: boolean;
|
|
12
|
+
response?: string;
|
|
13
|
+
error?: string;
|
|
14
|
+
agentId?: string;
|
|
15
|
+
tokenUsage?: {
|
|
16
|
+
input: number;
|
|
17
|
+
output: number;
|
|
18
|
+
total: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Process result from shell command execution
|
|
23
|
+
*/
|
|
24
|
+
interface ProcessResult {
|
|
25
|
+
stdout: string;
|
|
26
|
+
stderr: string;
|
|
27
|
+
exitCode: number;
|
|
28
|
+
duration?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Task types - discriminated union of different background task kinds
|
|
32
|
+
*/
|
|
33
|
+
type Task = {
|
|
34
|
+
type: 'agent';
|
|
35
|
+
taskId: string;
|
|
36
|
+
agentId: string;
|
|
37
|
+
taskDescription: string;
|
|
38
|
+
promise: Promise<TaskResult>;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'process';
|
|
41
|
+
taskId: string;
|
|
42
|
+
processId: string;
|
|
43
|
+
command: string;
|
|
44
|
+
promise: Promise<ProcessResult>;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'generic';
|
|
47
|
+
taskId: string;
|
|
48
|
+
description: string;
|
|
49
|
+
promise: Promise<unknown>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Task lifecycle status
|
|
53
|
+
*/
|
|
54
|
+
type TaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
55
|
+
/**
|
|
56
|
+
* Entry in the task registry tracking a background task
|
|
57
|
+
*/
|
|
58
|
+
interface TaskEntry {
|
|
59
|
+
task: Task;
|
|
60
|
+
status: TaskStatus;
|
|
61
|
+
startedAt: Date;
|
|
62
|
+
completedAt?: Date;
|
|
63
|
+
result?: unknown;
|
|
64
|
+
error?: string;
|
|
65
|
+
/** If true, auto-trigger agent turn on completion */
|
|
66
|
+
notify?: boolean;
|
|
67
|
+
/** Timeout handle for this task (if set) */
|
|
68
|
+
timeoutHandle: ReturnType<typeof setTimeout> | undefined;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Signal types - events that trigger state transitions
|
|
72
|
+
*/
|
|
73
|
+
type Signal = {
|
|
74
|
+
type: 'task:completed';
|
|
75
|
+
taskId: string;
|
|
76
|
+
result: unknown;
|
|
77
|
+
} | {
|
|
78
|
+
type: 'task:failed';
|
|
79
|
+
taskId: string;
|
|
80
|
+
error: string;
|
|
81
|
+
} | {
|
|
82
|
+
type: 'task:cancelled';
|
|
83
|
+
taskId: string;
|
|
84
|
+
} | {
|
|
85
|
+
type: 'timeout';
|
|
86
|
+
conditionId: string;
|
|
87
|
+
} | {
|
|
88
|
+
type: 'user:input';
|
|
89
|
+
content: string;
|
|
90
|
+
sessionId: string;
|
|
91
|
+
} | {
|
|
92
|
+
type: 'external';
|
|
93
|
+
source: string;
|
|
94
|
+
data: unknown;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Extract signal type string
|
|
98
|
+
*/
|
|
99
|
+
type SignalType = Signal['type'];
|
|
100
|
+
/**
|
|
101
|
+
* Wait conditions - composable conditions for suspension
|
|
102
|
+
*/
|
|
103
|
+
type WaitCondition = {
|
|
104
|
+
type: 'task';
|
|
105
|
+
taskId: string;
|
|
106
|
+
} | {
|
|
107
|
+
type: 'any';
|
|
108
|
+
conditions: WaitCondition[];
|
|
109
|
+
} | {
|
|
110
|
+
type: 'all';
|
|
111
|
+
conditions: WaitCondition[];
|
|
112
|
+
} | {
|
|
113
|
+
type: 'timeout';
|
|
114
|
+
ms: number;
|
|
115
|
+
conditionId: string;
|
|
116
|
+
} | {
|
|
117
|
+
type: 'race';
|
|
118
|
+
task: WaitCondition;
|
|
119
|
+
timeout: WaitCondition;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Agent loop states
|
|
123
|
+
*/
|
|
124
|
+
type AgentState = 'idle' | 'processing' | 'waiting';
|
|
125
|
+
/**
|
|
126
|
+
* Task info returned by list/check operations (without internal promise)
|
|
127
|
+
*/
|
|
128
|
+
interface TaskInfo {
|
|
129
|
+
taskId: string;
|
|
130
|
+
type: Task['type'];
|
|
131
|
+
status: TaskStatus;
|
|
132
|
+
startedAt: Date;
|
|
133
|
+
completedAt?: Date;
|
|
134
|
+
duration?: number;
|
|
135
|
+
description?: string;
|
|
136
|
+
result?: unknown;
|
|
137
|
+
error?: string;
|
|
138
|
+
cancelReason?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Filter options for listing tasks
|
|
142
|
+
*/
|
|
143
|
+
interface TaskFilter {
|
|
144
|
+
status?: TaskStatus | TaskStatus[];
|
|
145
|
+
type?: Task['type'];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Result from waiting on a condition
|
|
149
|
+
*/
|
|
150
|
+
interface WaitResult {
|
|
151
|
+
signal: Signal;
|
|
152
|
+
/** For 'all' conditions, contains all signals */
|
|
153
|
+
allSignals?: Signal[];
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Options for registering a task
|
|
157
|
+
*/
|
|
158
|
+
interface RegisterTaskOptions {
|
|
159
|
+
/** Auto-trigger agent turn on completion */
|
|
160
|
+
notify?: boolean;
|
|
161
|
+
/** Timeout in milliseconds */
|
|
162
|
+
timeout?: number;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export type { AgentState, ProcessResult, RegisterTaskOptions, Signal, SignalType, Task, TaskEntry, TaskFilter, TaskInfo, TaskResult, TaskStatus, WaitCondition, WaitResult };
|
package/dist/types.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dexto/orchestration",
|
|
3
|
+
"version": "1.5.8",
|
|
4
|
+
"description": "Agent orchestration layer for background task management, event-driven completion handling, and async workflows",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"dexto",
|
|
16
|
+
"orchestration",
|
|
17
|
+
"background-tasks",
|
|
18
|
+
"async",
|
|
19
|
+
"multi-agent",
|
|
20
|
+
"workflow"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"zod": "^3.25.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"tsup": "^8.0.0",
|
|
27
|
+
"typescript": "^5.3.3"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsup",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"clean": "rm -rf dist"
|
|
37
|
+
}
|
|
38
|
+
}
|