@ai-setting/roy-agent-core 1.5.43 → 1.5.45
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 +5 -5
- package/dist/env/agent/index.js +5 -5
- package/dist/env/commands/index.js +5 -5
- package/dist/env/context/index.js +4 -1
- package/dist/env/debug/index.js +5 -5
- package/dist/env/event-source/index.js +7 -7
- package/dist/env/hook/index.js +3 -3
- package/dist/env/index.js +24 -20
- package/dist/env/llm/index.js +5 -5
- package/dist/env/log-trace/index.js +5 -5
- package/dist/env/mcp/index.js +20 -6
- package/dist/env/memory/index.js +5 -5
- package/dist/env/plugin/index.js +5 -5
- package/dist/env/prompt/index.js +5 -5
- package/dist/env/session/index.js +6 -6
- package/dist/env/session/storage/index.js +1 -1
- package/dist/env/skill/index.js +5 -5
- package/dist/env/task/delegate/index.js +3 -3
- package/dist/env/task/index.js +6 -6
- package/dist/env/task/plugins/index.js +2 -2
- package/dist/env/tool/built-in/index.js +1 -1
- package/dist/env/tool/index.js +6 -6
- package/dist/env/workflow/decorators/index.js +1 -1
- package/dist/env/workflow/engine/index.js +10 -4
- package/dist/env/workflow/index.js +42 -24
- package/dist/env/workflow/nodes/index.js +5 -1
- package/dist/env/workflow/tools/index.js +14 -0
- package/dist/env/workflow/types/index.js +16 -2
- package/dist/env/workflow/utils/index.js +15 -196
- package/dist/index.js +35 -31
- package/dist/shared/@ai-setting/{roy-agent-core-kajktp3d.js → roy-agent-core-20fm423j.js} +47 -26
- package/dist/shared/@ai-setting/{roy-agent-core-ffb9fq4v.js → roy-agent-core-2vhsccvz.js} +54 -12
- package/dist/shared/@ai-setting/{roy-agent-core-69jskqjg.js → roy-agent-core-44g4dhzg.js} +75 -7
- package/dist/shared/@ai-setting/{roy-agent-core-e9fdm13a.js → roy-agent-core-4gmxjdhn.js} +4 -2
- package/dist/shared/@ai-setting/{roy-agent-core-b4wd9tn6.js → roy-agent-core-4k9a823d.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-68qy97r3.js +31 -0
- package/dist/shared/@ai-setting/roy-agent-core-6atd905e.js +42 -0
- package/dist/shared/@ai-setting/{roy-agent-core-4jqq077c.js → roy-agent-core-6e3wz81d.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-pwkk12p4.js → roy-agent-core-6mcb7nqa.js} +60 -0
- package/dist/shared/@ai-setting/roy-agent-core-6vxg2gmr.js +321 -0
- package/dist/shared/@ai-setting/{roy-agent-core-9p43ap7h.js → roy-agent-core-8y804aat.js} +4 -2
- package/dist/shared/@ai-setting/{roy-agent-core-0rtxwr28.js → roy-agent-core-9bmtxmp6.js} +77 -120
- package/dist/shared/@ai-setting/{roy-agent-core-r6rwsr54.js → roy-agent-core-9p604xjf.js} +29 -9
- package/dist/shared/@ai-setting/{roy-agent-core-z1xf2fdk.js → roy-agent-core-a67e90d1.js} +6 -4
- package/dist/shared/@ai-setting/{roy-agent-core-xkb264a8.js → roy-agent-core-bp3xggmb.js} +192 -26
- package/dist/shared/@ai-setting/{roy-agent-core-zrja5v78.js → roy-agent-core-ce9w0j8n.js} +10 -2
- package/dist/shared/@ai-setting/{roy-agent-core-bmr6bdfb.js → roy-agent-core-cr8xer31.js} +15 -8
- package/dist/shared/@ai-setting/roy-agent-core-dbxm76wf.js +190 -0
- package/dist/shared/@ai-setting/{roy-agent-core-nj8yerg9.js → roy-agent-core-eftqdsy5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-7fgf85wc.js → roy-agent-core-h0x19xgn.js} +6 -7
- package/dist/shared/@ai-setting/{roy-agent-core-psvwzdhj.js → roy-agent-core-hdszq729.js} +9 -5
- package/dist/shared/@ai-setting/{roy-agent-core-dxbsc1zy.js → roy-agent-core-ja9qhg6d.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-cevpwnq7.js → roy-agent-core-mjbfgqen.js} +5 -3
- package/dist/shared/@ai-setting/roy-agent-core-nhfy3p8q.js +132 -0
- package/dist/shared/@ai-setting/{roy-agent-core-2jnzv9at.js → roy-agent-core-nn9dmffw.js} +629 -288
- package/dist/shared/@ai-setting/roy-agent-core-qnrf2aw6.js +441 -0
- package/dist/shared/@ai-setting/{roy-agent-core-ee6nnnqw.js → roy-agent-core-r9hq4cjx.js} +8 -1
- package/dist/shared/@ai-setting/{roy-agent-core-jqy2mdyq.js → roy-agent-core-rgj6hq15.js} +52 -41
- package/dist/shared/@ai-setting/{roy-agent-core-z33en0cz.js → roy-agent-core-rm3hay00.js} +15 -2
- package/dist/shared/@ai-setting/{roy-agent-core-e130w7mv.js → roy-agent-core-rx74rye7.js} +5 -3
- package/dist/shared/@ai-setting/{roy-agent-core-pxcrzyv9.js → roy-agent-core-sk535ft2.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-v002ynpa.js +435 -0
- package/dist/shared/@ai-setting/{roy-agent-core-2dhd60aw.js → roy-agent-core-vdwvamre.js} +10 -0
- package/dist/shared/@ai-setting/{roy-agent-core-1zq3p19q.js → roy-agent-core-w64zachx.js} +8 -4
- package/dist/shared/@ai-setting/roy-agent-core-ye0z728h.js +18 -0
- package/dist/shared/@ai-setting/{roy-agent-core-rsybkb38.js → roy-agent-core-ysvh8er9.js} +36 -39
- package/dist/shared/@ai-setting/{roy-agent-core-9yxb3ty9.js → roy-agent-core-z5sxe4p7.js} +5 -1
- package/dist/shared/@ai-setting/{roy-agent-core-eg6nv09z.js → roy-agent-core-ztx5eh72.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-nqgrjja0.js → roy-agent-core-zwq6vhpj.js} +1 -1
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
- package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +0 -11
- package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
|
@@ -0,0 +1,441 @@
|
|
|
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/edge.ts
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
var EdgeDefinitionSchema;
|
|
13
|
+
var init_edge = __esm(() => {
|
|
14
|
+
EdgeDefinitionSchema = z.object({
|
|
15
|
+
from: z.string().min(1, "Edge source node ID is required"),
|
|
16
|
+
to: z.string().min(1, "Edge target node ID is required"),
|
|
17
|
+
when: z.string().optional()
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// src/env/workflow/types/workflow.ts
|
|
22
|
+
import { z as z2 } from "zod";
|
|
23
|
+
async function getYamlParser() {
|
|
24
|
+
if (!yamlParser) {
|
|
25
|
+
yamlParser = await import("yaml");
|
|
26
|
+
}
|
|
27
|
+
return yamlParser;
|
|
28
|
+
}
|
|
29
|
+
async function parseWorkflowFile(content, filename) {
|
|
30
|
+
const isYaml = filename.endsWith(".yaml") || filename.endsWith(".yml");
|
|
31
|
+
const isJson = filename.endsWith(".json");
|
|
32
|
+
let definition;
|
|
33
|
+
if (isYaml) {
|
|
34
|
+
const yaml = await getYamlParser();
|
|
35
|
+
definition = WorkflowDefinitionSchema.parse(yaml.parse(content));
|
|
36
|
+
} else if (isJson) {
|
|
37
|
+
definition = WorkflowDefinitionSchema.parse(JSON.parse(content));
|
|
38
|
+
} else {
|
|
39
|
+
try {
|
|
40
|
+
definition = WorkflowDefinitionSchema.parse(JSON.parse(content));
|
|
41
|
+
} catch {
|
|
42
|
+
const yaml = await getYamlParser();
|
|
43
|
+
definition = WorkflowDefinitionSchema.parse(yaml.parse(content));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
format: isYaml ? "yaml" : "json",
|
|
48
|
+
definition
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function parseWorkflowFileSync(content, filename) {
|
|
52
|
+
const isYaml = filename.endsWith(".yaml") || filename.endsWith(".yml");
|
|
53
|
+
const isJson = filename.endsWith(".json");
|
|
54
|
+
let definition;
|
|
55
|
+
if (isJson) {
|
|
56
|
+
definition = WorkflowDefinitionSchema.parse(JSON.parse(content));
|
|
57
|
+
} else if (isYaml) {
|
|
58
|
+
throw new Error("Synchronous YAML parsing not supported. Use parseWorkflowFile() instead.");
|
|
59
|
+
} else {
|
|
60
|
+
try {
|
|
61
|
+
definition = WorkflowDefinitionSchema.parse(JSON.parse(content));
|
|
62
|
+
} catch {
|
|
63
|
+
throw new Error("Cannot auto-detect format. Please use .yaml, .yml, or .json extension.");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
format: isJson ? "json" : "yaml",
|
|
68
|
+
definition
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
var DependsOnSchema, RetryConfigSchema, NodeDefinitionSchema, WorkflowConfigSchema, OutputDefinitionSchema, InputParameterSchema, WorkflowInputsSchema, WorkflowMetadataSchema, WorkflowDefinitionSchema, yamlParser = null;
|
|
72
|
+
var init_workflow = __esm(() => {
|
|
73
|
+
init_edge();
|
|
74
|
+
DependsOnSchema = z2.array(z2.string());
|
|
75
|
+
RetryConfigSchema = z2.object({
|
|
76
|
+
max_attempts: z2.number().min(1).default(1),
|
|
77
|
+
backoff: z2.enum(["fixed", "exponential"]).default("exponential"),
|
|
78
|
+
initial_delay: z2.number().min(0).default(1000)
|
|
79
|
+
});
|
|
80
|
+
NodeDefinitionSchema = z2.object({
|
|
81
|
+
id: z2.string().min(1, "Node ID is required"),
|
|
82
|
+
type: z2.string().min(1, "Node type is required"),
|
|
83
|
+
name: z2.string().optional(),
|
|
84
|
+
config: z2.record(z2.string(), z2.unknown()).optional().default({}),
|
|
85
|
+
depends_on: z2.array(z2.string()).optional(),
|
|
86
|
+
condition: z2.string().optional(),
|
|
87
|
+
retry: RetryConfigSchema.optional(),
|
|
88
|
+
timeout: z2.number().optional()
|
|
89
|
+
});
|
|
90
|
+
WorkflowConfigSchema = z2.object({
|
|
91
|
+
parallel_limit: z2.number().nullable().optional(),
|
|
92
|
+
timeout: z2.number().nullable().optional(),
|
|
93
|
+
retry: RetryConfigSchema.optional(),
|
|
94
|
+
debug: z2.boolean().optional(),
|
|
95
|
+
strict: z2.boolean().optional(),
|
|
96
|
+
maxIterations: z2.number().optional().default(100),
|
|
97
|
+
loopEnabled: z2.boolean().optional().default(false)
|
|
98
|
+
});
|
|
99
|
+
OutputDefinitionSchema = z2.object({
|
|
100
|
+
name: z2.string(),
|
|
101
|
+
source: z2.string(),
|
|
102
|
+
path: z2.string()
|
|
103
|
+
});
|
|
104
|
+
InputParameterSchema = z2.object({
|
|
105
|
+
type: z2.enum(["string", "number", "boolean", "object", "array"]),
|
|
106
|
+
description: z2.string().optional(),
|
|
107
|
+
default: z2.unknown().optional(),
|
|
108
|
+
required: z2.boolean().default(false)
|
|
109
|
+
});
|
|
110
|
+
WorkflowInputsSchema = z2.record(z2.string(), InputParameterSchema);
|
|
111
|
+
WorkflowMetadataSchema = z2.object({
|
|
112
|
+
author: z2.string().optional(),
|
|
113
|
+
taskId: z2.number().optional(),
|
|
114
|
+
tags: z2.array(z2.string()).optional().default([]),
|
|
115
|
+
created_at: z2.string().optional(),
|
|
116
|
+
updated_at: z2.string().optional()
|
|
117
|
+
});
|
|
118
|
+
WorkflowDefinitionSchema = z2.object({
|
|
119
|
+
name: z2.string().min(1, "Workflow name is required"),
|
|
120
|
+
version: z2.string().default("1.0"),
|
|
121
|
+
description: z2.string().optional(),
|
|
122
|
+
config: WorkflowConfigSchema.optional().default({}),
|
|
123
|
+
nodes: z2.array(NodeDefinitionSchema).min(1, "At least one node is required"),
|
|
124
|
+
entry: z2.union([z2.string(), z2.array(z2.string())]).default("__default_entry__"),
|
|
125
|
+
outputs: z2.array(OutputDefinitionSchema).optional().default([]),
|
|
126
|
+
inputs: WorkflowInputsSchema.optional().default({}),
|
|
127
|
+
metadata: WorkflowMetadataSchema.optional().default({}),
|
|
128
|
+
edges: z2.array(EdgeDefinitionSchema).optional().default([])
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// src/env/workflow/types/workflow-message.ts
|
|
133
|
+
import { z as z3 } from "zod";
|
|
134
|
+
var WorkflowMessageRoleSchema;
|
|
135
|
+
var init_workflow_message = __esm(() => {
|
|
136
|
+
init_workflow_hil();
|
|
137
|
+
WorkflowMessageRoleSchema = z3.enum([
|
|
138
|
+
"workflow.node.start",
|
|
139
|
+
"workflow.node.interrupt",
|
|
140
|
+
"workflow.node.end",
|
|
141
|
+
"workflow.node.resume"
|
|
142
|
+
]);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// src/env/workflow/types/workflow-session.ts
|
|
146
|
+
function isWorkflowSessionMetadata(metadata) {
|
|
147
|
+
if (typeof metadata !== "object" || metadata === null || !("type" in metadata) || metadata.type !== "workflow") {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
const m = metadata;
|
|
151
|
+
if (!m.workflowId || typeof m.workflowId !== "string") {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
if (!m.workflowName || typeof m.workflowName !== "string") {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
if (!m.status || typeof m.status !== "string") {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const validStatuses = ["running", "paused", "completed", "failed", "stopped"];
|
|
161
|
+
if (!validStatuses.includes(m.status)) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
function getWorkflowSessionStatus(metadata) {
|
|
167
|
+
return metadata.status || "running";
|
|
168
|
+
}
|
|
169
|
+
var init_workflow_session = () => {};
|
|
170
|
+
|
|
171
|
+
// src/env/workflow/types/context.ts
|
|
172
|
+
var init_context = () => {};
|
|
173
|
+
|
|
174
|
+
// src/env/workflow/types/event.ts
|
|
175
|
+
import { z as z4 } from "zod";
|
|
176
|
+
function createWorkflowEvent(type, runId, data) {
|
|
177
|
+
return {
|
|
178
|
+
type,
|
|
179
|
+
run_id: runId,
|
|
180
|
+
timestamp: Date.now(),
|
|
181
|
+
...data
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
var BaseEventSchema, WorkflowStartedEventSchema, WorkflowPausedEventSchema, WorkflowResumedEventSchema, WorkflowStoppedEventSchema, WorkflowCompletedEventSchema, WorkflowFailedEventSchema, WorkflowOutputEventSchema, NodeScheduledEventSchema, NodeStartedEventSchema, NodeProgressEventSchema, NodeCompletedEventSchema, NodeFailedEventSchema, NodeSkippedEventSchema, NodeDataEventSchema, NodeAddedEventSchema, NodeRemovedEventSchema, ControlPauseEventSchema, ControlResumeEventSchema, ControlStopEventSchema, NodeInterruptEventSchema, WorkflowAskUserEventSchema, WorkflowEventSchema;
|
|
185
|
+
var init_event = __esm(() => {
|
|
186
|
+
BaseEventSchema = z4.object({
|
|
187
|
+
type: z4.string(),
|
|
188
|
+
run_id: z4.string(),
|
|
189
|
+
timestamp: z4.number()
|
|
190
|
+
});
|
|
191
|
+
WorkflowStartedEventSchema = BaseEventSchema.extend({
|
|
192
|
+
type: z4.literal("workflow.started"),
|
|
193
|
+
workflow_name: z4.string(),
|
|
194
|
+
input: z4.record(z4.string(), z4.unknown()).optional()
|
|
195
|
+
});
|
|
196
|
+
WorkflowPausedEventSchema = BaseEventSchema.extend({
|
|
197
|
+
type: z4.literal("workflow.paused")
|
|
198
|
+
});
|
|
199
|
+
WorkflowResumedEventSchema = BaseEventSchema.extend({
|
|
200
|
+
type: z4.literal("workflow.resumed")
|
|
201
|
+
});
|
|
202
|
+
WorkflowStoppedEventSchema = BaseEventSchema.extend({
|
|
203
|
+
type: z4.literal("workflow.stopped"),
|
|
204
|
+
reason: z4.string()
|
|
205
|
+
});
|
|
206
|
+
WorkflowCompletedEventSchema = BaseEventSchema.extend({
|
|
207
|
+
type: z4.literal("workflow.completed"),
|
|
208
|
+
result: z4.record(z4.string(), z4.unknown()).optional(),
|
|
209
|
+
duration_ms: z4.number()
|
|
210
|
+
});
|
|
211
|
+
WorkflowFailedEventSchema = BaseEventSchema.extend({
|
|
212
|
+
type: z4.literal("workflow.failed"),
|
|
213
|
+
error: z4.object({
|
|
214
|
+
message: z4.string(),
|
|
215
|
+
stack: z4.string().optional()
|
|
216
|
+
}),
|
|
217
|
+
failed_at: z4.string()
|
|
218
|
+
});
|
|
219
|
+
WorkflowOutputEventSchema = BaseEventSchema.extend({
|
|
220
|
+
type: z4.literal("workflow.output"),
|
|
221
|
+
output: z4.record(z4.string(), z4.unknown())
|
|
222
|
+
});
|
|
223
|
+
NodeScheduledEventSchema = BaseEventSchema.extend({
|
|
224
|
+
type: z4.literal("node.scheduled"),
|
|
225
|
+
node_id: z4.string()
|
|
226
|
+
});
|
|
227
|
+
NodeStartedEventSchema = BaseEventSchema.extend({
|
|
228
|
+
type: z4.literal("node.started"),
|
|
229
|
+
node_id: z4.string(),
|
|
230
|
+
input: z4.any().optional(),
|
|
231
|
+
agentSessionId: z4.string().optional(),
|
|
232
|
+
userQuery: z4.string().optional(),
|
|
233
|
+
userResponse: z4.string().optional()
|
|
234
|
+
});
|
|
235
|
+
NodeProgressEventSchema = BaseEventSchema.extend({
|
|
236
|
+
type: z4.literal("node.progress"),
|
|
237
|
+
node_id: z4.string(),
|
|
238
|
+
progress: z4.number(),
|
|
239
|
+
message: z4.string().optional()
|
|
240
|
+
});
|
|
241
|
+
NodeCompletedEventSchema = BaseEventSchema.extend({
|
|
242
|
+
type: z4.literal("node.completed"),
|
|
243
|
+
node_id: z4.string(),
|
|
244
|
+
output: z4.any(),
|
|
245
|
+
duration_ms: z4.number()
|
|
246
|
+
});
|
|
247
|
+
NodeFailedEventSchema = BaseEventSchema.extend({
|
|
248
|
+
type: z4.literal("node.failed"),
|
|
249
|
+
node_id: z4.string(),
|
|
250
|
+
error: z4.object({
|
|
251
|
+
message: z4.string(),
|
|
252
|
+
stack: z4.string().optional()
|
|
253
|
+
})
|
|
254
|
+
});
|
|
255
|
+
NodeSkippedEventSchema = BaseEventSchema.extend({
|
|
256
|
+
type: z4.literal("node.skipped"),
|
|
257
|
+
node_id: z4.string(),
|
|
258
|
+
reason: z4.string()
|
|
259
|
+
});
|
|
260
|
+
NodeDataEventSchema = BaseEventSchema.extend({
|
|
261
|
+
type: z4.literal("node.data"),
|
|
262
|
+
from_node: z4.string(),
|
|
263
|
+
to_node: z4.string(),
|
|
264
|
+
data: z4.any()
|
|
265
|
+
});
|
|
266
|
+
NodeAddedEventSchema = BaseEventSchema.extend({
|
|
267
|
+
type: z4.literal("node.added"),
|
|
268
|
+
node_id: z4.string(),
|
|
269
|
+
node: z4.any()
|
|
270
|
+
});
|
|
271
|
+
NodeRemovedEventSchema = BaseEventSchema.extend({
|
|
272
|
+
type: z4.literal("node.removed"),
|
|
273
|
+
node_id: z4.string()
|
|
274
|
+
});
|
|
275
|
+
ControlPauseEventSchema = BaseEventSchema.extend({
|
|
276
|
+
type: z4.literal("control.pause")
|
|
277
|
+
});
|
|
278
|
+
ControlResumeEventSchema = BaseEventSchema.extend({
|
|
279
|
+
type: z4.literal("control.resume")
|
|
280
|
+
});
|
|
281
|
+
ControlStopEventSchema = BaseEventSchema.extend({
|
|
282
|
+
type: z4.literal("control.stop")
|
|
283
|
+
});
|
|
284
|
+
NodeInterruptEventSchema = BaseEventSchema.extend({
|
|
285
|
+
type: z4.literal("node.interrupt"),
|
|
286
|
+
node_id: z4.string(),
|
|
287
|
+
node_type: z4.string(),
|
|
288
|
+
query: z4.string()
|
|
289
|
+
});
|
|
290
|
+
WorkflowAskUserEventSchema = BaseEventSchema.extend({
|
|
291
|
+
type: z4.literal("workflow.ask-user"),
|
|
292
|
+
session_id: z4.string(),
|
|
293
|
+
node_id: z4.string(),
|
|
294
|
+
node_type: z4.string(),
|
|
295
|
+
query: z4.string()
|
|
296
|
+
});
|
|
297
|
+
WorkflowEventSchema = z4.union([
|
|
298
|
+
WorkflowStartedEventSchema,
|
|
299
|
+
WorkflowPausedEventSchema,
|
|
300
|
+
WorkflowResumedEventSchema,
|
|
301
|
+
WorkflowStoppedEventSchema,
|
|
302
|
+
WorkflowCompletedEventSchema,
|
|
303
|
+
WorkflowFailedEventSchema,
|
|
304
|
+
WorkflowOutputEventSchema,
|
|
305
|
+
NodeScheduledEventSchema,
|
|
306
|
+
NodeStartedEventSchema,
|
|
307
|
+
NodeProgressEventSchema,
|
|
308
|
+
NodeCompletedEventSchema,
|
|
309
|
+
NodeFailedEventSchema,
|
|
310
|
+
NodeSkippedEventSchema,
|
|
311
|
+
NodeDataEventSchema,
|
|
312
|
+
NodeAddedEventSchema,
|
|
313
|
+
NodeRemovedEventSchema,
|
|
314
|
+
ControlPauseEventSchema,
|
|
315
|
+
ControlResumeEventSchema,
|
|
316
|
+
ControlStopEventSchema,
|
|
317
|
+
NodeInterruptEventSchema,
|
|
318
|
+
WorkflowAskUserEventSchema
|
|
319
|
+
]);
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
// src/env/workflow/types/run.ts
|
|
323
|
+
import { z as z5 } from "zod";
|
|
324
|
+
function createNodeExecutionContext(params) {
|
|
325
|
+
return {
|
|
326
|
+
...params,
|
|
327
|
+
askUser: (query) => {
|
|
328
|
+
throw new AskUserError(params.runId, params.sessionId, params.nodeId, "unknown", query);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
var RunStatusSchema, NodeStatusSchema;
|
|
333
|
+
var init_run = __esm(() => {
|
|
334
|
+
init_workflow_message();
|
|
335
|
+
RunStatusSchema = z5.enum([
|
|
336
|
+
"idle",
|
|
337
|
+
"running",
|
|
338
|
+
"paused",
|
|
339
|
+
"stopped",
|
|
340
|
+
"completed",
|
|
341
|
+
"failed"
|
|
342
|
+
]);
|
|
343
|
+
NodeStatusSchema = z5.enum([
|
|
344
|
+
"pending",
|
|
345
|
+
"scheduled",
|
|
346
|
+
"started",
|
|
347
|
+
"running",
|
|
348
|
+
"completed",
|
|
349
|
+
"failed",
|
|
350
|
+
"skipped"
|
|
351
|
+
]);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
// src/env/workflow/types/workflow-error.ts
|
|
355
|
+
import { z as z6 } from "zod";
|
|
356
|
+
function nodeNotFound(referencedNodeId, unresolved) {
|
|
357
|
+
return new TemplateUnresolvedError(`Referenced node not found: ${referencedNodeId}`, unresolved, { nodeId: referencedNodeId, reason: "node_not_found" });
|
|
358
|
+
}
|
|
359
|
+
function pathNotFound(referencedNodeId, path, template) {
|
|
360
|
+
return new TemplateUnresolvedError(`Path not found in node ${referencedNodeId}: ${path}`, [template], { nodeId: referencedNodeId, path, reason: "path_not_found" });
|
|
361
|
+
}
|
|
362
|
+
function unresolvedVariable(template, path) {
|
|
363
|
+
const context = { template, reason: "unresolved_variable" };
|
|
364
|
+
if (path) {
|
|
365
|
+
context.path = path;
|
|
366
|
+
}
|
|
367
|
+
return new TemplateUnresolvedError(`Unresolved variable: ${template}`, [template], context);
|
|
368
|
+
}
|
|
369
|
+
var WorkflowErrorContextSchema, WorkflowError, TemplateUnresolvedError, WorkflowValidationError;
|
|
370
|
+
var init_workflow_error = __esm(() => {
|
|
371
|
+
WorkflowErrorContextSchema = z6.record(z6.unknown());
|
|
372
|
+
WorkflowError = class WorkflowError extends Error {
|
|
373
|
+
context;
|
|
374
|
+
constructor(message, context = {}) {
|
|
375
|
+
super(message);
|
|
376
|
+
this.context = context;
|
|
377
|
+
Object.defineProperty(this, "name", {
|
|
378
|
+
value: this.constructor.name,
|
|
379
|
+
writable: true,
|
|
380
|
+
enumerable: false,
|
|
381
|
+
configurable: true
|
|
382
|
+
});
|
|
383
|
+
if (Error.captureStackTrace) {
|
|
384
|
+
Error.captureStackTrace(this, this.constructor);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
toJSON() {
|
|
388
|
+
return {
|
|
389
|
+
name: this.name,
|
|
390
|
+
message: this.message,
|
|
391
|
+
context: this.context,
|
|
392
|
+
stack: this.stack
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
TemplateUnresolvedError = class TemplateUnresolvedError extends WorkflowError {
|
|
397
|
+
unresolved;
|
|
398
|
+
constructor(message, unresolved = [], context = {}) {
|
|
399
|
+
super(message, context);
|
|
400
|
+
this.unresolved = unresolved;
|
|
401
|
+
}
|
|
402
|
+
toJSON() {
|
|
403
|
+
return {
|
|
404
|
+
...super.toJSON(),
|
|
405
|
+
unresolved: this.unresolved
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
WorkflowValidationError = class WorkflowValidationError extends WorkflowError {
|
|
410
|
+
field;
|
|
411
|
+
invalidValue;
|
|
412
|
+
constructor(message, field, invalidValue) {
|
|
413
|
+
super(message, { field });
|
|
414
|
+
this.field = field;
|
|
415
|
+
this.invalidValue = invalidValue;
|
|
416
|
+
}
|
|
417
|
+
toJSON() {
|
|
418
|
+
return {
|
|
419
|
+
...super.toJSON(),
|
|
420
|
+
field: this.field,
|
|
421
|
+
invalidValue: this.invalidValue
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
// src/env/workflow/types/index.ts
|
|
428
|
+
var init_types = __esm(() => {
|
|
429
|
+
init_run();
|
|
430
|
+
init_workflow_error();
|
|
431
|
+
init_edge();
|
|
432
|
+
init_workflow();
|
|
433
|
+
init_workflow_message();
|
|
434
|
+
init_workflow_session();
|
|
435
|
+
init_context();
|
|
436
|
+
init_workflow_hil();
|
|
437
|
+
init_event();
|
|
438
|
+
init_run();
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
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, EdgeDefinitionSchema, DependsOnSchema, RetryConfigSchema, NodeDefinitionSchema, WorkflowConfigSchema, OutputDefinitionSchema, InputParameterSchema, WorkflowInputsSchema, WorkflowMetadataSchema, WorkflowDefinitionSchema, parseWorkflowFile, parseWorkflowFileSync, WorkflowMessageRoleSchema, isWorkflowSessionMetadata, getWorkflowSessionStatus, RunStatusSchema, NodeStatusSchema, createNodeExecutionContext, WorkflowError, TemplateUnresolvedError, WorkflowValidationError, nodeNotFound, pathNotFound, unresolvedVariable, init_workflow_error, init_types };
|
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
} from "./roy-agent-core-q5qj0fes.js";
|
|
9
9
|
import {
|
|
10
10
|
BaseComponent
|
|
11
|
-
} from "./roy-agent-core-
|
|
11
|
+
} from "./roy-agent-core-6e3wz81d.js";
|
|
12
|
+
import {
|
|
13
|
+
init_context
|
|
14
|
+
} from "./roy-agent-core-rm3hay00.js";
|
|
12
15
|
import {
|
|
13
16
|
createLogger,
|
|
14
17
|
init_logger
|
|
@@ -421,4 +424,8 @@ class BaseEnvironment extends BaseComponent {
|
|
|
421
424
|
__legacyDecorateClassTS([
|
|
422
425
|
TracedAs("env.handle_query", { recordParams: true, recordResult: true, log: true })
|
|
423
426
|
], BaseEnvironment.prototype, "handle_query", null);
|
|
427
|
+
|
|
428
|
+
// src/env/index.ts
|
|
429
|
+
init_context();
|
|
430
|
+
|
|
424
431
|
export { generateId, generateDescendingId, BaseEnvironment };
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
getEnvContext
|
|
3
|
-
|
|
2
|
+
getEnvContext,
|
|
3
|
+
init_context
|
|
4
|
+
} from "./roy-agent-core-rm3hay00.js";
|
|
5
|
+
import {
|
|
6
|
+
__esm
|
|
7
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
4
8
|
|
|
5
9
|
// src/env/hook/hook-manager.ts
|
|
6
10
|
class HookManager {
|
|
@@ -163,45 +167,11 @@ class HookManager {
|
|
|
163
167
|
}
|
|
164
168
|
}
|
|
165
169
|
}
|
|
170
|
+
var init_hook_manager = __esm(() => {
|
|
171
|
+
init_context();
|
|
172
|
+
});
|
|
166
173
|
|
|
167
174
|
// src/env/hook/global-hook-manager.ts
|
|
168
|
-
var globalHookManager = new HookManager;
|
|
169
|
-
var AgentHookPoints = {
|
|
170
|
-
BEFORE_START: "agent:before.start",
|
|
171
|
-
BEFORE_LLM: "agent:before.llm",
|
|
172
|
-
AFTER_LLM: "agent:after.llm",
|
|
173
|
-
BEFORE_TOOL: "agent:before.tool",
|
|
174
|
-
AFTER_TOOL: "agent:after.tool",
|
|
175
|
-
ON_ITERATION: "agent:on.iteration",
|
|
176
|
-
ON_THRESHOLD: "agent:on.threshold",
|
|
177
|
-
AFTER_COMPLETE: "agent:after.complete",
|
|
178
|
-
ON_ERROR: "agent:on.error"
|
|
179
|
-
};
|
|
180
|
-
var LLMHookPoints = {
|
|
181
|
-
BEFORE_INVOKE: "llm:before.invoke",
|
|
182
|
-
AFTER_INVOKE: "llm:after.invoke",
|
|
183
|
-
ON_STREAM: "llm:on.stream"
|
|
184
|
-
};
|
|
185
|
-
var ToolHookPoints = {
|
|
186
|
-
BEFORE_EXECUTE: "tool:before.execute",
|
|
187
|
-
AFTER_EXECUTE: "tool:after.execute",
|
|
188
|
-
BEFORE_REGISTER: "tool:before.register",
|
|
189
|
-
AFTER_REGISTER: "tool:after.register",
|
|
190
|
-
ON_ERROR: "tool:on.error"
|
|
191
|
-
};
|
|
192
|
-
var hookPointAliases = {
|
|
193
|
-
"before.tool": "tool:before.execute",
|
|
194
|
-
"after.tool": "tool:after.execute",
|
|
195
|
-
"llm.before-invoke": "llm:before.invoke",
|
|
196
|
-
"llm.after-invoke": "llm:after.invoke",
|
|
197
|
-
"llm.stream": "llm:on.stream",
|
|
198
|
-
"prompt.before-render": "prompt:before.render",
|
|
199
|
-
"prompt.after-render": "prompt:after.render",
|
|
200
|
-
"prompt:before.render": "prompt.before-render",
|
|
201
|
-
"prompt:after.render": "prompt.after-render",
|
|
202
|
-
"prompt:after-render": "prompt.after-render",
|
|
203
|
-
"prompt:before-render": "prompt.before-render"
|
|
204
|
-
};
|
|
205
175
|
function setupAliasHooks() {
|
|
206
176
|
const originalRegister = globalHookManager.register.bind(globalHookManager);
|
|
207
177
|
globalHookManager.register = function(hookPoint, hook) {
|
|
@@ -212,7 +182,6 @@ function setupAliasHooks() {
|
|
|
212
182
|
}
|
|
213
183
|
};
|
|
214
184
|
}
|
|
215
|
-
setupAliasHooks();
|
|
216
185
|
async function executeAgentHook(hookPoint, data, metadata = {}) {
|
|
217
186
|
await globalHookManager.execute(hookPoint, data, metadata);
|
|
218
187
|
}
|
|
@@ -225,5 +194,47 @@ async function executeLLMHook(hookPoint, data, metadata = {}) {
|
|
|
225
194
|
async function executeToolHook(hookPoint, data, metadata = {}) {
|
|
226
195
|
await globalHookManager.execute(hookPoint, data, metadata);
|
|
227
196
|
}
|
|
197
|
+
var globalHookManager, AgentHookPoints, LLMHookPoints, ToolHookPoints, hookPointAliases;
|
|
198
|
+
var init_global_hook_manager = __esm(() => {
|
|
199
|
+
init_hook_manager();
|
|
200
|
+
globalHookManager = new HookManager;
|
|
201
|
+
AgentHookPoints = {
|
|
202
|
+
BEFORE_START: "agent:before.start",
|
|
203
|
+
BEFORE_LLM: "agent:before.llm",
|
|
204
|
+
AFTER_LLM: "agent:after.llm",
|
|
205
|
+
BEFORE_TOOL: "agent:before.tool",
|
|
206
|
+
AFTER_TOOL: "agent:after.tool",
|
|
207
|
+
ON_ITERATION: "agent:on.iteration",
|
|
208
|
+
ON_THRESHOLD: "agent:on.threshold",
|
|
209
|
+
AFTER_COMPLETE: "agent:after.complete",
|
|
210
|
+
ON_ERROR: "agent:on.error"
|
|
211
|
+
};
|
|
212
|
+
LLMHookPoints = {
|
|
213
|
+
BEFORE_INVOKE: "llm:before.invoke",
|
|
214
|
+
AFTER_INVOKE: "llm:after.invoke",
|
|
215
|
+
ON_STREAM: "llm:on.stream"
|
|
216
|
+
};
|
|
217
|
+
ToolHookPoints = {
|
|
218
|
+
BEFORE_EXECUTE: "tool:before.execute",
|
|
219
|
+
AFTER_EXECUTE: "tool:after.execute",
|
|
220
|
+
BEFORE_REGISTER: "tool:before.register",
|
|
221
|
+
AFTER_REGISTER: "tool:after.register",
|
|
222
|
+
ON_ERROR: "tool:on.error"
|
|
223
|
+
};
|
|
224
|
+
hookPointAliases = {
|
|
225
|
+
"before.tool": "tool:before.execute",
|
|
226
|
+
"after.tool": "tool:after.execute",
|
|
227
|
+
"llm.before-invoke": "llm:before.invoke",
|
|
228
|
+
"llm.after-invoke": "llm:after.invoke",
|
|
229
|
+
"llm.stream": "llm:on.stream",
|
|
230
|
+
"prompt.before-render": "prompt:before.render",
|
|
231
|
+
"prompt.after-render": "prompt:after.render",
|
|
232
|
+
"prompt:before.render": "prompt.before-render",
|
|
233
|
+
"prompt:after.render": "prompt.after-render",
|
|
234
|
+
"prompt:after-render": "prompt.after-render",
|
|
235
|
+
"prompt:before-render": "prompt.before-render"
|
|
236
|
+
};
|
|
237
|
+
setupAliasHooks();
|
|
238
|
+
});
|
|
228
239
|
|
|
229
|
-
export { HookManager, globalHookManager, AgentHookPoints, LLMHookPoints, ToolHookPoints, executeAgentHook, executeAgentHookWithIntervention, executeLLMHook, executeToolHook };
|
|
240
|
+
export { HookManager, init_hook_manager, globalHookManager, AgentHookPoints, LLMHookPoints, ToolHookPoints, executeAgentHook, executeAgentHookWithIntervention, executeLLMHook, executeToolHook, init_global_hook_manager };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__esm
|
|
3
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
4
|
+
|
|
1
5
|
// src/env/context/env-context.ts
|
|
2
6
|
import { AsyncLocalStorage } from "async_hooks";
|
|
3
|
-
var envContextStorage = new AsyncLocalStorage;
|
|
4
7
|
function getEnvContext() {
|
|
5
8
|
return envContextStorage.getStore();
|
|
6
9
|
}
|
|
@@ -41,4 +44,14 @@ function mergeEnvContext(partial) {
|
|
|
41
44
|
Object.assign(current, partial);
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
|
-
|
|
47
|
+
var envContextStorage;
|
|
48
|
+
var init_env_context = __esm(() => {
|
|
49
|
+
envContextStorage = new AsyncLocalStorage;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// src/env/context/index.ts
|
|
53
|
+
var init_context = __esm(() => {
|
|
54
|
+
init_env_context();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export { envContextStorage, getEnvContext, getEnvContextOrEmpty, hasEnvContext, runWithEnvContext, runWithEnvContextAsync, createEnvContext, mergeEnvContext, init_context };
|
|
@@ -8,11 +8,12 @@ import {
|
|
|
8
8
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
9
9
|
import {
|
|
10
10
|
BaseComponent
|
|
11
|
-
} from "./roy-agent-core-
|
|
11
|
+
} from "./roy-agent-core-6e3wz81d.js";
|
|
12
12
|
import {
|
|
13
13
|
ToolHookPoints,
|
|
14
|
-
globalHookManager
|
|
15
|
-
|
|
14
|
+
globalHookManager,
|
|
15
|
+
init_global_hook_manager
|
|
16
|
+
} from "./roy-agent-core-rgj6hq15.js";
|
|
16
17
|
import {
|
|
17
18
|
createLogger,
|
|
18
19
|
init_logger
|
|
@@ -140,6 +141,7 @@ class ToolValidator {
|
|
|
140
141
|
|
|
141
142
|
// src/env/tool/tool-component.ts
|
|
142
143
|
init_logger();
|
|
144
|
+
init_global_hook_manager();
|
|
143
145
|
|
|
144
146
|
// src/env/tool/tool-config-registration.ts
|
|
145
147
|
var TOOL_DEFAULTS = {
|