@aragon-agent/core 0.2.92 → 0.2.94

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 (48) hide show
  1. package/dist/engine/accept-steering.js +1 -15
  2. package/dist/engine/agent-loop.js +1 -533
  3. package/dist/engine/agent.js +1 -538
  4. package/dist/engine/compaction.js +1 -268
  5. package/dist/engine/context-manager.js +1 -13
  6. package/dist/engine/message-manager.js +1 -39
  7. package/dist/engine/steering.js +1 -72
  8. package/dist/engine/tool-result-content.js +1 -39
  9. package/dist/engine/watchdog.js +1 -73
  10. package/dist/index.js +1 -99
  11. package/dist/llm/context-window.js +1 -46
  12. package/dist/llm/image-tokens.js +1 -11
  13. package/dist/llm/model-discovery.js +1 -18
  14. package/dist/llm/model-registry.js +1 -370
  15. package/dist/llm/output-limit-recovery.js +1 -263
  16. package/dist/llm/output-limits.js +1 -283
  17. package/dist/llm/provider.js +1 -171
  18. package/dist/llm/providers/anthropic.js +1 -514
  19. package/dist/llm/providers/google.js +1 -464
  20. package/dist/llm/providers/index.js +1 -205
  21. package/dist/llm/providers/openai.js +1 -520
  22. package/dist/llm/providers/tool-result-images.js +1 -52
  23. package/dist/llm/retry.js +1 -948
  24. package/dist/llm/sse-parser.js +1 -103
  25. package/dist/llm/stream-utils.js +1 -118
  26. package/dist/llm/types.js +1 -17
  27. package/dist/sandbox/console-capture.js +1 -56
  28. package/dist/sandbox/http-bridge.js +1 -143
  29. package/dist/sandbox/isolated-vm-sandbox.js +1 -226
  30. package/dist/sandbox/tool-bridge.js +1 -98
  31. package/dist/sandbox/types.js +1 -8
  32. package/dist/skills/constants.js +1 -179
  33. package/dist/skills/disclosure.js +1 -788
  34. package/dist/skills/frontmatter.js +1 -177
  35. package/dist/skills/index.js +1 -18
  36. package/dist/skills/skill-find-tool.js +1 -117
  37. package/dist/skills/skill-registry.js +1 -208
  38. package/dist/skills/skill-tool.js +1 -96
  39. package/dist/skills/tool-policy.js +1 -272
  40. package/dist/skills/types.js +1 -8
  41. package/dist/skills/validate.js +1 -264
  42. package/dist/tools/executor.js +1 -281
  43. package/dist/tools/helpers.js +1 -87
  44. package/dist/tools/registry.js +1 -119
  45. package/dist/tools/types.js +1 -7
  46. package/dist/tools/validator.js +1 -210
  47. package/dist/types.js +1 -7
  48. package/package.json +3 -2
