@ai-setting/roy-agent-core 1.4.12 → 1.4.13

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 (57) hide show
  1. package/dist/index.d.ts +7825 -0
  2. package/dist/index.js +13073 -19300
  3. package/dist/shared/chunk-0q6s9wm6.js +249 -0
  4. package/dist/shared/chunk-1aakcfp1.js +15 -0
  5. package/dist/shared/chunk-1d4rwms4.js +25 -0
  6. package/dist/shared/chunk-1pf5mfgd.js +82 -0
  7. package/dist/shared/chunk-1qwabsm0.js +154 -0
  8. package/dist/shared/chunk-25x2pdtp.js +107 -0
  9. package/dist/shared/chunk-2b5kbhx3.js +366 -0
  10. package/dist/shared/chunk-91bas8w5.js +20 -0
  11. package/dist/shared/chunk-9qzt1v1p.js +10 -0
  12. package/dist/shared/chunk-a9qmy3sc.js +296 -0
  13. package/dist/shared/chunk-g6j5n3gv.js +549 -0
  14. package/dist/shared/chunk-hs7tbmje.js +24 -0
  15. package/dist/shared/chunk-mf5xqbdh.js +14 -0
  16. package/dist/shared/chunk-q9j99fsm.js +368 -0
  17. package/dist/{env/workflow/engine/index.js → shared/chunk-rncy3rtd.js} +330 -1581
  18. package/dist/shared/chunk-t1rh6jtm.js +205 -0
  19. package/dist/{env/task/hooks/index.js → shared/chunk-wbkh7wat.js} +3 -18
  20. package/dist/shared/chunk-yqmx37vm.js +10 -0
  21. package/dist/shared/chunk-ze20rksg.js +102 -0
  22. package/package.json +7 -7
  23. package/dist/config/index.js +0 -1670
  24. package/dist/env/agent/index.js +0 -3035
  25. package/dist/env/commands/index.js +0 -1685
  26. package/dist/env/debug/formatters/index.js +0 -639
  27. package/dist/env/debug/index.js +0 -2300
  28. package/dist/env/hook/index.js +0 -273
  29. package/dist/env/index.js +0 -12591
  30. package/dist/env/llm/index.js +0 -2736
  31. package/dist/env/log-trace/index.js +0 -1779
  32. package/dist/env/mcp/index.js +0 -2173
  33. package/dist/env/mcp/tool/index.js +0 -1149
  34. package/dist/env/memory/built-in/index.js +0 -225
  35. package/dist/env/memory/index.js +0 -2171
  36. package/dist/env/memory/plugin/index.js +0 -1263
  37. package/dist/env/prompt/index.js +0 -2107
  38. package/dist/env/session/index.js +0 -3594
  39. package/dist/env/session/storage/index.js +0 -2049
  40. package/dist/env/skill/index.js +0 -1635
  41. package/dist/env/skill/tool/index.js +0 -114
  42. package/dist/env/task/delegate/index.js +0 -1844
  43. package/dist/env/task/index.js +0 -3578
  44. package/dist/env/task/plugins/index.js +0 -1626
  45. package/dist/env/task/storage/index.js +0 -1464
  46. package/dist/env/task/tools/index.js +0 -344
  47. package/dist/env/task/tools/operation/index.js +0 -270
  48. package/dist/env/tool/built-in/index.js +0 -1151
  49. package/dist/env/tool/index.js +0 -2284
  50. package/dist/env/workflow/decorators/index.js +0 -449
  51. package/dist/env/workflow/index.js +0 -6214
  52. package/dist/env/workflow/nodes/index.js +0 -650
  53. package/dist/env/workflow/service/index.js +0 -262
  54. package/dist/env/workflow/storage/index.js +0 -1236
  55. package/dist/env/workflow/tools/index.js +0 -1081
  56. package/dist/env/workflow/types/index.js +0 -479
  57. package/dist/env/workflow/utils/index.js +0 -1631
