@ai-agent-forge/agent-forge 0.86.7 → 0.88.0

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 (717) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +10 -11
  3. package/dist/artifacts/artifact-store.d.ts.map +1 -1
  4. package/dist/artifacts/artifact-store.js +9 -5
  5. package/dist/artifacts/artifact-store.js.map +1 -1
  6. package/dist/bundle/.build-manifest.json +430 -413
  7. package/dist/bundle/chunks/{chunk-A7GUOX2H.js → chunk-6ZKDNZHA.js} +5 -1
  8. package/dist/bundle/chunks/chunk-HLJEVRWP.js +13 -0
  9. package/dist/bundle/chunks/chunk-YGHQME4V.js +1456 -0
  10. package/dist/bundle/chunks/image-resize-worker.js +12 -1
  11. package/dist/bundle/chunks/{virtual-modules-3IZ4MYSQ.js → virtual-modules-KZ5DRH7Q.js} +1 -1
  12. package/dist/bundle/cli.js +1 -1
  13. package/dist/bundle/client.js +1 -1
  14. package/dist/bundle/index.js +2 -2
  15. package/dist/bundle/rpc-entry.js +1 -1
  16. package/dist/cli/args.d.ts.map +1 -1
  17. package/dist/cli/args.js +231 -185
  18. package/dist/cli/args.js.map +1 -1
  19. package/dist/cli/auth-check.d.ts.map +1 -1
  20. package/dist/cli/auth-check.js +17 -4
  21. package/dist/cli/auth-check.js.map +1 -1
  22. package/dist/cli/auth-command.d.ts.map +1 -1
  23. package/dist/cli/auth-command.js +15 -9
  24. package/dist/cli/auth-command.js.map +1 -1
  25. package/dist/cli/credential-print.d.ts.map +1 -1
  26. package/dist/cli/credential-print.js +14 -7
  27. package/dist/cli/credential-print.js.map +1 -1
  28. package/dist/cli/experimental/command.d.ts.map +1 -1
  29. package/dist/cli/experimental/command.js +6 -5
  30. package/dist/cli/experimental/command.js.map +1 -1
  31. package/dist/cli/list-models.d.ts.map +1 -1
  32. package/dist/cli/list-models.js +9 -8
  33. package/dist/cli/list-models.js.map +1 -1
  34. package/dist/cli/plugin-manager-controller.d.ts.map +1 -1
  35. package/dist/cli/plugin-manager-controller.js +2 -1
  36. package/dist/cli/plugin-manager-controller.js.map +1 -1
  37. package/dist/cli/serve.d.ts.map +1 -1
  38. package/dist/cli/serve.js +8 -5
  39. package/dist/cli/serve.js.map +1 -1
  40. package/dist/client/remote-session.d.ts.map +1 -1
  41. package/dist/client/remote-session.js +16 -9
  42. package/dist/client/remote-session.js.map +1 -1
  43. package/dist/config.d.ts.map +1 -1
  44. package/dist/config.js +5 -3
  45. package/dist/config.js.map +1 -1
  46. package/dist/core/agent-capability-contract.d.ts +0 -7
  47. package/dist/core/agent-capability-contract.d.ts.map +1 -1
  48. package/dist/core/agent-capability-contract.js +72 -68
  49. package/dist/core/agent-capability-contract.js.map +1 -1
  50. package/dist/core/agent-session-bash.d.ts.map +1 -1
  51. package/dist/core/agent-session-bash.js +5 -4
  52. package/dist/core/agent-session-bash.js.map +1 -1
  53. package/dist/core/agent-session-compaction.d.ts +6 -10
  54. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  55. package/dist/core/agent-session-compaction.js +35 -133
  56. package/dist/core/agent-session-compaction.js.map +1 -1
  57. package/dist/core/agent-session-context.d.ts.map +1 -1
  58. package/dist/core/agent-session-context.js +18 -13
  59. package/dist/core/agent-session-context.js.map +1 -1
  60. package/dist/core/agent-session-internal.d.ts +0 -6
  61. package/dist/core/agent-session-internal.d.ts.map +1 -1
  62. package/dist/core/agent-session-internal.js.map +1 -1
  63. package/dist/core/agent-session-model.d.ts.map +1 -1
  64. package/dist/core/agent-session-model.js +2 -1
  65. package/dist/core/agent-session-model.js.map +1 -1
  66. package/dist/core/agent-session-retry.d.ts.map +1 -1
  67. package/dist/core/agent-session-retry.js +3 -3
  68. package/dist/core/agent-session-retry.js.map +1 -1
  69. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  70. package/dist/core/agent-session-runtime.js +7 -6
  71. package/dist/core/agent-session-runtime.js.map +1 -1
  72. package/dist/core/agent-session-services.d.ts +1 -1
  73. package/dist/core/agent-session-services.d.ts.map +1 -1
  74. package/dist/core/agent-session-services.js.map +1 -1
  75. package/dist/core/agent-session-tools.d.ts.map +1 -1
  76. package/dist/core/agent-session-tools.js +3 -2
  77. package/dist/core/agent-session-tools.js.map +1 -1
  78. package/dist/core/agent-session.d.ts +40 -22
  79. package/dist/core/agent-session.d.ts.map +1 -1
  80. package/dist/core/agent-session.js +147 -67
  81. package/dist/core/agent-session.js.map +1 -1
  82. package/dist/core/auth-guidance.d.ts.map +1 -1
  83. package/dist/core/auth-guidance.js +11 -5
  84. package/dist/core/auth-guidance.js.map +1 -1
  85. package/dist/core/auth-storage.d.ts.map +1 -1
  86. package/dist/core/auth-storage.js +9 -6
  87. package/dist/core/auth-storage.js.map +1 -1
  88. package/dist/core/compaction/compaction.d.ts.map +1 -1
  89. package/dist/core/compaction/compaction.js +2 -1
  90. package/dist/core/compaction/compaction.js.map +1 -1
  91. package/dist/core/embedded-sdk.d.ts.map +1 -1
  92. package/dist/core/embedded-sdk.js +10 -6
  93. package/dist/core/embedded-sdk.js.map +1 -1
  94. package/dist/core/export-html/index.d.ts.map +1 -1
  95. package/dist/core/export-html/index.js +9 -4
  96. package/dist/core/export-html/index.js.map +1 -1
  97. package/dist/core/extensions/agent-composition.d.ts.map +1 -1
  98. package/dist/core/extensions/agent-composition.js +26 -19
  99. package/dist/core/extensions/agent-composition.js.map +1 -1
  100. package/dist/core/extensions/bootstrap-agent-loop.d.ts.map +1 -1
  101. package/dist/core/extensions/bootstrap-agent-loop.js +3 -2
  102. package/dist/core/extensions/bootstrap-agent-loop.js.map +1 -1
  103. package/dist/core/extensions/bootstrap-compaction-policy.d.ts.map +1 -1
  104. package/dist/core/extensions/bootstrap-compaction-policy.js +0 -34
  105. package/dist/core/extensions/bootstrap-compaction-policy.js.map +1 -1
  106. package/dist/core/extensions/bootstrap-lifecycle.d.ts.map +1 -1
  107. package/dist/core/extensions/bootstrap-lifecycle.js +20 -17
  108. package/dist/core/extensions/bootstrap-lifecycle.js.map +1 -1
  109. package/dist/core/extensions/bootstrap-overflow-policy.d.ts.map +1 -1
  110. package/dist/core/extensions/bootstrap-overflow-policy.js +2 -1
  111. package/dist/core/extensions/bootstrap-overflow-policy.js.map +1 -1
  112. package/dist/core/extensions/bootstrap-retry-policy.d.ts.map +1 -1
  113. package/dist/core/extensions/bootstrap-retry-policy.js +4 -3
  114. package/dist/core/extensions/bootstrap-retry-policy.js.map +1 -1
  115. package/dist/core/extensions/bootstrap-skills.d.ts.map +1 -1
  116. package/dist/core/extensions/bootstrap-skills.js +7 -6
  117. package/dist/core/extensions/bootstrap-skills.js.map +1 -1
  118. package/dist/core/extensions/bootstrap-tools.d.ts.map +1 -1
  119. package/dist/core/extensions/bootstrap-tools.js +2 -1
  120. package/dist/core/extensions/bootstrap-tools.js.map +1 -1
  121. package/dist/core/extensions/capability-plugin.d.ts.map +1 -1
  122. package/dist/core/extensions/capability-plugin.js +37 -13
  123. package/dist/core/extensions/capability-plugin.js.map +1 -1
  124. package/dist/core/extensions/capability-runtime-events.d.ts.map +1 -1
  125. package/dist/core/extensions/capability-runtime-events.js +17 -13
  126. package/dist/core/extensions/capability-runtime-events.js.map +1 -1
  127. package/dist/core/extensions/capability-runtime-guards.d.ts.map +1 -1
  128. package/dist/core/extensions/capability-runtime-guards.js +16 -15
  129. package/dist/core/extensions/capability-runtime-guards.js.map +1 -1
  130. package/dist/core/extensions/capability-runtime-manifest.d.ts.map +1 -1
  131. package/dist/core/extensions/capability-runtime-manifest.js +52 -30
  132. package/dist/core/extensions/capability-runtime-manifest.js.map +1 -1
  133. package/dist/core/extensions/capability-runtime-validation.d.ts.map +1 -1
  134. package/dist/core/extensions/capability-runtime-validation.js +66 -65
  135. package/dist/core/extensions/capability-runtime-validation.js.map +1 -1
  136. package/dist/core/extensions/capability-runtime.d.ts.map +1 -1
  137. package/dist/core/extensions/capability-runtime.js +147 -127
  138. package/dist/core/extensions/capability-runtime.js.map +1 -1
  139. package/dist/core/extensions/compaction-memory-failure-mode.d.ts.map +1 -1
  140. package/dist/core/extensions/compaction-memory-failure-mode.js +3 -2
  141. package/dist/core/extensions/compaction-memory-failure-mode.js.map +1 -1
  142. package/dist/core/extensions/context-strategy-binding.d.ts.map +1 -1
  143. package/dist/core/extensions/context-strategy-binding.js +7 -4
  144. package/dist/core/extensions/context-strategy-binding.js.map +1 -1
  145. package/dist/core/extensions/lifecycle-catalog.d.ts.map +1 -1
  146. package/dist/core/extensions/lifecycle-catalog.js +290 -279
  147. package/dist/core/extensions/lifecycle-catalog.js.map +1 -1
  148. package/dist/core/extensions/lifecycle-delivery-queue.d.ts.map +1 -1
  149. package/dist/core/extensions/lifecycle-delivery-queue.js +3 -2
  150. package/dist/core/extensions/lifecycle-delivery-queue.js.map +1 -1
  151. package/dist/core/extensions/provider-failover.d.ts +7 -3
  152. package/dist/core/extensions/provider-failover.d.ts.map +1 -1
  153. package/dist/core/extensions/provider-failover.js +9 -8
  154. package/dist/core/extensions/provider-failover.js.map +1 -1
  155. package/dist/core/facade/coding-agent-facade.d.ts +6 -6
  156. package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
  157. package/dist/core/facade/coding-agent-facade.js +2 -3
  158. package/dist/core/facade/coding-agent-facade.js.map +1 -1
  159. package/dist/core/http-dispatcher.d.ts.map +1 -1
  160. package/dist/core/http-dispatcher.js +2 -1
  161. package/dist/core/http-dispatcher.js.map +1 -1
  162. package/dist/core/i18n/index.d.ts +14 -0
  163. package/dist/core/i18n/index.d.ts.map +1 -0
  164. package/dist/core/i18n/index.js +67 -0
  165. package/dist/core/i18n/index.js.map +1 -0
  166. package/dist/core/i18n/locales/en/example.d.ts +7 -0
  167. package/dist/core/i18n/locales/en/example.d.ts.map +1 -0
  168. package/dist/core/i18n/locales/en/example.js +7 -0
  169. package/dist/core/i18n/locales/en/example.js.map +1 -0
  170. package/dist/core/i18n/locales/zh-cn/cli.d.ts +8 -0
  171. package/dist/core/i18n/locales/zh-cn/cli.d.ts.map +1 -0
  172. package/dist/core/i18n/locales/zh-cn/cli.js +229 -0
  173. package/dist/core/i18n/locales/zh-cn/cli.js.map +1 -0
  174. package/dist/core/i18n/locales/zh-cn/common.d.ts +6 -0
  175. package/dist/core/i18n/locales/zh-cn/common.d.ts.map +1 -0
  176. package/dist/core/i18n/locales/zh-cn/common.js +6 -0
  177. package/dist/core/i18n/locales/zh-cn/common.js.map +1 -0
  178. package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts +13 -0
  179. package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts.map +1 -0
  180. package/dist/core/i18n/locales/zh-cn/core-contract-core.js +173 -0
  181. package/dist/core/i18n/locales/zh-cn/core-contract-core.js.map +1 -0
  182. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts +12 -0
  183. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts.map +1 -0
  184. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js +582 -0
  185. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js.map +1 -0
  186. package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts +9 -0
  187. package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts.map +1 -0
  188. package/dist/core/i18n/locales/zh-cn/core-contract-final.js +55 -0
  189. package/dist/core/i18n/locales/zh-cn/core-contract-final.js.map +1 -0
  190. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts +11 -0
  191. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts.map +1 -0
  192. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js +455 -0
  193. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js.map +1 -0
  194. package/dist/core/i18n/locales/zh-cn/core-errors.d.ts +9 -0
  195. package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -0
  196. package/dist/core/i18n/locales/zh-cn/core-errors.js +191 -0
  197. package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -0
  198. package/dist/core/i18n/locales/zh-cn/example.d.ts +7 -0
  199. package/dist/core/i18n/locales/zh-cn/example.d.ts.map +1 -0
  200. package/dist/core/i18n/locales/zh-cn/example.js +10 -0
  201. package/dist/core/i18n/locales/zh-cn/example.js.map +1 -0
  202. package/dist/core/i18n/locales/zh-cn/index.d.ts +2 -0
  203. package/dist/core/i18n/locales/zh-cn/index.d.ts.map +1 -0
  204. package/dist/core/i18n/locales/zh-cn/index.js +41 -0
  205. package/dist/core/i18n/locales/zh-cn/index.js.map +1 -0
  206. package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts +10 -0
  207. package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -0
  208. package/dist/core/i18n/locales/zh-cn/interactive-mode.js +267 -0
  209. package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -0
  210. package/dist/core/i18n/locales/zh-cn/keybindings.d.ts +11 -0
  211. package/dist/core/i18n/locales/zh-cn/keybindings.d.ts.map +1 -0
  212. package/dist/core/i18n/locales/zh-cn/keybindings.js +67 -0
  213. package/dist/core/i18n/locales/zh-cn/keybindings.js.map +1 -0
  214. package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts +7 -0
  215. package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts.map +1 -0
  216. package/dist/core/i18n/locales/zh-cn/slash-commands.js +39 -0
  217. package/dist/core/i18n/locales/zh-cn/slash-commands.js.map +1 -0
  218. package/dist/core/i18n/locales/zh-cn/tui-builtin.d.ts +10 -0
  219. package/dist/core/i18n/locales/zh-cn/tui-builtin.d.ts.map +1 -0
  220. package/dist/core/i18n/locales/zh-cn/tui-builtin.js +15 -0
  221. package/dist/core/i18n/locales/zh-cn/tui-builtin.js.map +1 -0
  222. package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts +13 -0
  223. package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts.map +1 -0
  224. package/dist/core/i18n/locales/zh-cn/tui-components-misc.js +102 -0
  225. package/dist/core/i18n/locales/zh-cn/tui-components-misc.js.map +1 -0
  226. package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts +12 -0
  227. package/dist/core/i18n/locales/zh-cn/tui-components-selectors.d.ts.map +1 -0
  228. package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js +286 -0
  229. package/dist/core/i18n/locales/zh-cn/tui-components-selectors.js.map +1 -0
  230. package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.d.ts +9 -0
  231. package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.d.ts.map +1 -0
  232. package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.js +79 -0
  233. package/dist/core/i18n/locales/zh-cn/tui-interactive-misc.js.map +1 -0
  234. package/dist/core/i18n/locales/zh-cn/tui-self-owned.d.ts +8 -0
  235. package/dist/core/i18n/locales/zh-cn/tui-self-owned.d.ts.map +1 -0
  236. package/dist/core/i18n/locales/zh-cn/tui-self-owned.js +72 -0
  237. package/dist/core/i18n/locales/zh-cn/tui-self-owned.js.map +1 -0
  238. package/dist/core/keybindings.d.ts +15 -0
  239. package/dist/core/keybindings.d.ts.map +1 -1
  240. package/dist/core/keybindings.js +18 -0
  241. package/dist/core/keybindings.js.map +1 -1
  242. package/dist/core/logger.d.ts.map +1 -1
  243. package/dist/core/logger.js +5 -1
  244. package/dist/core/logger.js.map +1 -1
  245. package/dist/core/model-config.d.ts +0 -1
  246. package/dist/core/model-config.d.ts.map +1 -1
  247. package/dist/core/model-config.js +9 -1
  248. package/dist/core/model-config.js.map +1 -1
  249. package/dist/core/model-registry.d.ts.map +1 -1
  250. package/dist/core/model-registry.js +2 -1
  251. package/dist/core/model-registry.js.map +1 -1
  252. package/dist/core/model-runtime.d.ts.map +1 -1
  253. package/dist/core/model-runtime.js +11 -7
  254. package/dist/core/model-runtime.js.map +1 -1
  255. package/dist/core/package-install-host.d.ts.map +1 -1
  256. package/dist/core/package-install-host.js +4 -3
  257. package/dist/core/package-install-host.js.map +1 -1
  258. package/dist/core/package-manager.d.ts.map +1 -1
  259. package/dist/core/package-manager.js +15 -10
  260. package/dist/core/package-manager.js.map +1 -1
  261. package/dist/core/package-resource-collection.d.ts.map +1 -1
  262. package/dist/core/package-resource-collection.js +2 -1
  263. package/dist/core/package-resource-collection.js.map +1 -1
  264. package/dist/core/package-source.d.ts.map +1 -1
  265. package/dist/core/package-source.js +3 -2
  266. package/dist/core/package-source.js.map +1 -1
  267. package/dist/core/provider-composer.d.ts +2 -2
  268. package/dist/core/provider-composer.d.ts.map +1 -1
  269. package/dist/core/provider-composer.js +29 -21
  270. package/dist/core/provider-composer.js.map +1 -1
  271. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  272. package/dist/core/remote-catalog-provider.js +6 -2
  273. package/dist/core/remote-catalog-provider.js.map +1 -1
  274. package/dist/core/resolve-config-value.d.ts.map +1 -1
  275. package/dist/core/resolve-config-value.js +15 -5
  276. package/dist/core/resolve-config-value.js.map +1 -1
  277. package/dist/core/sdk.d.ts +27 -5
  278. package/dist/core/sdk.d.ts.map +1 -1
  279. package/dist/core/sdk.js +80 -55
  280. package/dist/core/sdk.js.map +1 -1
  281. package/dist/core/session-cwd.d.ts.map +1 -1
  282. package/dist/core/session-cwd.js +5 -2
  283. package/dist/core/session-cwd.js.map +1 -1
  284. package/dist/core/session-export.d.ts.map +1 -1
  285. package/dist/core/session-export.js +2 -1
  286. package/dist/core/session-export.js.map +1 -1
  287. package/dist/core/session-manager.d.ts.map +1 -1
  288. package/dist/core/session-manager.js +39 -29
  289. package/dist/core/session-manager.js.map +1 -1
  290. package/dist/core/session-storage.d.ts.map +1 -1
  291. package/dist/core/session-storage.js +3 -3
  292. package/dist/core/session-storage.js.map +1 -1
  293. package/dist/core/settings-manager.d.ts +20 -20
  294. package/dist/core/settings-manager.d.ts.map +1 -1
  295. package/dist/core/settings-manager.js +47 -59
  296. package/dist/core/settings-manager.js.map +1 -1
  297. package/dist/core/slash-commands.d.ts.map +1 -1
  298. package/dist/core/slash-commands.js +53 -32
  299. package/dist/core/slash-commands.js.map +1 -1
  300. package/dist/core/system-prompt.d.ts.map +1 -1
  301. package/dist/core/system-prompt.js +25 -2
  302. package/dist/core/system-prompt.js.map +1 -1
  303. package/dist/core/tools/bash.d.ts.map +1 -1
  304. package/dist/core/tools/bash.js +11 -7
  305. package/dist/core/tools/bash.js.map +1 -1
  306. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  307. package/dist/core/tools/edit-diff.js +9 -4
  308. package/dist/core/tools/edit-diff.js.map +1 -1
  309. package/dist/core/tools/edit.d.ts.map +1 -1
  310. package/dist/core/tools/edit.js +4 -3
  311. package/dist/core/tools/edit.js.map +1 -1
  312. package/dist/core/tools/index.d.ts.map +1 -1
  313. package/dist/core/tools/index.js +3 -2
  314. package/dist/core/tools/index.js.map +1 -1
  315. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  316. package/dist/core/tools/output-accumulator.js +2 -1
  317. package/dist/core/tools/output-accumulator.js.map +1 -1
  318. package/dist/core/tools/read.d.ts.map +1 -1
  319. package/dist/core/tools/read.js +6 -2
  320. package/dist/core/tools/read.js.map +1 -1
  321. package/dist/core/tools/write.d.ts.map +1 -1
  322. package/dist/core/tools/write.js +2 -1
  323. package/dist/core/tools/write.js.map +1 -1
  324. package/dist/durable/durable-service.d.ts.map +1 -1
  325. package/dist/durable/durable-service.js +25 -18
  326. package/dist/durable/durable-service.js.map +1 -1
  327. package/dist/host/checkpoint-commit.d.ts.map +1 -1
  328. package/dist/host/checkpoint-commit.js +2 -1
  329. package/dist/host/checkpoint-commit.js.map +1 -1
  330. package/dist/host/manual-compaction.d.ts.map +1 -1
  331. package/dist/host/manual-compaction.js +2 -1
  332. package/dist/host/manual-compaction.js.map +1 -1
  333. package/dist/host/output-projection.d.ts +0 -13
  334. package/dist/host/output-projection.d.ts.map +1 -1
  335. package/dist/host/output-projection.js +16 -2
  336. package/dist/host/output-projection.js.map +1 -1
  337. package/dist/host/summary-retry.d.ts.map +1 -1
  338. package/dist/host/summary-retry.js +3 -2
  339. package/dist/host/summary-retry.js.map +1 -1
  340. package/dist/main.d.ts.map +1 -1
  341. package/dist/main.js +97 -60
  342. package/dist/main.js.map +1 -1
  343. package/dist/modes/interactive/components/agents-view.d.ts.map +1 -1
  344. package/dist/modes/interactive/components/agents-view.js +18 -15
  345. package/dist/modes/interactive/components/agents-view.js.map +1 -1
  346. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  347. package/dist/modes/interactive/components/assistant-message.js +6 -5
  348. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  349. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  350. package/dist/modes/interactive/components/bash-execution.js +12 -7
  351. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  352. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  353. package/dist/modes/interactive/components/bordered-loader.js +2 -1
  354. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  355. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  356. package/dist/modes/interactive/components/branch-summary-message.js +6 -5
  357. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  358. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  359. package/dist/modes/interactive/components/compaction-summary-message.js +9 -5
  360. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  361. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  362. package/dist/modes/interactive/components/config-selector.js +18 -15
  363. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  364. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  365. package/dist/modes/interactive/components/custom-entry.js +2 -1
  366. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  367. package/dist/modes/interactive/components/dialog-editor.d.ts.map +1 -1
  368. package/dist/modes/interactive/components/dialog-editor.js +5 -4
  369. package/dist/modes/interactive/components/dialog-editor.js.map +1 -1
  370. package/dist/modes/interactive/components/dialog-input.d.ts.map +1 -1
  371. package/dist/modes/interactive/components/dialog-input.js +2 -1
  372. package/dist/modes/interactive/components/dialog-input.js.map +1 -1
  373. package/dist/modes/interactive/components/dialog-selector.d.ts.map +1 -1
  374. package/dist/modes/interactive/components/dialog-selector.js +4 -3
  375. package/dist/modes/interactive/components/dialog-selector.js.map +1 -1
  376. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  377. package/dist/modes/interactive/components/first-time-setup.js +11 -10
  378. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  379. package/dist/modes/interactive/components/footer.d.ts +0 -2
  380. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  381. package/dist/modes/interactive/components/footer.js +8 -10
  382. package/dist/modes/interactive/components/footer.js.map +1 -1
  383. package/dist/modes/interactive/components/index.d.ts +1 -0
  384. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  385. package/dist/modes/interactive/components/index.js +1 -0
  386. package/dist/modes/interactive/components/index.js.map +1 -1
  387. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  388. package/dist/modes/interactive/components/keybinding-hints.js +3 -2
  389. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  390. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  391. package/dist/modes/interactive/components/login-dialog.js +12 -11
  392. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  393. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  394. package/dist/modes/interactive/components/mermaid.js +6 -2
  395. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  396. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  397. package/dist/modes/interactive/components/model-selector.js +28 -16
  398. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  399. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  400. package/dist/modes/interactive/components/oauth-selector.js +10 -9
  401. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  402. package/dist/modes/interactive/components/plugin-manager-entry.d.ts.map +1 -1
  403. package/dist/modes/interactive/components/plugin-manager-entry.js +22 -13
  404. package/dist/modes/interactive/components/plugin-manager-entry.js.map +1 -1
  405. package/dist/modes/interactive/components/plugin-selection-entry.d.ts.map +1 -1
  406. package/dist/modes/interactive/components/plugin-selection-entry.js +27 -12
  407. package/dist/modes/interactive/components/plugin-selection-entry.js.map +1 -1
  408. package/dist/modes/interactive/components/queue-manager-selector.d.ts +60 -0
  409. package/dist/modes/interactive/components/queue-manager-selector.d.ts.map +1 -0
  410. package/dist/modes/interactive/components/queue-manager-selector.js +166 -0
  411. package/dist/modes/interactive/components/queue-manager-selector.js.map +1 -0
  412. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  413. package/dist/modes/interactive/components/scoped-models-selector.js +16 -14
  414. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  415. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  416. package/dist/modes/interactive/components/session-selector.js +43 -31
  417. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  418. package/dist/modes/interactive/components/settings-selector.d.ts +4 -6
  419. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  420. package/dist/modes/interactive/components/settings-selector.js +115 -120
  421. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  422. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  423. package/dist/modes/interactive/components/settings-submenu.js +5 -4
  424. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  425. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  426. package/dist/modes/interactive/components/show-images-selector.js +3 -2
  427. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  428. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  429. package/dist/modes/interactive/components/skill-invocation-message.js +4 -3
  430. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  431. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  432. package/dist/modes/interactive/components/status-indicator.js +14 -5
  433. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  434. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  435. package/dist/modes/interactive/components/theme-selector.js +2 -1
  436. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  437. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  438. package/dist/modes/interactive/components/thinking-selector.js +11 -4
  439. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  440. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  441. package/dist/modes/interactive/components/tool-execution.js +8 -3
  442. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  443. package/dist/modes/interactive/components/tree-list.d.ts.map +1 -1
  444. package/dist/modes/interactive/components/tree-list.js +7 -6
  445. package/dist/modes/interactive/components/tree-list.js.map +1 -1
  446. package/dist/modes/interactive/components/tree-render.d.ts.map +1 -1
  447. package/dist/modes/interactive/components/tree-render.js +28 -23
  448. package/dist/modes/interactive/components/tree-render.js.map +1 -1
  449. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  450. package/dist/modes/interactive/components/tree-selector.js +9 -7
  451. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  452. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  453. package/dist/modes/interactive/components/user-message-selector.js +5 -4
  454. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  455. package/dist/modes/interactive/components/workflow-view.d.ts.map +1 -1
  456. package/dist/modes/interactive/components/workflow-view.js +36 -21
  457. package/dist/modes/interactive/components/workflow-view.js.map +1 -1
  458. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  459. package/dist/modes/interactive/external-editor.js +2 -1
  460. package/dist/modes/interactive/external-editor.js.map +1 -1
  461. package/dist/modes/interactive/interactive-auth.d.ts.map +1 -1
  462. package/dist/modes/interactive/interactive-auth.js +71 -40
  463. package/dist/modes/interactive/interactive-auth.js.map +1 -1
  464. package/dist/modes/interactive/interactive-commands.d.ts +1 -0
  465. package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
  466. package/dist/modes/interactive/interactive-commands.js +3 -0
  467. package/dist/modes/interactive/interactive-commands.js.map +1 -1
  468. package/dist/modes/interactive/interactive-dialog-ui.d.ts.map +1 -1
  469. package/dist/modes/interactive/interactive-dialog-ui.js +5 -5
  470. package/dist/modes/interactive/interactive-dialog-ui.js.map +1 -1
  471. package/dist/modes/interactive/interactive-format.d.ts.map +1 -1
  472. package/dist/modes/interactive/interactive-format.js +34 -18
  473. package/dist/modes/interactive/interactive-format.js.map +1 -1
  474. package/dist/modes/interactive/interactive-helpers.d.ts.map +1 -1
  475. package/dist/modes/interactive/interactive-helpers.js +7 -2
  476. package/dist/modes/interactive/interactive-helpers.js.map +1 -1
  477. package/dist/modes/interactive/interactive-mode.d.ts +4 -2
  478. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  479. package/dist/modes/interactive/interactive-mode.js +350 -279
  480. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  481. package/dist/modes/interactive/interactive-selectors.d.ts +9 -0
  482. package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
  483. package/dist/modes/interactive/interactive-selectors.js +79 -25
  484. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  485. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  486. package/dist/modes/interactive/theme/theme-controller.js +5 -1
  487. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  488. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  489. package/dist/modes/interactive/theme/theme.js +26 -23
  490. package/dist/modes/interactive/theme/theme.js.map +1 -1
  491. package/dist/modes/json-event.d.ts.map +1 -1
  492. package/dist/modes/json-event.js +3 -2
  493. package/dist/modes/json-event.js.map +1 -1
  494. package/dist/modes/print-mode.d.ts.map +1 -1
  495. package/dist/modes/print-mode.js +3 -2
  496. package/dist/modes/print-mode.js.map +1 -1
  497. package/dist/modes/rpc/rpc-client.d.ts +0 -8
  498. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  499. package/dist/modes/rpc/rpc-client.js +3 -14
  500. package/dist/modes/rpc/rpc-client.js.map +1 -1
  501. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  502. package/dist/modes/rpc/rpc-mode.js +0 -9
  503. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  504. package/dist/modes/rpc/rpc-types.d.ts +0 -19
  505. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  506. package/dist/modes/rpc/rpc-types.js.map +1 -1
  507. package/dist/package-manager-cli.d.ts.map +1 -1
  508. package/dist/package-manager-cli.js +28 -13
  509. package/dist/package-manager-cli.js.map +1 -1
  510. package/dist/plugins/ecosystem/catalog.d.ts.map +1 -1
  511. package/dist/plugins/ecosystem/catalog.js +3 -2
  512. package/dist/plugins/ecosystem/catalog.js.map +1 -1
  513. package/dist/plugins/ecosystem/cli.d.ts.map +1 -1
  514. package/dist/plugins/ecosystem/cli.js +2 -1
  515. package/dist/plugins/ecosystem/cli.js.map +1 -1
  516. package/dist/plugins/ecosystem/default-plugin-market.d.ts.map +1 -1
  517. package/dist/plugins/ecosystem/default-plugin-market.js +3 -2
  518. package/dist/plugins/ecosystem/default-plugin-market.js.map +1 -1
  519. package/dist/plugins/ecosystem/distribution.d.ts.map +1 -1
  520. package/dist/plugins/ecosystem/distribution.js +2 -1
  521. package/dist/plugins/ecosystem/distribution.js.map +1 -1
  522. package/dist/plugins/ecosystem/installer.d.ts.map +1 -1
  523. package/dist/plugins/ecosystem/installer.js +3 -2
  524. package/dist/plugins/ecosystem/installer.js.map +1 -1
  525. package/dist/plugins/ecosystem/node-disk-registry-source.d.ts.map +1 -1
  526. package/dist/plugins/ecosystem/node-disk-registry-source.js +20 -17
  527. package/dist/plugins/ecosystem/node-disk-registry-source.js.map +1 -1
  528. package/dist/plugins/ecosystem/node-distribution-host.d.ts.map +1 -1
  529. package/dist/plugins/ecosystem/node-distribution-host.js +35 -34
  530. package/dist/plugins/ecosystem/node-distribution-host.js.map +1 -1
  531. package/dist/plugins/ecosystem/node-npm-registry-source.d.ts.map +1 -1
  532. package/dist/plugins/ecosystem/node-npm-registry-source.js +35 -34
  533. package/dist/plugins/ecosystem/node-npm-registry-source.js.map +1 -1
  534. package/dist/plugins/ecosystem/node-package-install-host.d.ts.map +1 -1
  535. package/dist/plugins/ecosystem/node-package-install-host.js +9 -8
  536. package/dist/plugins/ecosystem/node-package-install-host.js.map +1 -1
  537. package/dist/plugins/ecosystem/node-package-install-persistence.d.ts.map +1 -1
  538. package/dist/plugins/ecosystem/node-package-install-persistence.js +4 -3
  539. package/dist/plugins/ecosystem/node-package-install-persistence.js.map +1 -1
  540. package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts +9 -2
  541. package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
  542. package/dist/plugins/ecosystem/node-plugin-bootstrap.js +44 -5
  543. package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
  544. package/dist/plugins/ecosystem/node-plugin-trust-root.d.ts.map +1 -1
  545. package/dist/plugins/ecosystem/node-plugin-trust-root.js +10 -9
  546. package/dist/plugins/ecosystem/node-plugin-trust-root.js.map +1 -1
  547. package/dist/plugins/ecosystem/node-registry-source.d.ts.map +1 -1
  548. package/dist/plugins/ecosystem/node-registry-source.js +31 -30
  549. package/dist/plugins/ecosystem/node-registry-source.js.map +1 -1
  550. package/dist/plugins/ecosystem/node-release-package-source.d.ts.map +1 -1
  551. package/dist/plugins/ecosystem/node-release-package-source.js +30 -29
  552. package/dist/plugins/ecosystem/node-release-package-source.js.map +1 -1
  553. package/dist/plugins/ecosystem/node-tar-writer.d.ts.map +1 -1
  554. package/dist/plugins/ecosystem/node-tar-writer.js +11 -10
  555. package/dist/plugins/ecosystem/node-tar-writer.js.map +1 -1
  556. package/dist/plugins/ecosystem/node-url-package-source.d.ts.map +1 -1
  557. package/dist/plugins/ecosystem/node-url-package-source.js +21 -20
  558. package/dist/plugins/ecosystem/node-url-package-source.js.map +1 -1
  559. package/dist/plugins/ecosystem/plugin-acquisition.d.ts.map +1 -1
  560. package/dist/plugins/ecosystem/plugin-acquisition.js +3 -2
  561. package/dist/plugins/ecosystem/plugin-acquisition.js.map +1 -1
  562. package/dist/plugins/ecosystem/plugin-bootstrap.d.ts +9 -1
  563. package/dist/plugins/ecosystem/plugin-bootstrap.d.ts.map +1 -1
  564. package/dist/plugins/ecosystem/plugin-bootstrap.js +5 -0
  565. package/dist/plugins/ecosystem/plugin-bootstrap.js.map +1 -1
  566. package/dist/plugins/ecosystem/registry-cli-adapter.d.ts.map +1 -1
  567. package/dist/plugins/ecosystem/registry-cli-adapter.js +2 -1
  568. package/dist/plugins/ecosystem/registry-cli-adapter.js.map +1 -1
  569. package/dist/plugins/ecosystem/registry.d.ts.map +1 -1
  570. package/dist/plugins/ecosystem/registry.js +35 -32
  571. package/dist/plugins/ecosystem/registry.js.map +1 -1
  572. package/dist/plugins/ecosystem/resolver.d.ts.map +1 -1
  573. package/dist/plugins/ecosystem/resolver.js +3 -2
  574. package/dist/plugins/ecosystem/resolver.js.map +1 -1
  575. package/dist/plugins/ecosystem/selection-store.d.ts.map +1 -1
  576. package/dist/plugins/ecosystem/selection-store.js +11 -10
  577. package/dist/plugins/ecosystem/selection-store.js.map +1 -1
  578. package/dist/plugins/ecosystem/selection.d.ts.map +1 -1
  579. package/dist/plugins/ecosystem/selection.js +8 -7
  580. package/dist/plugins/ecosystem/selection.js.map +1 -1
  581. package/dist/plugins/ecosystem/state.d.ts.map +1 -1
  582. package/dist/plugins/ecosystem/state.js +24 -23
  583. package/dist/plugins/ecosystem/state.js.map +1 -1
  584. package/dist/plugins/ecosystem/updates.d.ts.map +1 -1
  585. package/dist/plugins/ecosystem/updates.js +5 -4
  586. package/dist/plugins/ecosystem/updates.js.map +1 -1
  587. package/dist/plugins/mcp-http.d.ts +0 -17
  588. package/dist/plugins/mcp-http.d.ts.map +1 -1
  589. package/dist/plugins/mcp-http.js +30 -7
  590. package/dist/plugins/mcp-http.js.map +1 -1
  591. package/dist/plugins/plugin-supervisor.d.ts.map +1 -1
  592. package/dist/plugins/plugin-supervisor.js +19 -1
  593. package/dist/plugins/plugin-supervisor.js.map +1 -1
  594. package/dist/profile/first-roles.d.ts.map +1 -1
  595. package/dist/profile/first-roles.js +10 -1
  596. package/dist/profile/first-roles.js.map +1 -1
  597. package/dist/profile/goal-plugin.d.ts.map +1 -1
  598. package/dist/profile/goal-plugin.js +24 -5
  599. package/dist/profile/goal-plugin.js.map +1 -1
  600. package/dist/profile/identity.d.ts.map +1 -1
  601. package/dist/profile/identity.js +7 -6
  602. package/dist/profile/identity.js.map +1 -1
  603. package/dist/profile/lock.d.ts.map +1 -1
  604. package/dist/profile/lock.js +15 -1
  605. package/dist/profile/lock.js.map +1 -1
  606. package/dist/profile/plan-plugin.d.ts.map +1 -1
  607. package/dist/profile/plan-plugin.js +26 -13
  608. package/dist/profile/plan-plugin.js.map +1 -1
  609. package/dist/profile/plugin-profiles.d.ts.map +1 -1
  610. package/dist/profile/plugin-profiles.js +2 -1
  611. package/dist/profile/plugin-profiles.js.map +1 -1
  612. package/dist/profile/policy-manifest.d.ts.map +1 -1
  613. package/dist/profile/policy-manifest.js +5 -4
  614. package/dist/profile/policy-manifest.js.map +1 -1
  615. package/dist/profile/profile-registry.d.ts +0 -12
  616. package/dist/profile/profile-registry.d.ts.map +1 -1
  617. package/dist/profile/profile-registry.js +14 -1
  618. package/dist/profile/profile-registry.js.map +1 -1
  619. package/dist/profile/role-catalog.d.ts +0 -1
  620. package/dist/profile/role-catalog.d.ts.map +1 -1
  621. package/dist/profile/role-catalog.js +17 -15
  622. package/dist/profile/role-catalog.js.map +1 -1
  623. package/dist/profile/role-orchestrator.d.ts.map +1 -1
  624. package/dist/profile/role-orchestrator.js +8 -7
  625. package/dist/profile/role-orchestrator.js.map +1 -1
  626. package/dist/profile/role-runner.d.ts.map +1 -1
  627. package/dist/profile/role-runner.js +3 -2
  628. package/dist/profile/role-runner.js.map +1 -1
  629. package/dist/profile/root-facade.d.ts.map +1 -1
  630. package/dist/profile/root-facade.js +2 -1
  631. package/dist/profile/root-facade.js.map +1 -1
  632. package/dist/profile/skill-discovery-wiring.d.ts.map +1 -1
  633. package/dist/profile/skill-discovery-wiring.js +7 -2
  634. package/dist/profile/skill-discovery-wiring.js.map +1 -1
  635. package/dist/profile/state-store.d.ts.map +1 -1
  636. package/dist/profile/state-store.js +13 -9
  637. package/dist/profile/state-store.js.map +1 -1
  638. package/dist/profile/todo-plugin.d.ts.map +1 -1
  639. package/dist/profile/todo-plugin.js +9 -4
  640. package/dist/profile/todo-plugin.js.map +1 -1
  641. package/dist/profiles/builtin-suites.d.ts +13 -6
  642. package/dist/profiles/builtin-suites.d.ts.map +1 -1
  643. package/dist/profiles/builtin-suites.js +15 -6
  644. package/dist/profiles/builtin-suites.js.map +1 -1
  645. package/dist/profiles/suite-loader.d.ts +25 -1
  646. package/dist/profiles/suite-loader.d.ts.map +1 -1
  647. package/dist/profiles/suite-loader.js +34 -9
  648. package/dist/profiles/suite-loader.js.map +1 -1
  649. package/dist/remote/server-entry.d.ts.map +1 -1
  650. package/dist/remote/server-entry.js +3 -2
  651. package/dist/remote/server-entry.js.map +1 -1
  652. package/dist/remote/session-source.d.ts.map +1 -1
  653. package/dist/remote/session-source.js +8 -4
  654. package/dist/remote/session-source.js.map +1 -1
  655. package/dist/share/session-share.d.ts.map +1 -1
  656. package/dist/share/session-share.js +14 -2
  657. package/dist/share/session-share.js.map +1 -1
  658. package/dist/testing/plugin-testkit.d.ts.map +1 -1
  659. package/dist/testing/plugin-testkit.js +4 -3
  660. package/dist/testing/plugin-testkit.js.map +1 -1
  661. package/dist/testing/runtime-delivery-queue.d.ts.map +1 -1
  662. package/dist/testing/runtime-delivery-queue.js +2 -1
  663. package/dist/testing/runtime-delivery-queue.js.map +1 -1
  664. package/dist/testing/session-plugin-testkit.d.ts.map +1 -1
  665. package/dist/testing/session-plugin-testkit.js +10 -7
  666. package/dist/testing/session-plugin-testkit.js.map +1 -1
  667. package/dist/utils/ansi.d.ts.map +1 -1
  668. package/dist/utils/ansi.js +2 -1
  669. package/dist/utils/ansi.js.map +1 -1
  670. package/dist/utils/clipboard.d.ts.map +1 -1
  671. package/dist/utils/clipboard.js +7 -6
  672. package/dist/utils/clipboard.js.map +1 -1
  673. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  674. package/dist/utils/image-resize-worker.js +3 -2
  675. package/dist/utils/image-resize-worker.js.map +1 -1
  676. package/dist/utils/photon.d.ts +2 -2
  677. package/dist/utils/photon.d.ts.map +1 -1
  678. package/dist/utils/photon.js +2 -2
  679. package/dist/utils/photon.js.map +1 -1
  680. package/dist/utils/shell.d.ts.map +1 -1
  681. package/dist/utils/shell.js +9 -8
  682. package/dist/utils/shell.js.map +1 -1
  683. package/dist/utils/tools-manager.d.ts.map +1 -1
  684. package/dist/utils/tools-manager.js +23 -13
  685. package/dist/utils/tools-manager.js.map +1 -1
  686. package/dist/utils/version-check.d.ts.map +1 -1
  687. package/dist/utils/version-check.js +5 -1
  688. package/dist/utils/version-check.js.map +1 -1
  689. package/docs/compaction.md +1 -3
  690. package/docs/docs.json +4 -0
  691. package/docs/index.md +1 -0
  692. package/docs/keybindings.md +3 -0
  693. package/docs/mcp.md +103 -0
  694. package/docs/models.md +14 -22
  695. package/docs/providers.md +0 -1
  696. package/docs/quickstart.md +1 -1
  697. package/docs/rpc.md +1 -26
  698. package/docs/sdk.md +4 -6
  699. package/docs/settings.md +10 -12
  700. package/docs/skills.md +1 -9
  701. package/docs/terminal-setup.md +2 -3
  702. package/docs/usage.md +7 -6
  703. package/examples/extensions/with-deps/package-lock.json +2 -2
  704. package/examples/extensions/with-deps/package.json +1 -1
  705. package/examples/extensions/with-deps/plugin.json +1 -1
  706. package/examples/sdk/10-settings.ts +2 -4
  707. package/examples/sdk/12-full-control.ts +1 -2
  708. package/package.json +1 -3
  709. package/dist/bundle/chunks/chunk-EALJ5DDX.js +0 -1452
  710. package/dist/core/extensions/microcompact.d.ts +0 -80
  711. package/dist/core/extensions/microcompact.d.ts.map +0 -1
  712. package/dist/core/extensions/microcompact.js +0 -134
  713. package/dist/core/extensions/microcompact.js.map +0 -1
  714. package/dist/server/create-harness.d.ts +0 -26
  715. package/dist/server/create-harness.d.ts.map +0 -1
  716. package/dist/server/create-harness.js +0 -106
  717. package/dist/server/create-harness.js.map +0 -1
