@ai-setting/roy-agent-core 1.5.15-test → 1.5.17-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.d.ts +1250 -0
- package/dist/config/index.js +32 -0
- package/dist/env/agent/index.d.ts +2279 -0
- package/dist/env/agent/index.js +24 -0
- package/dist/env/commands/index.d.ts +1131 -0
- package/dist/env/commands/index.js +14 -0
- package/dist/env/debug/formatters/index.d.ts +236 -0
- package/dist/env/debug/formatters/index.js +11 -0
- package/dist/env/debug/index.d.ts +1652 -0
- package/dist/env/debug/index.js +26 -0
- package/dist/env/hook/index.d.ts +279 -0
- package/dist/env/hook/index.js +29 -0
- package/dist/env/index.d.ts +3481 -0
- package/dist/env/index.js +82 -0
- package/dist/env/llm/index.d.ts +1760 -0
- package/dist/env/llm/index.js +40 -0
- package/dist/env/log-trace/index.d.ts +1574 -0
- package/dist/env/log-trace/index.js +83 -0
- package/dist/env/mcp/index.d.ts +1331 -0
- package/dist/env/mcp/index.js +39 -0
- package/dist/env/mcp/tool/index.d.ts +183 -0
- package/dist/env/mcp/tool/index.js +14 -0
- package/dist/env/memory/built-in/index.d.ts +232 -0
- package/dist/env/memory/built-in/index.js +11 -0
- package/dist/env/memory/index.d.ts +1799 -0
- package/dist/env/memory/index.js +56 -0
- package/dist/env/memory/plugin/index.d.ts +747 -0
- package/dist/env/memory/plugin/index.js +36 -0
- package/dist/env/prompt/index.d.ts +1164 -0
- package/dist/env/prompt/index.js +20 -0
- package/dist/env/session/index.d.ts +1908 -0
- package/dist/env/session/index.js +25 -0
- package/dist/env/session/storage/index.d.ts +564 -0
- package/dist/env/session/storage/index.js +18 -0
- package/dist/env/skill/index.d.ts +1266 -0
- package/dist/env/skill/index.js +34 -0
- package/dist/env/skill/tool/index.d.ts +193 -0
- package/dist/env/skill/tool/index.js +9 -0
- package/dist/env/task/delegate/index.d.ts +1612 -0
- package/dist/env/task/delegate/index.js +18 -0
- package/dist/env/task/events/index.d.ts +171 -0
- package/dist/env/task/events/index.js +7 -0
- package/dist/env/task/hooks/index.d.ts +624 -0
- package/dist/env/task/hooks/index.js +7 -0
- package/dist/env/task/index.d.ts +1553 -0
- package/dist/env/task/index.js +34 -0
- package/dist/env/task/plugins/index.d.ts +466 -0
- package/dist/env/task/plugins/index.js +23 -0
- package/dist/env/task/storage/index.d.ts +241 -0
- package/dist/env/task/storage/index.js +14 -0
- package/dist/env/task/tools/index.d.ts +1485 -0
- package/dist/env/task/tools/index.js +17 -0
- package/dist/env/task/tools/operation/index.d.ts +1484 -0
- package/dist/env/task/tools/operation/index.js +15 -0
- package/dist/env/tool/built-in/index.d.ts +218 -0
- package/dist/env/tool/built-in/index.js +25 -0
- package/dist/env/tool/index.d.ts +1396 -0
- package/dist/env/tool/index.js +39 -0
- package/dist/env/workflow/decorators/index.d.ts +2161 -0
- package/dist/env/workflow/decorators/index.js +27 -0
- package/dist/env/workflow/engine/index.d.ts +3453 -0
- package/dist/env/workflow/engine/index.js +28 -0
- package/dist/env/workflow/index.d.ts +3546 -0
- package/dist/env/workflow/index.js +136 -0
- package/dist/env/workflow/nodes/index.d.ts +2092 -0
- package/dist/env/workflow/nodes/index.js +19 -0
- package/dist/env/workflow/service/index.d.ts +227 -0
- package/dist/env/workflow/service/index.js +13 -0
- package/dist/env/workflow/storage/index.d.ts +165 -0
- package/dist/env/workflow/storage/index.js +27 -0
- package/dist/env/workflow/tools/index.d.ts +416 -0
- package/dist/env/workflow/tools/index.js +159 -0
- package/dist/env/workflow/types/index.d.ts +2255 -0
- package/dist/env/workflow/types/index.js +98 -0
- package/dist/env/workflow/utils/index.d.ts +2031 -0
- package/dist/env/workflow/utils/index.js +637 -0
- package/dist/index.d.ts +7858 -0
- package/dist/index.js +399 -0
- package/dist/shared/@ai-setting/roy-agent-core-0rtxwr28.js +258 -0
- package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +36 -0
- package/dist/shared/@ai-setting/roy-agent-core-1akcqxj9.js +349 -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-3jywqmdd.js +393 -0
- package/dist/shared/@ai-setting/roy-agent-core-3rr5k71j.js +200 -0
- package/dist/shared/@ai-setting/roy-agent-core-44hnfb02.js +299 -0
- package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +206 -0
- package/dist/shared/@ai-setting/roy-agent-core-4txzpsbt.js +393 -0
- package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +350 -0
- package/dist/shared/@ai-setting/roy-agent-core-69jskqjg.js +180 -0
- package/dist/shared/@ai-setting/roy-agent-core-6kvtahqv.js +408 -0
- package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +284 -0
- package/dist/shared/@ai-setting/roy-agent-core-81w1963m.js +762 -0
- package/dist/shared/@ai-setting/roy-agent-core-8gxth0eh.js +10 -0
- package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +14 -0
- package/dist/shared/@ai-setting/roy-agent-core-93zfb3r1.js +922 -0
- package/dist/shared/@ai-setting/roy-agent-core-9yxb3ty9.js +15 -0
- package/dist/shared/@ai-setting/roy-agent-core-b0x5dda6.js +1130 -0
- package/dist/shared/@ai-setting/roy-agent-core-bcbqy27c.js +14 -0
- package/dist/shared/@ai-setting/roy-agent-core-bvr1761x.js +653 -0
- package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +93 -0
- package/dist/shared/@ai-setting/roy-agent-core-d7cyjkf7.js +872 -0
- package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +11 -0
- package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +64 -0
- package/dist/shared/@ai-setting/roy-agent-core-eajcvp4e.js +378 -0
- package/dist/shared/@ai-setting/roy-agent-core-f7q2x5z6.js +492 -0
- package/dist/shared/@ai-setting/roy-agent-core-fs0mn2jk.js +52 -0
- package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +171 -0
- package/dist/shared/@ai-setting/roy-agent-core-g99pxzn5.js +862 -0
- package/dist/shared/@ai-setting/roy-agent-core-gbqcyegm.js +1387 -0
- package/dist/shared/@ai-setting/roy-agent-core-gjq1yk68.js +208 -0
- package/dist/shared/@ai-setting/roy-agent-core-gq20wsgv.js +139 -0
- package/dist/shared/@ai-setting/roy-agent-core-gwc4h96n.js +534 -0
- package/dist/shared/@ai-setting/roy-agent-core-jfh9q2qh.js +204 -0
- package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +603 -0
- package/dist/shared/@ai-setting/roy-agent-core-kkbwepqb.js +97 -0
- package/dist/shared/@ai-setting/roy-agent-core-pjr12nnd.js +587 -0
- package/dist/shared/@ai-setting/roy-agent-core-psv4v63c.js +176 -0
- package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +60 -0
- package/dist/shared/@ai-setting/roy-agent-core-qqceba6k.js +442 -0
- 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-r9ezzemr.js +10 -0
- package/dist/shared/@ai-setting/roy-agent-core-rhmtwnw1.js +267 -0
- package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +584 -0
- package/dist/shared/@ai-setting/roy-agent-core-rvxg1wps.js +102 -0
- package/dist/shared/@ai-setting/roy-agent-core-satmq6sh.js +549 -0
- package/dist/shared/@ai-setting/roy-agent-core-sx7wsvnn.js +15 -0
- package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +213 -0
- package/dist/shared/@ai-setting/roy-agent-core-vf215qfv.js +812 -0
- package/dist/shared/@ai-setting/roy-agent-core-vkz81f7v.js +1316 -0
- package/dist/shared/@ai-setting/roy-agent-core-vn2bc59q.js +1205 -0
- package/dist/shared/@ai-setting/roy-agent-core-wa1kzqky.js +328 -0
- package/dist/shared/@ai-setting/roy-agent-core-wft9ra24.js +20 -0
- package/dist/shared/@ai-setting/roy-agent-core-wrcy0h6z.js +2098 -0
- package/dist/shared/@ai-setting/roy-agent-core-xq8hhqb8.js +419 -0
- package/dist/shared/@ai-setting/roy-agent-core-xs5rsgat.js +368 -0
- package/dist/shared/@ai-setting/roy-agent-core-zbkpc41z.js +377 -0
- package/dist/shared/@ai-setting/roy-agent-core-zgypchmt.js +172 -0
- package/dist/shared/@ai-setting/roy-agent-core-zpn0bqa8.js +103 -0
- package/package.json +29 -8
|
@@ -0,0 +1,350 @@
|
|
|
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, InputParameterSchema, WorkflowInputsSchema, 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
|
+
InputParameterSchema = z.object({
|
|
90
|
+
type: z.enum(["string", "number", "boolean", "object", "array"]),
|
|
91
|
+
description: z.string().optional(),
|
|
92
|
+
default: z.unknown().optional(),
|
|
93
|
+
required: z.boolean().default(false)
|
|
94
|
+
});
|
|
95
|
+
WorkflowInputsSchema = z.record(z.string(), InputParameterSchema);
|
|
96
|
+
WorkflowMetadataSchema = z.object({
|
|
97
|
+
author: z.string().optional(),
|
|
98
|
+
taskId: z.number().optional(),
|
|
99
|
+
tags: z.array(z.string()).optional().default([]),
|
|
100
|
+
created_at: z.string().optional(),
|
|
101
|
+
updated_at: z.string().optional()
|
|
102
|
+
});
|
|
103
|
+
WorkflowDefinitionSchema = z.object({
|
|
104
|
+
name: z.string().min(1, "Workflow name is required"),
|
|
105
|
+
version: z.string().default("1.0"),
|
|
106
|
+
description: z.string().optional(),
|
|
107
|
+
config: WorkflowConfigSchema.optional().default({}),
|
|
108
|
+
nodes: z.array(NodeDefinitionSchema).min(1, "At least one node is required"),
|
|
109
|
+
entry: z.union([z.string(), z.array(z.string())]).default("__default_entry__"),
|
|
110
|
+
outputs: z.array(OutputDefinitionSchema).optional().default([]),
|
|
111
|
+
inputs: WorkflowInputsSchema.optional().default({}),
|
|
112
|
+
metadata: WorkflowMetadataSchema.optional().default({})
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// src/env/workflow/types/workflow-message.ts
|
|
117
|
+
import { z as z2 } from "zod";
|
|
118
|
+
var WorkflowMessageRoleSchema;
|
|
119
|
+
var init_workflow_message = __esm(() => {
|
|
120
|
+
init_workflow_hil();
|
|
121
|
+
WorkflowMessageRoleSchema = z2.enum([
|
|
122
|
+
"workflow.node.start",
|
|
123
|
+
"workflow.node.interrupt",
|
|
124
|
+
"workflow.node.end",
|
|
125
|
+
"workflow.node.resume"
|
|
126
|
+
]);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// src/env/workflow/types/workflow-session.ts
|
|
130
|
+
function isWorkflowSessionMetadata(metadata) {
|
|
131
|
+
if (typeof metadata !== "object" || metadata === null || !("type" in metadata) || metadata.type !== "workflow") {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
const m = metadata;
|
|
135
|
+
if (!m.workflowId || typeof m.workflowId !== "string") {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
if (!m.workflowName || typeof m.workflowName !== "string") {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
if (!m.status || typeof m.status !== "string") {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
const validStatuses = ["running", "paused", "completed", "failed", "stopped"];
|
|
145
|
+
if (!validStatuses.includes(m.status)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
function getWorkflowSessionStatus(metadata) {
|
|
151
|
+
return metadata.status || "running";
|
|
152
|
+
}
|
|
153
|
+
var init_workflow_session = () => {};
|
|
154
|
+
|
|
155
|
+
// src/env/workflow/types/context.ts
|
|
156
|
+
var init_context = () => {};
|
|
157
|
+
|
|
158
|
+
// src/env/workflow/types/event.ts
|
|
159
|
+
import { z as z3 } from "zod";
|
|
160
|
+
function createWorkflowEvent(type, runId, data) {
|
|
161
|
+
return {
|
|
162
|
+
type,
|
|
163
|
+
run_id: runId,
|
|
164
|
+
timestamp: Date.now(),
|
|
165
|
+
...data
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
var BaseEventSchema, WorkflowStartedEventSchema, WorkflowPausedEventSchema, WorkflowResumedEventSchema, WorkflowStoppedEventSchema, WorkflowCompletedEventSchema, WorkflowFailedEventSchema, WorkflowOutputEventSchema, NodeScheduledEventSchema, NodeStartedEventSchema, NodeProgressEventSchema, NodeCompletedEventSchema, NodeFailedEventSchema, NodeSkippedEventSchema, NodeDataEventSchema, NodeAddedEventSchema, NodeRemovedEventSchema, ControlPauseEventSchema, ControlResumeEventSchema, ControlStopEventSchema, NodeInterruptEventSchema, WorkflowAskUserEventSchema, WorkflowEventSchema;
|
|
169
|
+
var init_event = __esm(() => {
|
|
170
|
+
BaseEventSchema = z3.object({
|
|
171
|
+
type: z3.string(),
|
|
172
|
+
run_id: z3.string(),
|
|
173
|
+
timestamp: z3.number()
|
|
174
|
+
});
|
|
175
|
+
WorkflowStartedEventSchema = BaseEventSchema.extend({
|
|
176
|
+
type: z3.literal("workflow.started"),
|
|
177
|
+
workflow_name: z3.string(),
|
|
178
|
+
input: z3.record(z3.string(), z3.unknown()).optional()
|
|
179
|
+
});
|
|
180
|
+
WorkflowPausedEventSchema = BaseEventSchema.extend({
|
|
181
|
+
type: z3.literal("workflow.paused")
|
|
182
|
+
});
|
|
183
|
+
WorkflowResumedEventSchema = BaseEventSchema.extend({
|
|
184
|
+
type: z3.literal("workflow.resumed")
|
|
185
|
+
});
|
|
186
|
+
WorkflowStoppedEventSchema = BaseEventSchema.extend({
|
|
187
|
+
type: z3.literal("workflow.stopped"),
|
|
188
|
+
reason: z3.string()
|
|
189
|
+
});
|
|
190
|
+
WorkflowCompletedEventSchema = BaseEventSchema.extend({
|
|
191
|
+
type: z3.literal("workflow.completed"),
|
|
192
|
+
result: z3.record(z3.string(), z3.unknown()).optional(),
|
|
193
|
+
duration_ms: z3.number()
|
|
194
|
+
});
|
|
195
|
+
WorkflowFailedEventSchema = BaseEventSchema.extend({
|
|
196
|
+
type: z3.literal("workflow.failed"),
|
|
197
|
+
error: z3.object({
|
|
198
|
+
message: z3.string(),
|
|
199
|
+
stack: z3.string().optional()
|
|
200
|
+
}),
|
|
201
|
+
failed_at: z3.string()
|
|
202
|
+
});
|
|
203
|
+
WorkflowOutputEventSchema = BaseEventSchema.extend({
|
|
204
|
+
type: z3.literal("workflow.output"),
|
|
205
|
+
output: z3.record(z3.string(), z3.unknown())
|
|
206
|
+
});
|
|
207
|
+
NodeScheduledEventSchema = BaseEventSchema.extend({
|
|
208
|
+
type: z3.literal("node.scheduled"),
|
|
209
|
+
node_id: z3.string()
|
|
210
|
+
});
|
|
211
|
+
NodeStartedEventSchema = BaseEventSchema.extend({
|
|
212
|
+
type: z3.literal("node.started"),
|
|
213
|
+
node_id: z3.string(),
|
|
214
|
+
input: z3.any().optional(),
|
|
215
|
+
agentSessionId: z3.string().optional(),
|
|
216
|
+
userQuery: z3.string().optional(),
|
|
217
|
+
userResponse: z3.string().optional()
|
|
218
|
+
});
|
|
219
|
+
NodeProgressEventSchema = BaseEventSchema.extend({
|
|
220
|
+
type: z3.literal("node.progress"),
|
|
221
|
+
node_id: z3.string(),
|
|
222
|
+
progress: z3.number(),
|
|
223
|
+
message: z3.string().optional()
|
|
224
|
+
});
|
|
225
|
+
NodeCompletedEventSchema = BaseEventSchema.extend({
|
|
226
|
+
type: z3.literal("node.completed"),
|
|
227
|
+
node_id: z3.string(),
|
|
228
|
+
output: z3.any(),
|
|
229
|
+
duration_ms: z3.number()
|
|
230
|
+
});
|
|
231
|
+
NodeFailedEventSchema = BaseEventSchema.extend({
|
|
232
|
+
type: z3.literal("node.failed"),
|
|
233
|
+
node_id: z3.string(),
|
|
234
|
+
error: z3.object({
|
|
235
|
+
message: z3.string(),
|
|
236
|
+
stack: z3.string().optional()
|
|
237
|
+
})
|
|
238
|
+
});
|
|
239
|
+
NodeSkippedEventSchema = BaseEventSchema.extend({
|
|
240
|
+
type: z3.literal("node.skipped"),
|
|
241
|
+
node_id: z3.string(),
|
|
242
|
+
reason: z3.string()
|
|
243
|
+
});
|
|
244
|
+
NodeDataEventSchema = BaseEventSchema.extend({
|
|
245
|
+
type: z3.literal("node.data"),
|
|
246
|
+
from_node: z3.string(),
|
|
247
|
+
to_node: z3.string(),
|
|
248
|
+
data: z3.any()
|
|
249
|
+
});
|
|
250
|
+
NodeAddedEventSchema = BaseEventSchema.extend({
|
|
251
|
+
type: z3.literal("node.added"),
|
|
252
|
+
node_id: z3.string(),
|
|
253
|
+
node: z3.any()
|
|
254
|
+
});
|
|
255
|
+
NodeRemovedEventSchema = BaseEventSchema.extend({
|
|
256
|
+
type: z3.literal("node.removed"),
|
|
257
|
+
node_id: z3.string()
|
|
258
|
+
});
|
|
259
|
+
ControlPauseEventSchema = BaseEventSchema.extend({
|
|
260
|
+
type: z3.literal("control.pause")
|
|
261
|
+
});
|
|
262
|
+
ControlResumeEventSchema = BaseEventSchema.extend({
|
|
263
|
+
type: z3.literal("control.resume")
|
|
264
|
+
});
|
|
265
|
+
ControlStopEventSchema = BaseEventSchema.extend({
|
|
266
|
+
type: z3.literal("control.stop")
|
|
267
|
+
});
|
|
268
|
+
NodeInterruptEventSchema = BaseEventSchema.extend({
|
|
269
|
+
type: z3.literal("node.interrupt"),
|
|
270
|
+
node_id: z3.string(),
|
|
271
|
+
node_type: z3.string(),
|
|
272
|
+
query: z3.string()
|
|
273
|
+
});
|
|
274
|
+
WorkflowAskUserEventSchema = BaseEventSchema.extend({
|
|
275
|
+
type: z3.literal("workflow.ask-user"),
|
|
276
|
+
session_id: z3.string(),
|
|
277
|
+
node_id: z3.string(),
|
|
278
|
+
node_type: z3.string(),
|
|
279
|
+
query: z3.string()
|
|
280
|
+
});
|
|
281
|
+
WorkflowEventSchema = z3.union([
|
|
282
|
+
WorkflowStartedEventSchema,
|
|
283
|
+
WorkflowPausedEventSchema,
|
|
284
|
+
WorkflowResumedEventSchema,
|
|
285
|
+
WorkflowStoppedEventSchema,
|
|
286
|
+
WorkflowCompletedEventSchema,
|
|
287
|
+
WorkflowFailedEventSchema,
|
|
288
|
+
WorkflowOutputEventSchema,
|
|
289
|
+
NodeScheduledEventSchema,
|
|
290
|
+
NodeStartedEventSchema,
|
|
291
|
+
NodeProgressEventSchema,
|
|
292
|
+
NodeCompletedEventSchema,
|
|
293
|
+
NodeFailedEventSchema,
|
|
294
|
+
NodeSkippedEventSchema,
|
|
295
|
+
NodeDataEventSchema,
|
|
296
|
+
NodeAddedEventSchema,
|
|
297
|
+
NodeRemovedEventSchema,
|
|
298
|
+
ControlPauseEventSchema,
|
|
299
|
+
ControlResumeEventSchema,
|
|
300
|
+
ControlStopEventSchema,
|
|
301
|
+
NodeInterruptEventSchema,
|
|
302
|
+
WorkflowAskUserEventSchema
|
|
303
|
+
]);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// src/env/workflow/types/run.ts
|
|
307
|
+
import { z as z4 } from "zod";
|
|
308
|
+
function createNodeExecutionContext(params) {
|
|
309
|
+
return {
|
|
310
|
+
...params,
|
|
311
|
+
askUser: (query) => {
|
|
312
|
+
throw new AskUserError(params.runId, params.sessionId, params.nodeId, "unknown", query);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
var RunStatusSchema, NodeStatusSchema;
|
|
317
|
+
var init_run = __esm(() => {
|
|
318
|
+
init_workflow_message();
|
|
319
|
+
RunStatusSchema = z4.enum([
|
|
320
|
+
"idle",
|
|
321
|
+
"running",
|
|
322
|
+
"paused",
|
|
323
|
+
"stopped",
|
|
324
|
+
"completed",
|
|
325
|
+
"failed"
|
|
326
|
+
]);
|
|
327
|
+
NodeStatusSchema = z4.enum([
|
|
328
|
+
"pending",
|
|
329
|
+
"scheduled",
|
|
330
|
+
"started",
|
|
331
|
+
"running",
|
|
332
|
+
"completed",
|
|
333
|
+
"failed",
|
|
334
|
+
"skipped"
|
|
335
|
+
]);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// src/env/workflow/types/index.ts
|
|
339
|
+
var init_types = __esm(() => {
|
|
340
|
+
init_run();
|
|
341
|
+
init_workflow();
|
|
342
|
+
init_workflow_message();
|
|
343
|
+
init_workflow_session();
|
|
344
|
+
init_context();
|
|
345
|
+
init_workflow_hil();
|
|
346
|
+
init_event();
|
|
347
|
+
init_run();
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
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, InputParameterSchema, WorkflowInputsSchema, WorkflowMetadataSchema, WorkflowDefinitionSchema, parseWorkflowFile, parseWorkflowFileSync, WorkflowMessageRoleSchema, isWorkflowSessionMetadata, getWorkflowSessionStatus, RunStatusSchema, NodeStatusSchema, createNodeExecutionContext, init_types };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AskUserError,
|
|
3
|
+
init_workflow_hil
|
|
4
|
+
} from "./roy-agent-core-e25xkv53.js";
|
|
5
|
+
import {
|
|
6
|
+
__esm
|
|
7
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
8
|
+
|
|
9
|
+
// src/env/workflow/nodes/agent-component-adapter.ts
|
|
10
|
+
class AgentComponentAdapter {
|
|
11
|
+
agentComponent;
|
|
12
|
+
options;
|
|
13
|
+
_sessionComponent;
|
|
14
|
+
agentSessionPrefix = "agent";
|
|
15
|
+
_currentAgentSessionId;
|
|
16
|
+
pendingSessions = new Map;
|
|
17
|
+
runSessionToAgentSessions = new Map;
|
|
18
|
+
constructor(agentComponent, options = {}, _sessionComponent) {
|
|
19
|
+
this.agentComponent = agentComponent;
|
|
20
|
+
this.options = options;
|
|
21
|
+
this._sessionComponent = _sessionComponent;
|
|
22
|
+
}
|
|
23
|
+
setSessionComponent(sessionComponent) {
|
|
24
|
+
this._sessionComponent = sessionComponent;
|
|
25
|
+
}
|
|
26
|
+
getCurrentAgentSessionId() {
|
|
27
|
+
return this._currentAgentSessionId;
|
|
28
|
+
}
|
|
29
|
+
registerAgent(name, config) {
|
|
30
|
+
this.agentComponent.registerAgent(name, {
|
|
31
|
+
type: config.type || "general",
|
|
32
|
+
model: config.model,
|
|
33
|
+
systemPrompt: config.systemPrompt,
|
|
34
|
+
maxIterations: config.maxIterations,
|
|
35
|
+
allowedTools: config.allowedTools,
|
|
36
|
+
deniedTools: config.deniedTools,
|
|
37
|
+
timeout: config.timeout,
|
|
38
|
+
maxErrorRetries: config.maxErrorRetries
|
|
39
|
+
});
|
|
40
|
+
if (config.sessionIdPrefix) {
|
|
41
|
+
this.agentSessionPrefixes.set(name, config.sessionIdPrefix);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async run(config, resumeOptions) {
|
|
45
|
+
const startTime = Date.now();
|
|
46
|
+
const nodeId = config.nodeId || "unknown";
|
|
47
|
+
const runId = config.runId || "unknown";
|
|
48
|
+
const workflowSessionId = config.workflowSessionId;
|
|
49
|
+
const isResume = !!resumeOptions?.userQuery;
|
|
50
|
+
let agentSessionId = resumeOptions?.agentSessionId || config.agentSessionId || this._currentAgentSessionId;
|
|
51
|
+
if (!agentSessionId && this._sessionComponent) {
|
|
52
|
+
agentSessionId = `${this.agentSessionPrefix}_${runId}_${nodeId}_${Date.now()}`;
|
|
53
|
+
try {
|
|
54
|
+
await this._sessionComponent.create({
|
|
55
|
+
title: `Agent Session: ${config.type} (${agentSessionId})`,
|
|
56
|
+
metadata: {
|
|
57
|
+
type: "agent",
|
|
58
|
+
workflowRunId: runId,
|
|
59
|
+
workflowNodeId: nodeId
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.warn(`Failed to create agent session ${agentSessionId}:`, error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (agentSessionId) {
|
|
67
|
+
this._currentAgentSessionId = agentSessionId;
|
|
68
|
+
if (workflowSessionId && this._sessionComponent) {
|
|
69
|
+
const mapping = this.runSessionToAgentSessions.get(workflowSessionId) || [];
|
|
70
|
+
if (!mapping.includes(agentSessionId)) {
|
|
71
|
+
mapping.push(agentSessionId);
|
|
72
|
+
this.runSessionToAgentSessions.set(workflowSessionId, mapping);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (isResume) {
|
|
76
|
+
this.pendingSessions.delete(agentSessionId);
|
|
77
|
+
} else {
|
|
78
|
+
this.pendingSessions.set(agentSessionId, {
|
|
79
|
+
agentSessionId,
|
|
80
|
+
nodeId,
|
|
81
|
+
runId,
|
|
82
|
+
createdAt: Date.now()
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const context = {};
|
|
88
|
+
if (config.options?.timeout) {
|
|
89
|
+
context.abort = new AbortController;
|
|
90
|
+
}
|
|
91
|
+
if (agentSessionId) {
|
|
92
|
+
context.sessionId = agentSessionId;
|
|
93
|
+
}
|
|
94
|
+
if (config.options?.allowedTools) {
|
|
95
|
+
context.allowedTools = config.options.allowedTools;
|
|
96
|
+
}
|
|
97
|
+
if (config.options?.deniedTools) {
|
|
98
|
+
context.deniedTools = config.options.deniedTools;
|
|
99
|
+
}
|
|
100
|
+
if (config.workflowHistory) {
|
|
101
|
+
context.workflowHistory = config.workflowHistory;
|
|
102
|
+
}
|
|
103
|
+
context.additionInfo = config.prompt;
|
|
104
|
+
const userInput = resumeOptions?.userQuery || "";
|
|
105
|
+
const result = await this.agentComponent.run(config.type || "general", userInput, context);
|
|
106
|
+
if (result.error?.startsWith("__ASK_USER_ERROR__:")) {
|
|
107
|
+
const jsonStr = result.error.substring("__ASK_USER_ERROR__:".length);
|
|
108
|
+
const errorInfo = JSON.parse(jsonStr);
|
|
109
|
+
throw new AskUserError(runId, errorInfo.sessionId, errorInfo.nodeId, errorInfo.nodeType || "agent", errorInfo.query);
|
|
110
|
+
}
|
|
111
|
+
const duration = Date.now() - startTime;
|
|
112
|
+
if (agentSessionId) {
|
|
113
|
+
this.pendingSessions.delete(agentSessionId);
|
|
114
|
+
}
|
|
115
|
+
const messages = result._messages || [];
|
|
116
|
+
return {
|
|
117
|
+
output: result.finalText || result.output,
|
|
118
|
+
metadata: {
|
|
119
|
+
duration,
|
|
120
|
+
iterations: result.iterations,
|
|
121
|
+
toolCalls: result.toolCalls?.length,
|
|
122
|
+
agentSessionId
|
|
123
|
+
},
|
|
124
|
+
messages
|
|
125
|
+
};
|
|
126
|
+
} catch (error) {
|
|
127
|
+
const isAskUserError = error instanceof Error && error.name === "AskUserError";
|
|
128
|
+
if (isAskUserError) {
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
const duration = Date.now() - startTime;
|
|
132
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
133
|
+
if (agentSessionId) {
|
|
134
|
+
this.pendingSessions.delete(agentSessionId);
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
output: undefined,
|
|
138
|
+
metadata: {
|
|
139
|
+
duration,
|
|
140
|
+
error: errorMessage,
|
|
141
|
+
agentSessionId
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
} finally {
|
|
145
|
+
if (isResume) {
|
|
146
|
+
this._currentAgentSessionId = undefined;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async resumeAgent(agentSessionId, userQuery, config) {
|
|
151
|
+
this.pendingSessions.delete(agentSessionId);
|
|
152
|
+
this._currentAgentSessionId = agentSessionId;
|
|
153
|
+
config.agentSessionId = agentSessionId;
|
|
154
|
+
return this.run(config, { userQuery, agentSessionId });
|
|
155
|
+
}
|
|
156
|
+
getPendingSession(agentSessionId) {
|
|
157
|
+
return this.pendingSessions.get(agentSessionId);
|
|
158
|
+
}
|
|
159
|
+
getPendingSessionsForRun(runId) {
|
|
160
|
+
return Array.from(this.pendingSessions.values()).filter((session) => session.runId === runId);
|
|
161
|
+
}
|
|
162
|
+
getAgentSessionsForWorkflowSession(workflowSessionId) {
|
|
163
|
+
return this.runSessionToAgentSessions.get(workflowSessionId) || [];
|
|
164
|
+
}
|
|
165
|
+
hasAgent(name) {
|
|
166
|
+
return this.agentComponent.getAgent(name) !== undefined;
|
|
167
|
+
}
|
|
168
|
+
listAgents() {
|
|
169
|
+
return this.agentComponent.listAgents().map((a) => a.name);
|
|
170
|
+
}
|
|
171
|
+
getAgentComponent() {
|
|
172
|
+
return this.agentComponent;
|
|
173
|
+
}
|
|
174
|
+
agentSessionPrefixes = new Map;
|
|
175
|
+
}
|
|
176
|
+
var init_agent_component_adapter = __esm(() => {
|
|
177
|
+
init_workflow_hil();
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
export { AgentComponentAdapter, init_agent_component_adapter };
|