@ai-setting/roy-agent-core 1.5.42 → 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 (31) hide show
  1. package/dist/env/agent/index.js +2 -2
  2. package/dist/env/index.js +11 -10
  3. package/dist/env/task/delegate/index.js +3 -2
  4. package/dist/env/task/index.js +3 -3
  5. package/dist/env/tool/built-in/index.js +1 -1
  6. package/dist/env/tool/index.js +2 -2
  7. package/dist/env/workflow/decorators/index.js +1 -1
  8. package/dist/env/workflow/engine/index.js +4 -3
  9. package/dist/env/workflow/index.js +34 -19
  10. package/dist/env/workflow/nodes/index.js +5 -1
  11. package/dist/env/workflow/types/index.js +16 -2
  12. package/dist/env/workflow/utils/index.js +15 -196
  13. package/dist/index.js +13 -12
  14. package/dist/shared/@ai-setting/{roy-agent-core-9q6sa7m3.js → roy-agent-core-1zq3p19q.js} +1 -1
  15. package/dist/shared/@ai-setting/{roy-agent-core-ffb9fq4v.js → roy-agent-core-23gw9c4s.js} +2 -2
  16. package/dist/shared/@ai-setting/{roy-agent-core-bmr6bdfb.js → roy-agent-core-2ms7296b.js} +4 -4
  17. package/dist/shared/@ai-setting/{roy-agent-core-2jnzv9at.js → roy-agent-core-38dkek2y.js} +319 -189
  18. package/dist/shared/@ai-setting/roy-agent-core-6vxg2gmr.js +321 -0
  19. package/dist/shared/@ai-setting/{roy-agent-core-0rtxwr28.js → roy-agent-core-9bmtxmp6.js} +77 -120
  20. package/dist/shared/@ai-setting/{roy-agent-core-xz22rmak.js → roy-agent-core-9p43ap7h.js} +21 -7
  21. package/dist/shared/@ai-setting/{roy-agent-core-7t05apnp.js → roy-agent-core-fg3j215p.js} +26 -0
  22. package/dist/shared/@ai-setting/{roy-agent-core-7fgf85wc.js → roy-agent-core-h0x19xgn.js} +6 -7
  23. package/dist/shared/@ai-setting/roy-agent-core-qnrf2aw6.js +441 -0
  24. package/dist/shared/@ai-setting/{roy-agent-core-ek6gk3wk.js → roy-agent-core-r6rwsr54.js} +42 -3
  25. package/dist/shared/@ai-setting/roy-agent-core-v002ynpa.js +435 -0
  26. package/dist/shared/@ai-setting/{roy-agent-core-rsybkb38.js → roy-agent-core-ysvh8er9.js} +36 -39
  27. package/dist/shared/@ai-setting/{roy-agent-core-9yxb3ty9.js → roy-agent-core-z5sxe4p7.js} +5 -1
  28. package/package.json +1 -1
  29. package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
  30. package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
  31. /package/dist/shared/@ai-setting/{roy-agent-core-e130w7mv.js → roy-agent-core-ryw3ckfy.js} +0 -0
@@ -132,6 +132,11 @@ class WorkflowConverter {
132
132
  retry: meta.retry,
133
133
  timeout: meta.timeout
134
134
  }));
135
+ const edges = edgeMetadatas.map((edge) => ({
136
+ from: edge.from,
137
+ to: edge.to,
138
+ when: edge.condition
139
+ }));
135
140
  const entry = workflowMeta.entry || nodeMetadatas[0]?.nodeId || "unknown";
136
141
  return {
137
142
  name: workflowMeta.name,
@@ -139,6 +144,7 @@ class WorkflowConverter {
139
144
  description: workflowMeta.description,
140
145
  config: workflowMeta.config || {},
141
146
  nodes,
147
+ edges,
142
148
  entry,
143
149
  outputs: [],
144
150
  metadata: {
@@ -158,13 +164,6 @@ class WorkflowConverter {
158
164
  if (!targetNode.dependsOn.includes(edge.from)) {
159
165
  targetNode.dependsOn = [...targetNode.dependsOn, edge.from];
160
166
  }
161
- if (edge.condition) {
162
- if (targetNode.condition) {
163
- targetNode.condition = `(${targetNode.condition}) AND (${edge.condition})`;
164
- } else {
165
- targetNode.condition = edge.condition;
166
- }
167
- }
168
167
  }
169
168
  }
170
169
  return nodeMap;
@@ -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 };
@@ -4,7 +4,7 @@ import {
4
4
  } from "./roy-agent-core-e25xkv53.js";
5
5
  import {
6
6
  AgentRegistry
7
- } from "./roy-agent-core-7t05apnp.js";
7
+ } from "./roy-agent-core-fg3j215p.js";
8
8
  import {
9
9
  ContextError
10
10
  } from "./roy-agent-core-ctdhjv68.js";
