zidane 8.2.1 → 8.2.2

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 (182) hide show
  1. package/dist/acp-cli.js +8 -8
  2. package/dist/{acp-D7Pr8NGt.js → acp-oYRjlh71.js} +6 -6
  3. package/dist/{acp-D7Pr8NGt.js.map → acp-oYRjlh71.js.map} +1 -1
  4. package/dist/acp.d.ts +2 -2
  5. package/dist/acp.js +1 -1
  6. package/dist/{agent-DecDtKA_.js → agent-CBQglXtH.js} +9 -379
  7. package/dist/agent-CBQglXtH.js.map +1 -0
  8. package/dist/agent.d.ts +1 -1
  9. package/dist/agent.js +1 -1
  10. package/dist/{builtin-artifact-kinds-B_OEgf8b.js → builtin-artifact-kinds-BmorPkgz.js} +36 -9
  11. package/dist/builtin-artifact-kinds-BmorPkgz.js.map +1 -0
  12. package/dist/chat/pure.d.ts +3 -3
  13. package/dist/chat/pure.js +4 -4
  14. package/dist/chat.d.ts +4 -4
  15. package/dist/chat.js +14 -14
  16. package/dist/{cli-shared-Dx4vmif6.js → cli-shared-E5m_pI8A.js} +2 -2
  17. package/dist/{cli-shared-Dx4vmif6.js.map → cli-shared-E5m_pI8A.js.map} +1 -1
  18. package/dist/{client-core-imHuBWV3.d.ts → client-core-BdD20sOv.d.ts} +24 -5
  19. package/dist/{client-core-imHuBWV3.d.ts.map → client-core-BdD20sOv.d.ts.map} +1 -1
  20. package/dist/{connection-loop-CdHt3iQi.d.ts → connection-loop-DTk82YVl.d.ts} +3 -3
  21. package/dist/{connection-loop-CdHt3iQi.d.ts.map → connection-loop-DTk82YVl.d.ts.map} +1 -1
  22. package/dist/contexts/daytona.d.ts +1 -1
  23. package/dist/contexts/e2b.d.ts +1 -1
  24. package/dist/{credentials-Dti61yoi.js → credentials-B9DfBJP9.js} +11 -7
  25. package/dist/credentials-B9DfBJP9.js.map +1 -0
  26. package/dist/daemon-cli.js +2 -2
  27. package/dist/{dispatcher-vy3J6JMA.js → dispatcher-BICXFGiJ.js} +27 -13
  28. package/dist/dispatcher-BICXFGiJ.js.map +1 -0
  29. package/dist/{engine-BN6PjWAW.js → engine-QCX3GV-i.js} +5 -5
  30. package/dist/{engine-BN6PjWAW.js.map → engine-QCX3GV-i.js.map} +1 -1
  31. package/dist/{eval-BaJtxLCW.js → eval-CfQlBR81.js} +2 -2
  32. package/dist/{eval-BaJtxLCW.js.map → eval-CfQlBR81.js.map} +1 -1
  33. package/dist/eval.d.ts +1 -1
  34. package/dist/eval.js +1 -1
  35. package/dist/{executor-CT4oUkg6.js → executor-B8GoXaaE.js} +2 -2
  36. package/dist/{executor-CT4oUkg6.js.map → executor-B8GoXaaE.js.map} +1 -1
  37. package/dist/{extensions-BKt7lxxv.js → extensions-BeH3D-bq.js} +114 -113
  38. package/dist/extensions-BeH3D-bq.js.map +1 -0
  39. package/dist/extensions.d.ts +1 -1
  40. package/dist/extensions.js +2 -2
  41. package/dist/{fold-rules-BYedvsH7.d.ts → fold-rules-DSypi36k.d.ts} +2 -2
  42. package/dist/{fold-rules-BYedvsH7.d.ts.map → fold-rules-DSypi36k.d.ts.map} +1 -1
  43. package/dist/google-O6pRnddf.js +881 -0
  44. package/dist/google-O6pRnddf.js.map +1 -0
  45. package/dist/{headless-Ebd1ZEzC.js → headless-R4pbpTkm.js} +3 -3
  46. package/dist/{headless-Ebd1ZEzC.js.map → headless-R4pbpTkm.js.map} +1 -1
  47. package/dist/headless.d.ts +1 -1
  48. package/dist/headless.js +1 -1
  49. package/dist/{host-scoped-settings-Cy_zbmB_.js → host-scoped-settings-CCnaBkCV.js} +2 -2
  50. package/dist/{host-scoped-settings-Cy_zbmB_.js.map → host-scoped-settings-CCnaBkCV.js.map} +1 -1
  51. package/dist/{host-signals-Cx2IAbHh.js → host-signals-DI9JQvR9.js} +5 -5
  52. package/dist/{host-signals-Cx2IAbHh.js.map → host-signals-DI9JQvR9.js.map} +1 -1
  53. package/dist/{index-pc71ADi6.d.ts → index-BkNeiJYI.d.ts} +71 -4
  54. package/dist/index-BkNeiJYI.d.ts.map +1 -0
  55. package/dist/{index-CidMTcxS.d.ts → index-DyQyDLX1.d.ts} +167 -10
  56. package/dist/index-DyQyDLX1.d.ts.map +1 -0
  57. package/dist/{index-Bt_G2Z_2.d.ts → index-lcuvhQfF.d.ts} +5 -5
  58. package/dist/{index-Bt_G2Z_2.d.ts.map → index-lcuvhQfF.d.ts.map} +1 -1
  59. package/dist/index.d.ts +3 -3
  60. package/dist/index.js +15 -15
  61. package/dist/ipc/remote.d.ts +5 -5
  62. package/dist/ipc/remote.js +3 -3
  63. package/dist/ipc.d.ts +5 -5
  64. package/dist/ipc.js +6 -6
  65. package/dist/{links-DSZ4uQ5w.js → links-CN5JFFde.js} +9 -9
  66. package/dist/{links-DSZ4uQ5w.js.map → links-CN5JFFde.js.map} +1 -1
  67. package/dist/mcp.d.ts +1 -1
  68. package/dist/{oauth-BSqXgads.js → oauth-TVPPye84.js} +155 -25
  69. package/dist/oauth-TVPPye84.js.map +1 -0
  70. package/dist/{openai-dTmPxM6T.js → openai-Rh6u5NXF.js} +121 -2
  71. package/dist/openai-Rh6u5NXF.js.map +1 -0
  72. package/dist/{openrouter-CtZbQDa0.js → openrouter-Dg0yaI-o.js} +91 -2
  73. package/dist/openrouter-Dg0yaI-o.js.map +1 -0
  74. package/dist/output/stream-json.d.ts +1 -1
  75. package/dist/output/terminal.d.ts +1 -1
  76. package/dist/plugins.d.ts +1 -1
  77. package/dist/{presets-EzlHyFSi.js → presets-DXeHsd24.js} +3 -3
  78. package/dist/{presets-EzlHyFSi.js.map → presets-DXeHsd24.js.map} +1 -1
  79. package/dist/presets.d.ts +1 -1
  80. package/dist/presets.js +1 -1
  81. package/dist/{prompts-D2lPHLOV.d.ts → prompts-DmY13jvF.d.ts} +2 -1
  82. package/dist/prompts-DmY13jvF.d.ts.map +1 -0
  83. package/dist/protocol-BIv1Yuvl.js.map +1 -1
  84. package/dist/providers/anthropic.d.ts +1 -1
  85. package/dist/providers/arcee.d.ts +1 -1
  86. package/dist/providers/baseten.d.ts +1 -1
  87. package/dist/providers/cerebras.d.ts +1 -1
  88. package/dist/providers/google.d.ts +1 -1
  89. package/dist/providers/google.js +1 -784
  90. package/dist/providers/local.d.ts +1 -1
  91. package/dist/providers/neuralwatt.d.ts +1 -1
  92. package/dist/providers/openai-compat.d.ts +1 -1
  93. package/dist/providers/openai.d.ts +1 -1
  94. package/dist/providers/openai.js +1 -1
  95. package/dist/providers/openrouter.d.ts +1 -1
  96. package/dist/providers/openrouter.js +1 -1
  97. package/dist/providers/xai.d.ts +1 -1
  98. package/dist/providers/xai.js +1 -101
  99. package/dist/providers.d.ts +2 -2
  100. package/dist/providers.js +6 -5
  101. package/dist/{registry-BBaEgTsX.js → registry-PNi9rsGi.js} +3 -3
  102. package/dist/{registry-BBaEgTsX.js.map → registry-PNi9rsGi.js.map} +1 -1
  103. package/dist/{remote-hosts-bO7wOt44.js → remote-hosts-b6Luwdhu.js} +4 -4
  104. package/dist/{remote-hosts-bO7wOt44.js.map → remote-hosts-b6Luwdhu.js.map} +1 -1
  105. package/dist/restate.d.ts +1 -1
  106. package/dist/{secret-shapes-Cda65uDH.js → secret-shapes-CEoGmfEE.js} +10 -1
  107. package/dist/secret-shapes-CEoGmfEE.js.map +1 -0
  108. package/dist/session/sqlite.d.ts +1 -1
  109. package/dist/{session-factory-BazyVdzj.js → session-factory-CMwIXE-7.js} +5 -5
  110. package/dist/{session-factory-BazyVdzj.js.map → session-factory-CMwIXE-7.js.map} +1 -1
  111. package/dist/session.d.ts +1 -1
  112. package/dist/{settings-keys-zYaer8DY.js → settings-keys-DssjmqAV.js} +3 -3
  113. package/dist/{settings-keys-zYaer8DY.js.map → settings-keys-DssjmqAV.js.map} +1 -1
  114. package/dist/{shell-path-od9XHRPt.js → shell-path-BUFwqU_A.js} +3 -3
  115. package/dist/{shell-path-od9XHRPt.js.map → shell-path-BUFwqU_A.js.map} +1 -1
  116. package/dist/{skills-use-D68a1gyZ.js → skills-use-CssTEaIj.js} +375 -2
  117. package/dist/skills-use-CssTEaIj.js.map +1 -0
  118. package/dist/skills.d.ts +1 -1
  119. package/dist/{system-freeze-DXvJpveP.js → system-freeze-Um9ZJiPo.js} +24 -9
  120. package/dist/system-freeze-Um9ZJiPo.js.map +1 -0
  121. package/dist/{todo-edits-CmqNFvLJ.js → todo-edits-H77ROt6X.js} +2 -2
  122. package/dist/{todo-edits-CmqNFvLJ.js.map → todo-edits-H77ROt6X.js.map} +1 -1
  123. package/dist/tools/fetch-url.d.ts +1 -1
  124. package/dist/tools/prompts.d.ts +1 -1
  125. package/dist/tools/prompts.js +7 -0
  126. package/dist/tools/prompts.js.map +1 -1
  127. package/dist/tools/web-search.d.ts +1 -1
  128. package/dist/{tools-9Dpm8F-f.js → tools-pZVFIJ_K.js} +273 -2
  129. package/dist/tools-pZVFIJ_K.js.map +1 -0
  130. package/dist/tools.d.ts +3 -3
  131. package/dist/tools.js +4 -4
  132. package/dist/{transcript-anchors-B3TFJqr_.js → transcript-anchors-s-yxh0jt.js} +10 -10
  133. package/dist/{transcript-anchors-B3TFJqr_.js.map → transcript-anchors-s-yxh0jt.js.map} +1 -1
  134. package/dist/{transcript-reconcile-BC2DbTmp.js → transcript-reconcile-DeFLIQ14.js} +19 -2
  135. package/dist/{transcript-reconcile-BC2DbTmp.js.map → transcript-reconcile-DeFLIQ14.js.map} +1 -1
  136. package/dist/tui.d.ts +7 -7
  137. package/dist/tui.js +24 -22
  138. package/dist/tui.js.map +1 -1
  139. package/dist/{turn-operations-CIFoOebZ.d.ts → turn-operations-BbGJ-KSt.d.ts} +2 -2
  140. package/dist/{turn-operations-CIFoOebZ.d.ts.map → turn-operations-BbGJ-KSt.d.ts.map} +1 -1
  141. package/dist/{types-iFLlZKd0.d.ts → types-C0PJmBaO.d.ts} +2 -2
  142. package/dist/{types-iFLlZKd0.d.ts.map → types-C0PJmBaO.d.ts.map} +1 -1
  143. package/dist/types-JzccL5GE.js +24 -0
  144. package/dist/types-JzccL5GE.js.map +1 -0
  145. package/dist/types.d.ts +2 -2
  146. package/dist/{url-BTH-HE9Y.js → url-CLl0u4Z8.js} +2 -2
  147. package/dist/{url-BTH-HE9Y.js.map → url-CLl0u4Z8.js.map} +1 -1
  148. package/dist/{version-4T82xRxQ.js → version-v77Y4A3C.js} +2 -2
  149. package/dist/{version-4T82xRxQ.js.map → version-v77Y4A3C.js.map} +1 -1
  150. package/dist/wire-DH77Z-rr.js +80 -0
  151. package/dist/wire-DH77Z-rr.js.map +1 -0
  152. package/dist/{workspace-exec-stream-By8na6vz.js → workspace-exec-stream-kqARO8iC.js} +4 -4
  153. package/dist/{workspace-exec-stream-By8na6vz.js.map → workspace-exec-stream-kqARO8iC.js.map} +1 -1
  154. package/dist/{write-file-B4vi3SvQ.js → write-file-QYrcDdl3.js} +3 -3
  155. package/dist/{write-file-B4vi3SvQ.js.map → write-file-QYrcDdl3.js.map} +1 -1
  156. package/dist/{ws-CS312Jpx.js → ws-BD9FN98u.js} +5 -5
  157. package/dist/{ws-CS312Jpx.js.map → ws-BD9FN98u.js.map} +1 -1
  158. package/dist/{ws-client-wWka-Jku.js → ws-client-D7eb2UbH.js} +3 -3
  159. package/dist/{ws-client-wWka-Jku.js.map → ws-client-D7eb2UbH.js.map} +1 -1
  160. package/dist/xai-CStTwCV2.js +182 -0
  161. package/dist/xai-CStTwCV2.js.map +1 -0
  162. package/docs/ARCHITECTURE.md +1 -0
  163. package/docs/ARTIFACTS.md +1 -1
  164. package/docs/EXTENSIONS.md +9 -5
  165. package/package.json +2 -2
  166. package/dist/agent-DecDtKA_.js.map +0 -1
  167. package/dist/builtin-artifact-kinds-B_OEgf8b.js.map +0 -1
  168. package/dist/credentials-Dti61yoi.js.map +0 -1
  169. package/dist/dispatcher-vy3J6JMA.js.map +0 -1
  170. package/dist/extensions-BKt7lxxv.js.map +0 -1
  171. package/dist/index-CidMTcxS.d.ts.map +0 -1
  172. package/dist/index-pc71ADi6.d.ts.map +0 -1
  173. package/dist/oauth-BSqXgads.js.map +0 -1
  174. package/dist/openai-dTmPxM6T.js.map +0 -1
  175. package/dist/openrouter-CtZbQDa0.js.map +0 -1
  176. package/dist/prompts-D2lPHLOV.d.ts.map +0 -1
  177. package/dist/providers/google.js.map +0 -1
  178. package/dist/providers/xai.js.map +0 -1
  179. package/dist/secret-shapes-Cda65uDH.js.map +0 -1
  180. package/dist/skills-use-D68a1gyZ.js.map +0 -1
  181. package/dist/system-freeze-DXvJpveP.js.map +0 -1
  182. package/dist/tools-9Dpm8F-f.js.map +0 -1
