@ai-setting/roy-agent-core 1.5.37 → 1.5.40

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 (74) hide show
  1. package/dist/config/index.js +4 -3
  2. package/dist/env/agent/index.js +10 -9
  3. package/dist/env/commands/index.js +7 -6
  4. package/dist/env/context/index.js +21 -0
  5. package/dist/env/debug/index.js +4 -3
  6. package/dist/env/event-source/index.js +12 -6
  7. package/dist/env/hook/index.js +2 -1
  8. package/dist/env/index.js +41 -18
  9. package/dist/env/llm/index.js +8 -7
  10. package/dist/env/log-trace/index.js +10 -9
  11. package/dist/env/mcp/index.js +8 -7
  12. package/dist/env/mcp/tool/index.js +4 -4
  13. package/dist/env/memory/index.js +12 -11
  14. package/dist/env/memory/plugin/index.js +4 -4
  15. package/dist/env/plugin/index.js +18 -0
  16. package/dist/env/prompt/index.js +7 -6
  17. package/dist/env/session/index.js +11 -10
  18. package/dist/env/session/storage/index.js +2 -6
  19. package/dist/env/skill/index.js +7 -6
  20. package/dist/env/task/delegate/index.js +6 -5
  21. package/dist/env/task/index.js +10 -8
  22. package/dist/env/task/plugins/index.js +13 -6
  23. package/dist/env/task/storage/index.js +4 -4
  24. package/dist/env/tool/built-in/index.js +3 -3
  25. package/dist/env/tool/index.js +8 -7
  26. package/dist/env/workflow/engine/index.js +5 -5
  27. package/dist/env/workflow/index.js +9 -8
  28. package/dist/env/workflow/storage/index.js +5 -5
  29. package/dist/env/workflow/tools/index.js +3 -3
  30. package/dist/env/workflow/utils/index.js +4 -4
  31. package/dist/index.js +67 -60
  32. package/dist/shared/@ai-setting/{roy-agent-core-44hnfb02.js → roy-agent-core-10n2jh7p.js} +1 -1
  33. package/dist/shared/@ai-setting/{roy-agent-core-xt3fx7m1.js → roy-agent-core-15x8fe5h.js} +38 -56
  34. package/dist/shared/@ai-setting/{roy-agent-core-1akcqxj9.js → roy-agent-core-1bfmxx89.js} +1 -1
  35. package/dist/shared/@ai-setting/{roy-agent-core-ty94k28r.js → roy-agent-core-2jnzv9at.js} +2 -2
  36. package/dist/shared/@ai-setting/{roy-agent-core-3jywqmdd.js → roy-agent-core-2x07feb7.js} +317 -65
  37. package/dist/shared/@ai-setting/{roy-agent-core-cefh9hjv.js → roy-agent-core-4jqq077c.js} +1 -1
  38. package/dist/shared/@ai-setting/{roy-agent-core-xs5rsgat.js → roy-agent-core-58k274fg.js} +108 -23
  39. package/dist/shared/@ai-setting/{roy-agent-core-mx489p7f.js → roy-agent-core-728h32vx.js} +263 -33
  40. package/dist/shared/@ai-setting/{roy-agent-core-jfh9q2qh.js → roy-agent-core-7b35emr7.js} +0 -15
  41. package/dist/shared/@ai-setting/{roy-agent-core-3rr5k71j.js → roy-agent-core-8n4bz6y3.js} +1 -1
  42. package/dist/shared/@ai-setting/{roy-agent-core-zpn0bqa8.js → roy-agent-core-9ffsvvcf.js} +1 -1
  43. package/dist/shared/@ai-setting/roy-agent-core-az13yzmc.js +11 -0
  44. package/dist/shared/@ai-setting/{roy-agent-core-0wdjp769.js → roy-agent-core-b4wd9tn6.js} +2 -2
  45. package/dist/shared/@ai-setting/{roy-agent-core-6kvtahqv.js → roy-agent-core-c3ct1346.js} +1 -1
  46. package/dist/shared/@ai-setting/{roy-agent-core-psv4v63c.js → roy-agent-core-c6592r3c.js} +19 -2
  47. package/dist/shared/@ai-setting/{roy-agent-core-c2wjwx16.js → roy-agent-core-c8f2hync.js} +305 -287
  48. package/dist/shared/@ai-setting/roy-agent-core-cevpwnq7.js +147 -0
  49. package/dist/shared/@ai-setting/{roy-agent-core-hkb529dw.js → roy-agent-core-dxbsc1zy.js} +7 -7
  50. package/dist/shared/@ai-setting/{roy-agent-core-vqspcspb.js → roy-agent-core-e130w7mv.js} +3 -3
  51. package/dist/shared/@ai-setting/{roy-agent-core-j0ke54vy.js → roy-agent-core-ee6nnnqw.js} +5 -5
  52. package/dist/shared/@ai-setting/{roy-agent-core-qdmt6nz7.js → roy-agent-core-eg6nv09z.js} +2 -2
  53. package/dist/shared/@ai-setting/{roy-agent-core-hd1z20yq.js → roy-agent-core-frx4p6d1.js} +1 -1
  54. package/dist/shared/@ai-setting/{roy-agent-core-bvr1761x.js → roy-agent-core-hsxn8m1j.js} +1 -1
  55. package/dist/shared/@ai-setting/{roy-agent-core-86gphny5.js → roy-agent-core-jqy2mdyq.js} +15 -1
  56. package/dist/shared/@ai-setting/{roy-agent-core-c0d3dtjd.js → roy-agent-core-kajktp3d.js} +7 -7
  57. package/dist/shared/@ai-setting/{roy-agent-core-eajcvp4e.js → roy-agent-core-kwhv9dcd.js} +2 -2
  58. package/dist/shared/@ai-setting/{roy-agent-core-r9ezzemr.js → roy-agent-core-m0wp34r4.js} +1 -1
  59. package/dist/shared/@ai-setting/{roy-agent-core-fg1kxf70.js → roy-agent-core-nqgrjja0.js} +5 -5
  60. package/dist/shared/@ai-setting/{roy-agent-core-d7cyjkf7.js → roy-agent-core-pwkk12p4.js} +1 -1
  61. package/dist/shared/@ai-setting/{roy-agent-core-97ma0pr5.js → roy-agent-core-pxcrzyv9.js} +2 -2
  62. package/dist/shared/@ai-setting/{roy-agent-core-zgypchmt.js → roy-agent-core-q5qj0fes.js} +19 -11
  63. package/dist/shared/@ai-setting/{roy-agent-core-sx7wsvnn.js → roy-agent-core-qakqwbbh.js} +2 -2
  64. package/dist/shared/@ai-setting/{roy-agent-core-qfdp3pvq.js → roy-agent-core-rsybkb38.js} +1 -1
  65. package/dist/shared/@ai-setting/roy-agent-core-ty33mnr7.js +14 -0
  66. package/dist/shared/@ai-setting/{roy-agent-core-3prpabp8.js → roy-agent-core-v53rfk99.js} +2 -2
  67. package/dist/shared/@ai-setting/{roy-agent-core-wjd5kars.js → roy-agent-core-wb43x8hd.js} +3 -3
  68. package/dist/shared/@ai-setting/{roy-agent-core-e2vk2qh7.js → roy-agent-core-yc543gnq.js} +6 -6
  69. package/dist/shared/@ai-setting/{roy-agent-core-gf2c2pxr.js → roy-agent-core-ycg9rk6z.js} +3 -3
  70. package/dist/shared/@ai-setting/roy-agent-core-z33en0cz.js +44 -0
  71. package/dist/shared/@ai-setting/{roy-agent-core-by55z88t.js → roy-agent-core-zrja5v78.js} +11 -11
  72. package/dist/shared/@ai-setting/{roy-agent-core-wft9ra24.js → roy-agent-core-zwp3jp02.js} +4 -4
  73. package/package.json +1 -1
  74. package/dist/shared/@ai-setting/roy-agent-core-bcbqy27c.js +0 -14
