@ai-setting/roy-agent-core 1.5.45 → 1.5.47

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 (26) hide show
  1. package/dist/env/agent/index.js +3 -3
  2. package/dist/env/index.js +15 -14
  3. package/dist/env/mcp/index.js +7 -5
  4. package/dist/env/mcp/npm-prefix/index.js +21 -0
  5. package/dist/env/memory/index.js +4 -4
  6. package/dist/env/session/index.js +7 -7
  7. package/dist/env/task/delegate/index.js +2 -2
  8. package/dist/env/task/index.js +6 -6
  9. package/dist/env/workflow/engine/index.js +5 -5
  10. package/dist/env/workflow/index.js +19 -19
  11. package/dist/index.js +26 -25
  12. package/dist/shared/@ai-setting/{roy-agent-core-nn9dmffw.js → roy-agent-core-1rzpnycm.js} +113 -16
  13. package/dist/shared/@ai-setting/{roy-agent-core-cr8xer31.js → roy-agent-core-1t5esk1r.js} +3 -3
  14. package/dist/shared/@ai-setting/{roy-agent-core-44g4dhzg.js → roy-agent-core-2rtka82a.js} +4 -4
  15. package/dist/shared/@ai-setting/{roy-agent-core-9p604xjf.js → roy-agent-core-38sc085e.js} +8 -10
  16. package/dist/shared/@ai-setting/{roy-agent-core-r9hq4cjx.js → roy-agent-core-a23brrex.js} +61 -1
  17. package/dist/shared/@ai-setting/{roy-agent-core-68qy97r3.js → roy-agent-core-ebap34m2.js} +6 -1
  18. package/dist/shared/@ai-setting/{roy-agent-core-fg3j215p.js → roy-agent-core-emk3q2nt.js} +24 -3
  19. package/dist/shared/@ai-setting/roy-agent-core-fnv3ev18.js +61 -0
  20. package/dist/shared/@ai-setting/{roy-agent-core-8y804aat.js → roy-agent-core-jqq7c2rk.js} +34 -5
  21. package/dist/shared/@ai-setting/{roy-agent-core-dbxm76wf.js → roy-agent-core-kzbj10gk.js} +10 -3
  22. package/dist/shared/@ai-setting/{roy-agent-core-bp3xggmb.js → roy-agent-core-pm73be85.js} +32 -90
  23. package/dist/shared/@ai-setting/{roy-agent-core-w64zachx.js → roy-agent-core-t1ytby5n.js} +4 -4
  24. package/dist/shared/@ai-setting/{roy-agent-core-ye0z728h.js → roy-agent-core-twd8kzag.js} +3 -2
  25. package/package.json +1 -1
  26. package/dist/shared/@ai-setting/{roy-agent-core-ce9w0j8n.js → roy-agent-core-pyv1vb7v.js} +4 -4
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  WORKFLOW_JSON_OUTPUT_PLUGIN_KEY,
3
- extractStructuredJsonViaLlm,
4
3
  init_workflow_json_output_plugin,
5
- registerWorkflowJsonOutputPlugin
6
- } from "./roy-agent-core-dbxm76wf.js";
4
+ registerWorkflowJsonOutputPlugin,
5
+ tracedExtractStructuredJsonViaLlm
6
+ } from "./roy-agent-core-kzbj10gk.js";
7
7
  import {
8
8
  AskUserError,
9
9
  init_workflow_hil
@@ -229,7 +229,7 @@ class AgentComponentAdapter {
229
229
  role: m.role,
230
230
  content: m.content ?? ""
231
231
  }));