@@ -3,6 +3,7 @@ import { createReadStream } from "node:fs";
3
3
  import { mkdir, mkdtemp, open, rename, rm } from "node:fs/promises";
4
4
  import { tmpdir } from "node:os";
5
5
  import { isAbsolute, join } from "node:path";
6
+ import { t } from "../../core/i18n/index.js";
6
7
  import { createPluginDistributionV1 } from "./distribution.js";
7
8
  import { createNodePluginTrustRootV1 } from "./node-plugin-trust-root.js";
8
9
  const NODE_DISTRIBUTION_HOST_VERSION_V1 = 1;
@@ -12,20 +13,20 @@ const DEFAULT_REDIRECTS_V1 = 3;
12
13
  const MAX_REDIRECTS_V1 = 5;
13
14
  const REDIRECT_STATUS = new Set([301, 302, 303, 307, 308]);
14
15
  function cancelledRequestError() {
15
- const error = new Error("plugin request was cancelled");
16
+ const error = new Error(t("plugin request was cancelled"));
16
17
  error.name = "AbortError";
17
18
  return error;
18
19
  }
19
20
  function throwIfRequestCancelled(request) {
20
21
  if (request.timedOut())
21
- throw new Error("plugin request timed out");
22
+ throw new Error(t("plugin request timed out"));
22
23
  if (request.signal.aborted)
23
24
  throw cancelledRequestError();
24
25
  }