@@ -0,0 +1,147 @@
1
+ import {
2
+ BaseComponent
3
+ } from "./roy-agent-core-4jqq077c.js";
4
+ import {
5
+ globalHookManager
6
+ } from "./roy-agent-core-jqy2mdyq.js";
7
+ import {
8
+ createLogger,
9
+ init_logger
10
+ } from "./roy-agent-core-10n2jh7p.js";
11
+
12
+ // src/env/plugin/plugin-component.ts
13
+ init_logger();
14
+
15
+ class PluginComponent extends BaseComponent {
16
+ name = "plugin";
17
+ version = "1.0.0";
18
+ registry = new Map;
19
+ componentCache = new Map;
20
+ logger = createLogger("plugin");
21
+ configComponent;
22
+ constructor() {
23
+ super();
24
+ }
25
+ async init(config) {
26
+ await super.init(config);
27
+ const options = config?.options;
28
+ if (!options?.configComponent) {
29
+ throw new Error("ConfigComponent is required for PluginComponent initialization");
30
+ }
31
+ this.configComponent = options.configComponent;
32
+ this.setStatus("running");
33
+ this.logger.info("[PluginComponent] Initialized");
34
+ }
35
+ register(plugin) {
36
+ if (this.registry.has(plugin.name)) {
37
+ throw new Error(`Plugin "${plugin.name}" is already registered`);
38
+ }
39
+ const env = this.createPluginEnv(plugin);
40
+ try {
41
+ const result = plugin.init(env);
42
+ if (result instanceof Promise) {
43
+ result.then(() => {
44
+ this.registry.set(plugin.name, plugin);
45
+ this.logger.info(`Registered plugin: ${plugin.name}`);
46
+ }).catch((err) => {
47
+ this.logger.error(`Failed to init plugin ${plugin.name}: ${err}`);
48
+ throw err;
49
+ });
50
+ } else {
51
+ this.registry.set(plugin.name, plugin);
52
+ this.logger.info(`Registered plugin: ${plugin.name}`);
53
+ }
54
+ } catch (err) {
55
+ this.logger.error(`Failed to init plugin ${plugin.name}: ${err}`);
56
+ throw err;
57
+ }
58
+ }
59
+ unregister(name) {
60
+ const plugin = this.registry.get(name);
61
+ if (!plugin) {
62
+ return false;
63
+ }
64
+ try {
65
+ plugin.dispose();
66
+ this.registry.delete(name);
67
+ this.logger.info(`Unregistered plugin: ${name}`);
68
+ return true;
69
+ } catch (err) {
70
+ this.logger.error(`Failed to dispose plugin ${name}: ${err}`);
71
+ return false;
72
+ }
73
+ }
74
+ get(name) {
75
+ return this.registry.get(name);
76
+ }
77
+ list() {
78
+ return Array.from(this.registry.values());
79
+ }
80
+ has(name) {
81
+ return this.registry.has(name);
82
+ }
83
+ getConfig(name) {
84
+ return this.configComponent?.get(`plugin.${name}`);
85
+ }
86
+ registerAll(plugins) {
87
+ for (const plugin of plugins) {
88
+ this.register(plugin);
89
+ }
90
+ }
91
+ async stop() {
92
+ this.setStatus("stopping");
93
+ this.logger.info("[PluginComponent] Stopping...");
94
+ for (const [name, plugin] of this.registry) {
95
+ try {
96
+ const result = plugin.dispose();
97
+ if (result instanceof Promise) {
98
+ await result;
99
+ }
100
+ this.logger.debug(`Disposed plugin: ${name}`);
101
+ } catch (err) {
102
+ this.logger.error(`Failed to dispose plugin ${name}: ${err}`);
103
+ }
104
+ }
105
+ this.registry.clear();
106
+ this.componentCache.clear();
107
+ this.setStatus("stopped");
108
+ this.logger.info("[PluginComponent] Stopped");
109
+ }
110
+ createPluginEnv(plugin) {
111
+ const self = this;
112
+ return {
113
+ getComponent(name) {
114
+ return self.env?.getComponent(name);
115
+ },
116
+ registerAgent(config) {
117
+ const agentComponent = self.env?.getComponent("agent");
118
+ if (agentComponent) {
119
+ agentComponent.registerAgent(config.name, config);
120
+ self.logger.debug(`Registered agent: ${config.name} (for plugin: ${plugin.name})`);
121
+ } else {
122
+ self.logger.warn(`Cannot register agent ${config.name}: AgentComponent not available`);
123
+ }
124
+ },
125
+ registerTool(tool) {
126
+ const toolComponent = self.env?.getComponent("tool");
127
+ if (toolComponent) {
128
+ toolComponent.register(tool);
129
+ self.logger.debug(`Registered tool: ${tool.name} (for plugin: ${plugin.name})`);
130
+ } else {
131
+ self.logger.warn(`Cannot register tool ${tool.name}: ToolComponent not available`);
132
+ }
133
+ },
134
+ registerHook(hook) {
135
+ globalHookManager.register(hook.point, {
136
+ name: `${plugin.name}:${hook.point}`,
137
+ priority: hook.priority ?? plugin.priority,
138
+ execute: hook.handler
139
+ });
140
+ self.logger.debug(`Registered hook: ${hook.point} (for plugin: ${plugin.name})`);
141
+ },
142
+ logger: createLogger(`plugin:${plugin.name}`)
143
+ };
144
+ }
145
+ }
146
+
147
+ export { PluginComponent };
@@ -1,29 +1,29 @@
1
+ import {
2
+ init_decorator
3
+ } from "./roy-agent-core-q5qj0fes.js";
1
4
  import {
2
5
  envKeyToConfigKey
3
6
  } from "./roy-agent-core-qxhq8ven.js";