232
- return await extractStructuredJsonViaLlm(this._llmComponent, history, outputSchema, {
232
+ return await tracedExtractStructuredJsonViaLlm(this._llmComponent, history, outputSchema, {
233
233
  model: config.options?.model,
234
234
  sessionId: agentSessionId
235
235
  });
@@ -4,10 +4,13 @@ import {
4
4
  } from "./roy-agent-core-e25xkv53.js";
5
5
  import {
6
6
  AgentRegistry
7
- } from "./roy-agent-core-fg3j215p.js";
7
+ } from "./roy-agent-core-emk3q2nt.js";
8
8
  import {
9
9
  ContextError
10
10
  } from "./roy-agent-core-ctdhjv68.js";
11
+ import {
12
+ SessionMessageConverter
13
+ } from "./roy-agent-core-7b35emr7.js";
11
14
  import {
12
15
  TracedAs,
13
16
  init_decorator
@@ -30,9 +33,6 @@ import {
30
33
  createLogger,
31
34
  init_logger
32
35
  } from "./roy-agent-core-10n2jh7p.js";
33
- import {
34
- SessionMessageConverter
35
- } from "./roy-agent-core-7b35emr7.js";
36
36
  import {
37
37
  __legacyDecorateClassTS
38
38
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -889,12 +889,10 @@ class AgentComponent extends BaseComponent {
889
889
  sessionId: effectiveContext.sessionId,
890
890
  summary: result.finalText
891
891
  };
892
- await this.executePluginHooks(agent, "agent:after.react", {
893
- ...hookCtx,
894
- ...reactContext
895
- });
896
- if (hookCtx.structuredOutputExtracted) {
897
- result.structuredOutput = hookCtx.structuredOutputExtracted;
892
+ const mergedHookCtx = { ...hookCtx, ...reactContext };
893
+ await this.executePluginHooks(agent, "agent:after.react", mergedHookCtx);
894
+ if (mergedHookCtx.structuredOutputExtracted) {
895
+ result.structuredOutput = mergedHookCtx.structuredOutputExtracted;
898
896
  }
899
897
  await this.executePluginHooks(agent, "agent:after.complete", hookCtx);
900
898
  if (this.aborted.get(runId) === true || hookCtx._stopped) {
@@ -82,6 +82,14 @@ class BaseEnvironment extends BaseComponent {
82
82
  if (!agentComponent) {
83
83
  throw new Error("AgentComponent not found. Please register AgentComponent before calling handle_query.");
84
84
  }
85
+ const agentName = context?.agentType && context.agentType !== "default" ? context.agentType : "default";
86
+ const registry = agentComponent.getRegistry?.();
87
+ if (registry) {
88
+ const agentDef = registry.get(agentName);
89
+ if (agentDef?.type === "workflow") {
90
+ return await this.handleWorkflowAgentQuery(agentName, query, agentComponent);
91
+ }
92
+ }
85
93
  let systemPrompt = "You are a helpful assistant.";
86
94
  let promptSource = "fallback";
87
95
  try {
@@ -118,7 +126,6 @@ class BaseEnvironment extends BaseComponent {
118
126
  finalSystemPrompt = finalSystemPrompt.replace("{{workspace_dir}}", workspaceDir);
119
127
  logger.debug(`[handle_query] Injected workspace_dir: ${workspaceDir}`);
120
128
  }
121
- const agentName = context?.agentType && context.agentType !== "default" ? context.agentType : "default";
122
129
  let agent = agentComponent.getAgent(agentName);
123
130
  if (!agent) {
124
131
  if (agentName !== "default") {
@@ -155,6 +162,56 @@ class BaseEnvironment extends BaseComponent {
155
162
  }
156
163
  return result.finalText || "";
157
164
  }
165
+ async handleWorkflowAgentQuery(agentName, query, agentComponent) {
166
+ const registry = agentComponent.getRegistry?.();
167
+ if (!registry) {
168
+ return null;
169
+ }
170
+ const agentDef = registry.get(agentName);
171
+ if (!agentDef || agentDef.type !== "workflow") {
172
+ return null;
173
+ }
174
+ const workflowComponent = this.getComponent("workflow");
175
+ if (!workflowComponent) {
176
+ throw new Error(`WorkflowComponent not available — cannot run workflow agent "${agentName}". ` + `Ensure the workflow component is registered.`);
177
+ }
178
+ const workflowName = agentDef.workflow;
179
+ if (!workflowName) {
180
+ throw new Error(`Agent "${agentName}" has type 'workflow' but no workflow configured.`);
181
+ }
182
+ const svc = workflowComponent.getService?.();
183
+ if (!svc || typeof svc.getWorkflowByName !== "function") {
184
+ throw new Error(`WorkflowService not available. Cannot run workflow agent "${agentName}".`);
185
+ }
186
+ const workflow = svc.getWorkflowByName(workflowName);
187
+ if (!workflow) {
188
+ throw new Error(`Workflow "${workflowName}" not found. ` + `Use 'roy-agent workflow add' to register it first.`);
189
+ }
190
+ const wfResult = await workflowComponent.runWorkflow(workflow.definition, { query }, {});
191
+ if (wfResult.status === "paused") {
192
+ return JSON.stringify({
193
+ status: "paused",
194
+ message: `Workflow "${workflowName}" paused, waiting for user input.`,
195
+ pendingNodeId: wfResult.pendingNodeId,
196
+ query: wfResult.query,
197
+ sessionId: wfResult.sessionId,
198
+ hint: `Resume with: roy-agent workflow run -s ${wfResult.sessionId} --input "your response"`
199
+ });
200
+ }
201
+ if (wfResult.status === "failed") {
202
+ throw new Error(`Workflow "${workflowName}" execution failed: ${wfResult.error || "Unknown error (status: " + wfResult.status + ")"}`);
203
+ }
204
+ if (typeof wfResult.output === "string") {
205
+ return wfResult.output;
206
+ }
207
+ if (wfResult.output !== undefined && wfResult.output !== null) {
208
+ return JSON.stringify(wfResult.output);
209
+ }
210
+ if (wfResult.error) {
211
+ throw new Error(`Workflow "${workflowName}" completed with error: ${wfResult.error}`);
212
+ }
213
+ return "";
214
+ }
158
215
  async handle_action(action, context) {
159
216
  throw new Error("handle_action not implemented. Override in subclass.");
160
217
  }
@@ -424,6 +481,9 @@ class BaseEnvironment extends BaseComponent {
424
481
  __legacyDecorateClassTS([
425
482
  TracedAs("env.handle_query", { recordParams: true, recordResult: true, log: true })
426
483
  ], BaseEnvironment.prototype, "handle_query", null);
484
+ __legacyDecorateClassTS([
485
+ TracedAs("env.handle_workflow_agent_query", { recordParams: true, recordResult: true, log: true })
486
+ ], BaseEnvironment.prototype, "handleWorkflowAgentQuery", null);
427
487
 
428
488
  // src/env/index.ts
429
489
  init_context();
@@ -7,10 +7,13 @@ import {
7
7
  isWorkflowJsonOutputEnabled,
8
8
  registerWorkflowJsonOutputPlugin,
9
9
  runWorkflowJsonOutputExtraction,
10
+ tracedExtractStructuredJsonViaLlm,
11
+ tracedRunWorkflowJsonOutputExtraction,
10
12
  unregisterWorkflowJsonOutputPlugin
11
- } from "./roy-agent-core-dbxm76wf.js";
13
+ } from "./roy-agent-core-kzbj10gk.js";
12
14
  import"./roy-agent-core-nhfy3p8q.js";
13
15
  import"./roy-agent-core-e25xkv53.js";
16
+ import"./roy-agent-core-q5qj0fes.js";
14
17
  import"./roy-agent-core-rgj6hq15.js";
15
18
  import"./roy-agent-core-rm3hay00.js";
16
19
  import"./roy-agent-core-10n2jh7p.js";
@@ -21,6 +24,8 @@ init_workflow_json_output_plugin();
21
24
 
22
25
  export {
23
26
  unregisterWorkflowJsonOutputPlugin,
27
+ tracedRunWorkflowJsonOutputExtraction,
28
+ tracedExtractStructuredJsonViaLlm,
24
29
  runWorkflowJsonOutputExtraction,
25
30
  registerWorkflowJsonOutputPlugin,
26
31
  isWorkflowJsonOutputEnabled,
@@ -24,7 +24,8 @@ init_decorator();
24
24
  var logger = createLogger("agent:registry");
25
25
  var AgentConfigSchema = z.object({
26
26
  name: z.string(),
27
- type: z.enum(["primary", "sub"]),
27
+ type: z.enum(["primary", "sub", "workflow"]),
28
+ workflow: z.string().optional(),
28
29
  description: z.string().optional(),
29
30
  systemPromptRef: z.string().optional(),
30
31
  systemPrompt: z.string().optional(),
@@ -37,7 +38,7 @@ var AgentConfigSchema = z.object({
37
38
  toolRetries: z.number().optional(),
38
39
  doomLoopThreshold: z.number().optional(),
39
40
  filterHistory: z.boolean().optional()
40
- });
41
+ }).refine((data) => data.type !== "workflow" || data.workflow && data.workflow.length > 0, { message: "workflow is required when type is 'workflow'" });
41
42
 
42
43
  class AgentRegistry {
43
44
  agents = new Map;
@@ -78,6 +79,10 @@ class AgentRegistry {
78
79
  if (!agent.name) {
79
80
  throw new Error("Agent name is required");
80
81
  }
82
+ const validation = AgentConfigSchema.safeParse(agent);
83
+ if (!validation.success) {
84
+ throw new Error(`Invalid agent config for "${agent.name}": ${validation.error.issues.map((i) => i.message).join("; ")}`);
85
+ }
81
86
  this.agents.set(agent.name, { ...agent });
82
87
  logger.info(`[AgentRegistry] Registered agent: ${agent.name}`, { type: agent.type });
83
88
  }
@@ -133,6 +138,13 @@ class AgentRegistry {
133
138
  }
134
139
  return agent.systemPrompt;
135
140
  }
141
+ getWorkflowName(name) {
142
+ const agent = this.agents.get(name);
143
+ if (!agent || agent.type !== "workflow") {
144
+ return;
145
+ }
146
+ return agent.workflow;
147
+ }
136
148
  async load() {
137
149
  try {
138
150
  return await this.loadFromDirectory(this.configDir);
@@ -193,6 +205,11 @@ class AgentRegistry {
193
205
  }
194
206
  async saveAgent(agent) {
195
207
  try {
208
+ const validation = AgentConfigSchema.safeParse(agent);
209
+ if (!validation.success) {
210
+ logger.error(`[AgentRegistry] Invalid agent config for "${agent.name}": ${validation.error.message}`);
211
+ return false;
212
+ }
196
213
  await this.ensureConfigDir();
197
214
  const yamlContent = this.agentToYaml(agent);
198
215
  const filePath = join(this.configDir, `${agent.name}.yaml`);
@@ -226,7 +243,8 @@ class AgentRegistry {
226
243
  ...agent.toolTimeout !== undefined ? { toolTimeout: agent.toolTimeout } : {},
227
244
  ...agent.toolRetries !== undefined ? { toolRetries: agent.toolRetries } : {},
228
245
  ...agent.doomLoopThreshold !== undefined ? { doomLoopThreshold: agent.doomLoopThreshold } : {},
229
- ...agent.filterHistory !== undefined ? { filterHistory: agent.filterHistory } : {}
246
+ ...agent.filterHistory !== undefined ? { filterHistory: agent.filterHistory } : {},
247
+ ...agent.workflow !== undefined ? { workflow: agent.workflow } : {}
230
248
  };
231
249
  return yaml.stringify(config).trimEnd() + `
232
250
  `;
@@ -282,6 +300,9 @@ __legacyDecorateClassTS([
282
300
  __legacyDecorateClassTS([
283
301
  TracedAs("agent.registry.getSystemPrompt", { recordParams: true, recordResult: true, log: true })
284
302
  ], AgentRegistry.prototype, "getSystemPrompt", null);
303
+ __legacyDecorateClassTS([
304
+ TracedAs("agent.registry.getWorkflowName", { recordParams: true, recordResult: true })
305
+ ], AgentRegistry.prototype, "getWorkflowName", null);
285
306
  __legacyDecorateClassTS([
286
307
  TracedAs("agent.registry.load", { recordParams: false, recordResult: true, log: true })
287
308
  ], AgentRegistry.prototype, "load", null);
@@ -0,0 +1,61 @@
1
+ // src/env/mcp/npm-prefix/index.ts
2
+ import fs from "fs";
3
+ import { execSync } from "child_process";
4
+ import os from "os";
5
+ import path from "path";
6
+ function pathExistsSync(p) {
7
+ try {
8
+ fs.accessSync(p, fs.constants.F_OK);
9
+ return true;
10
+ } catch {
11
+ return false;
12
+ }
13
+ }
14
+ function getFallbackNpmPrefixPath() {
15
+ return path.join(os.homedir(), ".local", "share", "roy-agent", "npm-prefix");
16
+ }
17
+ function isUsableNpmPrefix(prefix) {
18
+ return pathExistsSync(path.join(prefix, "lib")) || pathExistsSync(path.join(prefix, "bin"));
19
+ }
20
+ function ensureNpmPrefixDirs(prefix) {
21
+ fs.mkdirSync(path.join(prefix, "lib"), { recursive: true });
22
+ fs.mkdirSync(path.join(prefix, "bin"), { recursive: true });
23
+ }
24
+ function ensureFallbackNpmPrefix() {
25
+ const fallback = getFallbackNpmPrefixPath();
26
+ ensureNpmPrefixDirs(fallback);
27
+ return fallback;
28
+ }
29
+ function readNpmConfigPrefix() {
30
+ try {
31
+ const prefix = execSync("npm config get prefix", {
32
+ encoding: "utf8",
33
+ stdio: ["ignore", "pipe", "ignore"]
34
+ }).trim();
35
+ return prefix || undefined;
36
+ } catch {
37
+ return;
38
+ }
39
+ }
40
+ function resolveNpmPrefix() {
41
+ const candidates = [
42
+ process.env.NPM_CONFIG_PREFIX,
43
+ process.env.npm_config_prefix,
44
+ readNpmConfigPrefix(),
45
+ path.join(os.homedir(), ".npm-global")
46
+ ].filter(Boolean);
47
+ for (const prefix of candidates) {
48
+ if (isUsableNpmPrefix(prefix)) {
49
+ return prefix;
50
+ }
51
+ }
52
+ return ensureFallbackNpmPrefix();
53
+ }
54
+ function resolveGlobalNodeModulesPath() {
55
+ return path.join(resolveNpmPrefix(), "lib", "node_modules");
56
+ }
57
+ function resolveGlobalBinPath() {
58
+ return path.join(resolveNpmPrefix(), "bin");
59
+ }
60
+
61
+ export { getFallbackNpmPrefixPath, isUsableNpmPrefix, ensureNpmPrefixDirs, ensureFallbackNpmPrefix, readNpmConfigPrefix, resolveNpmPrefix, resolveGlobalNodeModulesPath, resolveGlobalBinPath };
@@ -1,9 +1,13 @@
1
1
  import {
2
2
  DEFAULT_SUBAGENT_PROMPT
3
- } from "./roy-agent-core-fg3j215p.js";
3
+ } from "./roy-agent-core-emk3q2nt.js";
4
4
  import {
5
5
  TaskHookPoints
6
6
  } from "./roy-agent-core-92z6t4he.js";
7
+ import {
8
+ TracedAs,
9
+ init_decorator
10
+ } from "./roy-agent-core-q5qj0fes.js";
7
11
  import {
8
12
  globalHookManager,
9
13
  init_global_hook_manager
@@ -12,9 +16,13 @@ import {
12
16
  createLogger,
13
17
  init_logger
14
18
  } from "./roy-agent-core-10n2jh7p.js";
19
+ import {
20
+ __legacyDecorateClassTS
21
+ } from "./roy-agent-core-fs0mn2jk.js";
15
22
 
16
23
  // src/env/task/delegate/delegate-tool.ts
17
24
  init_logger();
25
+ init_decorator();
18
26
  import { z } from "zod";
19
27
 
20
28
  // src/env/task/delegate/subagent-resolver.ts
@@ -65,8 +73,14 @@ ${customAgentNote}
65
73
  }
66
74
  function listKnownSubagentDescriptions(registry) {
67
75
  const builtInLines = builtInSubAgents.map((agent) => `- ${agent.id}: ${agent.description}`);
68
- const registryAgents = registry?.listAgentsByType("sub") ?? [];
69
- const customLines = registryAgents.filter((agent) => !builtInSubAgents.some((builtIn) => builtIn.id === agent.name)).map((agent) => `- ${agent.name}: ${agent.description || "Custom agent"}`);
76
+ const registryAgents = registry?.list() ?? [];
77
+ const customLines = registryAgents.filter((agent) => !builtInSubAgents.some((builtIn) => builtIn.id === agent.name)).map((agent) => {
78
+ if (agent.type === "workflow") {
79
+ const workflowInfo = agent.workflow ? ` (workflow: ${agent.workflow})` : "";
80
+ return `- ${agent.name}: ${agent.description || "Workflow agent"}${workflowInfo}`;
81
+ }
82
+ return `- ${agent.name}: ${agent.description || "Custom agent"}`;
83
+ });
70
84
  const lines = [...builtInLines, ...customLines];
71
85
  const guidance = buildAgentSelectionGuide({ hasCustomAgents: customLines.length > 0 });
72
86
  return lines.join(`
@@ -163,6 +177,14 @@ function getSubAgentSpec(id) {
163
177
  return builtInSubAgents.find((agent) => agent.id === id);
164
178
  }
165
179
  function ensureSubAgentRegistered(agentComponent, subagentType, basePrompt, subAgent, deniedTools) {
180
+ const registry = agentComponent.getRegistry?.();
181
+ if (registry) {
182
+ const agentDef = registry.get(subagentType);
183
+ if (agentDef?.type === "workflow") {
184
+ logger.debug(`[delegate] Skipping registration for workflow agent: ${subagentType}`);
185
+ return null;
186
+ }
187
+ }
166
188
  let agentInstance = agentComponent.getAgent(subagentType);
167
189
  if (!agentInstance) {
168
190
  const agentConfig = {
@@ -444,6 +466,8 @@ ${prompt}
444
466
  deniedTools
445
467
  } : undefined;
446
468
  ensureSubAgentRegistered(agentComponent, subagentType, basePrompt, subAgentForRegister, deniedTools);
469
+ const isWorkflowAgent = registry?.get(subagentType)?.type === "workflow";
470
+ const delegateQuery = isWorkflowAgent ? prompt : fullPrompt;
447
471
  return new Promise((resolve, reject) => {
448
472
  const timer = setTimeout(() => {
449
473
  reject(new Error(`Task execution timeout after ${timeoutMs}ms`));
@@ -452,7 +476,7 @@ ${prompt}
452
476
  clearTimeout(timer);
453
477
  reject(new Error("Task execution stopped"));
454
478
  });
455
- this.env.handle_query?.(fullPrompt, {
479
+ this.env.handle_query?.(delegateQuery, {
456
480
  sessionId,
457
481
  deniedTools: deniedTools.length > 0 ? deniedTools : undefined,
458
482
  agentType: subagentType
@@ -509,6 +533,9 @@ ${prompt}
509
533
  logger.info(`[BackgroundTaskManager] Disposed`);
510
534
  }
511
535
  }
536
+ __legacyDecorateClassTS([
537
+ TracedAs("delegate.executeWithAbort", { recordParams: true, recordResult: true, log: true })
538
+ ], BackgroundTaskManager.prototype, "executeWithAbort", null);
512
539
  function getAgentRegistry(taskComponent) {
513
540
  const agentComponent = taskComponent.env?.getComponent?.("agent");
514
541
  return agentComponent?.getRegistry?.();
@@ -675,11 +702,13 @@ ${prompt}
675
702
  deniedTools
676
703
  } : undefined;
677
704
  ensureSubAgentRegistered(agentComponent, subagentType, basePrompt, subAgentForRegister, deniedTools);
705
+ const isWorkflowAgent = registry?.get(subagentType)?.type === "workflow";
706
+ const delegateQuery = isWorkflowAgent ? prompt : fullPrompt;
678
707
  const timeoutMs = timeout || DEFAULT_TIMEOUT;
679
708
  let result;
680
709
  try {
681
710
  result = await Promise.race([
682
- taskComponent.env?.handle_query?.(fullPrompt, {
711
+ taskComponent.env?.handle_query?.(delegateQuery, {
683
712
  sessionId: subSession.id,
684
713
  deniedTools: deniedTools.length > 0 ? deniedTools : undefined,
685
714
  agentType: subagentType
@@ -8,6 +8,10 @@ import {
8
8
  AskUserError,
9
9
  init_workflow_hil
10
10
  } from "./roy-agent-core-e25xkv53.js";
11
+ import {
12
+ init_decorator,
13
+ wrapFunction
14
+ } from "./roy-agent-core-q5qj0fes.js";
11
15
  import {
12
16
  globalHookManager,
13
17
  init_global_hook_manager
@@ -57,7 +61,7 @@ function registerWorkflowJsonOutputPlugin(llmComponent) {
57
61
  description: "Extract structured JSON after ReAct via a dedicated LLM invoke",
58
62
  execute: async (wrapper) => {
59
63
  const hookCtx = wrapper.data;
60
- await runWorkflowJsonOutputExtraction(hookCtx, llmComponent);
64
+ await tracedRunWorkflowJsonOutputExtraction(hookCtx, llmComponent);
61
65
  }
62
66
  });
63
67
  logger.info("Workflow JSON output plugin registered on agent:after.react");
@@ -175,16 +179,19 @@ function toLLMMessage(msg) {
175
179
  }
176
180
  return { role: msg.role, content: "" };
177
181
  }
178
- var logger, WORKFLOW_JSON_OUTPUT_SOURCE_ID = "workflow", WORKFLOW_JSON_OUTPUT_PLUGIN_NAME = "json-output", WORKFLOW_JSON_OUTPUT_PLUGIN_KEY, HOOK_POINT = "agent:after.react", HOOK_NAME, registered = false;
182
+ var logger, WORKFLOW_JSON_OUTPUT_SOURCE_ID = "workflow", WORKFLOW_JSON_OUTPUT_PLUGIN_NAME = "json-output", WORKFLOW_JSON_OUTPUT_PLUGIN_KEY, HOOK_POINT = "agent:after.react", HOOK_NAME, registered = false, tracedRunWorkflowJsonOutputExtraction, tracedExtractStructuredJsonViaLlm;
179
183
  var init_workflow_json_output_plugin = __esm(() => {
180
184
  init_global_hook_manager();
181
185
  init_workflow_hil();
182
186
  init_submit_json_output_tool();
183
187
  init_output_schema_hint();
184
188
  init_logger();
189
+ init_decorator();
185
190
  logger = createLogger("WorkflowJsonOutputPlugin");
186
191
  WORKFLOW_JSON_OUTPUT_PLUGIN_KEY = `${WORKFLOW_JSON_OUTPUT_SOURCE_ID}:${WORKFLOW_JSON_OUTPUT_PLUGIN_NAME}`;
187
192
  HOOK_NAME = `${WORKFLOW_JSON_OUTPUT_PLUGIN_NAME}:${HOOK_POINT}`;
193
+ tracedRunWorkflowJsonOutputExtraction = wrapFunction(runWorkflowJsonOutputExtraction, "workflow.json_output.extraction", { recordParams: true, recordResult: true, log: true });
194
+ tracedExtractStructuredJsonViaLlm = wrapFunction(extractStructuredJsonViaLlm, "workflow.json_output.extract_via_llm", { recordParams: false, recordResult: true, log: true });
188
195
  });
189
196
 
190
- export { WORKFLOW_JSON_OUTPUT_SOURCE_ID, WORKFLOW_JSON_OUTPUT_PLUGIN_NAME, WORKFLOW_JSON_OUTPUT_PLUGIN_KEY, isWorkflowJsonOutputEnabled, registerWorkflowJsonOutputPlugin, unregisterWorkflowJsonOutputPlugin, runWorkflowJsonOutputExtraction, extractStructuredJsonViaLlm, init_workflow_json_output_plugin };
197
+ export { WORKFLOW_JSON_OUTPUT_SOURCE_ID, WORKFLOW_JSON_OUTPUT_PLUGIN_NAME, WORKFLOW_JSON_OUTPUT_PLUGIN_KEY, isWorkflowJsonOutputEnabled, registerWorkflowJsonOutputPlugin, unregisterWorkflowJsonOutputPlugin, runWorkflowJsonOutputExtraction, extractStructuredJsonViaLlm, tracedRunWorkflowJsonOutputExtraction, tracedExtractStructuredJsonViaLlm, init_workflow_json_output_plugin };