25
26
  function boundedPositive(value, fallback, maximum, label) {
26
27
  const result = value ?? fallback;
27
28
  if (!Number.isSafeInteger(result) || result <= 0 || result > maximum)
28
- throw new Error(`${label} must be a positive integer at most ${maximum}`);
29
+ throw new Error(t("{label} must be a positive integer at most {maximum}", { label, maximum }));
29
30
  return result;
30
31
  }
31
32
  function allowedOrigin(value) {
@@ -34,12 +35,12 @@ function allowedOrigin(value) {
34
35
  parsed = new URL(value);
35
36
  }
36
37
  catch {
37
- throw new Error("allowed origin is invalid");
38
+ throw new Error(t("allowed origin is invalid"));
38
39
  }
39
40
  if ((parsed.protocol !== "http:" && parsed.protocol !== "https:") || parsed.username || parsed.password)
40
- throw new Error("allowed origin must be an http(s) origin");
41
+ throw new Error(t("allowed origin must be an http(s) origin"));
41
42
  if (parsed.pathname !== "/" || parsed.search !== "" || parsed.hash !== "")
42
- throw new Error("allowed origin must not include a path or query");
43
+ throw new Error(t("allowed origin must not include a path or query"));
43
44
  return parsed.origin;
44
45
  }
45
46
  function requestUrl(value, origins) {
@@ -48,12 +49,12 @@ function requestUrl(value, origins) {
48
49
  parsed = new URL(value);
49
50
  }
50
51
  catch {
51
- throw new Error("plugin source URL is invalid");
52
+ throw new Error(t("plugin source URL is invalid"));
52
53
  }
53
54
  if ((parsed.protocol !== "http:" && parsed.protocol !== "https:") || parsed.username || parsed.password)
54
- throw new Error("plugin source URL must use http(s) without credentials");
55
+ throw new Error(t("plugin source URL must use http(s) without credentials"));
55
56
  if (!origins.has(parsed.origin))
56
- throw new Error("plugin source origin is not allowed");
57
+ throw new Error(t("plugin source origin is not allowed"));
57
58
  return parsed;
58
59
  }
