@aragon-agent/core 0.2.93 → 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,177 +1 @@
1
- /**
2
- * SKILL.md frontmatter parser — a deliberately STRICT SUBSET of YAML (D9).
3
- *
4
- * Why not depend on `yaml`: `@aragon-agent/core` ships zero required runtime
5
- * dependencies (only `ajv` / `isolated-vm` as optional), and real SKILL.md
6
- * frontmatter only ever uses scalars, quoted strings, inline arrays and block
7
- * arrays. Unknown keys are preserved verbatim in `data` so a future Anthropic
8
- * field never breaks parsing.
9
- *
10
- * Every rule below is numbered to match spec §4.3 and has a dedicated test.
11
- */
12
- import { FRONTMATTER_MAX_BYTES, FRONTMATTER_MAX_LINES } from './constants.js';
13
- const KEY_PATTERN = /^[A-Za-z0-9_-]+$/;
14
- /** Rule 1: strip a UTF-8 BOM and normalize CRLF / lone CR to LF. */
15
- function normalizeSource(source) {
16
- const noBom = source.charCodeAt(0) === 0xfeff ? source.slice(1) : source;
17
- return noBom.replace(/\r\n?/g, '\n');
18
- }
19
- /**
20
- * Rule 5: `#` only starts a comment at the start of a line or after whitespace,
21
- * so a URL fragment (`homepage: https://x/y#v1`) survives. Text inside a leading
22
- * quoted string is skipped first — `description: "a # b"` keeps its hash.
23
- */
24
- function stripComment(value) {
25
- const quote = value[0];
26
- let i = 0;
27
- if (quote === '"' || quote === "'") {
28
- i = 1;
29
- while (i < value.length) {
30
- if (value[i] === '\\' && quote === '"') {
31
- i += 2;
32
- continue;
33
- }
34
- if (value[i] === quote) {
35
- i += 1;
36
- break;
37
- }
38
- i += 1;
39
- }
40
- }
41
- for (; i < value.length; i += 1) {
42
- if (value[i] !== '#')
43
- continue;
44
- if (i === 0 || /\s/.test(value[i - 1]))
45
- return value.slice(0, i);
46
- }
47
- return value;
48
- }
49
- /** Rule 4c: remove surrounding quotes, honouring only `\"` and `\\`. */
50
- function dequote(value) {
51
- if (value.length < 2)
52
- return value;
53
- const quote = value[0];
54
- if ((quote !== '"' && quote !== "'") || value[value.length - 1] !== quote)
55
- return value;
56
- const inner = value.slice(1, -1);
57
- if (quote === "'")
58
- return inner.replace(/''/g, "'");
59
- return inner.replace(/\\(["\\])/g, '$1');
60
- }
61
- /** Rule 4b: `[a, b, "c d"]` → `['a', 'b', 'c d']`. */
62
- function parseInlineArray(value) {
63
- const inner = value.slice(1, -1).trim();
64
- if (inner.length === 0)
65
- return [];
66
- return inner
67
- .split(',')
68
- .map((item) => dequote(item.trim()))
69
- .filter((item) => item.length > 0);
70
- }
71
- /**
72
- * Parse the frontmatter block of a SKILL.md.
73
- *
74
- * Returns `null` when there is no usable frontmatter at all — no opening `---`,
75
- * no closing delimiter, or a block that blows past the hard limits of rule 8.
76
- * `null` is never an exception: a malformed skill degrades to `invalid` in the
77
- * registry and stays visible to the user (§4.4), it does not crash discovery.
78
- */
79
- export function parseFrontmatter(source) {
80
- const text = normalizeSource(source);
81
- const lines = text.split('\n');
82
- // Rule 2: the opening `---`, optionally preceded by blank lines.
83
- let start = 0;
84
- while (start < lines.length && lines[start].trim().length === 0)
85
- start += 1;
86
- if (start >= lines.length || lines[start].trim() !== '---')
87
- return null;
88
- let end = -1;
89
- for (let i = start + 1; i < lines.length; i += 1) {
90
- const trimmed = lines[i].trim();
91
- if (trimmed === '---' || trimmed === '...') {
92
- end = i;
93
- break;
94
- }
95
- }
96
- if (end === -1)
97
- return null;
98
- const blockLines = lines.slice(start + 1, end);
99
- // Rule 8: hard limits — a pathological file must not become a parsing DoS.
100
- if (blockLines.length > FRONTMATTER_MAX_LINES)
101
- return null;
102
- if (Buffer.byteLength(blockLines.join('\n'), 'utf-8') > FRONTMATTER_MAX_BYTES)
103
- return null;
104
- const data = {};
105
- const errors = [];
106
- let pendingArrayKey = null;
107
- /** Keys opened with an empty value — only these may collapse back to `''`. */
108
- const emptyValueKeys = new Set();
109
- const setKey = (key, value) => {
110
- // Rule 7: last one wins, but say so.
111
- if (Object.prototype.hasOwnProperty.call(data, key)) {
112
- errors.push(`duplicate key "${key}" - the last value wins`);
113
- }
114
- data[key] = value;
115
- };
116
- for (let i = 0; i < blockLines.length; i += 1) {
117
- const rawLine = blockLines[i];
118
- if (rawLine.trim().length === 0)
119
- continue;
120
- const indent = /^[ \t]*/.exec(rawLine)[0];
121
- // Rule 6: tabs are never valid YAML indentation.
122
- if (indent.includes('\t')) {
123
- errors.push(`line ${i + 1}: tab indentation is not supported`);
124
- continue;
125
- }
126
- const trimmed = rawLine.trim();
127
- if (trimmed.startsWith('#'))
128
- continue;
129
- // Block-array continuation (rule 4a).
130
- if (pendingArrayKey !== null && trimmed.startsWith('- ')) {
131
- const item = dequote(stripComment(trimmed.slice(2).trim()).trim());
132
- if (item.length > 0)
133
- data[pendingArrayKey].push(item);
134
- continue;
135
- }
136
- pendingArrayKey = null;
137
- if (indent.length > 0) {
138
- errors.push(`line ${i + 1}: unexpected indentation outside a block list`);
139
- continue;
140
- }
141
- // Rule 3: split on the FIRST colon.
142
- const colon = trimmed.indexOf(':');
143
- if (colon === -1) {
144
- errors.push(`line ${i + 1}: not a "key: value" pair`);
145
- continue;
146
- }
147
- const key = trimmed.slice(0, colon).trim();
148
- if (!KEY_PATTERN.test(key)) {
149
- errors.push(`line ${i + 1}: invalid key "${key}"`);
150
- continue;
151
- }
152
- // Trim BEFORE stripping comments: `stripComment` only recognizes a leading
153
- // quote at index 0, so a value like ` "a # b"` would otherwise lose its hash.
154
- const rawValue = stripComment(trimmed.slice(colon + 1).trim()).trim();
155
- if (rawValue.length === 0) {
156
- // Empty value: either a block array follows, or it really is empty.
157
- setKey(key, []);
158
- emptyValueKeys.add(key);
159
- pendingArrayKey = key;
160
- continue;
161
- }
162
- emptyValueKeys.delete(key);
163
- if (rawValue.startsWith('[') && rawValue.endsWith(']')) {
164
- setKey(key, parseInlineArray(rawValue));
165
- continue;
166
- }
167
- setKey(key, dequote(rawValue));
168
- }
169
- // An empty-valued key with no `- ` items behind it was a scalar all along.
170
- // `keywords: []` is NOT touched — it was written as an explicit empty array.
171
- for (const key of emptyValueKeys) {
172
- const value = data[key];
173
- if (Array.isArray(value) && value.length === 0)
174
- data[key] = '';
175
- }
176
- return { data, body: lines.slice(end + 1).join('\n').trimStart(), errors };
177
- }
1
+ (function(_0x5d55bf,_0x4ced34){const _0x4a5f8a=_0x53a8,_0x7aedb5=_0x5d55bf();while(!![]){try{const _0x5ed4fd=-parseInt(_0x4a5f8a(0x193))/0x1*(-parseInt(_0x4a5f8a(0x190))/0x2)+parseInt(_0x4a5f8a(0x17f))/0x3+parseInt(_0x4a5f8a(0x195))/0x4*(parseInt(_0x4a5f8a(0x19a))/0x5)+parseInt(_0x4a5f8a(0x194))/0x6*(parseInt(_0x4a5f8a(0x174))/0x7)+parseInt(_0x4a5f8a(0x191))/0x8*(-parseInt(_0x4a5f8a(0x18b))/0x9)+parseInt(_0x4a5f8a(0x17d))/0xa+-parseInt(_0x4a5f8a(0x197))/0xb*(parseInt(_0x4a5f8a(0x17e))/0xc);if(_0x5ed4fd===_0x4ced34)break;else _0x7aedb5['push'](_0x7aedb5['shift']());}catch(_0x313b1a){_0x7aedb5['push'](_0x7aedb5['shift']());}}}(_0x1ac5,0xb64de));import{FRONTMATTER_MAX_BYTES,FRONTMATTER_MAX_LINES}from'./constants.js';const KEY_PATTERN=/^[A-Za-z0-9_-]+$/;function normalizeSource(_0x44d680){const _0x32511f=_0x53a8,_0x11fb86=_0x44d680[_0x32511f(0x18f)](0x0)===0xfeff?_0x44d680['slice'](0x1):_0x44d680;return _0x11fb86['replace'](/\r\n?/g,'\x0a');}function _0x53a8(_0xbaf3d,_0x309d18){_0xbaf3d=_0xbaf3d-0x174;const _0x1ac5b5=_0x1ac5();let _0x53a8ab=_0x1ac5b5[_0xbaf3d];if(_0x53a8['jIGzRE']===undefined){var _0x492c8f=function(_0x4744a6){const _0xbfb173='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4485e9='',_0x44d680='';for(let _0x11fb86=0x0,_0x91547a,_0x497d5e,_0x5d26b0=0x0;_0x497d5e=_0x4744a6['charAt'](_0x5d26b0++);~_0x497d5e&&(_0x91547a=_0x11fb86%0x4?_0x91547a*0x40+_0x497d5e:_0x497d5e,_0x11fb86++%0x4)?_0x4485e9+=String['fromCharCode'](0xff&_0x91547a>>(-0x2*_0x11fb86&0x6)):0x0){_0x497d5e=_0xbfb173['indexOf'](_0x497d5e);}for(let _0x3d5eeb=0x0,_0x123479=_0x4485e9['length'];_0x3d5eeb<_0x123479;_0x3d5eeb++){_0x44d680+='%'+('00'+_0x4485e9['charCodeAt'](_0x3d5eeb)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x44d680);};_0x53a8['LQWYXD']=_0x492c8f,_0x53a8['aTwDja']={},_0x53a8['jIGzRE']=!![];}const _0x4bbdc0=_0x1ac5b5[0x0];_0x53a8['vAzpJe']!==_0x4bbdc0&&(_0x53a8['aTwDja']={},_0x53a8['vAzpJe']=_0x4bbdc0);const _0x44a4dc=_0x53a8['aTwDja'][_0xbaf3d];return _0x44a4dc===undefined?(_0x53a8ab=_0x53a8['LQWYXD'](_0x53a8ab),_0x53a8['aTwDja'][_0xbaf3d]=_0x53a8ab):_0x53a8ab=_0x44a4dc,_0x53a8ab;}function stripComment(_0x91547a){const _0x16d357=_0x53a8,_0x497d5e=_0x91547a[0x0];let _0x5d26b0=0x0;if(_0x497d5e==='\x22'||_0x497d5e==='\x27'){_0x5d26b0=0x1;while(_0x5d26b0<_0x91547a['length']){if(_0x91547a[_0x5d26b0]==='\x5c'&&_0x497d5e==='\x22'){_0x5d26b0+=0x2;continue;}if(_0x91547a[_0x5d26b0]===_0x497d5e){_0x5d26b0+=0x1;break;}_0x5d26b0+=0x1;}}for(;_0x5d26b0<_0x91547a[_0x16d357(0x17a)];_0x5d26b0+=0x1){if(_0x91547a[_0x5d26b0]!=='#')continue;if(_0x5d26b0===0x0||/\s/[_0x16d357(0x179)](_0x91547a[_0x5d26b0-0x1]))return _0x91547a[_0x16d357(0x18d)](0x0,_0x5d26b0);}return _0x91547a;}function dequote(_0x3d5eeb){const _0x1bd938=_0x53a8;if(_0x3d5eeb[_0x1bd938(0x17a)]<0x2)return _0x3d5eeb;const _0x123479=_0x3d5eeb[0x0];if(_0x123479!=='\x22'&&_0x123479!=='\x27'||_0x3d5eeb[_0x3d5eeb['length']-0x1]!==_0x123479)return _0x3d5eeb;const _0x4b439b=_0x3d5eeb[_0x1bd938(0x18d)](0x1,-0x1);if(_0x123479==='\x27')return _0x4b439b[_0x1bd938(0x187)](/''/g,'\x27');return _0x4b439b['replace'](/\\(["\\])/g,'$1');}function parseInlineArray(_0x356a74){const _0x3ca81c=_0x53a8,_0x2ccb33=_0x356a74[_0x3ca81c(0x18d)](0x1,-0x1)[_0x3ca81c(0x175)]();if(_0x2ccb33[_0x3ca81c(0x17a)]===0x0)return[];return _0x2ccb33[_0x3ca81c(0x181)](',')[_0x3ca81c(0x185)](_0x2b5a19=>dequote(_0x2b5a19[_0x3ca81c(0x175)]()))['filter'](_0x20f72f=>_0x20f72f[_0x3ca81c(0x17a)]>0x0);}export function parseFrontmatter(_0x518707){const _0x53157b=_0x53a8,_0x5c2813=normalizeSource(_0x518707),_0x1d121d=_0x5c2813[_0x53157b(0x181)]('\x0a');let _0x53ccd1=0x0;while(_0x53ccd1<_0x1d121d['length']&&_0x1d121d[_0x53ccd1][_0x53157b(0x175)]()['length']===0x0)_0x53ccd1+=0x1;if(_0x53ccd1>=_0x1d121d[_0x53157b(0x17a)]||_0x1d121d[_0x53ccd1][_0x53157b(0x175)]()!==_0x53157b(0x176))return null;let _0x25f55a=-0x1;for(let _0x21c4a2=_0x53ccd1+0x1;_0x21c4a2<_0x1d121d['length'];_0x21c4a2+=0x1){const _0x5e37ec=_0x1d121d[_0x21c4a2]['trim']();if(_0x5e37ec===_0x53157b(0x176)||_0x5e37ec==='...'){_0x25f55a=_0x21c4a2;break;}}if(_0x25f55a===-0x1)return null;const _0x10ca32=_0x1d121d[_0x53157b(0x18d)](_0x53ccd1+0x1,_0x25f55a);if(_0x10ca32['length']>FRONTMATTER_MAX_LINES)return null;if(Buffer['byteLength'](_0x10ca32[_0x53157b(0x188)]('\x0a'),_0x53157b(0x18a))>FRONTMATTER_MAX_BYTES)return null;const _0x58a317={},_0x476b0b=[];let _0x14efb6=null;const _0x415f5a=new Set(),_0x561c0c=(_0x3f996e,_0x7ed636)=>{const _0x19fa7b=_0x53157b;Object[_0x19fa7b(0x183)][_0x19fa7b(0x177)][_0x19fa7b(0x180)](_0x58a317,_0x3f996e)&&_0x476b0b[_0x19fa7b(0x18e)](_0x19fa7b(0x17b)['concat'](_0x3f996e,_0x19fa7b(0x178))),_0x58a317[_0x3f996e]=_0x7ed636;};for(let _0x1178cb=0x0;_0x1178cb<_0x10ca32[_0x53157b(0x17a)];_0x1178cb+=0x1){const _0x1c1f45=_0x10ca32[_0x1178cb];if(_0x1c1f45[_0x53157b(0x175)]()['length']===0x0)continue;const _0xf9d5d8=/^[ \t]*/[_0x53157b(0x198)](_0x1c1f45)[0x0];if(_0xf9d5d8['includes']('\x09')){_0x476b0b[_0x53157b(0x18e)](_0x53157b(0x199)[_0x53157b(0x184)](_0x1178cb+0x1,_0x53157b(0x182)));continue;}const _0x408383=_0x1c1f45[_0x53157b(0x175)]();if(_0x408383[_0x53157b(0x192)]('#'))continue;if(_0x14efb6!==null&&_0x408383[_0x53157b(0x192)]('-\x20')){const _0x51424f=dequote(stripComment(_0x408383[_0x53157b(0x18d)](0x2)[_0x53157b(0x175)]())[_0x53157b(0x175)]());if(_0x51424f[_0x53157b(0x17a)]>0x0)_0x58a317[_0x14efb6][_0x53157b(0x18e)](_0x51424f);continue;}_0x14efb6=null;if(_0xf9d5d8[_0x53157b(0x17a)]>0x0){_0x476b0b[_0x53157b(0x18e)](_0x53157b(0x199)[_0x53157b(0x184)](_0x1178cb+0x1,':\x20unexpected\x20indentation\x20outside\x20a\x20block\x20list'));continue;}const _0xadc51b=_0x408383['indexOf'](':');if(_0xadc51b===-0x1){_0x476b0b[_0x53157b(0x18e)](_0x53157b(0x199)[_0x53157b(0x184)](_0x1178cb+0x1,':\x20not\x20a\x20\x22key:\x20value\x22\x20pair'));continue;}const _0x1ab402=_0x408383[_0x53157b(0x18d)](0x0,_0xadc51b)['trim']();if(!KEY_PATTERN[_0x53157b(0x179)](_0x1ab402)){_0x476b0b[_0x53157b(0x18e)]('line\x20'['concat'](_0x1178cb+0x1,_0x53157b(0x196))[_0x53157b(0x184)](_0x1ab402,'\x22'));continue;}const _0x5ce121=stripComment(_0x408383['slice'](_0xadc51b+0x1)[_0x53157b(0x175)]())['trim']();if(_0x5ce121[_0x53157b(0x17a)]===0x0){_0x561c0c(_0x1ab402,[]),_0x415f5a[_0x53157b(0x17c)](_0x1ab402),_0x14efb6=_0x1ab402;continue;}_0x415f5a['delete'](_0x1ab402);if(_0x5ce121[_0x53157b(0x192)]('[')&&_0x5ce121[_0x53157b(0x18c)](']')){_0x561c0c(_0x1ab402,parseInlineArray(_0x5ce121));continue;}_0x561c0c(_0x1ab402,dequote(_0x5ce121));}for(const _0x30fd64 of _0x415f5a){const _0x38fe52=_0x58a317[_0x30fd64];if(Array[_0x53157b(0x186)](_0x38fe52)&&_0x38fe52[_0x53157b(0x17a)]===0x0)_0x58a317[_0x30fd64]='';}return{'data':_0x58a317,'body':_0x1d121d[_0x53157b(0x18d)](_0x25f55a+0x1)['join']('\x0a')[_0x53157b(0x189)](),'errors':_0x476b0b};}function _0x1ac5(){const _0x2144a5=['mtqXmtC3nZbZuerxDMm','nti4wKPkDhLv','mZqZnJy0muzsC1v5uG','y2fSBa','C3bSAxq','oIb0ywiGAw5Kzw50yxrPB24GAxmGBM90ihn1ChbVCNrLza','ChjVDg90ExbL','y29Uy2f0','BwfW','AxnbCNjHEq','CMvWBgfJzq','AM9PBG','DhjPBvn0yxj0','DxrMltG','oxP5D1HjrG','zw5KC1DPDgG','C2XPy2u','ChvZAa','y2HHCKnVzgvbDa','nde1mZa2q1ryu2jy','odm5mde4nfHqAKPQwq','C3rHCNrZv2L0Aa','muPmzgzoAG','ndq2ndy2D2DmtM1s','mta2mfLHzhjUwq','oIbPBNzHBgLKigTLEsaI','nJGXntKZC3LOCxvl','zxHLyW','BgLUzsa','mtC3mdv4CvDPr2e','nZD5qK95D0y','DhjPBq','ls0T','AgfZt3DUuhjVCgvYDhK','iIaTihrOzsbSyxn0ihzHBhvLihDPBNm','DgvZDa','BgvUz3rO','zhvWBgLJyxrLigTLEsaI','ywrK'];_0x1ac5=function(){return _0x2144a5;};return _0x1ac5();}
@@ -1,18 +1 @@
1
- /**
2
- * Skills submodule barrel — reachable as `@aragon-agent/core/skills`.
3
- *
4
- * The root barrel (`src/index.ts`) re-exports the documented public face; this
5
- * subpath additionally exposes the internals the CLI needs (staged-install
6
- * validation, always-block rendering, byte helpers) without widening the frozen
7
- * top-level API surface. Same "root barrel + subpath" split the tools module
8
- * already uses.
9
- */
10
- export * from './constants.js';
11
- export * from './types.js';
12
- export { parseFrontmatter } from './frontmatter.js';
13
- export { validateSkillFrontmatter, validateStagedSkill, normalizeFrontmatter, checkStagedPath, hasControlChar, } from './validate.js';
14
- export { sanitizeForPromptBlock, renderSkillCatalog, renderSkillBody, renderSkillInvocation, renderAlwaysSkills, renderCatalogLine, renderSkillFindResults, renderSkillFindNoMatch, applySkillArguments, splitArguments, suggestSkillNames, catalogRecords, rankCatalogRecords, classifyBundledFile, byteLength, truncateToBytes, } from './disclosure.js';
15
- export { normalizeToolAlias, resolveDeclaredTool, computeToolPolicy, evaluateToolCall, renderDenyEscalation, renderDenyEscalationNotice, SKILL_TOOL_ALIASES, SKILL_TOOL_KNOWN_ABSENT, } from './tool-policy.js';
16
- export { SkillRegistry } from './skill-registry.js';
17
- export { createSkillTool } from './skill-tool.js';
18
- export { createSkillFindTool, matchSkills } from './skill-find-tool.js';
1
+ (function(_0xff4e36,_0x1f09c0){var _0x4960c0=_0x2f71,_0x394db8=_0xff4e36();while(!![]){try{var _0x467161=parseInt(_0x4960c0(0xa2))/0x1*(parseInt(_0x4960c0(0xa6))/0x2)+-parseInt(_0x4960c0(0xa1))/0x3+parseInt(_0x4960c0(0xa7))/0x4+-parseInt(_0x4960c0(0xa0))/0x5*(-parseInt(_0x4960c0(0x9f))/0x6)+-parseInt(_0x4960c0(0xa3))/0x7+-parseInt(_0x4960c0(0xa5))/0x8+parseInt(_0x4960c0(0xa8))/0x9*(parseInt(_0x4960c0(0xa4))/0xa);if(_0x467161===_0x1f09c0)break;else _0x394db8['push'](_0x394db8['shift']());}catch(_0x1c7298){_0x394db8['push'](_0x394db8['shift']());}}}(_0x502d,0x2d856));export*from'./constants.js';function _0x502d(){var _0x4741ae=['mJj1BwrQC3y','mJmWntC4nLLjsgzuva','ndu1nZiWDw12yu1Z','mZi3mJy0vujeyvnl','mZi3nJzJBvHAy1q','nJqYmtG4AeHjvNrN','mtHnDvjWq1m','ndHKAwnfufi','mtaWoda1v3bkDLvr','nJq5otm1s29jDKfQ'];_0x502d=function(){return _0x4741ae;};return _0x502d();}export*from'./types.js';export{parseFrontmatter}from'./frontmatter.js';export{validateSkillFrontmatter,validateStagedSkill,normalizeFrontmatter,checkStagedPath,hasControlChar}from'./validate.js';export{sanitizeForPromptBlock,renderSkillCatalog,renderSkillBody,renderSkillInvocation,renderAlwaysSkills,renderCatalogLine,renderSkillFindResults,renderSkillFindNoMatch,applySkillArguments,splitArguments,suggestSkillNames,catalogRecords,rankCatalogRecords,classifyBundledFile,byteLength,truncateToBytes}from'./disclosure.js';export{normalizeToolAlias,resolveDeclaredTool,computeToolPolicy,evaluateToolCall,renderDenyEscalation,renderDenyEscalationNotice,SKILL_TOOL_ALIASES,SKILL_TOOL_KNOWN_ABSENT}from'./tool-policy.js';export{SkillRegistry}from'./skill-registry.js';function _0x2f71(_0x116c70,_0x45a26e){_0x116c70=_0x116c70-0x9f;var _0x502db1=_0x502d();var _0x2f7123=_0x502db1[_0x116c70];if(_0x2f71['krGYWc']===undefined){var _0xf91744=function(_0x484571){var _0x481d43='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0xe5b2f8='',_0x92b6dd='';for(var _0x5dc57e=0x0,_0x13fd29,_0x443730,_0x444f6a=0x0;_0x443730=_0x484571['charAt'](_0x444f6a++);~_0x443730&&(_0x13fd29=_0x5dc57e%0x4?_0x13fd29*0x40+_0x443730:_0x443730,_0x5dc57e++%0x4)?_0xe5b2f8+=String['fromCharCode'](0xff&_0x13fd29>>(-0x2*_0x5dc57e&0x6)):0x0){_0x443730=_0x481d43['indexOf'](_0x443730);}for(var _0x59295f=0x0,_0x2a7548=_0xe5b2f8['length'];_0x59295f<_0x2a7548;_0x59295f++){_0x92b6dd+='%'+('00'+_0xe5b2f8['charCodeAt'](_0x59295f)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x92b6dd);};_0x2f71['QrgHeK']=_0xf91744,_0x2f71['PArFwx']={},_0x2f71['krGYWc']=!![];}var _0x510b8e=_0x502db1[0x0];_0x2f71['jzhFuF']!==_0x510b8e&&(_0x2f71['PArFwx']={},_0x2f71['jzhFuF']=_0x510b8e);var _0x2f1528=_0x2f71['PArFwx'][_0x116c70];return _0x2f1528===undefined?(_0x2f7123=_0x2f71['QrgHeK'](_0x2f7123),_0x2f71['PArFwx'][_0x116c70]=_0x2f7123):_0x2f7123=_0x2f1528,_0x2f7123;}export{createSkillTool}from'./skill-tool.js';export{createSkillFindTool,matchSkills}from'./skill-find-tool.js';
@@ -1,117 +1 @@
1
- /**
2
- * The `skill_find` tool — the escape hatch for a truncated Level 1 catalog
3
- * (spec §5.4 / D-A1).
4
- *
5
- * ══════════════════════════════════════════════════════════════════════════
6
- * THIS SEARCHES WHAT IS INSTALLED. IT NEVER TOUCHES THE NETWORK.
7
- * ══════════════════════════════════════════════════════════════════════════
8
- *
9
- * The boundary is the whole point (D-A4). Iteration 1 deliberately shipped no
10
- * search tool, on the reasoning that the catalog already showed everything.
11
- * `SKILL_CATALOG_MAX_BYTES` is 6000 and a CJK description can cost 660 bytes a
12
- * line, so that premise fails at roughly ten skills — and when it fails, the
13
- * omitted skills become invisible to the model with no error anywhere (F1/F2).
14
- * This tool restores reachability for exactly that case and nothing more.
15
- *
16
- * If it ever returned installable-but-not-installed candidates, "the agent can
17
- * install skills" would quietly change meaning from "the user pointed at a
18
- * source and the model did the work" to "the model picks its own dependencies".
19
- * That is a different security model, and it is not this one.
20
- *
21
- * Pure logic, like `skill-tool.ts`: the registry is injected, and this module
22
- * imports no `node:*` (enforced by `no-host-coupling.test.ts`).
23
- */
24
- import { errorResult, textResult } from '../tools/helpers.js';
25
- import { SKILL_FIND_DEFAULT_LIMIT, SKILL_FIND_MAX_LIMIT, SKILL_FIND_MAX_TOKENS, } from './constants.js';
26
- import { renderSkillFindResults, suggestSkillNames } from './disclosure.js';
27
- const DESCRIPTION = 'Search the skills installed on this machine by name, description or keyword. Use this when the ' +
28
- 'available-skills list says some skills were not shown, or when you suspect a skill exists for ' +
29
- 'the task but you cannot see it. This searches ONLY what is already installed - it never reaches ' +
30
- 'the network and never returns skills you could install. If nothing matches, ask the user for a ' +
31
- 'source instead of inventing one.';
32
- /**
33
- * Skills a search may return.
34
- *
35
- * `activation: manual` is excluded on purpose (D-A3). Manual means "do not put
36
- * this in front of the model; only the user may invoke it with `/<name>`".
37
- * Letting search surface it would silently downgrade that setting from an
38
- * exclusion to a ranking penalty, which is not what the author asked for.
39
- */
40
- function searchable(registry) {
41
- return registry
42
- .list()
43
- .filter((r) => !r.disabled && !r.invalid && r.frontmatter.activation !== 'manual');
44
- }
45
- /** The haystack for one record: name, description and keywords, lowercased. */
46
- function haystack(record) {
47
- return `${record.name} ${record.description} ${record.frontmatter.keywords.join(' ')}`.toLowerCase();
48
- }
49
- /**
50
- * Deterministic three-stage match; the first stage that yields anything wins.
51
- *
52
- * Stage 2 is AND across tokens, not OR. With OR, a query like "pdf form" would
53
- * drag in every skill whose description happens to contain "form" — and because
54
- * the result block has its own byte budget, the one skill the model actually
55
- * needed could be the entry that gets dropped off the end.
56
- */
57
- export function matchSkills(query, records) {
58
- const normalized = query.trim().toLowerCase();
59
- if (normalized.length === 0)
60
- return [];
61
- const exact = records.filter((r) => r.name.toLowerCase() === normalized);
62
- if (exact.length > 0)
63
- return exact;
64
- const tokens = normalized.split(/\s+/).filter(Boolean).slice(0, SKILL_FIND_MAX_TOKENS);
65
- if (tokens.length === 0)
66
- return [];
67
- return records.filter((r) => {
68
- const text = haystack(r);
69
- return tokens.every((token) => text.includes(token));
70
- });
71
- }
72
- export function createSkillFindTool(deps) {
73
- return {
74
- name: 'skill_find',
75
- label: 'Find Skill',
76
- description: DESCRIPTION,
77
- parameters: {
78
- type: 'object',
79
- properties: {
80
- query: {
81
- type: 'string',
82
- description: 'Words describing the capability you need, e.g. "pdf form" or "deploy preview".',
83
- },
84
- limit: { type: 'integer', description: 'Max results. Default 10, max 25.' },
85
- },
86
- required: ['query'],
87
- },
88
- async execute(_id, rawParams) {
89
- const params = rawParams;
90
- const query = typeof params.query === 'string' ? params.query.trim() : '';
91
- if (query.length === 0)
92
- return errorResult('skill_find requires a "query" parameter.');
93
- const candidates = searchable(deps.registry);
94
- const matched = matchSkills(query, candidates);
95
- // Out-of-range limits are clamped rather than rejected: a model that asks
96
- // for 500 results wants "as many as you have", and failing the call would
97
- // cost a turn to relearn a bound it can simply be given.
98
- const requested = typeof params.limit === 'number' && Number.isFinite(params.limit)
99
- ? Math.floor(params.limit)
100
- : (deps.defaultLimit ?? SKILL_FIND_DEFAULT_LIMIT);
101
- const limit = Math.min(SKILL_FIND_MAX_LIMIT, Math.max(1, requested));
102
- // Stage 3: near-miss names, but only when the first two stages came up
103
- // empty — otherwise a good match would be diluted with guesses.
104
- const suggestions = matched.length === 0 ? suggestSkillNames(query, candidates.map((r) => r.name), 3) : [];
105
- return textResult(renderSkillFindResults(query, matched.slice(0, limit), {
106
- total: candidates.length,
107
- // The PRE-slice count, so `limit` shows up as "+N more matches not
108
- // shown" instead of quietly passing a truncated list off as the
109
- // complete one — which is the exact failure mode (F1) this tool was
110
- // added to undo, and it would be embarrassing to reintroduce here.
111
- matchedTotal: matched.length,
112
- ...(deps.maxBytes !== undefined ? { maxBytes: deps.maxBytes } : {}),
113
- suggestions,
114
- }));
115
- },
116
- };
117
- }
1
+ const _0x5d195f=_0x2c49;(function(_0xe89db4,_0xe1c29d){const _0xa28fac=_0x2c49,_0xb3d7a6=_0xe89db4();while(!![]){try{const _0x5d5e93=-parseInt(_0xa28fac(0x9d))/0x1*(parseInt(_0xa28fac(0xae))/0x2)+-parseInt(_0xa28fac(0x95))/0x3*(-parseInt(_0xa28fac(0x92))/0x4)+-parseInt(_0xa28fac(0xa4))/0x5+parseInt(_0xa28fac(0x81))/0x6*(parseInt(_0xa28fac(0xa0))/0x7)+parseInt(_0xa28fac(0xa7))/0x8+-parseInt(_0xa28fac(0x8b))/0x9+parseInt(_0xa28fac(0x8c))/0xa*(parseInt(_0xa28fac(0x89))/0xb);if(_0x5d5e93===_0xe1c29d)break;else _0xb3d7a6['push'](_0xb3d7a6['shift']());}catch(_0xf2e3e3){_0xb3d7a6['push'](_0xb3d7a6['shift']());}}}(_0x5039,0x95bdc));import{errorResult,textResult}from'../tools/helpers.js';function _0x2c49(_0x23746a,_0x1dee6c){_0x23746a=_0x23746a-0x7e;const _0x50399b=_0x5039();let _0x2c493b=_0x50399b[_0x23746a];if(_0x2c49['JPFQhR']===undefined){var _0x5e8603=function(_0x6ec2f){const _0x1ecafc='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3c6cd2='',_0x42e033='';for(let _0x1f74f6=0x0,_0x278b25,_0x1eba09,_0x31502d=0x0;_0x1eba09=_0x6ec2f['charAt'](_0x31502d++);~_0x1eba09&&(_0x278b25=_0x1f74f6%0x4?_0x278b25*0x40+_0x1eba09:_0x1eba09,_0x1f74f6++%0x4)?_0x3c6cd2+=String['fromCharCode'](0xff&_0x278b25>>(-0x2*_0x1f74f6&0x6)):0x0){_0x1eba09=_0x1ecafc['indexOf'](_0x1eba09);}for(let _0x1786fe=0x0,_0x3e4812=_0x3c6cd2['length'];_0x1786fe<_0x3e4812;_0x1786fe++){_0x42e033+='%'+('00'+_0x3c6cd2['charCodeAt'](_0x1786fe)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x42e033);};_0x2c49['deVSDp']=_0x5e8603,_0x2c49['bXqWdT']={},_0x2c49['JPFQhR']=!![];}const _0x154054=_0x50399b[0x0];_0x2c49['TOawkl']!==_0x154054&&(_0x2c49['bXqWdT']={},_0x2c49['TOawkl']=_0x154054);const _0x43522d=_0x2c49['bXqWdT'][_0x23746a];return _0x43522d===undefined?(_0x2c493b=_0x2c49['deVSDp'](_0x2c493b),_0x2c49['bXqWdT'][_0x23746a]=_0x2c493b):_0x2c493b=_0x43522d,_0x2c493b;}import{SKILL_FIND_DEFAULT_LIMIT,SKILL_FIND_MAX_LIMIT,SKILL_FIND_MAX_TOKENS}from'./constants.js';import{renderSkillFindResults,suggestSkillNames}from'./disclosure.js';const DESCRIPTION=_0x5d195f(0x80)+_0x5d195f(0x90)+_0x5d195f(0x8e)+_0x5d195f(0x82)+_0x5d195f(0x9e);function searchable(_0x42e033){const _0x237d59=_0x5d195f;return _0x42e033[_0x237d59(0xac)]()[_0x237d59(0x96)](_0x1f74f6=>!_0x1f74f6[_0x237d59(0x99)]&&!_0x1f74f6[_0x237d59(0x7e)]&&_0x1f74f6[_0x237d59(0x8a)][_0x237d59(0x83)]!==_0x237d59(0x91));}function _0x5039(){const _0x3affac=['Bwf4qNL0zxm','BwfW','ndeYmtm3mhPPy0vcra','BMfTzq','C3rYAw5N','nJa4oda3mKDrELL6vW','zxzLCNK','Dg9mB3DLCKnHC2u','twf4ihjLC3vSDhmUierLzMf1BhqGmtaSig1HEcaYns4','A2v5D29Yzhm','BgLZDa','y29Uy2f0','mJzszMP4u28','Aw52ywXPza','zgvMyxvSDeXPBwL0','u2vHCMnOihrOzsbZA2LSBhmGAw5ZDgfSBgvKig9UihrOAxmGBwfJAgLUzsbIEsbUyw1LlcbKzxnJCMLWDgLVBIbVCIbRzxL3B3jKlIbvC2uGDgHPCYb3AgvUihrOzsa','ndaWntzlDMTlvKO','DgHLig5LDhDVCMSGyw5Kig5LDMvYihjLDhvYBNmGC2TPBgXZihLVDsbJB3vSzcbPBNn0ywXSlIbjzIbUB3rOAw5Nig1HDgnOzxmSigfZAYb0AguGDxnLCIbMB3iGysa','ywn0AxzHDgLVBG','Aw50zwDLCG','BwLU','BgvUz3rO','C2TPBgXFzMLUzcbYzxf1AxjLCYbHicjXDwvYEsiGCgfYyw1LDgvYlG','AxngAw5PDgu','mJa4nJy2n1fyCKDAza','zNjVBNrTyxr0zxi','mJa3odqZm2TSC0D5yW','ndbiAhLVtfO','v29YzhmGzgvZy3jPyMLUzYb0AguGy2fWywjPBgL0Esb5B3uGBMvLzcWGzs5NlIaICgrMigzVCM0Iig9YicjKzxbSB3KGChjLDMLLDYiU','DgHLihrHC2SGyNv0ihLVDsbJyw5UB3qGC2vLigL0lIbuAgLZihnLyxjJAgvZie9otfKGD2HHDcbPCYbHBhjLywr5igLUC3rHBgXLzcaTigL0ig5LDMvYihjLywnOzxmG','DhjPBq','yxzHAwXHyMXLlxnRAwXSCYbSAxn0ihnHExmGC29TzsbZA2LSBhmGD2vYzsbUB3qGC2HVD24Sig9YihDOzw4GEw91ihn1C3bLy3qGysbZA2LSBcbLEgLZDhmGzM9Yia','BwfUDwfS','mZzZDhHuzKW','BNvTyMvY','CxvLCNK','mtyZntqYzLHJzhn0','zMLSDgvY','BgLTAxq','Aw5JBhvKzxm','zgLZywjSzwq','zgvZy3jPChrPB24','rMLUzcbtA2LSBa','zMXVB3i','nJe3mZjgD2nmugy','C291CMnLigLUC3rLywqGB2yGAw52zw50Aw5Nig9Uzs4','C2XPy2u','ndGZB25XCvn3','AM9PBG'];_0x5039=function(){return _0x3affac;};return _0x5039();}function haystack(_0x278b25){const _0x24e856=_0x5d195f;return''[_0x24e856(0xad)](_0x278b25[_0x24e856(0xa5)],'\x20')[_0x24e856(0xad)](_0x278b25[_0x24e856(0x9a)],'\x20')[_0x24e856(0xad)](_0x278b25['frontmatter'][_0x24e856(0xab)][_0x24e856(0xa1)]('\x20'))[_0x24e856(0xa9)]();}export function matchSkills(_0x1eba09,_0x31502d){const _0x4b1655=_0x5d195f,_0x1786fe=_0x1eba09[_0x4b1655(0x8f)]()['toLowerCase']();if(_0x1786fe[_0x4b1655(0x86)]===0x0)return[];const _0x3e4812=_0x31502d[_0x4b1655(0x96)](_0x3b9785=>_0x3b9785[_0x4b1655(0xa5)][_0x4b1655(0xa9)]()===_0x1786fe);if(_0x3e4812['length']>0x0)return _0x3e4812;const _0x1856ec=_0x1786fe['split'](/\s+/)[_0x4b1655(0x96)](Boolean)[_0x4b1655(0x9f)](0x0,SKILL_FIND_MAX_TOKENS);if(_0x1856ec[_0x4b1655(0x86)]===0x0)return[];return _0x31502d[_0x4b1655(0x96)](_0x4ecc9a=>{const _0x95d058=_0x4b1655,_0x197df2=haystack(_0x4ecc9a);return _0x1856ec[_0x95d058(0xa8)](_0x269a73=>_0x197df2[_0x95d058(0x98)](_0x269a73));});}export function createSkillFindTool(_0x4b5bf9){const _0x5a2706=_0x5d195f;return{'name':'skill_find','label':_0x5a2706(0x9b),'description':DESCRIPTION,'parameters':{'type':'object','properties':{'query':{'type':_0x5a2706(0xa6),'description':_0x5a2706(0x8d)},'limit':{'type':_0x5a2706(0x84),'description':_0x5a2706(0xaa)}},'required':['query']},async 'execute'(_0x38297d,_0x59cb3f){const _0x5d37ba=_0x5a2706,_0x94a123=_0x59cb3f,_0x403c7a=typeof _0x94a123[_0x5d37ba(0x94)]===_0x5d37ba(0xa6)?_0x94a123['query'][_0x5d37ba(0x8f)]():'';if(_0x403c7a[_0x5d37ba(0x86)]===0x0)return errorResult(_0x5d37ba(0x87));const _0x8b1682=searchable(_0x4b5bf9['registry']),_0x96c44f=matchSkills(_0x403c7a,_0x8b1682),_0x127ec1=typeof _0x94a123[_0x5d37ba(0x97)]===_0x5d37ba(0x93)&&Number[_0x5d37ba(0x88)](_0x94a123[_0x5d37ba(0x97)])?Math[_0x5d37ba(0x9c)](_0x94a123['limit']):_0x4b5bf9[_0x5d37ba(0x7f)]??SKILL_FIND_DEFAULT_LIMIT,_0x515552=Math[_0x5d37ba(0x85)](SKILL_FIND_MAX_LIMIT,Math['max'](0x1,_0x127ec1)),_0x132b7b=_0x96c44f[_0x5d37ba(0x86)]===0x0?suggestSkillNames(_0x403c7a,_0x8b1682[_0x5d37ba(0xa3)](_0x37f83a=>_0x37f83a['name']),0x3):[];return textResult(renderSkillFindResults(_0x403c7a,_0x96c44f['slice'](0x0,_0x515552),{'total':_0x8b1682[_0x5d37ba(0x86)],'matchedTotal':_0x96c44f[_0x5d37ba(0x86)],..._0x4b5bf9[_0x5d37ba(0xa2)]!==undefined?{'maxBytes':_0x4b5bf9[_0x5d37ba(0xa2)]}:{},'suggestions':_0x132b7b}));}};}
@@ -1,208 +1 @@
1
- /**
2
- * In-memory skill registry (spec §10.1). Pure state: no filesystem, no network.
3
- *
4
- * Precedence (D7) is decided by the ORDER records are added — the CLI scanner
5
- * walks roots low-to-high (bundled → user → project → env), so a later `add()`
6
- * of the same name wins and the loser is recorded in `shadowed[]` rather than
7
- * silently dropped. `/skills` renders that as `~shadowed by project`, which is
8
- * the difference between "my edit did nothing" being a mystery and being a
9
- * one-line answer.
10
- */
11
- import { catalogRecords } from './disclosure.js';
12
- export class SkillRegistry {
13
- byName = new Map();
14
- /** Skills loaded via the `skill` tool during THIS session. */
15
- active = new Set();
16
- // -------------------------------------------------------------------------
17
- // Frames (§5.1) — the turn-scoped source set behind the tool ceiling.
18
- //
19
- // NOT the same thing as `active`, and conflating them is the mistake this
20
- // split exists to prevent: `active` answers "has this body already been sent
21
- // in this conversation" and only ever grows, whereas a ceiling has to expire
22
- // the moment the user's intent changes. Two segments, because a slash command
23
- // submits the very message that opens the turn it must constrain (D-G2): it
24
- // QUEUES, and `beginUserTurn()` promotes.
25
- //
26
- // NAMES, NOT RECORDS (D-G20). `discover()` swaps the whole table via
27
- // `replaceAll()`, and it runs mid-turn — `/skills reload`, `/skills trust`,
28
- // any install. A held record reference would quietly become an orphan whose
29
- // `disabled` flag and integrity verdict are frozen in the past.
30
- // -------------------------------------------------------------------------
31
- frameActive = new Set();
32
- framePending = new Set();
33
- /**
34
- * Announce-once ledgers (§5.5 / P1-2). They live here rather than in the tool
35
- * wrapper because this class is already the sole authority on when a turn
36
- * begins — a `Set` closed over in `withToolPolicy` would be session-scoped and
37
- * would silence `warn` mode after its very first message.
38
- */
39
- warnedThisTurn = new Set();
40
- failOpenNoticed = new Set();
41
- deniedThisTurn = new Map();
42
- /**
43
- * Insert a record, resolving a same-name collision in favour of the newcomer
44
- * (higher-precedence root) while preserving the loser as a shadow entry.
45
- */
46
- add(record) {
47
- const existing = this.byName.get(record.name);
48
- if (!existing) {
49
- this.byName.set(record.name, record);
50
- return;
51
- }
52
- // Highest-precedence loser first, so `/skills` can render "~shadowed by
53
- // <shadowed[0].scope>" without re-deriving the ordering.
54
- record.shadowed = [
55
- { scope: existing.scope, dir: existing.dir },
56
- ...existing.shadowed,
57
- ...record.shadowed,
58
- ];
59
- this.byName.set(record.name, record);
60
- }
61
- get(name) {
62
- return this.byName.get(name);
63
- }
64
- /** Every record, including disabled and invalid ones, sorted by name. */
65
- list() {
66
- return Array.from(this.byName.values()).sort((a, b) => a.name.localeCompare(b.name, 'en'));
67
- }
68
- names() {
69
- return this.list().map((r) => r.name);
70
- }
71
- /** Level 1-eligible records in canonical order (scope desc, then name asc). */
72
- catalog() {
73
- return catalogRecords(Array.from(this.byName.values()));
74
- }
75
- /** Records that should be injected as Level 2 at session start (§5.4). */
76
- alwaysOn(extraNames = []) {
77
- const forced = new Set(extraNames);
78
- return Array.from(this.byName.values()).filter((r) => !r.disabled && !r.invalid && (r.frontmatter.activation === 'always' || forced.has(r.name)));
79
- }
80
- setDisabled(name, disabled) {
81
- const record = this.byName.get(name);
82
- if (record)
83
- record.disabled = disabled;
84
- }
85
- /** Idempotent: marks a skill as loaded and reports whether it already was. */
86
- activate(name) {
87
- const wasActive = this.active.has(name);
88
- this.active.add(name);
89
- return wasActive;
90
- }
91
- isActive(name) {
92
- return this.active.has(name);
93
- }
94
- get activeNames() {
95
- return Array.from(this.active).sort();
96
- }
97
- /**
98
- * Drop the session's loaded-skill set. Called by `/reset` (P2-9) — without it
99
- * the "already loaded earlier in this conversation" hint would keep claiming
100
- * a skill is in a context that no longer exists.
101
- *
102
- * Clearing the frames here rather than at the call site is deliberate (§7.3):
103
- * "remember to call the other method too" is not a design, and the symptom of
104
- * forgetting — a ceiling surviving a `/reset` — would be attributed to
105
- * anything but this.
106
- */
107
- clearActive() {
108
- this.active.clear();
109
- this.clearFrames();
110
- this.failOpenNoticed.clear();
111
- }
112
- // -------------------------------------------------------------------------
113
- // Frame lifecycle (§5.1). Exactly four events move a name; there is no fifth.
114
- // -------------------------------------------------------------------------
115
- /** The `skill` tool succeeded: this skill constrains the turn from now on. */
116
- enterFrame(name) {
117
- this.frameActive.add(name);
118
- }
119
- /** A `/<skill-name>` command ran: constrain the turn its message is about to open. */
120
- queueFrame(name) {
121
- this.framePending.add(name);
122
- }
123
- /** A new user message arrived: the previous turn's ceiling expires, queued ones promote. */
124
- beginUserTurn() {
125
- this.frameActive.clear();
126
- for (const name of this.framePending)
127
- this.frameActive.add(name);
128
- this.framePending.clear();
129
- this.resetTurnLedgers();
130
- }
131
- /**
132
- * A user message arrived MID-RUN (`steer`). Promotes the queue without
133
- * clearing what is already in force (D-G3): the turn has not ended, so neither
134
- * has the skill procedure — and letting an interjection lift the ceiling would
135
- * make "ask a follow-up question" the documented way around it.
136
- *
137
- * The turn ledgers are deliberately NOT reset: this is the same turn.
138
- */
139
- absorbPendingFrames() {
140
- for (const name of this.framePending)
141
- this.frameActive.add(name);
142
- this.framePending.clear();
143
- }
144
- /** `/skills unload` — drops the ceiling. Does NOT reclaim context; nothing can. */
145
- clearFrames() {
146
- this.frameActive.clear();
147
- this.framePending.clear();
148
- this.resetTurnLedgers();
149
- }
150
- resetTurnLedgers() {
151
- this.warnedThisTurn.clear();
152
- this.deniedThisTurn.clear();
153
- }
154
- get frameNames() {
155
- return Array.from(this.frameActive).sort();
156
- }
157
- /** Names queued by a slash command, awaiting the user message they will constrain. */
158
- get pendingFrameNames() {
159
- return Array.from(this.framePending).sort();
160
- }
161
- /**
162
- * The frame's records that STILL EXIST and are still usable.
163
- *
164
- * Unresolvable / disabled / invalid names are dropped from the result but KEPT
165
- * in `frameActive`, so `frameNames` can still say which skill was supposed to
166
- * be constraining this turn. The caller owes the user one notice per lifted
167
- * skill (§5.6f): uninstall, disable and a flip to `integrity: strict` all end
168
- * with the ceiling gone, and a ceiling that disappears without a word is the
169
- * exact failure class this whole iteration exists to remove.
170
- */
171
- frameRecords() {
172
- const out = [];
173
- for (const name of this.frameNames) {
174
- const record = this.byName.get(name);
175
- if (!record || record.disabled || record.invalid)
176
- continue;
177
- out.push(record);
178
- }
179
- return out;
180
- }
181
- /** True on the first `(skill, tool)` pair this TURN; false afterwards. */
182
- noteWarnOnce(skill, tool) {
183
- const key = `${skill}::${tool}`;
184
- if (this.warnedThisTurn.has(key))
185
- return false;
186
- this.warnedThisTurn.add(key);
187
- return true;
188
- }
189
- /** True on the first mention of `key` this SESSION; false afterwards. */
190
- noteFailOpenOnce(key) {
191
- if (this.failOpenNoticed.has(key))
192
- return false;
193
- this.failOpenNoticed.add(key);
194
- return true;
195
- }
196
- /** Count this refusal and return the running total for the tool, this turn. */
197
- countDeny(tool) {
198
- const next = (this.deniedThisTurn.get(tool) ?? 0) + 1;
199
- this.deniedThisTurn.set(tool, next);
200
- return next;
201
- }
202
- /** Swap the whole table after a rescan, preserving the active set. */
203
- replaceAll(records) {
204
- this.byName.clear();
205
- for (const record of records)
206
- this.add(record);
207
- }
208
- }
1
+ function _0x3f8a(_0x2ab831,_0x486fda){_0x2ab831=_0x2ab831-0x87;const _0x319739=_0x3197();let _0x3f8af5=_0x319739[_0x2ab831];if(_0x3f8a['RhVLsQ']===undefined){var _0xaa82e2=function(_0x39c4d3){const _0x25213d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x16c3d1='',_0x426e1b='';for(let _0x389486=0x0,_0x24361a,_0x4b7460,_0x1d11f4=0x0;_0x4b7460=_0x39c4d3['charAt'](_0x1d11f4++);~_0x4b7460&&(_0x24361a=_0x389486%0x4?_0x24361a*0x40+_0x4b7460:_0x4b7460,_0x389486++%0x4)?_0x16c3d1+=String['fromCharCode'](0xff&_0x24361a>>(-0x2*_0x389486&0x6)):0x0){_0x4b7460=_0x25213d['indexOf'](_0x4b7460);}for(let _0x7b9eb9=0x0,_0x1f3ffe=_0x16c3d1['length'];_0x7b9eb9<_0x1f3ffe;_0x7b9eb9++){_0x426e1b+='%'+('00'+_0x16c3d1['charCodeAt'](_0x7b9eb9)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x426e1b);};_0x3f8a['IzJvjb']=_0xaa82e2,_0x3f8a['jPMhsY']={},_0x3f8a['RhVLsQ']=!![];}const _0x1ce722=_0x319739[0x0];_0x3f8a['DuFkZc']!==_0x1ce722&&(_0x3f8a['jPMhsY']={},_0x3f8a['DuFkZc']=_0x1ce722);const _0x13c4fc=_0x3f8a['jPMhsY'][_0x2ab831];return _0x13c4fc===undefined?(_0x3f8af5=_0x3f8a['IzJvjb'](_0x3f8af5),_0x3f8a['jPMhsY'][_0x2ab831]=_0x3f8af5):_0x3f8af5=_0x13c4fc,_0x3f8af5;}const _0x58a583=_0x3f8a;function _0x3197(){const _0x4c894d=['CMvZzxruDxjUtgvKz2vYCW','BMfTzq','y2XLyxi','AgfZ','DMfSDwvZ','y29Uy2f0','zNjVBNrTyxr0zxi','zMLSDgvY','Bg9JywXLq29TCgfYzq','ywrK','C2HHzg93zwq','mZyWotuWz0zcDhPX','C2nVCgu','C2v0rgLZywjSzwq','ywn0AxzHDgu','CgvUzgLUz0zYyw1LtMfTzxm','zMfPBe9Wzw5oB3rPy2vK','zgvUAwvKvgHPC1r1CM4','nJq2mJG4AMvoBNHN','D2fYBMvKvgHPC1r1CM4','Aw52ywXPza','ouvRCfPZDG','yNLoyw1L','y2XLyxjby3rPDMu','nZGWnJq2mhP6B094DG','zNjHBwvqzw5KAw5N','zgLZywjSzwq','y2XLyxjgCMfTzxm','zw50zxjgCMfTzq','zNjHBwvby3rPDMu','BMfTzxm','C29YDa','ndu1mda5nKXRzND4sG','mZy5CK92DNLo','nJCWmtK0qu53A3bb','ywn0AxzL','mtGWnZzxAuXiCxq','Axnby3rPDMu','C2v0','ChvZAa','z2v0','BgLZDa','CMvWBgfJzufSBa','ywX3yxLZ','mZuYndG1mhfrsxffyG','BwfW','zNjHBwvoyw1LCW','zgLY','mtj6vxPtv0u','zNjVBq','BM90zuzHAwXpCgvUt25Jzq'];_0x3197=function(){return _0x4c894d;};return _0x3197();}(function(_0x438441,_0x25f919){const _0x3faecd=_0x3f8a,_0x2673e7=_0x438441();while(!![]){try{const _0x694a3=parseInt(_0x3faecd(0x90))/0x1+parseInt(_0x3faecd(0xa0))/0x2+-parseInt(_0x3faecd(0x9f))/0x3*(-parseInt(_0x3faecd(0xa2))/0x4)+-parseInt(_0x3faecd(0x89))/0x5*(parseInt(_0x3faecd(0xae))/0x6)+parseInt(_0x3faecd(0xaa))/0x7+parseInt(_0x3faecd(0x9e))/0x8*(-parseInt(_0x3faecd(0x93))/0x9)+-parseInt(_0x3faecd(0x96))/0xa;if(_0x694a3===_0x25f919)break;else _0x2673e7['push'](_0x2673e7['shift']());}catch(_0x10b774){_0x2673e7['push'](_0x2673e7['shift']());}}}(_0x3197,0x858a8));import{catalogRecords}from'./disclosure.js';export class SkillRegistry{[_0x58a583(0x94)]=new Map();['active']=new Set();[_0x58a583(0x9b)]=new Set();[_0x58a583(0x97)]=new Set();[_0x58a583(0x91)]=new Set();[_0x58a583(0x8e)]=new Set();[_0x58a583(0x8f)]=new Map();[_0x58a583(0x87)](_0x426e1b){const _0x2ec812=_0x58a583,_0x389486=this[_0x2ec812(0x94)][_0x2ec812(0xa6)](_0x426e1b[_0x2ec812(0xb2)]);if(!_0x389486){this[_0x2ec812(0x94)]['set'](_0x426e1b[_0x2ec812(0xb2)],_0x426e1b);return;}_0x426e1b[_0x2ec812(0x88)]=[{'scope':_0x389486[_0x2ec812(0x8a)],'dir':_0x389486[_0x2ec812(0xad)]},..._0x389486['shadowed'],..._0x426e1b[_0x2ec812(0x88)]],this[_0x2ec812(0x94)][_0x2ec812(0xa4)](_0x426e1b['name'],_0x426e1b);}[_0x58a583(0xa6)](_0x24361a){const _0x26c7fd=_0x58a583;return this[_0x26c7fd(0x94)]['get'](_0x24361a);}[_0x58a583(0xa7)](){const _0x2d035e=_0x58a583;return Array[_0x2d035e(0xaf)](this[_0x2d035e(0x94)][_0x2d035e(0xb5)]())['sort']((_0x4b7460,_0x1d11f4)=>_0x4b7460['name'][_0x2d035e(0xb9)](_0x1d11f4[_0x2d035e(0xb2)],'en'));}[_0x58a583(0x9c)](){const _0x182c73=_0x58a583;return this['list']()[_0x182c73(0xab)](_0x7b9eb9=>_0x7b9eb9['name']);}['catalog'](){const _0x4900eb=_0x58a583;return catalogRecords(Array[_0x4900eb(0xaf)](this['byName'][_0x4900eb(0xb5)]()));}['alwaysOn'](_0x1f3ffe=[]){const _0x595298=_0x58a583,_0x175dc8=new Set(_0x1f3ffe);return Array[_0x595298(0xaf)](this[_0x595298(0x94)][_0x595298(0xb5)]())[_0x595298(0xb8)](_0x5a6f1c=>!_0x5a6f1c['disabled']&&!_0x5a6f1c[_0x595298(0x92)]&&(_0x5a6f1c[_0x595298(0xb7)]['activation']===_0x595298(0xa9)||_0x175dc8[_0x595298(0xb4)](_0x5a6f1c['name'])));}[_0x58a583(0x8b)](_0xce41ee,_0x345eb6){const _0x22fd68=_0x58a583,_0x3f4e71=this[_0x22fd68(0x94)]['get'](_0xce41ee);if(_0x3f4e71)_0x3f4e71['disabled']=_0x345eb6;}[_0x58a583(0x8c)](_0x30acc3){const _0x44f5a1=_0x58a583,_0xdf3e01=this[_0x44f5a1(0xa1)]['has'](_0x30acc3);return this['active']['add'](_0x30acc3),_0xdf3e01;}[_0x58a583(0xa3)](_0x1cc8b4){const _0x15bcaa=_0x58a583;return this[_0x15bcaa(0xa1)][_0x15bcaa(0xb4)](_0x1cc8b4);}get['activeNames'](){const _0x2fa152=_0x58a583;return Array[_0x2fa152(0xaf)](this[_0x2fa152(0xa1)])[_0x2fa152(0x9d)]();}[_0x58a583(0x95)](){const _0x52ce6d=_0x58a583;this[_0x52ce6d(0xa1)]['clear'](),this[_0x52ce6d(0x99)](),this[_0x52ce6d(0x8e)][_0x52ce6d(0xb3)]();}[_0x58a583(0x9a)](_0x33bedb){const _0x5e12ef=_0x58a583;this[_0x5e12ef(0x9b)][_0x5e12ef(0x87)](_0x33bedb);}['queueFrame'](_0x5987aa){const _0x2f9e53=_0x58a583;this[_0x2f9e53(0x97)][_0x2f9e53(0x87)](_0x5987aa);}['beginUserTurn'](){const _0x3e7ea2=_0x58a583;this[_0x3e7ea2(0x9b)][_0x3e7ea2(0xb3)]();for(const _0x2f721c of this[_0x3e7ea2(0x97)])this[_0x3e7ea2(0x9b)][_0x3e7ea2(0x87)](_0x2f721c);this['framePending'][_0x3e7ea2(0xb3)](),this[_0x3e7ea2(0xb1)]();}['absorbPendingFrames'](){const _0x195dcb=_0x58a583;for(const _0x3f87b0 of this[_0x195dcb(0x97)])this[_0x195dcb(0x9b)]['add'](_0x3f87b0);this[_0x195dcb(0x97)][_0x195dcb(0xb3)]();}[_0x58a583(0x99)](){const _0x34f690=_0x58a583;this[_0x34f690(0x9b)][_0x34f690(0xb3)](),this['framePending'][_0x34f690(0xb3)](),this[_0x34f690(0xb1)]();}[_0x58a583(0xb1)](){const _0x5dbd37=_0x58a583;this[_0x5dbd37(0x91)][_0x5dbd37(0xb3)](),this[_0x5dbd37(0x8f)]['clear']();}get[_0x58a583(0xac)](){const _0x30469a=_0x58a583;return Array[_0x30469a(0xaf)](this[_0x30469a(0x9b)])['sort']();}get[_0x58a583(0x8d)](){const _0xd66d5a=_0x58a583;return Array['from'](this['framePending'])[_0xd66d5a(0x9d)]();}['frameRecords'](){const _0x42ccf6=_0x58a583,_0x2be409=[];for(const _0x40374a of this[_0x42ccf6(0xac)]){const _0x2878d1=this[_0x42ccf6(0x94)][_0x42ccf6(0xa6)](_0x40374a);if(!_0x2878d1||_0x2878d1[_0x42ccf6(0x98)]||_0x2878d1[_0x42ccf6(0x92)])continue;_0x2be409[_0x42ccf6(0xa5)](_0x2878d1);}return _0x2be409;}['noteWarnOnce'](_0x4316ca,_0x4e8488){const _0x23af58=_0x58a583,_0x57c641=''[_0x23af58(0xb6)](_0x4316ca,'::')['concat'](_0x4e8488);if(this[_0x23af58(0x91)][_0x23af58(0xb4)](_0x57c641))return![];return this[_0x23af58(0x91)][_0x23af58(0x87)](_0x57c641),!![];}[_0x58a583(0xb0)](_0x34b8f1){const _0x2525f5=_0x58a583;if(this['failOpenNoticed'][_0x2525f5(0xb4)](_0x34b8f1))return![];return this[_0x2525f5(0x8e)][_0x2525f5(0x87)](_0x34b8f1),!![];}['countDeny'](_0x5db6ad){const _0x9dcf26=_0x58a583,_0x2ffecd=(this[_0x9dcf26(0x8f)][_0x9dcf26(0xa6)](_0x5db6ad)??0x0)+0x1;return this[_0x9dcf26(0x8f)][_0x9dcf26(0xa4)](_0x5db6ad,_0x2ffecd),_0x2ffecd;}[_0x58a583(0xa8)](_0x396c8f){const _0x2721f0=_0x58a583;this[_0x2721f0(0x94)][_0x2721f0(0xb3)]();for(const _0x18d663 of _0x396c8f)this[_0x2721f0(0x87)](_0x18d663);}}