@@ -4,6 +4,379 @@ import { t as escapeXml } from "./xml-gcHcz2Yh.js";
4
4
  import { n as stripShellInterpolations, s as validateResourcePathReal, t as interpolateShellCommands } from "./interpolate-DD1y8j36.js";
5
5
  import { t as containsNullByte } from "./binary-detect-Dtj5NGns.js";
6
6
  import { toolPrompts } from "./tools/prompts.js";
7
+ import { Buffer } from "node:buffer";
8
+ import { deflateSync, inflateSync } from "node:zlib";
9
+ //#region src/media/image-size.ts
10
+ /**
11
+ * Pixel dimensions from an image's header bytes: PNG, JPEG, GIF, WebP.
12
+ *
13
+ * Header-only — nothing is decoded, so the cost is constant for PNG / GIF /
14
+ * WebP and a marker walk for JPEG. Used to enforce provider dimension rules
15
+ * (Anthropic's 2000 px per-image cap once a request carries more than 20
16
+ * images) on media the harness cannot re-encode itself.
17
+ */
18
+ /** Dimensions of a PNG / JPEG / GIF / WebP payload, or `undefined` when unknown. */
19
+ function imageSize(bytes) {
20
+ if (bytes.length < 10) return void 0;
21
+ if (bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71) {
22
+ if (bytes.length < 24) return void 0;
23
+ return positive(readU32BE(bytes, 16), readU32BE(bytes, 20));
24
+ }
25
+ if (bytes[0] === 71 && bytes[1] === 73 && bytes[2] === 70) return positive(bytes[6] | bytes[7] << 8, bytes[8] | bytes[9] << 8);
26
+ if (bytes.length >= 30 && bytes[0] === 82 && bytes[1] === 73 && bytes[8] === 87 && bytes[9] === 69) return webpSize(bytes);
27
+ if (bytes[0] === 255 && bytes[1] === 216) return jpegSize(bytes);
28
+ }
29
+ /**
30
+ * {@link imageSize} over a base64 payload. Decodes a bounded prefix first and
31
+ * falls back to the whole payload only for JPEGs whose frame header sits
32
+ * past it (large EXIF / ICC segments).
33
+ */
34
+ function imageSizeFromBase64(b64) {
35
+ const small = imageSize(Buffer.from(b64.slice(0, 44), "base64"));
36
+ if (small) return small;
37
+ const head = Buffer.from(b64.slice(0, 87384), "base64");
38
+ const size = imageSize(head);
39
+ if (size || head.length < 65536 || head[0] !== 255) return size;
40
+ return imageSize(Buffer.from(b64, "base64"));
41
+ }
42
+ function webpSize(b) {
43
+ const chunk = String.fromCharCode(b[12], b[13], b[14], b[15]);
44
+ if (chunk === "VP8X") return positive(1 + (b[24] | b[25] << 8 | b[26] << 16), 1 + (b[27] | b[28] << 8 | b[29] << 16));
45
+ if (chunk === "VP8L") {
46
+ const bits = b[21] | b[22] << 8 | b[23] << 16 | b[24] << 24;
47
+ return positive((bits & 16383) + 1, (bits >>> 14 & 16383) + 1);
48
+ }
49
+ if (chunk === "VP8 ") return positive((b[26] | b[27] << 8) & 16383, (b[28] | b[29] << 8) & 16383);
50
+ }
51
+ function jpegSize(b) {
52
+ let i = 2;
53
+ while (i + 9 < b.length) {
54
+ if (b[i] !== 255) {
55
+ i++;
56
+ continue;
57
+ }
58
+ const marker = b[i + 1];
59
+ if (marker === 255 || marker === 1 || marker >= 208 && marker <= 217) {
60
+ i++;
61
+ continue;
62
+ }
63
+ if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) return positive(b[i + 7] << 8 | b[i + 8], b[i + 5] << 8 | b[i + 6]);
64
+ i += 2 + (b[i + 2] << 8 | b[i + 3]);
65
+ }
66
+ }
67
+ function readU32BE(b, o) {
68
+ return (b[o] << 24 >>> 0) + (b[o + 1] << 16) + (b[o + 2] << 8) + b[o + 3];
69
+ }
70
+ function positive(width, height) {
71
+ return width > 0 && height > 0 ? {
72
+ width,
73
+ height
74
+ } : void 0;
75
+ }
76
+ //#endregion
77
+ //#region src/media/png-downscale.ts
78
+ /**
79
+ * Dependency-free PNG downscaling on `node:zlib`.
80
+ *
81
+ * Retina screenshots (2400×1600, 2960×1840) are the bulk of the oversize
82
+ * images agents read. Past 2000 px they make a request carrying more than 20
83
+ * images fail outright (Anthropic's many-image rule), and they cost upload
84
+ * bytes and first-token latency for detail the model mostly can't use
85
+ * (2576 px max on Claude 4.7+, 1568 px before). Shrinking once,
86
+ * when the image enters the session, keeps the persisted bytes (and therefore
87
+ * the prompt-cache prefix) identical on every later request.
88
+ *
89
+ * Scope is deliberately narrow: non-interlaced 8-bit PNGs (gray, RGB,
90
+ * palette, gray+alpha, RGBA). Anything else returns `undefined` and the
91
+ * caller keeps the original — this module never loses an image.
92
+ */
93
+ /** Refuse to decode beyond this many pixels (~400 MB of RGBA float scratch). */
94
+ const MAX_SOURCE_PIXELS = 25e6;
95
+ const SIGNATURE = Buffer.from([
96
+ 137,
97
+ 80,
98
+ 78,
99
+ 71,
100
+ 13,
101
+ 10,
102
+ 26,
103
+ 10
104
+ ]);
105
+ /**
106
+ * Shrink a base64 image so its longest edge is at most `maxEdge`. Returns the
107
+ * replacement payload, or `undefined` when the image already fits, is not a
108
+ * PNG this module can decode, or anything goes wrong.
109
+ */
110
+ function shrinkImageBase64(data, mediaType, maxEdge) {
111
+ if (!(maxEdge > 0) || mediaType !== "image/png") return void 0;
112
+ const size = imageSizeFromBase64(data);
113
+ if (!size || Math.max(size.width, size.height) <= maxEdge) return void 0;
114
+ const out = downscalePng(Buffer.from(data, "base64"), maxEdge);
115
+ return out ? {
116
+ data: out.toString("base64"),
117
+ mediaType: "image/png"
118
+ } : void 0;
119
+ }
120
+ /** Downscale PNG bytes to fit `maxEdge`; `undefined` when unsupported or already small enough. */
121
+ function downscalePng(bytes, maxEdge) {
122
+ try {
123
+ const src = decodePng(bytes);
124
+ if (!src) return void 0;
125
+ const scale = maxEdge / Math.max(src.width, src.height);
126
+ if (scale >= 1) return void 0;
127
+ const width = Math.max(1, Math.round(src.width * scale));
128
+ const height = Math.max(1, Math.round(src.height * scale));
129
+ return encodePng({
130
+ width,
131
+ height,
132
+ channels: src.channels,
133
+ pixels: resizeArea(src, width, height)
134
+ });
135
+ } catch {
136
+ return;
137
+ }
138
+ }
139
+ function decodePng(bytes) {
140
+ const buf = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
141
+ if (buf.length < 33 || !buf.subarray(0, 8).equals(SIGNATURE)) return void 0;
142
+ let width = 0;
143
+ let height = 0;
144
+ let colorType = -1;
145
+ let palette;
146
+ let trns;
147
+ const idat = [];
148
+ for (let o = 8; o + 8 <= buf.length;) {
149
+ const len = buf.readUInt32BE(o);
150
+ const type = buf.toString("latin1", o + 4, o + 8);
151
+ const body = buf.subarray(o + 8, o + 8 + len);
152
+ if (body.length !== len) return void 0;
153
+ if (type === "IHDR") {
154
+ width = body.readUInt32BE(0);
155
+ height = body.readUInt32BE(4);
156
+ colorType = body[9];
157
+ if (body[8] !== 8 || body[10] !== 0 || body[11] !== 0 || body[12] !== 0) return void 0;
158
+ } else if (type === "PLTE") palette = body;
159
+ else if (type === "tRNS") trns = body;
160
+ else if (type === "IDAT") idat.push(body);
161
+ else if (type === "IEND") break;
162
+ o += 12 + len;
163
+ }
164
+ const srcChannels = {
165
+ 0: 1,
166
+ 2: 3,
167
+ 3: 1,
168
+ 4: 2,
169
+ 6: 4
170
+ }[colorType];
171
+ if (!srcChannels || width === 0 || height === 0 || width * height > MAX_SOURCE_PIXELS || idat.length === 0) return void 0;
172
+ if (trns && colorType !== 3) return void 0;
173
+ if (colorType === 3 && !palette) return void 0;
174
+ const stride = width * srcChannels;
175
+ const raw = inflateSync(Buffer.concat(idat), { maxOutputLength: (stride + 1) * height });
176
+ if (raw.length < (stride + 1) * height) return void 0;
177
+ const rows = unfilter(raw, width, height, srcChannels);
178
+ if (colorType !== 3) return {
179
+ width,
180
+ height,
181
+ channels: srcChannels,
182
+ pixels: rows
183
+ };
184
+ const channels = trns ? 4 : 3;
185
+ const pixels = new Uint8Array(width * height * channels);
186
+ for (let i = 0, p = 0; i < rows.length; i++, p += channels) {
187
+ const idx = rows[i];
188
+ pixels[p] = palette[idx * 3] ?? 0;
189
+ pixels[p + 1] = palette[idx * 3 + 1] ?? 0;
190
+ pixels[p + 2] = palette[idx * 3 + 2] ?? 0;
191
+ if (channels === 4) pixels[p + 3] = idx < trns.length ? trns[idx] : 255;
192
+ }
193
+ return {
194
+ width,
195
+ height,
196
+ channels,
197
+ pixels
198
+ };
199
+ }
200
+ function unfilter(raw, width, height, bpp) {
201
+ const stride = width * bpp;
202
+ const out = new Uint8Array(stride * height);
203
+ for (let y = 0; y < height; y++) {
204
+ const filter = raw[y * (stride + 1)];
205
+ const src = y * (stride + 1) + 1;
206
+ const row = y * stride;
207
+ const prev = row - stride;
208
+ for (let x = 0; x < stride; x++) {
209
+ const a = x >= bpp ? out[row + x - bpp] : 0;
210
+ const b = y > 0 ? out[prev + x] : 0;
211
+ const c = x >= bpp && y > 0 ? out[prev + x - bpp] : 0;
212
+ const v = raw[src + x];
213
+ switch (filter) {
214
+ case 0:
215
+ out[row + x] = v;
216
+ break;
217
+ case 1:
218
+ out[row + x] = v + a;
219
+ break;
220
+ case 2:
221
+ out[row + x] = v + b;
222
+ break;
223
+ case 3:
224
+ out[row + x] = v + (a + b >> 1);
225
+ break;
226
+ case 4:
227
+ out[row + x] = v + paeth(a, b, c);
228
+ break;
229
+ default: throw new Error(`bad PNG filter ${filter}`);
230
+ }
231
+ }
232
+ }
233
+ return out;
234
+ }
235
+ function paeth(a, b, c) {
236
+ const p = a + b - c;
237
+ const pa = Math.abs(p - a);
238
+ const pb = Math.abs(p - b);
239
+ const pc = Math.abs(p - c);
240
+ return pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
241
+ }
242
+ /**
243
+ * Area-average (box) resample: every output pixel is the coverage-weighted
244
+ * mean of the source pixels under it — the standard high-quality downscale.
245
+ * Separable (horizontal then vertical). Color is alpha-weighted so
246
+ * transparent pixels don't bleed their (meaningless) color into edges.
247
+ */
248
+ function resizeArea(src, width, height) {
249
+ const { channels: ch } = src;
250
+ const alpha = ch === 2 || ch === 4 ? ch - 1 : -1;
251
+ const xs = coverage(src.width, width);
252
+ const ys = coverage(src.height, height);
253
+ const mid = new Float32Array(src.height * width * ch);
254
+ for (let y = 0; y < src.height; y++) {
255
+ const srow = y * src.width * ch;
256
+ const mrow = y * width * ch;
257
+ for (let x = 0; x < width; x++) {
258
+ const { start, weights } = xs[x];
259
+ for (let k = 0; k < weights.length; k++) {
260
+ const s = srow + (start + k) * ch;
261
+ const w = weights[k];
262
+ const aw = alpha >= 0 ? w * src.pixels[s + alpha] / 255 : w;
263
+ for (let c = 0; c < ch; c++) mid[mrow + x * ch + c] += (c === alpha ? w : aw) * src.pixels[s + c];
264
+ }
265
+ }
266
+ }
267
+ const out = new Uint8Array(width * height * ch);
268
+ const acc = new Float64Array(ch);
269
+ for (let y = 0; y < height; y++) {
270
+ const { start, weights } = ys[y];
271
+ for (let x = 0; x < width; x++) {
272
+ acc.fill(0);
273
+ for (let k = 0; k < weights.length; k++) {
274
+ const m = ((start + k) * width + x) * ch;
275
+ for (let c = 0; c < ch; c++) acc[c] += weights[k] * mid[m + c];
276
+ }
277
+ const o = (y * width + x) * ch;
278
+ const a = alpha >= 0 ? acc[alpha] : 255;
279
+ for (let c = 0; c < ch; c++) {
280
+ const v = c === alpha ? acc[c] : alpha >= 0 ? a > 0 ? acc[c] * 255 / a : 0 : acc[c];
281
+ out[o + c] = Math.min(255, Math.max(0, Math.round(v)));
282
+ }
283
+ }
284
+ }
285
+ return out;
286
+ }
287
+ /** Per output index: the first source index it covers and normalized weights. */
288
+ function coverage(srcLen, dstLen) {
289
+ const ratio = srcLen / dstLen;
290
+ const result = [];
291
+ for (let i = 0; i < dstLen; i++) {
292
+ const lo = i * ratio;
293
+ const hi = Math.min(srcLen, (i + 1) * ratio);
294
+ const start = Math.floor(lo);
295
+ const end = Math.ceil(hi);
296
+ const weights = new Float32Array(end - start);
297
+ for (let s = start; s < end; s++) weights[s - start] = (Math.min(hi, s + 1) - Math.max(lo, s)) / ratio;
298
+ result.push({
299
+ start,
300
+ weights
301
+ });
302
+ }
303
+ return result;
304
+ }
305
+ function encodePng(img) {
306
+ const { width, height, channels: ch, pixels } = img;
307
+ const colorType = {
308
+ 1: 0,
309
+ 2: 4,
310
+ 3: 2,
311
+ 4: 6
312
+ }[ch];
313
+ const stride = width * ch;
314
+ const filtered = Buffer.alloc((stride + 1) * height);
315
+ const candidate = Buffer.alloc(stride);
316
+ for (let y = 0; y < height; y++) {
317
+ const row = y * stride;
318
+ let best = Number.POSITIVE_INFINITY;
319
+ let bestFilter = 0;
320
+ let bestBytes = Buffer.alloc(0);
321
+ for (let f = 0; f < 5; f++) {
322
+ let score = 0;
323
+ for (let x = 0; x < stride; x++) {
324
+ const a = x >= ch ? pixels[row + x - ch] : 0;
325
+ const b = y > 0 ? pixels[row - stride + x] : 0;
326
+ const c = x >= ch && y > 0 ? pixels[row - stride + x - ch] : 0;
327
+ const v = pixels[row + x];
328
+ const r = (f === 0 ? v : f === 1 ? v - a : f === 2 ? v - b : f === 3 ? v - (a + b >> 1) : v - paeth(a, b, c)) & 255;
329
+ candidate[x] = r;
330
+ score += r < 128 ? r : 256 - r;
331
+ }
332
+ if (score < best) {
333
+ best = score;
334
+ bestFilter = f;
335
+ bestBytes = Buffer.from(candidate);
336
+ }
337
+ }
338
+ filtered[y * (stride + 1)] = bestFilter;
339
+ bestBytes.copy(filtered, y * (stride + 1) + 1);
340
+ }
341
+ const ihdr = Buffer.alloc(13);
342
+ ihdr.writeUInt32BE(width, 0);
343
+ ihdr.writeUInt32BE(height, 4);
344
+ ihdr[8] = 8;
345
+ ihdr[9] = colorType;
346
+ return Buffer.concat([
347
+ SIGNATURE,
348
+ chunk("IHDR", ihdr),
349
+ chunk("IDAT", deflateSync(filtered)),
350
+ chunk("IEND", Buffer.alloc(0))
351
+ ]);
352
+ }
353
+ function chunk(type, body) {
354
+ const head = Buffer.alloc(8);
355
+ head.writeUInt32BE(body.length, 0);
356
+ head.write(type, 4, "latin1");
357
+ const crc = Buffer.alloc(4);
358
+ crc.writeUInt32BE(crc32(Buffer.concat([head.subarray(4), body])), 0);
359
+ return Buffer.concat([
360
+ head,
361
+ body,
362
+ crc
363
+ ]);
364
+ }
365
+ let crcTable;
366
+ function crc32(bytes) {
367
+ if (!crcTable) {
368
+ crcTable = /* @__PURE__ */ new Uint32Array(256);
369
+ for (let n = 0; n < 256; n++) {
370
+ let c = n;
371
+ for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
372
+ crcTable[n] = c >>> 0;
373
+ }
374
+ }
375
+ let c = 4294967295;
376
+ for (let i = 0; i < bytes.length; i++) c = crcTable[(c ^ bytes[i]) & 255] ^ c >>> 8;
377
+ return (c ^ 4294967295) >>> 0;
378
+ }
379
+ //#endregion
7
380
  //#region src/tools/tool-search.ts
