@ai-setting/roy-agent-core 1.5.43 → 1.5.44

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.
Files changed (24) hide show
  1. package/dist/env/index.js +7 -6
  2. package/dist/env/tool/built-in/index.js +1 -1
  3. package/dist/env/tool/index.js +2 -2
  4. package/dist/env/workflow/decorators/index.js +1 -1
  5. package/dist/env/workflow/engine/index.js +4 -3
  6. package/dist/env/workflow/index.js +34 -19
  7. package/dist/env/workflow/nodes/index.js +5 -1
  8. package/dist/env/workflow/types/index.js +16 -2
  9. package/dist/env/workflow/utils/index.js +15 -196
  10. package/dist/index.js +9 -8
  11. package/dist/shared/@ai-setting/{roy-agent-core-ffb9fq4v.js → roy-agent-core-23gw9c4s.js} +2 -2
  12. package/dist/shared/@ai-setting/{roy-agent-core-bmr6bdfb.js → roy-agent-core-2ms7296b.js} +4 -4
  13. package/dist/shared/@ai-setting/{roy-agent-core-2jnzv9at.js → roy-agent-core-38dkek2y.js} +319 -189
  14. package/dist/shared/@ai-setting/roy-agent-core-6vxg2gmr.js +321 -0
  15. package/dist/shared/@ai-setting/{roy-agent-core-0rtxwr28.js → roy-agent-core-9bmtxmp6.js} +77 -120
  16. package/dist/shared/@ai-setting/{roy-agent-core-7fgf85wc.js → roy-agent-core-h0x19xgn.js} +6 -7
  17. package/dist/shared/@ai-setting/roy-agent-core-qnrf2aw6.js +441 -0
  18. package/dist/shared/@ai-setting/roy-agent-core-v002ynpa.js +435 -0
  19. package/dist/shared/@ai-setting/{roy-agent-core-rsybkb38.js → roy-agent-core-ysvh8er9.js} +36 -39
  20. package/dist/shared/@ai-setting/{roy-agent-core-9yxb3ty9.js → roy-agent-core-z5sxe4p7.js} +5 -1
  21. package/package.json +1 -1
  22. package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
  23. package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
  24. /package/dist/shared/@ai-setting/{roy-agent-core-e130w7mv.js → roy-agent-core-ryw3ckfy.js} +0 -0
@@ -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 };