@@ -290,6 +290,7 @@ class AgentComponent extends BaseComponent {
290
290
  this.registerAgent(agentDef.name, {
291
291
  type: agentDef.type,
292
292
  systemPrompt,
293
+ systemPromptRef: agentDef.systemPromptRef,
293
294
  allowedTools: agentDef.allowedTools,
294
295
  deniedTools: agentDef.deniedTools,
295
296
  model: agentDef.model,
@@ -310,11 +311,17 @@ class AgentComponent extends BaseComponent {
310
311
  const systemPrompt = await this.registry.getSystemPrompt(agentDef.name);
311
312
  const existing = this.agents.get(agentDef.name);
312
313
  if (existing) {
313
- existing.config.systemPrompt = systemPrompt;
314
+ if (systemPrompt !== undefined) {
315
+ existing.config.systemPrompt = systemPrompt;
316
+ }
317
+ if (agentDef.systemPromptRef) {
318
+ existing.config.systemPromptRef = agentDef.systemPromptRef;
319
+ }
314
320
  } else {
315
321
  this.registerAgent(agentDef.name, {
316
322
  type: agentDef.type,
317
323
  systemPrompt,
324
+ systemPromptRef: agentDef.systemPromptRef,
318
325
  allowedTools: agentDef.allowedTools,
319
326
  deniedTools: agentDef.deniedTools,
320
327
  model: agentDef.model,
@@ -363,6 +370,27 @@ class AgentComponent extends BaseComponent {
363
370
  });
364
371
  }
365
372
  }
373
+ async resolveSystemPrompt(agent, agentName) {
374
+ if (agent.config.systemPrompt) {
375
+ return;
376
+ }
377
+ if (!agent.config.systemPromptRef) {
378
+ return;
379
+ }
380
+ if (!this.registry) {
381
+ logger.debug(`[resolveSystemPrompt] No registry available for ${agentName}`);
382
+ return;
383
+ }
384
+ try {
385
+ const resolvedPrompt = await this.registry.getSystemPrompt(agentName);
386
+ if (resolvedPrompt) {
387
+ agent.config.systemPrompt = resolvedPrompt;
388
+ logger.debug(`[AgentComponent] Resolved systemPrompt for agent: ${agentName}`);
389
+ }
390
+ } catch (error) {
391
+ logger.warn(`[AgentComponent] Failed to resolve systemPrompt for agent ${agentName}: ${error}`);
392
+ }
393
+ }
366
394
  getAgent(agentName) {
367
395
  return this.agents.get(agentName);
368
396
  }
@@ -393,7 +421,8 @@ class AgentComponent extends BaseComponent {
393
421
  doomLoopThreshold: config.doomLoopThreshold ?? this.config.defaultAgent.doomLoopThreshold,
394
422
  toolTimeout: config.toolTimeout ?? this.config.defaultAgent.toolTimeout,
395
423
  toolRetries: config.toolRetries ?? this.config.defaultAgent.toolRetries,
396
- systemPrompt: config.systemPrompt ?? this.config.defaultAgent.systemPrompt,
424
+ systemPrompt: config.systemPrompt ?? (config.systemPromptRef ? undefined : this.config.defaultAgent.systemPrompt),
425
+ systemPromptRef: config.systemPromptRef,
397
426
  model: config.model ?? this.config.defaultAgent.model,
398
427
  behaviorSpecId: config.behaviorSpecId ?? this.config.defaultAgent.behaviorSpecId,
399
428
  allowedTools: config.allowedTools ?? this.config.defaultAgent.allowedTools,
@@ -495,6 +524,7 @@ class AgentComponent extends BaseComponent {
495
524
  if (!this.doomLoopCaches.has(runId)) {
496
525
  this.doomLoopCaches.set(runId, new Map);
497
526
  }
527
+ await this.resolveSystemPrompt(agent, agentName);
498
528
  const effectiveContext = {
499
529
  ...context,
500
530
  agentType: agent.config.type,
@@ -1200,6 +1230,15 @@ ${ctx.context.additionInfo}`
1200
1230
  return messages;
1201
1231
  }
1202
1232
  }
1233
+ __legacyDecorateClassTS([
1234
+ TracedAs("agent.component.initRegistry", { recordParams: true, recordResult: true, log: true })
1235
+ ], AgentComponent.prototype, "initRegistry", null);
1236
+ __legacyDecorateClassTS([
1237
+ TracedAs("agent.component.syncRegistryAgentsFromConfig", { recordParams: false, recordResult: true, log: true })
1238
+ ], AgentComponent.prototype, "syncRegistryAgentsFromConfig", null);
1239
+ __legacyDecorateClassTS([
1240
+ TracedAs("agent.component.resolveSystemPrompt", { recordParams: true, recordResult: true, log: true })
1241
+ ], AgentComponent.prototype, "resolveSystemPrompt", null);
1203
1242
  __legacyDecorateClassTS([
1204
1243
  TracedAs("agent.component.run", { recordParams: true, recordResult: true, log: true })
1205
1244
  ], AgentComponent.prototype, "_run", null);