@ai-setting/roy-agent-core 1.7.49 → 1.7.51

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 (87) hide show
  1. package/dist/config/index.js +7 -7
  2. package/dist/env/agent/index.js +10 -10
  3. package/dist/env/commands/index.js +7 -7
  4. package/dist/env/context/index.js +3 -3
  5. package/dist/env/debug/index.js +7 -7
  6. package/dist/env/event-source/index.js +17 -14
  7. package/dist/env/hook/index.js +9 -6
  8. package/dist/env/index.js +38 -34
  9. package/dist/env/llm/index.js +7 -7
  10. package/dist/env/log-trace/index.js +7 -7
  11. package/dist/env/mcp/index.js +7 -7
  12. package/dist/env/memory/index.js +11 -11
  13. package/dist/env/plugin/index.js +7 -7
  14. package/dist/env/prompt/index.js +8 -8
  15. package/dist/env/session/index.js +7 -7
  16. package/dist/env/skill/index.js +7 -7
  17. package/dist/env/task/delegate/index.js +8 -8
  18. package/dist/env/task/index.js +17 -17
  19. package/dist/env/task/plugins/index.js +10 -9
  20. package/dist/env/task/storage/index.js +2 -2
  21. package/dist/env/task/tools/index.js +3 -3
  22. package/dist/env/tool/built-in/index.js +2 -2
  23. package/dist/env/tool/index.js +8 -8
  24. package/dist/env/workflow/engine/index.js +12 -9
  25. package/dist/env/workflow/hooks/index.js +25 -0
  26. package/dist/env/workflow/index.js +19 -17
  27. package/dist/env/workflow/nodes/index.js +2 -2
  28. package/dist/env/workflow/plugins/index.js +18 -0
  29. package/dist/env/workflow/service/index.js +2 -2
  30. package/dist/env/workflow/storage/index.js +3 -3
  31. package/dist/env/workflow/tools/index.js +11 -11
  32. package/dist/env/workflow/utils/index.js +24 -4
  33. package/dist/index.js +79 -70
  34. package/dist/shared/@ai-setting/{roy-agent-core-3ajh3cdj.js → roy-agent-core-0cfaqnz9.js} +1 -1
  35. package/dist/shared/@ai-setting/{roy-agent-core-trd6my5j.js → roy-agent-core-1cv9j4dg.js} +3 -3
  36. package/dist/shared/@ai-setting/{roy-agent-core-48f17g3x.js → roy-agent-core-2gay3sjt.js} +1 -1
  37. package/dist/shared/@ai-setting/{roy-agent-core-e302nvzt.js → roy-agent-core-2k4xffaa.js} +3 -3
  38. package/dist/shared/@ai-setting/{roy-agent-core-1pjct4nj.js → roy-agent-core-35s1w7tc.js} +230 -96
  39. package/dist/shared/@ai-setting/{roy-agent-core-hqtp5m8v.js → roy-agent-core-39xejr39.js} +13 -13
  40. package/dist/shared/@ai-setting/{roy-agent-core-v6zdngr7.js → roy-agent-core-3tv1q6f2.js} +8 -8
  41. package/dist/shared/@ai-setting/{roy-agent-core-mqaht7mm.js → roy-agent-core-4z3rq5gw.js} +2 -2
  42. package/dist/shared/@ai-setting/{roy-agent-core-fm77q3tn.js → roy-agent-core-5apmk4qw.js} +1 -1
  43. package/dist/shared/@ai-setting/{roy-agent-core-xmfyt3dg.js → roy-agent-core-6167phd4.js} +2 -2
  44. package/dist/shared/@ai-setting/{roy-agent-core-wt37tszm.js → roy-agent-core-7evvpfwc.js} +1 -1
  45. package/dist/shared/@ai-setting/{roy-agent-core-azdsyhvx.js → roy-agent-core-7g03zkkb.js} +1 -1
  46. package/dist/shared/@ai-setting/{roy-agent-core-v2d0bt7e.js → roy-agent-core-8s9jd2qy.js} +1 -1
  47. package/dist/shared/@ai-setting/{roy-agent-core-8pqq9yjt.js → roy-agent-core-978b6wfx.js} +1 -1
  48. package/dist/shared/@ai-setting/roy-agent-core-9csa89jx.js +46 -0
  49. package/dist/shared/@ai-setting/{roy-agent-core-x8ebdrtn.js → roy-agent-core-9faekt5n.js} +9 -5
  50. package/dist/shared/@ai-setting/{roy-agent-core-cnsjr3ws.js → roy-agent-core-9jzysq50.js} +2 -2
  51. package/dist/shared/@ai-setting/{roy-agent-core-5ja22qkf.js → roy-agent-core-ak4dc3kg.js} +1 -1
  52. package/dist/shared/@ai-setting/{roy-agent-core-ncaqkyfj.js → roy-agent-core-athdr2m0.js} +1 -1
  53. package/dist/shared/@ai-setting/{roy-agent-core-bt6h398s.js → roy-agent-core-dsevjbck.js} +20 -7
  54. package/dist/shared/@ai-setting/{roy-agent-core-5hjtbvxf.js → roy-agent-core-dv714bqh.js} +1 -1
  55. package/dist/shared/@ai-setting/{roy-agent-core-k0mx0tkh.js → roy-agent-core-dwx9hjwx.js} +1 -1
  56. package/dist/shared/@ai-setting/roy-agent-core-fs36xgcs.js +13 -0
  57. package/dist/shared/@ai-setting/{roy-agent-core-ydwtpzyf.js → roy-agent-core-fvs48d38.js} +4 -4
  58. package/dist/shared/@ai-setting/{roy-agent-core-223v204d.js → roy-agent-core-gdsqp6j8.js} +139 -15
  59. package/dist/shared/@ai-setting/{roy-agent-core-emjpkx9s.js → roy-agent-core-k8b440n3.js} +1 -1
  60. package/dist/shared/@ai-setting/{roy-agent-core-5vf48m39.js → roy-agent-core-kyasfzeh.js} +75 -754
  61. package/dist/shared/@ai-setting/roy-agent-core-na73mym1.js +367 -0
  62. package/dist/shared/@ai-setting/{roy-agent-core-j783tcqb.js → roy-agent-core-nde5gzta.js} +1 -1
  63. package/dist/shared/@ai-setting/{roy-agent-core-e2569ptp.js → roy-agent-core-ne2t1pay.js} +2 -2
  64. package/dist/shared/@ai-setting/{roy-agent-core-k0sy76cw.js → roy-agent-core-p2r27era.js} +17 -13
  65. package/dist/shared/@ai-setting/{roy-agent-core-xvf97xs4.js → roy-agent-core-p8ak03s0.js} +3 -3
  66. package/dist/shared/@ai-setting/{roy-agent-core-56j2q0w6.js → roy-agent-core-qamktze3.js} +1 -1
  67. package/dist/shared/@ai-setting/{roy-agent-core-khx0h4j2.js → roy-agent-core-qcspfszy.js} +11 -4
  68. package/dist/shared/@ai-setting/{roy-agent-core-rqyxdrxg.js → roy-agent-core-qm9jda8p.js} +1 -1
  69. package/dist/shared/@ai-setting/{roy-agent-core-yq45m8mm.js → roy-agent-core-rnwr39b0.js} +2 -2
  70. package/dist/shared/@ai-setting/{roy-agent-core-ed4tbkyj.js → roy-agent-core-rx16h2m1.js} +7 -3
  71. package/dist/shared/@ai-setting/{roy-agent-core-sea232w4.js → roy-agent-core-s214vmmd.js} +13 -13
  72. package/dist/shared/@ai-setting/{roy-agent-core-ecb8am8s.js → roy-agent-core-skzjs973.js} +5 -5
  73. package/dist/shared/@ai-setting/{roy-agent-core-zc9k2n3c.js → roy-agent-core-stnddvx9.js} +4 -4
  74. package/dist/shared/@ai-setting/{roy-agent-core-f51kwn6m.js → roy-agent-core-t37wbysj.js} +4 -4
  75. package/dist/shared/@ai-setting/{roy-agent-core-xn12d221.js → roy-agent-core-tdbv7ff4.js} +5 -3
  76. package/dist/shared/@ai-setting/{roy-agent-core-yes3mr8n.js → roy-agent-core-tjg71zqp.js} +1 -1
  77. package/dist/shared/@ai-setting/{roy-agent-core-yge38dkn.js → roy-agent-core-vrsxhw9e.js} +1 -1
  78. package/dist/shared/@ai-setting/{roy-agent-core-kazn764f.js → roy-agent-core-vvxb9522.js} +20 -7
  79. package/dist/shared/@ai-setting/{roy-agent-core-vrj9c5y6.js → roy-agent-core-wwytg8rv.js} +14 -7
  80. package/dist/shared/@ai-setting/roy-agent-core-wxsgay02.js +302 -0
  81. package/dist/shared/@ai-setting/{roy-agent-core-c0mnxxck.js → roy-agent-core-x8n1r7h4.js} +1 -1
  82. package/dist/shared/@ai-setting/{roy-agent-core-m9drr1fd.js → roy-agent-core-yd21n6c7.js} +2 -2
  83. package/dist/shared/@ai-setting/{roy-agent-core-zff8vvs5.js → roy-agent-core-yhsssn86.js} +1 -1
  84. package/dist/shared/@ai-setting/roy-agent-core-zd077w51.js +1037 -0
  85. package/dist/shared/@ai-setting/{roy-agent-core-2bbj3jqd.js → roy-agent-core-zd3ddm4k.js} +1 -1
  86. package/package.json +1 -1
  87. package/dist/shared/@ai-setting/roy-agent-core-98wwn2px.js +0 -35
