@ai-setting/roy-agent-core 1.5.14-test → 1.5.15-test
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/package.json +1 -1
- package/dist/config/index.d.ts +0 -1250
- package/dist/config/index.js +0 -32
- package/dist/env/agent/index.d.ts +0 -2279
- package/dist/env/agent/index.js +0 -24
- package/dist/env/commands/index.d.ts +0 -1131
- package/dist/env/commands/index.js +0 -14
- package/dist/env/debug/formatters/index.d.ts +0 -236
- package/dist/env/debug/formatters/index.js +0 -11
- package/dist/env/debug/index.d.ts +0 -1652
- package/dist/env/debug/index.js +0 -26
- package/dist/env/hook/index.d.ts +0 -279
- package/dist/env/hook/index.js +0 -29
- package/dist/env/index.d.ts +0 -3481
- package/dist/env/index.js +0 -82
- package/dist/env/llm/index.d.ts +0 -1760
- package/dist/env/llm/index.js +0 -40
- package/dist/env/log-trace/index.d.ts +0 -1574
- package/dist/env/log-trace/index.js +0 -83
- package/dist/env/mcp/index.d.ts +0 -1331
- package/dist/env/mcp/index.js +0 -39
- package/dist/env/mcp/tool/index.d.ts +0 -183
- package/dist/env/mcp/tool/index.js +0 -14
- package/dist/env/memory/built-in/index.d.ts +0 -232
- package/dist/env/memory/built-in/index.js +0 -11
- package/dist/env/memory/index.d.ts +0 -1799
- package/dist/env/memory/index.js +0 -56
- package/dist/env/memory/plugin/index.d.ts +0 -747
- package/dist/env/memory/plugin/index.js +0 -36
- package/dist/env/prompt/index.d.ts +0 -1164
- package/dist/env/prompt/index.js +0 -20
- package/dist/env/session/index.d.ts +0 -1908
- package/dist/env/session/index.js +0 -25
- package/dist/env/session/storage/index.d.ts +0 -564
- package/dist/env/session/storage/index.js +0 -18
- package/dist/env/skill/index.d.ts +0 -1266
- package/dist/env/skill/index.js +0 -34
- package/dist/env/skill/tool/index.d.ts +0 -193
- package/dist/env/skill/tool/index.js +0 -9
- package/dist/env/task/delegate/index.d.ts +0 -1612
- package/dist/env/task/delegate/index.js +0 -18
- package/dist/env/task/events/index.d.ts +0 -171
- package/dist/env/task/events/index.js +0 -7
- package/dist/env/task/hooks/index.d.ts +0 -624
- package/dist/env/task/hooks/index.js +0 -7
- package/dist/env/task/index.d.ts +0 -1553
- package/dist/env/task/index.js +0 -34
- package/dist/env/task/plugins/index.d.ts +0 -466
- package/dist/env/task/plugins/index.js +0 -23
- package/dist/env/task/storage/index.d.ts +0 -241
- package/dist/env/task/storage/index.js +0 -14
- package/dist/env/task/tools/index.d.ts +0 -1485
- package/dist/env/task/tools/index.js +0 -17
- package/dist/env/task/tools/operation/index.d.ts +0 -1484
- package/dist/env/task/tools/operation/index.js +0 -15
- package/dist/env/tool/built-in/index.d.ts +0 -218
- package/dist/env/tool/built-in/index.js +0 -25
- package/dist/env/tool/index.d.ts +0 -1396
- package/dist/env/tool/index.js +0 -39
- package/dist/env/workflow/decorators/index.d.ts +0 -2161
- package/dist/env/workflow/decorators/index.js +0 -27
- package/dist/env/workflow/engine/index.d.ts +0 -3453
- package/dist/env/workflow/engine/index.js +0 -28
- package/dist/env/workflow/index.d.ts +0 -3546
- package/dist/env/workflow/index.js +0 -136
- package/dist/env/workflow/nodes/index.d.ts +0 -2092
- package/dist/env/workflow/nodes/index.js +0 -19
- package/dist/env/workflow/service/index.d.ts +0 -227
- package/dist/env/workflow/service/index.js +0 -13
- package/dist/env/workflow/storage/index.d.ts +0 -165
- package/dist/env/workflow/storage/index.js +0 -27
- package/dist/env/workflow/tools/index.d.ts +0 -416
- package/dist/env/workflow/tools/index.js +0 -159
- package/dist/env/workflow/types/index.d.ts +0 -2255
- package/dist/env/workflow/types/index.js +0 -98
- package/dist/env/workflow/utils/index.d.ts +0 -2031
- package/dist/env/workflow/utils/index.js +0 -637
- package/dist/index.d.ts +0 -7858
- package/dist/index.js +0 -399
- package/dist/shared/@ai-setting/roy-agent-core-0rtxwr28.js +0 -258
- package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +0 -36
- package/dist/shared/@ai-setting/roy-agent-core-1akcqxj9.js +0 -349
- package/dist/shared/@ai-setting/roy-agent-core-1ce3fqrk.js +0 -117
- package/dist/shared/@ai-setting/roy-agent-core-2dhd60aw.js +0 -11
- package/dist/shared/@ai-setting/roy-agent-core-3jywqmdd.js +0 -393
- package/dist/shared/@ai-setting/roy-agent-core-3rr5k71j.js +0 -200
- package/dist/shared/@ai-setting/roy-agent-core-44hnfb02.js +0 -299
- package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +0 -206
- package/dist/shared/@ai-setting/roy-agent-core-4txzpsbt.js +0 -393
- package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
- package/dist/shared/@ai-setting/roy-agent-core-69jskqjg.js +0 -180
- package/dist/shared/@ai-setting/roy-agent-core-6kvtahqv.js +0 -408
- package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +0 -284
- package/dist/shared/@ai-setting/roy-agent-core-81w1963m.js +0 -762
- package/dist/shared/@ai-setting/roy-agent-core-8gxth0eh.js +0 -10
- package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +0 -14
- package/dist/shared/@ai-setting/roy-agent-core-93zfb3r1.js +0 -922
- package/dist/shared/@ai-setting/roy-agent-core-9yxb3ty9.js +0 -15
- package/dist/shared/@ai-setting/roy-agent-core-b0x5dda6.js +0 -1130
- package/dist/shared/@ai-setting/roy-agent-core-bcbqy27c.js +0 -14
- package/dist/shared/@ai-setting/roy-agent-core-bvr1761x.js +0 -653
- package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +0 -93
- package/dist/shared/@ai-setting/roy-agent-core-d7cyjkf7.js +0 -872
- package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +0 -11
- package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +0 -64
- package/dist/shared/@ai-setting/roy-agent-core-eajcvp4e.js +0 -378
- package/dist/shared/@ai-setting/roy-agent-core-f7q2x5z6.js +0 -492
- package/dist/shared/@ai-setting/roy-agent-core-fs0mn2jk.js +0 -52
- package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +0 -171
- package/dist/shared/@ai-setting/roy-agent-core-g99pxzn5.js +0 -862
- package/dist/shared/@ai-setting/roy-agent-core-gbqcyegm.js +0 -1387
- package/dist/shared/@ai-setting/roy-agent-core-gjq1yk68.js +0 -208
- package/dist/shared/@ai-setting/roy-agent-core-gq20wsgv.js +0 -139
- package/dist/shared/@ai-setting/roy-agent-core-gwc4h96n.js +0 -534
- package/dist/shared/@ai-setting/roy-agent-core-jfh9q2qh.js +0 -204
- package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
- package/dist/shared/@ai-setting/roy-agent-core-kkbwepqb.js +0 -97
- package/dist/shared/@ai-setting/roy-agent-core-pjr12nnd.js +0 -587
- package/dist/shared/@ai-setting/roy-agent-core-psv4v63c.js +0 -176
- package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +0 -60
- package/dist/shared/@ai-setting/roy-agent-core-qqceba6k.js +0 -442
- package/dist/shared/@ai-setting/roy-agent-core-qxhq8ven.js +0 -57
- package/dist/shared/@ai-setting/roy-agent-core-qxnbvgwe.js +0 -66
- package/dist/shared/@ai-setting/roy-agent-core-r9ezzemr.js +0 -10
- package/dist/shared/@ai-setting/roy-agent-core-rhmtwnw1.js +0 -267
- package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +0 -584
- package/dist/shared/@ai-setting/roy-agent-core-rvxg1wps.js +0 -102
- package/dist/shared/@ai-setting/roy-agent-core-satmq6sh.js +0 -549
- package/dist/shared/@ai-setting/roy-agent-core-sx7wsvnn.js +0 -15
- package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +0 -213
- package/dist/shared/@ai-setting/roy-agent-core-vf215qfv.js +0 -812
- package/dist/shared/@ai-setting/roy-agent-core-vkz81f7v.js +0 -1316
- package/dist/shared/@ai-setting/roy-agent-core-vn2bc59q.js +0 -1205
- package/dist/shared/@ai-setting/roy-agent-core-wa1kzqky.js +0 -328
- package/dist/shared/@ai-setting/roy-agent-core-wft9ra24.js +0 -20
- package/dist/shared/@ai-setting/roy-agent-core-wrcy0h6z.js +0 -2098
- package/dist/shared/@ai-setting/roy-agent-core-xq8hhqb8.js +0 -419
- package/dist/shared/@ai-setting/roy-agent-core-xs5rsgat.js +0 -368
- package/dist/shared/@ai-setting/roy-agent-core-zbkpc41z.js +0 -377
- package/dist/shared/@ai-setting/roy-agent-core-zgypchmt.js +0 -172
- package/dist/shared/@ai-setting/roy-agent-core-zpn0bqa8.js +0 -103
|
@@ -1,350 +0,0 @@
|
|
|
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 };
|
|
@@ -1,180 +0,0 @@
|
|
|
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 };
|