@ai-setting/roy-agent-core 1.4.13 → 1.4.15
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/dist/config/index.js +32 -0
- package/dist/env/agent/index.js +24 -0
- package/dist/env/commands/index.js +14 -0
- package/dist/env/debug/formatters/index.js +11 -0
- package/dist/env/debug/index.js +26 -0
- package/dist/env/hook/index.js +29 -0
- package/dist/env/index.js +81 -0
- package/dist/env/llm/index.js +40 -0
- package/dist/env/log-trace/index.js +83 -0
- package/dist/env/mcp/index.js +39 -0
- package/dist/env/mcp/tool/index.js +14 -0
- package/dist/env/memory/built-in/index.js +11 -0
- package/dist/env/memory/index.js +56 -0
- package/dist/env/memory/plugin/index.js +36 -0
- package/dist/env/prompt/index.js +20 -0
- package/dist/env/session/index.js +25 -0
- package/dist/env/session/storage/index.js +18 -0
- package/dist/env/skill/index.js +34 -0
- package/dist/env/skill/tool/index.js +9 -0
- package/dist/env/task/delegate/index.js +18 -0
- package/dist/env/task/hooks/index.js +7 -0
- package/dist/env/task/index.js +30 -0
- package/dist/env/task/plugins/index.js +23 -0
- package/dist/env/task/storage/index.js +14 -0
- package/dist/env/task/tools/index.js +17 -0
- package/dist/env/task/tools/operation/index.js +15 -0
- package/dist/{shared/chunk-1d4rwms4.js → env/tool/built-in/index.js} +4 -4
- package/dist/env/tool/index.js +39 -0
- package/dist/env/workflow/decorators/index.js +27 -0
- package/dist/env/workflow/engine/index.js +28 -0
- package/dist/env/workflow/index.js +132 -0
- package/dist/env/workflow/nodes/index.js +19 -0
- package/dist/env/workflow/service/index.js +13 -0
- package/dist/env/workflow/storage/index.js +27 -0
- package/dist/env/workflow/tools/index.js +159 -0
- package/dist/env/workflow/types/index.js +94 -0
- package/dist/env/workflow/utils/index.js +637 -0
- package/dist/index.js +233 -16386
- package/dist/shared/{chunk-2b5kbhx3.js → @ai-setting/roy-agent-core-0rtxwr28.js} +6 -114
- package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +36 -0
- package/dist/shared/@ai-setting/roy-agent-core-12zkpda2.js +393 -0
- package/dist/shared/@ai-setting/roy-agent-core-1ce3fqrk.js +117 -0
- package/dist/shared/@ai-setting/roy-agent-core-2dhd60aw.js +11 -0
- package/dist/shared/@ai-setting/roy-agent-core-2kg2wma8.js +620 -0
- package/dist/shared/@ai-setting/roy-agent-core-2x0m2p66.js +851 -0
- package/dist/shared/@ai-setting/roy-agent-core-35x0wrtt.js +172 -0
- package/dist/shared/{chunk-1pf5mfgd.js → @ai-setting/roy-agent-core-37e4tep3.js} +2 -2
- package/dist/shared/@ai-setting/roy-agent-core-3agad0d9.js +603 -0
- package/dist/shared/@ai-setting/roy-agent-core-4arba14a.js +419 -0
- package/dist/shared/@ai-setting/roy-agent-core-4rqmfr7t.js +266 -0
- package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +206 -0
- package/dist/shared/@ai-setting/roy-agent-core-561b1c4p.js +377 -0
- package/dist/shared/@ai-setting/roy-agent-core-5xf65pz6.js +1305 -0
- package/dist/shared/@ai-setting/roy-agent-core-6a72jfdy.js +303 -0
- package/dist/shared/{chunk-1aakcfp1.js → @ai-setting/roy-agent-core-7f303ffd.js} +3 -3
- package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +284 -0
- package/dist/shared/{chunk-t1rh6jtm.js → @ai-setting/roy-agent-core-7n436rb4.js} +7 -12
- package/dist/shared/@ai-setting/roy-agent-core-7r85t0qn.js +492 -0
- package/dist/shared/@ai-setting/roy-agent-core-7rewcey6.js +862 -0
- package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +14 -0
- package/dist/shared/@ai-setting/roy-agent-core-9qwp5qkz.js +1387 -0
- package/dist/shared/{chunk-mf5xqbdh.js → @ai-setting/roy-agent-core-9yxb3ty9.js} +3 -2
- package/dist/shared/@ai-setting/roy-agent-core-anwsxdds.js +1205 -0
- package/dist/shared/{chunk-1qwabsm0.js → @ai-setting/roy-agent-core-bncgx3gb.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-cd00w5mb.js +762 -0
- package/dist/shared/@ai-setting/roy-agent-core-cgs0j60t.js +442 -0
- package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +93 -0
- package/dist/shared/@ai-setting/roy-agent-core-dbsk841j.js +286 -0
- package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +64 -0
- package/dist/shared/{chunk-yqmx37vm.js → @ai-setting/roy-agent-core-e5jcp24a.js} +2 -2
- package/dist/shared/@ai-setting/roy-agent-core-e62e2a5a.js +204 -0
- package/dist/shared/{chunk-g6j5n3gv.js → @ai-setting/roy-agent-core-ewrj1c4k.js} +2 -2
- package/dist/shared/{chunk-rncy3rtd.js → @ai-setting/roy-agent-core-fdb6m4e4.js} +119 -1113
- package/dist/shared/{chunk-q9j99fsm.js → @ai-setting/roy-agent-core-fv32jaa8.js} +3 -3
- package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +171 -0
- package/dist/shared/@ai-setting/roy-agent-core-gmnkza34.js +202 -0
- package/dist/shared/@ai-setting/roy-agent-core-hz7rr4yx.js +513 -0
- package/dist/shared/@ai-setting/roy-agent-core-j3bbr2n0.js +378 -0
- package/dist/shared/{chunk-a9qmy3sc.js → @ai-setting/roy-agent-core-j3wc4465.js} +6 -3
- package/dist/shared/@ai-setting/roy-agent-core-jj79gszx.js +1130 -0
- package/dist/shared/@ai-setting/roy-agent-core-mwwk6req.js +913 -0
- package/dist/shared/{chunk-0q6s9wm6.js → @ai-setting/roy-agent-core-pc9g3962.js} +6 -50
- package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +60 -0
- package/dist/shared/@ai-setting/roy-agent-core-pzsg9pvf.js +393 -0
- package/dist/shared/{chunk-91bas8w5.js → @ai-setting/roy-agent-core-q779wnwm.js} +5 -5
- package/dist/shared/{chunk-25x2pdtp.js → @ai-setting/roy-agent-core-qw0ebh1d.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-qxhq8ven.js +57 -0
- package/dist/shared/@ai-setting/roy-agent-core-qxnbvgwe.js +66 -0
- package/dist/shared/@ai-setting/roy-agent-core-qya7seh6.js +408 -0
- package/dist/shared/@ai-setting/roy-agent-core-rbetrphj.js +97 -0
- package/dist/shared/@ai-setting/roy-agent-core-re1wjfw7.js +587 -0
- package/dist/shared/@ai-setting/roy-agent-core-rft3fmp0.js +14 -0
- package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +584 -0
- package/dist/shared/{chunk-ze20rksg.js → @ai-setting/roy-agent-core-rvxg1wps.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-rzp9kxne.js +341 -0
- package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +213 -0
- package/dist/shared/@ai-setting/roy-agent-core-w78syn7w.js +788 -0
- package/dist/shared/{chunk-9qzt1v1p.js → @ai-setting/roy-agent-core-z2t8hse8.js} +3 -2
- package/package.json +8 -7
- package/dist/index.d.ts +0 -7825
- package/dist/shared/chunk-hs7tbmje.js +0 -24
- /package/dist/shared/{chunk-wbkh7wat.js → @ai-setting/roy-agent-core-fs0mn2jk.js} +0 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AskUserError,
|
|
3
|
+
init_workflow_hil
|
|
4
|
+
} from "./roy-agent-core-e25xkv53.js";
|
|
5
|
+
import {
|
|
6
|
+
__esm,
|
|
7
|
+
__require
|
|
8
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
9
|
+
|
|
10
|
+
// src/env/workflow/types/workflow.ts
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
async function getYamlParser() {
|
|
13
|
+
if (!yamlParser) {
|
|
14
|
+
yamlParser = await import("yaml");
|
|
15
|
+
}
|
|
16
|
+
return yamlParser;
|
|
17
|
+
}
|
|
18
|
+
async function parseWorkflowFile(content, filename) {
|
|
19
|
+
const isYaml = filename.endsWith(".yaml") || filename.endsWith(".yml");
|
|
20
|
+
const isJson = filename.endsWith(".json");
|
|
21
|
+
let definition;
|
|
22
|
+
if (isYaml) {
|
|
23
|
+
const yaml = await getYamlParser();
|
|
24
|
+
definition = WorkflowDefinitionSchema.parse(yaml.parse(content));
|
|
25
|
+
} else if (isJson) {
|
|
26
|
+
definition = WorkflowDefinitionSchema.parse(JSON.parse(content));
|
|
27
|
+
} else {
|
|
28
|
+
try {
|
|
29
|
+
definition = WorkflowDefinitionSchema.parse(JSON.parse(content));
|
|
30
|
+
} catch {
|
|
31
|
+
const yaml = await getYamlParser();
|
|
32
|
+
definition = WorkflowDefinitionSchema.parse(yaml.parse(content));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
format: isYaml ? "yaml" : "json",
|
|
37
|
+
definition
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function parseWorkflowFileSync(content, filename) {
|
|
41
|
+
const isYaml = filename.endsWith(".yaml") || filename.endsWith(".yml");
|
|
42
|
+
const isJson = filename.endsWith(".json");
|
|
43
|
+
let definition;
|
|
44
|
+
if (isJson) {
|
|
45
|
+
definition = WorkflowDefinitionSchema.parse(JSON.parse(content));
|
|
46
|
+
} else if (isYaml) {
|
|
47
|
+
throw new Error("Synchronous YAML parsing not supported. Use parseWorkflowFile() instead.");
|
|
48
|
+
} else {
|
|
49
|
+
try {
|
|
50
|
+
definition = WorkflowDefinitionSchema.parse(JSON.parse(content));
|
|
51
|
+
} catch {
|
|
52
|
+
throw new Error("Cannot auto-detect format. Please use .yaml, .yml, or .json extension.");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
format: isJson ? "json" : "yaml",
|
|
57
|
+
definition
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
var DependsOnSchema, RetryConfigSchema, NodeDefinitionSchema, WorkflowConfigSchema, OutputDefinitionSchema, WorkflowMetadataSchema, WorkflowDefinitionSchema, yamlParser = null;
|
|
61
|
+
var init_workflow = __esm(() => {
|
|
62
|
+
DependsOnSchema = z.array(z.string());
|
|
63
|
+
RetryConfigSchema = z.object({
|
|
64
|
+
max_attempts: z.number().min(1).default(1),
|
|
65
|
+
backoff: z.enum(["fixed", "exponential"]).default("exponential"),
|
|
66
|
+
initial_delay: z.number().min(0).default(1000)
|
|
67
|
+
});
|
|
68
|
+
NodeDefinitionSchema = z.object({
|
|
69
|
+
id: z.string().min(1, "Node ID is required"),
|
|
70
|
+
type: z.string().min(1, "Node type is required"),
|
|
71
|
+
name: z.string().optional(),
|
|
72
|
+
config: z.record(z.string(), z.unknown()).optional().default({}),
|
|
73
|
+
depends_on: z.array(z.string()).optional(),
|
|
74
|
+
condition: z.string().optional(),
|
|
75
|
+
retry: RetryConfigSchema.optional(),
|
|
76
|
+
timeout: z.number().optional()
|
|
77
|
+
});
|
|
78
|
+
WorkflowConfigSchema = z.object({
|
|
79
|
+
parallel_limit: z.number().nullable().optional(),
|
|
80
|
+
timeout: z.number().nullable().optional(),
|
|
81
|
+
retry: RetryConfigSchema.optional(),
|
|
82
|
+
debug: z.boolean().optional()
|
|
83
|
+
});
|
|
84
|
+
OutputDefinitionSchema = z.object({
|
|
85
|
+
name: z.string(),
|
|
86
|
+
source: z.string(),
|
|
87
|
+
path: z.string()
|
|
88
|
+
});
|
|
89
|
+
WorkflowMetadataSchema = z.object({
|
|
90
|
+
author: z.string().optional(),
|
|
91
|
+
taskId: z.number().optional(),
|
|
92
|
+
tags: z.array(z.string()).optional().default([]),
|
|
93
|
+
created_at: z.string().optional(),
|
|
94
|
+
updated_at: z.string().optional()
|
|
95
|
+
});
|
|
96
|
+
WorkflowDefinitionSchema = z.object({
|
|
97
|
+
name: z.string().min(1, "Workflow name is required"),
|
|
98
|
+
version: z.string().default("1.0"),
|
|
99
|
+
description: z.string().optional(),
|
|
100
|
+
config: WorkflowConfigSchema.optional().default({}),
|
|
101
|
+
nodes: z.array(NodeDefinitionSchema).min(1, "At least one node is required"),
|
|
102
|
+
entry: z.union([z.string(), z.array(z.string())]).default("__default_entry__"),
|
|
103
|
+
outputs: z.array(OutputDefinitionSchema).optional().default([]),
|
|
104
|
+
metadata: WorkflowMetadataSchema.optional().default({})
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// src/env/workflow/types/workflow-message.ts
|
|
109
|
+
import { z as z2 } from "zod";
|
|
110
|
+
var WorkflowMessageRoleSchema;
|
|
111
|
+
var init_workflow_message = __esm(() => {
|
|
112
|
+
init_workflow_hil();
|
|
113
|
+
WorkflowMessageRoleSchema = z2.enum([
|
|
114
|
+
"workflow.node.call",
|
|
115
|
+
"workflow.node.interrupt",
|
|
116
|
+
"workflow.node.result",
|
|
117
|
+
"workflow.node.resume"
|
|
118
|
+
]);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// src/env/workflow/types/workflow-session.ts
|
|
122
|
+
function isWorkflowSessionMetadata(metadata) {
|
|
123
|
+
if (typeof metadata !== "object" || metadata === null || !("type" in metadata) || metadata.type !== "workflow") {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const m = metadata;
|
|
127
|
+
if (!m.workflowId || typeof m.workflowId !== "string") {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
if (!m.workflowName || typeof m.workflowName !== "string") {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (!m.status || typeof m.status !== "string") {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
const validStatuses = ["running", "paused", "completed", "failed", "stopped"];
|
|
137
|
+
if (!validStatuses.includes(m.status)) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
function getWorkflowSessionStatus(metadata) {
|
|
143
|
+
return metadata.status || "running";
|
|
144
|
+
}
|
|
145
|
+
var init_workflow_session = () => {};
|
|
146
|
+
|
|
147
|
+
// src/env/workflow/types/context.ts
|
|
148
|
+
var init_context = () => {};
|
|
149
|
+
|
|
150
|
+
// src/env/workflow/types/event.ts
|
|
151
|
+
import { z as z3 } from "zod";
|
|
152
|
+
function createWorkflowEvent(type, runId, data) {
|
|
153
|
+
return {
|
|
154
|
+
type,
|
|
155
|
+
run_id: runId,
|
|
156
|
+
timestamp: Date.now(),
|
|
157
|
+
...data
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
var BaseEventSchema, WorkflowStartedEventSchema, WorkflowPausedEventSchema, WorkflowResumedEventSchema, WorkflowStoppedEventSchema, WorkflowCompletedEventSchema, WorkflowFailedEventSchema, WorkflowOutputEventSchema, NodeScheduledEventSchema, NodeStartedEventSchema, NodeProgressEventSchema, NodeCompletedEventSchema, NodeFailedEventSchema, NodeSkippedEventSchema, NodeDataEventSchema, NodeAddedEventSchema, NodeRemovedEventSchema, ControlPauseEventSchema, ControlResumeEventSchema, ControlStopEventSchema, NodeInterruptEventSchema, WorkflowAskUserEventSchema, WorkflowEventSchema;
|
|
161
|
+
var init_event = __esm(() => {
|
|
162
|
+
BaseEventSchema = z3.object({
|
|
163
|
+
type: z3.string(),
|
|
164
|
+
run_id: z3.string(),
|
|
165
|
+
timestamp: z3.number()
|
|
166
|
+
});
|
|
167
|
+
WorkflowStartedEventSchema = BaseEventSchema.extend({
|
|
168
|
+
type: z3.literal("workflow.started"),
|
|
169
|
+
workflow_name: z3.string(),
|
|
170
|
+
input: z3.record(z3.string(), z3.unknown()).optional()
|
|
171
|
+
});
|
|
172
|
+
WorkflowPausedEventSchema = BaseEventSchema.extend({
|
|
173
|
+
type: z3.literal("workflow.paused")
|
|
174
|
+
});
|
|
175
|
+
WorkflowResumedEventSchema = BaseEventSchema.extend({
|
|
176
|
+
type: z3.literal("workflow.resumed")
|
|
177
|
+
});
|
|
178
|
+
WorkflowStoppedEventSchema = BaseEventSchema.extend({
|
|
179
|
+
type: z3.literal("workflow.stopped"),
|
|
180
|
+
reason: z3.string()
|
|
181
|
+
});
|
|
182
|
+
WorkflowCompletedEventSchema = BaseEventSchema.extend({
|
|
183
|
+
type: z3.literal("workflow.completed"),
|
|
184
|
+
result: z3.record(z3.string(), z3.unknown()).optional(),
|
|
185
|
+
duration_ms: z3.number()
|
|
186
|
+
});
|
|
187
|
+
WorkflowFailedEventSchema = BaseEventSchema.extend({
|
|
188
|
+
type: z3.literal("workflow.failed"),
|
|
189
|
+
error: z3.object({
|
|
190
|
+
message: z3.string(),
|
|
191
|
+
stack: z3.string().optional()
|
|
192
|
+
}),
|
|
193
|
+
failed_at: z3.string()
|
|
194
|
+
});
|
|
195
|
+
WorkflowOutputEventSchema = BaseEventSchema.extend({
|
|
196
|
+
type: z3.literal("workflow.output"),
|
|
197
|
+
output: z3.record(z3.string(), z3.unknown())
|
|
198
|
+
});
|
|
199
|
+
NodeScheduledEventSchema = BaseEventSchema.extend({
|
|
200
|
+
type: z3.literal("node.scheduled"),
|
|
201
|
+
node_id: z3.string()
|
|
202
|
+
});
|
|
203
|
+
NodeStartedEventSchema = BaseEventSchema.extend({
|
|
204
|
+
type: z3.literal("node.started"),
|
|
205
|
+
node_id: z3.string(),
|
|
206
|
+
input: z3.any(),
|
|
207
|
+
agentSessionId: z3.string().optional(),
|
|
208
|
+
userResponse: z3.string().optional()
|
|
209
|
+
});
|
|
210
|
+
NodeProgressEventSchema = BaseEventSchema.extend({
|
|
211
|
+
type: z3.literal("node.progress"),
|
|
212
|
+
node_id: z3.string(),
|
|
213
|
+
progress: z3.number(),
|
|
214
|
+
message: z3.string().optional()
|
|
215
|
+
});
|
|
216
|
+
NodeCompletedEventSchema = BaseEventSchema.extend({
|
|
217
|
+
type: z3.literal("node.completed"),
|
|
218
|
+
node_id: z3.string(),
|
|
219
|
+
output: z3.any(),
|
|
220
|
+
duration_ms: z3.number()
|
|
221
|
+
});
|
|
222
|
+
NodeFailedEventSchema = BaseEventSchema.extend({
|
|
223
|
+
type: z3.literal("node.failed"),
|
|
224
|
+
node_id: z3.string(),
|
|
225
|
+
error: z3.object({
|
|
226
|
+
message: z3.string(),
|
|
227
|
+
stack: z3.string().optional()
|
|
228
|
+
})
|
|
229
|
+
});
|
|
230
|
+
NodeSkippedEventSchema = BaseEventSchema.extend({
|
|
231
|
+
type: z3.literal("node.skipped"),
|
|
232
|
+
node_id: z3.string(),
|
|
233
|
+
reason: z3.string()
|
|
234
|
+
});
|
|
235
|
+
NodeDataEventSchema = BaseEventSchema.extend({
|
|
236
|
+
type: z3.literal("node.data"),
|
|
237
|
+
from_node: z3.string(),
|
|
238
|
+
to_node: z3.string(),
|
|
239
|
+
data: z3.any()
|
|
240
|
+
});
|
|
241
|
+
NodeAddedEventSchema = BaseEventSchema.extend({
|
|
242
|
+
type: z3.literal("node.added"),
|
|
243
|
+
node_id: z3.string(),
|
|
244
|
+
node: z3.any()
|
|
245
|
+
});
|
|
246
|
+
NodeRemovedEventSchema = BaseEventSchema.extend({
|
|
247
|
+
type: z3.literal("node.removed"),
|
|
248
|
+
node_id: z3.string()
|
|
249
|
+
});
|
|
250
|
+
ControlPauseEventSchema = BaseEventSchema.extend({
|
|
251
|
+
type: z3.literal("control.pause")
|
|
252
|
+
});
|
|
253
|
+
ControlResumeEventSchema = BaseEventSchema.extend({
|
|
254
|
+
type: z3.literal("control.resume")
|
|
255
|
+
});
|
|
256
|
+
ControlStopEventSchema = BaseEventSchema.extend({
|
|
257
|
+
type: z3.literal("control.stop")
|
|
258
|
+
});
|
|
259
|
+
NodeInterruptEventSchema = BaseEventSchema.extend({
|
|
260
|
+
type: z3.literal("node.interrupt"),
|
|
261
|
+
node_id: z3.string(),
|
|
262
|
+
node_type: z3.string(),
|
|
263
|
+
query: z3.string()
|
|
264
|
+
});
|
|
265
|
+
WorkflowAskUserEventSchema = BaseEventSchema.extend({
|
|
266
|
+
type: z3.literal("workflow.ask-user"),
|
|
267
|
+
session_id: z3.string(),
|
|
268
|
+
node_id: z3.string(),
|
|
269
|
+
node_type: z3.string(),
|
|
270
|
+
query: z3.string()
|
|
271
|
+
});
|
|
272
|
+
WorkflowEventSchema = z3.union([
|
|
273
|
+
WorkflowStartedEventSchema,
|
|
274
|
+
WorkflowPausedEventSchema,
|
|
275
|
+
WorkflowResumedEventSchema,
|
|
276
|
+
WorkflowStoppedEventSchema,
|
|
277
|
+
WorkflowCompletedEventSchema,
|
|
278
|
+
WorkflowFailedEventSchema,
|
|
279
|
+
WorkflowOutputEventSchema,
|
|
280
|
+
NodeScheduledEventSchema,
|
|
281
|
+
NodeStartedEventSchema,
|
|
282
|
+
NodeProgressEventSchema,
|
|
283
|
+
NodeCompletedEventSchema,
|
|
284
|
+
NodeFailedEventSchema,
|
|
285
|
+
NodeSkippedEventSchema,
|
|
286
|
+
NodeDataEventSchema,
|
|
287
|
+
NodeAddedEventSchema,
|
|
288
|
+
NodeRemovedEventSchema,
|
|
289
|
+
ControlPauseEventSchema,
|
|
290
|
+
ControlResumeEventSchema,
|
|
291
|
+
ControlStopEventSchema,
|
|
292
|
+
NodeInterruptEventSchema,
|
|
293
|
+
WorkflowAskUserEventSchema
|
|
294
|
+
]);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// src/env/workflow/types/run.ts
|
|
298
|
+
import { z as z4 } from "zod";
|
|
299
|
+
function createNodeExecutionContext(params) {
|
|
300
|
+
return {
|
|
301
|
+
...params,
|
|
302
|
+
askUser: (query) => {
|
|
303
|
+
throw new AskUserError(params.runId, params.sessionId, params.nodeId, "unknown", query);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
var RunStatusSchema, NodeStatusSchema;
|
|
308
|
+
var init_run = __esm(() => {
|
|
309
|
+
init_workflow_message();
|
|
310
|
+
RunStatusSchema = z4.enum([
|
|
311
|
+
"idle",
|
|
312
|
+
"running",
|
|
313
|
+
"paused",
|
|
314
|
+
"stopped",
|
|
315
|
+
"completed",
|
|
316
|
+
"failed"
|
|
317
|
+
]);
|
|
318
|
+
NodeStatusSchema = z4.enum([
|
|
319
|
+
"pending",
|
|
320
|
+
"scheduled",
|
|
321
|
+
"started",
|
|
322
|
+
"running",
|
|
323
|
+
"completed",
|
|
324
|
+
"failed",
|
|
325
|
+
"skipped"
|
|
326
|
+
]);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
// src/env/workflow/types/index.ts
|
|
330
|
+
var init_types = __esm(() => {
|
|
331
|
+
init_run();
|
|
332
|
+
init_workflow();
|
|
333
|
+
init_workflow_message();
|
|
334
|
+
init_workflow_session();
|
|
335
|
+
init_context();
|
|
336
|
+
init_workflow_hil();
|
|
337
|
+
init_event();
|
|
338
|
+
init_run();
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
export { BaseEventSchema, WorkflowStartedEventSchema, WorkflowPausedEventSchema, WorkflowResumedEventSchema, WorkflowStoppedEventSchema, WorkflowCompletedEventSchema, WorkflowFailedEventSchema, WorkflowOutputEventSchema, NodeScheduledEventSchema, NodeStartedEventSchema, NodeProgressEventSchema, NodeCompletedEventSchema, NodeFailedEventSchema, NodeSkippedEventSchema, NodeDataEventSchema, NodeAddedEventSchema, NodeRemovedEventSchema, ControlPauseEventSchema, ControlResumeEventSchema, ControlStopEventSchema, NodeInterruptEventSchema, WorkflowAskUserEventSchema, WorkflowEventSchema, createWorkflowEvent, init_event, DependsOnSchema, RetryConfigSchema, NodeDefinitionSchema, WorkflowConfigSchema, OutputDefinitionSchema, WorkflowMetadataSchema, WorkflowDefinitionSchema, parseWorkflowFile, parseWorkflowFileSync, WorkflowMessageRoleSchema, isWorkflowSessionMetadata, getWorkflowSessionStatus, RunStatusSchema, NodeStatusSchema, createNodeExecutionContext, init_types };
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// src/env/task/tools/operation/operation-types.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var ActionTypeEnum = z.enum([
|
|
4
|
+
"create",
|
|
5
|
+
"progress",
|
|
6
|
+
"milestone",
|
|
7
|
+
"problem",
|
|
8
|
+
"solution",
|
|
9
|
+
"decision",
|
|
10
|
+
"review",
|
|
11
|
+
"completed"
|
|
12
|
+
]);
|
|
13
|
+
var CreateOperationToolSchema = z.object({
|
|
14
|
+
task_id: z.number().describe("Task ID"),
|
|
15
|
+
action_type: ActionTypeEnum.describe("Type of action"),
|
|
16
|
+
action_title: z.string().describe("Title of the action"),
|
|
17
|
+
action_description: z.string().optional().describe("Detailed description"),
|
|
18
|
+
md_path: z.string().optional().describe("Path to detailed markdown documentation")
|
|
19
|
+
});
|
|
20
|
+
var GetOperationToolSchema = z.object({
|
|
21
|
+
operation_id: z.number().describe("Operation ID")
|
|
22
|
+
});
|
|
23
|
+
var ListOperationsToolSchema = z.object({
|
|
24
|
+
task_id: z.number().describe("Task ID"),
|
|
25
|
+
action_type: ActionTypeEnum.optional(),
|
|
26
|
+
limit: z.number().optional().default(20),
|
|
27
|
+
offset: z.number().optional().default(0)
|
|
28
|
+
});
|
|
29
|
+
var UpdateOperationToolSchema = z.object({
|
|
30
|
+
operation_id: z.number().describe("Operation ID"),
|
|
31
|
+
action_title: z.string().optional(),
|
|
32
|
+
action_description: z.string().optional()
|
|
33
|
+
});
|
|
34
|
+
var DeleteOperationToolSchema = z.object({
|
|
35
|
+
operation_id: z.number().describe("Operation ID")
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// src/env/task/tools/operation/create-tool.ts
|
|
39
|
+
function createOperationTool(taskComponent) {
|
|
40
|
+
return {
|
|
41
|
+
name: "task_operation_create",
|
|
42
|
+
description: "Create an operation record for a task. Tracks progress, milestones, problems, etc.",
|
|
43
|
+
parameters: CreateOperationToolSchema,
|
|
44
|
+
execute: async (args, ctx) => {
|
|
45
|
+
const params = CreateOperationToolSchema.parse(args);
|
|
46
|
+
const sessionId = ctx.session_id || "unknown";
|
|
47
|
+
try {
|
|
48
|
+
const operation = await taskComponent.createOperation({
|
|
49
|
+
taskId: params.task_id,
|
|
50
|
+
sessionId,
|
|
51
|
+
actionType: params.action_type,
|
|
52
|
+
actionTitle: params.action_title,
|
|
53
|
+
actionDescription: params.action_description,
|
|
54
|
+
mdPath: params.md_path
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
success: true,
|
|
58
|
+
output: `Operation created: #${operation.id} for task #${operation.taskId}`,
|
|
59
|
+
metadata: {
|
|
60
|
+
execution_time_ms: 0,
|
|
61
|
+
operation_id: operation.id,
|
|
62
|
+
task_id: operation.taskId,
|
|
63
|
+
session_id: operation.sessionId
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
output: "",
|
|
70
|
+
error: error instanceof Error ? error.message : String(error),
|
|
71
|
+
metadata: { execution_time_ms: 0 }
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// src/env/task/tools/operation/get-tool.ts
|
|
78
|
+
function getOperationTool(taskComponent) {
|
|
79
|
+
return {
|
|
80
|
+
name: "task_operation_get",
|
|
81
|
+
description: "Get a single operation record by ID.",
|
|
82
|
+
parameters: GetOperationToolSchema,
|
|
83
|
+
execute: async (args, ctx) => {
|
|
84
|
+
const params = GetOperationToolSchema.parse(args);
|
|
85
|
+
try {
|
|
86
|
+
const operation = await taskComponent.getOperation(params.operation_id);
|
|
87
|
+
if (!operation) {
|
|
88
|
+
return {
|
|
89
|
+
success: false,
|
|
90
|
+
output: "",
|
|
91
|
+
error: `Operation not found: ${params.operation_id}`,
|
|
92
|
+
metadata: { execution_time_ms: 0 }
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
success: true,
|
|
97
|
+
output: JSON.stringify(operation, null, 2),
|
|
98
|
+
metadata: { execution_time_ms: 0 }
|
|
99
|
+
};
|
|
100
|
+
} catch (error) {
|
|
101
|
+
return {
|
|
102
|
+
success: false,
|
|
103
|
+
output: "",
|
|
104
|
+
error: error instanceof Error ? error.message : String(error),
|
|
105
|
+
metadata: { execution_time_ms: 0 }
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// src/env/task/tools/operation/list-tool.ts
|
|
112
|
+
function listOperationsTool(taskComponent) {
|
|
113
|
+
return {
|
|
114
|
+
name: "task_operation_list",
|
|
115
|
+
description: "List operation records for a task with optional filters.",
|
|
116
|
+
parameters: ListOperationsToolSchema,
|
|
117
|
+
execute: async (args, ctx) => {
|
|
118
|
+
const params = ListOperationsToolSchema.parse(args);
|
|
119
|
+
try {
|
|
120
|
+
const operations = await taskComponent.listOperations({
|
|
121
|
+
taskId: params.task_id,
|
|
122
|
+
actionType: params.action_type,
|
|
123
|
+
limit: params.limit,
|
|
124
|
+
offset: params.offset
|
|
125
|
+
});
|
|
126
|
+
return {
|
|
127
|
+
success: true,
|
|
128
|
+
output: JSON.stringify({ operations, count: operations.length }),
|
|
129
|
+
metadata: { execution_time_ms: 0 }
|
|
130
|
+
};
|
|
131
|
+
} catch (error) {
|
|
132
|
+
return {
|
|
133
|
+
success: false,
|
|
134
|
+
output: "",
|
|
135
|
+
error: error instanceof Error ? error.message : String(error),
|
|
136
|
+
metadata: { execution_time_ms: 0 }
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
// src/env/task/tools/operation/update-tool.ts
|
|
143
|
+
function updateOperationTool(taskComponent) {
|
|
144
|
+
return {
|
|
145
|
+
name: "task_operation_update",
|
|
146
|
+
description: "Update an operation record's title or description.",
|
|
147
|
+
parameters: UpdateOperationToolSchema,
|
|
148
|
+
execute: async (args, ctx) => {
|
|
149
|
+
const params = UpdateOperationToolSchema.parse(args);
|
|
150
|
+
try {
|
|
151
|
+
const operation = await taskComponent.updateOperation(params.operation_id, {
|
|
152
|
+
actionTitle: params.action_title,
|
|
153
|
+
actionDescription: params.action_description
|
|
154
|
+
});
|
|
155
|
+
if (!operation) {
|
|
156
|
+
return {
|
|
157
|
+
success: false,
|
|
158
|
+
output: "",
|
|
159
|
+
error: `Operation not found: ${params.operation_id}`,
|
|
160
|
+
metadata: { execution_time_ms: 0 }
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
success: true,
|
|
165
|
+
output: `Operation updated: #${operation.id}`,
|
|
166
|
+
metadata: { execution_time_ms: 0, operation }
|
|
167
|
+
};
|
|
168
|
+
} catch (error) {
|
|
169
|
+
return {
|
|
170
|
+
success: false,
|
|
171
|
+
output: "",
|
|
172
|
+
error: error instanceof Error ? error.message : String(error),
|
|
173
|
+
metadata: { execution_time_ms: 0 }
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
// src/env/task/tools/operation/delete-tool.ts
|
|
180
|
+
function deleteOperationTool(taskComponent) {
|
|
181
|
+
return {
|
|
182
|
+
name: "task_operation_delete",
|
|
183
|
+
description: "Delete an operation record.",
|
|
184
|
+
parameters: DeleteOperationToolSchema,
|
|
185
|
+
execute: async (args, ctx) => {
|
|
186
|
+
const params = DeleteOperationToolSchema.parse(args);
|
|
187
|
+
try {
|
|
188
|
+
const deleted = await taskComponent.deleteOperation(params.operation_id);
|
|
189
|
+
if (!deleted) {
|
|
190
|
+
return {
|
|
191
|
+
success: false,
|
|
192
|
+
output: "",
|
|
193
|
+
error: `Operation not found: ${params.operation_id}`,
|
|
194
|
+
metadata: { execution_time_ms: 0 }
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
success: true,
|
|
199
|
+
output: `Operation deleted: #${params.operation_id}`,
|
|
200
|
+
metadata: { execution_time_ms: 0 }
|
|
201
|
+
};
|
|
202
|
+
} catch (error) {
|
|
203
|
+
return {
|
|
204
|
+
success: false,
|
|
205
|
+
output: "",
|
|
206
|
+
error: error instanceof Error ? error.message : String(error),
|
|
207
|
+
metadata: { execution_time_ms: 0 }
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
export { createOperationTool, getOperationTool, listOperationsTool, updateOperationTool, deleteOperationTool };
|