@@ -0,0 +1,367 @@
1
+ import {
2
+ DAGManager,
3
+ init_dag_manager
4
+ } from "./roy-agent-core-8s9jd2qy.js";
5
+
6
+ // src/env/workflow/utils/node-output-contracts.ts
7
+ var VIRTUAL_OUTPUT_FIELD = "output";
8
+ var NODE_OUTPUT_CONTRACTS = {
9
+ tool: {
10
+ fields: [],
11
+ closed: true,
12
+ description: "a tool node's stored value is its result (usually a string)",
13
+ suggestedField: VIRTUAL_OUTPUT_FIELD
14
+ },
15
+ python_call: {
16
+ fields: [],
17
+ closed: true,
18
+ description: "a pythonCall node's stored value is its JSON-parsed stdout",
19
+ suggestedField: VIRTUAL_OUTPUT_FIELD
20
+ },
21
+ pythonCall: {
22
+ fields: [],
23
+ closed: true,
24
+ description: "a pythonCall node's stored value is its JSON-parsed stdout",
25
+ suggestedField: VIRTUAL_OUTPUT_FIELD
26
+ },
27
+ skill: {
28
+ fields: [],
29
+ closed: true,
30
+ description: "a skill node's stored value is the skill's return value",
31
+ suggestedField: VIRTUAL_OUTPUT_FIELD
32
+ },
33
+ condition: {
34
+ fields: ["success", "condition"],
35
+ closed: true,
36
+ description: "a condition node's stored value is { success, condition }",
37
+ suggestedField: VIRTUAL_OUTPUT_FIELD,
38
+ canonicalField: "condition"
39
+ },
40
+ merge: {
41
+ fields: ["strategy", "results", "count"],
42
+ closed: true,
43
+ description: "a merge node's stored value is { strategy, results, count }",
44
+ suggestedField: VIRTUAL_OUTPUT_FIELD,
45
+ canonicalField: "results"
46
+ },
47
+ agent: {
48
+ fields: ["result", "metadata", "workflowHistory"],
49
+ canonicalField: "result",
50
+ closed: false,
51
+ description: "an agent node's stored value is { result, metadata, workflowHistory, ...<json output fields> }",
52
+ suggestedField: "result"
53
+ },
54
+ workflow: {
55
+ fields: ["result"],
56
+ closed: false,
57
+ description: "a workflow node's stored value is the child workflow's top-level output",
58
+ suggestedField: VIRTUAL_OUTPUT_FIELD
59
+ },
60
+ ask_user: {
61
+ fields: [],
62
+ closed: true,
63
+ description: "an askUser node never produces output (it always pauses)"
64
+ },
65
+ askUser: {
66
+ fields: [],
67
+ closed: true,
68
+ description: "an askUser node never produces output (it always pauses)"
69
+ }
70
+ };
71
+ function getNodeOutputContract(nodeType) {
72
+ return NODE_OUTPUT_CONTRACTS[nodeType] ?? {
73
+ fields: [],
74
+ closed: false,
75
+ description: `unknown node type "${nodeType}" (output shape unknown)`
76
+ };
77
+ }
78
+ function getSuggestionFieldForResultMisuse(nodeType) {
79
+ const contract = getNodeOutputContract(nodeType);
80
+ return contract.canonicalField ?? contract.suggestedField ?? VIRTUAL_OUTPUT_FIELD;
81
+ }
82
+ function hasClosedOutputContract(nodeType) {
83
+ return getNodeOutputContract(nodeType).closed;
84
+ }
85
+ var RESULT_INVALID_NODE_TYPES = new Set([
86
+ "tool",
87
+ "python_call",
88
+ "pythonCall",
89
+ "skill",
90
+ "condition",
91
+ "merge",
92
+ "ask_user",
93
+ "askUser"
94
+ ]);
95
+ function getAgentDeclaredJsonFields(config) {
96
+ const output = config?.output;
97
+ const properties = output?.schema?.properties;
98
+ if (!properties || typeof properties !== "object")
99
+ return;
100
+ const keys = Object.keys(properties);
101
+ return keys.length > 0 ? keys : undefined;
102
+ }
103
+
104
+ // src/env/workflow/utils/template-contract-validator.ts
105
+ var TEMPLATE_RE = /\{\{\s*([^{}]+?)\s*\}\}/g;
106
+ var PURE_PATH_RE = /^[A-Za-z_][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+|\[-?\d+\])*$/;
107
+ var NON_NODE_SCOPES = new Set(["input", "inputs", "config", "env", "workflow", "vars", "secrets"]);
108
+ function isPurePath(body) {
109
+ return PURE_PATH_RE.test(body);
110
+ }
111
+ function walkStrings(value, visit) {
112
+ if (typeof value === "string") {
113
+ visit(value);
114
+ return;
115
+ }
116
+ if (Array.isArray(value)) {
117
+ for (const item of value)
118
+ walkStrings(item, visit);
119
+ return;
120
+ }
121
+ if (value && typeof value === "object") {
122
+ for (const v of Object.values(value))
123
+ walkStrings(v, visit);
124
+ }
125
+ }
126
+ function extractNodeRefs(config) {
127
+ const refs = [];
128
+ walkStrings(config, (s) => {
129
+ TEMPLATE_RE.lastIndex = 0;
130
+ let m;
131
+ while ((m = TEMPLATE_RE.exec(s)) !== null) {
132
+ const raw = m[0];
133
+ const body = m[1].split("|")[0].trim();
134
+ if (!body || /\s/.test(body) || !isPurePath(body))
135
+ continue;
136
+ if (body.startsWith("#") || body.startsWith("/"))
137
+ continue;
138
+ const parts = body.split(".");
139
+ let sourceNodeId;
140
+ let rest;
141
+ if (parts[0] === "nodes") {
142
+ if (parts.length < 2)
143
+ continue;
144
+ sourceNodeId = parts[1];
145
+ rest = parts.slice(2);
146
+ } else {
147
+ sourceNodeId = parts[0];
148
+ rest = parts.slice(1);
149
+ }
150
+ if (!sourceNodeId)
151
+ continue;
152
+ if (NON_NODE_SCOPES.has(sourceNodeId))
153
+ continue;
154
+ refs.push({ template: raw, sourceNodeId, rest });
155
+ }
156
+ });
157
+ return refs;
158
+ }
159
+ function baseSegment(seg) {
160
+ if (!seg)
161
+ return "";
162
+ return seg.replace(/\[-?\d+\]$/, "");
163
+ }
164
+ function buildGraph(nodes, edges) {
165
+ const byId = new Map;
166
+ const direct = new Map;
167
+ for (const n of nodes) {
168
+ if (!n || typeof n !== "object" || typeof n.id !== "string" || !n.id)
169
+ continue;
170
+ byId.set(n.id, n);
171
+ const deps = Array.isArray(n.depends_on) ? n.depends_on.filter((d) => typeof d === "string") : [];
172
+ direct.set(n.id, [...deps]);
173
+ }
174
+ for (const e of Array.isArray(edges) ? edges : []) {
175
+ if (!e || typeof e.from !== "string" || typeof e.to !== "string")
176
+ continue;
177
+ const to = direct.get(e.to);
178
+ if (!to)
179
+ continue;
180
+ if (!to.includes(e.from))
181
+ to.push(e.from);
182
+ }
183
+ const upstream = new Map;
184
+ for (const id of byId.keys()) {
185
+ const seen = new Set;
186
+ const stack = [...direct.get(id) ?? []];
187
+ while (stack.length > 0) {
188
+ const d = stack.pop();
189
+ if (seen.has(d))
190
+ continue;
191
+ seen.add(d);
192
+ for (const dd of direct.get(d) ?? [])
193
+ stack.push(dd);
194
+ }
195
+ upstream.set(id, seen);
196
+ }
197
+ return { byId, upstream };
198
+ }
199
+ function validateTemplateContracts(definition) {
200
+ if (!definition || typeof definition !== "object")
201
+ return [];
202
+ const def = definition;
203
+ if (!Array.isArray(def.nodes))
204
+ return [];
205
+ const nodes = def.nodes;
206
+ const { byId, upstream } = buildGraph(nodes, Array.isArray(def.edges) ? def.edges : []);
207
+ const findings = [];
208
+ for (const node of nodes) {
209
+ if (!node || typeof node !== "object" || typeof node.id !== "string" || !node.id)
210
+ continue;
211
+ const nodeId = node.id;
212
+ const refs = extractNodeRefs(node.config);
213
+ const upOfNode = upstream.get(nodeId) ?? new Set;
214
+ for (const ref of refs) {
215
+ const { template, sourceNodeId, rest } = ref;
216
+ const src = byId.get(sourceNodeId);
217
+ if (!src) {
218
+ findings.push({
219
+ severity: "error",
220
+ rule: "R1-node-not-found",
221
+ nodeId,
222
+ template,
223
+ sourceNodeId,
224
+ message: `Node "${nodeId}" references "${template}", but no node with id ` + `"${sourceNodeId}" exists in this workflow.`,
225
+ suggestion: `Remove the reference, or add a node with id "${sourceNodeId}".`
226
+ });
227
+ continue;
228
+ }
229
+ const srcType = src.type;
230
+ const contract = getNodeOutputContract(srcType);
231
+ const allowed = new Set([VIRTUAL_OUTPUT_FIELD, ...contract.fields]);
232
+ const first = baseSegment(rest[0]);
233
+ if (first === "result" && RESULT_INVALID_NODE_TYPES.has(srcType)) {
234
+ const suggestedField = getSuggestionFieldForResultMisuse(srcType);
235
+ const fixed = template.replace(new RegExp(`(nodes\\.${escapeRegExp(sourceNodeId)}|^\\{\\{${escapeRegExp(sourceNodeId)})\\.result`), `$1.${suggestedField}`);
236
+ findings.push({
237
+ severity: "error",
238
+ rule: "R2-result-on-non-agent",
239
+ nodeId,
240
+ template,
241
+ sourceNodeId,
242
+ sourceNodeType: srcType,
243
+ message: `Node "${nodeId}" references "${template}", but "${sourceNodeId}" is a ` + `"${srcType}" node — ${contract.description}. The ".result" field only ` + `exists on agent nodes; the value will silently resolve to an empty ` + `string at runtime. Use ".output" instead.`,
244
+ suggestion: fixed !== template ? fixed : undefined
245
+ });
246
+ continue;
247
+ }
248
+ if (first && contract.closed && !allowed.has(first)) {
249
+ findings.push({
250
+ severity: "warning",
251
+ rule: "R3-unknown-field-on-closed",
252
+ nodeId,
253
+ template,
254
+ sourceNodeId,
255
+ sourceNodeType: srcType,
256
+ message: `Node "${nodeId}" references "${template}"; "${sourceNodeId}" is a ` + `"${srcType}" node whose output is ${contract.description} — "${first}" ` + `is not one of [${[...allowed].join(", ")}]. It may resolve only if the ` + `node's output object happens to contain "${first}".`,
257
+ suggestion: contract.suggestedField ? template.replace(new RegExp(`\\.${escapeRegExp(first)}(?=\\.|\\[|\\}\\}|$)`), `.${contract.suggestedField}`) : undefined
258
+ });
259
+ }
260
+ if (srcType === "tool" && first === VIRTUAL_OUTPUT_FIELD && rest.length > 1) {
261
+ findings.push({
262
+ severity: "info",
263
+ rule: "R4-deep-path-into-tool",
264
+ nodeId,
265
+ template,
266
+ sourceNodeId,
267
+ sourceNodeType: srcType,
268
+ message: `Node "${nodeId}" references "${template}" — a deep path into a "tool" ` + `node. Tool outputs are frequently plain strings, in which case ` + `".${rest.slice(1).join(".")}" cannot be navigated. Verify the tool ` + `returns a structured object.`
269
+ });
270
+ }
271
+ if (srcType === "agent" && first) {
272
+ const declared = getAgentDeclaredJsonFields(src.config);
273
+ if (declared && first && !allowed.has(first) && !declared.includes(first)) {
274
+ findings.push({
275
+ severity: "warning",
276
+ rule: "R5-agent-schema-field",
277
+ nodeId,
278
+ template,
279
+ sourceNodeId,
280
+ sourceNodeType: srcType,
281
+ message: `Node "${nodeId}" references "${template}", but agent node ` + `"${sourceNodeId}" declares a JSON output schema with fields ` + `[${declared.join(", ")}]. "${first}" is not among them ` + `(nor the generic "result"/"output"/"metadata"/"workflowHistory").`
282
+ });
283
+ }
284
+ }
285
+ if (sourceNodeId !== nodeId && !upOfNode.has(sourceNodeId)) {
286
+ findings.push({
287
+ severity: "info",
288
+ rule: "R6-not-upstream",
289
+ nodeId,
290
+ template,
291
+ sourceNodeId,
292
+ sourceNodeType: srcType,
293
+ message: `Node "${nodeId}" references "${template}", but "${sourceNodeId}" is not ` + `in its upstream dependency closure. This is valid for loop back-edges ` + `(consuming the previous round's output) but otherwise may resolve to an ` + `empty value on the first execution.`
294
+ });
295
+ }
296
+ }
297
+ }
298
+ return findings;
299
+ }
300
+ function escapeRegExp(s) {
301
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
302
+ }
303
+ function getTemplateContractErrors(definition) {
304
+ return validateTemplateContracts(definition).filter((f) => f.severity === "error");
305
+ }
306
+ function getTemplateContractWarnings(definition) {
307
+ return validateTemplateContracts(definition).filter((f) => f.severity === "warning");
308
+ }
309
+ function formatTemplateContractFindings(findings) {
310
+ return findings.map((f) => {
311
+ const head = `[template-contract:${f.rule}] Node "${f.nodeId}": ${f.message}`;
312
+ return f.suggestion ? `${head} — Did you mean "${f.suggestion}"?` : head;
313
+ });
314
+ }
315
+
316
+ // src/env/workflow/utils/validate-workflow-definition.ts
317
+ init_dag_manager();
318
+ function validateWorkflowDefinition(definition, options = {}) {
319
+ if (!definition || typeof definition !== "object") {
320
+ return {
321
+ valid: false,
322
+ errors: ["Workflow definition must be an object"]
323
+ };
324
+ }
325
+ const def = definition;
326
+ if (!Array.isArray(def.nodes)) {
327
+ return {
328
+ valid: false,
329
+ errors: ["Workflow definition must have a 'nodes' array"]
330
+ };
331
+ }
332
+ let structural;
333
+ try {
334
+ const dag = new DAGManager(definition, { allowCycles: false });
335
+ structural = dag.validate();
336
+ } catch (error) {
337
+ structural = {
338
+ valid: false,
339
+ errors: [
340
+ `Validation error: ${error instanceof Error ? error.message : String(error)}`
341
+ ]
342
+ };
343
+ }
344
+ let findings = [];
345
+ if (structural.valid && !options.skipTemplateContracts) {
346
+ try {
347
+ findings = validateTemplateContracts(definition);
348
+ } catch {
349
+ findings = [];
350
+ }
351
+ }
352
+ const contractErrors = findings.filter((f) => f.severity === "error");
353
+ const contractWarnings = findings.filter((f) => f.severity === "warning");
354
+ const contractInfos = findings.filter((f) => f.severity === "info");
355
+ const errors = [...structural.errors, ...formatTemplateContractFindings(contractErrors)];
356
+ const warnings = formatTemplateContractFindings(contractWarnings);
357
+ const infos = formatTemplateContractFindings(contractInfos);
358
+ return {
359
+ valid: structural.valid && contractErrors.length === 0,
360
+ errors,
361
+ ...warnings.length > 0 ? { warnings } : {},
362
+ ...infos.length > 0 ? { infos } : {},
363
+ ...findings.length > 0 ? { findings } : {}
364
+ };
365
+ }
366
+
367
+ export { VIRTUAL_OUTPUT_FIELD, NODE_OUTPUT_CONTRACTS, getNodeOutputContract, hasClosedOutputContract, RESULT_INVALID_NODE_TYPES, getAgentDeclaredJsonFields, validateTemplateContracts, getTemplateContractErrors, getTemplateContractWarnings, formatTemplateContractFindings, validateWorkflowDefinition };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TracedAs,
3
3
  init_decorator