8
381
  const DEFAULT_LIMIT = 20;
9
382
  function rankByQuery(catalog, query) {
@@ -419,6 +792,6 @@ function createSkillsUseTool(options) {
419
792
  };
420
793
  }
421
794
  //#endregion
422
- export { createToolSearchTool as a, applyToolSearchToUnlocked as i, createSkillsRunScriptTool as n, selectToolSearchMatches as o, createSkillsReadTool as r, createSkillsUseTool as t };
795
+ export { createToolSearchTool as a, imageSizeFromBase64 as c, applyToolSearchToUnlocked as i, createSkillsRunScriptTool as n, selectToolSearchMatches as o, createSkillsReadTool as r, shrinkImageBase64 as s, createSkillsUseTool as t };
423
796
 
424
- //# sourceMappingURL=skills-use-D68a1gyZ.js.map
797
+ //# sourceMappingURL=skills-use-CssTEaIj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills-use-CssTEaIj.js","names":[],"sources":["../src/media/image-size.ts","../src/media/png-downscale.ts","../src/tools/tool-search.ts","../src/tools/skills-read.ts","../src/tools/skills-run-script.ts","../src/tools/skills-use.ts"],"sourcesContent":["/**\n * Pixel dimensions from an image's header bytes: PNG, JPEG, GIF, WebP.\n *\n * Header-only — nothing is decoded, so the cost is constant for PNG / GIF /\n * WebP and a marker walk for JPEG. Used to enforce provider dimension rules\n * (Anthropic's 2000 px per-image cap once a request carries more than 20\n * images) on media the harness cannot re-encode itself.\n */\n\nimport { Buffer } from 'node:buffer'\n\nexport interface ImageSize {\n width: number\n height: number\n}\n\n/** Dimensions of a PNG / JPEG / GIF / WebP payload, or `undefined` when unknown. */\nexport function imageSize(bytes: Uint8Array): ImageSize | undefined {\n if (bytes.length < 10)\n return undefined\n // PNG: signature, then the IHDR chunk (width/height big-endian at 16/20).\n if (bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4E && bytes[3] === 0x47) {\n if (bytes.length < 24)\n return undefined\n return positive(readU32BE(bytes, 16), readU32BE(bytes, 20))\n }\n // GIF: logical screen size, little-endian at 6/8.\n if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46)\n return positive(bytes[6]! | (bytes[7]! << 8), bytes[8]! | (bytes[9]! << 8))\n // WebP: RIFF container; the first chunk says which bitstream follows.\n if (bytes.length >= 30 && bytes[0] === 0x52 && bytes[1] === 0x49 && bytes[8] === 0x57 && bytes[9] === 0x45)\n return webpSize(bytes)\n if (bytes[0] === 0xFF && bytes[1] === 0xD8)\n return jpegSize(bytes)\n return undefined\n}\n\n/**\n * {@link imageSize} over a base64 payload. Decodes a bounded prefix first and\n * falls back to the whole payload only for JPEGs whose frame header sits\n * past it (large EXIF / ICC segments).\n */\nexport function imageSizeFromBase64(b64: string): ImageSize | undefined {\n // PNG / GIF / WebP fit in the first 32 bytes; this runs per image per\n // request, so only JPEG pays for a larger decode.\n const small = imageSize(Buffer.from(b64.slice(0, 44), 'base64'))\n if (small)\n return small\n const head = Buffer.from(b64.slice(0, 87_384), 'base64')\n const size = imageSize(head)\n if (size || head.length < 65_536 || head[0] !== 0xFF)\n return size\n return imageSize(Buffer.from(b64, 'base64'))\n}\n\nfunction webpSize(b: Uint8Array): ImageSize | undefined {\n const chunk = String.fromCharCode(b[12]!, b[13]!, b[14]!, b[15]!)\n if (chunk === 'VP8X')\n return positive(1 + (b[24]! | (b[25]! << 8) | (b[26]! << 16)), 1 + (b[27]! | (b[28]! << 8) | (b[29]! << 16)))\n if (chunk === 'VP8L') {\n const bits = b[21]! | (b[22]! << 8) | (b[23]! << 16) | (b[24]! << 24)\n return positive((bits & 0x3FFF) + 1, ((bits >>> 14) & 0x3FFF) + 1)\n }\n if (chunk === 'VP8 ')\n return positive((b[26]! | (b[27]! << 8)) & 0x3FFF, (b[28]! | (b[29]! << 8)) & 0x3FFF)\n return undefined\n}\n\nfunction jpegSize(b: Uint8Array): ImageSize | undefined {\n let i = 2\n while (i + 9 < b.length) {\n if (b[i] !== 0xFF) {\n i++\n continue\n }\n const marker = b[i + 1]!\n // Fill bytes and standalone markers carry no length.\n if (marker === 0xFF || marker === 0x01 || (marker >= 0xD0 && marker <= 0xD9)) {\n i++\n continue\n }\n // SOF0–SOF15 except DHT (C4), JPG (C8) and DAC (CC): height then width.\n if (marker >= 0xC0 && marker <= 0xCF && marker !== 0xC4 && marker !== 0xC8 && marker !== 0xCC)\n return positive((b[i + 7]! << 8) | b[i + 8]!, (b[i + 5]! << 8) | b[i + 6]!)\n i += 2 + ((b[i + 2]! << 8) | b[i + 3]!)\n }\n return undefined\n}\n\nfunction readU32BE(b: Uint8Array, o: number): number {\n return ((b[o]! << 24) >>> 0) + (b[o + 1]! << 16) + (b[o + 2]! << 8) + b[o + 3]!\n}\n\nfunction positive(width: number, height: number): ImageSize | undefined {\n return width > 0 && height > 0 ? { width, height } : undefined\n}\n","/**\n * Dependency-free PNG downscaling on `node:zlib`.\n *\n * Retina screenshots (2400×1600, 2960×1840) are the bulk of the oversize\n * images agents read. Past 2000 px they make a request carrying more than 20\n * images fail outright (Anthropic's many-image rule), and they cost upload\n * bytes and first-token latency for detail the model mostly can't use\n * (2576 px max on Claude 4.7+, 1568 px before). Shrinking once,\n * when the image enters the session, keeps the persisted bytes (and therefore\n * the prompt-cache prefix) identical on every later request.\n *\n * Scope is deliberately narrow: non-interlaced 8-bit PNGs (gray, RGB,\n * palette, gray+alpha, RGBA). Anything else returns `undefined` and the\n * caller keeps the original — this module never loses an image.\n */\n\nimport { Buffer } from 'node:buffer'\nimport { deflateSync, inflateSync } from 'node:zlib'\nimport { imageSizeFromBase64 } from './image-size'\n\n/** Refuse to decode beyond this many pixels (~400 MB of RGBA float scratch). */\nconst MAX_SOURCE_PIXELS = 25_000_000\n\nconst SIGNATURE = Buffer.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])\n\ninterface DecodedPng {\n width: number\n height: number\n /** 1 gray, 2 gray+alpha, 3 RGB, 4 RGBA. */\n channels: number\n pixels: Uint8Array\n}\n\n/**\n * Shrink a base64 image so its longest edge is at most `maxEdge`. Returns the\n * replacement payload, or `undefined` when the image already fits, is not a\n * PNG this module can decode, or anything goes wrong.\n */\nexport function shrinkImageBase64(\n data: string,\n mediaType: string,\n maxEdge: number,\n): { data: string, mediaType: string } | undefined {\n if (!(maxEdge > 0) || mediaType !== 'image/png')\n return undefined\n const size = imageSizeFromBase64(data)\n if (!size || Math.max(size.width, size.height) <= maxEdge)\n return undefined\n const out = downscalePng(Buffer.from(data, 'base64'), maxEdge)\n return out ? { data: out.toString('base64'), mediaType: 'image/png' } : undefined\n}\n\n/** Downscale PNG bytes to fit `maxEdge`; `undefined` when unsupported or already small enough. */\nexport function downscalePng(bytes: Uint8Array, maxEdge: number): Buffer | undefined {\n try {\n const src = decodePng(bytes)\n if (!src)\n return undefined\n const scale = maxEdge / Math.max(src.width, src.height)\n if (scale >= 1)\n return undefined\n const width = Math.max(1, Math.round(src.width * scale))\n const height = Math.max(1, Math.round(src.height * scale))\n return encodePng({ width, height, channels: src.channels, pixels: resizeArea(src, width, height) })\n }\n catch {\n return undefined\n }\n}\n\nexport function decodePng(bytes: Uint8Array): DecodedPng | undefined {\n const buf = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)\n if (buf.length < 33 || !buf.subarray(0, 8).equals(SIGNATURE))\n return undefined\n let width = 0\n let height = 0\n let colorType = -1\n let palette: Buffer | undefined\n let trns: Buffer | undefined\n const idat: Buffer[] = []\n for (let o = 8; o + 8 <= buf.length;) {\n const len = buf.readUInt32BE(o)\n const type = buf.toString('latin1', o + 4, o + 8)\n const body = buf.subarray(o + 8, o + 8 + len)\n if (body.length !== len)\n return undefined\n if (type === 'IHDR') {\n width = body.readUInt32BE(0)\n height = body.readUInt32BE(4)\n colorType = body[9]!\n // 8-bit depth, deflate, standard filtering, no interlace only.\n if (body[8] !== 8 || body[10] !== 0 || body[11] !== 0 || body[12] !== 0)\n return undefined\n }\n else if (type === 'PLTE') { palette = body }\n else if (type === 'tRNS') { trns = body }\n else if (type === 'IDAT') { idat.push(body) }\n else if (type === 'IEND') { break }\n o += 12 + len\n }\n const srcChannels = ({ 0: 1, 2: 3, 3: 1, 4: 2, 6: 4 } as Record<number, number>)[colorType]\n if (!srcChannels || width === 0 || height === 0 || width * height > MAX_SOURCE_PIXELS || idat.length === 0)\n return undefined\n // A single transparent color key on gray/RGB would be lost by averaging.\n if (trns && colorType !== 3)\n return undefined\n if (colorType === 3 && !palette)\n return undefined\n\n const stride = width * srcChannels\n // Cap the inflate at the size IHDR implies: a tiny crafted IDAT could\n // otherwise expand to gigabytes before the length check below. Overflow throws.\n const raw = inflateSync(Buffer.concat(idat), { maxOutputLength: (stride + 1) * height })\n if (raw.length < (stride + 1) * height)\n return undefined\n const rows = unfilter(raw, width, height, srcChannels)\n\n if (colorType !== 3)\n return { width, height, channels: srcChannels, pixels: rows }\n // Expand palette indices to RGB, or RGBA when the palette carries alpha.\n const channels = trns ? 4 : 3\n const pixels = new Uint8Array(width * height * channels)\n for (let i = 0, p = 0; i < rows.length; i++, p += channels) {\n const idx = rows[i]!\n pixels[p] = palette![idx * 3] ?? 0\n pixels[p + 1] = palette![idx * 3 + 1] ?? 0\n pixels[p + 2] = palette![idx * 3 + 2] ?? 0\n if (channels === 4)\n pixels[p + 3] = idx < trns!.length ? trns![idx]! : 255\n }\n return { width, height, channels, pixels }\n}\n\nfunction unfilter(raw: Uint8Array, width: number, height: number, bpp: number): Uint8Array {\n const stride = width * bpp\n const out = new Uint8Array(stride * height)\n for (let y = 0; y < height; y++) {\n const filter = raw[y * (stride + 1)]!\n const src = y * (stride + 1) + 1\n const row = y * stride\n const prev = row - stride\n for (let x = 0; x < stride; x++) {\n const a = x >= bpp ? out[row + x - bpp]! : 0\n const b = y > 0 ? out[prev + x]! : 0\n const c = x >= bpp && y > 0 ? out[prev + x - bpp]! : 0\n const v = raw[src + x]!\n switch (filter) {\n case 0: out[row + x] = v; break\n case 1: out[row + x] = v + a; break\n case 2: out[row + x] = v + b; break\n case 3: out[row + x] = v + ((a + b) >> 1); break\n case 4: out[row + x] = v + paeth(a, b, c); break\n default: throw new Error(`bad PNG filter ${filter}`)\n }\n }\n }\n return out\n}\n\nfunction paeth(a: number, b: number, c: number): number {\n const p = a + b - c\n const pa = Math.abs(p - a)\n const pb = Math.abs(p - b)\n const pc = Math.abs(p - c)\n return pa <= pb && pa <= pc ? a : pb <= pc ? b : c\n}\n\n/**\n * Area-average (box) resample: every output pixel is the coverage-weighted\n * mean of the source pixels under it — the standard high-quality downscale.\n * Separable (horizontal then vertical). Color is alpha-weighted so\n * transparent pixels don't bleed their (meaningless) color into edges.\n */\nfunction resizeArea(src: DecodedPng, width: number, height: number): Uint8Array {\n const { channels: ch } = src\n const alpha = ch === 2 || ch === 4 ? ch - 1 : -1\n const xs = coverage(src.width, width)\n const ys = coverage(src.height, height)\n\n // Pass 1: rows → width columns, alpha-premultiplied floats.\n const mid = new Float32Array(src.height * width * ch)\n for (let y = 0; y < src.height; y++) {\n const srow = y * src.width * ch\n const mrow = y * width * ch\n for (let x = 0; x < width; x++) {\n const { start, weights } = xs[x]!\n for (let k = 0; k < weights.length; k++) {\n const s = srow + (start + k) * ch\n const w = weights[k]!\n const aw = alpha >= 0 ? w * src.pixels[s + alpha]! / 255 : w\n for (let c = 0; c < ch; c++)\n mid[mrow + x * ch + c]! += (c === alpha ? w : aw) * src.pixels[s + c]!\n }\n }\n }\n\n // Pass 2: columns → height rows, then un-premultiply.\n const out = new Uint8Array(width * height * ch)\n const acc = new Float64Array(ch)\n for (let y = 0; y < height; y++) {\n const { start, weights } = ys[y]!\n for (let x = 0; x < width; x++) {\n acc.fill(0)\n for (let k = 0; k < weights.length; k++) {\n const m = ((start + k) * width + x) * ch\n for (let c = 0; c < ch; c++)\n acc[c]! += weights[k]! * mid[m + c]!\n }\n const o = (y * width + x) * ch\n const a = alpha >= 0 ? acc[alpha]! : 255\n for (let c = 0; c < ch; c++) {\n const v = c === alpha ? acc[c]! : alpha >= 0 ? (a > 0 ? acc[c]! * 255 / a : 0) : acc[c]!\n out[o + c] = Math.min(255, Math.max(0, Math.round(v)))\n }\n }\n }\n return out\n}\n\n/** Per output index: the first source index it covers and normalized weights. */\nfunction coverage(srcLen: number, dstLen: number): Array<{ start: number, weights: Float32Array }> {\n const ratio = srcLen / dstLen\n const result: Array<{ start: number, weights: Float32Array }> = []\n for (let i = 0; i < dstLen; i++) {\n const lo = i * ratio\n const hi = Math.min(srcLen, (i + 1) * ratio)\n const start = Math.floor(lo)\n const end = Math.ceil(hi)\n const weights = new Float32Array(end - start)\n for (let s = start; s < end; s++)\n weights[s - start] = (Math.min(hi, s + 1) - Math.max(lo, s)) / ratio\n result.push({ start, weights })\n }\n return result\n}\n\nexport function encodePng(img: DecodedPng): Buffer {\n const { width, height, channels: ch, pixels } = img\n const colorType = ({ 1: 0, 2: 4, 3: 2, 4: 6 } as Record<number, number>)[ch]!\n const stride = width * ch\n const filtered = Buffer.alloc((stride + 1) * height)\n const candidate = Buffer.alloc(stride)\n // Per-row adaptive filter: keep whichever of the five minimizes the sum of\n // absolute signed residuals (libpng's default heuristic).\n for (let y = 0; y < height; y++) {\n const row = y * stride\n let best = Number.POSITIVE_INFINITY\n let bestFilter = 0\n let bestBytes = Buffer.alloc(0)\n for (let f = 0; f < 5; f++) {\n let score = 0\n for (let x = 0; x < stride; x++) {\n const a = x >= ch ? pixels[row + x - ch]! : 0\n const b = y > 0 ? pixels[row - stride + x]! : 0\n const c = x >= ch && y > 0 ? pixels[row - stride + x - ch]! : 0\n const v = pixels[row + x]!\n const r = (f === 0 ? v : f === 1 ? v - a : f === 2 ? v - b : f === 3 ? v - ((a + b) >> 1) : v - paeth(a, b, c)) & 0xFF\n candidate[x] = r\n score += r < 128 ? r : 256 - r\n }\n if (score < best) {\n best = score\n bestFilter = f\n bestBytes = Buffer.from(candidate)\n }\n }\n filtered[y * (stride + 1)] = bestFilter\n bestBytes.copy(filtered, y * (stride + 1) + 1)\n }\n const ihdr = Buffer.alloc(13)\n ihdr.writeUInt32BE(width, 0)\n ihdr.writeUInt32BE(height, 4)\n ihdr[8] = 8\n ihdr[9] = colorType\n return Buffer.concat([\n SIGNATURE,\n chunk('IHDR', ihdr),\n chunk('IDAT', deflateSync(filtered)),\n chunk('IEND', Buffer.alloc(0)),\n ])\n}\n\nfunction chunk(type: string, body: Buffer): Buffer {\n const head = Buffer.alloc(8)\n head.writeUInt32BE(body.length, 0)\n head.write(type, 4, 'latin1')\n const crc = Buffer.alloc(4)\n crc.writeUInt32BE(crc32(Buffer.concat([head.subarray(4), body])), 0)\n return Buffer.concat([head, body, crc])\n}\n\nlet crcTable: Uint32Array | undefined\nfunction crc32(bytes: Uint8Array): number {\n if (!crcTable) {\n crcTable = new Uint32Array(256)\n for (let n = 0; n < 256; n++) {\n let c = n\n for (let k = 0; k < 8; k++)\n c = c & 1 ? 0xEDB88320 ^ (c >>> 1) : c >>> 1\n crcTable[n] = c >>> 0\n }\n }\n let c = 0xFFFFFFFF\n for (let i = 0; i < bytes.length; i++)\n c = crcTable[(c ^ bytes[i]!) & 0xFF]! ^ (c >>> 8)\n return (c ^ 0xFFFFFFFF) >>> 0\n}\n","/**\n * `tool_search` — progressive tool disclosure.\n *\n * Counterpart to `skills_use` for the MCP tool surface: the catalog (name +\n * description) lives in the system prompt; full `inputSchema` payloads load\n * lazily through this tool. After a successful match, the matched tools'\n * canonical names are added to the per-run \"unlocked\" set and become callable\n * immediately (the loop rebuilds `formattedTools` before the next provider\n * request, advertising the unlocked tools to the provider).\n *\n * Aliasing: the tool advertises and matches on the **wire** (alias-rewritten)\n * name — the only name the model ever sees. Internally each lazy entry also\n * carries its `canonicalName`, which is what gets added to the `unlocked` set\n * (the loop's tool registry is keyed by canonical name).\n *\n * Result shape: structured pseudo-XML wrapping a JSON `inputSchema` payload.\n * The schema is inlined verbatim (NOT XML-escaped) so the model can reuse it\n * directly when constructing arguments — escaping the JSON would force the\n * model to mentally un-escape `&quot;` etc. when reasoning about field types.\n */\n\nimport type { ToolContext, ToolDef } from './types'\nimport { escapeXml } from '../xml'\nimport { toolPrompts } from './prompts'\n\n/** A tool the model can discover through `tool_search` and unlock on demand. */\nexport interface LazyToolEntry {\n /**\n * Wire name (after `toolAliases` rewrite). What the model sees in the\n * catalog, what `tool_search` matches against, and what the provider's\n * tool list will carry once the entry is unlocked.\n */\n name: string\n /**\n * Canonical (registry-key) name used for unlock-set membership and for the\n * loop's `ctx.tools[name]` dispatch lookup. Equal to `name` when no alias\n * is configured for this tool.\n */\n canonicalName: string\n /** Tool description matched by the search. */\n description: string\n /** JSON Schema of the tool input, returned inline when the tool is unlocked. */\n inputSchema: Record<string, unknown>\n /** Source MCP server, when applicable. Used for `server`-bulk unlock. */\n server?: string\n}\n\n/** Options for {@link createToolSearchTool}. */\nexport interface ToolSearchToolOptions {\n /**\n * Snapshot of every lazy tool the model can discover. Built once per run by\n * the agent — the tool closes over this array and never mutates it.\n */\n catalog: readonly LazyToolEntry[]\n /**\n * Mutable per-run set of unlocked **canonical** tool names. The tool adds\n * matches in place; the loop reads the set when rebuilding the wire-level\n * tool list. Keyed by canonical (not wire) so dispatch lookups stay\n * alias-stable.\n *\n * Prefer `addUnlock` for cache-stable wire-tool ordering: writes through a\n * Set lose unlock order, so the wire-level rebuild that filters by `unlocked`\n * has to fall back to registry iteration order — which moves entries every\n * time a lazy tool earlier in the registry is unlocked, breaking provider\n * prompt-cache breakpoints. The agent passes both when it owns the unlock\n * tracker, with `addUnlock` mirroring writes into an ordered log.\n */\n unlocked: Set<string>\n /**\n * Optional callback fired for every canonical name the tool unlocks. When\n * set, the agent uses this to maintain an append-only `dynamicUnlockOrder`\n * so the wire-level tool list emits new unlocks at the tail and keeps the\n * provider prefix cache warm. Idempotent on repeat unlocks of the same\n * name — callers may dedupe internally.\n *\n * Invoked **in addition to** the `unlocked.add` (which still happens, for\n * callers that only watch the Set).\n */\n addUnlock?: (canonical: string) => void\n /** Default cap on returned matches when the model omits `limit`. */\n defaultLimit?: number\n /**\n * Dispatch mode (`toolSearch.mode: 'dispatch'`): surfaced tools are NOT\n * appended to the wire tools array; the model invokes them through this\n * envelope tool. The description and result footer say so — without it the\n * model would emit a direct `tool_use` the provider has never been told\n * about.\n */\n dispatcherName?: string\n}\n\nconst DEFAULT_LIMIT = 20\n\nfunction rankByQuery(catalog: readonly LazyToolEntry[], query: string): LazyToolEntry[] {\n const q = query.trim().toLowerCase()\n if (!q)\n return [...catalog]\n\n // Two-tier ranking: name hits beat description hits. Within each tier we\n // preserve registration order so deterministic catalogs produce\n // deterministic results.\n const nameHits: LazyToolEntry[] = []\n const descHits: LazyToolEntry[] = []\n for (const entry of catalog) {\n if (entry.name.toLowerCase().includes(q))\n nameHits.push(entry)\n else if (entry.description.toLowerCase().includes(q))\n descHits.push(entry)\n }\n return [...nameHits, ...descHits]\n}\n\n/**\n * Sanitise a JSON-stringified schema for embedding inside a pseudo-XML tag.\n *\n * The schema is inlined verbatim (NOT XML-escaped) so the model can reuse\n * field types directly when constructing arguments. The only transformation\n * we apply is replacing `<` with `\\u003c` inside string literals — this\n * keeps the JSON byte-equivalent for the model (JSON parsers decode the\n * escape) while preventing a hostile or buggy `inputSchema` from injecting\n * apparent XML tags (`</input_schema>`, `<evil>…`) that would muddle the\n * model's read of the surrounding result envelope.\n *\n * The substitution is safe because `<` is only meaningful when it appears\n * literally; the `\\u003c` form is not a tag character and is identical to\n * `<` after JSON parsing.\n */\nfunction sanitiseSchemaForXml(schemaJson: string): string {\n return schemaJson.replace(/</g, '\\\\u003c')\n}\n\nfunction formatMatch(entry: LazyToolEntry): string {\n const schema = sanitiseSchemaForXml(JSON.stringify(entry.inputSchema))\n const serverAttr = entry.server ? ` server=\"${escapeXml(entry.server)}\"` : ''\n return [\n ` <tool name=\"${escapeXml(entry.name)}\"${serverAttr}>`,\n ` <description>${escapeXml(entry.description)}</description>`,\n ` <input_schema>${schema}</input_schema>`,\n ` </tool>`,\n ].join('\\n')\n}\n\ninterface SelectionResult {\n /** Matches kept after the `limit` cap. */\n shown: LazyToolEntry[]\n /** Number of matches before the cap. */\n total: number\n /** Whether the cap dropped some matches. */\n truncated: boolean\n /** Requested `names` that are not in the catalog. */\n misses: string[]\n /** The trimmed `query`, if one was given. */\n query: string | undefined\n /** The `server` filter, if one was given. */\n server: string | undefined\n}\n\n/**\n * Pure resolver for a `tool_search` invocation. Mirrors the matching the\n * execute path performs (`names` → `server` → `query` → unconstrained fallback,\n * then cap by `limit`). Extracted so the unlock side-effect can be replayed\n * deterministically when a session is resumed — `run()` walks the persisted\n * `tool_search` tool_calls and feeds each historical input through here to\n * rebuild the `unlocked` set seeded by prior runs.\n *\n * Returns the entries the original call would have shown (post-limit), not the\n * full pre-cap match set — the cap is part of what the model actually saw.\n */\nexport function selectToolSearchMatches(\n catalog: readonly LazyToolEntry[],\n input: Record<string, unknown>,\n defaultLimit: number = DEFAULT_LIMIT,\n): SelectionResult {\n const byName = new Map(catalog.map(e => [e.name, e]))\n const byServer = new Map<string, LazyToolEntry[]>()\n for (const entry of catalog) {\n if (!entry.server)\n continue\n const list = byServer.get(entry.server) ?? []\n list.push(entry)\n byServer.set(entry.server, list)\n }\n const maxLimit = Math.max(catalog.length, 1)\n\n const rawQuery = typeof input.query === 'string' ? input.query.trim() : undefined\n const query = rawQuery || undefined\n const namesIn = Array.isArray(input.names)\n ? input.names.filter((n): n is string => typeof n === 'string' && n.length > 0)\n : undefined\n const server = typeof input.server === 'string' && input.server.length > 0 ? input.server : undefined\n const limitIn = typeof input.limit === 'number' && Number.isFinite(input.limit) && input.limit > 0\n ? Math.floor(input.limit as number)\n : defaultLimit\n const limit = Math.min(limitIn, maxLimit)\n\n const matches: LazyToolEntry[] = []\n const seen = new Set<string>()\n const misses: string[] = []\n\n if (namesIn && namesIn.length > 0) {\n for (const n of namesIn) {\n if (seen.has(n))\n continue\n const entry = byName.get(n)\n if (entry) {\n matches.push(entry)\n seen.add(n)\n }\n else {\n misses.push(n)\n }\n }\n }\n\n if (server) {\n const list = byServer.get(server) ?? []\n for (const entry of list) {\n if (seen.has(entry.name))\n continue\n matches.push(entry)\n seen.add(entry.name)\n }\n }\n\n if (query !== undefined) {\n for (const entry of rankByQuery(catalog, query)) {\n if (seen.has(entry.name))\n continue\n matches.push(entry)\n seen.add(entry.name)\n }\n }\n\n if (!namesIn?.length && !server && query === undefined) {\n for (const entry of catalog) {\n matches.push(entry)\n seen.add(entry.name)\n }\n }\n\n const truncated = matches.length > limit\n const shown = truncated ? matches.slice(0, limit) : matches\n return { shown, total: matches.length, truncated, misses, query, server }\n}\n\n/**\n * Replay the unlock side-effect of a single historical `tool_search` call.\n *\n * Used on session resume: every run starts with a fresh `unlocked` set\n * (seeded with eager tools only), but the resumed conversation already\n * shows the model that some lazy tools are callable. Without this replay\n * the model emits a `tool_use` for a tool the gate then refuses with\n * \"load via tool_search first\".\n *\n * Safe to call repeatedly with the same input; the `Set` add is idempotent.\n * Lookups missing from the current catalog (host changed `mcpServers` or\n * `disclosure` between runs) are silently dropped — the model will get a\n * normal \"tool not callable\" error on its next attempt, which is the\n * correct response when a tool genuinely no longer exists.\n */\nexport function applyToolSearchToUnlocked(\n catalog: readonly LazyToolEntry[],\n input: Record<string, unknown>,\n unlocked: Set<string>,\n defaultLimit?: number,\n addUnlock?: (canonical: string) => void,\n): void {\n const { shown } = selectToolSearchMatches(catalog, input, defaultLimit ?? DEFAULT_LIMIT)\n for (const entry of shown) {\n unlocked.add(entry.canonicalName)\n addUnlock?.(entry.canonicalName)\n }\n}\n\n/**\n * Factory for `tool_search`. Auto-injected by the agent when\n * `behavior.toolDisclosure === 'lazy'` and at least one MCP tool is in the\n * registry. Opt out via `behavior.toolSearch.tool === false`.\n * @param options - Lazy tool catalog, unlock set and callbacks. See {@link ToolSearchToolOptions}.\n */\nexport function createToolSearchTool(options: ToolSearchToolOptions): ToolDef {\n const defaultLimit = options.defaultLimit ?? DEFAULT_LIMIT\n const dispatcher = options.dispatcherName\n\n return {\n // Read-only over the in-memory catalog — fan out with other reads.\n isConcurrencySafe: true,\n spec: {\n name: 'tool_search',\n description: [\n toolPrompts.tool_search.core,\n dispatcher ? toolPrompts.tool_search.callableVia(dispatcher) : toolPrompts.tool_search.callable,\n ].join(' '),\n inputSchema: {\n type: 'object',\n properties: {\n query: {\n type: 'string',\n description: 'Substring to match against tool name + description (case-insensitive).',\n },\n names: {\n type: 'array',\n items: { type: 'string' },\n description: 'Explicit tool names to load (bypasses ranking). Use the names shown in <searchable_tools>.',\n },\n server: {\n type: 'string',\n description: 'MCP server name: load every tool from this server.',\n },\n limit: {\n type: 'integer',\n minimum: 1,\n description: `Cap on returned matches. Default: ${defaultLimit}.`,\n },\n },\n additionalProperties: false,\n },\n },\n\n async execute(input, ctx: ToolContext): Promise<string> {\n // Cheap signal check — refuses cleanly if the run was aborted between\n // the model emitting the call and the executor running it.\n if (ctx.signal?.aborted)\n return '<tool_search_results matches=\"0\" aborted=\"true\">Run aborted.</tool_search_results>'\n\n if (options.catalog.length === 0)\n return '<tool_search_results matches=\"0\">No lazy tools registered for this run.</tool_search_results>'\n\n const { shown, total, truncated, misses, query, server } = selectToolSearchMatches(\n options.catalog,\n input,\n defaultLimit,\n )\n\n // Unlock by canonical name — the loop's tool registry is keyed on\n // canonical, so this is what `buildFormattedTools` checks. The\n // `addUnlock` callback (when wired by the agent) also records the\n // canonical into the per-run dynamic-unlock log so the wire-level\n // rebuild can emit fresh unlocks at the tail rather than at their\n // registry position, keeping the provider prefix cache warm.\n for (const entry of shown) {\n options.unlocked.add(entry.canonicalName)\n options.addUnlock?.(entry.canonicalName)\n }\n\n const parts: string[] = []\n const queryAttr = query ? ` query=\"${escapeXml(query)}\"` : ''\n const serverAttr = server ? ` server=\"${escapeXml(server)}\"` : ''\n parts.push(`<tool_search_results matches=\"${shown.length}\" total=\"${total}\"${queryAttr}${serverAttr}>`)\n if (shown.length === 0) {\n parts.push(' No matches. Try a broader query, or omit all parameters to list everything.')\n }\n else {\n for (const entry of shown)\n parts.push(formatMatch(entry))\n parts.push('')\n parts.push(dispatcher\n ? ` These tools are now callable through \\`${dispatcher}\\`: pass the tool name as \\`name\\` and an object matching its schema as \\`arguments\\`.`\n : ' These tools are now callable. Invoke them by name in subsequent turns.')\n if (truncated) {\n parts.push(` ${total - shown.length} additional matches were truncated; refine the query or raise \\`limit\\`.`)\n }\n }\n if (misses.length > 0) {\n parts.push(` <misses>${misses.map(escapeXml).join(', ')}</misses>`)\n }\n parts.push('</tool_search_results>')\n\n return parts.join('\\n')\n },\n }\n}\n","/**\n * `skills_read` tool — reads a bundled resource file from an active skill.\n *\n * Requires the skill to be active (model must have called `skills_use` first).\n * Paths are validated against the skill's `baseDir` to prevent directory\n * traversal. File I/O goes through `ctx.execution.readFile` so docker/sandbox\n * execution contexts work identically to in-process.\n */\n\nimport type { SkillActivationState } from '../skills/activation'\nimport type { SkillConfig } from '../skills/types'\nimport type { ToolContext, ToolDef } from './types'\nimport { errorMessage } from '../errors'\nimport { validateResourcePathReal } from '../skills/validate'\nimport { containsNullByte } from './binary-detect'\nimport { toolPrompts } from './prompts'\n\n/** Options for {@link createSkillsReadTool}. */\nexport interface SkillsReadToolOptions {\n /** Resolved skills the model may read from. */\n catalog: readonly SkillConfig[]\n /** Activation state. Only active skills can be read. */\n state: SkillActivationState\n}\n\n/**\n * Creates the `skills_read` tool, which reads a bundled resource file of an active skill. Unknown skill names are rejected at runtime.\n *\n * @param options - Skill catalog and activation state.\n */\nexport function createSkillsReadTool(options: SkillsReadToolOptions): ToolDef {\n const byName = new Map(options.catalog.map(s => [s.name, s]))\n\n return {\n // Read-only over the skill catalog — concurrency-safe.\n isConcurrencySafe: true,\n spec: {\n name: 'skills_read',\n description: toolPrompts.skills_read,\n inputSchema: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: 'The name of the active skill, as listed in the <available_skills> catalog.',\n },\n path: {\n type: 'string',\n description: 'Path to the resource, relative to the skill root. Cannot escape the skill directory.',\n },\n },\n required: ['name', 'path'],\n additionalProperties: false,\n },\n },\n\n async execute(input, ctx: ToolContext): Promise<string> {\n const skillName = input.name as string\n const relPath = input.path as string\n\n const skill = byName.get(skillName)\n if (!skill) {\n const available = [...byName.keys()].join(', ') || '<none>'\n return `Error: unknown skill \"${skillName}\". Available skills: ${available}.`\n }\n\n if (!options.state.isActive(skillName))\n return `Error: skill \"${skillName}\" is not active. Call skills_use with name: \"${skillName}\" first.`\n\n if (!skill.baseDir) {\n return (\n `Error: skill \"${skillName}\" has no base directory `\n + '(likely an inline skill without bundled resources); cannot read files.'\n )\n }\n\n const validated = await validateResourcePathReal(relPath, skill.baseDir)\n if (!validated.valid)\n return `Error: ${validated.error}`\n\n let content: string\n try {\n content = await ctx.execution.readFile(ctx.handle, validated.absolutePath)\n }\n catch (err) {\n return `Error reading \"${relPath}\" in skill \"${skillName}\": ${errorMessage(err)}`\n }\n\n if (containsNullByte(content)) {\n // `ExecutionContext.readFile` returns a UTF-8 string — invalid UTF-8\n // bytes get replacement chars, so a round-trip through base64 would\n // corrupt the payload. Instead of pretending we can deliver binary\n // bytes, return a descriptor that tells the agent where the file is.\n // This tool reads through the text-based `readFile` only (it does not\n // use the optional `ExecutionContext.readFileBinary`), so host\n // adapters needing binaries should stream them out-of-band.\n return JSON.stringify({\n kind: 'binary-unsupported',\n path: validated.absolutePath,\n note:\n 'This file appears to be binary. The skills_read tool returns text only; '\n + 'binary files are not delivered through the execution context\\'s text-based readFile API.',\n })\n }\n\n return content\n },\n }\n}\n","/**\n * `skills_run_script` tool — executes a script from an active skill's\n * `scripts/` directory via the agent's execution context.\n *\n * Path is validated against the skill's `baseDir` and constrained to the\n * `scripts/` subdirectory. Timeout is configurable via\n * `SkillsConfig.scriptTimeoutMs` (default 60 s).\n */\n\nimport type { SkillActivationState } from '../skills/activation'\nimport type { SkillConfig } from '../skills/types'\nimport type { ToolContext, ToolDef } from './types'\nimport { errorMessage } from '../errors'\nimport { validateResourcePathReal } from '../skills/validate'\nimport { toolPrompts } from './prompts'\nimport { alwaysQuote } from './shell-quote'\n\n/** Options for {@link createSkillsRunScriptTool}. */\nexport interface SkillsRunScriptToolOptions {\n /** Resolved skills whose scripts the model may run. */\n catalog: readonly SkillConfig[]\n /** Activation state. Only active skills can run scripts. */\n state: SkillActivationState\n /** Script timeout in milliseconds. Default 60000. */\n scriptTimeoutMs?: number\n}\n\nconst ABS_WINDOWS_RE = /^[a-z]:[\\\\/]/i\nconst COLLAPSE_SLASHES_RE = /\\/+/g\n\n/**\n * Creates the `skills_run_script` tool, which runs a script from an active skill's `scripts/` directory in the execution context.\n *\n * @param options - Skill catalog, activation state and script timeout.\n */\nexport function createSkillsRunScriptTool(options: SkillsRunScriptToolOptions): ToolDef {\n const byName = new Map(options.catalog.map(s => [s.name, s]))\n const timeoutMs = options.scriptTimeoutMs ?? 60_000\n\n return {\n spec: {\n name: 'skills_run_script',\n description: toolPrompts.skills_run_script,\n inputSchema: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: 'The name of the active skill, as listed in the <available_skills> catalog.',\n },\n script: {\n type: 'string',\n description: 'Path to the script relative to the skill\\'s scripts/ directory (e.g. \"extract.py\", \"merge.sh\").',\n },\n args: {\n type: 'array',\n items: { type: 'string' },\n description: 'Optional argv array passed to the script.',\n },\n },\n required: ['name', 'script'],\n additionalProperties: false,\n },\n },\n\n async execute(input, ctx: ToolContext): Promise<string> {\n const skillName = input.name as string\n const scriptRel = input.script as string\n const args = (input.args as string[] | undefined) ?? []\n\n const skill = byName.get(skillName)\n if (!skill) {\n const available = [...byName.keys()].join(', ') || '<none>'\n return `Error: unknown skill \"${skillName}\". Available skills: ${available}.`\n }\n\n if (!options.state.isActive(skillName))\n return `Error: skill \"${skillName}\" is not active. Call skills_use with name: \"${skillName}\" first.`\n\n if (!skill.baseDir)\n return `Error: skill \"${skillName}\" has no base directory (likely an inline skill); cannot run scripts.`\n\n // Reject absolute script paths up front — otherwise they'd be spuriously\n // \"normalized\" under scripts/ by the join below.\n if (scriptRel.startsWith('/') || ABS_WINDOWS_RE.test(scriptRel))\n return `Error: Absolute paths are not allowed (\"${scriptRel}\").`\n\n // Resolve under scripts/ and validate — rejects escapes via `..`.\n const joinedPath = `scripts/${scriptRel}`.replace(COLLAPSE_SLASHES_RE, '/')\n const validated = await validateResourcePathReal(joinedPath, skill.baseDir)\n if (!validated.valid)\n return `Error: ${validated.error}`\n\n // Build a shell command that honors shebang (via POSIX exec). For\n // languages without shebang (e.g. Python on Windows-authored files),\n // the script's first-line `#!/usr/bin/env python3` handles it.\n const cmd = [validated.absolutePath, ...args].map(alwaysQuote).join(' ')\n try {\n // Forward `ctx.signal` so a per-call cancel (or run abort) sends\n // SIGTERM to the script — same rationale as the shell tool: without\n // it, a long-running script keeps consuming compute after the\n // model has already moved on with the cancellation marker.\n const result = await ctx.execution.exec(ctx.handle, cmd, {\n timeout: Math.max(1, Math.round(timeoutMs / 1000)),\n signal: ctx.signal,\n })\n return JSON.stringify({\n exitCode: result.exitCode,\n stdout: result.stdout,\n stderr: result.stderr,\n })\n }\n catch (err) {\n return `Error running script \"${scriptRel}\" for skill \"${skillName}\": ${errorMessage(err)}`\n }\n },\n }\n}\n","/**\n * `skills_use` tool — activates or deactivates a skill from the model side.\n *\n * Implements tier 2 of progressive disclosure per the Agent Skills spec.\n *\n * Two modes:\n *\n * - `mode: \"activate\"` (default, spec-mandated) — loads the skill's full\n * instructions, fires `skills:activate` with `via: 'model'`, and\n * returns the frontmatter-stripped body wrapped in `<skill_content>`\n * tags. Shell-interpolation (`!`` `cmd` ``) runs per-activation so\n * values like `gh pr diff` reflect the current state.\n * - `mode: \"deactivate\"` (zidane extension) — releases an active skill,\n * fires `skills:deactivate` with `reason: 'model'`. The matching\n * skill's `allowed-tools` restrictions stop applying on the next\n * dispatch. Use this when the skill's job is done and its tool\n * allow-list is now blocking unrelated follow-up work.\n *\n * The deactivate mode is what lets the model recover from a stuck\n * `AgentToolNotAllowedError` (the canonical hint of which points the\n * model right back here) without waiting for a run boundary.\n */\n\nimport type { Hookable } from 'hookable'\nimport type { AgentHooks } from '../agent'\nimport type { SkillActivationState } from '../skills/activation'\nimport type { ShellInterpolationApproval, SkillConfig } from '../skills/types'\nimport type { ToolContext, ToolDef } from './types'\nimport { interpolateShellCommands, stripShellInterpolations } from '../skills/interpolate'\nimport { escapeXml } from '../xml'\nimport { toolPrompts } from './prompts'\n\n/** Options for {@link createSkillsUseTool}. */\nexport interface SkillsUseToolOptions {\n /** Resolved skills catalog for this run. */\n catalog: readonly SkillConfig[]\n /** Per-agent activation state the tool mutates. */\n state: SkillActivationState\n /** Agent hooks — used to fire `skills:activate` on first activation. */\n hooks: Hookable<AgentHooks>\n /**\n * Execute `!\\`cmd\\`` shell interpolation on activation. Mirrors\n * `SkillsConfig.allowShellInterpolation`. Default `true`. Interpolation\n * runs arbitrary shell from (possibly third-party) skill content, outside\n * the allowed-tools gate — set `false` for locked-down hosts. When off,\n * patterns are replaced with a `[shell interpolation disabled]`\n * placeholder.\n */\n allowShellInterpolation?: boolean\n /**\n * Optional approval gate for `!\\`cmd\\`` shell interpolation. Invoked once\n * per (skill, command) the first time a skill with embedded shell is\n * activated, BEFORE the command runs. Return `false` to skip that command\n * (it is replaced with a `[shell interpolation not approved]` placeholder).\n * When omitted, interpolation runs without prompting. Hosts\n * (TUI/GUI) can wire this to an interactive confirmation.\n */\n approveShellInterpolation?: (request: ShellInterpolationApproval) => boolean | Promise<boolean>\n}\n\nexport type { ShellInterpolationApproval } from '../skills/types'\n\nconst MAX_RESOURCE_LIST = 50\n\nfunction buildSkillContentWrapper(skill: SkillConfig, body: string): string {\n const parts: string[] = []\n parts.push(`<skill_content name=\"${escapeXml(skill.name)}\" spec_version=\"0.1\">`)\n parts.push(body)\n\n if (skill.baseDir) {\n parts.push('')\n parts.push(`Skill directory: ${skill.baseDir}`)\n parts.push('Relative paths resolve against this directory.')\n }\n\n if (skill.resources?.length) {\n parts.push('')\n parts.push('<skill_resources>')\n const shown = skill.resources.slice(0, MAX_RESOURCE_LIST)\n for (const res of shown) {\n parts.push(` <file type=\"${res.type}\">${escapeXml(res.path)}</file>`)\n }\n if (skill.resources.length > MAX_RESOURCE_LIST) {\n parts.push(` <!-- …(${skill.resources.length - MAX_RESOURCE_LIST} more) -->`)\n }\n parts.push('</skill_resources>')\n }\n\n if (skill.compatibility) {\n parts.push('')\n parts.push(`Compatibility: ${skill.compatibility}`)\n }\n\n if (skill.allowedTools?.length) {\n parts.push(`Allowed tools: ${skill.allowedTools.join(' ')}`)\n }\n\n parts.push('</skill_content>')\n return parts.join('\\n')\n}\n\n/**\n * Factory for `skills_use`. Auto-injected into the agent's tool set by the\n * agent runtime when a non-empty skills catalog is available (unless\n * `SkillsConfig.tool === false`).\n *\n * The `name` property carries no `enum` so the tool list stays byte-stable\n * across catalogs; unknown names are rejected at runtime with the list of\n * available skills.\n * @param options - Skill catalog, activation state, hooks and shell interpolation settings.\n */\nexport function createSkillsUseTool(options: SkillsUseToolOptions): ToolDef {\n const byName = new Map(options.catalog.map(s => [s.name, s]))\n // Cache interpolated bodies for the lifetime of this tool instance. The\n // agent rebuilds skills tools per-run, so this cache naturally resets on\n // each run boundary — avoiding stale shell output from a prior run.\n const interpolatedBodyCache = new Map<string, string>()\n\n return {\n spec: {\n name: 'skills_use',\n description: toolPrompts.skills_use,\n inputSchema: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: 'The name of the skill to activate or deactivate, as listed in the <available_skills> catalog.',\n },\n mode: {\n type: 'string',\n enum: ['activate', 'deactivate'],\n description: 'Whether to activate (load + apply the skill) or deactivate (release an active skill). Default: \"activate\".',\n },\n },\n required: ['name'],\n additionalProperties: false,\n },\n },\n\n async execute(input, ctx: ToolContext): Promise<string> {\n const skillName = input.name as string\n const skill = byName.get(skillName)\n if (!skill) {\n const available = [...byName.keys()].join(', ') || '<none>'\n return `Error: unknown skill \"${skillName}\". Available skills: ${available}.`\n }\n\n const mode = (input.mode as string | undefined) ?? 'activate'\n\n if (mode === 'deactivate') {\n const removed = options.state.deactivate(skillName)\n if (!removed) {\n // Idempotent: deactivating a non-active skill is a no-op rather\n // than an error — the model has no reliable way to know whether a\n // prior run-end pass already cleared the activation, and a\n // confirmation is more useful than a failure here.\n return `Skill \"${skillName}\" was not active: nothing to deactivate.`\n }\n await options.hooks.callHook('skills:deactivate', { skill: removed.skill, reason: 'model' })\n const remaining = options.state.active().map(a => a.skill.name)\n const tail = remaining.length > 0\n ? ` Remaining active skills: ${remaining.join(', ')}.`\n : ' No skills are currently active.'\n return `Skill \"${skillName}\" deactivated: its allowed-tools restrictions no longer apply.${tail}`\n }\n\n const wasActive = options.state.isActive(skillName)\n\n if (!wasActive) {\n const outcome = options.state.activate(skill, 'model')\n if (outcome === 'cap-reached') {\n const activeNames = options.state.active().map(a => a.skill.name).join(', ')\n return (\n `Error: cannot activate \"${skillName}\": the maxActive skill cap has been reached. `\n + `Currently active: ${activeNames}. Call \\`skills_use\\` with \\`mode: \"deactivate\"\\` and one of those names first.`\n )\n }\n await options.hooks.callHook('skills:activate', { skill, via: 'model' })\n }\n\n // Interpolate `!\\`cmd\\`` once per (skill, tool-instance). A second\n // `skills_use` call on the same skill returns the cached body.\n // Interpolation runs unless `allowShellInterpolation: false`; when\n // disabled the patterns are neutralized with a placeholder. An optional\n // `approveShellInterpolation` gate can veto individual commands.\n let body = interpolatedBodyCache.get(skillName)\n if (body === undefined) {\n if (!skill.instructions.includes('!`')) {\n body = skill.instructions\n }\n else if (options.allowShellInterpolation !== false) {\n const failures: string[] = []\n const approve = options.approveShellInterpolation\n body = await interpolateShellCommands(skill.instructions, ctx.execution, ctx.handle, {\n onFailure: command => failures.push(command),\n ...(approve\n ? { approve: (command: string) => approve({ skillName, source: skill.source, command }) }\n : {}),\n })\n // Surface partial interpolation failure in the activation result —\n // the inline `[command failed …]` markers alone are easy to read\n // past, and the model should know the content may be incomplete.\n if (failures.length > 0) {\n body += `\\n\\nWarning: ${failures.length} shell interpolation command${failures.length === 1 ? '' : 's'} failed during activation (${failures.map(c => `\\`${c}\\``).join(', ')}). The instructions above may be missing dynamic content; see the inline [command failed …] markers.`\n }\n }\n else {\n body = stripShellInterpolations(skill.instructions)\n }\n interpolatedBodyCache.set(skillName, body)\n }\n\n return buildSkillContentWrapper(skill, body)\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,UAAU,OAA0C;CAClE,IAAI,MAAM,SAAS,IACjB,OAAO,KAAA;CAET,IAAI,MAAM,OAAO,OAAQ,MAAM,OAAO,MAAQ,MAAM,OAAO,MAAQ,MAAM,OAAO,IAAM;EACpF,IAAI,MAAM,SAAS,IACjB,OAAO,KAAA;EACT,OAAO,SAAS,UAAU,OAAO,EAAE,GAAG,UAAU,OAAO,EAAE,CAAC;CAC5D;CAEA,IAAI,MAAM,OAAO,MAAQ,MAAM,OAAO,MAAQ,MAAM,OAAO,IACzD,OAAO,SAAS,MAAM,KAAO,MAAM,MAAO,GAAI,MAAM,KAAO,MAAM,MAAO,CAAE;CAE5E,IAAI,MAAM,UAAU,MAAM,MAAM,OAAO,MAAQ,MAAM,OAAO,MAAQ,MAAM,OAAO,MAAQ,MAAM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,OAAO,MAAM,yBAAyB,MAAM,cAAc,IAAI,WAAW,IAAI,QAAQ;MACnF,YAAW,YAAW,SAAS,KAAK,OAAO;MAC3C,GAAI,UACA,EAAE,UAAU,YAAoB,QAAQ;OAAE;OAAW,QAAQ,MAAM;OAAQ;MAAQ,CAAC,EAAE,IACtF,CAAC;KACP,CAAC;KAID,IAAI,SAAS,SAAS,GACpB,QAAQ,gBAAgB,SAAS,OAAO,8BAA8B,SAAS,WAAW,IAAI,KAAK,IAAI,6BAA6B,SAAS,KAAI,MAAK,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE;IAEjL,OAEE,OAAO,yBAAyB,MAAM,YAAY;IAEpD,sBAAsB,IAAI,WAAW,IAAI;GAC3C;GAEA,OAAO,yBAAyB,OAAO,IAAI;EAC7C;CACF;AACF"}
package/dist/skills.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $d as SkillInstallError, Af as SkillPickGroup, Bd as matchesAllowedTool, Bf as IMPLICITLY_ALLOWED_SKILL_TOOLS, Cf as SkillBrowseErrorCode, Df as RecommendedSkillSource, Ef as RECOMMENDED_SKILL_SOURCES, Fd as SkillTokenWeights, Ff as githubPreviewImageUrl, Gd as validateSkillName, Hd as validateResourcePath, Id as skillTokenWeights, If as groupSkillPicks, Jd as interpolateShellCommands, Kd as resolveSkills, Ld as SkillValidationIssue, Lf as skillCategory, Md as defineSkill, Mf as SkillSourceListing, Nd as writeSkillToDisk, Nf as SkillSourceSkill, Of as SkillInstallTarget, Pd as writeSkillsToDisk, Pf as githubAvatarUrl, Qd as SkillInstallCandidate, Rd as SkillValidationResult, Rf as skillPickKey, Sf as SkillBrowseError, Tf as clearSkillSourceCache, Ud as validateResourcePathReal, Vd as parseAllowedToolPattern, Vf as installAllowedToolsGate, Wd as validateSkillForWrite, Xd as SKILL_PROVENANCE_FILE, Yd as stripShellInterpolations, Zd as SkillCandidateDetail, _f as SKILL_CANDIDATE_MAX_DEPTH, aE as SkillConfig, af as listSkillCandidates, ax as createSkillActivationState, bf as skillCandidatesFromPaths, cE as SkillSource, cf as SourcedScanPath, df as inferSource, ef as SkillInstallErrorCode, ex as ActivationVia, ff as parseFrontmatter, gf as skillCatalogEntry, hf as buildCatalog, iE as ShellInterpolationApproval, if as installSkillFromSpec, ix as SkillActivationStateOptions, jf as SkillSourceInfo, kf as SkillPick, lE as SkillsConfig, lf as discoverSkills, mf as parseSkillFile, nf as SkillInstallResult, nx as DeactivationReason, oE as SkillDiagnostic, of as parseSkillInstallSpec, pf as parseSkillContent, qd as InterpolateShellCommandsOptions, rf as SkillInstallSpec, rx as SkillActivationState, sE as SkillResource, sf as readSkillProvenance, tf as SkillInstallOptions, tx as ActiveSkill, uf as getDefaultScanPaths, vf as SkillPathCandidate, wf as browseSkillSource, xf as BrowseSkillSourceOptions, yf as sanitizeSkillName, zd as isToolAllowedByUnion, zf as skillPickOf } from "./index-CidMTcxS.js";
1
+ import { $d as stripShellInterpolations, Af as RECOMMENDED_SKILL_SOURCES, Bd as skillTokenWeights, Bf as groupSkillPicks, CE as SkillDiagnostic, Cf as sanitizeSkillName, Df as SkillBrowseErrorCode, EE as SkillsConfig, Ef as SkillBrowseError, Ff as SkillSourceInfo, Gd as parseAllowedToolPattern, Gf as installAllowedToolsGate, Hd as SkillValidationResult, Hf as skillPickKey, Id as defineSkill, If as SkillSourceListing, Jd as validateSkillForWrite, Kd as validateResourcePath, Ld as writeSkillToDisk, Lf as SkillSourceSkill, Mf as SkillInstallTarget, Nf as SkillPick, Of as browseSkillSource, Pf as SkillPickGroup, Qd as interpolateShellCommands, Rd as writeSkillsToDisk, Rf as githubAvatarUrl, SE as SkillConfig, Sf as SkillPathCandidate, TE as SkillSource, Tf as BrowseSkillSourceOptions, Ud as isToolAllowedByUnion, Uf as skillPickOf, Vd as SkillValidationIssue, Vf as skillCategory, Wd as matchesAllowedTool, Wf as IMPLICITLY_ALLOWED_SKILL_TOOLS, Xd as resolveSkills, Yd as validateSkillName, Zd as InterpolateShellCommandsOptions, _f as parseSkillContent, af as SkillInstallOptions, ax as ActiveSkill, bf as skillCatalogEntry, cf as installSkillFromSpec, cx as SkillActivationStateOptions, df as readSkillProvenance, ef as SKILL_PROVENANCE_FILE, ff as SourcedScanPath, gf as parseFrontmatter, hf as inferSource, if as SkillInstallErrorCode, ix as ActivationVia, jf as RecommendedSkillSource, kf as clearSkillSourceCache, lf as listSkillCandidates, lx as createSkillActivationState, mf as getDefaultScanPaths, nf as SkillInstallCandidate, of as SkillInstallResult, ox as DeactivationReason, pf as discoverSkills, qd as validateResourcePathReal, rf as SkillInstallError, sf as SkillInstallSpec, sx as SkillActivationState, tf as SkillCandidateDetail, uf as parseSkillInstallSpec, vf as parseSkillFile, wE as SkillResource, wf as skillCandidatesFromPaths, xE as ShellInterpolationApproval, xf as SKILL_CANDIDATE_MAX_DEPTH, yf as buildCatalog, zd as SkillTokenWeights, zf as githubPreviewImageUrl } from "./index-DyQyDLX1.js";
2
2
  export { type ActivationVia, type ActiveSkill, type BrowseSkillSourceOptions, type DeactivationReason, IMPLICITLY_ALLOWED_SKILL_TOOLS, type InterpolateShellCommandsOptions, RECOMMENDED_SKILL_SOURCES, type RecommendedSkillSource, SKILL_CANDIDATE_MAX_DEPTH, SKILL_PROVENANCE_FILE, type ShellInterpolationApproval, type SkillActivationState, type SkillActivationStateOptions, SkillBrowseError, type SkillBrowseErrorCode, type SkillCandidateDetail, type SkillConfig, type SkillDiagnostic, type SkillInstallCandidate, SkillInstallError, type SkillInstallErrorCode, type SkillInstallOptions, type SkillInstallResult, type SkillInstallSpec, type SkillInstallTarget, type SkillPathCandidate, type SkillPick, type SkillPickGroup, type SkillResource, type SkillSource, type SkillSourceInfo, type SkillSourceListing, type SkillSourceSkill, type SkillTokenWeights, type SkillValidationIssue, type SkillValidationResult, type SkillsConfig, type SourcedScanPath, browseSkillSource, buildCatalog, clearSkillSourceCache, createSkillActivationState, defineSkill, discoverSkills, getDefaultScanPaths, githubAvatarUrl, githubPreviewImageUrl, groupSkillPicks, inferSource, installAllowedToolsGate, installSkillFromSpec, interpolateShellCommands, isToolAllowedByUnion, listSkillCandidates, matchesAllowedTool, parseAllowedToolPattern, parseFrontmatter, parseSkillContent, parseSkillFile, parseSkillInstallSpec, readSkillProvenance, resolveSkills, sanitizeSkillName, skillCandidatesFromPaths, skillCatalogEntry, skillCategory, skillPickKey, skillPickOf, skillTokenWeights, stripShellInterpolations, validateResourcePath, validateResourcePathReal, validateSkillForWrite, validateSkillName, writeSkillToDisk, writeSkillsToDisk };