@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,96 +1 @@
1
- /**
2
- * The `skill` tool — Level 2 of progressive disclosure (spec §5.2).
3
- *
4
- * WHY A TOOL RESULT AND NOT A SYSTEM-PROMPT REWRITE (D2): `Agent.prompt()`
5
- * snapshots `this.systemPrompt` when the loop starts, so mutating it mid-run is
6
- * a no-op for the current turn. A tool result, by contrast, enters the message
7
- * history immediately, survives `/save` + `/resume` for free, and costs nothing
8
- * on turns where no skill is used.
9
- *
10
- * NAMING (D4): lowercase `skill`, matching the seven existing snake_case tools,
11
- * rather than Claude Code's `Skill`. The catalog block spells out the mapping so
12
- * community skills that say "call the Skill tool" still resolve.
13
- */
14
- import { errorResult, textResult } from '../tools/helpers.js';
15
- import { renderSkillBody, suggestSkillNames } from './disclosure.js';
16
- const DESCRIPTION = 'Load the full instructions of an installed skill before doing work it covers. ' +
17
- 'Pick the exact name from <available_skills>. Returns the skill body plus a list of ' +
18
- 'bundled files you can then read with read_file or run with bash. ' +
19
- 'Loading a skill is cheap - prefer it over re-deriving a procedure yourself.';
20
- export function createSkillTool(deps) {
21
- return {
22
- name: 'skill',
23
- label: 'Skill',
24
- description: DESCRIPTION,
25
- parameters: {
26
- type: 'object',
27
- properties: {
28
- name: { type: 'string', description: 'Exact skill name from <available_skills>.' },
29
- arguments: { type: 'string', description: 'Optional free-form arguments for the skill.' },
30
- force: {
31
- type: 'boolean',
32
- description: 'Re-send the full body even if this skill was already loaded in this conversation. ' +
33
- 'Only needed if you cannot find the earlier copy.',
34
- },
35
- },
36
- required: ['name'],
37
- },
38
- async execute(_id, rawParams) {
39
- const params = rawParams;
40
- const name = typeof params.name === 'string' ? params.name.trim() : '';
41
- if (name.length === 0)
42
- return errorResult('skill requires a "name" parameter.');
43
- const record = deps.registry.get(name);
44
- if (!record) {
45
- const suggestions = suggestSkillNames(name, deps.registry.names());
46
- const hint = suggestions.length > 0 ? ` Did you mean: ${suggestions.join(', ')}?` : '';
47
- return errorResult(`Unknown skill "${name}".${hint} Run /skills to list all.`);
48
- }
49
- if (record.disabled) {
50
- return errorResult(`Skill "${name}" is disabled. Enable it with /skills enable ${name}.`);
51
- }
52
- if (record.invalid) {
53
- const first = record.issues.find((i) => i.level === 'error');
54
- return errorResult(`Skill "${name}" failed validation: ${first ? `${first.code} - ${first.message}` : 'unknown error'}.`);
55
- }
56
- // The single place where a host-side throw is converted into a diagnosable
57
- // tool error. The engine would otherwise turn it into a generic stack trace.
58
- let loaded;
59
- try {
60
- loaded = deps.loadBody(name);
61
- }
62
- catch (err) {
63
- const message = err instanceof Error ? err.message : String(err);
64
- return errorResult(`Could not read SKILL.md for "${name}": ${message}`);
65
- }
66
- // ── The order below is load-bearing; do not reorder (§7.2). ──────────
67
- // 1. Hydrate.
68
- record.body = loaded.body;
69
- record.files = loaded.files;
70
- // 2. Record the session-level load and learn whether it is a repeat.
71
- const alreadyLoaded = deps.registry.activate(name);
72
- // 3. Enter the frame BEFORE step 4 — this skill is one of the ceiling's
73
- // own sources, and a digest counts as a "I am using this" statement
74
- // just as much as a full load does, so the ceiling applies either way.
75
- deps.registry.enterFrame(name);
76
- // 4. Only now is a policy snapshot truthful.
77
- const policy = deps.policySnapshot?.();
78
- // 5. Repeat loads get the digest unless the model explicitly asks otherwise.
79
- const force = params.force === true;
80
- const mode = alreadyLoaded && !force ? 'digest' : 'full';
81
- const args = typeof params.arguments === 'string' ? params.arguments : '';
82
- // 6. Render.
83
- return textResult(renderSkillBody(record, {
84
- ...(deps.bodyMaxBytes !== undefined ? { bodyMaxBytes: deps.bodyMaxBytes } : {}),
85
- ...(deps.resultMaxBytes !== undefined ? { resultMaxBytes: deps.resultMaxBytes } : {}),
86
- // The legacy one-line hint belongs to the full re-send only; the digest
87
- // states the same fact in its own opening line.
88
- ...(mode === 'full' && alreadyLoaded ? { alreadyLoaded: true } : {}),
89
- mode,
90
- ...(policy ? { policy } : {}),
91
- ...(deps.platform ? { platform: deps.platform } : {}),
92
- ...(args.length > 0 ? { arguments: args } : {}),
93
- }));
94
- },
95
- };
96
- }
1
+ const _0x1a9f14=_0x174b;function _0x174b(_0x2d552c,_0x59ba98){_0x2d552c=_0x2d552c-0x104;const _0xa3b6c3=_0xa3b6();let _0x174b76=_0xa3b6c3[_0x2d552c];if(_0x174b['NcZekc']===undefined){var _0x483185=function(_0x2ad460){const _0x11cb95='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5cc7af='',_0x92b615='';for(let _0x48f8df=0x0,_0x240873,_0x55066d,_0x50b279=0x0;_0x55066d=_0x2ad460['charAt'](_0x50b279++);~_0x55066d&&(_0x240873=_0x48f8df%0x4?_0x240873*0x40+_0x55066d:_0x55066d,_0x48f8df++%0x4)?_0x5cc7af+=String['fromCharCode'](0xff&_0x240873>>(-0x2*_0x48f8df&0x6)):0x0){_0x55066d=_0x11cb95['indexOf'](_0x55066d);}for(let _0xc122d8=0x0,_0x489dc8=_0x5cc7af['length'];_0xc122d8<_0x489dc8;_0xc122d8++){_0x92b615+='%'+('00'+_0x5cc7af['charCodeAt'](_0xc122d8)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x92b615);};_0x174b['bGmXll']=_0x483185,_0x174b['oAIgeU']={},_0x174b['NcZekc']=!![];}const _0x470f7c=_0xa3b6c3[0x0];_0x174b['VrWPhY']!==_0x470f7c&&(_0x174b['oAIgeU']={},_0x174b['VrWPhY']=_0x470f7c);const _0x3d8c51=_0x174b['oAIgeU'][_0x2d552c];return _0x3d8c51===undefined?(_0x174b76=_0x174b['bGmXll'](_0x174b76),_0x174b['oAIgeU'][_0x2d552c]=_0x174b76):_0x174b76=_0x3d8c51,_0x174b76;}(function(_0x51b21b,_0x24a189){const _0x495af9=_0x174b,_0x588416=_0x51b21b();while(!![]){try{const _0x46d258=-parseInt(_0x495af9(0x10b))/0x1*(-parseInt(_0x495af9(0x12b))/0x2)+-parseInt(_0x495af9(0x134))/0x3*(parseInt(_0x495af9(0x111))/0x4)+-parseInt(_0x495af9(0x11b))/0x5*(-parseInt(_0x495af9(0x11c))/0x6)+parseInt(_0x495af9(0x112))/0x7*(parseInt(_0x495af9(0x11e))/0x8)+parseInt(_0x495af9(0x133))/0x9+parseInt(_0x495af9(0x104))/0xa*(parseInt(_0x495af9(0x116))/0xb)+-parseInt(_0x495af9(0x131))/0xc;if(_0x46d258===_0x24a189)break;else _0x588416['push'](_0x588416['shift']());}catch(_0x21b27b){_0x588416['push'](_0x588416['shift']());}}}(_0xa3b6,0xc20d6));import{errorResult,textResult}from'../tools/helpers.js';import{renderSkillBody,suggestSkillNames}from'./disclosure.js';function _0xa3b6(){const _0x229f5e=['zNvSBa','B2jQzwn0','ic0G','t25SEsbUzwvKzwqGAwyGEw91ignHBM5VDcbMAw5KihrOzsbLyxjSAwvYignVChKU','zM9Yy2u','mtK4mtK2mgzNDwLgzq','zxjYB3i','CMvNAxn0CNK','y29Kzq','yxjNDw1LBNrZ','AM9PBG','CgXHDgzVCM0','nLHAtLDgBa','zgLNzxn0','BMfTzq','rxHHy3qGC2TPBgWGBMfTzsbMCM9TidXHDMfPBgfIBgvFC2TPBgXZpI4','u2TPBgW','Aw52ywXPza','mJbdz2zABvm','mtm1oe9rr3reDW','zMLSzxm','AxnZDwvZ','tg9Hzcb0AguGzNvSBcbPBNn0CNvJDgLVBNmGB2yGyw4GAw5ZDgfSBgvKihnRAwXSigjLzM9YzsbKB2LUzYb3B3jRigL0ignVDMvYCY4G','mtfzzg9jD2y','C2TPBgW','zgLZywjSzwq','BgvUz3rO','yM9KEu1HEej5DgvZ','nZG3odG1CwvOr2nP','mZzSA0DZrM0','y29Uy2f0','nty5nJHQrw15EvO','uMuTC2vUzcb0AguGzNvSBcbIB2r5igv2zw4GAwyGDgHPCYbZA2LSBcb3yxmGywXYzwfKEsbSB2fKzwqGAw4GDgHPCYbJB252zxjZyxrPB24Uia','Bgv2zwW','iIbPCYbKAxnHyMXLzc4Grw5HyMXLigL0ihDPDgGGl3nRAwXSCYbLBMfIBguG','BMfTzxm','u2TPBgWGiG','BwvZC2fNzq','CMvZDwX0twf4qNL0zxm','t3b0Aw9UywWGzNjLzs1MB3jTigfYz3vTzw50CYbMB3iGDgHLihnRAwXSlG','vw5RBM93BIbZA2LSBcaI','ywn0AxzHDgu','zMLUza','C2TPBgWGCMvXDwLYzxmGysaIBMfTzsiGCgfYyw1LDgvYlG','ndm4ntyYBNLnC0vZ','tg9HzgLUzYbHihnRAwXSigLZignOzwfWic0GChjLzMvYigL0ig92zxiGCMuTzgvYAxzPBMCGysbWCM9Jzwr1CMuGEw91CNnLBgyU','ifj1BIaVC2TPBgXZihrVigXPC3qGywXSlG','iJOG','ierPzcb5B3uGBwvHBJOG','yM9KEq','ntaXndeXodrvC3DKBwi','C3rYAw5N','mtmYnJq4otnvBMHoDuy','mJa0odu1BKfnzw9t','ugLJAYb0AguGzxHHy3qGBMfTzsbMCM9TidXHDMfPBgfIBgvFC2TPBgXZpI4GuMv0DxjUCYb0AguGC2TPBgWGyM9KEsbWBhvZigeGBgLZDcbVzIa','Cg9SAwn5u25HChnOB3q','DhjPBq','yM9VBgvHBG','Bg9HzejVzhK','yNvUzgXLzcbMAwXLCYb5B3uGy2fUihrOzw4GCMvHzcb3AxrOihjLywrFzMLSzsbVCIbYDw4GD2L0AcbIyxnOlIa'];_0xa3b6=function(){return _0x229f5e;};return _0xa3b6();}const DESCRIPTION=_0x1a9f14(0x115)+_0x1a9f14(0x135)+_0x1a9f14(0x13a)+_0x1a9f14(0x12c);export function createSkillTool(_0x92b615){const _0x255a64=_0x1a9f14;return{'name':_0x255a64(0x117),'label':_0x255a64(0x10f),'description':DESCRIPTION,'parameters':{'type':_0x255a64(0x13c),'properties':{'name':{'type':_0x255a64(0x132),'description':_0x255a64(0x10e)},'arguments':{'type':_0x255a64(0x132),'description':_0x255a64(0x126)},'force':{'type':_0x255a64(0x138),'description':_0x255a64(0x11f)+_0x255a64(0x13e)}},'required':[_0x255a64(0x10d)]},async 'execute'(_0x48f8df,_0x240873){const _0x178c9f=_0x255a64,_0x55066d=_0x240873,_0x50b279=typeof _0x55066d[_0x178c9f(0x10d)]==='string'?_0x55066d['name'][_0x178c9f(0x137)]():'';if(_0x50b279['length']===0x0)return errorResult(_0x178c9f(0x12a));const _0xc122d8=_0x92b615[_0x178c9f(0x106)]['get'](_0x50b279);if(!_0xc122d8){const _0x357d55=suggestSkillNames(_0x50b279,_0x92b615['registry'][_0x178c9f(0x122)]()),_0x4fd303=_0x357d55['length']>0x0?_0x178c9f(0x12f)['concat'](_0x357d55[_0x178c9f(0x109)](',\x20'),'?'):'';return errorResult(_0x178c9f(0x127)[_0x178c9f(0x11d)](_0x50b279,'\x22.')[_0x178c9f(0x11d)](_0x4fd303,_0x178c9f(0x12d)));}if(_0xc122d8[_0x178c9f(0x118)])return errorResult(_0x178c9f(0x123)[_0x178c9f(0x11d)](_0x50b279,_0x178c9f(0x121))[_0x178c9f(0x11d)](_0x50b279,'.'));if(_0xc122d8[_0x178c9f(0x110)]){const _0x1eaea7=_0xc122d8[_0x178c9f(0x114)][_0x178c9f(0x129)](_0x3b6a4b=>_0x3b6a4b[_0x178c9f(0x120)]===_0x178c9f(0x105));return errorResult(_0x178c9f(0x123)[_0x178c9f(0x11d)](_0x50b279,'\x22\x20failed\x20validation:\x20')[_0x178c9f(0x11d)](_0x1eaea7?''['concat'](_0x1eaea7[_0x178c9f(0x107)],_0x178c9f(0x13d))[_0x178c9f(0x11d)](_0x1eaea7[_0x178c9f(0x124)]):'unknown\x20error','.'));}let _0x489dc8;try{_0x489dc8=_0x92b615[_0x178c9f(0x139)](_0x50b279);}catch(_0x26a813){const _0x2dcb78=_0x26a813 instanceof Error?_0x26a813[_0x178c9f(0x124)]:String(_0x26a813);return errorResult('Could\x20not\x20read\x20SKILL.md\x20for\x20\x22'[_0x178c9f(0x11d)](_0x50b279,_0x178c9f(0x12e))['concat'](_0x2dcb78));}_0xc122d8[_0x178c9f(0x130)]=_0x489dc8[_0x178c9f(0x130)],_0xc122d8['files']=_0x489dc8[_0x178c9f(0x113)];const _0x31d18b=_0x92b615[_0x178c9f(0x106)][_0x178c9f(0x128)](_0x50b279);_0x92b615[_0x178c9f(0x106)]['enterFrame'](_0x50b279);const _0x7abe57=_0x92b615[_0x178c9f(0x136)]?.(),_0x4fef5a=_0x55066d[_0x178c9f(0x13f)]===!![],_0x2c92ab=_0x31d18b&&!_0x4fef5a?_0x178c9f(0x10c):_0x178c9f(0x13b),_0xae78c4=typeof _0x55066d[_0x178c9f(0x108)]===_0x178c9f(0x132)?_0x55066d[_0x178c9f(0x108)]:'';return textResult(renderSkillBody(_0xc122d8,{..._0x92b615[_0x178c9f(0x11a)]!==undefined?{'bodyMaxBytes':_0x92b615['bodyMaxBytes']}:{},..._0x92b615[_0x178c9f(0x125)]!==undefined?{'resultMaxBytes':_0x92b615[_0x178c9f(0x125)]}:{},..._0x2c92ab==='full'&&_0x31d18b?{'alreadyLoaded':!![]}:{},'mode':_0x2c92ab,..._0x7abe57?{'policy':_0x7abe57}:{},..._0x92b615[_0x178c9f(0x10a)]?{'platform':_0x92b615[_0x178c9f(0x10a)]}:{},..._0xae78c4[_0x178c9f(0x119)]>0x0?{'arguments':_0xae78c4}:{}}));}};}
@@ -1,272 +1 @@
1
- /**
2
- * The turn-scoped tool ceiling (spec §5) — what turns `allowed-tools` from a
3
- * decorative frontmatter field into an executable declaration.
4
- *
5
- * PURE FUNCTIONS ONLY. This module does not know which tools the host has; the
6
- * caller passes `registered` and `floor` in (D-G7). Core owns the SKILL.md
7
- * FORMAT — which includes knowing that `Read` is what Claude Code calls its
8
- * read-a-file tool — while the CLI owns the inventory of what actually exists.
9
- *
10
- * THE DIRECTION OF FAILURE IS THE WHOLE DESIGN (D-G4). A declaration this host
11
- * cannot fully resolve waives that skill's contribution ENTIRELY rather than
12
- * narrowing it: honouring the half we understood would silently constrain an
13
- * author to something they never wrote, and the reason (one mistyped tool name)
14
- * would be invisible. Fail-open plus a loud notice is correct here; the
15
- * fail-closed rule lives on the install gate, where the adversary is a person
16
- * rather than a typo.
17
- */
18
- import { TOOL_POLICY_DENY_ESCALATE_AT } from './constants.js';
19
- // ---------------------------------------------------------------------------
20
- // Name resolution (§5.3)
21
- // ---------------------------------------------------------------------------
22
- /** Lower-case and strip `_`, `-` and whitespace: `Read`→`read`, `read_file`→`readfile`. */
23
- export function normalizeToolAlias(name) {
24
- return name.toLowerCase().replace(/[_\-\s]/g, '');
25
- }
26
- /**
27
- * Claude Code's vocabulary → this host's snake_case names.
28
- *
29
- * Keys are already normalized. This table is why `.claude/skills` interop — the
30
- * README's headline feature — survives enforcement at all: without it every
31
- * community declaration (`allowed-tools: [Read, Bash]`) would resolve to nothing
32
- * and every such skill would take the fail-open path, making the whole ceiling
33
- * ornamental (FG2 / RG2).
34
- */
35
- export const SKILL_TOOL_ALIASES = Object.freeze({
36
- read: 'read_file',
37
- readfile: 'read_file',
38
- view: 'read_file',
39
- cat: 'read_file',
40
- write: 'write_file',
41
- writefile: 'write_file',
42
- create: 'write_file',
43
- edit: 'edit_file',
44
- editfile: 'edit_file',
45
- multiedit: 'edit_file',
46
- strreplaceeditor: 'edit_file',
47
- strreplacebasededitor: 'edit_file',
48
- bash: 'bash',
49
- shell: 'bash',
50
- sh: 'bash',
51
- runcommand: 'bash',
52
- terminal: 'bash',
53
- ls: 'list_dir',
54
- listdir: 'list_dir',
55
- listdirectory: 'list_dir',
56
- glob: 'glob',
57
- findfiles: 'glob',
58
- grep: 'grep',
59
- search: 'grep',
60
- ripgrep: 'grep',
61
- skill: 'skill',
62
- skillfind: 'skill_find',
63
- skillinstall: 'skill_install',
64
- skillcreate: 'skill_create',
65
- });
66
- /**
67
- * Capabilities this host simply does not have. A declaration naming one is
68
- * DROPPED, not treated as unresolvable (D-G5).
69
- *
70
- * If these counted as "cannot resolve", nearly every community skill would take
71
- * the fail-open path and enforcement would be theatre. Dropping them changes no
72
- * executable set — the model could never have called them — while leaving the
73
- * rest of the declaration in force. That is precision, not a concession.
74
- *
75
- * THIS TABLE ONLY GROWS. Removing an entry pushes already-working skills into
76
- * fail-open with no symptom whatsoever.
77
- */
78
- export const SKILL_TOOL_KNOWN_ABSENT = new Set([
79
- 'webfetch',
80
- 'websearch',
81
- 'task',
82
- 'agent',
83
- 'todowrite',
84
- 'todoread',
85
- 'notebookedit',
86
- 'notebookread',
87
- 'bashoutput',
88
- 'killshell',
89
- 'slashcommand',
90
- 'exitplanmode',
91
- 'askuserquestion',
92
- 'computer',
93
- ]);
94
- /**
95
- * Resolve one declared name against the live tool list.
96
- *
97
- * `string` — a tool on this host.
98
- * `'absent'` — a real Claude Code tool this host lacks; drop it silently.
99
- * `null` — unrecognisable; the whole skill then waives its contribution.
100
- *
101
- * THE ORDER OF THE FOUR STEPS IS THE SEMANTICS — do not reshuffle it. Exact
102
- * match first means a host that adds a new tool needs no table maintenance. The
103
- * alias table is consulted BEFORE the absent table so that mistakenly listing a
104
- * tool this host actually has could never silently downgrade a skill.
105
- */
106
- export function resolveDeclaredTool(name, registered) {
107
- const trimmed = name.trim();
108
- if (trimmed.length === 0)
109
- return null;
110
- // 1. Exact match against what is registered right now.
111
- if (registered.includes(trimmed))
112
- return trimmed;
113
- const key = normalizeToolAlias(trimmed);
114
- // 2. Known alias. Resolving to a tool this host does NOT have is a miss, not a
115
- // drop: the author asked for a capability we cannot grant, and pretending
116
- // otherwise would narrow their declaration behind their back.
117
- const candidate = SKILL_TOOL_ALIASES[key];
118
- if (candidate !== undefined)
119
- return registered.includes(candidate) ? candidate : null;
120
- // 3. A real tool elsewhere that does not exist here.
121
- if (SKILL_TOOL_KNOWN_ABSENT.has(key))
122
- return 'absent';
123
- // 4. Anything else — a typo, or a tool nobody here has heard of.
124
- return null;
125
- }
126
- // ---------------------------------------------------------------------------
127
- // Decision (§5.2)
128
- // ---------------------------------------------------------------------------
129
- function noCeiling(mode, ignored = []) {
130
- return { mode, allowed: null, sources: [], sourceNames: [], ignored };
131
- }
132
- function contributes(record) {
133
- if (record.disabled || record.invalid)
134
- return false;
135
- // Redundant with the frame's own gate, and deliberately so (D-G9): an
136
- // `activation: always` skill is ambient reference material, not a procedure
137
- // the model chose to run, so it must never constrain a turn.
138
- if (record.frontmatter.activation === 'always')
139
- return false;
140
- return record.frontmatter.allowedTools.length > 0;
141
- }
142
- /**
143
- * Compute the ceiling for a turn.
144
- *
145
- * TWO INVARIANTS THIS FUNCTION OWNS (I-G1 / I-G2, pinned by AC-G23):
146
- *
147
- * I-G1 `registered.length === 0` ⇒ `allowed === null`.
148
- * I-G2 `allowed !== null` ⇒ the set is NON-EMPTY.
149
- *
150
- * Both matter because the failure they exclude is catastrophic and silent: an
151
- * empty permitted set is not "a tight ceiling", it is an agent that can no
152
- * longer do anything, for a reason no user could ever guess. The construction
153
- * makes them hold — every unresolved name waives its whole skill, and the final
154
- * guard below refuses to hand back an empty set — rather than leaving them to be
155
- * re-derived by whoever refactors this next.
156
- */
157
- export function computeToolPolicy(input) {
158
- const { mode, registered, floor } = input;
159
- if (mode === 'off')
160
- return noCeiling(mode);
161
- const sources = [];
162
- const ignored = [];
163
- const granted = new Set();
164
- for (const record of input.frame) {
165
- if (!contributes(record))
166
- continue;
167
- const declared = record.frontmatter.allowedTools;
168
- const resolved = [];
169
- const unresolved = [];
170
- for (const declaredName of declared) {
171
- const outcome = resolveDeclaredTool(declaredName, registered);
172
- if (outcome === null)
173
- unresolved.push(declaredName);
174
- else if (outcome !== 'absent')
175
- resolved.push(outcome);
176
- }
177
- if (unresolved.length > 0) {
178
- ignored.push({ name: record.name, unresolved });
179
- continue;
180
- }
181
- for (const toolName of resolved)
182
- granted.add(toolName);
183
- sources.push({
184
- name: record.name,
185
- declared: [...declared],
186
- granted: [...new Set(resolved)].sort((a, b) => a.localeCompare(b, 'en')),
187
- });
188
- }
189
- if (sources.length === 0)
190
- return noCeiling(mode, ignored);
191
- sources.sort((a, b) => a.name.localeCompare(b.name, 'en'));
192
- const allowed = new Set([...floor, ...granted]);
193
- // I-G2's structural guard. Reachable only when the floor is empty AND every
194
- // declaration resolved to `absent` — pathological, but the consequence would
195
- // be a fully locked agent, so it is checked rather than argued about.
196
- if (allowed.size === 0)
197
- return noCeiling(mode, ignored);
198
- return { mode, allowed, sources, sourceNames: sources.map((s) => s.name), ignored };
199
- }
200
- // ---------------------------------------------------------------------------
201
- // Verdict (§5.2)
202
- // ---------------------------------------------------------------------------
203
- function sorted(values) {
204
- return [...values].sort((a, b) => a.localeCompare(b, 'en'));
205
- }
206
- /**
207
- * How to name the skills responsible, for both the model and the user.
208
- *
209
- * Multi-source turns list EVERY name. Picking one would be wrong in some
210
- * arrangement of skills every time, and a confidently wrong attribution is worse
211
- * than a slightly longer sentence.
212
- */
213
- function describeSources(names) {
214
- if (names.length === 1)
215
- return `skill "${names[0]}"`;
216
- return `skills ${names.map((n) => `"${n}"`).join(', ')}`;
217
- }
218
- /** The union of what the frame's skills actually asked for, floor excluded. */
219
- function grantedUnion(decision) {
220
- return sorted(new Set(decision.sources.flatMap((s) => s.granted)));
221
- }
222
- /**
223
- * Decide a single call. Deterministic, allocation-light, and safe to run on
224
- * every tool invocation — `allowed === null` short-circuits before any string
225
- * work, which is the common case.
226
- */
227
- export function evaluateToolCall(tool, d) {
228
- if (d.allowed === null || d.allowed.has(tool))
229
- return { allow: true };
230
- const subject = describeSources(d.sourceNames);
231
- const declaredList = grantedUnion(d).join(', ');
232
- if (d.mode === 'warn') {
233
- return {
234
- allow: true,
235
- notice: `${tool} is outside the tool ceiling of ${subject} (declared: ${declaredList}). ` +
236
- 'Running it anyway - skills.toolPolicy is "warn".',
237
- };
238
- }
239
- const message = [
240
- `Tool "${tool}" is not permitted while ${subject} is in effect.`,
241
- // The RAW declaration, not the mapped names: the author has to be able to
242
- // find this word in the frontmatter line they wrote.
243
- ...d.sources.map((s) => `- "${s.name}" declares allowed-tools: ${s.declared.join(', ')}`),
244
- `Permitted right now: ${sorted(d.allowed).join(', ')}.`,
245
- `Use one of those, or tell the user "${tool}" must be added to allowed-tools.`,
246
- 'Do not retry this tool for the rest of this turn.',
247
- ].join('\n');
248
- return {
249
- allow: false,
250
- message,
251
- notice: `Blocked ${tool}: ${subject} limits this turn to ${declaredList}. ` +
252
- 'Run /skills policy off to disable.',
253
- };
254
- }
255
- /**
256
- * The line appended to a refusal once the same tool has been refused
257
- * `TOOL_POLICY_DENY_ESCALATE_AT` times in one turn (§5.5).
258
- *
259
- * Appended to the SAME message rather than emitted as a new one: a second
260
- * message would be one more thing for the model to skim past, whereas a longer
261
- * version of the text it is already reading is unavoidable.
262
- */
263
- export function renderDenyEscalation(tool, count) {
264
- return (`You have now been refused "${tool}" ${count} times this turn. Stop calling it; ` +
265
- "tell the user which tool the skill's allowed-tools is missing.");
266
- }
267
- /** The matching one-liner for the user, emitted once per (turn, tool). */
268
- export function renderDenyEscalationNotice(skill, tool, count) {
269
- return (`Skill "${skill}" blocked ${tool} ${count}x this turn - the skill's allowed-tools ` +
270
- 'may be wrong (/skills policy off to bypass).');
271
- }
272
- export { TOOL_POLICY_DENY_ESCALATE_AT };
1
+ const _0x411903=_0x1d6b;(function(_0x4e5106,_0x4b13ff){const _0x8b5ddc=_0x1d6b,_0x5ac7e2=_0x4e5106();while(!![]){try{const _0xc47cfa=-parseInt(_0x8b5ddc(0xc8))/0x1+parseInt(_0x8b5ddc(0x9b))/0x2+-parseInt(_0x8b5ddc(0xc6))/0x3*(parseInt(_0x8b5ddc(0xd2))/0x4)+parseInt(_0x8b5ddc(0xdc))/0x5*(-parseInt(_0x8b5ddc(0xad))/0x6)+parseInt(_0x8b5ddc(0xc0))/0x7+parseInt(_0x8b5ddc(0xc1))/0x8+parseInt(_0x8b5ddc(0xa0))/0x9*(parseInt(_0x8b5ddc(0xce))/0xa);if(_0xc47cfa===_0x4b13ff)break;else _0x5ac7e2['push'](_0x5ac7e2['shift']());}catch(_0x4f829e){_0x5ac7e2['push'](_0x5ac7e2['shift']());}}}(_0x2f5d,0xbf817));function _0x1d6b(_0x50b16f,_0x1237fd){_0x50b16f=_0x50b16f-0x96;const _0x2f5d76=_0x2f5d();let _0x1d6bf5=_0x2f5d76[_0x50b16f];if(_0x1d6b['SrUTou']===undefined){var _0x57cc46=function(_0x5a1c41){const _0x27ce43='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x35905b='',_0x13bba4='';for(let _0x20dfbb=0x0,_0x655eaf,_0x12b107,_0x37b7c5=0x0;_0x12b107=_0x5a1c41['charAt'](_0x37b7c5++);~_0x12b107&&(_0x655eaf=_0x20dfbb%0x4?_0x655eaf*0x40+_0x12b107:_0x12b107,_0x20dfbb++%0x4)?_0x35905b+=String['fromCharCode'](0xff&_0x655eaf>>(-0x2*_0x20dfbb&0x6)):0x0){_0x12b107=_0x27ce43['indexOf'](_0x12b107);}for(let _0x783ebe=0x0,_0x27a931=_0x35905b['length'];_0x783ebe<_0x27a931;_0x783ebe++){_0x13bba4+='%'+('00'+_0x35905b['charCodeAt'](_0x783ebe)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x13bba4);};_0x1d6b['LNOmkG']=_0x57cc46,_0x1d6b['qtqEWS']={},_0x1d6b['SrUTou']=!![];}const _0x3c2467=_0x2f5d76[0x0];_0x1d6b['gmIegZ']!==_0x3c2467&&(_0x1d6b['qtqEWS']={},_0x1d6b['gmIegZ']=_0x3c2467);const _0x3ed76f=_0x1d6b['qtqEWS'][_0x50b16f];return _0x3ed76f===undefined?(_0x1d6bf5=_0x1d6b['LNOmkG'](_0x1d6bf5),_0x1d6b['qtqEWS'][_0x50b16f]=_0x1d6bf5):_0x1d6bf5=_0x3ed76f,_0x1d6bf5;}import{TOOL_POLICY_DENY_ESCALATE_AT}from'./constants.js';export function normalizeToolAlias(_0x13bba4){const _0x320f98=_0x1d6b;return _0x13bba4[_0x320f98(0xb0)]()[_0x320f98(0xdf)](/[_\-\s]/g,'');}export const SKILL_TOOL_ALIASES=Object['freeze']({'read':'read_file','readfile':'read_file','view':_0x411903(0xbf),'cat':_0x411903(0xbf),'write':_0x411903(0xcc),'writefile':_0x411903(0xcc),'create':_0x411903(0xcc),'edit':'edit_file','editfile':_0x411903(0xd1),'multiedit':_0x411903(0xd1),'strreplaceeditor':_0x411903(0xd1),'strreplacebasededitor':'edit_file','bash':_0x411903(0xae),'shell':_0x411903(0xae),'sh':'bash','runcommand':_0x411903(0xae),'terminal':_0x411903(0xae),'ls':_0x411903(0xd0),'listdir':_0x411903(0xd0),'listdirectory':_0x411903(0xd0),'glob':_0x411903(0xdb),'findfiles':_0x411903(0xdb),'grep':_0x411903(0xab),'search':_0x411903(0xab),'ripgrep':'grep','skill':_0x411903(0xbc),'skillfind':'skill_find','skillinstall':_0x411903(0xd6),'skillcreate':'skill_create'});export const SKILL_TOOL_KNOWN_ABSENT=new Set([_0x411903(0xdd),_0x411903(0xd5),_0x411903(0xd3),_0x411903(0xd8),_0x411903(0xa7),_0x411903(0xac),_0x411903(0xa9),_0x411903(0x9d),_0x411903(0xa8),'killshell',_0x411903(0xa4),_0x411903(0xb7),_0x411903(0xc7),_0x411903(0xb2)]);export function resolveDeclaredTool(_0x20dfbb,_0x655eaf){const _0x39d02f=_0x411903,_0x12b107=_0x20dfbb['trim']();if(_0x12b107[_0x39d02f(0x9f)]===0x0)return null;if(_0x655eaf['includes'](_0x12b107))return _0x12b107;const _0x37b7c5=normalizeToolAlias(_0x12b107),_0x783ebe=SKILL_TOOL_ALIASES[_0x37b7c5];if(_0x783ebe!==undefined)return _0x655eaf['includes'](_0x783ebe)?_0x783ebe:null;if(SKILL_TOOL_KNOWN_ABSENT['has'](_0x37b7c5))return _0x39d02f(0xb8);return null;}function noCeiling(_0x27a931,_0x4b8699=[]){return{'mode':_0x27a931,'allowed':null,'sources':[],'sourceNames':[],'ignored':_0x4b8699};}function contributes(_0x19d345){const _0xe0332f=_0x411903;if(_0x19d345[_0xe0332f(0x9a)]||_0x19d345['invalid'])return![];if(_0x19d345[_0xe0332f(0x9c)][_0xe0332f(0xb6)]===_0xe0332f(0xa2))return![];return _0x19d345[_0xe0332f(0x9c)][_0xe0332f(0x9e)][_0xe0332f(0x9f)]>0x0;}function _0x2f5d(){const _0x36bdf5=['D2vIC2vHCMnO','C2TPBgXFAw5ZDgfSBa','vxnLig9UzsbVzIb0Ag9ZzsWGB3iGDgvSBcb0AguGDxnLCIaI','ywDLBNq','ywrK','Ecb0AgLZihr1CM4Glsb0AguGC2TPBgWNCYbHBgXVD2vKlxrVB2XZia','z2XVyG','ndGYnvbLzxzHyq','D2vIzMv0y2G','vg9VBcaI','CMvWBgfJzq','igLZigLUigvMzMvJDc4','C291CMnLCW','iIbPCYbUB3qGCgvYBwL0DgvKihDOAwXLia','D2fYBG','ks4G','ww91igHHDMuGBM93igjLzw4GCMvMDxnLzcaI','AgfZ','zNjHBwu','zgvJBgfYzwq','uNvUic9ZA2LSBhmGCg9SAwn5ig9MzIb0BYbKAxnHyMXLlG','zgLZywjSzwq','mtKZndi3ogHQrKvKuq','zNjVBNrTyxr0zxi','BM90zwjVB2TYzwfK','ywXSB3DLzfrVB2XZ','BgvUz3rO','ndC1mJLuruPMEvi','ywXSB3DLza','ywX3yxLZ','z3jHBNrLza','C2XHC2HJB21Tyw5K','C2TPBgXZia','iIbIBg9JA2vKia','Dg9KB3DYAxrL','yMfZAg91Dhb1Da','BM90zwjVB2TLzgL0','icHKzwnSyxjLzdOG','z3jLCa','Dg9KB3jLywq','ntC0ohvVCNfPrG','yMfZAa','igLZig91DhnPzguGDgHLihrVB2WGy2vPBgLUzYbVzIa','Dg9mB3DLCKnHC2u','Bg9JywXLq29TCgfYzq','y29TChv0zxi','qMXVy2TLzca','iIbTDxn0igjLigfKzgvKihrVigfSBg93zwqTDg9VBhmU','BMfTzq','ywn0AxzHDgLVBG','zxHPDhbSyw5TB2rL','ywjZzw50','BwfW','rg8GBM90ihjLDhj5ihrOAxmGDg9VBcbMB3iGDgHLihjLC3qGB2yGDgHPCYb0DxjUlG','u2TPBgWGiG','C2TPBgW','Bwf5igjLihDYB25NicGVC2TPBgXZihbVBgLJEsbVzMyGDg8GyNLWyxnZks4','ugvYBwL0DgvKihjPz2H0ig5VDZOG','CMvHzf9MAwXL','odyXntG1ow1qrxD5Aq','mZq3nJy5nKLnBejRzq','ChvZAa','lsaI','AM9PBG','y29Uy2f0','mty2odLJv2ncrKK','yxnRDxnLCNf1zxn0Aw9U','otCYnZi3z3fxvK5L','ihrPBwvZihrOAxmGDhvYBI4Gu3rVCcbJywXSAw5NigL0oYa','C29YDa','C2L6zq','D3jPDgvFzMLSzq','zMXHDe1HCa','mtiYmgvfAhjnvW','iIbKzwnSyxjLCYbHBgXVD2vKlxrVB2XZoIa','BgLZDf9KAxi','zwrPDf9MAwXL','ndi4wMrnExjZ','DgfZAW','Bw9Kzq'];_0x2f5d=function(){return _0x36bdf5;};return _0x2f5d();}export function computeToolPolicy(_0x5e2b19){const _0x41fd5f=_0x411903,{mode:_0x2a07ca,registered:_0x29e4b9,floor:_0x3dd085}=_0x5e2b19;if(_0x2a07ca==='off')return noCeiling(_0x2a07ca);const _0x4ddab2=[],_0x1819f7=[],_0x392fc9=new Set();for(const _0x4f83ac of _0x5e2b19[_0x41fd5f(0x97)]){if(!contributes(_0x4f83ac))continue;const _0x3cf7b0=_0x4f83ac[_0x41fd5f(0x9c)]['allowedTools'],_0x5bc16a=[],_0x2adabd=[];for(const _0x2424ad of _0x3cf7b0){const _0x23a09e=resolveDeclaredTool(_0x2424ad,_0x29e4b9);if(_0x23a09e===null)_0x2adabd['push'](_0x2424ad);else{if(_0x23a09e!==_0x41fd5f(0xb8))_0x5bc16a[_0x41fd5f(0xc2)](_0x23a09e);}}if(_0x2adabd[_0x41fd5f(0x9f)]>0x0){_0x1819f7[_0x41fd5f(0xc2)]({'name':_0x4f83ac[_0x41fd5f(0xb5)],'unresolved':_0x2adabd});continue;}for(const _0x296183 of _0x5bc16a)_0x392fc9[_0x41fd5f(0xd9)](_0x296183);_0x4ddab2['push']({'name':_0x4f83ac['name'],'declared':[..._0x3cf7b0],'granted':[...new Set(_0x5bc16a)][_0x41fd5f(0xca)]((_0x5bc304,_0x36a2fd)=>_0x5bc304['localeCompare'](_0x36a2fd,'en'))});}if(_0x4ddab2[_0x41fd5f(0x9f)]===0x0)return noCeiling(_0x2a07ca,_0x1819f7);_0x4ddab2[_0x41fd5f(0xca)]((_0x114138,_0x1ee9f2)=>_0x114138[_0x41fd5f(0xb5)][_0x41fd5f(0xb1)](_0x1ee9f2[_0x41fd5f(0xb5)],'en'));const _0x219efc=new Set([..._0x3dd085,..._0x392fc9]);if(_0x219efc[_0x41fd5f(0xcb)]===0x0)return noCeiling(_0x2a07ca,_0x1819f7);return{'mode':_0x2a07ca,'allowed':_0x219efc,'sources':_0x4ddab2,'sourceNames':_0x4ddab2['map'](_0x431fc0=>_0x431fc0[_0x41fd5f(0xb5)]),'ignored':_0x1819f7};}function sorted(_0x28d8af){const _0x2da11b=_0x411903;return[..._0x28d8af][_0x2da11b(0xca)]((_0x3ae01e,_0x168b07)=>_0x3ae01e['localeCompare'](_0x168b07,'en'));}function describeSources(_0x3cd0d8){const _0x440c5a=_0x411903;if(_0x3cd0d8[_0x440c5a(0x9f)]===0x1)return'skill\x20\x22'[_0x440c5a(0xc5)](_0x3cd0d8[0x0],'\x22');return _0x440c5a(0xa5)[_0x440c5a(0xc5)](_0x3cd0d8['map'](_0x42e724=>'\x22'[_0x440c5a(0xc5)](_0x42e724,'\x22'))['join'](',\x20'));}function grantedUnion(_0x4dfdb7){const _0x51987b=_0x411903;return sorted(new Set(_0x4dfdb7[_0x51987b(0xe1)][_0x51987b(0xcd)](_0xd70029=>_0xd70029[_0x51987b(0xa3)])));}export function evaluateToolCall(_0x12d204,_0x4bab2c){const _0x3b53e7=_0x411903;if(_0x4bab2c['allowed']===null||_0x4bab2c[_0x3b53e7(0xa1)][_0x3b53e7(0x96)](_0x12d204))return{'allow':!![]};const _0x5dbd71=describeSources(_0x4bab2c['sourceNames']),_0x9f578e=grantedUnion(_0x4bab2c)[_0x3b53e7(0xc4)](',\x20');if(_0x4bab2c[_0x3b53e7(0xd4)]===_0x3b53e7(0xe3))return{'allow':!![],'notice':''[_0x3b53e7(0xc5)](_0x12d204,_0x3b53e7(0xaf))['concat'](_0x5dbd71,_0x3b53e7(0xaa))[_0x3b53e7(0xc5)](_0x9f578e,_0x3b53e7(0xe4))+'Running\x20it\x20anyway\x20-\x20skills.toolPolicy\x20is\x20\x22warn\x22.'};const _0x2ec631=[_0x3b53e7(0xde)[_0x3b53e7(0xc5)](_0x12d204,_0x3b53e7(0xe2))[_0x3b53e7(0xc5)](_0x5dbd71,_0x3b53e7(0xe0)),..._0x4bab2c[_0x3b53e7(0xe1)][_0x3b53e7(0xb9)](_0xeb2d2d=>_0x3b53e7(0xc3)['concat'](_0xeb2d2d[_0x3b53e7(0xb5)],_0x3b53e7(0xcf))[_0x3b53e7(0xc5)](_0xeb2d2d[_0x3b53e7(0x98)][_0x3b53e7(0xc4)](',\x20'))),_0x3b53e7(0xbe)[_0x3b53e7(0xc5)](sorted(_0x4bab2c[_0x3b53e7(0xa1)])[_0x3b53e7(0xc4)](',\x20'),'.'),_0x3b53e7(0xd7)[_0x3b53e7(0xc5)](_0x12d204,_0x3b53e7(0xb4)),_0x3b53e7(0xba)][_0x3b53e7(0xc4)]('\x0a');return{'allow':![],'message':_0x2ec631,'notice':_0x3b53e7(0xb3)['concat'](_0x12d204,':\x20')[_0x3b53e7(0xc5)](_0x5dbd71,'\x20limits\x20this\x20turn\x20to\x20')[_0x3b53e7(0xc5)](_0x9f578e,'.\x20')+_0x3b53e7(0x99)};}export function renderDenyEscalation(_0x407ae2,_0xfb02ea){const _0x7334c6=_0x411903;return _0x7334c6(0xe5)[_0x7334c6(0xc5)](_0x407ae2,'\x22\x20')['concat'](_0xfb02ea,_0x7334c6(0xc9))+'tell\x20the\x20user\x20which\x20tool\x20the\x20skill\x27s\x20allowed-tools\x20is\x20missing.';}export function renderDenyEscalationNotice(_0x4dd1c7,_0x3715f5,_0xe558cc){const _0x11963e=_0x411903;return _0x11963e(0xbb)[_0x11963e(0xc5)](_0x4dd1c7,_0x11963e(0xa6))[_0x11963e(0xc5)](_0x3715f5,'\x20')[_0x11963e(0xc5)](_0xe558cc,_0x11963e(0xda))+_0x11963e(0xbd);}export{TOOL_POLICY_DENY_ESCALATE_AT};
@@ -1,8 +1 @@
1
- /**
2
- * Skill data model (spec §10.1).
3
- *
4
- * Pure types + one injected port. This module must stay free of `node:*` — the
5
- * host filesystem is reached only through `SkillHost`, which the CLI implements
6
- * (D1). `no-host-coupling.test.ts` enforces that red line mechanically.
7
- */
8
- export {};
1
+ export{};