4
- } from "./roy-agent-core-bt6h398s.js";
4
+ } from "./roy-agent-core-dsevjbck.js";
5
5
  import {
6
6
  __legacyDecorateClassTS
7
7
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TagRepository
3
- } from "./roy-agent-core-j783tcqb.js";
4
- import"./roy-agent-core-bt6h398s.js";
3
+ } from "./roy-agent-core-nde5gzta.js";
4
+ import"./roy-agent-core-dsevjbck.js";
5
5
  import"./roy-agent-core-8seq65bp.js";
6
6
  import"./roy-agent-core-jnszp0jq.js";
7
7
  import"./roy-agent-core-fs0mn2jk.js";
@@ -4,35 +4,35 @@ import {
4
4
  } from "./roy-agent-core-tbrn9wdm.js";
5
5
  import {
6
6
  getSharedEventStore
7
- } from "./roy-agent-core-zff8vvs5.js";
7
+ } from "./roy-agent-core-yhsssn86.js";
8
8
  import {
9
9
  TaskHookPoints
10
10
  } from "./roy-agent-core-1pg0fepg.js";
11
11
  import {
12
12
  builtInPrompts
13
- } from "./roy-agent-core-223v204d.js";
13
+ } from "./roy-agent-core-gdsqp6j8.js";
14
14
  import {
15
15
  DEFAULT_SUBAGENT_PROMPT
16
- } from "./roy-agent-core-ed4tbkyj.js";
16
+ } from "./roy-agent-core-rx16h2m1.js";
17
17
  import {
18
18
  runWithBgTaskIdAsync
19
19
  } from "./roy-agent-core-c1v263jn.js";