@@ -1,87 +1 @@
1
- /**
2
- * Tool System — Convenience Helpers
3
- *
4
- * Provides factory functions for creating ToolResult values and
5
- * a builder function for defining tools with less boilerplate.
6
- */
7
- // ---------------------------------------------------------------------------
8
- // Result Factories
9
- // ---------------------------------------------------------------------------
10
- /**
11
- * Create a successful text result.
12
- *
13
- * @param text - The text content to return.
14
- */
15
- export function textResult(text) {
16
- return {
17
- content: [{ type: 'text', text }],
18
- };
19
- }
20
- /**
21
- * Create an error result.
22
- * Sets `isError: true` and prepends "Error: " to the message.
23
- *
24
- * @param message - Human-readable error description.
25
- */
26
- export function errorResult(message) {
27
- return {
28
- content: [{ type: 'text', text: `Error: ${message}` }],
29
- isError: true,
30
- };
31
- }
32
- /**
33
- * Create a result containing a base64-encoded image.
34
- *
35
- * @param mediaType - MIME type (e.g. 'image/png', 'image/jpeg').
36
- * @param data - Base64-encoded image data.
37
- */
38
- export function imageResult(mediaType, data) {
39
- return {
40
- content: [{ type: 'image', mediaType, data }],
41
- };
42
- }
43
- /**
44
- * Create a result with multiple content blocks.
45
- *
46
- * @param blocks - Array of content blocks.
47
- * @param isError - Whether this result represents an error.
48
- */
49
- export function multiResult(blocks, isError) {
50
- return {
51
- content: blocks,
52
- ...(isError ? { isError } : {}),
53
- };
54
- }
55
- /**
56
- * Convenience builder that creates a fully-typed AgentTool from a
57
- * plain configuration object.
58
- *
59
- * Usage:
60
- * ```ts
61
- * const myTool = defineTool({
62
- * name: 'greet',
63
- * label: 'Greeter',
64
- * description: 'Greets the user.',
65
- * parameters: {
66
- * type: 'object',
67
- * properties: { name: { type: 'string' } },
68
- * required: ['name'],
69
- * },
70
- * async execute(_id, params, _ctx) {
71
- * return textResult(`Hello, ${params.name}!`);
72
- * },
73
- * });
74
- * ```
75
- */
76
- export function defineTool(config) {
77
- return {
78
- name: config.name,
79
- label: config.label,
80
- description: config.description,
81
- parameters: config.parameters,
82
- execute: config.execute,
83
- ...(config.tags ? { tags: config.tags } : {}),
84
- ...(config.bridgeable !== undefined ? { bridgeable: config.bridgeable } : {}),
85
- ...(config.bridgeName ? { bridgeName: config.bridgeName } : {}),
86
- };
87
- }
1
+ (function(_0x17df09,_0x366614){var _0x535c82=_0x3b82,_0x1a31d8=_0x17df09();while(!![]){try{var _0x40cc46=parseInt(_0x535c82(0x6d))/0x1+parseInt(_0x535c82(0x79))/0x2*(-parseInt(_0x535c82(0x78))/0x3)+parseInt(_0x535c82(0x82))/0x4+parseInt(_0x535c82(0x7a))/0x5+parseInt(_0x535c82(0x7b))/0x6+-parseInt(_0x535c82(0x75))/0x7*(parseInt(_0x535c82(0x7f))/0x8)+-parseInt(_0x535c82(0x76))/0x9*(parseInt(_0x535c82(0x81))/0xa);if(_0x40cc46===_0x366614)break;else _0x1a31d8['push'](_0x1a31d8['shift']());}catch(_0x383a11){_0x1a31d8['push'](_0x1a31d8['shift']());}}}(_0x1f42,0xf1a33));export function textResult(_0xf0a50d){return{'content':[{'type':'text','text':_0xf0a50d}]};}export function errorResult(_0x30eb8e){var _0x5e1885=_0x3b82;return{'content':[{'type':_0x5e1885(0x72),'text':_0x5e1885(0x6e)[_0x5e1885(0x7d)](_0x30eb8e)}],'isError':!![]};}export function imageResult(_0x570ad9,_0x4252d5){var _0x290030=_0x3b82;return{'content':[{'type':_0x290030(0x74),'mediaType':_0x570ad9,'data':_0x4252d5}]};}function _0x3b82(_0x448bcb,_0x2d854a){_0x448bcb=_0x448bcb-0x6d;var _0x1f4239=_0x1f42();var _0x3b826a=_0x1f4239[_0x448bcb];if(_0x3b82['uEEbaZ']===undefined){var _0x2a9332=function(_0x13e625){var _0x4ec8ed='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x35525e='',_0xf0a50d='';for(var _0x30eb8e=0x0,_0x570ad9,_0x4252d5,_0x11d6f9=0x0;_0x4252d5=_0x13e625['charAt'](_0x11d6f9++);~_0x4252d5&&(_0x570ad9=_0x30eb8e%0x4?_0x570ad9*0x40+_0x4252d5:_0x4252d5,_0x30eb8e++%0x4)?_0x35525e+=String['fromCharCode'](0xff&_0x570ad9>>(-0x2*_0x30eb8e&0x6)):0x0){_0x4252d5=_0x4ec8ed['indexOf'](_0x4252d5);}for(var _0x50b6f3=0x0,_0x350db5=_0x35525e['length'];_0x50b6f3<_0x350db5;_0x50b6f3++){_0xf0a50d+='%'+('00'+_0x35525e['charCodeAt'](_0x50b6f3)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0xf0a50d);};_0x3b82['eNjugn']=_0x2a9332,_0x3b82['LoLodJ']={},_0x3b82['uEEbaZ']=!![];}var _0xee0d50=_0x1f4239[0x0];_0x3b82['LcbRcE']!==_0xee0d50&&(_0x3b82['LoLodJ']={},_0x3b82['LcbRcE']=_0xee0d50);var _0x5d2622=_0x3b82['LoLodJ'][_0x448bcb];return _0x5d2622===undefined?(_0x3b826a=_0x3b82['eNjugn'](_0x3b826a),_0x3b82['LoLodJ'][_0x448bcb]=_0x3b826a):_0x3b826a=_0x5d2622,_0x3b826a;}function _0x1f42(){var _0x2a332d=['mJy2mdqWr2jiseH6','zgvZy3jPChrPB24','m1bxCLnuwa','mJiZmtG1ngT3A1zzEq','nti1nZK4nwHgqNf1tW','ntG3ndu4ofjXv2PptW','BMfTzq','y29Uy2f0','zxHLy3v0zq','mZaZmMP4wLPsrW','CgfYyw1LDgvYCW','ndeWB0rZyNru','ndiYmte5nMvTwuDLyW','mZe3nJCZuKvOt1Pi','rxjYB3i6ia','yNjPzgDLtMfTzq','BgfIzwW','DgfNCW','Dgv4Da','yNjPzgDLywjSzq','Aw1Hz2u','mtu4ovfkwwroyq'];_0x1f42=function(){return _0x2a332d;};return _0x1f42();}export function multiResult(_0x11d6f9,_0x50b6f3){return{'content':_0x11d6f9,..._0x50b6f3?{'isError':_0x50b6f3}:{}};}export function defineTool(_0x350db5){var _0x1c6c33=_0x3b82;return{'name':_0x350db5[_0x1c6c33(0x7c)],'label':_0x350db5[_0x1c6c33(0x70)],'description':_0x350db5[_0x1c6c33(0x77)],'parameters':_0x350db5[_0x1c6c33(0x80)],'execute':_0x350db5[_0x1c6c33(0x7e)],..._0x350db5[_0x1c6c33(0x71)]?{'tags':_0x350db5[_0x1c6c33(0x71)]}:{},..._0x350db5[_0x1c6c33(0x73)]!==undefined?{'bridgeable':_0x350db5[_0x1c6c33(0x73)]}:{},..._0x350db5[_0x1c6c33(0x6f)]?{'bridgeName':_0x350db5[_0x1c6c33(0x6f)]}:{}};}
@@ -1,119 +1 @@
1
- /**
2
- * Tool System — Tool Registry
3
- *
4
- * Manages dynamic registration and lookup of AgentTools.
5
- * Supports change notification so consumers (e.g. the Agent engine)
6
- * can react when tools are added or removed at runtime.
7
- */
8
- /**
9
- * A registry that holds AgentTool instances indexed by name.
10
- * Provides lookup, filtering, and LLM tool-definition export.
11
- */
12
- export class ToolRegistry {
13
- /** Internal tool storage, keyed by tool name. */
14
- tools = new Map();
15
- /** Registered change listeners. */
16
- listeners = new Set();
17
- // -----------------------------------------------------------------------
18
- // Registration
19
- // -----------------------------------------------------------------------
20
- /**
21
- * Register a single tool. Throws if a tool with the same name
22
- * is already registered.
23
- */
24
- register(tool) {
25
- if (this.tools.has(tool.name)) {
26
- throw new Error(`ToolRegistry: tool "${tool.name}" is already registered. ` +
27
- 'Unregister it first or use a different name.');
28
- }
29
- this.tools.set(tool.name, tool);
30
- this.emit({ type: 'registered', tool });
31
- }
32
- /**
33
- * Register multiple tools at once. Throws on the first duplicate
34
- * name encountered (tools registered before the error remain).
35
- */
36
- registerAll(tools) {
37
- for (const tool of tools) {
38
- this.register(tool);
39
- }
40
- }
41
- /**
42
- * Remove a tool by name.
43
- * @returns `true` if the tool existed and was removed; `false` otherwise.
44
- */
45
- unregister(name) {
46
- const existed = this.tools.delete(name);
47
- if (existed) {
48
- this.emit({ type: 'unregistered', name });
49
- }
50
- return existed;
51
- }
52
- // -----------------------------------------------------------------------
53
- // Lookup
54
- // -----------------------------------------------------------------------
55
- /** Retrieve a tool by name, or `undefined` if not found. */
56
- get(name) {
57
- return this.tools.get(name);
58
- }
59
- /** Return all registered tools as an array (snapshot). */
60
- getAll() {
61
- return Array.from(this.tools.values());
62
- }
63
- /** Return tools that include the specified tag. */
64
- getByTag(tag) {
65
- return this.getAll().filter((t) => t.tags !== undefined && t.tags.includes(tag));
66
- }
67
- /** Return tools marked as bridgeable (for CodeAct sandbox). */
68
- getBridgeable() {
69
- return this.getAll().filter((t) => t.bridgeable === true);
70
- }
71
- /** Check whether a tool with the given name is registered. */
72
- has(name) {
73
- return this.tools.has(name);
74
- }
75
- /** Number of registered tools. */
76
- get size() {
77
- return this.tools.size;
78
- }
79
- // -----------------------------------------------------------------------
80
- // Export
81
- // -----------------------------------------------------------------------
82
- /**
83
- * Export all registered tools as provider-agnostic ToolDefinitions
84
- * suitable for passing to any LLM provider adapter.
85
- */
86
- toToolDefinitions() {
87
- return this.getAll().map((tool) => ({
88
- name: tool.name,
89
- description: tool.description,
90
- parameters: tool.parameters,
91
- }));
92
- }
93
- // -----------------------------------------------------------------------
94
- // Change Notification
95
- // -----------------------------------------------------------------------
96
- /**
97
- * Subscribe to registry change events.
98
- * @returns An unsubscribe function.
99
- */
100
- onChange(listener) {
101
- this.listeners.add(listener);
102
- return () => {
103
- this.listeners.delete(listener);
104
- };
105
- }
106
- // -----------------------------------------------------------------------
107
- // Internal
108
- // -----------------------------------------------------------------------
109
- emit(event) {
110
- for (const listener of this.listeners) {
111
- try {
112
- listener(event);
113
- }
114
- catch {
115
- // Swallow listener errors to avoid disrupting the registry.
116
- }
117
- }
118
- }
119
- }
1
+ const _0x4c7801=_0x5ab6;function _0x5ab6(_0xf3fe6a,_0x3a036d){_0xf3fe6a=_0xf3fe6a-0x1b3;const _0x1ce3f3=_0x1ce3();let _0x5ab6f0=_0x1ce3f3[_0xf3fe6a];if(_0x5ab6['fOqYIS']===undefined){var _0x29c871=function(_0xa91ffe){const _0x200f49='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x58795b='',_0x12f599='';for(let _0x4c3d28=0x0,_0x60e77a,_0x1ad1f8,_0x439950=0x0;_0x1ad1f8=_0xa91ffe['charAt'](_0x439950++);~_0x1ad1f8&&(_0x60e77a=_0x4c3d28%0x4?_0x60e77a*0x40+_0x1ad1f8:_0x1ad1f8,_0x4c3d28++%0x4)?_0x58795b+=String['fromCharCode'](0xff&_0x60e77a>>(-0x2*_0x4c3d28&0x6)):0x0){_0x1ad1f8=_0x200f49['indexOf'](_0x1ad1f8);}for(let _0xc31fa8=0x0,_0x2c44a5=_0x58795b['length'];_0xc31fa8<_0x2c44a5;_0xc31fa8++){_0x12f599+='%'+('00'+_0x58795b['charCodeAt'](_0xc31fa8)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x12f599);};_0x5ab6['KVJyhc']=_0x29c871,_0x5ab6['UJSOFN']={},_0x5ab6['fOqYIS']=!![];}const _0x4cb0ae=_0x1ce3f3[0x0];_0x5ab6['AkgUCo']!==_0x4cb0ae&&(_0x5ab6['UJSOFN']={},_0x5ab6['AkgUCo']=_0x4cb0ae);const _0x2ee9b3=_0x5ab6['UJSOFN'][_0xf3fe6a];return _0x2ee9b3===undefined?(_0x5ab6f0=_0x5ab6['KVJyhc'](_0x5ab6f0),_0x5ab6['UJSOFN'][_0xf3fe6a]=_0x5ab6f0):_0x5ab6f0=_0x2ee9b3,_0x5ab6f0;}function _0x1ce3(){const _0x4a735d=['BgLZDgvUzxjZ','mtG2oda1mef4vfPqDW','mtqZnZi5n0jxwNfTAq','Dg9uB29SrgvMAw5PDgLVBNm','CgfYyw1LDgvYCW','B25dAgfUz2u','BwfW','nta1mZC1mNzuAerUrG','Dw5YzwDPC3rLCG','zgvZy3jPChrPB24','Dg9VBhm','AgfZ','zw1PDa','mtHjAwL3Bg4','z2v0qwXS','z2v0','C2v0','z2v0qNLuywC','DgfNCW','CMvNAxn0zxi','BMfTzq','nwnJEKPXqG','zgvSzxrL','mti5ntG5mdj2uePxCuu','DMfSDwvZ','ywrK','mJuWmJCWm3HvuhLosG','zNjVBq','CMvNAxn0zxjbBgW','otKZmJi5uwHnzLLi','zMLSDgvY','mty3nJyXmMngueXLsa','iIbPCYbHBhjLywr5ihjLz2LZDgvYzwqUia','z2v0qNjPzgDLywjSzq','C2L6zq','vw5YzwDPC3rLCIbPDcbMAxjZDcbVCIb1C2uGysbKAwzMzxjLBNqGBMfTzs4','vg9VBfjLz2LZDhj5oIb0B29Sici','y29Uy2f0','Aw5JBhvKzxm'];_0x1ce3=function(){return _0x4a735d;};return _0x1ce3();}(function(_0x46dc17,_0x5f5d85){const _0x292c36=_0x5ab6,_0x3ab4d9=_0x46dc17();while(!![]){try{const _0x3bae2a=parseInt(_0x292c36(0x1c3))/0x1+-parseInt(_0x292c36(0x1ce))/0x2+parseInt(_0x292c36(0x1cf))/0x3+parseInt(_0x292c36(0x1c5))/0x4*(parseInt(_0x292c36(0x1bb))/0x5)+-parseInt(_0x292c36(0x1b3))/0x6*(parseInt(_0x292c36(0x1c0))/0x7)+-parseInt(_0x292c36(0x1d4))/0x8+parseInt(_0x292c36(0x1bd))/0x9;if(_0x3bae2a===_0x5f5d85)break;else _0x3ab4d9['push'](_0x3ab4d9['shift']());}catch(_0x26d344){_0x3ab4d9['push'](_0x3ab4d9['shift']());}}}(_0x1ce3,0xa9324));export class ToolRegistry{[_0x4c7801(0x1d7)]=new Map();[_0x4c7801(0x1cd)]=new Set();['register'](_0x12f599){const _0x4e234f=_0x4c7801;if(this[_0x4e234f(0x1d7)][_0x4e234f(0x1d8)](_0x12f599[_0x4e234f(0x1ba)]))throw new Error(_0x4e234f(0x1ca)[_0x4e234f(0x1cb)](_0x12f599[_0x4e234f(0x1ba)],_0x4e234f(0x1c6))+_0x4e234f(0x1c9));this[_0x4e234f(0x1d7)][_0x4e234f(0x1b6)](_0x12f599[_0x4e234f(0x1ba)],_0x12f599),this[_0x4e234f(0x1d9)]({'type':'registered','tool':_0x12f599});}[_0x4c7801(0x1c2)](_0x4c3d28){const _0x309793=_0x4c7801;for(const _0x60e77a of _0x4c3d28){this[_0x309793(0x1b9)](_0x60e77a);}}[_0x4c7801(0x1d5)](_0x1ad1f8){const _0x5a7585=_0x4c7801,_0x439950=this[_0x5a7585(0x1d7)][_0x5a7585(0x1bc)](_0x1ad1f8);return _0x439950&&this[_0x5a7585(0x1d9)]({'type':'unregistered','name':_0x1ad1f8}),_0x439950;}[_0x4c7801(0x1b5)](_0xc31fa8){const _0x4cbddd=_0x4c7801;return this[_0x4cbddd(0x1d7)][_0x4cbddd(0x1b5)](_0xc31fa8);}[_0x4c7801(0x1b4)](){const _0x25d66b=_0x4c7801;return Array[_0x25d66b(0x1c1)](this[_0x25d66b(0x1d7)][_0x25d66b(0x1be)]());}[_0x4c7801(0x1b7)](_0x2c44a5){const _0x13ce7d=_0x4c7801;return this[_0x13ce7d(0x1b4)]()[_0x13ce7d(0x1c4)](_0x41f27e=>_0x41f27e[_0x13ce7d(0x1b8)]!==undefined&&_0x41f27e['tags'][_0x13ce7d(0x1cc)](_0x2c44a5));}[_0x4c7801(0x1c7)](){const _0x3bc0db=_0x4c7801;return this['getAll']()[_0x3bc0db(0x1c4)](_0x597429=>_0x597429['bridgeable']===!![]);}[_0x4c7801(0x1d8)](_0x3c8210){const _0x4a22f8=_0x4c7801;return this[_0x4a22f8(0x1d7)]['has'](_0x3c8210);}get[_0x4c7801(0x1c8)](){const _0x475bf5=_0x4c7801;return this[_0x475bf5(0x1d7)][_0x475bf5(0x1c8)];}[_0x4c7801(0x1d0)](){const _0x3632dd=_0x4c7801;return this['getAll']()[_0x3632dd(0x1d3)](_0x16fd92=>({'name':_0x16fd92[_0x3632dd(0x1ba)],'description':_0x16fd92[_0x3632dd(0x1d6)],'parameters':_0x16fd92[_0x3632dd(0x1d1)]}));}[_0x4c7801(0x1d2)](_0x5d9a48){const _0x5cf753=_0x4c7801;return this[_0x5cf753(0x1cd)][_0x5cf753(0x1bf)](_0x5d9a48),()=>{const _0x518116=_0x5cf753;this[_0x518116(0x1cd)][_0x518116(0x1bc)](_0x5d9a48);};}[_0x4c7801(0x1d9)](_0x209008){const _0x2e5f54=_0x4c7801;for(const _0x226611 of this[_0x2e5f54(0x1cd)]){try{_0x226611(_0x209008);}catch{}}}}
@@ -1,7 +1 @@
1
- /**
2
- * Tool System — Core Type Definitions
3
- *
4
- * Defines the AgentTool interface and related types.
5
- * Parameters use standard JSON Schema 7.
6
- */
7
- export {};
1
+ export{};
@@ -1,210 +1 @@
1
- /**
2
- * Tool System — Parameter Validator
3
- *
4
- * Validates tool parameters against their JSON Schema 7 definitions.
5
- * Uses `ajv` when available for full JSON Schema validation; falls back
6
- * to a minimal inline validator for basic type checking when ajv is
7
- * not yet installed.
8
- */
9
- /**
10
- * Error thrown when parameter validation fails.
11
- */
12
- export class ToolValidationError extends Error {
13
- errors;
14
- constructor(errors) {
15
- super(`Parameter validation failed: ${formatValidationErrors(errors)}`);
16
- this.errors = errors;
17
- this.name = 'ToolValidationError';
18
- }
19
- }
20
- // ---------------------------------------------------------------------------
21
- // ToolParamValidator
22
- // ---------------------------------------------------------------------------
23
- /**
24
- * Validates tool call parameters against a JSON Schema 7 definition.
25
- *
26
- * Attempts to use `ajv` for full schema validation. If ajv is not
27
- * available at runtime (not yet installed), falls back to a lightweight
28
- * inline validator that covers basic type and required-field checks.
29
- */
30
- export class ToolParamValidator {
31
- strategy = null;
32
- strategyReady = null;
33
- /**
34
- * Validate `params` against the given JSON Schema.
35
- *
36
- * @returns The validated (and potentially coerced) parameters.
37
- * @throws {ToolValidationError} if validation fails.
38
- */
39
- async validate(schema, params) {
40
- const strategy = await this.getStrategy();
41
- return strategy.validate(schema, params);
42
- }
43
- // -----------------------------------------------------------------------
44
- // Strategy Resolution
45
- // -----------------------------------------------------------------------
46
- getStrategy() {
47
- if (this.strategyReady) {
48
- return this.strategyReady;
49
- }
50
- this.strategyReady = (async () => {
51
- try {
52
- // Dynamic import for ESM compatibility.
53
- const AjvModule = await import('ajv');
54
- const Ajv = AjvModule.default ?? AjvModule;
55
- this.strategy = new AjvStrategy(Ajv);
56
- }
57
- catch {
58
- // ajv not installed — use the fallback.
59
- this.strategy = new FallbackStrategy();
60
- }
61
- return this.strategy;
62
- })();
63
- return this.strategyReady;
64
- }
65
- }
66
- // ---------------------------------------------------------------------------
67
- // Ajv-based Strategy
68
- // ---------------------------------------------------------------------------
69
- class AjvStrategy {
70
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
- ajvInstance;
72
- /** Cache of compiled validators keyed by a stable schema fingerprint. */
73
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
- compiledCache = new Map();
75
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
- constructor(Ajv) {
77
- this.ajvInstance = new Ajv({
78
- allErrors: true,
79
- coerceTypes: true,
80
- useDefaults: true,
81
- strict: false,
82
- });
83
- }
84
- validate(schema, params) {
85
- // Ensure we validate an object even if params is null/undefined.
86
- const data = params !== null && typeof params === 'object' && !Array.isArray(params)
87
- ? { ...params }
88
- : {};
89
- const validateFn = this.getOrCompile(schema);
90
- const valid = validateFn(data);
91
- if (!valid) {
92
- const errors = (validateFn.errors ?? []).map((err) => ({
93
- path: err.instancePath || '/',
94
- message: err.message ?? 'unknown error',
95
- }));
96
- throw new ToolValidationError(errors);
97
- }
98
- return data;
99
- }
100
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
101
- getOrCompile(schema) {
102
- const key = JSON.stringify(schema);
103
- let fn = this.compiledCache.get(key);
104
- if (!fn) {
105
- fn = this.ajvInstance.compile(schema);
106
- this.compiledCache.set(key, fn);
107
- }
108
- return fn;
109
- }
110
- }
111
- // ---------------------------------------------------------------------------
112
- // Fallback Strategy (no ajv)
113
- // ---------------------------------------------------------------------------
114
- /**
115
- * A lightweight validator that covers the most common schema shapes
116
- * used in tool parameter definitions:
117
- * - top-level `type: 'object'` with `properties` and `required`
118
- * - per-property primitive type checks (string, number, boolean, array, object)
119
- *
120
- * This is NOT a full JSON Schema 7 implementation — it exists solely
121
- * as a safety net until ajv is installed.
122
- */
123
- class FallbackStrategy {
124
- validate(schema, params) {
125
- const data = params !== null && typeof params === 'object' && !Array.isArray(params)
126
- ? { ...params }
127
- : {};
128
- const errors = [];
129
- // Check required fields.
130
- if (Array.isArray(schema.required)) {
131
- for (const key of schema.required) {
132
- if (data[key] === undefined || data[key] === null) {
133
- errors.push({
134
- path: `/${key}`,
135
- message: `required property '${key}' is missing`,
136
- });
137
- }
138
- }
139
- }
140
- // Check property types.
141
- if (schema.properties) {
142
- for (const [key, propSchema] of Object.entries(schema.properties)) {
143
- const value = data[key];
144
- if (value === undefined || value === null) {
145
- // Apply defaults if specified.
146
- if (propSchema.default !== undefined) {
147
- data[key] = propSchema.default;
148
- }
149
- continue;
150
- }
151
- const typeError = checkPrimitiveType(key, value, propSchema);
152
- if (typeError) {
153
- errors.push(typeError);
154
- }
155
- }
156
- }
157
- if (errors.length > 0) {
158
- throw new ToolValidationError(errors);
159
- }
160
- return data;
161
- }
162
- }
163
- // ---------------------------------------------------------------------------
164
- // Helpers
165
- // ---------------------------------------------------------------------------
166
- function checkPrimitiveType(key, value, schema) {
167
- const expectedType = schema.type;
168
- if (!expectedType || typeof expectedType !== 'string') {
169
- return null;
170
- }
171
- const actualType = Array.isArray(value) ? 'array' : typeof value;
172
- switch (expectedType) {
173
- case 'string':
174
- if (typeof value !== 'string') {
175
- return { path: `/${key}`, message: `expected string, got ${actualType}` };
176
- }
177
- break;
178
- case 'number':
179
- case 'integer':
180
- if (typeof value !== 'number') {
181
- return { path: `/${key}`, message: `expected number, got ${actualType}` };
182
- }
183
- break;
184
- case 'boolean':
185
- if (typeof value !== 'boolean') {
186
- return { path: `/${key}`, message: `expected boolean, got ${actualType}` };
187
- }
188
- break;
189
- case 'array':
190
- if (!Array.isArray(value)) {
191
- return { path: `/${key}`, message: `expected array, got ${actualType}` };
192
- }
193
- break;
194
- case 'object':
195
- if (typeof value !== 'object' || Array.isArray(value) || value === null) {
196
- return { path: `/${key}`, message: `expected object, got ${actualType}` };
197
- }
198
- break;
199
- // 'null' and unknown types are not checked — let them pass.
200
- }
201
- return null;
202
- }
203
- /**
204
- * Format validation errors into a single human-readable string.
205
- */
206
- export function formatValidationErrors(errors) {
207
- return errors
208
- .map((e) => `${e.path}: ${e.message}`)
209
- .join('; ');
210
- }
1
+ function _0x4475(_0x5ac291,_0x22664d){_0x5ac291=_0x5ac291-0x1bf;const _0x299876=_0x2998();let _0x44750f=_0x299876[_0x5ac291];if(_0x4475['OsxzfW']===undefined){var _0x3a1693=function(_0x460b5b){const _0x4eb075='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5d2fe1='',_0x1163dc='';for(let _0x546d5e=0x0,_0x1a5be7,_0x2cef9b,_0x26aba7=0x0;_0x2cef9b=_0x460b5b['charAt'](_0x26aba7++);~_0x2cef9b&&(_0x1a5be7=_0x546d5e%0x4?_0x1a5be7*0x40+_0x2cef9b:_0x2cef9b,_0x546d5e++%0x4)?_0x5d2fe1+=String['fromCharCode'](0xff&_0x1a5be7>>(-0x2*_0x546d5e&0x6)):0x0){_0x2cef9b=_0x4eb075['indexOf'](_0x2cef9b);}for(let _0x32b55a=0x0,_0x5e5009=_0x5d2fe1['length'];_0x32b55a<_0x5e5009;_0x32b55a++){_0x1163dc+='%'+('00'+_0x5d2fe1['charCodeAt'](_0x32b55a)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1163dc);};_0x4475['gxFdfu']=_0x3a1693,_0x4475['FqNZql']={},_0x4475['OsxzfW']=!![];}const _0x2d955a=_0x299876[0x0];_0x4475['dKXnjl']!==_0x2d955a&&(_0x4475['FqNZql']={},_0x4475['dKXnjl']=_0x2d955a);const _0x344792=_0x4475['FqNZql'][_0x5ac291];return _0x344792===undefined?(_0x44750f=_0x4475['gxFdfu'](_0x44750f),_0x4475['FqNZql'][_0x5ac291]=_0x44750f):_0x44750f=_0x344792,_0x44750f;}const _0x2ba28f=_0x4475;(function(_0x3da532,_0x56e8bf){const _0x53d4ca=_0x4475,_0x230ea6=_0x3da532();while(!![]){try{const _0x725c8a=-parseInt(_0x53d4ca(0x1d5))/0x1+-parseInt(_0x53d4ca(0x1c0))/0x2+-parseInt(_0x53d4ca(0x1dc))/0x3+-parseInt(_0x53d4ca(0x1e9))/0x4+parseInt(_0x53d4ca(0x1cd))/0x5*(-parseInt(_0x53d4ca(0x1d2))/0x6)+parseInt(_0x53d4ca(0x1d0))/0x7*(-parseInt(_0x53d4ca(0x1dd))/0x8)+parseInt(_0x53d4ca(0x1c3))/0x9;if(_0x725c8a===_0x56e8bf)break;else _0x230ea6['push'](_0x230ea6['shift']());}catch(_0x65c105){_0x230ea6['push'](_0x230ea6['shift']());}}}(_0x2998,0x71596));export class ToolValidationError extends Error{[_0x2ba28f(0x1c4)];constructor(_0x1163dc){const _0x3f8a90=_0x2ba28f;super('Parameter\x20validation\x20failed:\x20'[_0x3f8a90(0x1c7)](formatValidationErrors(_0x1163dc))),this[_0x3f8a90(0x1c4)]=_0x1163dc,this['name']=_0x3f8a90(0x1d6);}}export class ToolParamValidator{[_0x2ba28f(0x1ce)]=null;['strategyReady']=null;async[_0x2ba28f(0x1cf)](_0x546d5e,_0x1a5be7){const _0x1cda6e=_0x2ba28f,_0x2cef9b=await this[_0x1cda6e(0x1c5)]();return _0x2cef9b[_0x1cda6e(0x1cf)](_0x546d5e,_0x1a5be7);}[_0x2ba28f(0x1c5)](){const _0xcc8d5=_0x2ba28f;if(this[_0xcc8d5(0x1c8)])return this[_0xcc8d5(0x1c8)];return this[_0xcc8d5(0x1c8)]=((async()=>{const _0x417c37=_0xcc8d5;try{const _0x26aba7=await import(_0x417c37(0x1d1)),_0x32b55a=_0x26aba7[_0x417c37(0x1d4)]??_0x26aba7;this[_0x417c37(0x1ce)]=new AjvStrategy(_0x32b55a);}catch{this['strategy']=new FallbackStrategy();}return this[_0x417c37(0x1ce)];})()),this[_0xcc8d5(0x1c8)];}}function _0x2998(){const _0x58166e=['vg9VBfzHBgLKyxrPB25fCNjVCG','AxnbCNjHEq','y29TCgLSzwrdywnOzq','Aw5ZDgfUy2vqyxrO','BgvUz3rO','Aw50zwDLCG','oty4ndi0vMfgt3zm','nJK1mKjYA1fgwG','zxHWzwn0zwqGyxjYyxKSigDVDca','C2v0','BNvTyMvY','ywP2sw5ZDgfUy2u','zw50CMLLCW','BwvZC2fNzq','C3rYAw5NAwz5','BwfW','AM9PBG','zxHWzwn0zwqGBNvTyMvYlcbNB3qG','CMvXDwLYzwq','otqYmJe2y0HlEMvl','yxjYyxK','zxHWzwn0zwqGyM9VBgvHBIWGz290ia','mtqWnJy0off4z0rJwG','Cgf0Aa','ChvZAa','mJGWmdC1nZDQBuj6uu4','zxjYB3jZ','z2v0u3rYyxrLz3K','ChjVCgvYDgLLCW','y29Uy2f0','C3rYyxrLz3LszwfKEq','B2jQzwn0','C3rYAw5N','z2v0t3jdB21WAwXL','jYbPCYbTAxnZAw5N','nde0mZe3nxLLtwPbAq','C3rYyxrLz3K','DMfSAwrHDgu','mZm1m3rewe5xBG','ywP2','nKvxuLf0tG','z2v0','zgvMyxvSDa','mtqXmtaZwKPkAgPL'];_0x2998=function(){return _0x58166e;};return _0x2998();}class AjvStrategy{[_0x2ba28f(0x1e1)];[_0x2ba28f(0x1d8)]=new Map();constructor(_0x5e5009){const _0x4e49e7=_0x2ba28f;this[_0x4e49e7(0x1e1)]=new _0x5e5009({'allErrors':!![],'coerceTypes':!![],'useDefaults':!![],'strict':![]});}[_0x2ba28f(0x1cf)](_0x1f3f5e,_0x3121e7){const _0x62c37b=_0x2ba28f,_0x4e6935=_0x3121e7!==null&&typeof _0x3121e7===_0x62c37b(0x1c9)&&!Array[_0x62c37b(0x1d7)](_0x3121e7)?{..._0x3121e7}:{},_0x55482e=this[_0x62c37b(0x1cb)](_0x1f3f5e),_0x47345d=_0x55482e(_0x4e6935);if(!_0x47345d){const _0x42e596=(_0x55482e[_0x62c37b(0x1c4)]??[])[_0x62c37b(0x1e5)](_0x15a808=>({'path':_0x15a808[_0x62c37b(0x1d9)]||'/','message':_0x15a808[_0x62c37b(0x1e3)]??'unknown\x20error'}));throw new ToolValidationError(_0x42e596);}return _0x4e6935;}[_0x2ba28f(0x1cb)](_0x3de83a){const _0x2d48c4=_0x2ba28f,_0x406826=JSON[_0x2d48c4(0x1e4)](_0x3de83a);let _0x3734bf=this[_0x2d48c4(0x1d8)][_0x2d48c4(0x1d3)](_0x406826);return!_0x3734bf&&(_0x3734bf=this[_0x2d48c4(0x1e1)]['compile'](_0x3de83a),this[_0x2d48c4(0x1d8)][_0x2d48c4(0x1df)](_0x406826,_0x3734bf)),_0x3734bf;}}class FallbackStrategy{['validate'](_0x3018d7,_0x1e4c34){const _0x2ab4ca=_0x2ba28f,_0x505f5c=_0x1e4c34!==null&&typeof _0x1e4c34===_0x2ab4ca(0x1c9)&&!Array[_0x2ab4ca(0x1d7)](_0x1e4c34)?{..._0x1e4c34}:{},_0x237ad4=[];if(Array[_0x2ab4ca(0x1d7)](_0x3018d7[_0x2ab4ca(0x1e8)]))for(const _0x374684 of _0x3018d7[_0x2ab4ca(0x1e8)]){(_0x505f5c[_0x374684]===undefined||_0x505f5c[_0x374684]===null)&&_0x237ad4['push']({'path':'/'[_0x2ab4ca(0x1c7)](_0x374684),'message':'required\x20property\x20\x27'[_0x2ab4ca(0x1c7)](_0x374684,_0x2ab4ca(0x1cc))});}if(_0x3018d7['properties'])for(const [_0x3b84df,_0x387e3d]of Object[_0x2ab4ca(0x1e2)](_0x3018d7[_0x2ab4ca(0x1c6)])){const _0x433a4f=_0x505f5c[_0x3b84df];if(_0x433a4f===undefined||_0x433a4f===null){_0x387e3d['default']!==undefined&&(_0x505f5c[_0x3b84df]=_0x387e3d[_0x2ab4ca(0x1d4)]);continue;}const _0x405495=checkPrimitiveType(_0x3b84df,_0x433a4f,_0x387e3d);_0x405495&&_0x237ad4[_0x2ab4ca(0x1c2)](_0x405495);}if(_0x237ad4[_0x2ab4ca(0x1da)]>0x0)throw new ToolValidationError(_0x237ad4);return _0x505f5c;}}function checkPrimitiveType(_0x2a577e,_0x49379d,_0x47e801){const _0x1b64f3=_0x2ba28f,_0x4b7d41=_0x47e801['type'];if(!_0x4b7d41||typeof _0x4b7d41!==_0x1b64f3(0x1ca))return null;const _0x4fe515=Array['isArray'](_0x49379d)?_0x1b64f3(0x1ea):typeof _0x49379d;switch(_0x4b7d41){case _0x1b64f3(0x1ca):if(typeof _0x49379d!==_0x1b64f3(0x1ca))return{'path':'/'[_0x1b64f3(0x1c7)](_0x2a577e),'message':'expected\x20string,\x20got\x20'[_0x1b64f3(0x1c7)](_0x4fe515)};break;case'number':case _0x1b64f3(0x1db):if(typeof _0x49379d!==_0x1b64f3(0x1e0))return{'path':'/'['concat'](_0x2a577e),'message':_0x1b64f3(0x1e7)['concat'](_0x4fe515)};break;case'boolean':if(typeof _0x49379d!=='boolean')return{'path':'/'[_0x1b64f3(0x1c7)](_0x2a577e),'message':_0x1b64f3(0x1bf)['concat'](_0x4fe515)};break;case _0x1b64f3(0x1ea):if(!Array[_0x1b64f3(0x1d7)](_0x49379d))return{'path':'/'[_0x1b64f3(0x1c7)](_0x2a577e),'message':_0x1b64f3(0x1de)[_0x1b64f3(0x1c7)](_0x4fe515)};break;case _0x1b64f3(0x1c9):if(typeof _0x49379d!==_0x1b64f3(0x1c9)||Array[_0x1b64f3(0x1d7)](_0x49379d)||_0x49379d===null)return{'path':'/'['concat'](_0x2a577e),'message':'expected\x20object,\x20got\x20'[_0x1b64f3(0x1c7)](_0x4fe515)};break;}return null;}export function formatValidationErrors(_0x5107fc){const _0x21489f=_0x2ba28f;return _0x5107fc[_0x21489f(0x1e5)](_0x1678fc=>''[_0x21489f(0x1c7)](_0x1678fc[_0x21489f(0x1c1)],':\x20')['concat'](_0x1678fc[_0x21489f(0x1e3)]))[_0x21489f(0x1e6)](';\x20');}
package/dist/types.js CHANGED
@@ -1,7 +1 @@
1
- /**
2
- * Core Agent event types.
3
- *
4
- * These events are emitted by the Agent engine during execution and consumed
5
- * by subscribers (e.g. SelfAgentService) to drive UI updates and persistence.
6
- */
7
- export {};
1
+ export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aragon-agent/core",
3
- "version": "0.2.92",
3
+ "version": "0.2.94",
4
4
  "description": "AragonAgent core engine — LLM provider adapters, streaming, tool registry/execution, steering, idle watchdog, and an optional isolated-vm sandbox.",
5
5
  "license": "MIT",
6
6
  "author": "AragonAgent contributors",
@@ -100,7 +100,8 @@
100
100
  "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
101
101
  "test": "vitest run",
102
102
  "verify:dist": "npm run build && node examples/consumer-smoke/run.mjs",
103
- "prepublishOnly": "node scripts/check-publishable.mjs && npm run build"
103
+ "build:release": "npm run build && node ../../scripts/obfuscate-dist.mjs core",
104
+ "prepublishOnly": "node scripts/check-publishable.mjs && npm run build:release"
104
105
  },
105
106
  "optionalDependencies": {
106
107
  "ajv": "^8.18.0",