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

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 (61) hide show
  1. package/dist/config/index.js +5 -5
  2. package/dist/env/agent/index.js +6 -6
  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 +22 -6
  12. package/dist/env/mcp/npm-prefix/index.js +21 -0
  13. package/dist/env/memory/index.js +9 -9
  14. package/dist/env/plugin/index.js +5 -5
  15. package/dist/env/prompt/index.js +5 -5
  16. package/dist/env/session/index.js +11 -11
  17. package/dist/env/session/storage/index.js +1 -1
  18. package/dist/env/skill/index.js +5 -5
  19. package/dist/env/task/delegate/index.js +3 -3
  20. package/dist/env/task/index.js +9 -9
  21. package/dist/env/task/plugins/index.js +2 -2
  22. package/dist/env/tool/index.js +5 -5
  23. package/dist/env/workflow/engine/index.js +8 -3
  24. package/dist/env/workflow/index.js +24 -21
  25. package/dist/env/workflow/tools/index.js +14 -0
  26. package/dist/index.js +42 -38
  27. package/dist/shared/@ai-setting/{roy-agent-core-kajktp3d.js → roy-agent-core-20fm423j.js} +47 -26
  28. package/dist/shared/@ai-setting/{roy-agent-core-23gw9c4s.js → roy-agent-core-2vhsccvz.js} +52 -10
  29. package/dist/shared/@ai-setting/{roy-agent-core-r6rwsr54.js → roy-agent-core-3t82jyqb.js} +32 -12
  30. package/dist/shared/@ai-setting/{roy-agent-core-69jskqjg.js → roy-agent-core-44g4dhzg.js} +75 -7
  31. package/dist/shared/@ai-setting/{roy-agent-core-e9fdm13a.js → roy-agent-core-4gmxjdhn.js} +4 -2
  32. package/dist/shared/@ai-setting/{roy-agent-core-b4wd9tn6.js → roy-agent-core-4k9a823d.js} +1 -1
  33. package/dist/shared/@ai-setting/roy-agent-core-68qy97r3.js +31 -0
  34. package/dist/shared/@ai-setting/roy-agent-core-6atd905e.js +42 -0
  35. package/dist/shared/@ai-setting/{roy-agent-core-4jqq077c.js → roy-agent-core-6e3wz81d.js} +2 -2
  36. package/dist/shared/@ai-setting/{roy-agent-core-pwkk12p4.js → roy-agent-core-6mcb7nqa.js} +60 -0
  37. package/dist/shared/@ai-setting/{roy-agent-core-1zq3p19q.js → roy-agent-core-6z063hns.js} +11 -7
  38. package/dist/shared/@ai-setting/{roy-agent-core-9p43ap7h.js → roy-agent-core-8y804aat.js} +4 -2
  39. package/dist/shared/@ai-setting/{roy-agent-core-z1xf2fdk.js → roy-agent-core-a67e90d1.js} +6 -4
  40. package/dist/shared/@ai-setting/{roy-agent-core-38dkek2y.js → roy-agent-core-btvxttqf.js} +329 -118
  41. package/dist/shared/@ai-setting/roy-agent-core-dbxm76wf.js +190 -0
  42. package/dist/shared/@ai-setting/{roy-agent-core-nj8yerg9.js → roy-agent-core-eftqdsy5.js} +1 -1
  43. package/dist/shared/@ai-setting/roy-agent-core-fnv3ev18.js +61 -0
  44. package/dist/shared/@ai-setting/{roy-agent-core-2ms7296b.js → roy-agent-core-frjr619w.js} +12 -5
  45. package/dist/shared/@ai-setting/{roy-agent-core-psvwzdhj.js → roy-agent-core-hdszq729.js} +9 -5
  46. package/dist/shared/@ai-setting/{roy-agent-core-dxbsc1zy.js → roy-agent-core-ja9qhg6d.js} +1 -1
  47. package/dist/shared/@ai-setting/{roy-agent-core-cevpwnq7.js → roy-agent-core-mjbfgqen.js} +5 -3
  48. package/dist/shared/@ai-setting/roy-agent-core-nhfy3p8q.js +132 -0
  49. package/dist/shared/@ai-setting/{roy-agent-core-xkb264a8.js → roy-agent-core-pm73be85.js} +132 -24
  50. package/dist/shared/@ai-setting/{roy-agent-core-zrja5v78.js → roy-agent-core-pyv1vb7v.js} +13 -5
  51. package/dist/shared/@ai-setting/{roy-agent-core-ee6nnnqw.js → roy-agent-core-r9hq4cjx.js} +8 -1
  52. package/dist/shared/@ai-setting/{roy-agent-core-jqy2mdyq.js → roy-agent-core-rgj6hq15.js} +52 -41
  53. package/dist/shared/@ai-setting/{roy-agent-core-z33en0cz.js → roy-agent-core-rm3hay00.js} +15 -2
  54. package/dist/shared/@ai-setting/{roy-agent-core-ryw3ckfy.js → roy-agent-core-rx74rye7.js} +5 -3
  55. package/dist/shared/@ai-setting/{roy-agent-core-pxcrzyv9.js → roy-agent-core-sk535ft2.js} +1 -1
  56. package/dist/shared/@ai-setting/{roy-agent-core-2dhd60aw.js → roy-agent-core-vdwvamre.js} +10 -0
  57. package/dist/shared/@ai-setting/roy-agent-core-ye0z728h.js +18 -0
  58. package/dist/shared/@ai-setting/{roy-agent-core-eg6nv09z.js → roy-agent-core-ztx5eh72.js} +1 -1
  59. package/dist/shared/@ai-setting/{roy-agent-core-nqgrjja0.js → roy-agent-core-zwq6vhpj.js} +1 -1
  60. package/package.json +2 -2
  61. package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +0 -11
