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

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 (73) hide show
  1. package/dist/config/index.js +5 -5
  2. package/dist/env/agent/index.js +5 -5
  3. package/dist/env/commands/index.js +5 -5
  4. package/dist/env/context/index.js +4 -1
  5. package/dist/env/debug/index.js +5 -5
  6. package/dist/env/event-source/index.js +7 -7
  7. package/dist/env/hook/index.js +3 -3
  8. package/dist/env/index.js +24 -20
  9. package/dist/env/llm/index.js +5 -5
  10. package/dist/env/log-trace/index.js +5 -5
  11. package/dist/env/mcp/index.js +20 -6
  12. package/dist/env/memory/index.js +5 -5
  13. package/dist/env/plugin/index.js +5 -5
  14. package/dist/env/prompt/index.js +5 -5
  15. package/dist/env/session/index.js +6 -6
  16. package/dist/env/session/storage/index.js +1 -1
  17. package/dist/env/skill/index.js +5 -5
  18. package/dist/env/task/delegate/index.js +3 -3
  19. package/dist/env/task/index.js +6 -6
  20. package/dist/env/task/plugins/index.js +2 -2
  21. package/dist/env/tool/built-in/index.js +1 -1
  22. package/dist/env/tool/index.js +6 -6
  23. package/dist/env/workflow/decorators/index.js +1 -1
  24. package/dist/env/workflow/engine/index.js +10 -4
  25. package/dist/env/workflow/index.js +42 -24
  26. package/dist/env/workflow/nodes/index.js +5 -1
  27. package/dist/env/workflow/tools/index.js +14 -0
  28. package/dist/env/workflow/types/index.js +16 -2
  29. package/dist/env/workflow/utils/index.js +15 -196
  30. package/dist/index.js +35 -31
  31. package/dist/shared/@ai-setting/{roy-agent-core-kajktp3d.js → roy-agent-core-20fm423j.js} +47 -26
  32. package/dist/shared/@ai-setting/{roy-agent-core-ffb9fq4v.js → roy-agent-core-2vhsccvz.js} +54 -12
  33. package/dist/shared/@ai-setting/{roy-agent-core-69jskqjg.js → roy-agent-core-44g4dhzg.js} +75 -7
  34. package/dist/shared/@ai-setting/{roy-agent-core-e9fdm13a.js → roy-agent-core-4gmxjdhn.js} +4 -2
  35. package/dist/shared/@ai-setting/{roy-agent-core-b4wd9tn6.js → roy-agent-core-4k9a823d.js} +1 -1
  36. package/dist/shared/@ai-setting/roy-agent-core-68qy97r3.js +31 -0
  37. package/dist/shared/@ai-setting/roy-agent-core-6atd905e.js +42 -0
  38. package/dist/shared/@ai-setting/{roy-agent-core-4jqq077c.js → roy-agent-core-6e3wz81d.js} +2 -2
  39. package/dist/shared/@ai-setting/{roy-agent-core-pwkk12p4.js → roy-agent-core-6mcb7nqa.js} +60 -0
  40. package/dist/shared/@ai-setting/roy-agent-core-6vxg2gmr.js +321 -0
  41. package/dist/shared/@ai-setting/{roy-agent-core-9p43ap7h.js → roy-agent-core-8y804aat.js} +4 -2
  42. package/dist/shared/@ai-setting/{roy-agent-core-0rtxwr28.js → roy-agent-core-9bmtxmp6.js} +77 -120
  43. package/dist/shared/@ai-setting/{roy-agent-core-r6rwsr54.js → roy-agent-core-9p604xjf.js} +29 -9
  44. package/dist/shared/@ai-setting/{roy-agent-core-z1xf2fdk.js → roy-agent-core-a67e90d1.js} +6 -4
  45. package/dist/shared/@ai-setting/{roy-agent-core-xkb264a8.js → roy-agent-core-bp3xggmb.js} +192 -26
  46. package/dist/shared/@ai-setting/{roy-agent-core-zrja5v78.js → roy-agent-core-ce9w0j8n.js} +10 -2
  47. package/dist/shared/@ai-setting/{roy-agent-core-bmr6bdfb.js → roy-agent-core-cr8xer31.js} +15 -8
  48. package/dist/shared/@ai-setting/roy-agent-core-dbxm76wf.js +190 -0
  49. package/dist/shared/@ai-setting/{roy-agent-core-nj8yerg9.js → roy-agent-core-eftqdsy5.js} +1 -1
  50. package/dist/shared/@ai-setting/{roy-agent-core-7fgf85wc.js → roy-agent-core-h0x19xgn.js} +6 -7
  51. package/dist/shared/@ai-setting/{roy-agent-core-psvwzdhj.js → roy-agent-core-hdszq729.js} +9 -5
  52. package/dist/shared/@ai-setting/{roy-agent-core-dxbsc1zy.js → roy-agent-core-ja9qhg6d.js} +1 -1
  53. package/dist/shared/@ai-setting/{roy-agent-core-cevpwnq7.js → roy-agent-core-mjbfgqen.js} +5 -3
  54. package/dist/shared/@ai-setting/roy-agent-core-nhfy3p8q.js +132 -0
  55. package/dist/shared/@ai-setting/{roy-agent-core-2jnzv9at.js → roy-agent-core-nn9dmffw.js} +629 -288
  56. package/dist/shared/@ai-setting/roy-agent-core-qnrf2aw6.js +441 -0
  57. package/dist/shared/@ai-setting/{roy-agent-core-ee6nnnqw.js → roy-agent-core-r9hq4cjx.js} +8 -1
  58. package/dist/shared/@ai-setting/{roy-agent-core-jqy2mdyq.js → roy-agent-core-rgj6hq15.js} +52 -41
  59. package/dist/shared/@ai-setting/{roy-agent-core-z33en0cz.js → roy-agent-core-rm3hay00.js} +15 -2
  60. package/dist/shared/@ai-setting/{roy-agent-core-e130w7mv.js → roy-agent-core-rx74rye7.js} +5 -3
  61. package/dist/shared/@ai-setting/{roy-agent-core-pxcrzyv9.js → roy-agent-core-sk535ft2.js} +1 -1
  62. package/dist/shared/@ai-setting/roy-agent-core-v002ynpa.js +435 -0
  63. package/dist/shared/@ai-setting/{roy-agent-core-2dhd60aw.js → roy-agent-core-vdwvamre.js} +10 -0
  64. package/dist/shared/@ai-setting/{roy-agent-core-1zq3p19q.js → roy-agent-core-w64zachx.js} +8 -4
  65. package/dist/shared/@ai-setting/roy-agent-core-ye0z728h.js +18 -0
  66. package/dist/shared/@ai-setting/{roy-agent-core-rsybkb38.js → roy-agent-core-ysvh8er9.js} +36 -39
  67. package/dist/shared/@ai-setting/{roy-agent-core-9yxb3ty9.js → roy-agent-core-z5sxe4p7.js} +5 -1
  68. package/dist/shared/@ai-setting/{roy-agent-core-eg6nv09z.js → roy-agent-core-ztx5eh72.js} +1 -1
  69. package/dist/shared/@ai-setting/{roy-agent-core-nqgrjja0.js → roy-agent-core-zwq6vhpj.js} +1 -1
  70. package/package.json +1 -1
  71. package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
  72. package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +0 -11
  73. package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