20
20
  import {
21
21
  globalHookManager,
22
22
  init_global_hook_manager
23
- } from "./roy-agent-core-mqaht7mm.js";
23
+ } from "./roy-agent-core-4z3rq5gw.js";
24
24
  import {
25
25
  init_context
26
- } from "./roy-agent-core-emjpkx9s.js";
26
+ } from "./roy-agent-core-k8b440n3.js";
27
27
  import {
28
28
  getCurrentTaskId,
29
29
  getEnvContext
30
- } from "./roy-agent-core-fm77q3tn.js";
30
+ } from "./roy-agent-core-5apmk4qw.js";
31
31
  import {
32
32
  TracedAs,
33
33
  init_decorator,
34
34
  wrapFunction
35
- } from "./roy-agent-core-bt6h398s.js";
35
+ } from "./roy-agent-core-dsevjbck.js";
36
36
  import {
37
37
  createLogger,
38
38
  init_logger
@@ -1129,13 +1129,13 @@ class BackgroundTaskManager {
1129
1129
  if (!reusedSession) {
1130
1130
  throw new Error(`Sub session not found for resume: ${existingSubSessionId}`);
1131
1131
  }
1132
- const createdBy = reusedSession?.info?.metadata?.created_by;
1132
+ const createdBy = reusedSession?.metadata?.created_by;
1133
1133
  if (createdBy && createdBy !== "subagent") {
1134
1134
  logger3.warn(`[BackgroundTaskManager] Session ${existingSubSessionId} was not created by a sub-agent (created_by=${createdBy}); reusing anyway`);
1135
1135
  }
1136
1136
  subSession = reusedSession;
1137
1137
  try {
1138
- const existingMeta = reusedSession?.info?.metadata || {};
1138
+ const existingMeta = reusedSession?.metadata ?? {};
1139
1139
  await sessionComponent.update(existingSubSessionId, {
1140
1140
  metadata: {
1141
1141
  ...existingMeta,
@@ -1250,7 +1250,7 @@ class BackgroundTaskManager {
1250
1250
  throw new Error(`Sub session not found: ${task.subSessionId}`);
1251
1251
  }
1252
1252
  const taskRegistry = this.processRegistries.get(taskId);
1253
- const result = await this.executeWithAbort(subSession, prompt, timeoutMs, taskId, abortController?.signal, task.similarTaskIds, taskRegistry, () => abortController?.abort());
1253
+ const result = await this.executeWithAbort(subSession, prompt, timeoutMs, taskId, abortController?.signal, task.similarTaskIds, taskRegistry, () => abortController?.abort(), task.subagentType);
1254
1254
  if (abortController?.signal.aborted) {
1255
1255
  logger3.info(`[BackgroundTaskManager] Task was aborted`, { taskId });
1256
1256
  return;
@@ -1416,12 +1416,16 @@ class BackgroundTaskManager {
1416
1416
  this.progressTimers.delete(taskId);
1417
1417
  }
1418
1418
  }
1419
- async executeWithAbort(subSession, prompt, timeoutMs, bgTaskId, signal, similarTaskIds, processRegistry, abortTask) {
1420
- const metadata = subSession.info?.metadata || {};
1419
+ async executeWithAbort(subSession, prompt, timeoutMs, bgTaskId, signal, similarTaskIds, processRegistry, abortTask, explicitSubagentType) {
1420
+ const metadata = subSession?.metadata ?? {};
1421
1421
  const taskId = metadata.task_id;
1422
1422
  const taskDescription = metadata.task_description || "";
1423
1423
  const sessionId = subSession.id;
1424
- const subagentType = metadata.subagent_type || "general";
1424
+ const metaSubagentType = metadata.subagent_type;
1425
+ const subagentType = metaSubagentType || explicitSubagentType || "general";
1426
+ if (!metaSubagentType && !explicitSubagentType) {
1427
+ logger3.warn(`[delegate] subagent_type unresolved (no session metadata, no explicit value) — falling back to "general". sessionId=${sessionId}`);
1428
+ }
1425
1429
  const agentComponent = this.env?.getComponent?.("agent");
1426
1430
  const registry = agentComponent?.getRegistry?.();
1427
1431
  const resolved = await resolveSubAgentConfig(subagentType, { registry });
@@ -21,17 +21,17 @@ import {
21
21
  } from "./roy-agent-core-7hh0brvs.js";
22
22
  import {
23
23
  BaseComponent
24
- } from "./roy-agent-core-xn12d221.js";
24
+ } from "./roy-agent-core-tdbv7ff4.js";
25
25
  import {
26
26
  LLMHookPoints,
27
27
  globalHookManager,
28
28
  init_global_hook_manager
29
- } from "./roy-agent-core-mqaht7mm.js";
29
+ } from "./roy-agent-core-4z3rq5gw.js";
30
30
  import {
31
31
  TracedAs,
32
32
  init_decorator,
33
33
  wrapFunction
34
- } from "./roy-agent-core-bt6h398s.js";
34
+ } from "./roy-agent-core-dsevjbck.js";
35
35
  import {
36
36
  createLogger,
37
37
  init_logger
@@ -8,7 +8,7 @@ import {
8
8
  } from "./roy-agent-core-qxnbvgwe.js";
9
9
  import {
10
10
  BaseComponent
11
- } from "./roy-agent-core-xn12d221.js";
11
+ } from "./roy-agent-core-tdbv7ff4.js";
12
12
  import {
13
13
  __require
14
14
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -1,7 +1,10 @@
1
1
  import {
2
2
  init_global_hook_manager,
3
3
  init_hook_manager
4
- } from "./roy-agent-core-mqaht7mm.js";
4
+ } from "./roy-agent-core-4z3rq5gw.js";
5
+ import {
6
+ __esm
7
+ } from "./roy-agent-core-fs0mn2jk.js";
5
8
 
6
9
  // src/env/hook/types.ts
7
10
  function createHook(meta, fn) {
@@ -13,9 +16,13 @@ function createHook(meta, fn) {
13
16
  function createPriorityHook(name, fn, priority) {
14
17
  return createHook({ name, priority }, fn);
15
18
  }
19
+ var init_types = () => {};
16
20
 
17
21
  // src/env/hook/index.ts
18
- init_hook_manager();
19
- init_global_hook_manager();
22
+ var init_hook = __esm(() => {
23
+ init_types();
24
+ init_hook_manager();
25
+ init_global_hook_manager();
26
+ });
20
27
 
21
- export { createHook, createPriorityHook };
28
+ export { createHook, createPriorityHook, init_hook };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TracedAs,
3
3
  init_decorator
4
- } from "./roy-agent-core-bt6h398s.js";
4
+ } from "./roy-agent-core-dsevjbck.js";
5
5
  import {
6
6
  createLogger,
7
7
  init_logger
@@ -3,10 +3,10 @@ import {
3
3
  } from "./roy-agent-core-7hh0brvs.js";
4
4
  import {
5
5
  BaseComponent
6
- } from "./roy-agent-core-xn12d221.js";
6
+ } from "./roy-agent-core-tdbv7ff4.js";
7
7
  import {
8
8
  init_decorator
9
- } from "./roy-agent-core-bt6h398s.js";
9
+ } from "./roy-agent-core-dsevjbck.js";
10
10
  import {
11
11
  createLogger,
12
12
  getTracerProvider,
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  TracedAs,
6
6
  init_decorator
7
- } from "./roy-agent-core-bt6h398s.js";
7
+ } from "./roy-agent-core-dsevjbck.js";
8
8
  import {
9
9
  createLogger,
10
10
  init_logger
@@ -257,10 +257,14 @@ class AgentRegistry {
257
257
  "workflow_search",
258
258
  "workflow_tag_list",
259
259
  "workflow_validate",
260
- "workflow_add"
260
+ "workflow_add",
261
+ "bash",
262
+ "read_file",
263
+ "workflow_run",
264
+ "workflow_run_status"
261
265
  ],
262
266
  deniedTools: ["delegate_task", "stop_task"],
263
- maxIterations: 30
267
+ maxIterations: 60
264
268
  };
265
269
  this.agents.set(name, agent);
266
270
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  exports_node_registry_helper,
3
3
  init_node_registry_helper
4
- } from "./roy-agent-core-yge38dkn.js";
4
+ } from "./roy-agent-core-vrsxhw9e.js";
5
5
  import {
6
6
  askUserTool,
7
7
  createRunWorkflowTool,
@@ -13,18 +13,18 @@ import {
13
13
  createWorkflowSearchTool,
14
14
  createWorkflowTagListTool,
15
15
  createWorkflowValidateTool
16
- } from "./roy-agent-core-kazn764f.js";
16
+ } from "./roy-agent-core-vvxb9522.js";
17
17
  import {
18
18
  WorkflowService
19
- } from "./roy-agent-core-wt37tszm.js";
19
+ } from "./roy-agent-core-7evvpfwc.js";
20
20
  import {
21
21
  WorkflowEngine,
22
22
  exports_engine,
23
23
  init_engine
24
- } from "./roy-agent-core-1pjct4nj.js";
24
+ } from "./roy-agent-core-35s1w7tc.js";
25
25
  import {
26
26
  BaseComponent
27
- } from "./roy-agent-core-xn12d221.js";
27
+ } from "./roy-agent-core-tdbv7ff4.js";
28
28
  import {
29
29
  createLogger,
30
30
  init_logger
@@ -104,7 +104,7 @@ class WorkflowComponent extends BaseComponent {
104
104
  return;
105
105
  try {
106
106
  const { NodeRegistry } = await import("../../env/workflow/engine/index.js");
107
- const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-cnsjr3ws.js");
107
+ const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-9jzysq50.js");
108
108
  this.nodeRegistry = new NodeRegistry;
109
109
  registerDecoratorNodeType2(this.nodeRegistry);
110
110
  this.decoratorsRegistered = true;
@@ -134,14 +134,14 @@ class WorkflowComponent extends BaseComponent {
134
134
  }
135
135
  async runWorkflow(definition, input, options) {
136
136
  const { NodeRegistry } = await import("../../env/workflow/engine/index.js");
137
- const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-cnsjr3ws.js");
137
+ const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-9jzysq50.js");
138
138
  const toolComponent = this.toolComponent || this._workflowEnv?.getComponent("tool");
139
139
  const skillComponent = this._workflowEnv?.getComponent("skill");
140
140
  let agentRunner = this.agentRunner;
141
141
  if (!agentRunner && this._workflowEnv) {
142
142
  const agentComponent = this._workflowEnv.getComponent("agent");
143
143
  if (agentComponent) {
144
- const { AgentComponentAdapter } = await import("./roy-agent-core-ecb8am8s.js");
144
+ const { AgentComponentAdapter } = await import("./roy-agent-core-skzjs973.js");
145
145
  agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent);
146
146
  }
147
147
  }
@@ -163,7 +163,7 @@ class WorkflowComponent extends BaseComponent {
163
163
  if (this.workflowService) {
164
164
  this.workflowService = null;
165
165
  try {
166
- const { closeDatabase } = await import("./roy-agent-core-e302nvzt.js");
166
+ const { closeDatabase } = await import("./roy-agent-core-2k4xffaa.js");
167
167
  closeDatabase();
168
168
  componentLogger.info("[WorkflowComponent] SQLite database closed");
169
169
  } catch (error) {
@@ -241,9 +241,9 @@ class WorkflowComponent extends BaseComponent {
241
241
  }
242
242
  async initSqliteService() {
243
243
  try {
244
- const { getDatabase, initializeTables } = await import("./roy-agent-core-e302nvzt.js");
245
- const { WorkflowRepository } = await import("./roy-agent-core-trd6my5j.js");
246
- const { TagRepository } = await import("./roy-agent-core-e2569ptp.js");
244
+ const { getDatabase, initializeTables } = await import("./roy-agent-core-2k4xffaa.js");
245
+ const { WorkflowRepository } = await import("./roy-agent-core-1cv9j4dg.js");
246
+ const { TagRepository } = await import("./roy-agent-core-ne2t1pay.js");
247
247
  const db = getDatabase();
248
248
  initializeTables();
249
249
  const workflowRepository = new WorkflowRepository(db);
@@ -309,7 +309,7 @@ class WorkflowComponent extends BaseComponent {
309
309
  this.workflowService = null;
310
310
  this.nodeRegistry = null;
311
311
  try {
312
- const { closeDatabase } = await import("./roy-agent-core-e302nvzt.js");
312
+ const { closeDatabase } = await import("./roy-agent-core-2k4xffaa.js");
313
313
  closeDatabase();
314
314
  } catch {}
315
315
  this._status = "stopped";