4
7
  import {
5
8
  BaseComponent
6
- } from "./roy-agent-core-cefh9hjv.js";
7
- import {
8
- init_decorator
9
- } from "./roy-agent-core-zgypchmt.js";
9
+ } from "./roy-agent-core-4jqq077c.js";
10
10
  import {
11
11
  createLogger,
12
12
  init_logger,
13
13
  setConfigComponent,
14
14
  setQuietMode
15
- } from "./roy-agent-core-44hnfb02.js";
15
+ } from "./roy-agent-core-10n2jh7p.js";
16
16
  import {
17
17
  getTracerProvider,
18
18
  init_propagation,
19
19
  init_tracer_provider,
20
20
  init_types,
21
21
  propagation
22
- } from "./roy-agent-core-xs5rsgat.js";
22
+ } from "./roy-agent-core-58k274fg.js";
23
23
  import {
24
24
  SQLiteSpanStorage,
25
25
  init_span_storage
26
- } from "./roy-agent-core-psv4v63c.js";
26
+ } from "./roy-agent-core-c6592r3c.js";
27
27
  import {
28
28
  __require
29
29
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -8,15 +8,15 @@ import {
8
8
  } from "./roy-agent-core-qxhq8ven.js";
9
9
  import {
10
10
  BaseComponent
11
- } from "./roy-agent-core-cefh9hjv.js";
11
+ } from "./roy-agent-core-4jqq077c.js";
12
12
  import {
13
13
  ToolHookPoints,
14
14
  globalHookManager
15
- } from "./roy-agent-core-86gphny5.js";
15
+ } from "./roy-agent-core-jqy2mdyq.js";
16
16
  import {
17
17
  createLogger,
18
18
  init_logger
19
- } from "./roy-agent-core-44hnfb02.js";
19
+ } from "./roy-agent-core-10n2jh7p.js";
20
20
  import {
21
21
  __require
22
22
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -2,17 +2,17 @@ import {
2
2
  ContextError,
3
3
  ErrorCodes
4
4
  } from "./roy-agent-core-ctdhjv68.js";
5
- import {
6
- BaseComponent
7
- } from "./roy-agent-core-cefh9hjv.js";
8
5
  import {
9
6
  TracedAs,
10
7
  init_decorator
11
- } from "./roy-agent-core-zgypchmt.js";
8
+ } from "./roy-agent-core-q5qj0fes.js";
9
+ import {
10
+ BaseComponent
11
+ } from "./roy-agent-core-4jqq077c.js";
12
12
  import {
13
13
  createLogger,
14
14
  init_logger
15
- } from "./roy-agent-core-44hnfb02.js";
15
+ } from "./roy-agent-core-10n2jh7p.js";
16
16
  import {
17
17
  __legacyDecorateClassTS
18
18
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -6,11 +6,11 @@ import {
6
6
  } from "./roy-agent-core-qxhq8ven.js";
7
7
  import {
8
8
  BaseComponent
9
- } from "./roy-agent-core-cefh9hjv.js";
9
+ } from "./roy-agent-core-4jqq077c.js";
10
10
  import {
11
11
  createLogger,
12
12
  init_logger
13
- } from "./roy-agent-core-44hnfb02.js";
13
+ } from "./roy-agent-core-10n2jh7p.js";
14
14
 