59
60
  function requestSignal(parent, timeoutMs) {
@@ -82,10 +83,10 @@ function contentLength(response) {
82
83
  if (value === null)
83
84
  return undefined;
84
85
  if (!/^\d+$/u.test(value))
85
- throw new Error("plugin response content length is invalid");
86
+ throw new Error(t("plugin response content length is invalid"));
86
87
  const result = Number(value);
87
88
  if (!Number.isSafeInteger(result))
88
- throw new Error("plugin response content length is invalid");
89
+ throw new Error(t("plugin response content length is invalid"));
89
90
  return result;
90
91
  }
91
92
  function contentType(response) {
@@ -97,10 +98,10 @@ function contentType(response) {
97
98
  function assertResponseMetadata(response, descriptor) {
98
99
  const length = contentLength(response);
99
100
  if (length !== descriptor.sizeBytes)
100
- throw new Error("plugin response size mismatch");
101
+ throw new Error(t("plugin response size mismatch"));
101
102
  const mediaType = contentType(response);
102
103
  if (mediaType !== descriptor.mediaType.toLowerCase())
103
- throw new Error("plugin response media type mismatch");
104
+ throw new Error(t("plugin response media type mismatch"));
104
105
  }
105
106
  async function cancelBody(response) {
106
107
  if (response.body !== null)
@@ -118,7 +119,7 @@ function expectedDigest(value) {
118
119
  return { algorithm: "sha256", hex: value.toLowerCase() };
119
120
  if (/^[0-9a-f]{128}$/iu.test(value))
120
121
  return { algorithm: "sha512", hex: value.toLowerCase() };
121
- throw new Error("plugin artifact digest algorithm is unsupported");
122
+ throw new Error(t("plugin artifact digest algorithm is unsupported"));
122
123
  }
123
124
  function metadataFromDescriptor(descriptor) {
124
125
  return {
@@ -149,7 +150,7 @@ async function writeFully(file, chunk) {
149
150
  while (offset < chunk.byteLength) {
150
151
  const result = await file.write(chunk, offset, chunk.byteLength - offset, null);
151
152
  if (result.bytesWritten <= 0)
152
- throw new Error("plugin artifact file write failed");
153
+ throw new Error(t("plugin artifact file write failed"));
153
154
  offset += result.bytesWritten;
154
155
  }
155
156
  }
@@ -161,20 +162,20 @@ async function writeFully(file, chunk) {
161
162
  export async function createNodeHttpPluginDistributionHostV1(options) {
162
163
  const transport = options.fetch ?? globalThis.fetch;
163
164
  if (typeof transport !== "function")
164
- throw new Error("Node fetch is unavailable");
165
+ throw new Error(t("Node fetch is unavailable"));
165
166
  if (!Array.isArray(options.allowedOrigins) || options.allowedOrigins.length === 0)
166
- throw new Error("at least one allowed origin is required");
167
+ throw new Error(t("at least one allowed origin is required"));
167
168
  const origins = new Set(options.allowedOrigins.map(allowedOrigin));
168
169
  const timeoutMs = boundedPositive(options.requestTimeoutMs, DEFAULT_TIMEOUT_MS_V1, MAX_TIMEOUT_MS_V1, "requestTimeoutMs");
169
170
  const maxRedirects = options.maxRedirects ?? DEFAULT_REDIRECTS_V1;
170
171
  if (!Number.isSafeInteger(maxRedirects) || maxRedirects < 0 || maxRedirects > MAX_REDIRECTS_V1)
171
- throw new Error(`maxRedirects must be an integer between 0 and ${MAX_REDIRECTS_V1}`);
172
+ throw new Error(t("maxRedirects must be an integer between 0 and {max}", { max: MAX_REDIRECTS_V1 }));
172
173
  const userAgent = options.userAgent ?? "agent-forge-plugin-distribution/1";
173
174
  if (userAgent.length === 0 || userAgent.length > 256 || /[\r\n]/u.test(userAgent))
174
- throw new Error("userAgent is invalid");
175
+ throw new Error(t("userAgent is invalid"));
175
176
  const configuredDirectory = options.artifactDirectory;
176
177
  if (configuredDirectory !== undefined && !isAbsolute(configuredDirectory))
177
- throw new Error("artifactDirectory must be absolute");
178
+ throw new Error(t("artifactDirectory must be absolute"));
178
179
  const baseDirectoryPromise = configuredDirectory === undefined
179
180
  ? mkdtemp(join(tmpdir(), "agent-forge-plugin-distribution-"))
180
181
  : (async () => {
@@ -188,7 +189,7 @@ export async function createNodeHttpPluginDistributionHostV1(options) {
188
189
  let closed = false;
189
190
  const assertOpen = () => {
190
191
  if (closed)
191
- throw new Error("plugin distribution host is closed");
192
+ throw new Error(t("plugin distribution host is closed"));
192
193
  };
193
194
  const beginOperation = () => {
194
195
  assertOpen();
@@ -237,7 +238,7 @@ export async function createNodeHttpPluginDistributionHostV1(options) {
237
238
  await cancelBody(response);
238
239
  request.cleanup();
239
240
  if (location === null || redirect >= maxRedirects)
240
- throw new Error("plugin redirect limit exceeded");
241
+ throw new Error(t("plugin redirect limit exceeded"));
241
242
  current = requestUrl(new URL(location, current).toString(), origins);
242
243
  }
243
244
  };
@@ -247,7 +248,7 @@ export async function createNodeHttpPluginDistributionHostV1(options) {
247
248
  const { response, request } = await fetchResponse(input.descriptor.source, "HEAD", input.signal, operation.signal);
248
249
  try {
249
250
  if (response.status < 200 || response.status >= 300)
250
- throw new Error("plugin metadata request failed");
251
+ throw new Error(t("plugin metadata request failed"));
251
252
  assertResponseMetadata(response, input.descriptor);
252
253
  return metadataFromDescriptor(input.descriptor);
253
254
  }
@@ -271,10 +272,10 @@ export async function createNodeHttpPluginDistributionHostV1(options) {
271
272
  let file;
272
273
  try {
273
274
  if (response.status < 200 || response.status >= 300)
274
- throw new Error("plugin artifact request failed");
275
+ throw new Error(t("plugin artifact request failed"));
275
276
  assertResponseMetadata(response, input.descriptor);
276
277
  if (response.body === null)
277
- throw new Error("plugin artifact response has no body");
278
+ throw new Error(t("plugin artifact response has no body"));
278
279
  const directory = await baseDirectoryPromise;
279
280
  temporaryPath = join(directory, `.partial-${randomUUID()}`);
280
281
  finalPath = join(directory, `artifact-${randomUUID()}`);
@@ -291,7 +292,7 @@ export async function createNodeHttpPluginDistributionHostV1(options) {
291
292
  const chunk = item.value;
292
293
  total += chunk.byteLength;
293
294
  if (total > input.descriptor.sizeBytes)
294
- throw new Error("plugin artifact exceeds its size limit");
295
+ throw new Error(t("plugin artifact exceeds its size limit"));
295
296
  hash.update(chunk);
296
297
  await writeFully(file, chunk);
297
298
  }
@@ -301,9 +302,9 @@ export async function createNodeHttpPluginDistributionHostV1(options) {
301
302
  }
302
303
  throwIfRequestCancelled(request);
303
304
  if (total !== input.descriptor.sizeBytes)
304
- throw new Error("plugin artifact size mismatch");
305
+ throw new Error(t("plugin artifact size mismatch"));
305
306
  if (hash.digest("hex") !== digest.hex)
306
- throw new Error("plugin artifact digest mismatch");
307
+ throw new Error(t("plugin artifact digest mismatch"));
307
308
  await file.close();
308
309
  file = undefined;
309
310
  await rename(temporaryPath, finalPath);
@@ -340,12 +341,12 @@ export async function createNodeHttpPluginDistributionHostV1(options) {
340
341
  const releaseArtifact = async (input) => {
341
342
  assertOpen();
342
343
  if (input.signal?.aborted)
343
- throw new Error("plugin artifact release was cancelled");
344
+ throw new Error(t("plugin artifact release was cancelled"));
344
345
  const record = artifacts.get(input.artifact.artifactRef);
345
346
  if (record === undefined)
346
- throw new Error("plugin artifact reference is unknown");
347
+ throw new Error(t("plugin artifact reference is unknown"));
347
348
  if (record.readers > 0)
348
- throw new Error("plugin artifact is still being read");
349
+ throw new Error(t("plugin artifact is still being read"));
349
350
  await rm(record.path, { force: false });
350
351
  artifacts.delete(input.artifact.artifactRef);
351
352
  };
@@ -356,10 +357,10 @@ export async function createNodeHttpPluginDistributionHostV1(options) {
356
357
  const abort = () => stream?.destroy(new Error("plugin artifact read was cancelled"));
357
358
  try {
358
359
  if (input.signal?.aborted)
359
- throw new Error("plugin artifact read was cancelled");
360
+ throw new Error(t("plugin artifact read was cancelled"));
360
361
  const record = artifacts.get(input.artifact.artifactRef);
361
362
  if (record === undefined || !artifactMatchesDescriptor(input.artifact, record.descriptor))
362
- throw new Error("plugin artifact reference is unknown");
363
+ throw new Error(t("plugin artifact reference is unknown"));
363
364
  record.readers += 1;
364
365
  acquiredRecord = record;
365
366
  stream = createReadStream(record.path, { highWaterMark: 64 * 1024 });
@@ -367,7 +368,7 @@ export async function createNodeHttpPluginDistributionHostV1(options) {
367
368
  operation.signal.addEventListener("abort", abort, { once: true });
368
369
  for await (const chunk of stream) {
369
370
  if (input.signal?.aborted || operation.signal.aborted)
370
- throw new Error("plugin artifact read was cancelled");
371
+ throw new Error(t("plugin artifact read was cancelled"));
371
372
  yield new Uint8Array(chunk);
372
373
  }
373
374
  }
@@ -1 +1 @@
1
- {"version":3,"file":"node-distribution-host.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-distribution-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAS7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAqC,MAAM,6BAA6B,CAAC;AAE7G,MAAM,iCAAiC,GAAG,CAAU,CAAC;AACrD,MAAM,qBAAqB,GAAG,MAAM,CAAC;AACrC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAClC,MA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2BAA2B,CAAC,EAAE,GAAG,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;QAC3E,MAAM,YAAY,GAAG,0BAA0B,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;QAC3F,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC1C,MAAM,KAAK,CAAC;IACb,CAAC;AAAA,CACD","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { createReadStream } from \"node:fs\";\nimport { mkdir, mkdtemp, open, rename, rm } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { isAbsolute, join } from \"node:path\";\nimport type {\n\tPluginDistributionArtifactHandleV1,\n\tPluginDistributionArtifactV1,\n\tPluginDistributionDescriptorV1,\n\tPluginDistributionHostV1,\n\tPluginDistributionMetadataV1,\n\tPluginDistributionV1,\n} from \"./distribution.ts\";\nimport { createPluginDistributionV1 } from \"./distribution.ts\";\nimport { createNodePluginTrustRootV1, type NodePluginTrustRootOptionsV1 } from \"./node-plugin-trust-root.ts\";\n\nconst NODE_DISTRIBUTION_HOST_VERSION_V1 = 1 as const;\nconst DEFAULT_TIMEOUT_MS_V1 = 30_000;\nconst MAX_TIMEOUT_MS_V1 = 120_000;\nconst DEFAULT_REDIRECTS_V1 = 3;\nconst MAX_REDIRECTS_V1 = 5;\nconst REDIRECT_STATUS = new Set([301, 302, 303, 307, 308]);\n\nexport interface NodeHttpPluginDistributionHostOptionsV1 {\n\t/** Real `fetch` or a deterministic replacement for tests. */\n\treadonly fetch?: typeof globalThis.fetch;\n\t/** Exact `http(s)` origins. An empty allowlist is rejected. */\n\treadonly allowedOrigins: readonly string[];\n\t/** Optional host-owned directory. It is never returned as an artifact reference. */\n\treadonly artifactDirectory?: string;\n\treadonly requestTimeoutMs?: number;\n\treadonly maxRedirects?: number;\n\treadonly userAgent?: string;\n}\n\nexport interface NodeHttpPluginDistributionHostV1 {\n\treadonly version: typeof NODE_DISTRIBUTION_HOST_VERSION_V1;\n\treadonly host: PluginDistributionHostV1;\n\t/**\n\t * Private Node-host reader for an installer that shares this host instance.\n\t * It is not part of the model-facing distribution contract and never exposes\n\t * a file path. The caller must consume it before releasing the artifact.\n\t */\n\treadonly openArtifact: (input: {\n\t\treadonly artifact: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => AsyncIterable<Uint8Array>;\n\t/** Remove all artifacts owned by this host instance. */\n\treadonly close: () => Promise<void>;\n}\n\n/**\n * Explicitly composed Node distribution stack. The caller supplies the trust\n * root; no key or network origin is discovered implicitly.\n */\nexport interface NodeHttpPluginDistributionStackOptionsV1 extends NodeHttpPluginDistributionHostOptionsV1 {\n\treadonly trustRoot: NodePluginTrustRootOptionsV1;\n\t/** Shared clock for descriptor expiry and trust-key validity. */\n\treadonly now?: () => number;\n}\n\nexport interface NodeHttpPluginDistributionStackV1 extends NodeHttpPluginDistributionHostV1 {\n\treadonly distribution: PluginDistributionV1;\n}\n\ninterface ArtifactRecord {\n\treadonly path: string;\n\treadonly descriptor: PluginDistributionDescriptorV1;\n\treaders: number;\n}\n\ninterface RequestSignal {\n\treadonly signal: AbortSignal;\n\treadonly timedOut: () => boolean;\n\treadonly cleanup: () => void;\n}\n\nfunction cancelledRequestError(): Error {\n\tconst error = new Error(\"plugin request was cancelled\");\n\terror.name = \"AbortError\";\n\treturn error;\n}\n\nfunction throwIfRequestCancelled(request: RequestSignal): void {\n\tif (request.timedOut()) throw new Error(\"plugin request timed out\");\n\tif (request.signal.aborted) throw cancelledRequestError();\n}\n\nfunction boundedPositive(value: number | undefined, fallback: number, maximum: number, label: string): number {\n\tconst result = value ?? fallback;\n\tif (!Number.isSafeInteger(result) || result <= 0 || result > maximum)\n\t\tthrow new Error(`${label} must be a positive integer at most ${maximum}`);\n\treturn result;\n}\n\nfunction allowedOrigin(value: string): string {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new Error(\"allowed origin is invalid\");\n\t}\n\tif ((parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") || parsed.username || parsed.password)\n\t\tthrow new Error(\"allowed origin must be an http(s) origin\");\n\tif (parsed.pathname !== \"/\" || parsed.search !== \"\" || parsed.hash !== \"\")\n\t\tthrow new Error(\"allowed origin must not include a path or query\");\n\treturn parsed.origin;\n}\n\nfunction requestUrl(value: string, origins: ReadonlySet<string>): URL {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new Error(\"plugin source URL is invalid\");\n\t}\n\tif ((parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") || parsed.username || parsed.password)\n\t\tthrow new Error(\"plugin source URL must use http(s) without credentials\");\n\tif (!origins.has(parsed.origin)) throw new Error(\"plugin source origin is not allowed\");\n\treturn parsed;\n}\n\nfunction requestSignal(parent: AbortSignal | undefined, timeoutMs: number): RequestSignal {\n\tconst controller = new AbortController();\n\tlet didTimeout = false;\n\tconst abort = () => controller.abort(parent?.reason);\n\tif (parent?.aborted === true) abort();\n\telse parent?.addEventListener(\"abort\", abort, { once: true });\n\tconst timeout = setTimeout(() => {\n\t\tdidTimeout = true;\n\t\tcontroller.abort();\n\t}, timeoutMs);\n\treturn {\n\t\tsignal: controller.signal,\n\t\ttimedOut: () => didTimeout,\n\t\tcleanup: () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tparent?.removeEventListener(\"abort\", abort);\n\t\t},\n\t};\n}\n\nfunction contentLength(response: Response): number | undefined {\n\tconst value = response.headers.get(\"content-length\");\n\tif (value === null) return undefined;\n\tif (!/^\\d+$/u.test(value)) throw new Error(\"plugin response content length is invalid\");\n\tconst result = Number(value);\n\tif (!Number.isSafeInteger(result)) throw new Error(\"plugin response content length is invalid\");\n\treturn result;\n}\n\nfunction contentType(response: Response): string | undefined {\n\tconst value = response.headers.get(\"content-type\");\n\tif (value === null) return undefined;\n\treturn value.split(\";\", 1)[0]?.trim().toLowerCase() || undefined;\n}\n\nfunction assertResponseMetadata(response: Response, descriptor: PluginDistributionDescriptorV1): void {\n\tconst length = contentLength(response);\n\tif (length !== descriptor.sizeBytes) throw new Error(\"plugin response size mismatch\");\n\tconst mediaType = contentType(response);\n\tif (mediaType !== descriptor.mediaType.toLowerCase()) throw new Error(\"plugin response media type mismatch\");\n}\n\nasync function cancelBody(response: Response): Promise<void> {\n\tif (response.body !== null) await response.body.cancel().catch(() => undefined);\n}\n\nfunction expectedDigest(value: string): { readonly algorithm: \"sha256\" | \"sha512\"; readonly hex: string } {\n\tconst prefixed = /^(sha256|sha512):([0-9a-f]+)$/iu.exec(value);\n\tif (prefixed !== null) {\n\t\tconst algorithm = prefixed[1]?.toLowerCase();\n\t\tconst hex = prefixed[2]?.toLowerCase();\n\t\tif ((algorithm === \"sha256\" && hex?.length === 64) || (algorithm === \"sha512\" && hex?.length === 128))\n\t\t\treturn { algorithm, hex };\n\t}\n\tif (/^[0-9a-f]{64}$/iu.test(value)) return { algorithm: \"sha256\", hex: value.toLowerCase() };\n\tif (/^[0-9a-f]{128}$/iu.test(value)) return { algorithm: \"sha512\", hex: value.toLowerCase() };\n\tthrow new Error(\"plugin artifact digest algorithm is unsupported\");\n}\n\nfunction metadataFromDescriptor(descriptor: PluginDistributionDescriptorV1): PluginDistributionMetadataV1 {\n\treturn {\n\t\tversion: 1,\n\t\tsource: descriptor.source,\n\t\tpluginId: descriptor.pluginId,\n\t\tpluginVersion: descriptor.pluginVersion,\n\t\tmanifestDigest: descriptor.manifestDigest,\n\t\tartifactDigest: descriptor.artifactDigest,\n\t\texpiresAt: descriptor.expiresAt,\n\t\tsizeBytes: descriptor.sizeBytes,\n\t\tmediaType: descriptor.mediaType,\n\t};\n}\n\nfunction artifactMatchesDescriptor(\n\tartifact: PluginDistributionArtifactV1,\n\tdescriptor: PluginDistributionDescriptorV1,\n): boolean {\n\treturn (\n\t\tartifact.version === 1 &&\n\t\tartifact.pluginId === descriptor.pluginId &&\n\t\tartifact.pluginVersion === descriptor.pluginVersion &&\n\t\tartifact.manifestDigest === descriptor.manifestDigest &&\n\t\tartifact.artifactDigest === descriptor.artifactDigest &&\n\t\tartifact.sizeBytes === descriptor.sizeBytes &&\n\t\tartifact.mediaType === descriptor.mediaType &&\n\t\tartifact.source === descriptor.source &&\n\t\tartifact.expiresAt === descriptor.expiresAt\n\t);\n}\n\nasync function writeFully(file: Awaited<ReturnType<typeof open>>, chunk: Uint8Array): Promise<void> {\n\tlet offset = 0;\n\twhile (offset < chunk.byteLength) {\n\t\tconst result = await file.write(chunk, offset, chunk.byteLength - offset, null);\n\t\tif (result.bytesWritten <= 0) throw new Error(\"plugin artifact file write failed\");\n\t\toffset += result.bytesWritten;\n\t}\n}\n\n/**\n * Node/undici distribution transport. It is a host adapter, not Core logic:\n * package bytes stay in a private artifact directory and are never returned by\n * the public distribution contract.\n */\nexport async function createNodeHttpPluginDistributionHostV1(\n\toptions: NodeHttpPluginDistributionHostOptionsV1,\n): Promise<NodeHttpPluginDistributionHostV1> {\n\tconst transport = options.fetch ?? globalThis.fetch;\n\tif (typeof transport !== \"function\") throw new Error(\"Node fetch is unavailable\");\n\tif (!Array.isArray(options.allowedOrigins) || options.allowedOrigins.length === 0)\n\t\tthrow new Error(\"at least one allowed origin is required\");\n\tconst origins = new Set(options.allowedOrigins.map(allowedOrigin));\n\tconst timeoutMs = boundedPositive(\n\t\toptions.requestTimeoutMs,\n\t\tDEFAULT_TIMEOUT_MS_V1,\n\t\tMAX_TIMEOUT_MS_V1,\n\t\t\"requestTimeoutMs\",\n\t);\n\tconst maxRedirects = options.maxRedirects ?? DEFAULT_REDIRECTS_V1;\n\tif (!Number.isSafeInteger(maxRedirects) || maxRedirects < 0 || maxRedirects > MAX_REDIRECTS_V1)\n\t\tthrow new Error(`maxRedirects must be an integer between 0 and ${MAX_REDIRECTS_V1}`);\n\tconst userAgent = options.userAgent ?? \"agent-forge-plugin-distribution/1\";\n\tif (userAgent.length === 0 || userAgent.length > 256 || /[\\r\\n]/u.test(userAgent))\n\t\tthrow new Error(\"userAgent is invalid\");\n\tconst configuredDirectory = options.artifactDirectory;\n\tif (configuredDirectory !== undefined && !isAbsolute(configuredDirectory))\n\t\tthrow new Error(\"artifactDirectory must be absolute\");\n\tconst baseDirectoryPromise: Promise<string> =\n\t\tconfiguredDirectory === undefined\n\t\t\t? mkdtemp(join(tmpdir(), \"agent-forge-plugin-distribution-\"))\n\t\t\t: (async () => {\n\t\t\t\t\tawait mkdir(configuredDirectory, { recursive: true });\n\t\t\t\t\treturn await mkdtemp(join(configuredDirectory, \"agent-forge-plugin-distribution-\"));\n\t\t\t\t})();\n\tconst artifacts = new Map<string, ArtifactRecord>();\n\tconst activeOperations = new Set<AbortController>();\n\tlet operationsDrained: (() => void) | undefined;\n\tlet closePromise: Promise<void> | undefined;\n\tlet closed = false;\n\n\tconst assertOpen = (): void => {\n\t\tif (closed) throw new Error(\"plugin distribution host is closed\");\n\t};\n\n\tconst beginOperation = (): AbortController => {\n\t\tassertOpen();\n\t\tconst controller = new AbortController();\n\t\tactiveOperations.add(controller);\n\t\treturn controller;\n\t};\n\n\tconst endOperation = (controller: AbortController): void => {\n\t\tactiveOperations.delete(controller);\n\t\tif (activeOperations.size === 0) {\n\t\t\toperationsDrained?.();\n\t\t\toperationsDrained = undefined;\n\t\t}\n\t};\n\n\tconst waitForOperations = async (): Promise<void> => {\n\t\tif (activeOperations.size === 0) return;\n\t\tawait new Promise<void>((resolve) => {\n\t\t\toperationsDrained = resolve;\n\t\t});\n\t};\n\n\tconst fetchResponse = async (\n\t\tvalue: string,\n\t\tmethod: \"HEAD\" | \"GET\",\n\t\tparentSignal: AbortSignal | undefined,\n\t\toperationSignal: AbortSignal,\n\t): Promise<{ readonly response: Response; readonly request: RequestSignal }> => {\n\t\tlet current = requestUrl(value, origins);\n\t\tfor (let redirect = 0; ; redirect += 1) {\n\t\t\tif (operationSignal.aborted) throw cancelledRequestError();\n\t\t\tassertOpen();\n\t\t\tconst request = requestSignal(\n\t\t\t\tAbortSignal.any([parentSignal, operationSignal].filter(Boolean) as AbortSignal[]),\n\t\t\t\ttimeoutMs,\n\t\t\t);\n\t\t\tlet response: Response;\n\t\t\ttry {\n\t\t\t\tresponse = await transport(current.toString(), {\n\t\t\t\t\tmethod,\n\t\t\t\t\theaders: { accept: \"*/*\", \"user-agent\": userAgent },\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: request.signal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\trequest.cleanup();\n\t\t\t\tthrowIfRequestCancelled(request);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (!REDIRECT_STATUS.has(response.status)) return { response, request };\n\t\t\tconst location = response.headers.get(\"location\");\n\t\t\tawait cancelBody(response);\n\t\t\trequest.cleanup();\n\t\t\tif (location === null || redirect >= maxRedirects) throw new Error(\"plugin redirect limit exceeded\");\n\t\t\tcurrent = requestUrl(new URL(location, current).toString(), origins);\n\t\t}\n\t};\n\n\tconst resolveMetadata = async (input: {\n\t\treadonly descriptor: PluginDistributionDescriptorV1;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginDistributionMetadataV1> => {\n\t\tconst operation = beginOperation();\n\t\ttry {\n\t\t\tconst { response, request } = await fetchResponse(\n\t\t\t\tinput.descriptor.source,\n\t\t\t\t\"HEAD\",\n\t\t\t\tinput.signal,\n\t\t\t\toperation.signal,\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tif (response.status < 200 || response.status >= 300) throw new Error(\"plugin metadata request failed\");\n\t\t\t\tassertResponseMetadata(response, input.descriptor);\n\t\t\t\treturn metadataFromDescriptor(input.descriptor);\n\t\t\t} finally {\n\t\t\t\tawait cancelBody(response);\n\t\t\t\trequest.cleanup();\n\t\t\t}\n\t\t} finally {\n\t\t\tendOperation(operation);\n\t\t}\n\t};\n\n\tconst acquireArtifact = async (input: {\n\t\treadonly descriptor: PluginDistributionDescriptorV1;\n\t\treadonly metadata: PluginDistributionMetadataV1;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginDistributionArtifactHandleV1> => {\n\t\tconst operation = beginOperation();\n\t\tlet temporaryPath: string | undefined;\n\t\tlet finalPath: string | undefined;\n\t\tlet published = false;\n\t\ttry {\n\t\t\tconst digest = expectedDigest(input.descriptor.artifactDigest);\n\t\t\tconst { response, request } = await fetchResponse(\n\t\t\t\tinput.descriptor.source,\n\t\t\t\t\"GET\",\n\t\t\t\tinput.signal,\n\t\t\t\toperation.signal,\n\t\t\t);\n\t\t\tlet file: Awaited<ReturnType<typeof open>> | undefined;\n\t\t\ttry {\n\t\t\t\tif (response.status < 200 || response.status >= 300) throw new Error(\"plugin artifact request failed\");\n\t\t\t\tassertResponseMetadata(response, input.descriptor);\n\t\t\t\tif (response.body === null) throw new Error(\"plugin artifact response has no body\");\n\t\t\t\tconst directory = await baseDirectoryPromise;\n\t\t\t\ttemporaryPath = join(directory, `.partial-${randomUUID()}`);\n\t\t\t\tfinalPath = join(directory, `artifact-${randomUUID()}`);\n\t\t\t\tfile = await open(temporaryPath, \"wx\");\n\t\t\t\tconst reader = response.body.getReader();\n\t\t\t\tconst hash = createHash(digest.algorithm);\n\t\t\t\tlet total = 0;\n\t\t\t\ttry {\n\t\t\t\t\tfor (;;) {\n\t\t\t\t\t\tthrowIfRequestCancelled(request);\n\t\t\t\t\t\tconst item = await reader.read();\n\t\t\t\t\t\tif (item.done) break;\n\t\t\t\t\t\tconst chunk = item.value;\n\t\t\t\t\t\ttotal += chunk.byteLength;\n\t\t\t\t\t\tif (total > input.descriptor.sizeBytes) throw new Error(\"plugin artifact exceeds its size limit\");\n\t\t\t\t\t\thash.update(chunk);\n\t\t\t\t\t\tawait writeFully(file, chunk);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\treader.releaseLock();\n\t\t\t\t}\n\t\t\t\tthrowIfRequestCancelled(request);\n\t\t\t\tif (total !== input.descriptor.sizeBytes) throw new Error(\"plugin artifact size mismatch\");\n\t\t\t\tif (hash.digest(\"hex\") !== digest.hex) throw new Error(\"plugin artifact digest mismatch\");\n\t\t\t\tawait file.close();\n\t\t\t\tfile = undefined;\n\t\t\t\tawait rename(temporaryPath, finalPath);\n\t\t\t\tassertOpen();\n\t\t\t\tconst artifactRef = `artifact://node-http/${randomUUID()}`;\n\t\t\t\tartifacts.set(artifactRef, { path: finalPath, descriptor: input.descriptor, readers: 0 });\n\t\t\t\tpublished = true;\n\t\t\t\treturn {\n\t\t\t\t\tartifactRef,\n\t\t\t\t\tartifactDigest: input.descriptor.artifactDigest,\n\t\t\t\t\tsizeBytes: input.descriptor.sizeBytes,\n\t\t\t\t\tmediaType: input.descriptor.mediaType,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrowIfRequestCancelled(request);\n\t\t\t\tthrow error;\n\t\t\t} finally {\n\t\t\t\tif (file !== undefined) await file.close().catch(() => undefined);\n\t\t\t\tawait cancelBody(response);\n\t\t\t\trequest.cleanup();\n\t\t\t}\n\t\t} finally {\n\t\t\tif (temporaryPath !== undefined) await rm(temporaryPath, { force: true }).catch(() => undefined);\n\t\t\tif (!published && finalPath !== undefined) await rm(finalPath, { force: true }).catch(() => undefined);\n\t\t\tendOperation(operation);\n\t\t}\n\t};\n\n\tconst releaseArtifact = async (input: {\n\t\treadonly artifact: { readonly artifactRef: string };\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<void> => {\n\t\tassertOpen();\n\t\tif (input.signal?.aborted) throw new Error(\"plugin artifact release was cancelled\");\n\t\tconst record = artifacts.get(input.artifact.artifactRef);\n\t\tif (record === undefined) throw new Error(\"plugin artifact reference is unknown\");\n\t\tif (record.readers > 0) throw new Error(\"plugin artifact is still being read\");\n\t\tawait rm(record.path, { force: false });\n\t\tartifacts.delete(input.artifact.artifactRef);\n\t};\n\n\tconst openArtifact = (input: {\n\t\treadonly artifact: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}): AsyncIterable<Uint8Array> =>\n\t\t(async function* (): AsyncGenerator<Uint8Array> {\n\t\t\tconst operation = beginOperation();\n\t\t\tlet stream: ReturnType<typeof createReadStream> | undefined;\n\t\t\tlet acquiredRecord: ArtifactRecord | undefined;\n\t\t\tconst abort = () => stream?.destroy(new Error(\"plugin artifact read was cancelled\"));\n\t\t\ttry {\n\t\t\t\tif (input.signal?.aborted) throw new Error(\"plugin artifact read was cancelled\");\n\t\t\t\tconst record = artifacts.get(input.artifact.artifactRef);\n\t\t\t\tif (record === undefined || !artifactMatchesDescriptor(input.artifact, record.descriptor))\n\t\t\t\t\tthrow new Error(\"plugin artifact reference is unknown\");\n\t\t\t\trecord.readers += 1;\n\t\t\t\tacquiredRecord = record;\n\t\t\t\tstream = createReadStream(record.path, { highWaterMark: 64 * 1024 });\n\t\t\t\tinput.signal?.addEventListener(\"abort\", abort, { once: true });\n\t\t\t\toperation.signal.addEventListener(\"abort\", abort, { once: true });\n\t\t\t\tfor await (const chunk of stream) {\n\t\t\t\t\tif (input.signal?.aborted || operation.signal.aborted)\n\t\t\t\t\t\tthrow new Error(\"plugin artifact read was cancelled\");\n\t\t\t\t\tyield new Uint8Array(chunk);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tinput.signal?.removeEventListener(\"abort\", abort);\n\t\t\t\toperation.signal.removeEventListener(\"abort\", abort);\n\t\t\t\tstream?.destroy();\n\t\t\t\tif (acquiredRecord !== undefined && acquiredRecord.readers > 0) acquiredRecord.readers -= 1;\n\t\t\t\tendOperation(operation);\n\t\t\t}\n\t\t})();\n\n\treturn {\n\t\tversion: NODE_DISTRIBUTION_HOST_VERSION_V1,\n\t\thost: { resolveMetadata, acquireArtifact, releaseArtifact },\n\t\topenArtifact,\n\t\tclose: async () => {\n\t\t\tif (closePromise !== undefined) return await closePromise;\n\t\t\tclosed = true;\n\t\t\tfor (const operation of activeOperations) operation.abort();\n\t\t\tclosePromise = (async () => {\n\t\t\t\tawait waitForOperations();\n\t\t\t\tconst directory = await baseDirectoryPromise;\n\t\t\t\tawait Promise.all([...artifacts.values()].map((record) => rm(record.path, { force: true })));\n\t\t\t\tartifacts.clear();\n\t\t\t\tawait rm(directory, { recursive: true, force: true });\n\t\t\t})();\n\t\t\treturn await closePromise;\n\t\t},\n\t};\n}\n\n/**\n * Compose the real Node HTTP transport with the explicit Ed25519 trust root.\n * Distribution descriptors are verified before metadata or artifact access;\n * the returned host still keeps bytes behind its private reader.\n */\nexport async function createNodeHttpPluginDistributionStackV1(\n\toptions: NodeHttpPluginDistributionStackOptionsV1,\n): Promise<NodeHttpPluginDistributionStackV1> {\n\tconst { trustRoot, now: configuredNow, ...hostOptions } = options;\n\tconst host = await createNodeHttpPluginDistributionHostV1(hostOptions);\n\ttry {\n\t\tconst now = configuredNow ?? trustRoot.now ?? (() => Date.now());\n\t\tconst verifySignature = createNodePluginTrustRootV1({ ...trustRoot, now });\n\t\tconst distribution = createPluginDistributionV1({ host: host.host, verifySignature, now });\n\t\treturn Object.freeze({ ...host, distribution });\n\t} catch (error) {\n\t\tawait host.close().catch(() => undefined);\n\t\tthrow error;\n\t}\n}\n"]}
1
+ {"version":3,"file":"node-distribution-host.js","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-distribution-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,M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AC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC1C,MAAM,KAAK,CAAC;IACb,CAAC;AAAA,CACD","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { createReadStream } from \"node:fs\";\nimport { mkdir, mkdtemp, open, rename, rm } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { isAbsolute, join } from \"node:path\";\n\nimport { t } from \"../../core/i18n/index.ts\";\nimport type {\n\tPluginDistributionArtifactHandleV1,\n\tPluginDistributionArtifactV1,\n\tPluginDistributionDescriptorV1,\n\tPluginDistributionHostV1,\n\tPluginDistributionMetadataV1,\n\tPluginDistributionV1,\n} from \"./distribution.ts\";\nimport { createPluginDistributionV1 } from \"./distribution.ts\";\nimport { createNodePluginTrustRootV1, type NodePluginTrustRootOptionsV1 } from \"./node-plugin-trust-root.ts\";\n\nconst NODE_DISTRIBUTION_HOST_VERSION_V1 = 1 as const;\nconst DEFAULT_TIMEOUT_MS_V1 = 30_000;\nconst MAX_TIMEOUT_MS_V1 = 120_000;\nconst DEFAULT_REDIRECTS_V1 = 3;\nconst MAX_REDIRECTS_V1 = 5;\nconst REDIRECT_STATUS = new Set([301, 302, 303, 307, 308]);\n\nexport interface NodeHttpPluginDistributionHostOptionsV1 {\n\t/** Real `fetch` or a deterministic replacement for tests. */\n\treadonly fetch?: typeof globalThis.fetch;\n\t/** Exact `http(s)` origins. An empty allowlist is rejected. */\n\treadonly allowedOrigins: readonly string[];\n\t/** Optional host-owned directory. It is never returned as an artifact reference. */\n\treadonly artifactDirectory?: string;\n\treadonly requestTimeoutMs?: number;\n\treadonly maxRedirects?: number;\n\treadonly userAgent?: string;\n}\n\nexport interface NodeHttpPluginDistributionHostV1 {\n\treadonly version: typeof NODE_DISTRIBUTION_HOST_VERSION_V1;\n\treadonly host: PluginDistributionHostV1;\n\t/**\n\t * Private Node-host reader for an installer that shares this host instance.\n\t * It is not part of the model-facing distribution contract and never exposes\n\t * a file path. The caller must consume it before releasing the artifact.\n\t */\n\treadonly openArtifact: (input: {\n\t\treadonly artifact: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}) => AsyncIterable<Uint8Array>;\n\t/** Remove all artifacts owned by this host instance. */\n\treadonly close: () => Promise<void>;\n}\n\n/**\n * Explicitly composed Node distribution stack. The caller supplies the trust\n * root; no key or network origin is discovered implicitly.\n */\nexport interface NodeHttpPluginDistributionStackOptionsV1 extends NodeHttpPluginDistributionHostOptionsV1 {\n\treadonly trustRoot: NodePluginTrustRootOptionsV1;\n\t/** Shared clock for descriptor expiry and trust-key validity. */\n\treadonly now?: () => number;\n}\n\nexport interface NodeHttpPluginDistributionStackV1 extends NodeHttpPluginDistributionHostV1 {\n\treadonly distribution: PluginDistributionV1;\n}\n\ninterface ArtifactRecord {\n\treadonly path: string;\n\treadonly descriptor: PluginDistributionDescriptorV1;\n\treaders: number;\n}\n\ninterface RequestSignal {\n\treadonly signal: AbortSignal;\n\treadonly timedOut: () => boolean;\n\treadonly cleanup: () => void;\n}\n\nfunction cancelledRequestError(): Error {\n\tconst error = new Error(t(\"plugin request was cancelled\"));\n\terror.name = \"AbortError\";\n\treturn error;\n}\n\nfunction throwIfRequestCancelled(request: RequestSignal): void {\n\tif (request.timedOut()) throw new Error(t(\"plugin request timed out\"));\n\tif (request.signal.aborted) throw cancelledRequestError();\n}\n\nfunction boundedPositive(value: number | undefined, fallback: number, maximum: number, label: string): number {\n\tconst result = value ?? fallback;\n\tif (!Number.isSafeInteger(result) || result <= 0 || result > maximum)\n\t\tthrow new Error(t(\"{label} must be a positive integer at most {maximum}\", { label, maximum }));\n\treturn result;\n}\n\nfunction allowedOrigin(value: string): string {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new Error(t(\"allowed origin is invalid\"));\n\t}\n\tif ((parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") || parsed.username || parsed.password)\n\t\tthrow new Error(t(\"allowed origin must be an http(s) origin\"));\n\tif (parsed.pathname !== \"/\" || parsed.search !== \"\" || parsed.hash !== \"\")\n\t\tthrow new Error(t(\"allowed origin must not include a path or query\"));\n\treturn parsed.origin;\n}\n\nfunction requestUrl(value: string, origins: ReadonlySet<string>): URL {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new Error(t(\"plugin source URL is invalid\"));\n\t}\n\tif ((parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") || parsed.username || parsed.password)\n\t\tthrow new Error(t(\"plugin source URL must use http(s) without credentials\"));\n\tif (!origins.has(parsed.origin)) throw new Error(t(\"plugin source origin is not allowed\"));\n\treturn parsed;\n}\n\nfunction requestSignal(parent: AbortSignal | undefined, timeoutMs: number): RequestSignal {\n\tconst controller = new AbortController();\n\tlet didTimeout = false;\n\tconst abort = () => controller.abort(parent?.reason);\n\tif (parent?.aborted === true) abort();\n\telse parent?.addEventListener(\"abort\", abort, { once: true });\n\tconst timeout = setTimeout(() => {\n\t\tdidTimeout = true;\n\t\tcontroller.abort();\n\t}, timeoutMs);\n\treturn {\n\t\tsignal: controller.signal,\n\t\ttimedOut: () => didTimeout,\n\t\tcleanup: () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tparent?.removeEventListener(\"abort\", abort);\n\t\t},\n\t};\n}\n\nfunction contentLength(response: Response): number | undefined {\n\tconst value = response.headers.get(\"content-length\");\n\tif (value === null) return undefined;\n\tif (!/^\\d+$/u.test(value)) throw new Error(t(\"plugin response content length is invalid\"));\n\tconst result = Number(value);\n\tif (!Number.isSafeInteger(result)) throw new Error(t(\"plugin response content length is invalid\"));\n\treturn result;\n}\n\nfunction contentType(response: Response): string | undefined {\n\tconst value = response.headers.get(\"content-type\");\n\tif (value === null) return undefined;\n\treturn value.split(\";\", 1)[0]?.trim().toLowerCase() || undefined;\n}\n\nfunction assertResponseMetadata(response: Response, descriptor: PluginDistributionDescriptorV1): void {\n\tconst length = contentLength(response);\n\tif (length !== descriptor.sizeBytes) throw new Error(t(\"plugin response size mismatch\"));\n\tconst mediaType = contentType(response);\n\tif (mediaType !== descriptor.mediaType.toLowerCase()) throw new Error(t(\"plugin response media type mismatch\"));\n}\n\nasync function cancelBody(response: Response): Promise<void> {\n\tif (response.body !== null) await response.body.cancel().catch(() => undefined);\n}\n\nfunction expectedDigest(value: string): { readonly algorithm: \"sha256\" | \"sha512\"; readonly hex: string } {\n\tconst prefixed = /^(sha256|sha512):([0-9a-f]+)$/iu.exec(value);\n\tif (prefixed !== null) {\n\t\tconst algorithm = prefixed[1]?.toLowerCase();\n\t\tconst hex = prefixed[2]?.toLowerCase();\n\t\tif ((algorithm === \"sha256\" && hex?.length === 64) || (algorithm === \"sha512\" && hex?.length === 128))\n\t\t\treturn { algorithm, hex };\n\t}\n\tif (/^[0-9a-f]{64}$/iu.test(value)) return { algorithm: \"sha256\", hex: value.toLowerCase() };\n\tif (/^[0-9a-f]{128}$/iu.test(value)) return { algorithm: \"sha512\", hex: value.toLowerCase() };\n\tthrow new Error(t(\"plugin artifact digest algorithm is unsupported\"));\n}\n\nfunction metadataFromDescriptor(descriptor: PluginDistributionDescriptorV1): PluginDistributionMetadataV1 {\n\treturn {\n\t\tversion: 1,\n\t\tsource: descriptor.source,\n\t\tpluginId: descriptor.pluginId,\n\t\tpluginVersion: descriptor.pluginVersion,\n\t\tmanifestDigest: descriptor.manifestDigest,\n\t\tartifactDigest: descriptor.artifactDigest,\n\t\texpiresAt: descriptor.expiresAt,\n\t\tsizeBytes: descriptor.sizeBytes,\n\t\tmediaType: descriptor.mediaType,\n\t};\n}\n\nfunction artifactMatchesDescriptor(\n\tartifact: PluginDistributionArtifactV1,\n\tdescriptor: PluginDistributionDescriptorV1,\n): boolean {\n\treturn (\n\t\tartifact.version === 1 &&\n\t\tartifact.pluginId === descriptor.pluginId &&\n\t\tartifact.pluginVersion === descriptor.pluginVersion &&\n\t\tartifact.manifestDigest === descriptor.manifestDigest &&\n\t\tartifact.artifactDigest === descriptor.artifactDigest &&\n\t\tartifact.sizeBytes === descriptor.sizeBytes &&\n\t\tartifact.mediaType === descriptor.mediaType &&\n\t\tartifact.source === descriptor.source &&\n\t\tartifact.expiresAt === descriptor.expiresAt\n\t);\n}\n\nasync function writeFully(file: Awaited<ReturnType<typeof open>>, chunk: Uint8Array): Promise<void> {\n\tlet offset = 0;\n\twhile (offset < chunk.byteLength) {\n\t\tconst result = await file.write(chunk, offset, chunk.byteLength - offset, null);\n\t\tif (result.bytesWritten <= 0) throw new Error(t(\"plugin artifact file write failed\"));\n\t\toffset += result.bytesWritten;\n\t}\n}\n\n/**\n * Node/undici distribution transport. It is a host adapter, not Core logic:\n * package bytes stay in a private artifact directory and are never returned by\n * the public distribution contract.\n */\nexport async function createNodeHttpPluginDistributionHostV1(\n\toptions: NodeHttpPluginDistributionHostOptionsV1,\n): Promise<NodeHttpPluginDistributionHostV1> {\n\tconst transport = options.fetch ?? globalThis.fetch;\n\tif (typeof transport !== \"function\") throw new Error(t(\"Node fetch is unavailable\"));\n\tif (!Array.isArray(options.allowedOrigins) || options.allowedOrigins.length === 0)\n\t\tthrow new Error(t(\"at least one allowed origin is required\"));\n\tconst origins = new Set(options.allowedOrigins.map(allowedOrigin));\n\tconst timeoutMs = boundedPositive(\n\t\toptions.requestTimeoutMs,\n\t\tDEFAULT_TIMEOUT_MS_V1,\n\t\tMAX_TIMEOUT_MS_V1,\n\t\t\"requestTimeoutMs\",\n\t);\n\tconst maxRedirects = options.maxRedirects ?? DEFAULT_REDIRECTS_V1;\n\tif (!Number.isSafeInteger(maxRedirects) || maxRedirects < 0 || maxRedirects > MAX_REDIRECTS_V1)\n\t\tthrow new Error(t(\"maxRedirects must be an integer between 0 and {max}\", { max: MAX_REDIRECTS_V1 }));\n\tconst userAgent = options.userAgent ?? \"agent-forge-plugin-distribution/1\";\n\tif (userAgent.length === 0 || userAgent.length > 256 || /[\\r\\n]/u.test(userAgent))\n\t\tthrow new Error(t(\"userAgent is invalid\"));\n\tconst configuredDirectory = options.artifactDirectory;\n\tif (configuredDirectory !== undefined && !isAbsolute(configuredDirectory))\n\t\tthrow new Error(t(\"artifactDirectory must be absolute\"));\n\tconst baseDirectoryPromise: Promise<string> =\n\t\tconfiguredDirectory === undefined\n\t\t\t? mkdtemp(join(tmpdir(), \"agent-forge-plugin-distribution-\"))\n\t\t\t: (async () => {\n\t\t\t\t\tawait mkdir(configuredDirectory, { recursive: true });\n\t\t\t\t\treturn await mkdtemp(join(configuredDirectory, \"agent-forge-plugin-distribution-\"));\n\t\t\t\t})();\n\tconst artifacts = new Map<string, ArtifactRecord>();\n\tconst activeOperations = new Set<AbortController>();\n\tlet operationsDrained: (() => void) | undefined;\n\tlet closePromise: Promise<void> | undefined;\n\tlet closed = false;\n\n\tconst assertOpen = (): void => {\n\t\tif (closed) throw new Error(t(\"plugin distribution host is closed\"));\n\t};\n\n\tconst beginOperation = (): AbortController => {\n\t\tassertOpen();\n\t\tconst controller = new AbortController();\n\t\tactiveOperations.add(controller);\n\t\treturn controller;\n\t};\n\n\tconst endOperation = (controller: AbortController): void => {\n\t\tactiveOperations.delete(controller);\n\t\tif (activeOperations.size === 0) {\n\t\t\toperationsDrained?.();\n\t\t\toperationsDrained = undefined;\n\t\t}\n\t};\n\n\tconst waitForOperations = async (): Promise<void> => {\n\t\tif (activeOperations.size === 0) return;\n\t\tawait new Promise<void>((resolve) => {\n\t\t\toperationsDrained = resolve;\n\t\t});\n\t};\n\n\tconst fetchResponse = async (\n\t\tvalue: string,\n\t\tmethod: \"HEAD\" | \"GET\",\n\t\tparentSignal: AbortSignal | undefined,\n\t\toperationSignal: AbortSignal,\n\t): Promise<{ readonly response: Response; readonly request: RequestSignal }> => {\n\t\tlet current = requestUrl(value, origins);\n\t\tfor (let redirect = 0; ; redirect += 1) {\n\t\t\tif (operationSignal.aborted) throw cancelledRequestError();\n\t\t\tassertOpen();\n\t\t\tconst request = requestSignal(\n\t\t\t\tAbortSignal.any([parentSignal, operationSignal].filter(Boolean) as AbortSignal[]),\n\t\t\t\ttimeoutMs,\n\t\t\t);\n\t\t\tlet response: Response;\n\t\t\ttry {\n\t\t\t\tresponse = await transport(current.toString(), {\n\t\t\t\t\tmethod,\n\t\t\t\t\theaders: { accept: \"*/*\", \"user-agent\": userAgent },\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: request.signal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\trequest.cleanup();\n\t\t\t\tthrowIfRequestCancelled(request);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (!REDIRECT_STATUS.has(response.status)) return { response, request };\n\t\t\tconst location = response.headers.get(\"location\");\n\t\t\tawait cancelBody(response);\n\t\t\trequest.cleanup();\n\t\t\tif (location === null || redirect >= maxRedirects) throw new Error(t(\"plugin redirect limit exceeded\"));\n\t\t\tcurrent = requestUrl(new URL(location, current).toString(), origins);\n\t\t}\n\t};\n\n\tconst resolveMetadata = async (input: {\n\t\treadonly descriptor: PluginDistributionDescriptorV1;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginDistributionMetadataV1> => {\n\t\tconst operation = beginOperation();\n\t\ttry {\n\t\t\tconst { response, request } = await fetchResponse(\n\t\t\t\tinput.descriptor.source,\n\t\t\t\t\"HEAD\",\n\t\t\t\tinput.signal,\n\t\t\t\toperation.signal,\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tif (response.status < 200 || response.status >= 300) throw new Error(t(\"plugin metadata request failed\"));\n\t\t\t\tassertResponseMetadata(response, input.descriptor);\n\t\t\t\treturn metadataFromDescriptor(input.descriptor);\n\t\t\t} finally {\n\t\t\t\tawait cancelBody(response);\n\t\t\t\trequest.cleanup();\n\t\t\t}\n\t\t} finally {\n\t\t\tendOperation(operation);\n\t\t}\n\t};\n\n\tconst acquireArtifact = async (input: {\n\t\treadonly descriptor: PluginDistributionDescriptorV1;\n\t\treadonly metadata: PluginDistributionMetadataV1;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<PluginDistributionArtifactHandleV1> => {\n\t\tconst operation = beginOperation();\n\t\tlet temporaryPath: string | undefined;\n\t\tlet finalPath: string | undefined;\n\t\tlet published = false;\n\t\ttry {\n\t\t\tconst digest = expectedDigest(input.descriptor.artifactDigest);\n\t\t\tconst { response, request } = await fetchResponse(\n\t\t\t\tinput.descriptor.source,\n\t\t\t\t\"GET\",\n\t\t\t\tinput.signal,\n\t\t\t\toperation.signal,\n\t\t\t);\n\t\t\tlet file: Awaited<ReturnType<typeof open>> | undefined;\n\t\t\ttry {\n\t\t\t\tif (response.status < 200 || response.status >= 300) throw new Error(t(\"plugin artifact request failed\"));\n\t\t\t\tassertResponseMetadata(response, input.descriptor);\n\t\t\t\tif (response.body === null) throw new Error(t(\"plugin artifact response has no body\"));\n\t\t\t\tconst directory = await baseDirectoryPromise;\n\t\t\t\ttemporaryPath = join(directory, `.partial-${randomUUID()}`);\n\t\t\t\tfinalPath = join(directory, `artifact-${randomUUID()}`);\n\t\t\t\tfile = await open(temporaryPath, \"wx\");\n\t\t\t\tconst reader = response.body.getReader();\n\t\t\t\tconst hash = createHash(digest.algorithm);\n\t\t\t\tlet total = 0;\n\t\t\t\ttry {\n\t\t\t\t\tfor (;;) {\n\t\t\t\t\t\tthrowIfRequestCancelled(request);\n\t\t\t\t\t\tconst item = await reader.read();\n\t\t\t\t\t\tif (item.done) break;\n\t\t\t\t\t\tconst chunk = item.value;\n\t\t\t\t\t\ttotal += chunk.byteLength;\n\t\t\t\t\t\tif (total > input.descriptor.sizeBytes) throw new Error(t(\"plugin artifact exceeds its size limit\"));\n\t\t\t\t\t\thash.update(chunk);\n\t\t\t\t\t\tawait writeFully(file, chunk);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\treader.releaseLock();\n\t\t\t\t}\n\t\t\t\tthrowIfRequestCancelled(request);\n\t\t\t\tif (total !== input.descriptor.sizeBytes) throw new Error(t(\"plugin artifact size mismatch\"));\n\t\t\t\tif (hash.digest(\"hex\") !== digest.hex) throw new Error(t(\"plugin artifact digest mismatch\"));\n\t\t\t\tawait file.close();\n\t\t\t\tfile = undefined;\n\t\t\t\tawait rename(temporaryPath, finalPath);\n\t\t\t\tassertOpen();\n\t\t\t\tconst artifactRef = `artifact://node-http/${randomUUID()}`;\n\t\t\t\tartifacts.set(artifactRef, { path: finalPath, descriptor: input.descriptor, readers: 0 });\n\t\t\t\tpublished = true;\n\t\t\t\treturn {\n\t\t\t\t\tartifactRef,\n\t\t\t\t\tartifactDigest: input.descriptor.artifactDigest,\n\t\t\t\t\tsizeBytes: input.descriptor.sizeBytes,\n\t\t\t\t\tmediaType: input.descriptor.mediaType,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrowIfRequestCancelled(request);\n\t\t\t\tthrow error;\n\t\t\t} finally {\n\t\t\t\tif (file !== undefined) await file.close().catch(() => undefined);\n\t\t\t\tawait cancelBody(response);\n\t\t\t\trequest.cleanup();\n\t\t\t}\n\t\t} finally {\n\t\t\tif (temporaryPath !== undefined) await rm(temporaryPath, { force: true }).catch(() => undefined);\n\t\t\tif (!published && finalPath !== undefined) await rm(finalPath, { force: true }).catch(() => undefined);\n\t\t\tendOperation(operation);\n\t\t}\n\t};\n\n\tconst releaseArtifact = async (input: {\n\t\treadonly artifact: { readonly artifactRef: string };\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<void> => {\n\t\tassertOpen();\n\t\tif (input.signal?.aborted) throw new Error(t(\"plugin artifact release was cancelled\"));\n\t\tconst record = artifacts.get(input.artifact.artifactRef);\n\t\tif (record === undefined) throw new Error(t(\"plugin artifact reference is unknown\"));\n\t\tif (record.readers > 0) throw new Error(t(\"plugin artifact is still being read\"));\n\t\tawait rm(record.path, { force: false });\n\t\tartifacts.delete(input.artifact.artifactRef);\n\t};\n\n\tconst openArtifact = (input: {\n\t\treadonly artifact: PluginDistributionArtifactV1;\n\t\treadonly signal?: AbortSignal;\n\t}): AsyncIterable<Uint8Array> =>\n\t\t(async function* (): AsyncGenerator<Uint8Array> {\n\t\t\tconst operation = beginOperation();\n\t\t\tlet stream: ReturnType<typeof createReadStream> | undefined;\n\t\t\tlet acquiredRecord: ArtifactRecord | undefined;\n\t\t\tconst abort = () => stream?.destroy(new Error(\"plugin artifact read was cancelled\"));\n\t\t\ttry {\n\t\t\t\tif (input.signal?.aborted) throw new Error(t(\"plugin artifact read was cancelled\"));\n\t\t\t\tconst record = artifacts.get(input.artifact.artifactRef);\n\t\t\t\tif (record === undefined || !artifactMatchesDescriptor(input.artifact, record.descriptor))\n\t\t\t\t\tthrow new Error(t(\"plugin artifact reference is unknown\"));\n\t\t\t\trecord.readers += 1;\n\t\t\t\tacquiredRecord = record;\n\t\t\t\tstream = createReadStream(record.path, { highWaterMark: 64 * 1024 });\n\t\t\t\tinput.signal?.addEventListener(\"abort\", abort, { once: true });\n\t\t\t\toperation.signal.addEventListener(\"abort\", abort, { once: true });\n\t\t\t\tfor await (const chunk of stream) {\n\t\t\t\t\tif (input.signal?.aborted || operation.signal.aborted)\n\t\t\t\t\t\tthrow new Error(t(\"plugin artifact read was cancelled\"));\n\t\t\t\t\tyield new Uint8Array(chunk);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tinput.signal?.removeEventListener(\"abort\", abort);\n\t\t\t\toperation.signal.removeEventListener(\"abort\", abort);\n\t\t\t\tstream?.destroy();\n\t\t\t\tif (acquiredRecord !== undefined && acquiredRecord.readers > 0) acquiredRecord.readers -= 1;\n\t\t\t\tendOperation(operation);\n\t\t\t}\n\t\t})();\n\n\treturn {\n\t\tversion: NODE_DISTRIBUTION_HOST_VERSION_V1,\n\t\thost: { resolveMetadata, acquireArtifact, releaseArtifact },\n\t\topenArtifact,\n\t\tclose: async () => {\n\t\t\tif (closePromise !== undefined) return await closePromise;\n\t\t\tclosed = true;\n\t\t\tfor (const operation of activeOperations) operation.abort();\n\t\t\tclosePromise = (async () => {\n\t\t\t\tawait waitForOperations();\n\t\t\t\tconst directory = await baseDirectoryPromise;\n\t\t\t\tawait Promise.all([...artifacts.values()].map((record) => rm(record.path, { force: true })));\n\t\t\t\tartifacts.clear();\n\t\t\t\tawait rm(directory, { recursive: true, force: true });\n\t\t\t})();\n\t\t\treturn await closePromise;\n\t\t},\n\t};\n}\n\n/**\n * Compose the real Node HTTP transport with the explicit Ed25519 trust root.\n * Distribution descriptors are verified before metadata or artifact access;\n * the returned host still keeps bytes behind its private reader.\n */\nexport async function createNodeHttpPluginDistributionStackV1(\n\toptions: NodeHttpPluginDistributionStackOptionsV1,\n): Promise<NodeHttpPluginDistributionStackV1> {\n\tconst { trustRoot, now: configuredNow, ...hostOptions } = options;\n\tconst host = await createNodeHttpPluginDistributionHostV1(hostOptions);\n\ttry {\n\t\tconst now = configuredNow ?? trustRoot.now ?? (() => Date.now());\n\t\tconst verifySignature = createNodePluginTrustRootV1({ ...trustRoot, now });\n\t\tconst distribution = createPluginDistributionV1({ host: host.host, verifySignature, now });\n\t\treturn Object.freeze({ ...host, distribution });\n\t} catch (error) {\n\t\tawait host.close().catch(() => undefined);\n\t\tthrow error;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"node-npm-registry-source.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-npm-registry-source.ts"],"names":[],"mappings":"AAqBA,MAAM,MAAM,gCAAgC,GACzC,WAAW,GACX,uBAAuB,GACvB,gBAAgB,GAChB,mBAAmB,GACnB,kBAAkB,GAClB,oBAAoB,GACpB,mBAAmB,GACnB,mBAAmB,GACnB,uBAAuB,CAAC;AAE3B,qBAAa,4BAA6B,SAAQ,KAAK;IACtD,QAAQ,CAAC,IAAI,EAAE,gCAAgC,CAAC;IAEhD,YAAY,IAAI,EAAE,gCAAgC,EAAE,OAAO,EAAE,MAAM,EAIlE;CACD;AAED,4FAA4F;AAC5F,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,SAAS,EAAE,Q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AAC,YAAY,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CAC/G;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAgBhE;AAgBD;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAmBzG;AAsKD,6FAA6F;AAC7F,wBAAgB,6BAA6B,CAAC,OAAO,GAAE,8BAAmC,GAAG,uBAAuB,CA8InH","sourcesContent":["import { comparePluginVersionsV1 } from \"./catalog.ts\";\n\n/**\n * Minimal npm registry (packument) source for plugin package acquisition\n * (design `插件独立分发与启动装配设计.md` §4.2). It is a two-step protocol:\n * resolve the packument to pick one version, then fetch the tarball. It does\n * not implement `PluginRegistrySourceV1.list()`; the signed registry sources\n * keep serving private deployments unchanged.\n */\n\nconst DEFAULT_NPM_REGISTRY_V1 = \"https://registry.npmjs.org\";\nconst DEFAULT_TIMEOUT_MS_V1 = 15_000;\nconst MAX_TIMEOUT_MS_V1 = 120_000;\nconst DEFAULT_MAX_RESPONSE_BYTES_V1 = 8 * 1024 * 1024;\nconst MAX_RESPONSE_BYTES_V1 = 16 * 1024 * 1024;\nconst DEFAULT_MAX_TARBALL_BYTES_V1 = 128 * 1024 * 1024;\nconst MAX_TARBALL_BYTES_V1 = 512 * 1024 * 1024;\nconst DEFAULT_REDIRECTS_V1 = 3;\nconst MAX_REDIRECTS_V1 = 5;\nconst REDIRECT_STATUS = new Set([301, 302, 303, 307, 308]);\n\nexport type NodeNpmRegistrySourceErrorCodeV1 =\n\t| \"cancelled\"\n\t| \"invalid_configuration\"\n\t| \"request_failed\"\n\t| \"request_timed_out\"\n\t| \"invalid_response\"\n\t| \"response_too_large\"\n\t| \"package_not_found\"\n\t| \"version_not_found\"\n\t| \"integrity_unsupported\";\n\nexport class NodeNpmRegistrySourceErrorV1 extends Error {\n\treadonly code: NodeNpmRegistrySourceErrorCodeV1;\n\n\tconstructor(code: NodeNpmRegistrySourceErrorCodeV1, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"NodeNpmRegistrySourceErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\n/** SRI integrity as hex plus its algorithm, aligned with the install host digest format. */\nexport interface NodeNpmIntegrityV1 {\n\treadonly algorithm: \"sha256\" | \"sha512\";\n\treadonly hex: string;\n}\n\nexport interface NodeNpmPackageResolutionV1 {\n\treadonly version: string;\n\treadonly tarballUrl: string;\n\treadonly integrity: NodeNpmIntegrityV1;\n\t/** Raw `dist` fields of the selected version. */\n\treadonly distInfo: Readonly<Record<string, unknown>>;\n}\n\nexport interface NodeNpmRegistrySourceOptionsV1 {\n\t/** Bare http(s) registry origin; defaults to the npm public registry. */\n\treadonly registry?: string;\n\t/** Bearer token for private registries. */\n\treadonly token?: string;\n\t/** Real fetch or a deterministic test replacement. */\n\treadonly fetch?: typeof globalThis.fetch;\n\treadonly requestTimeoutMs?: number;\n\treadonly maxResponseBytes?: number;\n\treadonly maxTarballBytes?: number;\n\treadonly maxRedirects?: number;\n\treadonly userAgent?: string;\n}\n\nexport interface NodeNpmRegistrySourceV1 {\n\treadonly version: 1;\n\t/** Sanitized bare registry origin (no credentials, path, query, or fragment). */\n\treadonly registry: string;\n\treadonly resolveNpmPackage: (input: {\n\t\treadonly name: string;\n\t\treadonly range?: string;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<NodeNpmPackageResolutionV1>;\n\treadonly fetchTarball: (input: { readonly url: string; readonly signal?: AbortSignal }) => Promise<Uint8Array>;\n}\n\n/** Convert an npm SRI string (`sha512-<base64>`, `sha256-<base64>`) to hex form. */\nexport function sriToIntegrityV1(sri: string): NodeNpmIntegrityV1 {\n\tconst match = /^(sha512|sha256)-([A-Za-z0-9+/]+={0,2})$/u.exec(sri.trim());\n\tif (match === null)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"integrity_unsupported\", \"npm integrity algorithm is unsupported\");\n\tconst algorithm = match[1] as \"sha512\" | \"sha256\";\n\tlet raw: Buffer;\n\ttry {\n\t\traw = Buffer.from(match[2]!, \"base64\");\n\t} catch {\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"integrity_unsupported\", \"npm integrity encoding is invalid\");\n\t}\n\tif ((algorithm === \"sha256\" && raw.byteLength !== 32) || (algorithm === \"sha512\" && raw.byteLength !== 64))\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"integrity_unsupported\", \"npm integrity length is invalid\");\n\tconst hex = raw.toString(\"hex\").toLowerCase();\n\tif (hex.length === 0) throw new NodeNpmRegistrySourceErrorV1(\"integrity_unsupported\", \"npm integrity is invalid\");\n\treturn { algorithm, hex };\n}\n\nfunction parseVersionTriple(value: string): readonly [number, number, number] | undefined {\n\tconst match = /^(\\d+)\\.(\\d+)\\.(\\d+)/u.exec(value.replace(/^[vV]/u, \"\"));\n\tif (match === null) return undefined;\n\tconst major = Number.parseInt(match[1]!, 10);\n\tconst minor = Number.parseInt(match[2]!, 10);\n\tconst patch = Number.parseInt(match[3]!, 10);\n\tif (!Number.isSafeInteger(major) || !Number.isSafeInteger(minor) || !Number.isSafeInteger(patch)) return undefined;\n\treturn [major, minor, patch] as const;\n}\n\nfunction plainVersion(value: string): string {\n\treturn value.replace(/^[vV]/u, \"\");\n}\n\n/**\n * Select the highest version satisfying a minimal range subset using the\n * ecosystem comparator (`comparePluginVersionsV1`): `undefined`/`latest` →\n * highest; `x.y.z` → exact full match (prerelease suffix included);\n * `^x.y.z` → >= x.y.z and < (x+1).0.0; `~x.y.z` → >= x.y.z and\n * < x.(y+1).0. Bounds use the comparator ordering (e.g. `1.0.0-alpha`\n * sorts below `1.0.0`).\n */\nexport function selectNpmPackageVersionV1(versions: readonly string[], range?: string): string | undefined {\n\tif (!Array.isArray(versions)) return undefined;\n\tlet candidates = versions.filter((value) => typeof value === \"string\" && parseVersionTriple(value) !== undefined);\n\tif (candidates.length === 0) return undefined;\n\tif (range === undefined || range === \"latest\") {\n\t\treturn candidates.reduce((left, right) => (comparePluginVersionsV1(right, left) > 0 ? right : left));\n\t}\n\tconst exact = plainVersion(range.replace(/^[=~^]/u, \"\"));\n\tif (!range.startsWith(\"^\") && !range.startsWith(\"~\"))\n\t\treturn candidates.find((value) => plainVersion(value) === exact);\n\tconst bound = parseVersionTriple(exact);\n\tif (bound === undefined) return undefined;\n\tconst [major, minor] = bound;\n\tconst upper = range.startsWith(\"^\") ? `${major + 1}.0.0` : `${major}.${minor + 1}.0`;\n\tcandidates = candidates.filter(\n\t\t(value) => comparePluginVersionsV1(value, exact) >= 0 && comparePluginVersionsV1(value, upper) < 0,\n\t);\n\tif (candidates.length === 0) return undefined;\n\treturn candidates.reduce((left, right) => (comparePluginVersionsV1(right, left) > 0 ? right : left));\n}\n\nfunction boundedPositive(value: number | undefined, fallback: number, maximum: number, label: string): number {\n\tconst result = value ?? fallback;\n\tif (!Number.isSafeInteger(result) || result <= 0 || result > maximum)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\t`${label} must be a positive integer at most ${maximum}`,\n\t\t);\n\treturn result;\n}\n\nfunction registryOrigin(value: string): string {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_configuration\", \"npm registry origin is invalid\");\n\t}\n\tif (\n\t\t(parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") ||\n\t\tparsed.username !== \"\" ||\n\t\tparsed.password !== \"\"\n\t)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\t\"npm registry origin must be http(s) without credentials\",\n\t\t);\n\tif (parsed.pathname !== \"/\" || parsed.search !== \"\" || parsed.hash !== \"\")\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\t\"npm registry origin must not include a path, query, or fragment\",\n\t\t);\n\treturn parsed.origin;\n}\n\nfunction packumentUrl(registryOriginValue: string, name: string): URL {\n\tconst scopeAt = name.indexOf(\"/\");\n\tif (name.startsWith(\"@\") && scopeAt > 0) {\n\t\t// npm registry convention keeps the leading scope literal and percent\n\t\t// encodes the rest of the name, including the separating slash.\n\t\tconst scope = name.slice(0, scopeAt);\n\t\tconst packageName = name.slice(scopeAt + 1);\n\t\treturn new URL(`${registryOriginValue}/${scope}%2F${encodeURIComponent(packageName)}`);\n\t}\n\tif (scopeAt >= 0) throw new NodeNpmRegistrySourceErrorV1(\"invalid_configuration\", \"npm package name is invalid\");\n\treturn new URL(`${registryOriginValue}/${encodeURIComponent(name)}`);\n}\n\nfunction tarballUrl(value: string): URL {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", \"npm tarball URL is invalid\");\n\t}\n\tif (\n\t\t(parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") ||\n\t\tparsed.username !== \"\" ||\n\t\tparsed.password !== \"\"\n\t)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\"invalid_response\",\n\t\t\t\"npm tarball URL must use http(s) without credentials\",\n\t\t);\n\tif (parsed.hash !== \"\")\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", \"npm tarball URL must not include a fragment\");\n\treturn parsed;\n}\n\nfunction isAbortLike(error: unknown): boolean {\n\treturn error instanceof Error && (error.name === \"AbortError\" || error.name === \"AbortSignalError\");\n}\n\ninterface RequestSignal {\n\treadonly signal: AbortSignal;\n\treadonly timedOut: () => boolean;\n\treadonly cleanup: () => void;\n}\n\nfunction requestSignal(parent: AbortSignal | undefined, timeoutMs: number): RequestSignal {\n\tconst controller = new AbortController();\n\tlet timedOut = false;\n\tconst abort = () => controller.abort(parent?.reason);\n\tif (parent?.aborted === true) abort();\n\telse parent?.addEventListener(\"abort\", abort, { once: true });\n\tconst timeout = setTimeout(() => {\n\t\ttimedOut = true;\n\t\tcontroller.abort();\n\t}, timeoutMs);\n\treturn {\n\t\tsignal: controller.signal,\n\t\ttimedOut: () => timedOut,\n\t\tcleanup: () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tparent?.removeEventListener(\"abort\", abort);\n\t\t},\n\t};\n}\n\nfunction isJsonResponse(response: Response): boolean {\n\tconst contentType = response.headers.get(\"content-type\");\n\tif (contentType === null) return false;\n\tconst mediaType = contentType.split(\";\", 1)[0]?.trim().toLowerCase();\n\treturn mediaType === \"application/json\" || mediaType === \"application/vnd.npm.install-v1+json\";\n}\n\nasync function readBody(response: Response, maxBytes: number, signal: AbortSignal): Promise<Uint8Array> {\n\tif (response.body === null)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", \"npm registry response has no body\");\n\tconst reader = response.body.getReader();\n\tconst chunks: Uint8Array[] = [];\n\tlet total = 0;\n\ttry {\n\t\tfor (;;) {\n\t\t\tif (signal.aborted) throw new DOMException(\"aborted\", \"AbortError\");\n\t\t\tconst item = await reader.read();\n\t\t\tif (item.done) break;\n\t\t\ttotal += item.value.byteLength;\n\t\t\tif (total > maxBytes)\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\t\t\"response_too_large\",\n\t\t\t\t\t\"npm registry response exceeds the configured size limit\",\n\t\t\t\t);\n\t\t\tchunks.push(item.value);\n\t\t}\n\t} finally {\n\t\treader.releaseLock();\n\t}\n\tconst bytes = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const chunk of chunks) {\n\t\tbytes.set(chunk, offset);\n\t\toffset += chunk.byteLength;\n\t}\n\treturn bytes;\n}\n\ninterface PackumentVersionDistV1 {\n\treadonly tarball?: unknown;\n\treadonly integrity?: unknown;\n}\n\ninterface PackumentVersionV1 {\n\treadonly dist?: PackumentVersionDistV1;\n}\n\ninterface PackumentV1 {\n\treadonly versions?: Readonly<Record<string, PackumentVersionV1>>;\n}\n\nfunction parsePackument(bytes: Uint8Array): Readonly<Record<string, PackumentVersionV1>> {\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes));\n\t} catch {\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", \"npm registry response is not valid JSON\");\n\t}\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value))\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", \"npm packument is invalid\");\n\tconst packument = value as PackumentV1;\n\tif (typeof packument.versions !== \"object\" || packument.versions === null || Array.isArray(packument.versions))\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", \"npm packument has no version table\");\n\treturn packument.versions;\n}\n\n/** Create a bounded npm registry reader. Version selection uses the ecosystem comparator. */\nexport function createNodeNpmRegistrySourceV1(options: NodeNpmRegistrySourceOptionsV1 = {}): NodeNpmRegistrySourceV1 {\n\tconst transport = options.fetch ?? globalThis.fetch;\n\tif (typeof transport !== \"function\")\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_configuration\", \"Node fetch is unavailable\");\n\tconst registry = registryOrigin(options.registry ?? DEFAULT_NPM_REGISTRY_V1);\n\tif (\n\t\toptions.token !== undefined &&\n\t\t(options.token.length === 0 || options.token.length > 4096 || /[\\r\\n\\s]/u.test(options.token))\n\t)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_configuration\", \"npm registry token is invalid\");\n\tconst token = options.token;\n\tconst timeoutMs = boundedPositive(\n\t\toptions.requestTimeoutMs,\n\t\tDEFAULT_TIMEOUT_MS_V1,\n\t\tMAX_TIMEOUT_MS_V1,\n\t\t\"requestTimeoutMs\",\n\t);\n\tconst maxResponseBytes = boundedPositive(\n\t\toptions.maxResponseBytes,\n\t\tDEFAULT_MAX_RESPONSE_BYTES_V1,\n\t\tMAX_RESPONSE_BYTES_V1,\n\t\t\"maxResponseBytes\",\n\t);\n\tconst maxTarballBytes = boundedPositive(\n\t\toptions.maxTarballBytes,\n\t\tDEFAULT_MAX_TARBALL_BYTES_V1,\n\t\tMAX_TARBALL_BYTES_V1,\n\t\t\"maxTarballBytes\",\n\t);\n\tconst maxRedirects = options.maxRedirects ?? DEFAULT_REDIRECTS_V1;\n\tif (!Number.isSafeInteger(maxRedirects) || maxRedirects < 0 || maxRedirects > MAX_REDIRECTS_V1)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\t`maxRedirects must be an integer between 0 and ${MAX_REDIRECTS_V1}`,\n\t\t);\n\tconst userAgent = options.userAgent ?? \"agent-forge-plugin-npm/1\";\n\tif (userAgent.length === 0 || userAgent.length > 256 || /[\\r\\n]/u.test(userAgent))\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_configuration\", \"userAgent is invalid\");\n\n\tconst fetchFollowingRedirects = async (\n\t\turl: URL,\n\t\theaders: Readonly<Record<string, string>>,\n\t\tparentSignal: AbortSignal | undefined,\n\t): Promise<{ readonly response: Response; readonly request: RequestSignal }> => {\n\t\tlet current = url;\n\t\tfor (let redirect = 0; ; redirect += 1) {\n\t\t\tconst request = requestSignal(parentSignal, timeoutMs);\n\t\t\tlet response: Response;\n\t\t\ttry {\n\t\t\t\tresponse = await transport(current.toString(), {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: { accept: \"*/*\", \"user-agent\": userAgent, ...headers },\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: request.signal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\trequest.cleanup();\n\t\t\t\tif (request.timedOut())\n\t\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"request_timed_out\", \"npm registry request timed out\");\n\t\t\t\tif (isAbortLike(error))\n\t\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"cancelled\", \"npm registry request was cancelled\");\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"request_failed\", \"npm registry request failed\");\n\t\t\t}\n\t\t\tif (!REDIRECT_STATUS.has(response.status)) return { response, request };\n\t\t\tconst location = response.headers.get(\"location\");\n\t\t\tawait response.body?.cancel().catch(() => undefined);\n\t\t\trequest.cleanup();\n\t\t\tif (location === null || redirect >= maxRedirects)\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"request_failed\", \"npm registry redirect limit exceeded\");\n\t\t\tcurrent = tarballUrl(new URL(location, current).toString());\n\t\t}\n\t};\n\n\tconst resolveNpmPackage = async (input: {\n\t\treadonly name: string;\n\t\treadonly range?: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<NodeNpmPackageResolutionV1> => {\n\t\tif (input.signal?.aborted === true)\n\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"cancelled\", \"npm registry request was cancelled\");\n\t\tconst endpoint = packumentUrl(registry, input.name);\n\t\tconst authorization: Readonly<Record<string, string>> =\n\t\t\ttoken === undefined ? {} : { authorization: `Bearer ${token}` };\n\t\tconst { response, request } = await fetchFollowingRedirects(endpoint, authorization, input.signal);\n\t\ttry {\n\t\t\tif (response.status === 404 || response.status === 403)\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"package_not_found\", \"npm package was not found on the registry\");\n\t\t\tif (response.status < 200 || response.status >= 300)\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"request_failed\", \"npm registry request did not succeed\");\n\t\t\tif (!isJsonResponse(response))\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", \"npm registry response must be JSON\");\n\t\t\tconst versions = parsePackument(await readBody(response, maxResponseBytes, request.signal));\n\t\t\tconst version = selectNpmPackageVersionV1(Object.keys(versions), input.range);\n\t\t\tconst dist = version === undefined ? undefined : versions[version]?.dist;\n\t\t\tif (\n\t\t\t\tversion === undefined ||\n\t\t\t\tdist === undefined ||\n\t\t\t\ttypeof dist.tarball !== \"string\" ||\n\t\t\t\tdist.tarball.length === 0\n\t\t\t) {\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\t\t\"version_not_found\",\n\t\t\t\t\t\"No npm package version matches the requested range\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst integrityValue = dist.integrity;\n\t\t\tconst integrity =\n\t\t\t\ttypeof integrityValue === \"string\" && integrityValue.length > 0\n\t\t\t\t\t? sriToIntegrityV1(integrityValue)\n\t\t\t\t\t: undefined;\n\t\t\tif (integrity === undefined)\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", \"npm package version has no integrity field\");\n\t\t\treturn {\n\t\t\t\tversion,\n\t\t\t\ttarballUrl: tarballUrl(dist.tarball).toString(),\n\t\t\t\tintegrity,\n\t\t\t\tdistInfo: dist as Readonly<Record<string, unknown>>,\n\t\t\t};\n\t\t} finally {\n\t\t\tawait response.body?.cancel().catch(() => undefined);\n\t\t\trequest.cleanup();\n\t\t}\n\t};\n\n\tconst fetchTarball = async (input: { readonly url: string; readonly signal?: AbortSignal }): Promise<Uint8Array> => {\n\t\tif (input.signal?.aborted === true)\n\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"cancelled\", \"npm tarball download was cancelled\");\n\t\tconst endpoint = tarballUrl(input.url);\n\t\tconst authorization: Readonly<Record<string, string>> =\n\t\t\ttoken === undefined ? {} : { authorization: `Bearer ${token}` };\n\t\tconst { response, request } = await fetchFollowingRedirects(endpoint, authorization, input.signal);\n\t\ttry {\n\t\t\tif (response.status < 200 || response.status >= 300)\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"request_failed\", \"npm tarball download did not succeed\");\n\t\t\treturn await readBody(response, maxTarballBytes, request.signal);\n\t\t} finally {\n\t\t\tawait response.body?.cancel().catch(() => undefined);\n\t\t\trequest.cleanup();\n\t\t}\n\t};\n\n\treturn { version: 1, registry, resolveNpmPackage, fetchTarball };\n}\n"]}
1
+ {"version":3,"file":"node-npm-registry-source.d.ts","sourceRoot":"","sources":["../../../src/plugins/ecosystem/node-npm-registry-source.ts"],"names":[],"mappings":"AAsBA,MAAM,MAAM,gCAAgC,GACzC,WAAW,GACX,uBAAuB,GACvB,gBAAgB,GAChB,mBAAmB,GACnB,kBAAkB,GAClB,oBAAoB,GACpB,mBAAmB,GACnB,mBAAmB,GACnB,uBAAuB,CAAC;AAE3B,qBAAa,4BAA6B,SAAQ,KAAK;IACtD,QAAQ,CAAC,IAAI,EAAE,gCAAgC,CAAC;IAEhD,YAAY,IAAI,EAAE,gCAAgC,EAAE,OAAO,EAAE,MAAM,EAIlE;CACD;AAED,4FAA4F;AAC5F,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACvC,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,8BAA8B;IAC9C,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE;QACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;KAC9B,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC1C,QAAQ,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CAC/G;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAgBhE;AAgBD;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAmBzG;AAsKD,6FAA6F;AAC7F,wBAAgB,6BAA6B,CAAC,OAAO,GAAE,8BAAmC,GAAG,uBAAuB,CA8InH","sourcesContent":["import { t } from \"../../core/i18n/index.ts\";\nimport { comparePluginVersionsV1 } from \"./catalog.ts\";\n\n/**\n * Minimal npm registry (packument) source for plugin package acquisition\n * (design `插件独立分发与启动装配设计.md` §4.2). It is a two-step protocol:\n * resolve the packument to pick one version, then fetch the tarball. It does\n * not implement `PluginRegistrySourceV1.list()`; the signed registry sources\n * keep serving private deployments unchanged.\n */\n\nconst DEFAULT_NPM_REGISTRY_V1 = \"https://registry.npmjs.org\";\nconst DEFAULT_TIMEOUT_MS_V1 = 15_000;\nconst MAX_TIMEOUT_MS_V1 = 120_000;\nconst DEFAULT_MAX_RESPONSE_BYTES_V1 = 8 * 1024 * 1024;\nconst MAX_RESPONSE_BYTES_V1 = 16 * 1024 * 1024;\nconst DEFAULT_MAX_TARBALL_BYTES_V1 = 128 * 1024 * 1024;\nconst MAX_TARBALL_BYTES_V1 = 512 * 1024 * 1024;\nconst DEFAULT_REDIRECTS_V1 = 3;\nconst MAX_REDIRECTS_V1 = 5;\nconst REDIRECT_STATUS = new Set([301, 302, 303, 307, 308]);\n\nexport type NodeNpmRegistrySourceErrorCodeV1 =\n\t| \"cancelled\"\n\t| \"invalid_configuration\"\n\t| \"request_failed\"\n\t| \"request_timed_out\"\n\t| \"invalid_response\"\n\t| \"response_too_large\"\n\t| \"package_not_found\"\n\t| \"version_not_found\"\n\t| \"integrity_unsupported\";\n\nexport class NodeNpmRegistrySourceErrorV1 extends Error {\n\treadonly code: NodeNpmRegistrySourceErrorCodeV1;\n\n\tconstructor(code: NodeNpmRegistrySourceErrorCodeV1, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"NodeNpmRegistrySourceErrorV1\";\n\t\tthis.code = code;\n\t}\n}\n\n/** SRI integrity as hex plus its algorithm, aligned with the install host digest format. */\nexport interface NodeNpmIntegrityV1 {\n\treadonly algorithm: \"sha256\" | \"sha512\";\n\treadonly hex: string;\n}\n\nexport interface NodeNpmPackageResolutionV1 {\n\treadonly version: string;\n\treadonly tarballUrl: string;\n\treadonly integrity: NodeNpmIntegrityV1;\n\t/** Raw `dist` fields of the selected version. */\n\treadonly distInfo: Readonly<Record<string, unknown>>;\n}\n\nexport interface NodeNpmRegistrySourceOptionsV1 {\n\t/** Bare http(s) registry origin; defaults to the npm public registry. */\n\treadonly registry?: string;\n\t/** Bearer token for private registries. */\n\treadonly token?: string;\n\t/** Real fetch or a deterministic test replacement. */\n\treadonly fetch?: typeof globalThis.fetch;\n\treadonly requestTimeoutMs?: number;\n\treadonly maxResponseBytes?: number;\n\treadonly maxTarballBytes?: number;\n\treadonly maxRedirects?: number;\n\treadonly userAgent?: string;\n}\n\nexport interface NodeNpmRegistrySourceV1 {\n\treadonly version: 1;\n\t/** Sanitized bare registry origin (no credentials, path, query, or fragment). */\n\treadonly registry: string;\n\treadonly resolveNpmPackage: (input: {\n\t\treadonly name: string;\n\t\treadonly range?: string;\n\t\treadonly signal?: AbortSignal;\n\t}) => Promise<NodeNpmPackageResolutionV1>;\n\treadonly fetchTarball: (input: { readonly url: string; readonly signal?: AbortSignal }) => Promise<Uint8Array>;\n}\n\n/** Convert an npm SRI string (`sha512-<base64>`, `sha256-<base64>`) to hex form. */\nexport function sriToIntegrityV1(sri: string): NodeNpmIntegrityV1 {\n\tconst match = /^(sha512|sha256)-([A-Za-z0-9+/]+={0,2})$/u.exec(sri.trim());\n\tif (match === null)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"integrity_unsupported\", t(\"npm integrity algorithm is unsupported\"));\n\tconst algorithm = match[1] as \"sha512\" | \"sha256\";\n\tlet raw: Buffer;\n\ttry {\n\t\traw = Buffer.from(match[2]!, \"base64\");\n\t} catch {\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"integrity_unsupported\", t(\"npm integrity encoding is invalid\"));\n\t}\n\tif ((algorithm === \"sha256\" && raw.byteLength !== 32) || (algorithm === \"sha512\" && raw.byteLength !== 64))\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"integrity_unsupported\", t(\"npm integrity length is invalid\"));\n\tconst hex = raw.toString(\"hex\").toLowerCase();\n\tif (hex.length === 0) throw new NodeNpmRegistrySourceErrorV1(\"integrity_unsupported\", t(\"npm integrity is invalid\"));\n\treturn { algorithm, hex };\n}\n\nfunction parseVersionTriple(value: string): readonly [number, number, number] | undefined {\n\tconst match = /^(\\d+)\\.(\\d+)\\.(\\d+)/u.exec(value.replace(/^[vV]/u, \"\"));\n\tif (match === null) return undefined;\n\tconst major = Number.parseInt(match[1]!, 10);\n\tconst minor = Number.parseInt(match[2]!, 10);\n\tconst patch = Number.parseInt(match[3]!, 10);\n\tif (!Number.isSafeInteger(major) || !Number.isSafeInteger(minor) || !Number.isSafeInteger(patch)) return undefined;\n\treturn [major, minor, patch] as const;\n}\n\nfunction plainVersion(value: string): string {\n\treturn value.replace(/^[vV]/u, \"\");\n}\n\n/**\n * Select the highest version satisfying a minimal range subset using the\n * ecosystem comparator (`comparePluginVersionsV1`): `undefined`/`latest` →\n * highest; `x.y.z` → exact full match (prerelease suffix included);\n * `^x.y.z` → >= x.y.z and < (x+1).0.0; `~x.y.z` → >= x.y.z and\n * < x.(y+1).0. Bounds use the comparator ordering (e.g. `1.0.0-alpha`\n * sorts below `1.0.0`).\n */\nexport function selectNpmPackageVersionV1(versions: readonly string[], range?: string): string | undefined {\n\tif (!Array.isArray(versions)) return undefined;\n\tlet candidates = versions.filter((value) => typeof value === \"string\" && parseVersionTriple(value) !== undefined);\n\tif (candidates.length === 0) return undefined;\n\tif (range === undefined || range === \"latest\") {\n\t\treturn candidates.reduce((left, right) => (comparePluginVersionsV1(right, left) > 0 ? right : left));\n\t}\n\tconst exact = plainVersion(range.replace(/^[=~^]/u, \"\"));\n\tif (!range.startsWith(\"^\") && !range.startsWith(\"~\"))\n\t\treturn candidates.find((value) => plainVersion(value) === exact);\n\tconst bound = parseVersionTriple(exact);\n\tif (bound === undefined) return undefined;\n\tconst [major, minor] = bound;\n\tconst upper = range.startsWith(\"^\") ? `${major + 1}.0.0` : `${major}.${minor + 1}.0`;\n\tcandidates = candidates.filter(\n\t\t(value) => comparePluginVersionsV1(value, exact) >= 0 && comparePluginVersionsV1(value, upper) < 0,\n\t);\n\tif (candidates.length === 0) return undefined;\n\treturn candidates.reduce((left, right) => (comparePluginVersionsV1(right, left) > 0 ? right : left));\n}\n\nfunction boundedPositive(value: number | undefined, fallback: number, maximum: number, label: string): number {\n\tconst result = value ?? fallback;\n\tif (!Number.isSafeInteger(result) || result <= 0 || result > maximum)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\tt(\"{label} must be a positive integer at most {maximum}\", { label, maximum }),\n\t\t);\n\treturn result;\n}\n\nfunction registryOrigin(value: string): string {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_configuration\", t(\"npm registry origin is invalid\"));\n\t}\n\tif (\n\t\t(parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") ||\n\t\tparsed.username !== \"\" ||\n\t\tparsed.password !== \"\"\n\t)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\tt(\"npm registry origin must be http(s) without credentials\"),\n\t\t);\n\tif (parsed.pathname !== \"/\" || parsed.search !== \"\" || parsed.hash !== \"\")\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\tt(\"npm registry origin must not include a path, query, or fragment\"),\n\t\t);\n\treturn parsed.origin;\n}\n\nfunction packumentUrl(registryOriginValue: string, name: string): URL {\n\tconst scopeAt = name.indexOf(\"/\");\n\tif (name.startsWith(\"@\") && scopeAt > 0) {\n\t\t// npm registry convention keeps the leading scope literal and percent\n\t\t// encodes the rest of the name, including the separating slash.\n\t\tconst scope = name.slice(0, scopeAt);\n\t\tconst packageName = name.slice(scopeAt + 1);\n\t\treturn new URL(`${registryOriginValue}/${scope}%2F${encodeURIComponent(packageName)}`);\n\t}\n\tif (scopeAt >= 0) throw new NodeNpmRegistrySourceErrorV1(\"invalid_configuration\", t(\"npm package name is invalid\"));\n\treturn new URL(`${registryOriginValue}/${encodeURIComponent(name)}`);\n}\n\nfunction tarballUrl(value: string): URL {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", t(\"npm tarball URL is invalid\"));\n\t}\n\tif (\n\t\t(parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") ||\n\t\tparsed.username !== \"\" ||\n\t\tparsed.password !== \"\"\n\t)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\"invalid_response\",\n\t\t\tt(\"npm tarball URL must use http(s) without credentials\"),\n\t\t);\n\tif (parsed.hash !== \"\")\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", t(\"npm tarball URL must not include a fragment\"));\n\treturn parsed;\n}\n\nfunction isAbortLike(error: unknown): boolean {\n\treturn error instanceof Error && (error.name === \"AbortError\" || error.name === \"AbortSignalError\");\n}\n\ninterface RequestSignal {\n\treadonly signal: AbortSignal;\n\treadonly timedOut: () => boolean;\n\treadonly cleanup: () => void;\n}\n\nfunction requestSignal(parent: AbortSignal | undefined, timeoutMs: number): RequestSignal {\n\tconst controller = new AbortController();\n\tlet timedOut = false;\n\tconst abort = () => controller.abort(parent?.reason);\n\tif (parent?.aborted === true) abort();\n\telse parent?.addEventListener(\"abort\", abort, { once: true });\n\tconst timeout = setTimeout(() => {\n\t\ttimedOut = true;\n\t\tcontroller.abort();\n\t}, timeoutMs);\n\treturn {\n\t\tsignal: controller.signal,\n\t\ttimedOut: () => timedOut,\n\t\tcleanup: () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tparent?.removeEventListener(\"abort\", abort);\n\t\t},\n\t};\n}\n\nfunction isJsonResponse(response: Response): boolean {\n\tconst contentType = response.headers.get(\"content-type\");\n\tif (contentType === null) return false;\n\tconst mediaType = contentType.split(\";\", 1)[0]?.trim().toLowerCase();\n\treturn mediaType === \"application/json\" || mediaType === \"application/vnd.npm.install-v1+json\";\n}\n\nasync function readBody(response: Response, maxBytes: number, signal: AbortSignal): Promise<Uint8Array> {\n\tif (response.body === null)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", t(\"npm registry response has no body\"));\n\tconst reader = response.body.getReader();\n\tconst chunks: Uint8Array[] = [];\n\tlet total = 0;\n\ttry {\n\t\tfor (;;) {\n\t\t\tif (signal.aborted) throw new DOMException(t(\"aborted\"), \"AbortError\");\n\t\t\tconst item = await reader.read();\n\t\t\tif (item.done) break;\n\t\t\ttotal += item.value.byteLength;\n\t\t\tif (total > maxBytes)\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\t\t\"response_too_large\",\n\t\t\t\t\tt(\"npm registry response exceeds the configured size limit\"),\n\t\t\t\t);\n\t\t\tchunks.push(item.value);\n\t\t}\n\t} finally {\n\t\treader.releaseLock();\n\t}\n\tconst bytes = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const chunk of chunks) {\n\t\tbytes.set(chunk, offset);\n\t\toffset += chunk.byteLength;\n\t}\n\treturn bytes;\n}\n\ninterface PackumentVersionDistV1 {\n\treadonly tarball?: unknown;\n\treadonly integrity?: unknown;\n}\n\ninterface PackumentVersionV1 {\n\treadonly dist?: PackumentVersionDistV1;\n}\n\ninterface PackumentV1 {\n\treadonly versions?: Readonly<Record<string, PackumentVersionV1>>;\n}\n\nfunction parsePackument(bytes: Uint8Array): Readonly<Record<string, PackumentVersionV1>> {\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes));\n\t} catch {\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", t(\"npm registry response is not valid JSON\"));\n\t}\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value))\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", t(\"npm packument is invalid\"));\n\tconst packument = value as PackumentV1;\n\tif (typeof packument.versions !== \"object\" || packument.versions === null || Array.isArray(packument.versions))\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", t(\"npm packument has no version table\"));\n\treturn packument.versions;\n}\n\n/** Create a bounded npm registry reader. Version selection uses the ecosystem comparator. */\nexport function createNodeNpmRegistrySourceV1(options: NodeNpmRegistrySourceOptionsV1 = {}): NodeNpmRegistrySourceV1 {\n\tconst transport = options.fetch ?? globalThis.fetch;\n\tif (typeof transport !== \"function\")\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_configuration\", t(\"Node fetch is unavailable\"));\n\tconst registry = registryOrigin(options.registry ?? DEFAULT_NPM_REGISTRY_V1);\n\tif (\n\t\toptions.token !== undefined &&\n\t\t(options.token.length === 0 || options.token.length > 4096 || /[\\r\\n\\s]/u.test(options.token))\n\t)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_configuration\", t(\"npm registry token is invalid\"));\n\tconst token = options.token;\n\tconst timeoutMs = boundedPositive(\n\t\toptions.requestTimeoutMs,\n\t\tDEFAULT_TIMEOUT_MS_V1,\n\t\tMAX_TIMEOUT_MS_V1,\n\t\t\"requestTimeoutMs\",\n\t);\n\tconst maxResponseBytes = boundedPositive(\n\t\toptions.maxResponseBytes,\n\t\tDEFAULT_MAX_RESPONSE_BYTES_V1,\n\t\tMAX_RESPONSE_BYTES_V1,\n\t\t\"maxResponseBytes\",\n\t);\n\tconst maxTarballBytes = boundedPositive(\n\t\toptions.maxTarballBytes,\n\t\tDEFAULT_MAX_TARBALL_BYTES_V1,\n\t\tMAX_TARBALL_BYTES_V1,\n\t\t\"maxTarballBytes\",\n\t);\n\tconst maxRedirects = options.maxRedirects ?? DEFAULT_REDIRECTS_V1;\n\tif (!Number.isSafeInteger(maxRedirects) || maxRedirects < 0 || maxRedirects > MAX_REDIRECTS_V1)\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\"invalid_configuration\",\n\t\t\tt(\"maxRedirects must be an integer between 0 and {max}\", { max: MAX_REDIRECTS_V1 }),\n\t\t);\n\tconst userAgent = options.userAgent ?? \"agent-forge-plugin-npm/1\";\n\tif (userAgent.length === 0 || userAgent.length > 256 || /[\\r\\n]/u.test(userAgent))\n\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_configuration\", t(\"userAgent is invalid\"));\n\n\tconst fetchFollowingRedirects = async (\n\t\turl: URL,\n\t\theaders: Readonly<Record<string, string>>,\n\t\tparentSignal: AbortSignal | undefined,\n\t): Promise<{ readonly response: Response; readonly request: RequestSignal }> => {\n\t\tlet current = url;\n\t\tfor (let redirect = 0; ; redirect += 1) {\n\t\t\tconst request = requestSignal(parentSignal, timeoutMs);\n\t\t\tlet response: Response;\n\t\t\ttry {\n\t\t\t\tresponse = await transport(current.toString(), {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: { accept: \"*/*\", \"user-agent\": userAgent, ...headers },\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: request.signal,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\trequest.cleanup();\n\t\t\t\tif (request.timedOut())\n\t\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"request_timed_out\", t(\"npm registry request timed out\"));\n\t\t\t\tif (isAbortLike(error))\n\t\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"cancelled\", t(\"npm registry request was cancelled\"));\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"request_failed\", t(\"npm registry request failed\"));\n\t\t\t}\n\t\t\tif (!REDIRECT_STATUS.has(response.status)) return { response, request };\n\t\t\tconst location = response.headers.get(\"location\");\n\t\t\tawait response.body?.cancel().catch(() => undefined);\n\t\t\trequest.cleanup();\n\t\t\tif (location === null || redirect >= maxRedirects)\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"request_failed\", t(\"npm registry redirect limit exceeded\"));\n\t\t\tcurrent = tarballUrl(new URL(location, current).toString());\n\t\t}\n\t};\n\n\tconst resolveNpmPackage = async (input: {\n\t\treadonly name: string;\n\t\treadonly range?: string;\n\t\treadonly signal?: AbortSignal;\n\t}): Promise<NodeNpmPackageResolutionV1> => {\n\t\tif (input.signal?.aborted === true)\n\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"cancelled\", t(\"npm registry request was cancelled\"));\n\t\tconst endpoint = packumentUrl(registry, input.name);\n\t\tconst authorization: Readonly<Record<string, string>> =\n\t\t\ttoken === undefined ? {} : { authorization: `Bearer ${token}` };\n\t\tconst { response, request } = await fetchFollowingRedirects(endpoint, authorization, input.signal);\n\t\ttry {\n\t\t\tif (response.status === 404 || response.status === 403)\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"package_not_found\", t(\"npm package was not found on the registry\"));\n\t\t\tif (response.status < 200 || response.status >= 300)\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"request_failed\", t(\"npm registry request did not succeed\"));\n\t\t\tif (!isJsonResponse(response))\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", t(\"npm registry response must be JSON\"));\n\t\t\tconst versions = parsePackument(await readBody(response, maxResponseBytes, request.signal));\n\t\t\tconst version = selectNpmPackageVersionV1(Object.keys(versions), input.range);\n\t\t\tconst dist = version === undefined ? undefined : versions[version]?.dist;\n\t\t\tif (\n\t\t\t\tversion === undefined ||\n\t\t\t\tdist === undefined ||\n\t\t\t\ttypeof dist.tarball !== \"string\" ||\n\t\t\t\tdist.tarball.length === 0\n\t\t\t) {\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\n\t\t\t\t\t\"version_not_found\",\n\t\t\t\t\tt(\"No npm package version matches the requested range\"),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst integrityValue = dist.integrity;\n\t\t\tconst integrity =\n\t\t\t\ttypeof integrityValue === \"string\" && integrityValue.length > 0\n\t\t\t\t\t? sriToIntegrityV1(integrityValue)\n\t\t\t\t\t: undefined;\n\t\t\tif (integrity === undefined)\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"invalid_response\", t(\"npm package version has no integrity field\"));\n\t\t\treturn {\n\t\t\t\tversion,\n\t\t\t\ttarballUrl: tarballUrl(dist.tarball).toString(),\n\t\t\t\tintegrity,\n\t\t\t\tdistInfo: dist as Readonly<Record<string, unknown>>,\n\t\t\t};\n\t\t} finally {\n\t\t\tawait response.body?.cancel().catch(() => undefined);\n\t\t\trequest.cleanup();\n\t\t}\n\t};\n\n\tconst fetchTarball = async (input: { readonly url: string; readonly signal?: AbortSignal }): Promise<Uint8Array> => {\n\t\tif (input.signal?.aborted === true)\n\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"cancelled\", t(\"npm tarball download was cancelled\"));\n\t\tconst endpoint = tarballUrl(input.url);\n\t\tconst authorization: Readonly<Record<string, string>> =\n\t\t\ttoken === undefined ? {} : { authorization: `Bearer ${token}` };\n\t\tconst { response, request } = await fetchFollowingRedirects(endpoint, authorization, input.signal);\n\t\ttry {\n\t\t\tif (response.status < 200 || response.status >= 300)\n\t\t\t\tthrow new NodeNpmRegistrySourceErrorV1(\"request_failed\", t(\"npm tarball download did not succeed\"));\n\t\t\treturn await readBody(response, maxTarballBytes, request.signal);\n\t\t} finally {\n\t\t\tawait response.body?.cancel().catch(() => undefined);\n\t\t\trequest.cleanup();\n\t\t}\n\t};\n\n\treturn { version: 1, registry, resolveNpmPackage, fetchTarball };\n}\n"]}