@harborclient/core 0.1.1

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 (736) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +21 -0
  3. package/README.md +36 -0
  4. package/dist/ai/chatComposer.d.ts +12 -0
  5. package/dist/ai/chatComposer.d.ts.map +1 -0
  6. package/dist/ai/chatComposer.js +20 -0
  7. package/dist/ai/chatComposer.js.map +1 -0
  8. package/dist/ai/chatContext.d.ts +181 -0
  9. package/dist/ai/chatContext.d.ts.map +1 -0
  10. package/dist/ai/chatContext.js +168 -0
  11. package/dist/ai/chatContext.js.map +1 -0
  12. package/dist/ai/chatStepMode.d.ts +43 -0
  13. package/dist/ai/chatStepMode.d.ts.map +1 -0
  14. package/dist/ai/chatStepMode.js +64 -0
  15. package/dist/ai/chatStepMode.js.map +1 -0
  16. package/dist/ai/chatTitle.d.ts +35 -0
  17. package/dist/ai/chatTitle.d.ts.map +1 -0
  18. package/dist/ai/chatTitle.js +109 -0
  19. package/dist/ai/chatTitle.js.map +1 -0
  20. package/dist/ai/gitCommitMessage.d.ts +47 -0
  21. package/dist/ai/gitCommitMessage.d.ts.map +1 -0
  22. package/dist/ai/gitCommitMessage.js +139 -0
  23. package/dist/ai/gitCommitMessage.js.map +1 -0
  24. package/dist/ai/models.d.ts +115 -0
  25. package/dist/ai/models.d.ts.map +1 -0
  26. package/dist/ai/models.js +209 -0
  27. package/dist/ai/models.js.map +1 -0
  28. package/dist/ai/requestUpdate.d.ts +273 -0
  29. package/dist/ai/requestUpdate.d.ts.map +1 -0
  30. package/dist/ai/requestUpdate.js +274 -0
  31. package/dist/ai/requestUpdate.js.map +1 -0
  32. package/dist/ai/scriptAsk.d.ts +115 -0
  33. package/dist/ai/scriptAsk.d.ts.map +1 -0
  34. package/dist/ai/scriptAsk.js +243 -0
  35. package/dist/ai/scriptAsk.js.map +1 -0
  36. package/dist/ai/scriptReferences.d.ts +377 -0
  37. package/dist/ai/scriptReferences.d.ts.map +1 -0
  38. package/dist/ai/scriptReferences.js +787 -0
  39. package/dist/ai/scriptReferences.js.map +1 -0
  40. package/dist/ai/settings.d.ts +8 -0
  41. package/dist/ai/settings.d.ts.map +1 -0
  42. package/dist/ai/settings.js +11 -0
  43. package/dist/ai/settings.js.map +1 -0
  44. package/dist/ai/tools/ITool.d.ts +26 -0
  45. package/dist/ai/tools/ITool.d.ts.map +1 -0
  46. package/dist/ai/tools/ITool.js +2 -0
  47. package/dist/ai/tools/ITool.js.map +1 -0
  48. package/dist/ai/tools/createCollection.d.ts +164 -0
  49. package/dist/ai/tools/createCollection.d.ts.map +1 -0
  50. package/dist/ai/tools/createCollection.js +36 -0
  51. package/dist/ai/tools/createCollection.js.map +1 -0
  52. package/dist/ai/tools/createFolder.d.ts +50 -0
  53. package/dist/ai/tools/createFolder.d.ts.map +1 -0
  54. package/dist/ai/tools/createFolder.js +34 -0
  55. package/dist/ai/tools/createFolder.js.map +1 -0
  56. package/dist/ai/tools/createRequest.d.ts +210 -0
  57. package/dist/ai/tools/createRequest.d.ts.map +1 -0
  58. package/dist/ai/tools/createRequest.js +88 -0
  59. package/dist/ai/tools/createRequest.js.map +1 -0
  60. package/dist/ai/tools/getActiveRequest.d.ts +20 -0
  61. package/dist/ai/tools/getActiveRequest.d.ts.map +1 -0
  62. package/dist/ai/tools/getActiveRequest.js +16 -0
  63. package/dist/ai/tools/getActiveRequest.js.map +1 -0
  64. package/dist/ai/tools/getActiveRequestDetails.d.ts +20 -0
  65. package/dist/ai/tools/getActiveRequestDetails.d.ts.map +1 -0
  66. package/dist/ai/tools/getActiveRequestDetails.js +16 -0
  67. package/dist/ai/tools/getActiveRequestDetails.js.map +1 -0
  68. package/dist/ai/tools/getActiveResponse.d.ts +39 -0
  69. package/dist/ai/tools/getActiveResponse.d.ts.map +1 -0
  70. package/dist/ai/tools/getActiveResponse.js +30 -0
  71. package/dist/ai/tools/getActiveResponse.js.map +1 -0
  72. package/dist/ai/tools/getActiveResponseSummary.d.ts +20 -0
  73. package/dist/ai/tools/getActiveResponseSummary.d.ts.map +1 -0
  74. package/dist/ai/tools/getActiveResponseSummary.js +16 -0
  75. package/dist/ai/tools/getActiveResponseSummary.js.map +1 -0
  76. package/dist/ai/tools/getActiveTerminal.d.ts +20 -0
  77. package/dist/ai/tools/getActiveTerminal.d.ts.map +1 -0
  78. package/dist/ai/tools/getActiveTerminal.js +16 -0
  79. package/dist/ai/tools/getActiveTerminal.js.map +1 -0
  80. package/dist/ai/tools/getActiveTerminalLines.d.ts +50 -0
  81. package/dist/ai/tools/getActiveTerminalLines.d.ts.map +1 -0
  82. package/dist/ai/tools/getActiveTerminalLines.js +37 -0
  83. package/dist/ai/tools/getActiveTerminalLines.js.map +1 -0
  84. package/dist/ai/tools/getCollection.d.ts +31 -0
  85. package/dist/ai/tools/getCollection.d.ts.map +1 -0
  86. package/dist/ai/tools/getCollection.js +28 -0
  87. package/dist/ai/tools/getCollection.js.map +1 -0
  88. package/dist/ai/tools/getFolder.d.ts +31 -0
  89. package/dist/ai/tools/getFolder.d.ts.map +1 -0
  90. package/dist/ai/tools/getFolder.js +28 -0
  91. package/dist/ai/tools/getFolder.js.map +1 -0
  92. package/dist/ai/tools/getMarkdownDocument.d.ts +40 -0
  93. package/dist/ai/tools/getMarkdownDocument.d.ts.map +1 -0
  94. package/dist/ai/tools/getMarkdownDocument.js +31 -0
  95. package/dist/ai/tools/getMarkdownDocument.js.map +1 -0
  96. package/dist/ai/tools/getRequest.d.ts +31 -0
  97. package/dist/ai/tools/getRequest.d.ts.map +1 -0
  98. package/dist/ai/tools/getRequest.js +28 -0
  99. package/dist/ai/tools/getRequest.js.map +1 -0
  100. package/dist/ai/tools/getSelectedCollection.d.ts +20 -0
  101. package/dist/ai/tools/getSelectedCollection.d.ts.map +1 -0
  102. package/dist/ai/tools/getSelectedCollection.js +16 -0
  103. package/dist/ai/tools/getSelectedCollection.js.map +1 -0
  104. package/dist/ai/tools/getSidebarRequest.d.ts +20 -0
  105. package/dist/ai/tools/getSidebarRequest.d.ts.map +1 -0
  106. package/dist/ai/tools/getSidebarRequest.js +16 -0
  107. package/dist/ai/tools/getSidebarRequest.js.map +1 -0
  108. package/dist/ai/tools/gitCommits.d.ts +50 -0
  109. package/dist/ai/tools/gitCommits.d.ts.map +1 -0
  110. package/dist/ai/tools/gitCommits.js +37 -0
  111. package/dist/ai/tools/gitCommits.js.map +1 -0
  112. package/dist/ai/tools/gitDiff.d.ts +70 -0
  113. package/dist/ai/tools/gitDiff.d.ts.map +1 -0
  114. package/dist/ai/tools/gitDiff.js +49 -0
  115. package/dist/ai/tools/gitDiff.js.map +1 -0
  116. package/dist/ai/tools/gitFileDiff.d.ts +80 -0
  117. package/dist/ai/tools/gitFileDiff.d.ts.map +1 -0
  118. package/dist/ai/tools/gitFileDiff.js +55 -0
  119. package/dist/ai/tools/gitFileDiff.js.map +1 -0
  120. package/dist/ai/tools/gitFileInfo.d.ts +60 -0
  121. package/dist/ai/tools/gitFileInfo.d.ts.map +1 -0
  122. package/dist/ai/tools/gitFileInfo.js +43 -0
  123. package/dist/ai/tools/gitFileInfo.js.map +1 -0
  124. package/dist/ai/tools/gitRepoInfo.d.ts +40 -0
  125. package/dist/ai/tools/gitRepoInfo.d.ts.map +1 -0
  126. package/dist/ai/tools/gitRepoInfo.js +31 -0
  127. package/dist/ai/tools/gitRepoInfo.js.map +1 -0
  128. package/dist/ai/tools/index.d.ts +1260 -0
  129. package/dist/ai/tools/index.d.ts.map +1 -0
  130. package/dist/ai/tools/index.js +100 -0
  131. package/dist/ai/tools/index.js.map +1 -0
  132. package/dist/ai/tools/listCollections.d.ts +20 -0
  133. package/dist/ai/tools/listCollections.d.ts.map +1 -0
  134. package/dist/ai/tools/listCollections.js +16 -0
  135. package/dist/ai/tools/listCollections.js.map +1 -0
  136. package/dist/ai/tools/listEnvironments.d.ts +20 -0
  137. package/dist/ai/tools/listEnvironments.d.ts.map +1 -0
  138. package/dist/ai/tools/listEnvironments.js +16 -0
  139. package/dist/ai/tools/listEnvironments.js.map +1 -0
  140. package/dist/ai/tools/listRequests.d.ts +40 -0
  141. package/dist/ai/tools/listRequests.d.ts.map +1 -0
  142. package/dist/ai/tools/listRequests.js +28 -0
  143. package/dist/ai/tools/listRequests.js.map +1 -0
  144. package/dist/ai/tools/queryResponseBody.d.ts +50 -0
  145. package/dist/ai/tools/queryResponseBody.d.ts.map +1 -0
  146. package/dist/ai/tools/queryResponseBody.js +37 -0
  147. package/dist/ai/tools/queryResponseBody.js.map +1 -0
  148. package/dist/ai/tools/schemas.d.ts +152 -0
  149. package/dist/ai/tools/schemas.d.ts.map +1 -0
  150. package/dist/ai/tools/schemas.js +81 -0
  151. package/dist/ai/tools/schemas.js.map +1 -0
  152. package/dist/ai/tools/searchDocs.d.ts +64 -0
  153. package/dist/ai/tools/searchDocs.d.ts.map +1 -0
  154. package/dist/ai/tools/searchDocs.js +44 -0
  155. package/dist/ai/tools/searchDocs.js.map +1 -0
  156. package/dist/ai/tools/sendActiveRequest.d.ts +39 -0
  157. package/dist/ai/tools/sendActiveRequest.d.ts.map +1 -0
  158. package/dist/ai/tools/sendActiveRequest.js +30 -0
  159. package/dist/ai/tools/sendActiveRequest.js.map +1 -0
  160. package/dist/ai/tools/setActiveEnvironment.d.ts +49 -0
  161. package/dist/ai/tools/setActiveEnvironment.d.ts.map +1 -0
  162. package/dist/ai/tools/setActiveEnvironment.js +36 -0
  163. package/dist/ai/tools/setActiveEnvironment.js.map +1 -0
  164. package/dist/ai/tools/systemPrompt.d.ts +5 -0
  165. package/dist/ai/tools/systemPrompt.d.ts.map +1 -0
  166. package/dist/ai/tools/systemPrompt.js +34 -0
  167. package/dist/ai/tools/systemPrompt.js.map +1 -0
  168. package/dist/ai/tools/terminalExec.d.ts +40 -0
  169. package/dist/ai/tools/terminalExec.d.ts.map +1 -0
  170. package/dist/ai/tools/terminalExec.js +31 -0
  171. package/dist/ai/tools/terminalExec.js.map +1 -0
  172. package/dist/ai/tools/types.d.ts +68 -0
  173. package/dist/ai/tools/types.d.ts.map +1 -0
  174. package/dist/ai/tools/types.js +2 -0
  175. package/dist/ai/tools/types.js.map +1 -0
  176. package/dist/ai/tools/updateActiveRequest.d.ts +279 -0
  177. package/dist/ai/tools/updateActiveRequest.d.ts.map +1 -0
  178. package/dist/ai/tools/updateActiveRequest.js +175 -0
  179. package/dist/ai/tools/updateActiveRequest.js.map +1 -0
  180. package/dist/ai/tools/updateRequestScript.d.ts +93 -0
  181. package/dist/ai/tools/updateRequestScript.d.ts.map +1 -0
  182. package/dist/ai/tools/updateRequestScript.js +57 -0
  183. package/dist/ai/tools/updateRequestScript.js.map +1 -0
  184. package/dist/auth.d.ts +192 -0
  185. package/dist/auth.d.ts.map +1 -0
  186. package/dist/auth.js +294 -0
  187. package/dist/auth.js.map +1 -0
  188. package/dist/bodyRawSend.d.ts +25 -0
  189. package/dist/bodyRawSend.d.ts.map +1 -0
  190. package/dist/bodyRawSend.js +61 -0
  191. package/dist/bodyRawSend.js.map +1 -0
  192. package/dist/builtinThemes.d.ts +33 -0
  193. package/dist/builtinThemes.d.ts.map +1 -0
  194. package/dist/builtinThemes.js +40 -0
  195. package/dist/builtinThemes.js.map +1 -0
  196. package/dist/codeEditorSettings.d.ts +2 -0
  197. package/dist/codeEditorSettings.d.ts.map +1 -0
  198. package/dist/codeEditorSettings.js +2 -0
  199. package/dist/codeEditorSettings.js.map +1 -0
  200. package/dist/collectionContainerOrder.d.ts +42 -0
  201. package/dist/collectionContainerOrder.d.ts.map +1 -0
  202. package/dist/collectionContainerOrder.js +62 -0
  203. package/dist/collectionContainerOrder.js.map +1 -0
  204. package/dist/collectionRunner.d.ts +510 -0
  205. package/dist/collectionRunner.d.ts.map +1 -0
  206. package/dist/collectionRunner.js +296 -0
  207. package/dist/collectionRunner.js.map +1 -0
  208. package/dist/contrast.d.ts +16 -0
  209. package/dist/contrast.d.ts.map +1 -0
  210. package/dist/contrast.js +51 -0
  211. package/dist/contrast.js.map +1 -0
  212. package/dist/cookies/CookieJar.d.ts +151 -0
  213. package/dist/cookies/CookieJar.d.ts.map +1 -0
  214. package/dist/cookies/CookieJar.js +318 -0
  215. package/dist/cookies/CookieJar.js.map +1 -0
  216. package/dist/deepLink.d.ts +98 -0
  217. package/dist/deepLink.d.ts.map +1 -0
  218. package/dist/deepLink.js +211 -0
  219. package/dist/deepLink.js.map +1 -0
  220. package/dist/environmentVariables.d.ts +34 -0
  221. package/dist/environmentVariables.d.ts.map +1 -0
  222. package/dist/environmentVariables.js +56 -0
  223. package/dist/environmentVariables.js.map +1 -0
  224. package/dist/filestore/index.d.ts +16 -0
  225. package/dist/filestore/index.d.ts.map +1 -0
  226. package/dist/filestore/index.js +16 -0
  227. package/dist/filestore/index.js.map +1 -0
  228. package/dist/filestore/parse.d.ts +44 -0
  229. package/dist/filestore/parse.d.ts.map +1 -0
  230. package/dist/filestore/parse.js +80 -0
  231. package/dist/filestore/parse.js.map +1 -0
  232. package/dist/filestore/schemas.d.ts +1612 -0
  233. package/dist/filestore/schemas.d.ts.map +1 -0
  234. package/dist/filestore/schemas.js +586 -0
  235. package/dist/filestore/schemas.js.map +1 -0
  236. package/dist/filestore/snippet.d.ts +10 -0
  237. package/dist/filestore/snippet.d.ts.map +1 -0
  238. package/dist/filestore/snippet.js +43 -0
  239. package/dist/filestore/snippet.js.map +1 -0
  240. package/dist/filestore/storageSchemas.d.ts +123 -0
  241. package/dist/filestore/storageSchemas.d.ts.map +1 -0
  242. package/dist/filestore/storageSchemas.js +94 -0
  243. package/dist/filestore/storageSchemas.js.map +1 -0
  244. package/dist/filestore/stringify.d.ts +59 -0
  245. package/dist/filestore/stringify.d.ts.map +1 -0
  246. package/dist/filestore/stringify.js +103 -0
  247. package/dist/filestore/stringify.js.map +1 -0
  248. package/dist/filestore/validate.d.ts +60 -0
  249. package/dist/filestore/validate.d.ts.map +1 -0
  250. package/dist/filestore/validate.js +118 -0
  251. package/dist/filestore/validate.js.map +1 -0
  252. package/dist/filestore/variables.d.ts +9 -0
  253. package/dist/filestore/variables.d.ts.map +1 -0
  254. package/dist/filestore/variables.js +15 -0
  255. package/dist/filestore/variables.js.map +1 -0
  256. package/dist/formData.d.ts +2 -0
  257. package/dist/formData.d.ts.map +1 -0
  258. package/dist/formData.js +2 -0
  259. package/dist/formData.js.map +1 -0
  260. package/dist/generalSettings.d.ts +22 -0
  261. package/dist/generalSettings.d.ts.map +1 -0
  262. package/dist/generalSettings.js +188 -0
  263. package/dist/generalSettings.js.map +1 -0
  264. package/dist/gitHttpErrors.d.ts +125 -0
  265. package/dist/gitHttpErrors.d.ts.map +1 -0
  266. package/dist/gitHttpErrors.js +271 -0
  267. package/dist/gitHttpErrors.js.map +1 -0
  268. package/dist/gitSidebarExpansion.d.ts +22 -0
  269. package/dist/gitSidebarExpansion.d.ts.map +1 -0
  270. package/dist/gitSidebarExpansion.js +16 -0
  271. package/dist/gitSidebarExpansion.js.map +1 -0
  272. package/dist/gitUrl.d.ts +39 -0
  273. package/dist/gitUrl.d.ts.map +1 -0
  274. package/dist/gitUrl.js +105 -0
  275. package/dist/gitUrl.js.map +1 -0
  276. package/dist/harborclientExport.d.ts +23 -0
  277. package/dist/harborclientExport.d.ts.map +1 -0
  278. package/dist/harborclientExport.js +39 -0
  279. package/dist/harborclientExport.js.map +1 -0
  280. package/dist/highContrastPalette.d.ts +91 -0
  281. package/dist/highContrastPalette.d.ts.map +1 -0
  282. package/dist/highContrastPalette.js +118 -0
  283. package/dist/highContrastPalette.js.map +1 -0
  284. package/dist/httpHeaders.d.ts +2 -0
  285. package/dist/httpHeaders.d.ts.map +1 -0
  286. package/dist/httpHeaders.js +2 -0
  287. package/dist/httpHeaders.js.map +1 -0
  288. package/dist/httpMethod.d.ts +9 -0
  289. package/dist/httpMethod.d.ts.map +1 -0
  290. package/dist/httpMethod.js +23 -0
  291. package/dist/httpMethod.js.map +1 -0
  292. package/dist/index.d.ts +18 -0
  293. package/dist/index.d.ts.map +1 -0
  294. package/dist/index.js +16 -0
  295. package/dist/index.js.map +1 -0
  296. package/dist/interfaces/ICookieJar.d.ts +41 -0
  297. package/dist/interfaces/ICookieJar.d.ts.map +1 -0
  298. package/dist/interfaces/ICookieJar.js +2 -0
  299. package/dist/interfaces/ICookieJar.js.map +1 -0
  300. package/dist/interfaces/IScriptRunner.d.ts +20 -0
  301. package/dist/interfaces/IScriptRunner.d.ts.map +1 -0
  302. package/dist/interfaces/IScriptRunner.js +2 -0
  303. package/dist/interfaces/IScriptRunner.js.map +1 -0
  304. package/dist/interfaces/PluginHooks.d.ts +24 -0
  305. package/dist/interfaces/PluginHooks.d.ts.map +1 -0
  306. package/dist/interfaces/PluginHooks.js +2 -0
  307. package/dist/interfaces/PluginHooks.js.map +1 -0
  308. package/dist/interfaces/SettingsProvider.d.ts +20 -0
  309. package/dist/interfaces/SettingsProvider.d.ts.map +1 -0
  310. package/dist/interfaces/SettingsProvider.js +2 -0
  311. package/dist/interfaces/SettingsProvider.js.map +1 -0
  312. package/dist/interfaces/index.d.ts +5 -0
  313. package/dist/interfaces/index.d.ts.map +1 -0
  314. package/dist/interfaces/index.js +2 -0
  315. package/dist/interfaces/index.js.map +1 -0
  316. package/dist/mcpToolNames.d.ts +27 -0
  317. package/dist/mcpToolNames.d.ts.map +1 -0
  318. package/dist/mcpToolNames.js +41 -0
  319. package/dist/mcpToolNames.js.map +1 -0
  320. package/dist/multipartRaw.d.ts +85 -0
  321. package/dist/multipartRaw.d.ts.map +1 -0
  322. package/dist/multipartRaw.js +244 -0
  323. package/dist/multipartRaw.js.map +1 -0
  324. package/dist/network/executeHttpSend.d.ts +39 -0
  325. package/dist/network/executeHttpSend.d.ts.map +1 -0
  326. package/dist/network/executeHttpSend.js +60 -0
  327. package/dist/network/executeHttpSend.js.map +1 -0
  328. package/dist/pageSidebarSection.d.ts +35 -0
  329. package/dist/pageSidebarSection.d.ts.map +1 -0
  330. package/dist/pageSidebarSection.js +76 -0
  331. package/dist/pageSidebarSection.js.map +1 -0
  332. package/dist/parseJson.d.ts +8 -0
  333. package/dist/parseJson.d.ts.map +1 -0
  334. package/dist/parseJson.js +17 -0
  335. package/dist/parseJson.js.map +1 -0
  336. package/dist/plugin/catalog.d.ts +229 -0
  337. package/dist/plugin/catalog.d.ts.map +1 -0
  338. package/dist/plugin/catalog.js +248 -0
  339. package/dist/plugin/catalog.js.map +1 -0
  340. package/dist/plugin/catalogCategories.d.ts +30 -0
  341. package/dist/plugin/catalogCategories.d.ts.map +1 -0
  342. package/dist/plugin/catalogCategories.js +88 -0
  343. package/dist/plugin/catalogCategories.js.map +1 -0
  344. package/dist/plugin/customThemeExport.d.ts +95 -0
  345. package/dist/plugin/customThemeExport.d.ts.map +1 -0
  346. package/dist/plugin/customThemeExport.js +264 -0
  347. package/dist/plugin/customThemeExport.js.map +1 -0
  348. package/dist/plugin/databaseTypes.d.ts +90 -0
  349. package/dist/plugin/databaseTypes.d.ts.map +1 -0
  350. package/dist/plugin/databaseTypes.js +2 -0
  351. package/dist/plugin/databaseTypes.js.map +1 -0
  352. package/dist/plugin/githubRaw.d.ts +54 -0
  353. package/dist/plugin/githubRaw.d.ts.map +1 -0
  354. package/dist/plugin/githubRaw.js +138 -0
  355. package/dist/plugin/githubRaw.js.map +1 -0
  356. package/dist/plugin/httpRequest.d.ts +17 -0
  357. package/dist/plugin/httpRequest.d.ts.map +1 -0
  358. package/dist/plugin/httpRequest.js +45 -0
  359. package/dist/plugin/httpRequest.js.map +1 -0
  360. package/dist/plugin/importHandlers.d.ts +65 -0
  361. package/dist/plugin/importHandlers.d.ts.map +1 -0
  362. package/dist/plugin/importHandlers.js +2 -0
  363. package/dist/plugin/importHandlers.js.map +1 -0
  364. package/dist/plugin/pluginDatabaseApi.d.ts +39 -0
  365. package/dist/plugin/pluginDatabaseApi.d.ts.map +1 -0
  366. package/dist/plugin/pluginDatabaseApi.js +45 -0
  367. package/dist/plugin/pluginDatabaseApi.js.map +1 -0
  368. package/dist/plugin/pluginSurface.d.ts +20 -0
  369. package/dist/plugin/pluginSurface.d.ts.map +1 -0
  370. package/dist/plugin/pluginSurface.js +31 -0
  371. package/dist/plugin/pluginSurface.js.map +1 -0
  372. package/dist/plugin/stripPluginScreenshotImagesFromMarkdown.d.ts +9 -0
  373. package/dist/plugin/stripPluginScreenshotImagesFromMarkdown.d.ts.map +1 -0
  374. package/dist/plugin/stripPluginScreenshotImagesFromMarkdown.js +132 -0
  375. package/dist/plugin/stripPluginScreenshotImagesFromMarkdown.js.map +1 -0
  376. package/dist/plugin/themeCategory.d.ts +62 -0
  377. package/dist/plugin/themeCategory.d.ts.map +1 -0
  378. package/dist/plugin/themeCategory.js +84 -0
  379. package/dist/plugin/themeCategory.js.map +1 -0
  380. package/dist/plugin/types.d.ts +415 -0
  381. package/dist/plugin/types.d.ts.map +1 -0
  382. package/dist/plugin/types.js +81 -0
  383. package/dist/plugin/types.js.map +1 -0
  384. package/dist/queryParams.d.ts +63 -0
  385. package/dist/queryParams.d.ts.map +1 -0
  386. package/dist/queryParams.js +170 -0
  387. package/dist/queryParams.js.map +1 -0
  388. package/dist/requestEditorTab.d.ts +24 -0
  389. package/dist/requestEditorTab.d.ts.map +1 -0
  390. package/dist/requestEditorTab.js +44 -0
  391. package/dist/requestEditorTab.js.map +1 -0
  392. package/dist/requestRunner/RequestRunner.d.ts +39 -0
  393. package/dist/requestRunner/RequestRunner.d.ts.map +1 -0
  394. package/dist/requestRunner/RequestRunner.js +298 -0
  395. package/dist/requestRunner/RequestRunner.js.map +1 -0
  396. package/dist/requestRunner/helpers.d.ts +52 -0
  397. package/dist/requestRunner/helpers.d.ts.map +1 -0
  398. package/dist/requestRunner/helpers.js +195 -0
  399. package/dist/requestRunner/helpers.js.map +1 -0
  400. package/dist/requestRunner/index.d.ts +7 -0
  401. package/dist/requestRunner/index.d.ts.map +1 -0
  402. package/dist/requestRunner/index.js +6 -0
  403. package/dist/requestRunner/index.js.map +1 -0
  404. package/dist/requestRunner/types.d.ts +148 -0
  405. package/dist/requestRunner/types.d.ts.map +1 -0
  406. package/dist/requestRunner/types.js +2 -0
  407. package/dist/requestRunner/types.js.map +1 -0
  408. package/dist/requestTags.d.ts +22 -0
  409. package/dist/requestTags.d.ts.map +1 -0
  410. package/dist/requestTags.js +34 -0
  411. package/dist/requestTags.js.map +1 -0
  412. package/dist/scriptRefs.d.ts +190 -0
  413. package/dist/scriptRefs.d.ts.map +1 -0
  414. package/dist/scriptRefs.js +387 -0
  415. package/dist/scriptRefs.js.map +1 -0
  416. package/dist/scriptStage.d.ts +118 -0
  417. package/dist/scriptStage.d.ts.map +1 -0
  418. package/dist/scriptStage.js +204 -0
  419. package/dist/scriptStage.js.map +1 -0
  420. package/dist/scripting/scriptApi.d.ts +59 -0
  421. package/dist/scripting/scriptApi.d.ts.map +1 -0
  422. package/dist/scripting/scriptApi.js +692 -0
  423. package/dist/scripting/scriptApi.js.map +1 -0
  424. package/dist/scripting/scriptAssertionCompat.d.ts +21 -0
  425. package/dist/scripting/scriptAssertionCompat.d.ts.map +1 -0
  426. package/dist/scripting/scriptAssertionCompat.js +58 -0
  427. package/dist/scripting/scriptAssertionCompat.js.map +1 -0
  428. package/dist/scripting/scriptEvaluator.d.ts +42 -0
  429. package/dist/scripting/scriptEvaluator.d.ts.map +1 -0
  430. package/dist/scripting/scriptEvaluator.js +179 -0
  431. package/dist/scripting/scriptEvaluator.js.map +1 -0
  432. package/dist/scripting/scriptExpect.d.ts +3 -0
  433. package/dist/scripting/scriptExpect.d.ts.map +1 -0
  434. package/dist/scripting/scriptExpect.js +14 -0
  435. package/dist/scripting/scriptExpect.js.map +1 -0
  436. package/dist/scripting/scriptFileOperations.d.ts +172 -0
  437. package/dist/scripting/scriptFileOperations.d.ts.map +1 -0
  438. package/dist/scripting/scriptFileOperations.js +271 -0
  439. package/dist/scripting/scriptFileOperations.js.map +1 -0
  440. package/dist/scripting/scriptResponseAssertions.d.ts +40 -0
  441. package/dist/scripting/scriptResponseAssertions.d.ts.map +1 -0
  442. package/dist/scripting/scriptResponseAssertions.js +249 -0
  443. package/dist/scripting/scriptResponseAssertions.js.map +1 -0
  444. package/dist/scripting/scriptResponseDocument.d.ts +47 -0
  445. package/dist/scripting/scriptResponseDocument.d.ts.map +1 -0
  446. package/dist/scripting/scriptResponseDocument.js +49 -0
  447. package/dist/scripting/scriptResponseDocument.js.map +1 -0
  448. package/dist/scripting/scriptRunner.d.ts +2 -0
  449. package/dist/scripting/scriptRunner.d.ts.map +1 -0
  450. package/dist/scripting/scriptRunner.js +132 -0
  451. package/dist/scripting/scriptRunner.js.map +1 -0
  452. package/dist/scripting/scriptSnippetBundler.d.ts +46 -0
  453. package/dist/scripting/scriptSnippetBundler.d.ts.map +1 -0
  454. package/dist/scripting/scriptSnippetBundler.js +136 -0
  455. package/dist/scripting/scriptSnippetBundler.js.map +1 -0
  456. package/dist/search/actions.d.ts +44 -0
  457. package/dist/search/actions.d.ts.map +1 -0
  458. package/dist/search/actions.js +120 -0
  459. package/dist/search/actions.js.map +1 -0
  460. package/dist/search/index.d.ts +13 -0
  461. package/dist/search/index.d.ts.map +1 -0
  462. package/dist/search/index.js +13 -0
  463. package/dist/search/index.js.map +1 -0
  464. package/dist/search/installedPlugins.d.ts +31 -0
  465. package/dist/search/installedPlugins.d.ts.map +1 -0
  466. package/dist/search/installedPlugins.js +73 -0
  467. package/dist/search/installedPlugins.js.map +1 -0
  468. package/dist/search/oramaIndex.d.ts +47 -0
  469. package/dist/search/oramaIndex.d.ts.map +1 -0
  470. package/dist/search/oramaIndex.js +56 -0
  471. package/dist/search/oramaIndex.js.map +1 -0
  472. package/dist/search/pagesCatalog.d.ts +34 -0
  473. package/dist/search/pagesCatalog.d.ts.map +1 -0
  474. package/dist/search/pagesCatalog.js +37 -0
  475. package/dist/search/pagesCatalog.js.map +1 -0
  476. package/dist/search/plugins.d.ts +40 -0
  477. package/dist/search/plugins.d.ts.map +1 -0
  478. package/dist/search/plugins.js +79 -0
  479. package/dist/search/plugins.js.map +1 -0
  480. package/dist/search/settings.d.ts +29 -0
  481. package/dist/search/settings.d.ts.map +1 -0
  482. package/dist/search/settings.js +63 -0
  483. package/dist/search/settings.js.map +1 -0
  484. package/dist/search/settingsCatalog.d.ts +112 -0
  485. package/dist/search/settingsCatalog.d.ts.map +1 -0
  486. package/dist/search/settingsCatalog.js +426 -0
  487. package/dist/search/settingsCatalog.js.map +1 -0
  488. package/dist/search/sidebar.d.ts +139 -0
  489. package/dist/search/sidebar.d.ts.map +1 -0
  490. package/dist/search/sidebar.js +342 -0
  491. package/dist/search/sidebar.js.map +1 -0
  492. package/dist/search/slashCommands.d.ts +45 -0
  493. package/dist/search/slashCommands.d.ts.map +1 -0
  494. package/dist/search/slashCommands.js +71 -0
  495. package/dist/search/slashCommands.js.map +1 -0
  496. package/dist/search/snippets.d.ts +48 -0
  497. package/dist/search/snippets.d.ts.map +1 -0
  498. package/dist/search/snippets.js +114 -0
  499. package/dist/search/snippets.js.map +1 -0
  500. package/dist/search/types.d.ts +60 -0
  501. package/dist/search/types.d.ts.map +1 -0
  502. package/dist/search/types.js +49 -0
  503. package/dist/search/types.js.map +1 -0
  504. package/dist/search/unified.d.ts +57 -0
  505. package/dist/search/unified.d.ts.map +1 -0
  506. package/dist/search/unified.js +153 -0
  507. package/dist/search/unified.js.map +1 -0
  508. package/dist/shortcuts.d.ts +174 -0
  509. package/dist/shortcuts.d.ts.map +1 -0
  510. package/dist/shortcuts.js +1040 -0
  511. package/dist/shortcuts.js.map +1 -0
  512. package/dist/sidebarColor.d.ts +16 -0
  513. package/dist/sidebarColor.d.ts.map +1 -0
  514. package/dist/sidebarColor.js +21 -0
  515. package/dist/sidebarColor.js.map +1 -0
  516. package/dist/sidebarExpansion.d.ts +12 -0
  517. package/dist/sidebarExpansion.d.ts.map +1 -0
  518. package/dist/sidebarExpansion.js +116 -0
  519. package/dist/sidebarExpansion.js.map +1 -0
  520. package/dist/snippet/catalog.d.ts +120 -0
  521. package/dist/snippet/catalog.d.ts.map +1 -0
  522. package/dist/snippet/catalog.js +105 -0
  523. package/dist/snippet/catalog.js.map +1 -0
  524. package/dist/snippet/types.d.ts +90 -0
  525. package/dist/snippet/types.d.ts.map +1 -0
  526. package/dist/snippet/types.js +2 -0
  527. package/dist/snippet/types.js.map +1 -0
  528. package/dist/snippetBundle.d.ts +21 -0
  529. package/dist/snippetBundle.d.ts.map +1 -0
  530. package/dist/snippetBundle.js +107 -0
  531. package/dist/snippetBundle.js.map +1 -0
  532. package/dist/snippetImport.d.ts +19 -0
  533. package/dist/snippetImport.d.ts.map +1 -0
  534. package/dist/snippetImport.js +34 -0
  535. package/dist/snippetImport.js.map +1 -0
  536. package/dist/snippetScope.d.ts +42 -0
  537. package/dist/snippetScope.d.ts.map +1 -0
  538. package/dist/snippetScope.js +50 -0
  539. package/dist/snippetScope.js.map +1 -0
  540. package/dist/storage/IStorage.d.ts +375 -0
  541. package/dist/storage/IStorage.d.ts.map +1 -0
  542. package/dist/storage/IStorage.js +2 -0
  543. package/dist/storage/IStorage.js.map +1 -0
  544. package/dist/themes.d.ts +24 -0
  545. package/dist/themes.d.ts.map +1 -0
  546. package/dist/themes.js +10 -0
  547. package/dist/themes.js.map +1 -0
  548. package/dist/types/ai.d.ts +304 -0
  549. package/dist/types/ai.d.ts.map +1 -0
  550. package/dist/types/ai.js +2 -0
  551. package/dist/types/ai.js.map +1 -0
  552. package/dist/types/api/backup.d.ts +27 -0
  553. package/dist/types/api/backup.d.ts.map +1 -0
  554. package/dist/types/api/backup.js +2 -0
  555. package/dist/types/api/backup.js.map +1 -0
  556. package/dist/types/api/chats.d.ts +88 -0
  557. package/dist/types/api/chats.d.ts.map +1 -0
  558. package/dist/types/api/chats.js +2 -0
  559. package/dist/types/api/chats.js.map +1 -0
  560. package/dist/types/api/collections.d.ts +251 -0
  561. package/dist/types/api/collections.d.ts.map +1 -0
  562. package/dist/types/api/collections.js +2 -0
  563. package/dist/types/api/collections.js.map +1 -0
  564. package/dist/types/api/customThemes.d.ts +68 -0
  565. package/dist/types/api/customThemes.d.ts.map +1 -0
  566. package/dist/types/api/customThemes.js +2 -0
  567. package/dist/types/api/customThemes.js.map +1 -0
  568. package/dist/types/api/docs.d.ts +14 -0
  569. package/dist/types/api/docs.d.ts.map +1 -0
  570. package/dist/types/api/docs.js +2 -0
  571. package/dist/types/api/docs.js.map +1 -0
  572. package/dist/types/api/documents.d.ts +51 -0
  573. package/dist/types/api/documents.d.ts.map +1 -0
  574. package/dist/types/api/documents.js +2 -0
  575. package/dist/types/api/documents.js.map +1 -0
  576. package/dist/types/api/environments.d.ts +57 -0
  577. package/dist/types/api/environments.d.ts.map +1 -0
  578. package/dist/types/api/environments.js +2 -0
  579. package/dist/types/api/environments.js.map +1 -0
  580. package/dist/types/api/git.d.ts +392 -0
  581. package/dist/types/api/git.d.ts.map +1 -0
  582. package/dist/types/api/git.js +2 -0
  583. package/dist/types/api/git.js.map +1 -0
  584. package/dist/types/api/http.d.ts +47 -0
  585. package/dist/types/api/http.d.ts.map +1 -0
  586. package/dist/types/api/http.js +2 -0
  587. package/dist/types/api/http.js.map +1 -0
  588. package/dist/types/api/index.d.ts +28 -0
  589. package/dist/types/api/index.d.ts.map +1 -0
  590. package/dist/types/api/index.js +2 -0
  591. package/dist/types/api/index.js.map +1 -0
  592. package/dist/types/api/mcp.d.ts +77 -0
  593. package/dist/types/api/mcp.d.ts.map +1 -0
  594. package/dist/types/api/mcp.js +2 -0
  595. package/dist/types/api/mcp.js.map +1 -0
  596. package/dist/types/api/plugins.d.ts +338 -0
  597. package/dist/types/api/plugins.d.ts.map +1 -0
  598. package/dist/types/api/plugins.js +2 -0
  599. package/dist/types/api/plugins.js.map +1 -0
  600. package/dist/types/api/requestHistory.d.ts +27 -0
  601. package/dist/types/api/requestHistory.d.ts.map +1 -0
  602. package/dist/types/api/requestHistory.js +2 -0
  603. package/dist/types/api/requestHistory.js.map +1 -0
  604. package/dist/types/api/requests.d.ts +35 -0
  605. package/dist/types/api/requests.d.ts.map +1 -0
  606. package/dist/types/api/requests.js +2 -0
  607. package/dist/types/api/requests.js.map +1 -0
  608. package/dist/types/api/settings.d.ts +163 -0
  609. package/dist/types/api/settings.d.ts.map +1 -0
  610. package/dist/types/api/settings.js +2 -0
  611. package/dist/types/api/settings.js.map +1 -0
  612. package/dist/types/api/sharing.d.ts +68 -0
  613. package/dist/types/api/sharing.d.ts.map +1 -0
  614. package/dist/types/api/sharing.js +2 -0
  615. package/dist/types/api/sharing.js.map +1 -0
  616. package/dist/types/api/snippets.d.ts +159 -0
  617. package/dist/types/api/snippets.d.ts.map +1 -0
  618. package/dist/types/api/snippets.js +2 -0
  619. package/dist/types/api/snippets.js.map +1 -0
  620. package/dist/types/api/storage.d.ts +57 -0
  621. package/dist/types/api/storage.d.ts.map +1 -0
  622. package/dist/types/api/storage.js +2 -0
  623. package/dist/types/api/storage.js.map +1 -0
  624. package/dist/types/api/tabGroup.d.ts +43 -0
  625. package/dist/types/api/tabGroup.d.ts.map +1 -0
  626. package/dist/types/api/tabGroup.js +2 -0
  627. package/dist/types/api/tabGroup.js.map +1 -0
  628. package/dist/types/api/teamHub.d.ts +225 -0
  629. package/dist/types/api/teamHub.d.ts.map +1 -0
  630. package/dist/types/api/teamHub.js +2 -0
  631. package/dist/types/api/teamHub.js.map +1 -0
  632. package/dist/types/api/terminal.d.ts +101 -0
  633. package/dist/types/api/terminal.d.ts.map +1 -0
  634. package/dist/types/api/terminal.js +2 -0
  635. package/dist/types/api/terminal.js.map +1 -0
  636. package/dist/types/api/trash.d.ts +27 -0
  637. package/dist/types/api/trash.d.ts.map +1 -0
  638. package/dist/types/api/trash.js +2 -0
  639. package/dist/types/api/trash.js.map +1 -0
  640. package/dist/types/api/window.d.ts +251 -0
  641. package/dist/types/api/window.d.ts.map +1 -0
  642. package/dist/types/api/window.js +2 -0
  643. package/dist/types/api/window.js.map +1 -0
  644. package/dist/types/app.d.ts +83 -0
  645. package/dist/types/app.d.ts.map +1 -0
  646. package/dist/types/app.js +2 -0
  647. package/dist/types/app.js.map +1 -0
  648. package/dist/types/collection.d.ts +559 -0
  649. package/dist/types/collection.d.ts.map +1 -0
  650. package/dist/types/collection.js +2 -0
  651. package/dist/types/collection.js.map +1 -0
  652. package/dist/types/common.d.ts +23 -0
  653. package/dist/types/common.d.ts.map +1 -0
  654. package/dist/types/common.js +2 -0
  655. package/dist/types/common.js.map +1 -0
  656. package/dist/types/customTheme.d.ts +163 -0
  657. package/dist/types/customTheme.d.ts.map +1 -0
  658. package/dist/types/customTheme.js +311 -0
  659. package/dist/types/customTheme.js.map +1 -0
  660. package/dist/types/environment.d.ts +64 -0
  661. package/dist/types/environment.d.ts.map +1 -0
  662. package/dist/types/environment.js +2 -0
  663. package/dist/types/environment.js.map +1 -0
  664. package/dist/types/index.d.ts +21 -0
  665. package/dist/types/index.d.ts.map +1 -0
  666. package/dist/types/index.js +20 -0
  667. package/dist/types/index.js.map +1 -0
  668. package/dist/types/mcp.d.ts +153 -0
  669. package/dist/types/mcp.d.ts.map +1 -0
  670. package/dist/types/mcp.js +2 -0
  671. package/dist/types/mcp.js.map +1 -0
  672. package/dist/types/request.d.ts +294 -0
  673. package/dist/types/request.d.ts.map +1 -0
  674. package/dist/types/request.js +2 -0
  675. package/dist/types/request.js.map +1 -0
  676. package/dist/types/requestHistory.d.ts +88 -0
  677. package/dist/types/requestHistory.d.ts.map +1 -0
  678. package/dist/types/requestHistory.js +5 -0
  679. package/dist/types/requestHistory.js.map +1 -0
  680. package/dist/types/script.d.ts +366 -0
  681. package/dist/types/script.d.ts.map +1 -0
  682. package/dist/types/script.js +34 -0
  683. package/dist/types/script.js.map +1 -0
  684. package/dist/types/settings.d.ts +340 -0
  685. package/dist/types/settings.d.ts.map +1 -0
  686. package/dist/types/settings.js +3 -0
  687. package/dist/types/settings.js.map +1 -0
  688. package/dist/types/sharing.d.ts +87 -0
  689. package/dist/types/sharing.d.ts.map +1 -0
  690. package/dist/types/sharing.js +2 -0
  691. package/dist/types/sharing.js.map +1 -0
  692. package/dist/types/snippet.d.ts +150 -0
  693. package/dist/types/snippet.d.ts.map +1 -0
  694. package/dist/types/snippet.js +2 -0
  695. package/dist/types/snippet.js.map +1 -0
  696. package/dist/types/storage.d.ts +846 -0
  697. package/dist/types/storage.d.ts.map +1 -0
  698. package/dist/types/storage.js +2 -0
  699. package/dist/types/storage.js.map +1 -0
  700. package/dist/types/tabGroup.d.ts +108 -0
  701. package/dist/types/tabGroup.d.ts.map +1 -0
  702. package/dist/types/tabGroup.js +26 -0
  703. package/dist/types/tabGroup.js.map +1 -0
  704. package/dist/types/teamHub.d.ts +690 -0
  705. package/dist/types/teamHub.d.ts.map +1 -0
  706. package/dist/types/teamHub.js +2 -0
  707. package/dist/types/teamHub.js.map +1 -0
  708. package/dist/types/trash.d.ts +63 -0
  709. package/dist/types/trash.d.ts.map +1 -0
  710. package/dist/types/trash.js +2 -0
  711. package/dist/types/trash.js.map +1 -0
  712. package/dist/types/window.d.ts +14 -0
  713. package/dist/types/window.d.ts.map +1 -0
  714. package/dist/types/window.js +2 -0
  715. package/dist/types/window.js.map +1 -0
  716. package/dist/types.d.ts +7 -0
  717. package/dist/types.d.ts.map +1 -0
  718. package/dist/types.js +2 -0
  719. package/dist/types.js.map +1 -0
  720. package/dist/urlencoded.d.ts +2 -0
  721. package/dist/urlencoded.d.ts.map +1 -0
  722. package/dist/urlencoded.js +2 -0
  723. package/dist/urlencoded.js.map +1 -0
  724. package/dist/urlencodedRaw.d.ts +23 -0
  725. package/dist/urlencodedRaw.d.ts.map +1 -0
  726. package/dist/urlencodedRaw.js +60 -0
  727. package/dist/urlencodedRaw.js.map +1 -0
  728. package/dist/userAgent.d.ts +132 -0
  729. package/dist/userAgent.d.ts.map +1 -0
  730. package/dist/userAgent.js +178 -0
  731. package/dist/userAgent.js.map +1 -0
  732. package/dist/zoomPresets.d.ts +38 -0
  733. package/dist/zoomPresets.d.ts.map +1 -0
  734. package/dist/zoomPresets.js +67 -0
  735. package/dist/zoomPresets.js.map +1 -0
  736. package/package.json +92 -0