15
15
  // src/env/memory/types.ts
16
16
  import { z } from "zod";
@@ -7,7 +7,7 @@ import {
7
7
  } from "./roy-agent-core-qxhq8ven.js";
8
8
  import {
9
9
  BaseComponent
10
- } from "./roy-agent-core-cefh9hjv.js";
10
+ } from "./roy-agent-core-4jqq077c.js";
11
11
  import {
12
12
  __require
13
13
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createLogger,
3
3
  init_logger
4
- } from "./roy-agent-core-44hnfb02.js";
4
+ } from "./roy-agent-core-10n2jh7p.js";
5
5
  import {
6
6
  __require
7
7
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -1,3 +1,7 @@
1
+ import {
2
+ getEnvContext
3
+ } from "./roy-agent-core-z33en0cz.js";
4
+
1
5
  // src/env/hook/hook-manager.ts
2
6
  class HookManager {
3
7
  _hooks = new Map;
@@ -34,6 +38,13 @@ class HookManager {
34
38
  const hooks = this._hooks.get(hookPoint);
35
39
  if (!hooks || hooks.length === 0)
36
40
  return;
41
+ const envContext = getEnvContext();
42
+ if (envContext) {
43
+ metadata.envContext = envContext;
44
+ if (!metadata.pluginEnabled && envContext.pluginEnabled) {
45
+ metadata.pluginEnabled = envContext.pluginEnabled;
46
+ }
47
+ }
37
48
  const sortedHooks = this.sortHooks(hooks);
38
49
  const ctx = this.createContext(hookPoint, data, metadata, "before");
39
50
  const pluginEnabled = metadata.pluginEnabled || {};
@@ -135,7 +146,10 @@ class HookManager {
135
146
  }
136
147
  async safeExecute(hook, ctx) {
137
148
  try {
138
- await hook.execute(ctx);
149
+ const result = hook.execute(ctx);
150
+ if (result && typeof result === "object" && typeof result.then === "function") {
151
+ await result;
152
+ }
139
153
  } catch (error) {
140
154
  console.error(`Hook "${hook.name}" failed:`, error);
141
155
  }
@@ -2,25 +2,25 @@ import {
2
2
  ContextError,
3
3
  ErrorCodes
4
4
  } from "./roy-agent-core-ctdhjv68.js";
5
+ import {
6
+ TracedAs,
7
+ init_decorator
8
+ } from "./roy-agent-core-q5qj0fes.js";
5
9
  import {
6
10
  envKeyToConfigKey,
7
11
  toEnvKey
8
12
  } from "./roy-agent-core-qxhq8ven.js";
9
13
  import {
10
14
  BaseComponent
11
- } from "./roy-agent-core-cefh9hjv.js";
15
+ } from "./roy-agent-core-4jqq077c.js";
12
16
  import {
13
17
  LLMHookPoints,
14
18
  globalHookManager
15
- } from "./roy-agent-core-86gphny5.js";
16
- import {
17
- TracedAs,
18
- init_decorator
19
- } from "./roy-agent-core-zgypchmt.js";
19
+ } from "./roy-agent-core-jqy2mdyq.js";
20
20
  import {
21
21
  createLogger,
22
22
  init_logger
23
- } from "./roy-agent-core-44hnfb02.js";
23
+ } from "./roy-agent-core-10n2jh7p.js";
24
24
  import {
25
25
  __legacyDecorateClassTS,
26
26
  __require
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  TracedAs,
3
3
  init_decorator
4
- } from "./roy-agent-core-zgypchmt.js";
4
+ } from "./roy-agent-core-q5qj0fes.js";
5
5
  import {
6
6
  createLogger,
7
7
  init_logger
8
- } from "./roy-agent-core-44hnfb02.js";
8
+ } from "./roy-agent-core-10n2jh7p.js";
9
9
  import {
10
10
  __legacyDecorateClassTS
11
11
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SQLiteSpanStorage,
3
3
  init_span_storage
4
- } from "./roy-agent-core-psv4v63c.js";
4
+ } from "./roy-agent-core-c6592r3c.js";
5
5
  import"./roy-agent-core-fs0mn2jk.js";