@@ -17,13 +17,15 @@ import {
17
17
  } from "./roy-agent-core-qxhq8ven.js";
18
18
  import {
19
19
  BaseComponent
20
- } from "./roy-agent-core-4jqq077c.js";
20
+ } from "./roy-agent-core-6e3wz81d.js";
21
21
  import {
22
- globalHookManager
23
- } from "./roy-agent-core-jqy2mdyq.js";
22
+ globalHookManager,
23
+ init_global_hook_manager
24
+ } from "./roy-agent-core-rgj6hq15.js";
24
25
  import {
26
+ init_context,
25
27
  runWithEnvContextAsync
26
- } from "./roy-agent-core-z33en0cz.js";
28
+ } from "./roy-agent-core-rm3hay00.js";
27
29
  import {
28
30
  createLogger,
29
31
  init_logger
@@ -67,6 +69,8 @@ var AGENT_CONFIG_REGISTRATION = {
67
69
 
68
70
  // src/env/agent/agent-component.ts
69
71
  init_decorator();
72
+ init_global_hook_manager();
73
+ init_context();
70
74
  init_workflow_hil();
71
75
  var logger = createLogger("agent:component");
72
76
  function toLLMMessage(msg) {
@@ -579,10 +583,12 @@ class AgentComponent extends BaseComponent {
579
583
  model: effectiveContext.model
580
584
  }
581
585
  });
582
- this.pushMessage(hookCtx, {
583
- role: "user",
584
- content: query
585
- });
586
+ if (query) {
587
+ this.pushMessage(hookCtx, {
588
+ role: "user",
589
+ content: query
590
+ });
591
+ }
586
592
  await this.executePluginHooks(agent, "agent:before.start", hookCtx);
587
593
  if (hookCtx._stopped) {
588
594
  return this.finalizeResult(result, hookCtx);
@@ -877,6 +883,7 @@ class AgentComponent extends BaseComponent {
877
883
  if (iteration >= agent.config.maxIterations && !result.finalText) {
878
884
  result.finalText = "Maximum iterations reached.";
879
885
  }
886
+ const newMessages = hookCtx.messages.slice(historyMessageCount);
880
887
  const reactContext = {
881
888
  messages: hookCtx.messages,
882
889
  sessionId: effectiveContext.sessionId,
@@ -886,6 +893,9 @@ class AgentComponent extends BaseComponent {
886
893
  ...hookCtx,
887
894
  ...reactContext
888
895
  });
896
+ if (hookCtx.structuredOutputExtracted) {
897
+ result.structuredOutput = hookCtx.structuredOutputExtracted;
898
+ }
889
899
  await this.executePluginHooks(agent, "agent:after.complete", hookCtx);
890
900
  if (this.aborted.get(runId) === true || hookCtx._stopped) {
891
901
  agent.status = "stopped";
@@ -913,7 +923,6 @@ class AgentComponent extends BaseComponent {
913
923
  }
914
924
  });
915
925
  }
916
- let newMessages = hookCtx.messages.slice(historyMessageCount);
917
926
  logger.info(`Agent run completed: ${agentName}`, {
918
927
  iterations: result.iterations,
919
928
  hasError: !!result.error,
@@ -1030,6 +1039,14 @@ ${ctx.context.additionInfo}`
1030
1039
  };
1031
1040
  }
1032
1041
  try {
1042
+ this.pushEnvEvent({
1043
+ type: "tool.call",
1044
+ payload: {
1045
+ id: toolCall.id,
1046
+ name: toolName,
1047
+ arguments: toolCall.arguments
1048
+ }
1049
+ });
1033
1050
  const toolContext = {
1034
1051
  session_id: ctx.context.sessionId,
1035
1052
  message_id: ctx.context.messageId,
@@ -1169,6 +1186,9 @@ ${ctx.context.additionInfo}`
1169
1186
  if (msg.role === "system") {
1170
1187
  continue;
1171
1188
  }
1189
+ if (msg.role === "user" && this.isEmptyMessage(msg.content)) {
1190
+ continue;
1191
+ }
1172
1192
  if (msg.role === "assistant" || msg.role === "tool") {
1173
1193
  if (this.isEmptyMessage(msg.content)) {
1174
1194
  continue;
@@ -7,13 +7,14 @@ import {
7
7
  } from "./roy-agent-core-qxhq8ven.js";
8
8
  import {
9
9
  BaseComponent
10
- } from "./roy-agent-core-4jqq077c.js";
10
+ } from "./roy-agent-core-6e3wz81d.js";
11
11
  import {
12
12
  createHook
13
- } from "./roy-agent-core-2dhd60aw.js";
13
+ } from "./roy-agent-core-vdwvamre.js";
14
14
  import {
15
- globalHookManager
16
- } from "./roy-agent-core-jqy2mdyq.js";
15
+ globalHookManager,
16
+ init_global_hook_manager
17
+ } from "./roy-agent-core-rgj6hq15.js";
17
18
  import {
18
19
  createLogger,
19
20
  init_logger
@@ -692,6 +693,7 @@ var PROMPT_CONFIG_REGISTRATION = {
692
693
  };
693
694
 
694
695
  // src/env/prompt/prompt-component.ts
696
+ init_global_hook_manager();
695
697
  var logger2 = createLogger("prompt");
696
698
 
697
699
  class PromptComponent extends BaseComponent {
@@ -10,7 +10,7 @@ import {
10
10
  } from "./roy-agent-core-qxhq8ven.js";
11
11
  import {
12
12
  BaseComponent
13
- } from "./roy-agent-core-4jqq077c.js";
13
+ } from "./roy-agent-core-6e3wz81d.js";
14
14
  import {
15
15
  createLogger,
16
16
  init_logger
@@ -21,6 +21,7 @@ import { z } from "zod";
21
21
  var McpServerLocalConfigSchema = z.object({
22
22
  type: z.literal("local"),
23
23
  command: z.array(z.string()).min(1),
24
+ cwd: z.string().optional(),
24
25
  environment: z.record(z.string(), z.string()).optional(),
25
26
  enabled: z.boolean().optional().default(true),
26
27
  timeout: z.number().int().positive().optional()
@@ -84,8 +85,148 @@ init_logger();
84
85
 
85
86
  // src/env/mcp/scanner.ts
86
87
  init_logger();
87
- import fs from "fs/promises";
88
+ import fs3 from "fs/promises";
89
+ import path4 from "path";
90
+
91
+ // src/env/mcp/command-resolver.ts
92
+ import fs2 from "fs";
93
+ import path3 from "path";
94
+
95
+ // src/env/mcp/npm-prefix.ts
96
+ import fs from "fs";
97
+ import { execSync } from "child_process";
98
+ import os2 from "os";
88
99
  import path2 from "path";
100
+ function pathExistsSync(p) {
101
+ try {
102
+ fs.accessSync(p, fs.constants.F_OK);
103
+ return true;
104
+ } catch {
105
+ return false;
106
+ }
107
+ }
108
+ function getFallbackNpmPrefixPath() {
109
+ return path2.join(os2.homedir(), ".local", "share", "roy-agent", "npm-prefix");
110
+ }
111
+ function isUsableNpmPrefix(prefix) {
112
+ return pathExistsSync(path2.join(prefix, "lib")) || pathExistsSync(path2.join(prefix, "bin"));
113
+ }
114
+ function ensureNpmPrefixDirs(prefix) {
115
+ fs.mkdirSync(path2.join(prefix, "lib"), { recursive: true });
116
+ fs.mkdirSync(path2.join(prefix, "bin"), { recursive: true });
117
+ }
118
+ function ensureFallbackNpmPrefix() {
119
+ const fallback = getFallbackNpmPrefixPath();
120
+ ensureNpmPrefixDirs(fallback);
121
+ return fallback;
122
+ }
123
+ function readNpmConfigPrefix() {
124
+ try {
125
+ const prefix = execSync("npm config get prefix", {
126
+ encoding: "utf8",
127
+ stdio: ["ignore", "pipe", "ignore"]
128
+ }).trim();
129
+ return prefix || undefined;
130
+ } catch {
131
+ return;
132
+ }
133
+ }
134
+ function resolveNpmPrefix() {
135
+ const candidates = [
136
+ process.env.NPM_CONFIG_PREFIX,
137
+ process.env.npm_config_prefix,
138
+ readNpmConfigPrefix(),
139
+ path2.join(os2.homedir(), ".npm-global")
140
+ ].filter(Boolean);
141
+ for (const prefix of candidates) {
142
+ if (isUsableNpmPrefix(prefix)) {
143
+ return prefix;
144
+ }
145
+ }
146
+ return ensureFallbackNpmPrefix();
147
+ }
148
+ function resolveGlobalNodeModulesPath() {
149
+ return path2.join(resolveNpmPrefix(), "lib", "node_modules");
150
+ }
151
+ function resolveGlobalBinPath() {
152
+ return path2.join(resolveNpmPrefix(), "bin");
153
+ }
154
+
155
+ // src/env/mcp/command-resolver.ts
156
+ var PACKAGE_RUNNERS = new Set(["npx", "npm", "bunx", "yarn"]);
157
+ function pathExistsSync2(p) {
158
+ try {
159
+ fs2.accessSync(p, fs2.constants.F_OK);
160
+ return true;
161
+ } catch {
162
+ return false;
163
+ }
164
+ }
165
+ function extractPackageName(command) {
166
+ if (command.length < 2) {
167
+ return;
168
+ }
169
+ const runner = path3.basename(command[0]);
170
+ if (runner === "npx" || runner === "bunx") {
171
+ return command[1];
172
+ }
173
+ if (runner === "npm" && command[1] === "exec") {
174
+ const separatorIndex = command.indexOf("--");
175
+ if (separatorIndex >= 0) {
176
+ return command[separatorIndex + 1];
177
+ }
178
+ return command[2];
179
+ }
180
+ if (runner === "yarn" && command[1] === "dlx") {
181
+ return command[2];
182
+ }
183
+ return;
184
+ }
185
+ function isPackageRunnerCommand(command) {
186
+ if (command.length < 2) {
187
+ return false;
188
+ }
189
+ const runner = path3.basename(command[0]);
190
+ if (!PACKAGE_RUNNERS.has(runner)) {
191
+ return false;
192
+ }
193
+ if (runner === "npm") {
194
+ return command[1] === "exec";
195
+ }
196
+ if (runner === "yarn") {
197
+ return command[1] === "dlx";
198
+ }
199
+ return true;
200
+ }
201
+ function resolvePackageRunnerCommand(command, serverDir) {
202
+ if (!isPackageRunnerCommand(command)) {
203
+ return command;
204
+ }
205
+ const packageName = extractPackageName(command);
206
+ if (!packageName) {
207
+ return command;
208
+ }
209
+ const localBin = path3.join(serverDir, "node_modules", ".bin", packageName);
210
+ if (pathExistsSync2(localBin)) {
211
+ return [localBin];
212
+ }
213
+ return command;
214
+ }
215
+ function augmentNpmEnvForPackageRunner(command, env) {
216
+ if (!isPackageRunnerCommand(command)) {
217
+ return env;
218
+ }
219
+ const prefix = env.NPM_CONFIG_PREFIX ?? process.env.NPM_CONFIG_PREFIX ?? process.env.npm_config_prefix;
220
+ if (prefix && isUsableNpmPrefix(prefix)) {
221
+ return env;
222
+ }
223
+ return {
224
+ ...env,
225
+ NPM_CONFIG_PREFIX: ensureFallbackNpmPrefix()
226
+ };
227
+ }
228
+
229
+ // src/env/mcp/scanner.ts
89
230
  var logger = createLogger("mcp-scanner");
90
231
  var ENTRY_SCRIPT_CANDIDATES = [
91
232
  "server.mjs",
@@ -104,13 +245,13 @@ var ENTRY_SCRIPT_CANDIDATES = [
104
245
  function expandPath(inputPath) {
105
246
  if (inputPath.startsWith("~/")) {
106
247
  const home = process.env.HOME || process.env.USERPROFILE || "";
107
- return path2.join(home, inputPath.slice(2));
248
+ return path4.join(home, inputPath.slice(2));
108
249
  }
109
- return path2.resolve(inputPath);
250
+ return path4.resolve(inputPath);
110
251
  }
111
252
  async function pathExists(p) {
112
253
  try {
113
- await fs.access(p);
254
+ await fs3.access(p);
114
255
  return true;
115
256
  } catch {
116
257
  return false;
@@ -118,7 +259,7 @@ async function pathExists(p) {
118
259
  }
119
260
  async function parseConfigJsonc(configPath) {
120
261
  try {
121
- const configContent = await fs.readFile(configPath, "utf-8");
262
+ const configContent = await fs3.readFile(configPath, "utf-8");
122
263
  const cleaned = configContent.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
123
264
  return JSON.parse(cleaned);
124
265
  } catch (error) {
@@ -126,6 +267,12 @@ async function parseConfigJsonc(configPath) {
126
267
  return;
127
268
  }
128
269
  }
270
+ function relativeCommandMatchesEntry(cmdPath, entryPath, serverDir) {
271
+ if (path4.resolve(serverDir, cmdPath) === entryPath) {
272
+ return true;
273
+ }
274
+ return ENTRY_SCRIPT_CANDIDATES.some((candidate) => cmdPath === candidate && entryPath === path4.join(serverDir, candidate));
275
+ }
129
276
  function buildDefaultCommand(entryPath, directoryConfig, serverDir) {
130
277
  if (directoryConfig?.command) {
131
278
  const cmd = directoryConfig.command;
@@ -134,15 +281,14 @@ function buildDefaultCommand(entryPath, directoryConfig, serverDir) {
134
281
  return cmd;
135
282
  }
136
283
  if (cmdPath && entryPath) {
137
- const resolvedConfigPath = path2.resolve(serverDir, cmdPath);
138
- if (resolvedConfigPath === entryPath || cmdPath === "src/index.ts" || cmdPath === "src/index.js") {
284
+ if (relativeCommandMatchesEntry(cmdPath, entryPath, serverDir)) {
139
285
  return ["bun", "run", entryPath];
140
286
  }
141
287
  }
142
288
  if (entryPath) {
143
289
  return ["bun", "run", entryPath];
144
290
  }
145
- return cmd;
291
+ return resolvePackageRunnerCommand(cmd, serverDir);
146
292
  }
147
293
  return entryPath ? ["bun", "run", entryPath] : undefined;
148
294
  }
@@ -170,10 +316,10 @@ class McpScanner {
170
316
  }
171
317
  logger.info(`[McpScanner] Scanning: ${expandedPath}`);
172
318
  try {
173
- const entries = await fs.readdir(expandedPath, { withFileTypes: true });
319
+ const entries = await fs3.readdir(expandedPath, { withFileTypes: true });
174
320
  for (const entry of entries) {
175
- const fullPath = path2.join(expandedPath, entry.name);
176
- const stat = await fs.stat(fullPath);
321
+ const fullPath = path4.join(expandedPath, entry.name);
322
+ const stat = await fs3.stat(fullPath);
177
323
  if (!stat.isDirectory())
178
324
  continue;
179
325
  await this.discoverServer(entry.name, fullPath, mcpPath.type);
@@ -184,8 +330,8 @@ class McpScanner {
184
330
  }
185
331
  async discoverServer(name, serverDir, sourceType) {
186
332
  const entryPath = await this.findEntryScript(serverDir);
187
- const configPath = path2.join(serverDir, "config.jsonc");
188
- const packagePath = path2.join(serverDir, "package.json");
333
+ const configPath = path4.join(serverDir, "config.jsonc");
334
+ const packagePath = path4.join(serverDir, "package.json");
189
335
  let directoryConfig;
190
336
  if (await pathExists(configPath)) {
191
337
  directoryConfig = await parseConfigJsonc(configPath);
@@ -193,6 +339,7 @@ class McpScanner {
193
339
  const defaultCommand = buildDefaultCommand(entryPath, directoryConfig, serverDir);
194
340
  const server = {
195
341
  name,
342
+ serverDir,
196
343
  entryPath: entryPath || undefined,
197
344
  configPath: await pathExists(configPath) ? configPath : undefined,
198
345
  packagePath: await pathExists(packagePath) ? packagePath : undefined,
@@ -208,7 +355,7 @@ class McpScanner {
208
355
  }
209
356
  async findEntryScript(serverDir) {
210
357
  for (const candidate of ENTRY_SCRIPT_CANDIDATES) {
211
- const entryPath = path2.join(serverDir, candidate);
358
+ const entryPath = path4.join(serverDir, candidate);
212
359
  if (await pathExists(entryPath)) {
213
360
  return entryPath;
214
361
  }
@@ -222,14 +369,14 @@ class McpScanner {
222
369
 
223
370
  // src/env/mcp/loader.ts
224
371
  init_logger();
225
- import fs2 from "fs/promises";
226
- import path3 from "path";
227
- import os2 from "os";
372
+ import fs4 from "fs/promises";
373
+ import path5 from "path";
374
+ import os3 from "os";
228
375
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
229
376
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
230
377
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
231
378
  var logger2 = createLogger("mcp-loader");
232
- var AUTH_JSON_PATH = path3.join(os2.homedir(), ".roy-agent", "auth.json");
379
+ var AUTH_JSON_PATH = path5.join(os3.homedir(), ".roy-agent", "auth.json");
233
380
 
234
381
  class McpLoader {
235
382
  clients = new Map;
@@ -252,6 +399,7 @@ class McpLoader {
252
399
  const localConfig = {
253
400
  type: "local",
254
401
  command,
402
+ ...server.serverDir ? { cwd: server.serverDir } : {},
255
403
  environment: server.directoryConfig?.environment,
256
404
  enabled: server.directoryConfig?.enabled ?? true,
257
405
  timeout: server.directoryConfig?.timeout ?? this.defaultTimeout
@@ -290,13 +438,16 @@ class McpLoader {
290
438
  let transport;
291
439
  if (config.type === "local") {
292
440
  const localConfig = config;
293
- const env = { ...localConfig.environment };
441
+ const env = augmentNpmEnvForPackageRunner(localConfig.command, { ...localConfig.environment });
294
442
  await this.injectMinimaxEnv(env);
295
443
  transport = new StdioClientTransport({
296
444
  command: localConfig.command[0],
297
445
  args: localConfig.command.slice(1),
298
- env
446
+ env,
447
+ ...localConfig.cwd ? { cwd: localConfig.cwd } : {},
448
+ stderr: "pipe"
299
449
  });
450
+ this.attachStderrDrain(name, transport);
300
451
  client = new Client({ name, version: "1.0.0" });
301
452
  await client.connect(transport);
302
453
  } else {
@@ -325,6 +476,21 @@ class McpLoader {
325
476
  this.clients.delete(name);
326
477
  logger2.info(`[McpLoader] Disconnected from ${name}`);
327
478
  }
479
+ attachStderrDrain(serverName, transport) {
480
+ const stderrStream = transport.stderr;
481
+ if (!stderrStream) {
482
+ return;
483
+ }
484
+ stderrStream.on("data", (chunk) => {
485
+ const text = chunk.toString().trim();
486
+ if (text) {
487
+ logger2.debug(`[McpLoader] ${serverName} stderr: ${text}`);
488
+ }
489
+ });
490
+ stderrStream.on("error", (error) => {
491
+ logger2.debug(`[McpLoader] ${serverName} stderr stream error`, { error });
492
+ });
493
+ }
328
494
  async closeTransport(transport, name) {
329
495
  try {
330
496
  const transportAny = transport;
@@ -355,7 +521,7 @@ class McpLoader {
355
521
  }
356
522
  async loadMinimaxApiKey() {
357
523
  try {
358
- const content = await fs2.readFile(AUTH_JSON_PATH, "utf-8");
524
+ const content = await fs4.readFile(AUTH_JSON_PATH, "utf-8");
359
525
  const auth = JSON.parse(content);
360
526
  return auth.providers?.minimax?.apiKey;
361
527
  } catch (error) {
@@ -376,15 +542,15 @@ class McpLoader {
376
542
  }
377
543
 
378
544
  // src/env/mcp/mcp-config-registration.ts
379
- import path4 from "path";
380
- import os3 from "os";
545
+ import path6 from "path";
546
+ import os4 from "os";
381
547
  var MCP_DEFAULTS = {
382
548
  "mcp.enabled": true,
383
549
  "mcp.timeout": 30000,
384
550
  "mcp.mcpPaths": [
385
551
  {
386
552
  type: "user",
387
- path: path4.join(os3.homedir(), ".config", "roy-agent", "mcp")
553
+ path: path6.join(os4.homedir(), ".config", "roy-agent", "mcp")
388
554
  },
389
555
  {
390
556
  type: "project",
@@ -625,4 +791,4 @@ class McpComponent extends BaseComponent {
625
791
  await this.loadServers();
626
792
  }
627
793
  }
628
- export { McpServerLocalConfigSchema, McpServerRemoteConfigSchema, McpServerConfigSchema, DEFAULT_MCP_CONFIG, MCP_CONFIG_KEYS, getMcpPathPriority, McpScanner, McpLoader, McpComponent };
794
+ export { McpServerLocalConfigSchema, McpServerRemoteConfigSchema, McpServerConfigSchema, DEFAULT_MCP_CONFIG, MCP_CONFIG_KEYS, getMcpPathPriority, isUsableNpmPrefix, ensureFallbackNpmPrefix, resolveNpmPrefix, resolveGlobalNodeModulesPath, resolveGlobalBinPath, resolvePackageRunnerCommand, augmentNpmEnvForPackageRunner, McpScanner, McpLoader, McpComponent };
@@ -15,7 +15,7 @@ import {
15
15
  } from "./roy-agent-core-qxhq8ven.js";
16
16
  import {
17
17
  BaseComponent
18
- } from "./roy-agent-core-4jqq077c.js";
18
+ } from "./roy-agent-core-6e3wz81d.js";
19
19
  import {
20
20
  createLogger,
21
21
  init_logger
@@ -23,7 +23,7 @@ import {
23
23
  import {
24
24
  MemorySessionStore,
25
25
  SQLiteSessionStore
26
- } from "./roy-agent-core-pwkk12p4.js";
26
+ } from "./roy-agent-core-6mcb7nqa.js";
27
27
  import {
28
28
  __legacyDecorateClassTS
29
29
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -341,6 +341,14 @@ class SessionComponent extends BaseComponent {
341
341
  const messages = await this.store?.getMessages(sessionId, options?.offset, options?.limit);
342
342
  return messages ?? [];
343
343
  }
344
+ async updateMessage(sessionId, messageId, updates) {
345
+ try {
346
+ return await this.store?.updateMessage(sessionId, messageId, updates) ?? false;
347
+ } catch (error) {
348
+ logger.error(`[SessionComponent] Failed to update message: ${error}`);
349
+ return false;
350
+ }
351
+ }
344
352
  async getMessageCount(sessionId, includeArchived) {
345
353
  return this.store?.getMessageCount(sessionId, includeArchived) ?? 0;
346
354
  }
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  exports_node_registry_helper,
3
3
  init_node_registry_helper
4
- } from "./roy-agent-core-0rtxwr28.js";
4
+ } from "./roy-agent-core-9bmtxmp6.js";
5
5
  import {
6
6
  WorkflowEngine,
7
7
  exports_engine,
8
8
  init_engine
9
- } from "./roy-agent-core-2jnzv9at.js";
9
+ } from "./roy-agent-core-nn9dmffw.js";
10
10
  import {
11
11
  WorkflowService
12
12
  } from "./roy-agent-core-4t40mkpv.js";
@@ -15,7 +15,7 @@ import {
15
15
  } from "./roy-agent-core-0vbdz0x7.js";
16
16
  import {
17
17
  BaseComponent
18
- } from "./roy-agent-core-4jqq077c.js";
18
+ } from "./roy-agent-core-6e3wz81d.js";
19
19
  import {
20
20
  createLogger,
21
21
  init_logger
@@ -97,7 +97,7 @@ class WorkflowComponent extends BaseComponent {
97
97
  return;
98
98
  try {
99
99
  const { NodeRegistry } = await import("../../env/workflow/engine/index.js");
100
- const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-9yxb3ty9.js");
100
+ const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-z5sxe4p7.js");
101
101
  this.nodeRegistry = new NodeRegistry;
102
102
  registerDecoratorNodeType2(this.nodeRegistry);
103
103
  this.decoratorsRegistered = true;
@@ -115,6 +115,7 @@ class WorkflowComponent extends BaseComponent {
115
115
  const registry = new NodeRegistry({
116
116
  toolRegistry: options.toolComponent,
117
117
  agentComponent: options.env?.getComponent("agent"),
118
+ llmComponent: options.env?.getComponent("llm"),
118
119
  skillRegistry: skillRegistryAdapter,
119
120
  sessionComponent: sessionComponentForEngine
120
121
  });
@@ -127,22 +128,24 @@ class WorkflowComponent extends BaseComponent {
127
128
  }
128
129
  async runWorkflow(definition, input, options) {
129
130
  const { NodeRegistry } = await import("../../env/workflow/engine/index.js");
130
- const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-9yxb3ty9.js");
131
+ const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-z5sxe4p7.js");
131
132
  const toolComponent = this.toolComponent || this._workflowEnv?.getComponent("tool");
132
133
  const skillComponent = this._workflowEnv?.getComponent("skill");
133
134
  let agentRunner = this.agentRunner;
134
135
  if (!agentRunner && this._workflowEnv) {
135
136
  const agentComponent = this._workflowEnv.getComponent("agent");
137
+ const llmComponent = this._workflowEnv.getComponent("llm");
136
138
  if (agentComponent) {
137
- const { AgentComponentAdapter } = await import("./roy-agent-core-dh9d7a3m.js");
138
- agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent);
139
+ const { AgentComponentAdapter } = await import("./roy-agent-core-ye0z728h.js");
140
+ agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent, llmComponent);
139
141
  }
140
142
  }
141
143
  const registry = new NodeRegistry({
142
144
  toolRegistry: toolComponent,
143
145
  skillRegistry: skillComponent,
144
146
  agentRunner,
145
- sessionComponent: this.sessionComponent
147
+ sessionComponent: this.sessionComponent,
148
+ llmComponent: this._workflowEnv?.getComponent("llm")
146
149
  });
147
150
  registerDecoratorNodeType2(registry);
148
151
  const engine = new WorkflowEngine(registry);
@@ -204,6 +207,10 @@ class WorkflowComponent extends BaseComponent {
204
207
  const skillComponent = this.skillRegistry || this._workflowEnv?.getComponent("skill");
205
208
  const sessionComponent = this._workflowEnv?.getComponent("session");
206
209
  componentLogger.info(`initSqliteService - toolComponent: ${!!toolComponent}, llmComponent: ${!!llmComponent}, skillRegistry: ${!!skillComponent}, sessionComponent: ${!!sessionComponent}`);
210
+ if (llmComponent) {
211
+ const { registerWorkflowJsonOutputPlugin } = await import("./roy-agent-core-68qy97r3.js");
212
+ registerWorkflowJsonOutputPlugin(llmComponent);
213
+ }
207
214
  this.createService({
208
215
  workflowRepository,
209
216
  toolComponent,