@@ -0,0 +1,787 @@
1
+ const AI_SCRIPT_REFERENCE_UUID = '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
2
+ /**
3
+ * Regex matching `@` script references in chat text:
4
+ * - Request scripts: `@<request-id>.<pre|post>.<script-index>`
5
+ * - Standalone snippets: `@snippet.<uuid>`
6
+ * - Footer terminals: `@term.<terminal-index>`
7
+ * - Collections: `@collection.<uuid>`
8
+ * - Folders: `@folder.<uuid>`
9
+ * - Saved requests: `@request.<uuid>`
10
+ * - Markdown documents and request comments: `@markdown.<uuid>`
11
+ * - Active request raw body: `@body`
12
+ *
13
+ * Request scripts, snippets, markdown, and raw body accept an optional
14
+ * `#<selection-start>.<selection-end>` suffix (character offsets). Terminal references use the
15
+ * same suffix for 1-based line numbers.
16
+ */
17
+ export const AI_SCRIPT_REFERENCE_PATTERN = new RegExp(`@(?:(active|\\d+)\\.(pre|post)\\.(\\d+)|snippet\\.(${AI_SCRIPT_REFERENCE_UUID})|term\\.(\\d+)|collection\\.(${AI_SCRIPT_REFERENCE_UUID})|folder\\.(${AI_SCRIPT_REFERENCE_UUID})|request\\.(${AI_SCRIPT_REFERENCE_UUID})|markdown\\.(${AI_SCRIPT_REFERENCE_UUID})|(body))(?:#(\\d+)\\.(\\d+))?(?!\\d)`, 'g');
18
+ /**
19
+ * Returns whether `@` at `index` is at a token boundary (start of text or after whitespace).
20
+ *
21
+ * @param text - Full composer draft.
22
+ * @param index - Index of the `@` character.
23
+ */
24
+ function isScriptReferenceBoundary(text, index) {
25
+ if (index === 0) {
26
+ return true;
27
+ }
28
+ const previous = text[index - 1];
29
+ return previous != null && /\s/.test(previous);
30
+ }
31
+ /**
32
+ * Parses selection suffix groups from a regex match.
33
+ *
34
+ * @param selectionStartRaw - Captured selection start group.
35
+ * @param selectionEndRaw - Captured selection end group.
36
+ * @param lineRange - When true, requires 1-based line numbers with end >= start.
37
+ */
38
+ function parseSelectionSuffix(selectionStartRaw, selectionEndRaw, lineRange = false) {
39
+ if (selectionStartRaw == null || selectionEndRaw == null) {
40
+ return undefined;
41
+ }
42
+ const selectionStart = Number(selectionStartRaw);
43
+ const selectionEnd = Number(selectionEndRaw);
44
+ if (!Number.isInteger(selectionStart) || !Number.isInteger(selectionEnd)) {
45
+ return undefined;
46
+ }
47
+ if (lineRange) {
48
+ if (selectionStart >= 1 && selectionEnd >= selectionStart) {
49
+ return { start: selectionStart, end: selectionEnd };
50
+ }
51
+ return undefined;
52
+ }
53
+ if (selectionStart >= 0 && selectionEnd > selectionStart) {
54
+ return { start: selectionStart, end: selectionEnd };
55
+ }
56
+ return undefined;
57
+ }
58
+ /**
59
+ * Parses one regex match into a structured script reference.
60
+ *
61
+ * @param match - RegExp match for {@link AI_SCRIPT_REFERENCE_PATTERN}.
62
+ * @param start - Document start offset of the match.
63
+ */
64
+ export function parseAiScriptReferenceMatch(match, start) {
65
+ const text = match[0];
66
+ const requestIdRaw = match[1];
67
+ const phase = match[2];
68
+ const scriptIndexRaw = match[3];
69
+ const snippetUuid = match[4];
70
+ const terminalIndexRaw = match[5];
71
+ const collectionUuid = match[6];
72
+ const folderUuid = match[7];
73
+ const requestUuid = match[8];
74
+ const markdownUuid = match[9];
75
+ const bodyToken = match[10];
76
+ const selectionStartRaw = match[11];
77
+ const selectionEndRaw = match[12];
78
+ if (bodyToken != null) {
79
+ return {
80
+ kind: 'body',
81
+ start,
82
+ end: start + text.length,
83
+ text,
84
+ selection: parseSelectionSuffix(selectionStartRaw, selectionEndRaw)
85
+ };
86
+ }
87
+ if (collectionUuid != null) {
88
+ return {
89
+ kind: 'collection',
90
+ collectionUuid,
91
+ start,
92
+ end: start + text.length,
93
+ text
94
+ };
95
+ }
96
+ if (folderUuid != null) {
97
+ return {
98
+ kind: 'folder',
99
+ folderUuid,
100
+ start,
101
+ end: start + text.length,
102
+ text
103
+ };
104
+ }
105
+ if (requestUuid != null) {
106
+ return {
107
+ kind: 'request',
108
+ requestUuid,
109
+ start,
110
+ end: start + text.length,
111
+ text
112
+ };
113
+ }
114
+ if (markdownUuid != null) {
115
+ return {
116
+ kind: 'markdown',
117
+ markdownUuid,
118
+ start,
119
+ end: start + text.length,
120
+ text,
121
+ selection: parseSelectionSuffix(selectionStartRaw, selectionEndRaw)
122
+ };
123
+ }
124
+ if (terminalIndexRaw != null) {
125
+ const terminalIndex = Number(terminalIndexRaw);
126
+ if (!Number.isInteger(terminalIndex) || terminalIndex < 1) {
127
+ return null;
128
+ }
129
+ return {
130
+ kind: 'terminal',
131
+ terminalIndex,
132
+ start,
133
+ end: start + text.length,
134
+ text,
135
+ selection: parseSelectionSuffix(selectionStartRaw, selectionEndRaw, true)
136
+ };
137
+ }
138
+ const selection = parseSelectionSuffix(selectionStartRaw, selectionEndRaw);
139
+ if (snippetUuid != null) {
140
+ return {
141
+ kind: 'snippet',
142
+ snippetUuid,
143
+ start,
144
+ end: start + text.length,
145
+ text,
146
+ selection
147
+ };
148
+ }
149
+ if (requestIdRaw == null || phase == null || scriptIndexRaw == null) {
150
+ return null;
151
+ }
152
+ if (phase !== 'pre' && phase !== 'post') {
153
+ return null;
154
+ }
155
+ const scriptIndex = Number(scriptIndexRaw);
156
+ if (!Number.isInteger(scriptIndex) || scriptIndex < 1) {
157
+ return null;
158
+ }
159
+ const requestId = requestIdRaw === 'active'
160
+ ? 'active'
161
+ : Number.isFinite(Number(requestIdRaw))
162
+ ? Number(requestIdRaw)
163
+ : null;
164
+ if (requestId == null) {
165
+ return null;
166
+ }
167
+ return {
168
+ kind: 'request-script',
169
+ requestId,
170
+ phase,
171
+ scriptIndex,
172
+ start,
173
+ end: start + text.length,
174
+ text,
175
+ selection
176
+ };
177
+ }
178
+ /**
179
+ * Finds syntactically valid `@` script reference candidates in plain text.
180
+ *
181
+ * @param text - Composer draft that may contain `@` references.
182
+ */
183
+ export function findAiScriptReferenceCandidates(text) {
184
+ const matches = [];
185
+ const pattern = new RegExp(AI_SCRIPT_REFERENCE_PATTERN.source, 'g');
186
+ for (const match of text.matchAll(pattern)) {
187
+ const start = match.index ?? 0;
188
+ if (!isScriptReferenceBoundary(text, start)) {
189
+ continue;
190
+ }
191
+ const parsed = parseAiScriptReferenceMatch(match, start);
192
+ if (parsed) {
193
+ matches.push(parsed);
194
+ }
195
+ }
196
+ return matches;
197
+ }
198
+ /**
199
+ * Removes valid `@` script reference tokens from plain text.
200
+ *
201
+ * @param text - Composer or title prompt text that may contain `@` references.
202
+ * @returns Text with script references removed and whitespace collapsed.
203
+ */
204
+ export function stripAiScriptReferences(text) {
205
+ const candidates = findAiScriptReferenceCandidates(text);
206
+ if (candidates.length === 0) {
207
+ return text.replace(/\s+/g, ' ').trim();
208
+ }
209
+ let stripped = text;
210
+ for (const candidate of [...candidates].sort((left, right) => right.start - left.start)) {
211
+ stripped = stripped.slice(0, candidate.start) + stripped.slice(candidate.end);
212
+ }
213
+ return stripped.replace(/\s+/g, ' ').trim();
214
+ }
215
+ /**
216
+ * Returns whether a parsed `@` reference resolves against the active request tab or snippet library.
217
+ *
218
+ * Mirrors `update_request_script` validation in the AI tool executor for request-script kind.
219
+ *
220
+ * @param reference - Parsed `@` script reference.
221
+ * @param context - Active tab script counts, request id, and snippet library.
222
+ */
223
+ export function isValidAiScriptReference(reference, context) {
224
+ if (reference.kind === 'markdown') {
225
+ if (reference.selection == null) {
226
+ return false;
227
+ }
228
+ return context.markdownSelections?.[reference.text] != null;
229
+ }
230
+ if (reference.kind === 'body') {
231
+ if (reference.selection == null) {
232
+ return false;
233
+ }
234
+ return context.requestBodySelections?.[reference.text] != null;
235
+ }
236
+ if (reference.kind === 'terminal') {
237
+ if (reference.selection == null) {
238
+ return false;
239
+ }
240
+ return context.terminalSelections?.[reference.text] != null;
241
+ }
242
+ if (reference.kind === 'snippet') {
243
+ return (context.snippets ?? []).some((entry) => entry.uuid === reference.snippetUuid);
244
+ }
245
+ if (reference.kind === 'collection') {
246
+ return context.collectionNamesByUuid?.[reference.collectionUuid] != null;
247
+ }
248
+ if (reference.kind === 'folder') {
249
+ return context.folderNamesByUuid?.[reference.folderUuid] != null;
250
+ }
251
+ if (reference.kind === 'request') {
252
+ return context.requestNamesByUuid?.[reference.requestUuid] != null;
253
+ }
254
+ if (!context.hasActiveRequestTab) {
255
+ return false;
256
+ }
257
+ if (reference.requestId !== 'active' && reference.requestId !== context.activeRequestId) {
258
+ return false;
259
+ }
260
+ const scriptCount = reference.phase === 'pre' ? context.preScriptCount : context.postScriptCount;
261
+ return reference.scriptIndex >= 1 && reference.scriptIndex <= scriptCount;
262
+ }
263
+ /**
264
+ * Returns the display name for a script row, matching the request editor list labels.
265
+ *
266
+ * @param script - Script reference entry from the active draft.
267
+ * @param snippets - Snippet library lookup source.
268
+ */
269
+ function scriptReferenceDisplayName(script, snippets) {
270
+ if (script.name?.trim()) {
271
+ return script.name.trim();
272
+ }
273
+ if (script.kind === 'snippet') {
274
+ const snippet = snippets.find((entry) => entry.uuid === script.snippetUuid);
275
+ return snippet ? snippet.name : 'Missing snippet';
276
+ }
277
+ return 'Inline script';
278
+ }
279
+ /**
280
+ * Resolves the display name for a valid `@` script reference.
281
+ *
282
+ * @param reference - Parsed `@` script reference.
283
+ * @param context - Active tab script rows and snippet library.
284
+ * @returns Script or snippet name when resolvable, otherwise null.
285
+ */
286
+ export function resolveAiScriptReferenceName(reference, context) {
287
+ if (!isValidAiScriptReference(reference, context)) {
288
+ return null;
289
+ }
290
+ if (reference.kind === 'terminal') {
291
+ return context.terminalSelections?.[reference.text]?.terminalLabel ?? null;
292
+ }
293
+ if (reference.kind === 'markdown') {
294
+ return context.markdownSelections?.[reference.text]?.label ?? null;
295
+ }
296
+ if (reference.kind === 'body') {
297
+ return context.requestBodySelections?.[reference.text]?.label ?? null;
298
+ }
299
+ if (reference.kind === 'snippet') {
300
+ const snippet = (context.snippets ?? []).find((entry) => entry.uuid === reference.snippetUuid);
301
+ return snippet?.name ?? null;
302
+ }
303
+ if (reference.kind === 'collection') {
304
+ const name = context.collectionNamesByUuid?.[reference.collectionUuid];
305
+ return name != null ? `Collection: ${name}` : null;
306
+ }
307
+ if (reference.kind === 'folder') {
308
+ const name = context.folderNamesByUuid?.[reference.folderUuid];
309
+ return name != null ? `Folder: ${name}` : null;
310
+ }
311
+ if (reference.kind === 'request') {
312
+ const name = context.requestNamesByUuid?.[reference.requestUuid];
313
+ return name != null ? `Request: ${name}` : null;
314
+ }
315
+ const scripts = reference.phase === 'pre' ? context.preScripts : context.postScripts;
316
+ if (scripts == null) {
317
+ return null;
318
+ }
319
+ const script = scripts[reference.scriptIndex - 1];
320
+ if (script == null) {
321
+ return null;
322
+ }
323
+ return scriptReferenceDisplayName(script, context.snippets ?? []);
324
+ }
325
+ /**
326
+ * Resolves the JavaScript source for a script row on the active request tab.
327
+ *
328
+ * @param script - Script reference entry from the active draft.
329
+ * @param snippets - Snippet library lookup source.
330
+ * @returns Script source text, or null when unavailable.
331
+ */
332
+ function resolveScriptSourceCode(script, snippets) {
333
+ if (script.kind === 'inline') {
334
+ return script.code ?? '';
335
+ }
336
+ if (script.kind === 'snippet') {
337
+ const linkedSnippet = snippets.find((entry) => entry.uuid === script.snippetUuid);
338
+ return linkedSnippet?.code ?? null;
339
+ }
340
+ return null;
341
+ }
342
+ /**
343
+ * Resolves the JavaScript source for a parsed `@` reference.
344
+ *
345
+ * @param reference - Parsed `@` script reference.
346
+ * @param context - Active tab script rows and snippet library.
347
+ * @returns Script or snippet source text, or null when unavailable.
348
+ */
349
+ function resolveReferenceSourceCode(reference, context) {
350
+ if (reference.kind === 'terminal' ||
351
+ reference.kind === 'markdown' ||
352
+ reference.kind === 'body' ||
353
+ reference.kind === 'collection' ||
354
+ reference.kind === 'folder' ||
355
+ reference.kind === 'request') {
356
+ return null;
357
+ }
358
+ if (reference.kind === 'snippet') {
359
+ const snippet = (context.snippets ?? []).find((entry) => entry.uuid === reference.snippetUuid);
360
+ return snippet?.code ?? null;
361
+ }
362
+ const scripts = reference.phase === 'pre' ? context.preScripts : context.postScripts;
363
+ const script = scripts?.[reference.scriptIndex - 1];
364
+ if (script == null) {
365
+ return null;
366
+ }
367
+ return resolveScriptSourceCode(script, context.snippets ?? []);
368
+ }
369
+ /**
370
+ * Returns the 1-based line number for a character offset in script source.
371
+ *
372
+ * @param source - Script source text.
373
+ * @param offset - Character offset into the source.
374
+ */
375
+ function lineNumberAtOffset(source, offset) {
376
+ const clamped = Math.min(Math.max(0, offset), source.length);
377
+ let line = 1;
378
+ for (let index = 0; index < clamped; index += 1) {
379
+ if (source[index] === '\n') {
380
+ line += 1;
381
+ }
382
+ }
383
+ return line;
384
+ }
385
+ /**
386
+ * Formats a selection range as a human-readable line span for badge labels.
387
+ *
388
+ * @param source - Script source text.
389
+ * @param selection - Character offsets into the script source.
390
+ * @returns Line span label such as `(line 3)` or `(lines 3-5)`.
391
+ */
392
+ function formatScriptSelectionLineRange(source, selection) {
393
+ const clampedStart = Math.min(Math.max(0, selection.start), source.length);
394
+ const clampedEnd = Math.min(Math.max(clampedStart, selection.end), source.length);
395
+ const startLine = lineNumberAtOffset(source, clampedStart);
396
+ const endLine = lineNumberAtOffset(source, Math.max(clampedStart, clampedEnd - 1));
397
+ if (startLine === endLine) {
398
+ return `(line ${startLine})`;
399
+ }
400
+ return `(lines ${startLine}-${endLine})`;
401
+ }
402
+ /**
403
+ * Resolves the badge label for a valid `@` script reference, including selection line ranges.
404
+ *
405
+ * @param reference - Parsed `@` script reference.
406
+ * @param context - Active tab script rows and snippet library.
407
+ * @returns Script name with optional line range, or null when not resolvable.
408
+ */
409
+ /**
410
+ * Formats a terminal line span for badge labels.
411
+ *
412
+ * @param startLine - 1-based start line of the selection.
413
+ * @param endLine - 1-based end line of the selection.
414
+ */
415
+ function formatTerminalSelectionLineRange(startLine, endLine) {
416
+ if (startLine === endLine) {
417
+ return `(line ${startLine})`;
418
+ }
419
+ return `(lines ${startLine}-${endLine})`;
420
+ }
421
+ export function resolveAiScriptReferenceLabel(reference, context) {
422
+ const name = resolveAiScriptReferenceName(reference, context);
423
+ if (name == null) {
424
+ return null;
425
+ }
426
+ if (reference.kind === 'terminal') {
427
+ const snapshot = context.terminalSelections?.[reference.text];
428
+ if (snapshot == null) {
429
+ return name;
430
+ }
431
+ return `${name} ${formatTerminalSelectionLineRange(snapshot.startLine, snapshot.endLine)}`;
432
+ }
433
+ if (reference.kind === 'markdown') {
434
+ const snapshot = context.markdownSelections?.[reference.text];
435
+ if (snapshot == null) {
436
+ return name;
437
+ }
438
+ return `${name} ${formatTerminalSelectionLineRange(snapshot.startLine, snapshot.endLine)}`;
439
+ }
440
+ if (reference.kind === 'body') {
441
+ const snapshot = context.requestBodySelections?.[reference.text];
442
+ if (snapshot == null) {
443
+ return name;
444
+ }
445
+ return `${name} ${formatTerminalSelectionLineRange(snapshot.startLine, snapshot.endLine)}`;
446
+ }
447
+ if (reference.selection == null) {
448
+ return name;
449
+ }
450
+ const source = resolveReferenceSourceCode(reference, context);
451
+ if (source == null) {
452
+ return name;
453
+ }
454
+ return `${name} ${formatScriptSelectionLineRange(source, reference.selection)}`;
455
+ }
456
+ /**
457
+ * Clamps selection offsets to script source bounds and returns the selected substring.
458
+ *
459
+ * @param source - Full script source text.
460
+ * @param selection - Character offsets from the `@` reference suffix.
461
+ */
462
+ function clampScriptSelection(source, selection) {
463
+ const start = Math.min(Math.max(0, selection.start), source.length);
464
+ const end = Math.min(Math.max(start, selection.end), source.length);
465
+ return {
466
+ start,
467
+ end,
468
+ text: source.slice(start, end)
469
+ };
470
+ }
471
+ /**
472
+ * Formats the line span label for agent context without surrounding parentheses.
473
+ *
474
+ * @param source - Script source text.
475
+ * @param selection - Clamped character offsets into the script source.
476
+ */
477
+ function formatScriptSelectionLineSpan(source, selection) {
478
+ return formatScriptSelectionLineRange(source, selection).replace(/^\(|\)$/g, '');
479
+ }
480
+ /**
481
+ * Formats one resolved terminal selection reference for the agent context block.
482
+ *
483
+ * @param reference - Parsed `@term` reference with a line-range suffix.
484
+ * @param context - Terminal selection snapshots keyed by reference token.
485
+ * @returns Context block for one terminal reference, or null when not resolvable.
486
+ */
487
+ function formatTerminalSelectionContextBlock(reference, context) {
488
+ if (reference.selection == null || !isValidAiScriptReference(reference, context)) {
489
+ return null;
490
+ }
491
+ const snapshot = context.terminalSelections?.[reference.text];
492
+ if (snapshot == null) {
493
+ return null;
494
+ }
495
+ const lineSpan = snapshot.startLine === snapshot.endLine
496
+ ? `line ${snapshot.startLine}`
497
+ : `lines ${snapshot.startLine}-${snapshot.endLine}`;
498
+ return [
499
+ `Reference ${reference.text} — footer terminal "${snapshot.terminalLabel}" (terminal ${reference.terminalIndex} in the tab list).`,
500
+ `Selected terminal output (${lineSpan}):`,
501
+ '```text',
502
+ snapshot.selectedText,
503
+ '```',
504
+ 'Surrounding terminal context (includes lines before and after the selection):',
505
+ '```text',
506
+ snapshot.contextText,
507
+ '```'
508
+ ].join('\n');
509
+ }
510
+ /**
511
+ * Formats one resolved markdown selection reference for the agent context block.
512
+ *
513
+ * @param reference - Parsed `@markdown` reference with a character-range suffix.
514
+ * @param context - Markdown selection snapshots keyed by reference token.
515
+ * @returns Context block for one markdown reference, or null when not resolvable.
516
+ */
517
+ function formatMarkdownSelectionContextBlock(reference, context) {
518
+ if (reference.selection == null || !isValidAiScriptReference(reference, context)) {
519
+ return null;
520
+ }
521
+ const snapshot = context.markdownSelections?.[reference.text];
522
+ if (snapshot == null) {
523
+ return null;
524
+ }
525
+ const lineSpan = snapshot.startLine === snapshot.endLine
526
+ ? `line ${snapshot.startLine}`
527
+ : `lines ${snapshot.startLine}-${snapshot.endLine}`;
528
+ return [
529
+ `Reference ${reference.text} — markdown "${snapshot.label}".`,
530
+ `Selected markdown text (characters ${snapshot.startOffset}–${snapshot.endOffset}, ${lineSpan}):`,
531
+ '```markdown',
532
+ snapshot.selectedText,
533
+ '```',
534
+ 'Call get_markdown_document with the same uuid when you need the full document or comment source.'
535
+ ].join('\n');
536
+ }
537
+ /**
538
+ * Formats one resolved raw-body selection reference for the agent context block.
539
+ *
540
+ * @param reference - Parsed `@body` reference with a character-range suffix.
541
+ * @param context - Raw-body selection snapshots keyed by reference token.
542
+ * @returns Context block for one body reference, or null when not resolvable.
543
+ */
544
+ function formatRequestBodySelectionContextBlock(reference, context) {
545
+ if (reference.selection == null || !isValidAiScriptReference(reference, context)) {
546
+ return null;
547
+ }
548
+ const snapshot = context.requestBodySelections?.[reference.text];
549
+ if (snapshot == null) {
550
+ return null;
551
+ }
552
+ const lineSpan = snapshot.startLine === snapshot.endLine
553
+ ? `line ${snapshot.startLine}`
554
+ : `lines ${snapshot.startLine}-${snapshot.endLine}`;
555
+ return [
556
+ `Reference ${reference.text} — raw request body "${snapshot.label}".`,
557
+ `Selected raw body text (characters ${snapshot.startOffset}–${snapshot.endOffset}, ${lineSpan}):`,
558
+ '```text',
559
+ snapshot.selectedText,
560
+ '```',
561
+ 'Call get_active_request_details when you need the full body (including body_raw / body_raw_effective). Use update_active_request with body_raw to replace the raw body text.'
562
+ ].join('\n');
563
+ }
564
+ function formatScriptSelectionContextBlock(reference, context) {
565
+ if (reference.kind === 'terminal') {
566
+ return formatTerminalSelectionContextBlock(reference, context);
567
+ }
568
+ if (reference.kind === 'markdown') {
569
+ return formatMarkdownSelectionContextBlock(reference, context);
570
+ }
571
+ if (reference.kind === 'body') {
572
+ return formatRequestBodySelectionContextBlock(reference, context);
573
+ }
574
+ if (reference.selection == null || !isValidAiScriptReference(reference, context)) {
575
+ return null;
576
+ }
577
+ const source = resolveReferenceSourceCode(reference, context);
578
+ if (source == null) {
579
+ return null;
580
+ }
581
+ const name = resolveAiScriptReferenceName(reference, context) ?? 'Unnamed script';
582
+ const clampedSelection = clampScriptSelection(source, reference.selection);
583
+ const lineSpan = formatScriptSelectionLineSpan(source, clampedSelection);
584
+ if (reference.kind === 'snippet') {
585
+ return [
586
+ `Reference ${reference.text} — standalone library snippet "${name}" (not linked to any specific request).`,
587
+ 'Full snippet source:',
588
+ '```js',
589
+ source,
590
+ '```',
591
+ `Selected text (characters ${clampedSelection.start}–${clampedSelection.end}, ${lineSpan}):`,
592
+ '```js',
593
+ clampedSelection.text,
594
+ '```'
595
+ ].join('\n');
596
+ }
597
+ if (reference.kind !== 'request-script') {
598
+ return null;
599
+ }
600
+ const phaseLabel = reference.phase === 'pre' ? 'pre-request' : 'post-request';
601
+ const requestLabel = reference.requestId === 'active'
602
+ ? 'of the active request'
603
+ : `of request id ${reference.requestId}`;
604
+ return [
605
+ `Reference ${reference.text} — script "${name}" (${phaseLabel} script ${reference.scriptIndex} ${requestLabel}).`,
606
+ 'Full script source:',
607
+ '```js',
608
+ source,
609
+ '```',
610
+ `Selected text (characters ${clampedSelection.start}–${clampedSelection.end}, ${lineSpan}):`,
611
+ '```js',
612
+ clampedSelection.text,
613
+ '```'
614
+ ].join('\n');
615
+ }
616
+ /**
617
+ * Formats one valid whole-script `@` reference (no `#selection` suffix) for agent context.
618
+ *
619
+ * @param reference - Parsed `@` script reference without a selection range.
620
+ * @param context - Active tab script rows and snippet library.
621
+ * @returns Context block with full script source, or null when not resolvable.
622
+ */
623
+ function formatWholeScriptReferenceContextBlock(reference, context) {
624
+ if (reference.selection != null ||
625
+ reference.kind === 'terminal' ||
626
+ reference.kind === 'markdown' ||
627
+ reference.kind === 'body' ||
628
+ reference.kind === 'collection' ||
629
+ reference.kind === 'folder' ||
630
+ reference.kind === 'request') {
631
+ return null;
632
+ }
633
+ if (!isValidAiScriptReference(reference, context)) {
634
+ return null;
635
+ }
636
+ const source = resolveReferenceSourceCode(reference, context);
637
+ if (source == null) {
638
+ return null;
639
+ }
640
+ const name = resolveAiScriptReferenceName(reference, context) ?? 'Unnamed script';
641
+ if (reference.kind === 'snippet') {
642
+ return [
643
+ `Reference ${reference.text} — standalone library snippet "${name}" (not linked to any specific request).`,
644
+ 'Full snippet source:',
645
+ '```js',
646
+ source,
647
+ '```'
648
+ ].join('\n');
649
+ }
650
+ if (reference.kind !== 'request-script') {
651
+ return null;
652
+ }
653
+ const phaseLabel = reference.phase === 'pre' ? 'pre-request' : 'post-request';
654
+ const requestLabel = reference.requestId === 'active'
655
+ ? 'of the active request'
656
+ : `of request id ${reference.requestId}`;
657
+ return [
658
+ `Reference ${reference.text} — script "${name}" (${phaseLabel} script ${reference.scriptIndex} ${requestLabel}).`,
659
+ 'Full script source:',
660
+ '```js',
661
+ source,
662
+ '```'
663
+ ].join('\n');
664
+ }
665
+ /**
666
+ * Formats agent context for one `@` script reference, with or without a selection suffix.
667
+ *
668
+ * @param reference - Parsed `@` script reference.
669
+ * @param context - Active tab script rows and snippet library.
670
+ */
671
+ function formatScriptReferenceContextBlock(reference, context) {
672
+ if (reference.selection != null) {
673
+ return formatScriptSelectionContextBlock(reference, context);
674
+ }
675
+ return formatWholeScriptReferenceContextBlock(reference, context);
676
+ }
677
+ /**
678
+ * Builds an ephemeral system message that expands valid `@` script references in the user message.
679
+ *
680
+ * References with a `#start.end` suffix include the selected substring; whole-script references
681
+ * include the full source so the model can answer questions without relying on tool calls alone.
682
+ *
683
+ * The returned text is injected into the LLM step messages only; it is not persisted in chat
684
+ * history so the composer can keep rendering compact badges.
685
+ *
686
+ * @param text - User message that may contain `@` script references.
687
+ * @param context - Active tab script rows and snippet library.
688
+ * @returns Formatted context block, or null when no valid references are present.
689
+ */
690
+ export function buildAiScriptSelectionContextMessage(text, context) {
691
+ const candidates = findAiScriptReferenceCandidates(text);
692
+ const resolved = candidates
693
+ .map((reference) => ({
694
+ reference,
695
+ block: formatScriptReferenceContextBlock(reference, context)
696
+ }))
697
+ .filter((entry) => entry.block != null ? true : false);
698
+ if (resolved.length === 0) {
699
+ return null;
700
+ }
701
+ const blocks = resolved.map((entry) => entry.block);
702
+ const hasTerminalSelection = resolved.some((entry) => entry.reference.kind === 'terminal' && entry.reference.selection != null);
703
+ const hasMarkdownSelection = resolved.some((entry) => entry.reference.kind === 'markdown' && entry.reference.selection != null);
704
+ const hasBodySelection = resolved.some((entry) => entry.reference.kind === 'body' && entry.reference.selection != null);
705
+ const hasScriptSelection = resolved.some((entry) => (entry.reference.kind === 'request-script' || entry.reference.kind === 'snippet') &&
706
+ entry.reference.selection != null);
707
+ const hasWholeScriptReference = resolved.some((entry) => (entry.reference.kind === 'request-script' || entry.reference.kind === 'snippet') &&
708
+ entry.reference.selection == null);
709
+ const headerParts = [];
710
+ if (hasTerminalSelection) {
711
+ headerParts.push('The user selected terminal output and is asking specifically about the SELECTED TEXT below.');
712
+ }
713
+ if (hasMarkdownSelection) {
714
+ headerParts.push('The user selected markdown text and is asking specifically about the SELECTED TEXT below.');
715
+ }
716
+ if (hasBodySelection) {
717
+ headerParts.push('The user selected raw request body text and is asking specifically about the SELECTED TEXT below.');
718
+ }
719
+ if (hasScriptSelection) {
720
+ headerParts.push('The user selected part of a script and is asking specifically about the SELECTED TEXT below.');
721
+ }
722
+ if (hasWholeScriptReference) {
723
+ headerParts.push('The user referenced one or more scripts via @ mentions. Use the script sources below to answer their question.');
724
+ }
725
+ const footerParts = [];
726
+ if (hasScriptSelection) {
727
+ footerParts.push('Focus your answer on the selected region.');
728
+ }
729
+ else if (hasBodySelection) {
730
+ footerParts.push('Focus your answer on the selected raw body region. Call get_active_request_details when you need the full body, and use update_active_request with body_raw to edit it.');
731
+ }
732
+ else if (hasMarkdownSelection) {
733
+ footerParts.push('Focus your answer on the selected markdown region. Call get_markdown_document when you need the full document or comment source.');
734
+ }
735
+ else if (hasWholeScriptReference) {
736
+ footerParts.push('Answer using the referenced script source below.');
737
+ }
738
+ if (hasTerminalSelection) {
739
+ footerParts.push('Terminal output references cannot be edited via tools. Explain, diagnose, or suggest shell commands the user can run.');
740
+ }
741
+ if (hasMarkdownSelection) {
742
+ footerParts.push('Markdown documents and request comments referenced with @markdown.<uuid> cannot be edited via tools. Propose replacement markdown in your reply for the user to paste back into the editor.');
743
+ }
744
+ if (hasBodySelection) {
745
+ footerParts.push('Raw body selections referenced with @body#start.end can be edited via update_active_request with body_raw (verbatim wire text for multipart/urlencoded). Prefer body_raw over structured body when the user is editing the Raw body drawer.');
746
+ }
747
+ if (resolved.some((entry) => entry.reference.kind === 'request-script')) {
748
+ footerParts.push(hasScriptSelection
749
+ ? 'When editing request scripts, use update_request_script with the same phase and scriptIndex from the reference, and respect the #start.end character offsets from the @ tag.'
750
+ : 'When editing request scripts, use update_request_script with the same phase and scriptIndex from the @ reference.');
751
+ }
752
+ if (resolved.some((entry) => entry.reference.kind === 'snippet')) {
753
+ footerParts.push('Standalone library snippets referenced with @snippet.<uuid> cannot be edited via tools. Propose replacement code in your reply for the user to paste back into the snippet editor.');
754
+ }
755
+ return [headerParts.join(' '), '', ...blocks, '', footerParts.join(' ')].join('\n');
756
+ }
757
+ /**
758
+ * Splits composer text into plain and highlightable `@` script reference segments.
759
+ *
760
+ * @param text - Composer draft.
761
+ * @param context - Active tab state for semantic validation.
762
+ */
763
+ export function tokenizeChatComposerText(text, context) {
764
+ const candidates = findAiScriptReferenceCandidates(text);
765
+ const tokens = [];
766
+ let lastIndex = 0;
767
+ for (const candidate of candidates) {
768
+ if (candidate.start < lastIndex) {
769
+ continue;
770
+ }
771
+ const highlight = isValidAiScriptReference(candidate, context);
772
+ if (candidate.start > lastIndex) {
773
+ tokens.push({ text: text.slice(lastIndex, candidate.start), highlight: false });
774
+ }
775
+ tokens.push({
776
+ text: candidate.text,
777
+ highlight,
778
+ reference: highlight ? candidate : undefined
779
+ });
780
+ lastIndex = candidate.end;
781
+ }
782
+ if (lastIndex < text.length) {
783
+ tokens.push({ text: text.slice(lastIndex), highlight: false });
784
+ }
785
+ return tokens;
786
+ }
787
+ //# sourceMappingURL=scriptReferences.js.map