6
6
  init_span_storage();
7
7
 
@@ -4,7 +4,7 @@ import {
4
4
  } from "./roy-agent-core-rvv6ydff.js";
5
5
  import {
6
6
  BaseComponent
7
- } from "./roy-agent-core-cefh9hjv.js";
7
+ } from "./roy-agent-core-4jqq077c.js";
8
8
  import {
9
9
  __require
10
10
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -141,7 +141,7 @@ class SpanDbReader {
141
141
  }
142
142
  async initSqliteStorage() {
143
143
  try {
144
- const { SQLiteSpanStorage } = await import("./roy-agent-core-r9ezzemr.js");
144
+ const { SQLiteSpanStorage } = await import("./roy-agent-core-m0wp34r4.js");
145
145
  this.storage = new SQLiteSpanStorage(this.dbPath);
146
146
  await this.storage.initialize();
147
147
  } catch (error) {
@@ -590,7 +590,7 @@ class DebugComponent extends BaseComponent {
590
590
  }
591
591
  async getLiveTrace(traceId) {
592
592
  try {
593
- const { getTracerProvider } = await import("./roy-agent-core-sx7wsvnn.js");
593
+ const { getTracerProvider } = await import("./roy-agent-core-qakqwbbh.js");
594
594
  const provider = getTracerProvider();
595
595
  if (!provider.isInitialized()) {
596
596
  await provider.initialize();
@@ -635,7 +635,7 @@ class DebugComponent extends BaseComponent {
635
635
  }
636
636
  async listLiveTraces(limit = 20) {
637
637
  try {
638
- const { getTracerProvider } = await import("./roy-agent-core-sx7wsvnn.js");
638
+ const { getTracerProvider } = await import("./roy-agent-core-qakqwbbh.js");
639
639
  const provider = getTracerProvider();
640
640
  if (!provider.isInitialized()) {
641
641
  await provider.initialize();
@@ -653,7 +653,7 @@ class DebugComponent extends BaseComponent {
653
653
  }
654
654
  async formatLiveTrace(traceId) {
655
655
  try {
656
- const { getTracerProvider } = await import("./roy-agent-core-sx7wsvnn.js");
656
+ const { getTracerProvider } = await import("./roy-agent-core-qakqwbbh.js");
657
657
  const provider = getTracerProvider();
658
658
  if (!provider.isInitialized()) {
659
659
  await provider.initialize();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SessionMessageConverter
3
- } from "./roy-agent-core-jfh9q2qh.js";
3
+ } from "./roy-agent-core-7b35emr7.js";
4
4
  import {
5
5
  __require
6
6
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -6,11 +6,11 @@ import {
6
6
  } from "./roy-agent-core-qxhq8ven.js";
7
7
  import {
8
8
  BaseComponent
9
- } from "./roy-agent-core-cefh9hjv.js";
9
+ } from "./roy-agent-core-4jqq077c.js";
10
10
  import {
11
11
  createLogger,
12
12
  init_logger
13
- } from "./roy-agent-core-44hnfb02.js";
13
+ } from "./roy-agent-core-10n2jh7p.js";
14
14
 
15
15
  // src/env/skill/skill-component.ts
16
16
  init_logger();
@@ -3,11 +3,11 @@ import {
3
3
  getMaxOutput,
4
4
  init_logger,
5
5
  simplifyFilePath
6
- } from "./roy-agent-core-44hnfb02.js";
6
+ } from "./roy-agent-core-10n2jh7p.js";
7
7
  import {
8
8
  getTracerProvider,
9
9
  init_tracer_provider
10
- } from "./roy-agent-core-xs5rsgat.js";
10
+ } from "./roy-agent-core-58k274fg.js";
11
11
  import {
12
12
  __esm
13
13
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -135,30 +135,38 @@ function wrapFunction(fn, name, options) {
135
135
  }
136
136
  }
137
137
  const callerLocation = getCallerLocation();
138
- logFn("enter", args, callerLocation);
139
138
  const span = tracer.startSpan(name, { attributes });
139
+ logFn("enter", args, callerLocation);
140
140
  try {
141
141
  const result = fn.call(this, ...args);
142
142
  if (result && typeof result === "object" && typeof result.then === "function") {
143
143
  return result.then((resolved) => {
144
- span.setAttribute("result", JSON.stringify(truncate(resolved)));
145
- span.end(resolved);
144
+ if (span) {
145
+ span.setAttribute("result", JSON.stringify(truncate(resolved)));
146
+ span.end(resolved);
147
+ }
146
148
  logFn("quit", options?.recordResult ? resolved : undefined, callerLocation);
147
149
  return resolved;
148
150
  }, (rejected) => {
149
- span.setAttribute("error", String(rejected));
150
- span.end(undefined, rejected instanceof Error ? rejected : new Error(String(rejected)));
151
+ if (span) {
152
+ span.setAttribute("error", String(rejected));
153
+ span.end(undefined, rejected instanceof Error ? rejected : new Error(String(rejected)));
154
+ }
151
155
  logFn("error", rejected.message, callerLocation);
152
156
  throw rejected;
153
157
  });
154
158
  }
155
- span.setAttribute("result", JSON.stringify(truncate(result)));
156
- span.end(result);
159
+ if (span) {
160
+ span.setAttribute("result", JSON.stringify(truncate(result)));
161
+ span.end(result);
162
+ }
157
163
  logFn("quit", options?.recordResult ? result : undefined, callerLocation);
158
164
  return result;
159
165
  } catch (error) {
160
- span.setAttribute("error", String(error));
161
- span.end(undefined, error instanceof Error ? error : new Error(String(error)));
166
+ if (span) {
167
+ span.setAttribute("error", String(error));
168
+ span.end(undefined, error instanceof Error ? error : new Error(String(error)));
169
+ }
162
170
  logFn("error", error.message, callerLocation);
163
171
  throw error;
164
172
  }
@@ -3,8 +3,8 @@ import {
3
3
  getTracerProvider,
4
4
  init_tracer_provider,
5
5
  resetTracerProvider
6
- } from "./roy-agent-core-xs5rsgat.js";
7
- import"./roy-agent-core-psv4v63c.js";
6
+ } from "./roy-agent-core-58k274fg.js";
7
+ import"./roy-agent-core-c6592r3c.js";
8
8
  import"./roy-agent-core-fs0mn2jk.js";
9
9
  init_tracer_provider();
10
10
 
@@ -3,7 +3,7 @@ import {
3
3
  init_propagation,
4
4
  init_tracer_provider,
5
5
  propagation
6
- } from "./roy-agent-core-xs5rsgat.js";
6
+ } from "./roy-agent-core-58k274fg.js";
7
7
  import {
8
8
  __toCommonJS
9
9
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -0,0 +1,14 @@
1
+ import {
2
+ WorkflowRepository,
3
+ rowToWorkflow
4
+ } from "./roy-agent-core-8n4bz6y3.js";
5
+ import"./roy-agent-core-9ffsvvcf.js";
6
+ import"./roy-agent-core-rvxg1wps.js";
7
+ import"./roy-agent-core-10n2jh7p.js";
8
+ import"./roy-agent-core-58k274fg.js";
9
+ import"./roy-agent-core-c6592r3c.js";
10
+ import"./roy-agent-core-fs0mn2jk.js";
11
+ export {
12
+ rowToWorkflow,
13
+ WorkflowRepository
14
+ };
@@ -3,11 +3,11 @@ import {
3
3
  } from "./roy-agent-core-92z6t4he.js";
4
4
  import {
5
5
  globalHookManager
6
- } from "./roy-agent-core-86gphny5.js";
6
+ } from "./roy-agent-core-jqy2mdyq.js";
7
7
  import {
8
8
  createLogger,
9
9
  init_logger
10
- } from "./roy-agent-core-44hnfb02.js";
10
+ } from "./roy-agent-core-10n2jh7p.js";
11
11
 
12
12
  // src/env/task/delegate/delegate-tool.ts
13
13
  init_logger();
@@ -4,17 +4,17 @@ import {
4
4
  } from "./roy-agent-core-qxhq8ven.js";
5
5
  import {
6
6
  BaseComponent
7
- } from "./roy-agent-core-cefh9hjv.js";
7
+ } from "./roy-agent-core-4jqq077c.js";
8
8
  import {
9
9
  createHook
10
10
  } from "./roy-agent-core-2dhd60aw.js";
11
11
  import {
12
12
  globalHookManager
13
- } from "./roy-agent-core-86gphny5.js";
13
+ } from "./roy-agent-core-jqy2mdyq.js";
14
14
  import {
15
15
  createLogger,
16
16
  init_logger
17
- } from "./roy-agent-core-44hnfb02.js";
17
+ } from "./roy-agent-core-10n2jh7p.js";
18
18
 
19
19
  // src/env/prompt/types.ts
20
20
  import { z } from "zod";
@@ -6,7 +6,7 @@ import {
6
6
  WorkflowEngine,
7
7
  exports_engine,
8
8
  init_engine
9
- } from "./roy-agent-core-ty94k28r.js";
9
+ } from "./roy-agent-core-2jnzv9at.js";
10
10
  import {
11
11
  WorkflowService
12
12
  } from "./roy-agent-core-4t40mkpv.js";