@@ -2,6 +2,10 @@ import {
2
2
  ComponentError,
3
3
  ErrorCodes
4
4
  } from "./roy-agent-core-ctdhjv68.js";
5
+ import {
6
+ ensureFallbackNpmPrefix,
7
+ isUsableNpmPrefix
8
+ } from "./roy-agent-core-fnv3ev18.js";
5
9
  import {
6
10
  adaptMcpTool
7
11
  } from "./roy-agent-core-1bfmxx89.js";
@@ -10,7 +14,7 @@ import {
10
14
  } from "./roy-agent-core-qxhq8ven.js";
11
15
  import {
12
16
  BaseComponent
13
- } from "./roy-agent-core-4jqq077c.js";
17
+ } from "./roy-agent-core-6e3wz81d.js";
14
18
  import {
15
19
  createLogger,
16
20
  init_logger
@@ -21,6 +25,7 @@ import { z } from "zod";
21
25
  var McpServerLocalConfigSchema = z.object({
22
26
  type: z.literal("local"),
23
27
  command: z.array(z.string()).min(1),
28
+ cwd: z.string().optional(),
24
29
  environment: z.record(z.string(), z.string()).optional(),
25
30
  enabled: z.boolean().optional().default(true),
26
31
  timeout: z.number().int().positive().optional()
@@ -84,8 +89,86 @@ init_logger();
84
89
 
85
90
  // src/env/mcp/scanner.ts
86
91
  init_logger();
87
- import fs from "fs/promises";
92
+ import fs2 from "fs/promises";
93
+ import path3 from "path";
94
+
95
+ // src/env/mcp/command-resolver.ts
96
+ import fs from "fs";
88
97
  import path2 from "path";
98
+ var PACKAGE_RUNNERS = new Set(["npx", "npm", "bunx", "yarn"]);
99
+ function pathExistsSync(p) {
100
+ try {
101
+ fs.accessSync(p, fs.constants.F_OK);
102
+ return true;
103
+ } catch {
104
+ return false;
105
+ }
106
+ }
107
+ function extractPackageName(command) {
108
+ if (command.length < 2) {
109
+ return;
110
+ }
111
+ const runner = path2.basename(command[0]);
112
+ if (runner === "npx" || runner === "bunx") {
113
+ return command[1];
114
+ }
115
+ if (runner === "npm" && command[1] === "exec") {
116
+ const separatorIndex = command.indexOf("--");
117
+ if (separatorIndex >= 0) {
118
+ return command[separatorIndex + 1];
119
+ }
120
+ return command[2];
121
+ }
122
+ if (runner === "yarn" && command[1] === "dlx") {
123
+ return command[2];
124
+ }
125
+ return;
126
+ }
127
+ function isPackageRunnerCommand(command) {
128
+ if (command.length < 2) {
129
+ return false;
130
+ }
131
+ const runner = path2.basename(command[0]);
132
+ if (!PACKAGE_RUNNERS.has(runner)) {
133
+ return false;
134
+ }
135
+ if (runner === "npm") {
136
+ return command[1] === "exec";
137
+ }
138
+ if (runner === "yarn") {
139
+ return command[1] === "dlx";
140
+ }
141
+ return true;
142
+ }
143
+ function resolvePackageRunnerCommand(command, serverDir) {
144
+ if (!isPackageRunnerCommand(command)) {
145
+ return command;
146
+ }
147
+ const packageName = extractPackageName(command);
148
+ if (!packageName) {
149
+ return command;
150
+ }
151
+ const localBin = path2.join(serverDir, "node_modules", ".bin", packageName);
152
+ if (pathExistsSync(localBin)) {
153
+ return [localBin];
154
+ }
155
+ return command;
156
+ }
157
+ function augmentNpmEnvForPackageRunner(command, env) {
158
+ if (!isPackageRunnerCommand(command)) {
159
+ return env;
160
+ }
161
+ const prefix = env.NPM_CONFIG_PREFIX ?? process.env.NPM_CONFIG_PREFIX ?? process.env.npm_config_prefix;
162
+ if (prefix && isUsableNpmPrefix(prefix)) {
163
+ return env;
164
+ }
165
+ return {
166
+ ...env,
167
+ NPM_CONFIG_PREFIX: ensureFallbackNpmPrefix()
168
+ };
169
+ }
170
+
171
+ // src/env/mcp/scanner.ts
89
172
  var logger = createLogger("mcp-scanner");
90
173
  var ENTRY_SCRIPT_CANDIDATES = [
91
174
  "server.mjs",
@@ -104,13 +187,13 @@ var ENTRY_SCRIPT_CANDIDATES = [
104
187
  function expandPath(inputPath) {
105
188
  if (inputPath.startsWith("~/")) {
106
189
  const home = process.env.HOME || process.env.USERPROFILE || "";
107
- return path2.join(home, inputPath.slice(2));
190
+ return path3.join(home, inputPath.slice(2));
108
191
  }
109
- return path2.resolve(inputPath);
192
+ return path3.resolve(inputPath);
110
193
  }
111
194
  async function pathExists(p) {
112
195
  try {
113
- await fs.access(p);
196
+ await fs2.access(p);
114
197
  return true;
115
198
  } catch {
116
199
  return false;
@@ -118,7 +201,7 @@ async function pathExists(p) {
118
201
  }
119
202
  async function parseConfigJsonc(configPath) {
120
203
  try {
121
- const configContent = await fs.readFile(configPath, "utf-8");
204
+ const configContent = await fs2.readFile(configPath, "utf-8");
122
205
  const cleaned = configContent.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
123
206
  return JSON.parse(cleaned);
124
207
  } catch (error) {
@@ -126,6 +209,12 @@ async function parseConfigJsonc(configPath) {
126
209
  return;
127
210
  }
128
211
  }
212
+ function relativeCommandMatchesEntry(cmdPath, entryPath, serverDir) {
213
+ if (path3.resolve(serverDir, cmdPath) === entryPath) {
214
+ return true;
215
+ }
216
+ return ENTRY_SCRIPT_CANDIDATES.some((candidate) => cmdPath === candidate && entryPath === path3.join(serverDir, candidate));
217
+ }
129
218
  function buildDefaultCommand(entryPath, directoryConfig, serverDir) {
130
219
  if (directoryConfig?.command) {
131
220
  const cmd = directoryConfig.command;
@@ -134,15 +223,14 @@ function buildDefaultCommand(entryPath, directoryConfig, serverDir) {
134
223
  return cmd;
135
224
  }
136
225
  if (cmdPath && entryPath) {
137
- const resolvedConfigPath = path2.resolve(serverDir, cmdPath);
138
- if (resolvedConfigPath === entryPath || cmdPath === "src/index.ts" || cmdPath === "src/index.js") {
226
+ if (relativeCommandMatchesEntry(cmdPath, entryPath, serverDir)) {
139
227
  return ["bun", "run", entryPath];
140
228
  }
141
229
  }
142
230
  if (entryPath) {
143
231
  return ["bun", "run", entryPath];
144
232
  }
145
- return cmd;
233
+ return resolvePackageRunnerCommand(cmd, serverDir);
146
234
  }
147
235
  return entryPath ? ["bun", "run", entryPath] : undefined;
148
236
  }
@@ -170,10 +258,10 @@ class McpScanner {
170
258
  }
171
259
  logger.info(`[McpScanner] Scanning: ${expandedPath}`);
172
260
  try {
173
- const entries = await fs.readdir(expandedPath, { withFileTypes: true });
261
+ const entries = await fs2.readdir(expandedPath, { withFileTypes: true });
174
262
  for (const entry of entries) {
175
- const fullPath = path2.join(expandedPath, entry.name);
176
- const stat = await fs.stat(fullPath);
263
+ const fullPath = path3.join(expandedPath, entry.name);
264
+ const stat = await fs2.stat(fullPath);
177
265
  if (!stat.isDirectory())
178
266
  continue;
179
267
  await this.discoverServer(entry.name, fullPath, mcpPath.type);
@@ -184,8 +272,8 @@ class McpScanner {
184
272
  }
185
273
  async discoverServer(name, serverDir, sourceType) {
186
274
  const entryPath = await this.findEntryScript(serverDir);
187
- const configPath = path2.join(serverDir, "config.jsonc");
188
- const packagePath = path2.join(serverDir, "package.json");
275
+ const configPath = path3.join(serverDir, "config.jsonc");
276
+ const packagePath = path3.join(serverDir, "package.json");
189
277
  let directoryConfig;
190
278
  if (await pathExists(configPath)) {
191
279
  directoryConfig = await parseConfigJsonc(configPath);
@@ -193,6 +281,7 @@ class McpScanner {
193
281
  const defaultCommand = buildDefaultCommand(entryPath, directoryConfig, serverDir);
194
282
  const server = {
195
283
  name,
284
+ serverDir,
196
285
  entryPath: entryPath || undefined,
197
286
  configPath: await pathExists(configPath) ? configPath : undefined,
198
287
  packagePath: await pathExists(packagePath) ? packagePath : undefined,
@@ -208,7 +297,7 @@ class McpScanner {
208
297
  }
209
298
  async findEntryScript(serverDir) {
210
299
  for (const candidate of ENTRY_SCRIPT_CANDIDATES) {
211
- const entryPath = path2.join(serverDir, candidate);
300
+ const entryPath = path3.join(serverDir, candidate);
212
301
  if (await pathExists(entryPath)) {
213
302
  return entryPath;
214
303
  }
@@ -222,14 +311,14 @@ class McpScanner {
222
311
 
223
312
  // src/env/mcp/loader.ts
224
313
  init_logger();
225
- import fs2 from "fs/promises";
226
- import path3 from "path";
314
+ import fs3 from "fs/promises";
315
+ import path4 from "path";
227
316
  import os2 from "os";
228
317
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
229
318
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
230
319
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
231
320
  var logger2 = createLogger("mcp-loader");
232
- var AUTH_JSON_PATH = path3.join(os2.homedir(), ".roy-agent", "auth.json");
321
+ var AUTH_JSON_PATH = path4.join(os2.homedir(), ".roy-agent", "auth.json");
233
322
 
234
323
  class McpLoader {
235
324
  clients = new Map;
@@ -252,6 +341,7 @@ class McpLoader {
252
341
  const localConfig = {
253
342
  type: "local",
254
343
  command,
344
+ ...server.serverDir ? { cwd: server.serverDir } : {},
255
345
  environment: server.directoryConfig?.environment,
256
346
  enabled: server.directoryConfig?.enabled ?? true,
257
347
  timeout: server.directoryConfig?.timeout ?? this.defaultTimeout
@@ -290,13 +380,16 @@ class McpLoader {
290
380
  let transport;
291
381
  if (config.type === "local") {
292
382
  const localConfig = config;
293
- const env = { ...localConfig.environment };
383
+ const env = augmentNpmEnvForPackageRunner(localConfig.command, { ...localConfig.environment });
294
384
  await this.injectMinimaxEnv(env);
295
385
  transport = new StdioClientTransport({
296
386
  command: localConfig.command[0],
297
387
  args: localConfig.command.slice(1),
298
- env
388
+ env,
389
+ ...localConfig.cwd ? { cwd: localConfig.cwd } : {},
390
+ stderr: "pipe"
299
391
  });
392
+ this.attachStderrDrain(name, transport);
300
393
  client = new Client({ name, version: "1.0.0" });
301
394
  await client.connect(transport);
302
395
  } else {
@@ -325,6 +418,21 @@ class McpLoader {
325
418
  this.clients.delete(name);
326
419
  logger2.info(`[McpLoader] Disconnected from ${name}`);
327
420
  }
421
+ attachStderrDrain(serverName, transport) {
422
+ const stderrStream = transport.stderr;
423
+ if (!stderrStream) {
424
+ return;
425
+ }
426
+ stderrStream.on("data", (chunk) => {
427
+ const text = chunk.toString().trim();
428
+ if (text) {
429
+ logger2.debug(`[McpLoader] ${serverName} stderr: ${text}`);
430
+ }
431
+ });
432
+ stderrStream.on("error", (error) => {
433
+ logger2.debug(`[McpLoader] ${serverName} stderr stream error`, { error });
434
+ });
435
+ }
328
436
  async closeTransport(transport, name) {
329
437
  try {
330
438
  const transportAny = transport;
@@ -355,7 +463,7 @@ class McpLoader {
355
463
  }
356
464
  async loadMinimaxApiKey() {
357
465
  try {
358
- const content = await fs2.readFile(AUTH_JSON_PATH, "utf-8");
466
+ const content = await fs3.readFile(AUTH_JSON_PATH, "utf-8");
359
467
  const auth = JSON.parse(content);
360
468
  return auth.providers?.minimax?.apiKey;
361
469
  } catch (error) {
@@ -376,7 +484,7 @@ class McpLoader {
376
484
  }
377
485
 
378
486
  // src/env/mcp/mcp-config-registration.ts
379
- import path4 from "path";
487
+ import path5 from "path";
380
488
  import os3 from "os";
381
489
  var MCP_DEFAULTS = {
382
490
  "mcp.enabled": true,
@@ -384,7 +492,7 @@ var MCP_DEFAULTS = {
384
492
  "mcp.mcpPaths": [
385
493
  {
386
494
  type: "user",
387
- path: path4.join(os3.homedir(), ".config", "roy-agent", "mcp")
495
+ path: path5.join(os3.homedir(), ".config", "roy-agent", "mcp")
388
496
  },
389
497
  {
390
498
  type: "project",
@@ -625,4 +733,4 @@ class McpComponent extends BaseComponent {
625
733
  await this.loadServers();
626
734
  }
627
735
  }
628
- export { McpServerLocalConfigSchema, McpServerRemoteConfigSchema, McpServerConfigSchema, DEFAULT_MCP_CONFIG, MCP_CONFIG_KEYS, getMcpPathPriority, McpScanner, McpLoader, McpComponent };
736
+ export { McpServerLocalConfigSchema, McpServerRemoteConfigSchema, McpServerConfigSchema, DEFAULT_MCP_CONFIG, MCP_CONFIG_KEYS, getMcpPathPriority, resolvePackageRunnerCommand, augmentNpmEnvForPackageRunner, McpScanner, McpLoader, McpComponent };
@@ -3,6 +3,10 @@ import {
3
3
  matchesQuery,
4
4
  parseSearchQuery
5
5
  } from "./roy-agent-core-rvxg1wps.js";
6
+ import {
7
+ MemorySessionStore,
8
+ SQLiteSessionStore
9
+ } from "./roy-agent-core-6mcb7nqa.js";
6
10
  import {
7
11
  SummaryAgent
8
12
  } from "./roy-agent-core-kwhv9dcd.js";
@@ -15,15 +19,11 @@ import {
15
19
  } from "./roy-agent-core-qxhq8ven.js";
16
20
  import {
17
21
  BaseComponent
18
- } from "./roy-agent-core-4jqq077c.js";
22
+ } from "./roy-agent-core-6e3wz81d.js";
19
23
  import {
20
24
  createLogger,
21
25
  init_logger
22
26
  } from "./roy-agent-core-10n2jh7p.js";
23
- import {
24
- MemorySessionStore,
25
- SQLiteSessionStore
26
- } from "./roy-agent-core-pwkk12p4.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
  }
@@ -8,7 +8,10 @@ import {
8
8
  } from "./roy-agent-core-q5qj0fes.js";
9
9
  import {
10
10
  BaseComponent
11
- } from "./roy-agent-core-4jqq077c.js";
11
+ } from "./roy-agent-core-6e3wz81d.js";
12
+ import {
13
+ init_context
14
+ } from "./roy-agent-core-rm3hay00.js";
12
15
  import {
13
16
  createLogger,
14
17
  init_logger
@@ -421,4 +424,8 @@ class BaseEnvironment extends BaseComponent {
421
424
  __legacyDecorateClassTS([
422
425
  TracedAs("env.handle_query", { recordParams: true, recordResult: true, log: true })
423
426
  ], BaseEnvironment.prototype, "handle_query", null);
427
+
428
+ // src/env/index.ts
429
+ init_context();
430
+
424
431
  export { generateId, generateDescendingId, BaseEnvironment };
@@ -1,6 +1,10 @@
1
1
  import {
2
- getEnvContext
3
- } from "./roy-agent-core-z33en0cz.js";
2
+ getEnvContext,
3
+ init_context
4
+ } from "./roy-agent-core-rm3hay00.js";
5
+ import {
6
+ __esm
7
+ } from "./roy-agent-core-fs0mn2jk.js";
4
8
 
5
9
  // src/env/hook/hook-manager.ts
6
10
  class HookManager {
@@ -163,45 +167,11 @@ class HookManager {
163
167
  }
164
168
  }
165
169
  }
170
+ var init_hook_manager = __esm(() => {
171
+ init_context();
172
+ });
166
173
 
167
174
  // src/env/hook/global-hook-manager.ts
168
- var globalHookManager = new HookManager;
169
- var AgentHookPoints = {
170
- BEFORE_START: "agent:before.start",
171
- BEFORE_LLM: "agent:before.llm",
172
- AFTER_LLM: "agent:after.llm",
173
- BEFORE_TOOL: "agent:before.tool",
174
- AFTER_TOOL: "agent:after.tool",
175
- ON_ITERATION: "agent:on.iteration",
176
- ON_THRESHOLD: "agent:on.threshold",
177
- AFTER_COMPLETE: "agent:after.complete",
178
- ON_ERROR: "agent:on.error"
179
- };
180
- var LLMHookPoints = {
181
- BEFORE_INVOKE: "llm:before.invoke",
182
- AFTER_INVOKE: "llm:after.invoke",
183
- ON_STREAM: "llm:on.stream"
184
- };
185
- var ToolHookPoints = {
186
- BEFORE_EXECUTE: "tool:before.execute",
187
- AFTER_EXECUTE: "tool:after.execute",
188
- BEFORE_REGISTER: "tool:before.register",
189
- AFTER_REGISTER: "tool:after.register",
190
- ON_ERROR: "tool:on.error"
191
- };
192
- var hookPointAliases = {
193
- "before.tool": "tool:before.execute",
194
- "after.tool": "tool:after.execute",
195
- "llm.before-invoke": "llm:before.invoke",
196
- "llm.after-invoke": "llm:after.invoke",
197
- "llm.stream": "llm:on.stream",
198
- "prompt.before-render": "prompt:before.render",
199
- "prompt.after-render": "prompt:after.render",
200
- "prompt:before.render": "prompt.before-render",
201
- "prompt:after.render": "prompt.after-render",
202
- "prompt:after-render": "prompt.after-render",
203
- "prompt:before-render": "prompt.before-render"
204
- };
205
175
  function setupAliasHooks() {
206
176
  const originalRegister = globalHookManager.register.bind(globalHookManager);
207
177
  globalHookManager.register = function(hookPoint, hook) {
@@ -212,7 +182,6 @@ function setupAliasHooks() {
212
182
  }
213
183
  };
214
184
  }
215
- setupAliasHooks();
216
185
  async function executeAgentHook(hookPoint, data, metadata = {}) {
217
186
  await globalHookManager.execute(hookPoint, data, metadata);
218
187
  }
@@ -225,5 +194,47 @@ async function executeLLMHook(hookPoint, data, metadata = {}) {
225
194
  async function executeToolHook(hookPoint, data, metadata = {}) {
226
195
  await globalHookManager.execute(hookPoint, data, metadata);
227
196
  }
197
+ var globalHookManager, AgentHookPoints, LLMHookPoints, ToolHookPoints, hookPointAliases;
198
+ var init_global_hook_manager = __esm(() => {
199
+ init_hook_manager();
200
+ globalHookManager = new HookManager;
201
+ AgentHookPoints = {
202
+ BEFORE_START: "agent:before.start",
203
+ BEFORE_LLM: "agent:before.llm",
204
+ AFTER_LLM: "agent:after.llm",
205
+ BEFORE_TOOL: "agent:before.tool",
206
+ AFTER_TOOL: "agent:after.tool",
207
+ ON_ITERATION: "agent:on.iteration",
208
+ ON_THRESHOLD: "agent:on.threshold",
209
+ AFTER_COMPLETE: "agent:after.complete",
210
+ ON_ERROR: "agent:on.error"
211
+ };
212
+ LLMHookPoints = {
213
+ BEFORE_INVOKE: "llm:before.invoke",
214
+ AFTER_INVOKE: "llm:after.invoke",
215
+ ON_STREAM: "llm:on.stream"
216
+ };
217
+ ToolHookPoints = {
218
+ BEFORE_EXECUTE: "tool:before.execute",
219
+ AFTER_EXECUTE: "tool:after.execute",
220
+ BEFORE_REGISTER: "tool:before.register",
221
+ AFTER_REGISTER: "tool:after.register",
222
+ ON_ERROR: "tool:on.error"
223
+ };
224
+ hookPointAliases = {
225
+ "before.tool": "tool:before.execute",
226
+ "after.tool": "tool:after.execute",
227
+ "llm.before-invoke": "llm:before.invoke",
228
+ "llm.after-invoke": "llm:after.invoke",
229
+ "llm.stream": "llm:on.stream",
230
+ "prompt.before-render": "prompt:before.render",
231
+ "prompt.after-render": "prompt:after.render",
232
+ "prompt:before.render": "prompt.before-render",
233
+ "prompt:after.render": "prompt.after-render",
234
+ "prompt:after-render": "prompt.after-render",
235
+ "prompt:before-render": "prompt.before-render"
236
+ };
237
+ setupAliasHooks();
238
+ });
228
239
 
229
- export { HookManager, globalHookManager, AgentHookPoints, LLMHookPoints, ToolHookPoints, executeAgentHook, executeAgentHookWithIntervention, executeLLMHook, executeToolHook };
240
+ export { HookManager, init_hook_manager, globalHookManager, AgentHookPoints, LLMHookPoints, ToolHookPoints, executeAgentHook, executeAgentHookWithIntervention, executeLLMHook, executeToolHook, init_global_hook_manager };
@@ -1,6 +1,9 @@
1
+ import {
2
+ __esm
3
+ } from "./roy-agent-core-fs0mn2jk.js";
4
+
1
5
  // src/env/context/env-context.ts
2
6
  import { AsyncLocalStorage } from "async_hooks";
3
- var envContextStorage = new AsyncLocalStorage;
4
7
  function getEnvContext() {
5
8
  return envContextStorage.getStore();
6
9
  }
@@ -41,4 +44,14 @@ function mergeEnvContext(partial) {
41
44
  Object.assign(current, partial);
42
45
  }
43
46
  }
44
- export { envContextStorage, getEnvContext, getEnvContextOrEmpty, hasEnvContext, runWithEnvContext, runWithEnvContextAsync, createEnvContext, mergeEnvContext };
47
+ var envContextStorage;
48
+ var init_env_context = __esm(() => {
49
+ envContextStorage = new AsyncLocalStorage;
50
+ });
51
+
52
+ // src/env/context/index.ts
53
+ var init_context = __esm(() => {
54
+ init_env_context();
55
+ });
56
+
57
+ export { envContextStorage, getEnvContext, getEnvContextOrEmpty, hasEnvContext, runWithEnvContext, runWithEnvContextAsync, createEnvContext, mergeEnvContext, init_context };
@@ -8,11 +8,12 @@ import {
8
8
  } from "./roy-agent-core-qxhq8ven.js";
9
9
  import {
10
10
  BaseComponent
11
- } from "./roy-agent-core-4jqq077c.js";
11
+ } from "./roy-agent-core-6e3wz81d.js";
12
12
  import {
13
13
  ToolHookPoints,
14
- globalHookManager
15
- } from "./roy-agent-core-jqy2mdyq.js";
14
+ globalHookManager,
15
+ init_global_hook_manager
16
+ } from "./roy-agent-core-rgj6hq15.js";
16
17
  import {
17
18
  createLogger,
18
19
  init_logger
@@ -140,6 +141,7 @@ class ToolValidator {
140
141
 
141
142
  // src/env/tool/tool-component.ts
142
143
  init_logger();
144
+ init_global_hook_manager();
143
145
 
144
146
  // src/env/tool/tool-config-registration.ts
145
147
  var TOOL_DEFAULTS = {
@@ -6,7 +6,7 @@ import {
6
6
  } from "./roy-agent-core-qxhq8ven.js";
7
7
  import {
8
8
  BaseComponent
9
- } from "./roy-agent-core-4jqq077c.js";
9
+ } from "./roy-agent-core-6e3wz81d.js";
10
10
  import {
11
11
  createLogger,
12
12
  init_logger
@@ -1,3 +1,8 @@
1
+ import {
2
+ init_global_hook_manager,
3
+ init_hook_manager
4
+ } from "./roy-agent-core-rgj6hq15.js";
5
+
1
6
  // src/env/hook/types.ts
2
7
  function createHook(meta, fn) {
3
8
  return {
@@ -8,4 +13,9 @@ function createHook(meta, fn) {
8
13
  function createPriorityHook(name, fn, priority) {
9
14
  return createHook({ name, priority }, fn);
10
15
  }
16
+
17
+ // src/env/hook/index.ts
18
+ init_hook_manager();
19
+ init_global_hook_manager();
20
+
11
21
  export { createHook, createPriorityHook };
@@ -0,0 +1,18 @@
1
+ import {
2
+ AgentComponentAdapter,
3
+ init_agent_component_adapter
4
+ } from "./roy-agent-core-44g4dhzg.js";
5
+ import"./roy-agent-core-dbxm76wf.js";
6
+ import"./roy-agent-core-nhfy3p8q.js";
7
+ import"./roy-agent-core-e25xkv53.js";
8
+ import"./roy-agent-core-rgj6hq15.js";
9
+ import"./roy-agent-core-rm3hay00.js";
10
+ import"./roy-agent-core-10n2jh7p.js";
11
+ import"./roy-agent-core-58k274fg.js";
12
+ import"./roy-agent-core-c6592r3c.js";
13
+ import"./roy-agent-core-fs0mn2jk.js";
14
+ init_agent_component_adapter();
15
+
16
+ export {
17
+ AgentComponentAdapter
18
+ };
@@ -6,7 +6,7 @@ import {
6
6
  } from "./roy-agent-core-qxhq8ven.js";
7
7
  import {
8
8
  BaseComponent
9
- } from "./roy-agent-core-4jqq077c.js";
9
+ } from "./roy-agent-core-6e3wz81d.js";
10
10
  import {
11
11
  createLogger,
12
12
  init_logger
@@ -4,7 +4,7 @@ import {
4
4
  } from "./roy-agent-core-rvv6ydff.js";
5
5
  import {
6
6
  BaseComponent
7
- } from "./roy-agent-core-4jqq077c.js";
7
+ } from "./roy-agent-core-6e3wz81d.js";
8
8
  import {
9
9
  __require
10
10
  } from "./roy-agent-core-fs0mn2jk.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.5.44",
3
+ "version": "1.5.46",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",
@@ -83,4 +83,4 @@
83
83
  "bugs": {
84
84
  "url": "https://github.com/ai-setting/roy-agent/issues"
85
85
  }
86
- }
86
+ }
@@ -1,11 +0,0 @@
1
- import {
2
- AgentComponentAdapter,
3
- init_agent_component_adapter
4
- } from "./roy-agent-core-69jskqjg.js";
5
- import"./roy-agent-core-e25xkv53.js";
6
- import"./roy-agent-core-fs0mn2jk.js";
7
- init_agent_component_adapter();
8
-
9
- export {
10
- AgentComponentAdapter
11
- };