@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.
- package/dist/engine/accept-steering.js +1 -15
- package/dist/engine/agent-loop.js +1 -533
- package/dist/engine/agent.js +1 -538
- package/dist/engine/compaction.js +1 -268
- package/dist/engine/context-manager.js +1 -13
- package/dist/engine/message-manager.js +1 -39
- package/dist/engine/steering.js +1 -72
- package/dist/engine/tool-result-content.js +1 -39
- package/dist/engine/watchdog.js +1 -73
- package/dist/index.js +1 -99
- package/dist/llm/context-window.js +1 -46
- package/dist/llm/image-tokens.js +1 -11
- package/dist/llm/model-discovery.js +1 -18
- package/dist/llm/model-registry.js +1 -370
- package/dist/llm/output-limit-recovery.js +1 -263
- package/dist/llm/output-limits.js +1 -283
- package/dist/llm/provider.js +1 -171
- package/dist/llm/providers/anthropic.js +1 -514
- package/dist/llm/providers/google.js +1 -464
- package/dist/llm/providers/index.js +1 -205
- package/dist/llm/providers/openai.js +1 -520
- package/dist/llm/providers/tool-result-images.js +1 -52
- package/dist/llm/retry.js +1 -948
- package/dist/llm/sse-parser.js +1 -103
- package/dist/llm/stream-utils.js +1 -118
- package/dist/llm/types.js +1 -17
- package/dist/sandbox/console-capture.js +1 -56
- package/dist/sandbox/http-bridge.js +1 -143
- package/dist/sandbox/isolated-vm-sandbox.js +1 -226
- package/dist/sandbox/tool-bridge.js +1 -98
- package/dist/sandbox/types.js +1 -8
- package/dist/skills/constants.js +1 -179
- package/dist/skills/disclosure.js +1 -788
- package/dist/skills/frontmatter.js +1 -177
- package/dist/skills/index.js +1 -18
- package/dist/skills/skill-find-tool.js +1 -117
- package/dist/skills/skill-registry.js +1 -208
- package/dist/skills/skill-tool.js +1 -96
- package/dist/skills/tool-policy.js +1 -272
- package/dist/skills/types.js +1 -8
- package/dist/skills/validate.js +1 -264
- package/dist/tools/executor.js +1 -281
- package/dist/tools/helpers.js +1 -87
- package/dist/tools/registry.js +1 -119
- package/dist/tools/types.js +1 -7
- package/dist/tools/validator.js +1 -210
- package/dist/types.js +1 -7
- package/package.json +3 -2
|
@@ -1,226 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* CodeAct Sandbox — IsolatedVmSandbox
|
|
3
|
-
*
|
|
4
|
-
* Primary implementation of the CodeActSandbox interface using the
|
|
5
|
-
* `isolated-vm` package. Provides a memory-limited, time-limited V8
|
|
6
|
-
* Isolate with bridged tool access, console capture, and HTTP fetch.
|
|
7
|
-
*
|
|
8
|
-
* Key design decisions:
|
|
9
|
-
* - Lazy initialization: the V8 Isolate is not created until first execute().
|
|
10
|
-
* - Variable persistence: the same Context is reused across execute() calls
|
|
11
|
-
* so variables defined in one call are available in subsequent calls.
|
|
12
|
-
* - reset() destroys the Context and re-creates it (clears all variables).
|
|
13
|
-
* - dispose() releases the Isolate entirely.
|
|
14
|
-
*/
|
|
15
|
-
import ivm from 'isolated-vm';
|
|
16
|
-
import { ConsoleCapture } from './console-capture.js';
|
|
17
|
-
import { ToolBridge } from './tool-bridge.js';
|
|
18
|
-
import { HttpBridge } from './http-bridge.js';
|
|
19
|
-
/** Default V8 Isolate memory limit (megabytes). */
|
|
20
|
-
const DEFAULT_MEMORY_LIMIT_MB = 128;
|
|
21
|
-
/** Default per-execution timeout (milliseconds). */
|
|
22
|
-
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
23
|
-
/**
|
|
24
|
-
* IsolatedVmSandbox executes LLM-generated JavaScript code in an isolated
|
|
25
|
-
* V8 environment with injected tool bridges, console capture, and HTTP access.
|
|
26
|
-
*/
|
|
27
|
-
export class IsolatedVmSandbox {
|
|
28
|
-
isolate = null;
|
|
29
|
-
context = null;
|
|
30
|
-
disposed = false;
|
|
31
|
-
memoryLimitMB;
|
|
32
|
-
defaultTimeout;
|
|
33
|
-
tools;
|
|
34
|
-
allowedHosts;
|
|
35
|
-
globals;
|
|
36
|
-
// Bridge instances — recreated on reset().
|
|
37
|
-
consoleCapture = null;
|
|
38
|
-
toolBridge = null;
|
|
39
|
-
httpBridge = null;
|
|
40
|
-
constructor(config = {}) {
|
|
41
|
-
this.memoryLimitMB = config.memoryLimitMB ?? DEFAULT_MEMORY_LIMIT_MB;
|
|
42
|
-
this.defaultTimeout = config.defaultTimeout ?? DEFAULT_TIMEOUT_MS;
|
|
43
|
-
this.tools = config.tools ?? [];
|
|
44
|
-
this.allowedHosts = config.allowedHosts ?? [];
|
|
45
|
-
this.globals = config.globals ?? {};
|
|
46
|
-
}
|
|
47
|
-
// ---------------------------------------------------------------------------
|
|
48
|
-
// CodeActSandbox interface
|
|
49
|
-
// ---------------------------------------------------------------------------
|
|
50
|
-
get isDisposed() {
|
|
51
|
-
return this.disposed;
|
|
52
|
-
}
|
|
53
|
-
async execute(code, options) {
|
|
54
|
-
this.assertNotDisposed();
|
|
55
|
-
// Lazy initialization on first execute().
|
|
56
|
-
if (!this.isolate) {
|
|
57
|
-
await this.initialize();
|
|
58
|
-
}
|
|
59
|
-
// Honor AbortSignal if already aborted.
|
|
60
|
-
if (options?.signal?.aborted) {
|
|
61
|
-
return {
|
|
62
|
-
consoleOutput: [],
|
|
63
|
-
error: { name: 'AbortError', message: 'Execution aborted before start' },
|
|
64
|
-
duration: 0,
|
|
65
|
-
toolCalls: [],
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
const timeout = options?.timeout ?? this.defaultTimeout;
|
|
69
|
-
const startTime = Date.now();
|
|
70
|
-
// Clear per-execution state.
|
|
71
|
-
this.toolBridge.clearToolCalls();
|
|
72
|
-
// Wrap user code in an async IIFE for top-level await support.
|
|
73
|
-
const wrappedCode = wrapCode(code);
|
|
74
|
-
try {
|
|
75
|
-
// Use context.eval with promise:true to support async code.
|
|
76
|
-
const rawResult = await this.context.eval(wrappedCode, {
|
|
77
|
-
timeout,
|
|
78
|
-
promise: true,
|
|
79
|
-
});
|
|
80
|
-
// Serialize the return value. Handle non-serializable values gracefully.
|
|
81
|
-
let returnValue;
|
|
82
|
-
if (rawResult !== undefined && rawResult !== null) {
|
|
83
|
-
try {
|
|
84
|
-
returnValue = typeof rawResult === 'string'
|
|
85
|
-
? rawResult
|
|
86
|
-
: JSON.stringify(rawResult);
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
returnValue = String(rawResult);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
returnValue,
|
|
94
|
-
consoleOutput: this.consoleCapture.drain(),
|
|
95
|
-
duration: Date.now() - startTime,
|
|
96
|
-
toolCalls: this.toolBridge.getToolCalls(),
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
catch (err) {
|
|
100
|
-
const errorInfo = extractErrorInfo(err);
|
|
101
|
-
return {
|
|
102
|
-
consoleOutput: this.consoleCapture.drain(),
|
|
103
|
-
error: errorInfo,
|
|
104
|
-
duration: Date.now() - startTime,
|
|
105
|
-
toolCalls: this.toolBridge.getToolCalls(),
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
async reset() {
|
|
110
|
-
this.assertNotDisposed();
|
|
111
|
-
if (!this.isolate) {
|
|
112
|
-
// Not yet initialized — nothing to reset.
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
// Release the current context.
|
|
116
|
-
if (this.context) {
|
|
117
|
-
this.context.release();
|
|
118
|
-
this.context = null;
|
|
119
|
-
}
|
|
120
|
-
// Create a fresh context and re-inject all bridges.
|
|
121
|
-
await this.createContextAndInjectBridges();
|
|
122
|
-
}
|
|
123
|
-
dispose() {
|
|
124
|
-
if (this.disposed)
|
|
125
|
-
return;
|
|
126
|
-
this.disposed = true;
|
|
127
|
-
if (this.context) {
|
|
128
|
-
this.context.release();
|
|
129
|
-
this.context = null;
|
|
130
|
-
}
|
|
131
|
-
if (this.isolate) {
|
|
132
|
-
this.isolate.dispose();
|
|
133
|
-
this.isolate = null;
|
|
134
|
-
}
|
|
135
|
-
this.consoleCapture = null;
|
|
136
|
-
this.toolBridge = null;
|
|
137
|
-
this.httpBridge = null;
|
|
138
|
-
}
|
|
139
|
-
// ---------------------------------------------------------------------------
|
|
140
|
-
// Private — Initialization
|
|
141
|
-
// ---------------------------------------------------------------------------
|
|
142
|
-
/** Full lazy initialization: create Isolate, Context, and inject bridges. */
|
|
143
|
-
async initialize() {
|
|
144
|
-
this.isolate = new ivm.Isolate({ memoryLimit: this.memoryLimitMB });
|
|
145
|
-
await this.createContextAndInjectBridges();
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Create a new Context within the existing Isolate and inject all
|
|
149
|
-
* bridges (console, tools, HTTP, globals).
|
|
150
|
-
*/
|
|
151
|
-
async createContextAndInjectBridges() {
|
|
152
|
-
this.context = await this.isolate.createContext();
|
|
153
|
-
// --- Console capture ---
|
|
154
|
-
this.consoleCapture = new ConsoleCapture();
|
|
155
|
-
await this.consoleCapture.inject(this.context);
|
|
156
|
-
// --- Tool bridge ---
|
|
157
|
-
this.toolBridge = new ToolBridge(this.tools);
|
|
158
|
-
await this.toolBridge.injectAll(this.context);
|
|
159
|
-
// --- HTTP bridge ---
|
|
160
|
-
this.httpBridge = new HttpBridge({ allowedHosts: this.allowedHosts });
|
|
161
|
-
await this.httpBridge.inject(this.context);
|
|
162
|
-
// --- Pre-injected globals ---
|
|
163
|
-
await this.injectGlobals();
|
|
164
|
-
}
|
|
165
|
-
/** Validate that a name is a safe JavaScript identifier. */
|
|
166
|
-
static validateIdentifier(name) {
|
|
167
|
-
if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) {
|
|
168
|
-
throw new Error(`Invalid global variable name "${name}": must be a valid JS identifier`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/** Inject user-provided global variables into the sandbox context. */
|
|
172
|
-
async injectGlobals() {
|
|
173
|
-
const jail = this.context.global;
|
|
174
|
-
for (const [key, value] of Object.entries(this.globals)) {
|
|
175
|
-
// SECURITY: Validate key is a safe identifier before interpolating into eval'd code.
|
|
176
|
-
IsolatedVmSandbox.validateIdentifier(key);
|
|
177
|
-
// Only primitive values and JSON-serializable objects can be transferred.
|
|
178
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
179
|
-
await jail.set(key, value);
|
|
180
|
-
}
|
|
181
|
-
else if (value === null || value === undefined) {
|
|
182
|
-
await jail.set(key, value ?? null);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
// Serialize complex values as JSON and parse inside sandbox.
|
|
186
|
-
const json = JSON.stringify(value);
|
|
187
|
-
await this.context.eval(`globalThis.${key} = ${json};`);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
// ---------------------------------------------------------------------------
|
|
192
|
-
// Private — Helpers
|
|
193
|
-
// ---------------------------------------------------------------------------
|
|
194
|
-
/** Throw immediately if the sandbox has been disposed. */
|
|
195
|
-
assertNotDisposed() {
|
|
196
|
-
if (this.disposed) {
|
|
197
|
-
throw new Error('Cannot use a disposed CodeActSandbox');
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
// ---------------------------------------------------------------------------
|
|
202
|
-
// Module-level helpers
|
|
203
|
-
// ---------------------------------------------------------------------------
|
|
204
|
-
/**
|
|
205
|
-
* Wrap user code in an async IIFE so top-level `await` and `return` work.
|
|
206
|
-
*/
|
|
207
|
-
function wrapCode(userCode) {
|
|
208
|
-
return `(async () => {\n${userCode}\n})()`;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Extract a structured error object from an unknown thrown value.
|
|
212
|
-
* Handles isolated-vm timeout errors, memory errors, and generic JS errors.
|
|
213
|
-
*/
|
|
214
|
-
function extractErrorInfo(err) {
|
|
215
|
-
if (err instanceof Error) {
|
|
216
|
-
return {
|
|
217
|
-
name: err.name,
|
|
218
|
-
message: err.message,
|
|
219
|
-
stack: err.stack,
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
return {
|
|
223
|
-
name: 'Error',
|
|
224
|
-
message: String(err),
|
|
225
|
-
};
|
|
226
|
-
}
|
|
1
|
+
const _0x312614=_0x4a91;(function(_0x9b2eb6,_0x1c4bdf){const _0x60c7a1=_0x4a91,_0x42ee30=_0x9b2eb6();while(!![]){try{const _0xa380a0=parseInt(_0x60c7a1(0x111))/0x1+-parseInt(_0x60c7a1(0x10a))/0x2*(-parseInt(_0x60c7a1(0x106))/0x3)+parseInt(_0x60c7a1(0x102))/0x4+parseInt(_0x60c7a1(0x10c))/0x5+parseInt(_0x60c7a1(0xfb))/0x6+-parseInt(_0x60c7a1(0x10e))/0x7*(-parseInt(_0x60c7a1(0x115))/0x8)+-parseInt(_0x60c7a1(0x122))/0x9;if(_0xa380a0===_0x1c4bdf)break;else _0x42ee30['push'](_0x42ee30['shift']());}catch(_0x10f1cf){_0x42ee30['push'](_0x42ee30['shift']());}}}(_0x381d,0x9a6dc));import _0x4f08a2 from'isolated-vm';import{ConsoleCapture}from'./console-capture.js';function _0x381d(){const _0xd42c56=['cN0PkcK','C2LNBMfS','rxjYB3i','Aw5PDgLHBgL6zq','Ahr0CejYAwrNzq','zgLZCg9Zzwq','id0G','y29UC29SzunHChr1CMu','nZe4odmXmLzpAK5lyW','y3jLyxrLq29UDgv4DefUzeLUAMvJDejYAwrNzxm','z2v0vg9VBenHBgXZ','zxzHBa','zgvMyxvSDfrPBwvVDxq','zw50CMLLCW','Dg9VBhm','ndu1mdeWnfLtq0HvuG','y3jLyxrLq29UDgv4Da','y29Uy2f0','AxnVBgf0zq','mtm5nJa5mKPpBuzXDa','BM93','y29UDgv4Da','y2XLyxjuB29Sq2fSBhm','mMTpqLfmzW','C3rYAw5NAwz5','mJa1mJqWsKPmwKP4','Aw5Qzwn0qwXS','n0XzsLjYrW','z2XVyMfSCW','kgfZEw5JicGPid0+ihSk','oduXnZm3sgnbyuji','sxnVBgf0zq','yxnZzxj0tM90rgLZCg9Zzwq','sw52ywXPzcbNBg9IywWGDMfYAwfIBguGBMfTzsaI','nte1mJe0ng5uDKXfEa','Aw5Qzwn0r2XVyMfSCW','q2fUBM90ihvZzsbHigrPC3bVC2vKienVzgvby3rtyw5KyM94','Dg9VBejYAwrNzq','iJOGBxvZDcbIzsbHihzHBgLKiePtigLKzw50AwzPzxi','ywjVCNrLza','zgLZCg9Zzq','C3rYAw5N','BwvTB3j5tgLTAxrnqG','DgLTzw91Da','C3rHy2S','zhjHAw4','zxHLy3v0zq','mZmZndy4ndvnzKfuA3q','CMvZzxq','BNvTyMvY','CMvSzwfZzq','ywXSB3DLzeHVC3rZ','rxHLy3v0Aw9UigfIB3j0zwqGyMvMB3jLihn0yxj0','qwjVCNrfCNjVCG','BwvZC2fNzq','Aw5Qzwn0','C2v0'];_0x381d=function(){return _0xd42c56;};return _0x381d();}import{ToolBridge}from'./tool-bridge.js';function _0x4a91(_0x48feda,_0x20e695){_0x48feda=_0x48feda-0xec;const _0x381dd2=_0x381d();let _0x4a91f9=_0x381dd2[_0x48feda];if(_0x4a91['RwQKhI']===undefined){var _0x538bba=function(_0x189ed9){const _0x51672a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x324cce='',_0x4f08a2='';for(let _0x2e2f0e=0x0,_0x371d92,_0x40d3da,_0x374eb0=0x0;_0x40d3da=_0x189ed9['charAt'](_0x374eb0++);~_0x40d3da&&(_0x371d92=_0x2e2f0e%0x4?_0x371d92*0x40+_0x40d3da:_0x40d3da,_0x2e2f0e++%0x4)?_0x324cce+=String['fromCharCode'](0xff&_0x371d92>>(-0x2*_0x2e2f0e&0x6)):0x0){_0x40d3da=_0x51672a['indexOf'](_0x40d3da);}for(let _0x52c73d=0x0,_0xdbc41c=_0x324cce['length'];_0x52c73d<_0xdbc41c;_0x52c73d++){_0x4f08a2+='%'+('00'+_0x324cce['charCodeAt'](_0x52c73d)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4f08a2);};_0x4a91['olpSzK']=_0x538bba,_0x4a91['KRBkRz']={},_0x4a91['RwQKhI']=!![];}const _0x2b0a58=_0x381dd2[0x0];_0x4a91['fuanbq']!==_0x2b0a58&&(_0x4a91['KRBkRz']={},_0x4a91['fuanbq']=_0x2b0a58);const _0x5d7334=_0x4a91['KRBkRz'][_0x48feda];return _0x5d7334===undefined?(_0x4a91f9=_0x4a91['olpSzK'](_0x4a91f9),_0x4a91['KRBkRz'][_0x48feda]=_0x4a91f9):_0x4a91f9=_0x5d7334,_0x4a91f9;}import{HttpBridge}from'./http-bridge.js';const DEFAULT_MEMORY_LIMIT_MB=0x80,DEFAULT_TIMEOUT_MS=0x7530;export class IsolatedVmSandbox{[_0x312614(0x105)]=null;[_0x312614(0x108)]=null;['disposed']=![];['memoryLimitMB'];[_0x312614(0xff)];[_0x312614(0x101)];[_0x312614(0xed)];['globals'];['consoleCapture']=null;[_0x312614(0x118)]=null;['httpBridge']=null;constructor(_0x2e2f0e={}){const _0x5184c0=_0x312614;this[_0x5184c0(0x11d)]=_0x2e2f0e[_0x5184c0(0x11d)]??DEFAULT_MEMORY_LIMIT_MB,this[_0x5184c0(0xff)]=_0x2e2f0e[_0x5184c0(0xff)]??DEFAULT_TIMEOUT_MS,this[_0x5184c0(0x101)]=_0x2e2f0e[_0x5184c0(0x101)]??[],this[_0x5184c0(0xed)]=_0x2e2f0e[_0x5184c0(0xed)]??[],this['globals']=_0x2e2f0e[_0x5184c0(0x10f)]??{};}get['isDisposed'](){return this['disposed'];}async[_0x312614(0x121)](_0x371d92,_0x40d3da){const _0x485e7e=_0x312614;this['assertNotDisposed']();!this[_0x485e7e(0x105)]&&await this[_0x485e7e(0xf6)]();if(_0x40d3da?.[_0x485e7e(0xf4)]?.[_0x485e7e(0x11a)])return{'consoleOutput':[],'error':{'name':_0x485e7e(0xef),'message':_0x485e7e(0xee)},'duration':0x0,'toolCalls':[]};const _0x374eb0=_0x40d3da?.[_0x485e7e(0x11e)]??this['defaultTimeout'],_0x52c73d=Date[_0x485e7e(0x107)]();this[_0x485e7e(0x118)][_0x485e7e(0x109)]();const _0xdbc41c=wrapCode(_0x371d92);try{const _0x5cc993=await this[_0x485e7e(0x108)]['eval'](_0xdbc41c,{'timeout':_0x374eb0,'promise':!![]});let _0x15c1f4;if(_0x5cc993!==undefined&&_0x5cc993!==null)try{_0x15c1f4=typeof _0x5cc993===_0x485e7e(0x11c)?_0x5cc993:JSON['stringify'](_0x5cc993);}catch{_0x15c1f4=String(_0x5cc993);}return{'returnValue':_0x15c1f4,'consoleOutput':this['consoleCapture']['drain'](),'duration':Date['now']()-_0x52c73d,'toolCalls':this['toolBridge'][_0x485e7e(0xfd)]()};}catch(_0x2acdd){const _0x1c9d6c=extractErrorInfo(_0x2acdd);return{'consoleOutput':this[_0x485e7e(0xfa)][_0x485e7e(0x120)](),'error':_0x1c9d6c,'duration':Date['now']()-_0x52c73d,'toolCalls':this[_0x485e7e(0x118)]['getToolCalls']()};}}async[_0x312614(0x123)](){const _0x555b97=_0x312614;this[_0x555b97(0x113)]();if(!this[_0x555b97(0x105)])return;this[_0x555b97(0x108)]&&(this[_0x555b97(0x108)]['release'](),this['context']=null),await this[_0x555b97(0xfc)]();}[_0x312614(0x11b)](){const _0x553bac=_0x312614;if(this['disposed'])return;this['disposed']=!![],this[_0x553bac(0x108)]&&(this[_0x553bac(0x108)][_0x553bac(0xec)](),this[_0x553bac(0x108)]=null),this['isolate']&&(this['isolate'][_0x553bac(0x11b)](),this[_0x553bac(0x105)]=null),this[_0x553bac(0xfa)]=null,this[_0x553bac(0x118)]=null,this['httpBridge']=null;}async['initialize'](){const _0x52d0c5=_0x312614;this['isolate']=new _0x4f08a2[(_0x52d0c5(0x112))]({'memoryLimit':this[_0x52d0c5(0x11d)]}),await this[_0x52d0c5(0xfc)]();}async[_0x312614(0xfc)](){const _0x121187=_0x312614;this[_0x121187(0x108)]=await this[_0x121187(0x105)][_0x121187(0x103)](),this[_0x121187(0xfa)]=new ConsoleCapture(),await this['consoleCapture']['inject'](this[_0x121187(0x108)]),this[_0x121187(0x118)]=new ToolBridge(this['tools']),await this['toolBridge'][_0x121187(0x10d)](this[_0x121187(0x108)]),this[_0x121187(0xf7)]=new HttpBridge({'allowedHosts':this[_0x121187(0xed)]}),await this['httpBridge'][_0x121187(0xf1)](this['context']),await this['injectGlobals']();}static['validateIdentifier'](_0x88cd87){const _0x35f0da=_0x312614;if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/['test'](_0x88cd87))throw new Error(_0x35f0da(0x114)[_0x35f0da(0x104)](_0x88cd87,_0x35f0da(0x119)));}async[_0x312614(0x116)](){const _0x1b9d67=_0x312614,_0x2a54e1=this[_0x1b9d67(0x108)]['global'];for(const [_0x5674a5,_0x1fa245]of Object[_0x1b9d67(0x100)](this[_0x1b9d67(0x10f)])){IsolatedVmSandbox['validateIdentifier'](_0x5674a5);if(typeof _0x1fa245===_0x1b9d67(0x11c)||typeof _0x1fa245===_0x1b9d67(0x124)||typeof _0x1fa245==='boolean')await _0x2a54e1[_0x1b9d67(0xf2)](_0x5674a5,_0x1fa245);else{if(_0x1fa245===null||_0x1fa245===undefined)await _0x2a54e1['set'](_0x5674a5,_0x1fa245??null);else{const _0x195a7a=JSON[_0x1b9d67(0x10b)](_0x1fa245);await this[_0x1b9d67(0x108)][_0x1b9d67(0xfe)]('globalThis.'[_0x1b9d67(0x104)](_0x5674a5,_0x1b9d67(0xf9))[_0x1b9d67(0x104)](_0x195a7a,';'));}}}}['assertNotDisposed'](){const _0x43f95c=_0x312614;if(this[_0x43f95c(0xf8)])throw new Error(_0x43f95c(0x117));}}function wrapCode(_0x519021){const _0x11fa28=_0x312614;return _0x11fa28(0x110)['concat'](_0x519021,_0x11fa28(0xf3));}function extractErrorInfo(_0x1173f2){const _0x4d3d2d=_0x312614;if(_0x1173f2 instanceof Error)return{'name':_0x1173f2['name'],'message':_0x1173f2[_0x4d3d2d(0xf0)],'stack':_0x1173f2[_0x4d3d2d(0x11f)]};return{'name':_0x4d3d2d(0xf5),'message':String(_0x1173f2)};}
|
|
@@ -1,98 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* CodeAct Sandbox — Tool Bridge
|
|
3
|
-
*
|
|
4
|
-
* Bridges AgentTool instances into the isolated-vm sandbox as globally
|
|
5
|
-
* available async functions. Only tools marked `bridgeable: true` are
|
|
6
|
-
* injected. Each call is recorded for inclusion in ExecuteResult.toolCalls.
|
|
7
|
-
*/
|
|
8
|
-
import ivm from 'isolated-vm';
|
|
9
|
-
/**
|
|
10
|
-
* ToolBridge manages the injection of AgentTools into an isolated-vm
|
|
11
|
-
* Context and records every tool invocation made from sandbox code.
|
|
12
|
-
*/
|
|
13
|
-
export class ToolBridge {
|
|
14
|
-
tools;
|
|
15
|
-
toolCalls = [];
|
|
16
|
-
constructor(tools) {
|
|
17
|
-
this.tools = tools;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Inject all bridgeable tools as global async functions in the given context.
|
|
21
|
-
*
|
|
22
|
-
* For each tool with `bridgeable: true`, a global function is registered
|
|
23
|
-
* using the tool's `bridgeName` (falling back to `name`). The sandbox
|
|
24
|
-
* function signature is:
|
|
25
|
-
*
|
|
26
|
-
* async function toolName(args: object): Promise<string>
|
|
27
|
-
*
|
|
28
|
-
* The host-side callback executes the real tool, records the call, and
|
|
29
|
-
* returns the text result (or throws on error).
|
|
30
|
-
*/
|
|
31
|
-
async injectAll(context) {
|
|
32
|
-
const bridgeableTools = this.tools.filter((t) => t.bridgeable);
|
|
33
|
-
for (const tool of bridgeableTools) {
|
|
34
|
-
await this.injectTool(context, tool);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/** Return all tool call records accumulated since the last clear. */
|
|
38
|
-
getToolCalls() {
|
|
39
|
-
return [...this.toolCalls];
|
|
40
|
-
}
|
|
41
|
-
/** Clear accumulated tool call records. Called before each execute(). */
|
|
42
|
-
clearToolCalls() {
|
|
43
|
-
this.toolCalls = [];
|
|
44
|
-
}
|
|
45
|
-
// ---------------------------------------------------------------------------
|
|
46
|
-
// Private
|
|
47
|
-
// ---------------------------------------------------------------------------
|
|
48
|
-
/**
|
|
49
|
-
* Validate that a function name is a safe JavaScript identifier.
|
|
50
|
-
* Prevents code injection via malicious tool names in evalClosure.
|
|
51
|
-
*/
|
|
52
|
-
static validateIdentifier(name) {
|
|
53
|
-
if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) {
|
|
54
|
-
throw new Error(`Invalid bridge function name "${name}": must be a valid JS identifier (letters, digits, _, $)`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async injectTool(context, tool) {
|
|
58
|
-
const fnName = tool.bridgeName || tool.name;
|
|
59
|
-
// SECURITY: Validate fnName is a safe identifier before interpolating into eval'd code.
|
|
60
|
-
ToolBridge.validateIdentifier(fnName);
|
|
61
|
-
// Host-side callback invoked when sandbox code calls the bridged function.
|
|
62
|
-
const callback = new ivm.Reference(async (argsJson) => {
|
|
63
|
-
const args = JSON.parse(argsJson);
|
|
64
|
-
const startTime = Date.now();
|
|
65
|
-
try {
|
|
66
|
-
const result = await tool.execute(`sandbox-${Date.now()}`, args, { signal: undefined });
|
|
67
|
-
const text = result.content
|
|
68
|
-
.filter((c) => c.type === 'text')
|
|
69
|
-
.map((c) => c.text)
|
|
70
|
-
.join('\n');
|
|
71
|
-
this.toolCalls.push({
|
|
72
|
-
toolName: tool.name,
|
|
73
|
-
args,
|
|
74
|
-
result: text,
|
|
75
|
-
duration: Date.now() - startTime,
|
|
76
|
-
});
|
|
77
|
-
return text;
|
|
78
|
-
}
|
|
79
|
-
catch (err) {
|
|
80
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
81
|
-
this.toolCalls.push({
|
|
82
|
-
toolName: tool.name,
|
|
83
|
-
args,
|
|
84
|
-
error: errMsg,
|
|
85
|
-
duration: Date.now() - startTime,
|
|
86
|
-
});
|
|
87
|
-
throw new Error(errMsg);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
// Register the async function in the sandbox's global scope.
|
|
91
|
-
// $0 is the ivm.Reference to the host callback.
|
|
92
|
-
// The sandbox function JSON-stringifies args before sending to host,
|
|
93
|
-
// and awaits the promise returned by the host callback.
|
|
94
|
-
await context.evalClosure(`globalThis.${fnName} = async function(args) {
|
|
95
|
-
return await $0.apply(undefined, [JSON.stringify(args)], { result: { promise: true } });
|
|
96
|
-
}`, [callback], { arguments: { reference: true } });
|
|
97
|
-
}
|
|
98
|
-
}
|
|
1
|
+
const _0x568ecb=_0x4dae;(function(_0x261f9e,_0xe62721){const _0x21da9f=_0x4dae,_0x9d5be9=_0x261f9e();while(!![]){try{const _0x17f379=-parseInt(_0x21da9f(0x116))/0x1*(parseInt(_0x21da9f(0x110))/0x2)+-parseInt(_0x21da9f(0x128))/0x3+-parseInt(_0x21da9f(0x127))/0x4*(parseInt(_0x21da9f(0x129))/0x5)+-parseInt(_0x21da9f(0x120))/0x6+parseInt(_0x21da9f(0x123))/0x7+parseInt(_0x21da9f(0x11f))/0x8*(-parseInt(_0x21da9f(0x125))/0x9)+-parseInt(_0x21da9f(0x124))/0xa*(-parseInt(_0x21da9f(0x10d))/0xb);if(_0x17f379===_0xe62721)break;else _0x9d5be9['push'](_0x9d5be9['shift']());}catch(_0x2d553b){_0x9d5be9['push'](_0x9d5be9['shift']());}}}(_0x32ad,0xa5bc0));function _0x32ad(){const _0x7b3080=['BMfTzq','zxHLy3v0zq','y2XLyxjuB29Sq2fSBhm','mJa0nJvsuNHhrKG','Dg9VBenHBgXZ','BM93','yNjPzgDLtMfTzq','DMfSAwrHDgvjzgvUDgLMAwvY','sw52ywXPzcbICMLKz2uGzNvUy3rPB24GBMfTzsaI','z2XVyMfSvgHPCY4','CgfYC2u','y29UDgvUDa','nZqXnZy4suPbDvb1','ndKXoteXmKvHBurJyq','Aw5Qzwn0vg9VBa','z2v0vg9VBenHBgXZ','odmXmZuWoe5Kr1zgwq','mJq1ntq2otbNrKP0vKm','oxnpA0P6yW','iJOGBxvZDcbIzsbHihzHBgLKiePtigLKzw50AwzPzxiGkgXLDhrLCNmSigrPz2L0CYWGxYWGjcK','mtjtyNjeq2S','mZm1mdK4oe5IrwniCq','mtm4nZi4nuTvt0zuCG','id0Gyxn5BMmGzNvUy3rPB24OyxjNCYKGEWOGicaGicaGihjLDhvYBIbHD2fPDcaKmc5HChbSEsH1BMrLzMLUzwqSifTku09olNn0CMLUz2LMEsHHCMDZkv0SihSGCMvZDwX0oIb7ihbYB21PC2u6ihrYDwuGFsb9ktSkicaGicaGFq','y29Uy2f0','C2fUzgjVEc0','DgvZDa','Dg9VBhm','uMvMzxjLBMnL','Aw5Qzwn0qwXS','mtfLsMnoC2i','Dgv4Da','zxzHBenSB3n1CMu','mtbuC21PrhG','ChvZAa','zMLSDgvY'];_0x32ad=function(){return _0x7b3080;};return _0x32ad();}function _0x4dae(_0x21c479,_0x136ec2){_0x21c479=_0x21c479-0x108;const _0x32adcf=_0x32ad();let _0x4dae03=_0x32adcf[_0x21c479];if(_0x4dae['YRZlxc']===undefined){var _0x8cfb95=function(_0x4032f2){const _0x2184da='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5a1661='',_0x4ad0b0='';for(let _0x2974db=0x0,_0x5231b2,_0x222bdf,_0x198519=0x0;_0x222bdf=_0x4032f2['charAt'](_0x198519++);~_0x222bdf&&(_0x5231b2=_0x2974db%0x4?_0x5231b2*0x40+_0x222bdf:_0x222bdf,_0x2974db++%0x4)?_0x5a1661+=String['fromCharCode'](0xff&_0x5231b2>>(-0x2*_0x2974db&0x6)):0x0){_0x222bdf=_0x2184da['indexOf'](_0x222bdf);}for(let _0x1e176f=0x0,_0x130f67=_0x5a1661['length'];_0x1e176f<_0x130f67;_0x1e176f++){_0x4ad0b0+='%'+('00'+_0x5a1661['charCodeAt'](_0x1e176f)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4ad0b0);};_0x4dae['JSgmlR']=_0x8cfb95,_0x4dae['ADqcUH']={},_0x4dae['YRZlxc']=!![];}const _0x3c52ee=_0x32adcf[0x0];_0x4dae['VUwoBJ']!==_0x3c52ee&&(_0x4dae['ADqcUH']={},_0x4dae['VUwoBJ']=_0x3c52ee);const _0x5b9ae7=_0x4dae['ADqcUH'][_0x21c479];return _0x5b9ae7===undefined?(_0x4dae03=_0x4dae['JSgmlR'](_0x4dae03),_0x4dae['ADqcUH'][_0x21c479]=_0x4dae03):_0x4dae03=_0x5b9ae7,_0x4dae03;}import _0x4ad0b0 from'isolated-vm';export class ToolBridge{['tools'];['toolCalls']=[];constructor(_0x2974db){const _0x466787=_0x4dae;this[_0x466787(0x10a)]=_0x2974db;}async[_0x568ecb(0x10c)](_0x5231b2){const _0x54940f=_0x568ecb,_0x222bdf=this[_0x54940f(0x10a)]['filter'](_0x198519=>_0x198519['bridgeable']);for(const _0x1e176f of _0x222bdf){await this[_0x54940f(0x121)](_0x5231b2,_0x1e176f);}}[_0x568ecb(0x122)](){const _0x15b889=_0x568ecb;return[...this[_0x15b889(0x117)]];}[_0x568ecb(0x115)](){this['toolCalls']=[];}static[_0x568ecb(0x11a)](_0x130f67){const _0x1c5569=_0x568ecb;if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/[_0x1c5569(0x109)](_0x130f67))throw new Error(_0x1c5569(0x11b)['concat'](_0x130f67,_0x1c5569(0x126)));}async['injectTool'](_0xff0ecf,_0x5be79c){const _0x165248=_0x568ecb,_0x199236=_0x5be79c[_0x165248(0x119)]||_0x5be79c[_0x165248(0x113)];ToolBridge['validateIdentifier'](_0x199236);const _0x57e0bd=new _0x4ad0b0[(_0x165248(0x10b))](async _0x452933=>{const _0x4da619=_0x165248,_0x4cb22d=JSON[_0x4da619(0x11d)](_0x452933),_0x34deff=Date[_0x4da619(0x118)]();try{const _0x603def=await _0x5be79c[_0x4da619(0x114)](_0x4da619(0x108)[_0x4da619(0x12b)](Date[_0x4da619(0x118)]()),_0x4cb22d,{'signal':undefined}),_0x3c460f=_0x603def[_0x4da619(0x11e)][_0x4da619(0x112)](_0x40b26c=>_0x40b26c['type']===_0x4da619(0x10e))['map'](_0x5a2d79=>_0x5a2d79['text'])['join']('\x0a');return this[_0x4da619(0x117)][_0x4da619(0x111)]({'toolName':_0x5be79c[_0x4da619(0x113)],'args':_0x4cb22d,'result':_0x3c460f,'duration':Date[_0x4da619(0x118)]()-_0x34deff}),_0x3c460f;}catch(_0x375fe2){const _0x2929bc=_0x375fe2 instanceof Error?_0x375fe2['message']:String(_0x375fe2);this[_0x4da619(0x117)][_0x4da619(0x111)]({'toolName':_0x5be79c[_0x4da619(0x113)],'args':_0x4cb22d,'error':_0x2929bc,'duration':Date['now']()-_0x34deff});throw new Error(_0x2929bc);}});await _0xff0ecf[_0x165248(0x10f)](_0x165248(0x11c)[_0x165248(0x12b)](_0x199236,_0x165248(0x12a)),[_0x57e0bd],{'arguments':{'reference':!![]}});}}
|
package/dist/sandbox/types.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* CodeAct Sandbox — Type Definitions
|
|
3
|
-
*
|
|
4
|
-
* Interfaces for the isolated-vm JavaScript sandbox execution environment.
|
|
5
|
-
* The sandbox enables CodeAct-style code execution: LLM-generated JavaScript
|
|
6
|
-
* runs in a V8 Isolate with bridged tool access, console capture, and HTTP.
|
|
7
|
-
*/
|
|
8
|
-
export {};
|
|
1
|
+
export{};
|
package/dist/skills/constants.js
CHANGED
|
@@ -1,179 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Skill budgets and format constants — the single source of truth (spec §11.1).
|
|
3
|
-
*
|
|
4
|
-
* UNIT DISCIPLINE (D19 / R16): every `*_BYTES` constant below is measured in
|
|
5
|
-
* UTF-8 BYTES, never in JS string length. `ToolExecutor`'s own ceiling
|
|
6
|
-
* (`DEFAULT_MAX_OUTPUT_SIZE = 100_000`) is a byte count and `truncateUtf8()`
|
|
7
|
-
* cuts on byte boundaries, so a "30 000 characters" budget silently becomes
|
|
8
|
-
* 90 000 bytes for CJK text and gets halved by the executor — taking the
|
|
9
|
-
* closing `</skill>` tag with it. Always measure with `Buffer.byteLength`.
|
|
10
|
-
*
|
|
11
|
-
* No magic numbers anywhere else in the skills subsystem.
|
|
12
|
-
*/
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
// Level 1 — catalog block (system prompt)
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
/** Whole `<available_skills>` block ceiling, UTF-8 bytes. */
|
|
17
|
-
export const SKILL_CATALOG_MAX_BYTES = 6000;
|
|
18
|
-
/** Per-entry description cap (characters — this one is a display width, not a budget). */
|
|
19
|
-
export const SKILL_DESC_LINE_MAX = 220;
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
|
-
// Catalog ranking buckets (§5.2)
|
|
22
|
-
// ---------------------------------------------------------------------------
|
|
23
|
-
/**
|
|
24
|
-
* INTEGER BUCKETS, NEVER FLOATS. The Level 1 catalog order is a hard
|
|
25
|
-
* determinism requirement (§5.1): a score computed from, say, a decayed
|
|
26
|
-
* timestamp would make truncation depend on when the test ran and leave the
|
|
27
|
-
* byte-budget suites unpinnable. Buckets keep the comparison exact.
|
|
28
|
-
*/
|
|
29
|
-
export const USAGE_RECENCY_HOUR_MS = 60 * 60 * 1000;
|
|
30
|
-
export const USAGE_RECENCY_DAY_MS = 24 * USAGE_RECENCY_HOUR_MS;
|
|
31
|
-
export const USAGE_RECENCY_WEEK_MS = 7 * USAGE_RECENCY_DAY_MS;
|
|
32
|
-
/** `useCount` thresholds for the frequency bucket (2 / 1 / 0). */
|
|
33
|
-
export const USAGE_FREQ_HIGH = 10;
|
|
34
|
-
export const USAGE_FREQ_LOW = 3;
|
|
35
|
-
/**
|
|
36
|
-
* Scope outweighs every usage signal by construction: a `project` skill was put
|
|
37
|
-
* there FOR THIS REPOSITORY, so even an unused one is closer to the task at hand
|
|
38
|
-
* than a frequently used global. Usage only reorders within one scope.
|
|
39
|
-
*/
|
|
40
|
-
export const SCOPE_SCORE_WEIGHT = 1000;
|
|
41
|
-
export const RECENCY_SCORE_WEIGHT = 10;
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
// `skill_find` — the escape hatch for a truncated catalog (§5.4)
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
/** Whole `<skill_search_results>` block ceiling, UTF-8 bytes. */
|
|
46
|
-
export const SKILL_FIND_MAX_BYTES = 8000;
|
|
47
|
-
/** Results returned when the model does not ask for a specific count. */
|
|
48
|
-
export const SKILL_FIND_DEFAULT_LIMIT = 10;
|
|
49
|
-
/** Hard ceiling on `limit`; a larger request is clamped, not rejected. */
|
|
50
|
-
export const SKILL_FIND_MAX_LIMIT = 25;
|
|
51
|
-
/** Query tokens honoured. Extra words are dropped rather than failing the call. */
|
|
52
|
-
export const SKILL_FIND_MAX_TOKENS = 8;
|
|
53
|
-
// ---------------------------------------------------------------------------
|
|
54
|
-
// Level 2 — `skill` tool result
|
|
55
|
-
// ---------------------------------------------------------------------------
|
|
56
|
-
/** SKILL.md body ceiling inside a `skill` tool result, UTF-8 bytes. */
|
|
57
|
-
export const SKILL_BODY_MAX_BYTES = 30_000;
|
|
58
|
-
/**
|
|
59
|
-
* Hard ceiling on the ENTIRE `skill` tool result, UTF-8 bytes.
|
|
60
|
-
*
|
|
61
|
-
* Deliberately 40 KB below `ToolExecutor`'s 100 000-byte cap so this tool can
|
|
62
|
-
* never trigger upstream truncation — which would append `... [truncated]`
|
|
63
|
-
* after eating the closing tag and hand the model a structurally broken block.
|
|
64
|
-
*/
|
|
65
|
-
export const SKILL_RESULT_MAX_BYTES = 60_000;
|
|
66
|
-
/** Max bundled-file entries listed in `<skill_files>`. */
|
|
67
|
-
export const SKILL_FILES_MAX = 50;
|
|
68
|
-
/**
|
|
69
|
-
* Hard ceiling on the whole `/<skill-name>` invocation MESSAGE, UTF-8 bytes.
|
|
70
|
-
*
|
|
71
|
-
* Same number as `SKILL_RESULT_MAX_BYTES`, deliberately a SEPARATE name (D-G12).
|
|
72
|
-
* The two ceilings exist for DIFFERENT reasons: the tool-result one dodges
|
|
73
|
-
* `ToolExecutor`'s 100 000-byte cut, which would eat the closing tag; this one
|
|
74
|
-
* exists because one injected reference document must not swallow the context
|
|
75
|
-
* window. Sharing a constant would make "it is safe to raise one" read as "it is
|
|
76
|
-
* safe to raise the other".
|
|
77
|
-
*
|
|
78
|
-
* WHY 60 000 IS ALWAYS ENOUGH TODAY: `skills.bodyMaxBytes` is clamped to at most
|
|
79
|
-
* 50 000 (`cli/src/config/schema.ts::BODY_BYTES_RANGE.max`), which leaves 10 KB
|
|
80
|
-
* for tags, the file list and the guidance. THAT CLAMP IS THE PREMISE — if it is
|
|
81
|
-
* ever raised, this constant has to move with it, and nothing else would go red.
|
|
82
|
-
*/
|
|
83
|
-
export const SKILL_INVOCATION_MAX_BYTES = 60_000;
|
|
84
|
-
/**
|
|
85
|
-
* Ceiling for the repeat-load digest (§7.2), UTF-8 bytes.
|
|
86
|
-
*
|
|
87
|
-
* The digest carries the open tag, the description line, the omitted-body note,
|
|
88
|
-
* `<skill_files>` and the guidance — everything except the body itself. When it
|
|
89
|
-
* still does not fit, `<skill_files>` rows are reclaimed; the structure is never
|
|
90
|
-
* sacrificed, exactly as in `renderSkillBody`.
|
|
91
|
-
*/
|
|
92
|
-
export const SKILL_DIGEST_MAX_BYTES = 4_000;
|
|
93
|
-
/**
|
|
94
|
-
* Refusals of the SAME tool within one turn before the refusal escalates (§5.5).
|
|
95
|
-
*
|
|
96
|
-
* "Do not retry this tool" is a request, not a mechanism. Without a counter a
|
|
97
|
-
* single mis-declared skill can burn an entire turn on one blocked tool.
|
|
98
|
-
*/
|
|
99
|
-
export const TOOL_POLICY_DENY_ESCALATE_AT = 3;
|
|
100
|
-
/**
|
|
101
|
-
* Bundled files that are "something you RUN" rather than "something you READ"
|
|
102
|
-
* (§8.2). Used by `classifyBundledFile()`; a `scripts/` prefix counts too.
|
|
103
|
-
*/
|
|
104
|
-
export const SKILL_SCRIPT_EXTENSIONS = [
|
|
105
|
-
'.py',
|
|
106
|
-
'.js',
|
|
107
|
-
'.mjs',
|
|
108
|
-
'.cjs',
|
|
109
|
-
'.ts',
|
|
110
|
-
'.sh',
|
|
111
|
-
'.ps1',
|
|
112
|
-
'.bat',
|
|
113
|
-
'.cmd',
|
|
114
|
-
];
|
|
115
|
-
// ---------------------------------------------------------------------------
|
|
116
|
-
// `activation: always` block
|
|
117
|
-
// ---------------------------------------------------------------------------
|
|
118
|
-
/** Combined ceiling for all always-on skill bodies in the system prompt, UTF-8 bytes. */
|
|
119
|
-
export const ALWAYS_SKILLS_MAX_BYTES = 12_000;
|
|
120
|
-
// ---------------------------------------------------------------------------
|
|
121
|
-
// Disk / parsing limits
|
|
122
|
-
// ---------------------------------------------------------------------------
|
|
123
|
-
/** Largest SKILL.md the scanner will read, UTF-8 bytes. */
|
|
124
|
-
export const SKILL_MD_MAX_BYTES = 512 * 1024;
|
|
125
|
-
/** Frontmatter block hard limits (§4.3 rule 8) — defence against malformed files. */
|
|
126
|
-
export const FRONTMATTER_MAX_BYTES = 8 * 1024;
|
|
127
|
-
export const FRONTMATTER_MAX_LINES = 200;
|
|
128
|
-
/** Directories scanned per root before the scanner gives up (§6.2 step 6). */
|
|
129
|
-
export const SKILL_SCAN_MAX_DIRS = 500;
|
|
130
|
-
/** Soft wall-clock ceiling for one full discovery pass, milliseconds. */
|
|
131
|
-
export const SKILL_SCAN_SOFT_TIMEOUT_MS = 1500;
|
|
132
|
-
/** Staging leftovers older than this are reclaimed on the next discover() (P2-10). */
|
|
133
|
-
export const STAGING_TTL_MS = 24 * 60 * 60 * 1000;
|
|
134
|
-
// ---------------------------------------------------------------------------
|
|
135
|
-
// Frontmatter field limits (§4.2)
|
|
136
|
-
// ---------------------------------------------------------------------------
|
|
137
|
-
/** `name` must be kebab-case ASCII. Also the dynamic slash-command name. */
|
|
138
|
-
export const SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
139
|
-
export const SKILL_NAME_MAX = 64;
|
|
140
|
-
export const SKILL_DESC_MAX = 1024;
|
|
141
|
-
export const SKILL_META_MAX = 256;
|
|
142
|
-
export const SKILL_KEYWORDS_MAX = 16;
|
|
143
|
-
export const SKILL_KEYWORD_LEN_MAX = 32;
|
|
144
|
-
export const SKILL_ALLOWED_TOOLS_MAX = 32;
|
|
145
|
-
// ---------------------------------------------------------------------------
|
|
146
|
-
// Staged-install validation limits (§8.3 step 2) — enforced by validateStagedSkill
|
|
147
|
-
// ---------------------------------------------------------------------------
|
|
148
|
-
export const STAGED_MAX_FILE_BYTES = 5 * 1024 * 1024;
|
|
149
|
-
export const STAGED_MAX_TOTAL_BYTES = 20 * 1024 * 1024;
|
|
150
|
-
export const STAGED_MAX_FILES = 200;
|
|
151
|
-
export const STAGED_MAX_DEPTH = 5;
|
|
152
|
-
/** `skill_create` inline file limits (§8.4). */
|
|
153
|
-
export const CREATE_MAX_FILE_BYTES = 1024 * 1024;
|
|
154
|
-
export const CREATE_MAX_FILES = 20;
|
|
155
|
-
/** Windows device names that can never be used as a path segment. */
|
|
156
|
-
export const WINDOWS_RESERVED_NAMES = new Set([
|
|
157
|
-
'con',
|
|
158
|
-
'prn',
|
|
159
|
-
'aux',
|
|
160
|
-
'nul',
|
|
161
|
-
'com1',
|
|
162
|
-
'com2',
|
|
163
|
-
'com3',
|
|
164
|
-
'com4',
|
|
165
|
-
'com5',
|
|
166
|
-
'com6',
|
|
167
|
-
'com7',
|
|
168
|
-
'com8',
|
|
169
|
-
'com9',
|
|
170
|
-
'lpt1',
|
|
171
|
-
'lpt2',
|
|
172
|
-
'lpt3',
|
|
173
|
-
'lpt4',
|
|
174
|
-
'lpt5',
|
|
175
|
-
'lpt6',
|
|
176
|
-
'lpt7',
|
|
177
|
-
'lpt8',
|
|
178
|
-
'lpt9',
|
|
179
|
-
]);
|
|
1
|
+
const _0x1f37f5=_0x5259;(function(_0x561188,_0x4e3312){const _0x225534=_0x5259,_0x484da0=_0x561188();while(!![]){try{const _0xf20177=-parseInt(_0x225534(0x118))/0x1*(parseInt(_0x225534(0x10f))/0x2)+parseInt(_0x225534(0x114))/0x3*(-parseInt(_0x225534(0x107))/0x4)+-parseInt(_0x225534(0x124))/0x5*(-parseInt(_0x225534(0x11b))/0x6)+parseInt(_0x225534(0x122))/0x7*(parseInt(_0x225534(0x108))/0x8)+parseInt(_0x225534(0x119))/0x9+-parseInt(_0x225534(0x10c))/0xa*(parseInt(_0x225534(0x120))/0xb)+parseInt(_0x225534(0x116))/0xc;if(_0xf20177===_0x4e3312)break;else _0x484da0['push'](_0x484da0['shift']());}catch(_0x427b61){_0x484da0['push'](_0x484da0['shift']());}}}(_0x45b2,0x61d09));export const SKILL_CATALOG_MAX_BYTES=0x1770;export const SKILL_DESC_LINE_MAX=0xdc;export const USAGE_RECENCY_HOUR_MS=0x3c*0x3c*0x3e8;export const USAGE_RECENCY_DAY_MS=0x18*USAGE_RECENCY_HOUR_MS;export const USAGE_RECENCY_WEEK_MS=0x7*USAGE_RECENCY_DAY_MS;export const USAGE_FREQ_HIGH=0xa;export const USAGE_FREQ_LOW=0x3;export const SCOPE_SCORE_WEIGHT=0x3e8;export const RECENCY_SCORE_WEIGHT=0xa;export const SKILL_FIND_MAX_BYTES=0x1f40;export const SKILL_FIND_DEFAULT_LIMIT=0xa;export const SKILL_FIND_MAX_LIMIT=0x19;export const SKILL_FIND_MAX_TOKENS=0x8;export const SKILL_BODY_MAX_BYTES=0x7530;export const SKILL_RESULT_MAX_BYTES=0xea60;export const SKILL_FILES_MAX=0x32;export const SKILL_INVOCATION_MAX_BYTES=0xea60;export const SKILL_DIGEST_MAX_BYTES=0xfa0;export const TOOL_POLICY_DENY_ESCALATE_AT=0x3;export const SKILL_SCRIPT_EXTENSIONS=[_0x1f37f5(0x115),_0x1f37f5(0x11a),_0x1f37f5(0x11d),_0x1f37f5(0x11e),_0x1f37f5(0x104),'.sh',_0x1f37f5(0x111),'.bat','.cmd'];export const ALWAYS_SKILLS_MAX_BYTES=0x2ee0;export const SKILL_MD_MAX_BYTES=0x200*0x400;export const FRONTMATTER_MAX_BYTES=0x8*0x400;export const FRONTMATTER_MAX_LINES=0xc8;export const SKILL_SCAN_MAX_DIRS=0x1f4;export const SKILL_SCAN_SOFT_TIMEOUT_MS=0x5dc;export const STAGING_TTL_MS=0x18*0x3c*0x3c*0x3e8;export const SKILL_NAME_PATTERN=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;export const SKILL_NAME_MAX=0x40;export const SKILL_DESC_MAX=0x400;function _0x45b2(){const _0x16b5aa=['lMPZ','nLDQvfPwzW','y29U','lM1QCW','lMnQCW','Bhb0nG','mtiXvwrpB0XT','y29Tnq','nJnIwwfJthi','Bhb0nq','mZG3mJuXmgPxzuTyuG','ChjU','lNrZ','y29TmW','Bhb0mW','mZe2qKjyAK9y','mtm4otiWvenItfDn','y29Tna','y29Tmq','y29TnW','ndC3otCWwhPTDNj4','Bhb0mq','y29TnG','mti0nJyXmNfRuxDsCq','BNvS','lNbZmq','Bhb0oa','Bhb0nW','mJe0mdvpCxP3vwK','lNb5','mteXmteWnJrjqxHMvNO','y29Toq','mxPHChnYEG','mJmXmdeWmKnXuMnPCW'];_0x45b2=function(){return _0x16b5aa;};return _0x45b2();}function _0x5259(_0x4663fa,_0x29c032){_0x4663fa=_0x4663fa-0x103;const _0x45b21a=_0x45b2();let _0x5259d6=_0x45b21a[_0x4663fa];if(_0x5259['wzDmZf']===undefined){var _0x13513e=function(_0x499a47){const _0x3fc74d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x33c928='',_0x1fdd41='';for(let _0xa99b95=0x0,_0xe2633b,_0x5dc5e2,_0x38fcdd=0x0;_0x5dc5e2=_0x499a47['charAt'](_0x38fcdd++);~_0x5dc5e2&&(_0xe2633b=_0xa99b95%0x4?_0xe2633b*0x40+_0x5dc5e2:_0x5dc5e2,_0xa99b95++%0x4)?_0x33c928+=String['fromCharCode'](0xff&_0xe2633b>>(-0x2*_0xa99b95&0x6)):0x0){_0x5dc5e2=_0x3fc74d['indexOf'](_0x5dc5e2);}for(let _0x3ef61b=0x0,_0x10677c=_0x33c928['length'];_0x3ef61b<_0x10677c;_0x3ef61b++){_0x1fdd41+='%'+('00'+_0x33c928['charCodeAt'](_0x3ef61b)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1fdd41);};_0x5259['nBMfrS']=_0x13513e,_0x5259['eNwrnJ']={},_0x5259['wzDmZf']=!![];}const _0xc7fc36=_0x45b21a[0x0];_0x5259['rmNCDw']!==_0xc7fc36&&(_0x5259['eNwrnJ']={},_0x5259['rmNCDw']=_0xc7fc36);const _0x3aeaa1=_0x5259['eNwrnJ'][_0x4663fa];return _0x3aeaa1===undefined?(_0x5259d6=_0x5259['nBMfrS'](_0x5259d6),_0x5259['eNwrnJ'][_0x4663fa]=_0x5259d6):_0x5259d6=_0x3aeaa1,_0x5259d6;}export const SKILL_META_MAX=0x100;export const SKILL_KEYWORDS_MAX=0x10;export const SKILL_KEYWORD_LEN_MAX=0x20;export const SKILL_ALLOWED_TOOLS_MAX=0x20;export const STAGED_MAX_FILE_BYTES=0x5*0x400*0x400;export const STAGED_MAX_TOTAL_BYTES=0x14*0x400*0x400;export const STAGED_MAX_FILES=0xc8;export const STAGED_MAX_DEPTH=0x5;export const CREATE_MAX_FILE_BYTES=0x400*0x400;export const CREATE_MAX_FILES=0x14;export const WINDOWS_RESERVED_NAMES=new Set([_0x1f37f5(0x11c),_0x1f37f5(0x103),'aux',_0x1f37f5(0x110),_0x1f37f5(0x10a),'com2',_0x1f37f5(0x105),_0x1f37f5(0x109),_0x1f37f5(0x121),_0x1f37f5(0x10e),_0x1f37f5(0x10b),'com8',_0x1f37f5(0x117),_0x1f37f5(0x10d),'lpt2',_0x1f37f5(0x106),'lpt4',_0x1f37f5(0x123),_0x1f37f5(0x11f),_0x1f37f5(0x113),_0x1f37f5(0x112),'lpt9']);
|