@@ -15,11 +15,11 @@ import {
15
15
  } from "./roy-agent-core-0vbdz0x7.js";
16
16
  import {
17
17
  BaseComponent
18
- } from "./roy-agent-core-cefh9hjv.js";
18
+ } from "./roy-agent-core-4jqq077c.js";
19
19
  import {
20
20
  createLogger,
21
21
  init_logger
22
- } from "./roy-agent-core-44hnfb02.js";
22
+ } from "./roy-agent-core-10n2jh7p.js";
23
23
  import {
24
24
  __require,
25
25
  __toCommonJS
@@ -156,7 +156,7 @@ class WorkflowComponent extends BaseComponent {
156
156
  if (this.workflowService) {
157
157
  this.workflowService = null;
158
158
  try {
159
- const { closeDatabase } = await import("./roy-agent-core-wft9ra24.js");
159
+ const { closeDatabase } = await import("./roy-agent-core-zwp3jp02.js");
160
160
  closeDatabase();
161
161
  componentLogger.info("[WorkflowComponent] SQLite database closed");
162
162
  } catch (error) {
@@ -193,8 +193,8 @@ class WorkflowComponent extends BaseComponent {
193
193
  }
194
194
  async initSqliteService() {
195
195
  try {
196
- const { getDatabase, initializeTables } = await import("./roy-agent-core-wft9ra24.js");
197
- const { WorkflowRepository } = await import("./roy-agent-core-bcbqy27c.js");
196
+ const { getDatabase, initializeTables } = await import("./roy-agent-core-zwp3jp02.js");
197
+ const { WorkflowRepository } = await import("./roy-agent-core-ty33mnr7.js");
198
198
  const db = getDatabase();
199
199
  initializeTables();
200
200
  const workflowRepository = new WorkflowRepository(db);
@@ -4,17 +4,17 @@ import {
4
4
  } from "./roy-agent-core-ctdhjv68.js";
5
5
  import {
6
6
  adaptMcpTool
7
- } from "./roy-agent-core-1akcqxj9.js";
7
+ } from "./roy-agent-core-1bfmxx89.js";
8
8
  import {
9
9
  toEnvKey
10
10
  } from "./roy-agent-core-qxhq8ven.js";
11
11
  import {
12
12
  BaseComponent
13
- } from "./roy-agent-core-cefh9hjv.js";
13
+ } from "./roy-agent-core-4jqq077c.js";
14
14
  import {
15
15
  createLogger,
16
16
  init_logger
17
- } from "./roy-agent-core-44hnfb02.js";
17
+ } from "./roy-agent-core-10n2jh7p.js";
18
18
 
19
19
  // src/env/mcp/types.ts
20
20
  import { z } from "zod";
@@ -0,0 +1,44 @@
1
+ // src/env/context/env-context.ts
2
+ import { AsyncLocalStorage } from "async_hooks";
3
+ var envContextStorage = new AsyncLocalStorage;
4
+ function getEnvContext() {
5
+ return envContextStorage.getStore();
6
+ }
7
+ function getEnvContextOrEmpty() {
8
+ return envContextStorage.getStore() || {};
9
+ }
10
+ function hasEnvContext() {
11
+ return envContextStorage.getStore() !== undefined;
12
+ }
13
+ function runWithEnvContext(context, fn) {
14
+ if (context) {
15
+ return envContextStorage.run(context, fn);
16
+ }
17
+ return fn();
18
+ }
19
+ async function runWithEnvContextAsync(context, fn) {
20
+ if (context) {
21
+ return envContextStorage.run(context, fn);
22
+ }
23
+ return fn();
24
+ }
25
+ function createEnvContext(options) {
26
+ return {
27
+ envEvent: options.envEvent,
28
+ sourceId: options.sourceId,
29
+ userId: options.userId,
30
+ traceId: options.traceId ?? crypto.randomUUID(),
31
+ requestId: options.requestId ?? crypto.randomUUID(),
32
+ replyChannel: options.replyChannel,
33
+ pluginEnabled: options.pluginEnabled,
34
+ plugins: options.plugins,
35
+ timestamp: options.timestamp ?? Date.now()
36
+ };
37
+ }
38
+ function mergeEnvContext(partial) {
39
+ const current = envContextStorage.getStore();
40
+ if (current) {
41
+ Object.assign(current, partial);
42
+ }
43
+ }
44
+ export { envContextStorage, getEnvContext, getEnvContextOrEmpty, hasEnvContext, runWithEnvContext, runWithEnvContextAsync, createEnvContext, mergeEnvContext };