@@ -1,273 +0,0 @@
1
- // @bun
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- function __accessProp(key) {
7
- return this[key];
8
- }
9
- var __toCommonJS = (from) => {
10
- var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
- if (entry)
12
- return entry;
13
- entry = __defProp({}, "__esModule", { value: true });
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (var key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(entry, key))
17
- __defProp(entry, key, {
18
- get: __accessProp.bind(from, key),
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- __moduleCache.set(from, entry);
23
- return entry;
24
- };
25
- var __moduleCache;
26
- var __returnValue = (v) => v;
27
- function __exportSetter(name, newValue) {
28
- this[name] = __returnValue.bind(null, newValue);
29
- }
30
- var __export = (target, all) => {
31
- for (var name in all)
32
- __defProp(target, name, {
33
- get: all[name],
34
- enumerable: true,
35
- configurable: true,
36
- set: __exportSetter.bind(all, name)
37
- });
38
- };
39
- var __legacyDecorateClassTS = function(decorators, target, key, desc) {
40
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
41
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
42
- r = Reflect.decorate(decorators, target, key, desc);
43
- else
44
- for (var i = decorators.length - 1;i >= 0; i--)
45
- if (d = decorators[i])
46
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
47
- return c > 3 && r && Object.defineProperty(target, key, r), r;
48
- };
49
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
50
- var __require = import.meta.require;
51
-
52
- // packages/core/src/env/hook/types.ts
53
- function createHook(meta, fn) {
54
- return {
55
- ...meta,
56
- execute: fn
57
- };
58
- }
59
- function createPriorityHook(name, fn, priority) {
60
- return createHook({ name, priority }, fn);
61
- }
62
- // packages/core/src/env/hook/hook-manager.ts
63
- class HookManager {
64
- _hooks = new Map;
65
- componentName;
66
- componentVersion;
67
- defaultPriority;
68
- constructor(options = {}) {
69
- this.componentName = options.componentName ?? "unknown";
70
- this.componentVersion = options.componentVersion ?? "0.0.0";
71
- this.defaultPriority = options.defaultPriority ?? 0;
72
- }
73
- register(hookPoint, hook) {
74
- const hooks = this.getOrCreateHooks(hookPoint);
75
- hooks.push(hook);
76
- }
77
- registerMany(hookPoint, hooks) {
78
- const hookList = this.getOrCreateHooks(hookPoint);
79
- hookList.push(...hooks);
80
- }
81
- unregister(hookPoint, name) {
82
- const hooks = this._hooks.get(hookPoint);
83
- if (!hooks)
84
- return false;
85
- const index = hooks.findIndex((h) => h.name === name);
86
- if (index === -1)
87
- return false;
88
- hooks.splice(index, 1);
89
- return true;
90
- }
91
- unregisterAll(hookPoint) {
92
- this._hooks.delete(hookPoint);
93
- }
94
- async execute(hookPoint, data, metadata = {}) {
95
- const hooks = this._hooks.get(hookPoint);
96
- if (!hooks || hooks.length === 0)
97
- return;
98
- const sortedHooks = this.sortHooks(hooks);
99
- const ctx = this.createContext(hookPoint, data, metadata, "before");
100
- for (const hook of sortedHooks) {
101
- await this.safeExecute(hook, ctx);
102
- }
103
- }
104
- async executeAndCollect(hookPoint, data, metadata = {}) {
105
- const hooks = this._hooks.get(hookPoint);
106
- if (!hooks || hooks.length === 0)
107
- return [];
108
- const sortedHooks = this.sortHooks(hooks);
109
- const ctx = this.createContext(hookPoint, data, metadata, "before");
110
- const results = [];
111
- for (const hook of sortedHooks) {
112
- const result = await this.safeExecuteAndReturn(hook, ctx);
113
- if (result !== undefined) {
114
- results.push(result);
115
- }
116
- }
117
- return results;
118
- }
119
- count(hookPoint) {
120
- return this._hooks.get(hookPoint)?.length ?? 0;
121
- }
122
- clear() {
123
- this._hooks.clear();
124
- }
125
- getHookPoints() {
126
- return Array.from(this._hooks.keys());
127
- }
128
- hasHooks(hookPoint) {
129
- return this.count(hookPoint) > 0;
130
- }
131
- setComponentInfo(name, version) {
132
- this.componentName = name;
133
- this.componentVersion = version;
134
- }
135
- get hooks() {
136
- return this._hooks;
137
- }
138
- async executeWithIntervention(hookPoint, data, metadata = {}) {
139
- const hooks = this._hooks.get(hookPoint);
140
- if (!hooks || hooks.length === 0) {
141
- return { stopped: false, results: [] };
142
- }
143
- const sortedHooks = this.sortHooks(hooks);
144
- const ctx = this.createContext(hookPoint, data, metadata, "before");
145
- const results = [];
146
- let stopped = false;
147
- let action;
148
- for (const hook of sortedHooks) {
149
- if (stopped)
150
- break;
151
- const result = await this.safeExecuteAndReturn(hook, ctx);
152
- results.push(result);
153
- if (result && typeof result === "object" && "stopped" in result) {
154
- const hookResult = result;
155
- if (hookResult.stopped) {
156
- stopped = true;
157
- action = hookResult.action;
158
- }
159
- }
160
- }
161
- return { stopped, action, results };
162
- }
163
- getOrCreateHooks(hookPoint) {
164
- let hooks = this._hooks.get(hookPoint);
165
- if (!hooks) {
166
- hooks = [];
167
- this._hooks.set(hookPoint, hooks);
168
- }
169
- return hooks;
170
- }
171
- sortHooks(hooks) {
172
- return [...hooks].sort((a, b) => {
173
- const priorityA = a.priority ?? this.defaultPriority;
174
- const priorityB = b.priority ?? this.defaultPriority;
175
- return priorityA - priorityB;
176
- });
177
- }
178
- createContext(hookPoint, data, metadata, phase) {
179
- return {
180
- component: {
181
- name: this.componentName,
182
- version: this.componentVersion
183
- },
184
- data,
185
- metadata,
186
- phase,
187
- hookPoint
188
- };
189
- }
190
- async safeExecute(hook, ctx) {
191
- try {
192
- await hook.execute(ctx);
193
- } catch (error) {
194
- console.error(`Hook "${hook.name}" failed:`, error);
195
- }
196
- }
197
- async safeExecuteAndReturn(hook, ctx) {
198
- try {
199
- return await hook.execute(ctx);
200
- } catch (error) {
201
- console.error(`Hook "${hook.name}" failed:`, error);
202
- return;
203
- }
204
- }
205
- }
206
- // packages/core/src/env/hook/global-hook-manager.ts
207
- var globalHookManager = new HookManager;
208
- var AgentHookPoints = {
209
- BEFORE_START: "agent:before.start",
210
- BEFORE_LLM: "agent:before.llm",
211
- AFTER_LLM: "agent:after.llm",
212
- BEFORE_TOOL: "agent:before.tool",
213
- AFTER_TOOL: "agent:after.tool",
214
- ON_ITERATION: "agent:on.iteration",
215
- ON_THRESHOLD: "agent:on.threshold",
216
- AFTER_COMPLETE: "agent:after.complete",
217
- ON_ERROR: "agent:on.error"
218
- };
219
- var LLMHookPoints = {
220
- BEFORE_INVOKE: "llm:before.invoke",
221
- AFTER_INVOKE: "llm:after.invoke",
222
- ON_STREAM: "llm:on.stream"
223
- };
224
- var ToolHookPoints = {
225
- BEFORE_EXECUTE: "tool:before.execute",
226
- AFTER_EXECUTE: "tool:after.execute",
227
- BEFORE_REGISTER: "tool:before.register",
228
- AFTER_REGISTER: "tool:after.register",
229
- ON_ERROR: "tool:on.error"
230
- };
231
- var hookPointAliases = {
232
- "before.tool": "tool:before.execute",
233
- "after.tool": "tool:after.execute",
234
- "llm.before-invoke": "llm:before.invoke",
235
- "llm.after-invoke": "llm:after.invoke",
236
- "llm.stream": "llm:on.stream"
237
- };
238
- function setupAliasHooks() {
239
- const originalRegister = globalHookManager.register.bind(globalHookManager);
240
- globalHookManager.register = function(hookPoint, hook) {
241
- originalRegister(hookPoint, hook);
242
- const alias = hookPointAliases[hookPoint];
243
- if (alias) {
244
- originalRegister(alias, hook);
245
- }
246
- };
247
- }
248
- setupAliasHooks();
249
- async function executeAgentHook(hookPoint, data, metadata = {}) {
250
- await globalHookManager.execute(hookPoint, data, metadata);
251
- }
252
- async function executeAgentHookWithIntervention(hookPoint, data, metadata = {}) {
253
- return globalHookManager.executeWithIntervention(hookPoint, data, metadata);
254
- }
255
- async function executeLLMHook(hookPoint, data, metadata = {}) {
256
- await globalHookManager.execute(hookPoint, data, metadata);
257
- }
258
- async function executeToolHook(hookPoint, data, metadata = {}) {
259
- await globalHookManager.execute(hookPoint, data, metadata);
260
- }
261
- export {
262
- globalHookManager,
263
- executeToolHook,
264
- executeLLMHook,
265
- executeAgentHookWithIntervention,
266
- executeAgentHook,
267
- createPriorityHook,
268
- createHook,
269
- ToolHookPoints,
270
- LLMHookPoints,
271
- HookManager,
272
- AgentHookPoints
273
- };