@mountaya/studio 0.0.0-stage → 0.1.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 (524) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENCE.fr.txt +280 -0
  3. package/LICENSE.txt +262 -0
  4. package/README.md +917 -2
  5. package/dist/agent/index.cjs +2854 -0
  6. package/dist/agent/index.cjs.map +1 -0
  7. package/dist/agent/index.d.cts +1257 -0
  8. package/dist/agent/index.d.ts +1257 -0
  9. package/dist/agent/index.js +2818 -0
  10. package/dist/agent/index.js.map +1 -0
  11. package/dist/bus-BwiNiXdH.d.ts +514 -0
  12. package/dist/bus-DzmhPwdK.d.cts +514 -0
  13. package/dist/chainModel-B23pEP_1.d.cts +127 -0
  14. package/dist/chainModel-B23pEP_1.d.ts +127 -0
  15. package/dist/chunk-2HFY7ETU.js +5721 -0
  16. package/dist/chunk-2HFY7ETU.js.map +1 -0
  17. package/dist/chunk-355TOXSB.js +72 -0
  18. package/dist/chunk-355TOXSB.js.map +1 -0
  19. package/dist/chunk-4ZCUZVSV.js +10275 -0
  20. package/dist/chunk-4ZCUZVSV.js.map +1 -0
  21. package/dist/chunk-6HEKY3NF.js +95 -0
  22. package/dist/chunk-6HEKY3NF.js.map +1 -0
  23. package/dist/chunk-7GFLGGBX.cjs +8 -0
  24. package/dist/chunk-7GFLGGBX.cjs.map +1 -0
  25. package/dist/chunk-7NBRCENN.cjs +19 -0
  26. package/dist/chunk-7NBRCENN.cjs.map +1 -0
  27. package/dist/chunk-AF5GCXE3.js +8 -0
  28. package/dist/chunk-AF5GCXE3.js.map +1 -0
  29. package/dist/chunk-CJDIFRGZ.cjs +2005 -0
  30. package/dist/chunk-CJDIFRGZ.cjs.map +1 -0
  31. package/dist/chunk-CNPZY7N3.js +349 -0
  32. package/dist/chunk-CNPZY7N3.js.map +1 -0
  33. package/dist/chunk-DZJHTWSF.cjs +45 -0
  34. package/dist/chunk-DZJHTWSF.cjs.map +1 -0
  35. package/dist/chunk-EABIHHWA.js +42 -0
  36. package/dist/chunk-EABIHHWA.js.map +1 -0
  37. package/dist/chunk-EKZWV6RS.cjs +415 -0
  38. package/dist/chunk-EKZWV6RS.cjs.map +1 -0
  39. package/dist/chunk-EOKRXXAC.cjs +24 -0
  40. package/dist/chunk-EOKRXXAC.cjs.map +1 -0
  41. package/dist/chunk-F73W2ZTJ.js +1126 -0
  42. package/dist/chunk-F73W2ZTJ.js.map +1 -0
  43. package/dist/chunk-H4DVOZ5O.js +1897 -0
  44. package/dist/chunk-H4DVOZ5O.js.map +1 -0
  45. package/dist/chunk-HI52PBFT.cjs +10314 -0
  46. package/dist/chunk-HI52PBFT.cjs.map +1 -0
  47. package/dist/chunk-IDBXFBLG.cjs +1225 -0
  48. package/dist/chunk-IDBXFBLG.cjs.map +1 -0
  49. package/dist/chunk-LBWTJZUJ.js +297 -0
  50. package/dist/chunk-LBWTJZUJ.js.map +1 -0
  51. package/dist/chunk-NCLA6DKD.cjs +310 -0
  52. package/dist/chunk-NCLA6DKD.cjs.map +1 -0
  53. package/dist/chunk-O4MC5DPD.js +19 -0
  54. package/dist/chunk-O4MC5DPD.js.map +1 -0
  55. package/dist/chunk-OP37FKW6.cjs +98 -0
  56. package/dist/chunk-OP37FKW6.cjs.map +1 -0
  57. package/dist/chunk-OQSYFH3Z.cjs +5945 -0
  58. package/dist/chunk-OQSYFH3Z.cjs.map +1 -0
  59. package/dist/chunk-PACIO4NS.cjs +26 -0
  60. package/dist/chunk-PACIO4NS.cjs.map +1 -0
  61. package/dist/chunk-PSZ2R3TC.cjs +75 -0
  62. package/dist/chunk-PSZ2R3TC.cjs.map +1 -0
  63. package/dist/chunk-QFO5CZG2.cjs +136 -0
  64. package/dist/chunk-QFO5CZG2.cjs.map +1 -0
  65. package/dist/chunk-QL63MUEW.cjs +140 -0
  66. package/dist/chunk-QL63MUEW.cjs.map +1 -0
  67. package/dist/chunk-RFUPPVZO.js +17 -0
  68. package/dist/chunk-RFUPPVZO.js.map +1 -0
  69. package/dist/chunk-RPG2LWMP.js +23 -0
  70. package/dist/chunk-RPG2LWMP.js.map +1 -0
  71. package/dist/chunk-TIBXK6B7.cjs +12 -0
  72. package/dist/chunk-TIBXK6B7.cjs.map +1 -0
  73. package/dist/chunk-UU65VNEV.js +381 -0
  74. package/dist/chunk-UU65VNEV.js.map +1 -0
  75. package/dist/chunk-VGX6TR2I.js +209 -0
  76. package/dist/chunk-VGX6TR2I.js.map +1 -0
  77. package/dist/chunk-WUTDDBVP.js +130 -0
  78. package/dist/chunk-WUTDDBVP.js.map +1 -0
  79. package/dist/chunk-WVQQLKCI.cjs +224 -0
  80. package/dist/chunk-WVQQLKCI.cjs.map +1 -0
  81. package/dist/chunk-WZYXG3SE.js +111 -0
  82. package/dist/chunk-WZYXG3SE.js.map +1 -0
  83. package/dist/chunk-XDI2X3KE.js +6 -0
  84. package/dist/chunk-XDI2X3KE.js.map +1 -0
  85. package/dist/chunk-XKHLRIC7.cjs +381 -0
  86. package/dist/chunk-XKHLRIC7.cjs.map +1 -0
  87. package/dist/context-DNtd2WUv.d.cts +11666 -0
  88. package/dist/context-DgB72Bur.d.ts +11666 -0
  89. package/dist/directorThreads-CqmvsV8b.d.cts +80 -0
  90. package/dist/directorThreads-CqmvsV8b.d.ts +80 -0
  91. package/dist/en-Bu4Ti9Ev.d.cts +2315 -0
  92. package/dist/en-Bu4Ti9Ev.d.ts +2315 -0
  93. package/dist/engines/index.cjs +3446 -0
  94. package/dist/engines/index.cjs.map +1 -0
  95. package/dist/engines/index.d.cts +2216 -0
  96. package/dist/engines/index.d.ts +2216 -0
  97. package/dist/engines/index.js +3416 -0
  98. package/dist/engines/index.js.map +1 -0
  99. package/dist/handlers/index.cjs +99 -0
  100. package/dist/handlers/index.cjs.map +1 -0
  101. package/dist/handlers/index.d.cts +445 -0
  102. package/dist/handlers/index.d.ts +445 -0
  103. package/dist/handlers/index.js +42 -0
  104. package/dist/handlers/index.js.map +1 -0
  105. package/dist/index.cjs +4562 -0
  106. package/dist/index.cjs.map +1 -0
  107. package/dist/index.d.cts +7297 -0
  108. package/dist/index.d.ts +7297 -0
  109. package/dist/index.js +3223 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/plugins/index.cjs +977 -0
  112. package/dist/plugins/index.cjs.map +1 -0
  113. package/dist/plugins/index.d.cts +313 -0
  114. package/dist/plugins/index.d.ts +313 -0
  115. package/dist/plugins/index.js +933 -0
  116. package/dist/plugins/index.js.map +1 -0
  117. package/dist/saveFile-j-1kkApx.d.cts +123 -0
  118. package/dist/saveFile-j-1kkApx.d.ts +123 -0
  119. package/dist/seams/index.cjs +152 -0
  120. package/dist/seams/index.cjs.map +1 -0
  121. package/dist/seams/index.d.cts +485 -0
  122. package/dist/seams/index.d.ts +485 -0
  123. package/dist/seams/index.js +79 -0
  124. package/dist/seams/index.js.map +1 -0
  125. package/dist/shareLink-B6hlt942.d.ts +144 -0
  126. package/dist/shareLink-C7rIMb7x.d.ts +527 -0
  127. package/dist/shareLink-CnTxxXjp.d.cts +144 -0
  128. package/dist/shareLink-DyZVYH2V.d.cts +527 -0
  129. package/dist/strings/fr/index.cjs +2121 -0
  130. package/dist/strings/fr/index.cjs.map +1 -0
  131. package/dist/strings/fr/index.d.cts +19 -0
  132. package/dist/strings/fr/index.d.ts +19 -0
  133. package/dist/strings/fr/index.js +2119 -0
  134. package/dist/strings/fr/index.js.map +1 -0
  135. package/dist/strings/index.cjs +2678 -0
  136. package/dist/strings/index.cjs.map +1 -0
  137. package/dist/strings/index.d.cts +731 -0
  138. package/dist/strings/index.d.ts +731 -0
  139. package/dist/strings/index.js +2644 -0
  140. package/dist/strings/index.js.map +1 -0
  141. package/dist/studioPlugin-C3C7VjMy.d.ts +847 -0
  142. package/dist/studioPlugin-Cf3OBNUv.d.cts +847 -0
  143. package/dist/tabs-B2nRO4p_.d.cts +15 -0
  144. package/dist/tabs-B2nRO4p_.d.ts +15 -0
  145. package/dist/testing/index.cjs +292 -0
  146. package/dist/testing/index.cjs.map +1 -0
  147. package/dist/testing/index.d.cts +306 -0
  148. package/dist/testing/index.d.ts +306 -0
  149. package/dist/testing/index.js +284 -0
  150. package/dist/testing/index.js.map +1 -0
  151. package/dist/time/index.cjs +28 -0
  152. package/dist/time/index.cjs.map +1 -0
  153. package/dist/time/index.d.cts +43 -0
  154. package/dist/time/index.d.ts +43 -0
  155. package/dist/time/index.js +26 -0
  156. package/dist/time/index.js.map +1 -0
  157. package/dist/types-BzJRV6UI.d.cts +845 -0
  158. package/dist/types-BzJRV6UI.d.ts +845 -0
  159. package/dist/zoneForm-CdYNtnnA.d.cts +320 -0
  160. package/dist/zoneForm-mG85yt5e.d.ts +320 -0
  161. package/package.json +225 -4
  162. package/src/agent/engines/agentThreads.ts +1601 -0
  163. package/src/agent/engines/directorChat.ts +500 -0
  164. package/src/agent/index.ts +67 -0
  165. package/src/agent/rules/agentEditLock.ts +115 -0
  166. package/src/agent/rules/agentErrorCopy.ts +44 -0
  167. package/src/agent/rules/copilotOrganization.ts +36 -0
  168. package/src/agent/rules/playbook.gen.ts +444 -0
  169. package/src/agent/rules/router.ts +518 -0
  170. package/src/agent/rules/stateDelta.ts +28 -0
  171. package/src/agent/rules/studioRouter.ts +123 -0
  172. package/src/agent/rules/surfaces.gen.ts +633 -0
  173. package/src/agent/rules/threadsUrl.ts +48 -0
  174. package/src/agent/rules/transcriptObserver.ts +90 -0
  175. package/src/agent/stores/agentThreads.ts +454 -0
  176. package/src/bus/contracts/noData.ts +18 -0
  177. package/src/bus/contracts/shared.ts +172 -0
  178. package/src/bus/contracts/studioTools.ts +224 -0
  179. package/src/bus/rules/bus.ts +858 -0
  180. package/src/bus/rules/confirmation.ts +22 -0
  181. package/src/bus/rules/defineRegistry.ts +26 -0
  182. package/src/bus/rules/errors.ts +401 -0
  183. package/src/bus/rules/handlerErrors.ts +103 -0
  184. package/src/bus/rules/handlerRegistry.ts +627 -0
  185. package/src/bus/rules/inputSchema.ts +232 -0
  186. package/src/bus/rules/invalidInput.ts +441 -0
  187. package/src/bus/rules/lateBoundTools.ts +100 -0
  188. package/src/bus/rules/studioRegistry.ts +324 -0
  189. package/src/bus/rules/studioToolBus.ts +73 -0
  190. package/src/bus/rules/types.ts +805 -0
  191. package/src/chrome/contracts/alert.ts +42 -0
  192. package/src/chrome/contracts/itinerary.ts +26 -0
  193. package/src/chrome/contracts/map.ts +23 -0
  194. package/src/chrome/contracts/overlay.ts +46 -0
  195. package/src/chrome/contracts/panel.ts +29 -0
  196. package/src/chrome/contracts/question.ts +52 -0
  197. package/src/chrome/contracts/selection.ts +26 -0
  198. package/src/chrome/contracts/sidenav.ts +23 -0
  199. package/src/chrome/contracts/snapshot.ts +319 -0
  200. package/src/chrome/contracts/state.ts +22 -0
  201. package/src/chrome/contracts/tabs.ts +56 -0
  202. package/src/chrome/handlers/alert.ts +91 -0
  203. package/src/chrome/handlers/introspection.ts +180 -0
  204. package/src/chrome/handlers/panels.ts +42 -0
  205. package/src/chrome/handlers/question.ts +24 -0
  206. package/src/chrome/handlers/sidenav.ts +116 -0
  207. package/src/chrome/handlers/snapshot.ts +451 -0
  208. package/src/chrome/handlers/stateDelta.ts +125 -0
  209. package/src/chrome/handlers/tabs.ts +143 -0
  210. package/src/chrome/handlers/timestamp.ts +19 -0
  211. package/src/chrome/rules/agentSelectors.ts +210 -0
  212. package/src/chrome/rules/mapAlert.ts +13 -0
  213. package/src/chrome/rules/question.ts +25 -0
  214. package/src/chrome/rules/tabs.ts +13 -0
  215. package/src/chrome/stores/activeDraftSession.ts +134 -0
  216. package/src/chrome/stores/chrome.ts +527 -0
  217. package/src/chrome/stores/uiStore.ts +573 -0
  218. package/src/collab/contracts/collab.ts +261 -0
  219. package/src/collab/handlers/collab.ts +468 -0
  220. package/src/collab/rules/toolNames.ts +33 -0
  221. package/src/collab/stores/collab.ts +899 -0
  222. package/src/collections/contracts/collection.ts +182 -0
  223. package/src/collections/handlers/collectionAttach.ts +141 -0
  224. package/src/collections/handlers/collections.ts +499 -0
  225. package/src/collections/handlers/heldCollection.ts +42 -0
  226. package/src/collections/handlers/restCollections.ts +386 -0
  227. package/src/collections/rules/collections.ts +138 -0
  228. package/src/collections/rules/entityCollections.ts +53 -0
  229. package/src/collections/stores/collections.ts +133 -0
  230. package/src/data/contracts/data.ts +233 -0
  231. package/src/data/contracts/itinerary.ts +71 -0
  232. package/src/data/handlers/activityResolve.ts +76 -0
  233. package/src/data/handlers/data.ts +200 -0
  234. package/src/data/handlers/graphql.ts +26 -0
  235. package/src/data/handlers/mutationSink.ts +1577 -0
  236. package/src/data/handlers/profile.ts +83 -0
  237. package/src/data/handlers/writeThrough.ts +417 -0
  238. package/src/data/rules/cache.ts +181 -0
  239. package/src/data/rules/dataTypes.ts +40 -0
  240. package/src/data/rules/keys.ts +106 -0
  241. package/src/data/rules/persistence.ts +1058 -0
  242. package/src/data/rules/requestBody.ts +43 -0
  243. package/src/data/rules/restErrors.ts +354 -0
  244. package/src/data/rules/sessionSurface.ts +156 -0
  245. package/src/data/rules/toolResultData.ts +73 -0
  246. package/src/data/rules/uuid.ts +24 -0
  247. package/src/edit/contracts/edit.ts +37 -0
  248. package/src/edit/contracts/itinerary.ts +57 -0
  249. package/src/edit/handlers/draftCommit.ts +257 -0
  250. package/src/edit/handlers/editDiscard.ts +34 -0
  251. package/src/edit/handlers/editLock.ts +949 -0
  252. package/src/edit/handlers/editor.ts +203 -0
  253. package/src/edit/handlers/formUnsaved.ts +24 -0
  254. package/src/edit/rules/draftMetadata.ts +117 -0
  255. package/src/edit/rules/editKeyboard.ts +222 -0
  256. package/src/edit/rules/editShortcuts.ts +102 -0
  257. package/src/edit/rules/editTooltip.ts +174 -0
  258. package/src/edit/rules/editorTaken.ts +49 -0
  259. package/src/edit/rules/history.ts +26 -0
  260. package/src/edit/rules/unsavedWork.ts +60 -0
  261. package/src/edit/stores/editorReservation.ts +70 -0
  262. package/src/edit/stores/formsUnsaved.ts +54 -0
  263. package/src/embed/contracts/embed.ts +48 -0
  264. package/src/embed/engines/embedFraming.ts +1329 -0
  265. package/src/embed/engines/embedReady.ts +353 -0
  266. package/src/embed/engines/framingPageSession.ts +169 -0
  267. package/src/embed/handlers/embed.ts +130 -0
  268. package/src/embed/rules/allowedDomains.ts +71 -0
  269. package/src/embed/rules/bridgeMessages.ts +224 -0
  270. package/src/embed/rules/defaults.ts +173 -0
  271. package/src/embed/rules/displaySeed.ts +115 -0
  272. package/src/embed/rules/embedAllowlist.ts +146 -0
  273. package/src/embed/rules/embedConstraints.ts +215 -0
  274. package/src/embed/rules/embedElements.ts +277 -0
  275. package/src/embed/rules/embedSectionFields.ts +126 -0
  276. package/src/embed/rules/embedSecurity.ts +116 -0
  277. package/src/embed/rules/fieldDependencies.ts +87 -0
  278. package/src/embed/rules/fieldOptions.ts +138 -0
  279. package/src/embed/rules/layerOptions.ts +161 -0
  280. package/src/embed/rules/readyProtocol.ts +66 -0
  281. package/src/embed/rules/safetyRules.ts +213 -0
  282. package/src/embed/rules/snippet.ts +531 -0
  283. package/src/embed/rules/tableCode.ts +269 -0
  284. package/src/embed/stores/embed.ts +60 -0
  285. package/src/embed/stores/embedContent.ts +77 -0
  286. package/src/engines/index.ts +81 -0
  287. package/src/handlers/index.ts +66 -0
  288. package/src/index.ts +1086 -0
  289. package/src/itinerary/contracts/itinerary.ts +705 -0
  290. package/src/itinerary/engines/itineraryPace.ts +612 -0
  291. package/src/itinerary/engines/profileMarker.ts +238 -0
  292. package/src/itinerary/handlers/importStaging.ts +352 -0
  293. package/src/itinerary/handlers/itinerary.ts +572 -0
  294. package/src/itinerary/handlers/itineraryDuplicate.ts +177 -0
  295. package/src/itinerary/handlers/itineraryExport.ts +117 -0
  296. package/src/itinerary/handlers/itineraryImport.ts +783 -0
  297. package/src/itinerary/handlers/itineraryPublish.ts +118 -0
  298. package/src/itinerary/handlers/itinerarySelection.ts +354 -0
  299. package/src/itinerary/handlers/itinerarySuggest.ts +1186 -0
  300. package/src/itinerary/handlers/itineraryUnpublish.ts +101 -0
  301. package/src/itinerary/handlers/publicationScope.ts +118 -0
  302. package/src/itinerary/handlers/restItineraries.ts +752 -0
  303. package/src/itinerary/handlers/restItineraryExport.ts +70 -0
  304. package/src/itinerary/handlers/restItineraryImport.ts +311 -0
  305. package/src/itinerary/handlers/restItineraryPace.ts +87 -0
  306. package/src/itinerary/handlers/restItineraryRecord.ts +36 -0
  307. package/src/itinerary/handlers/suggestParams.ts +379 -0
  308. package/src/itinerary/handlers/suggestStaging.ts +363 -0
  309. package/src/itinerary/handlers/surfaceOpen.ts +389 -0
  310. package/src/itinerary/rules/activity.ts +139 -0
  311. package/src/itinerary/rules/analysis.ts +42 -0
  312. package/src/itinerary/rules/ceiling.ts +49 -0
  313. package/src/itinerary/rules/createFlow.ts +107 -0
  314. package/src/itinerary/rules/densify.ts +440 -0
  315. package/src/itinerary/rules/draftSurface.ts +219 -0
  316. package/src/itinerary/rules/editorView.ts +83 -0
  317. package/src/itinerary/rules/export.ts +159 -0
  318. package/src/itinerary/rules/friendlyName.ts +77 -0
  319. package/src/itinerary/rules/import.ts +1052 -0
  320. package/src/itinerary/rules/importFiles.ts +140 -0
  321. package/src/itinerary/rules/importTotals.ts +77 -0
  322. package/src/itinerary/rules/liveSegment.ts +712 -0
  323. package/src/itinerary/rules/lngLat.ts +17 -0
  324. package/src/itinerary/rules/mapSync.ts +100 -0
  325. package/src/itinerary/rules/previewRender.ts +416 -0
  326. package/src/itinerary/rules/profileReadout.ts +216 -0
  327. package/src/itinerary/rules/routing.ts +707 -0
  328. package/src/itinerary/rules/suggest.ts +522 -0
  329. package/src/itinerary/rules/suggestionPreview.ts +119 -0
  330. package/src/itinerary/rules/view.ts +61 -0
  331. package/src/itinerary/stores/importSession.ts +319 -0
  332. package/src/itinerary/stores/itinerary.ts +331 -0
  333. package/src/itinerary/stores/itineraryDuplicate.ts +76 -0
  334. package/src/itinerary/stores/sessionIdentity.ts +43 -0
  335. package/src/itinerary/stores/suggestSession.ts +418 -0
  336. package/src/layers/contracts/itinerary.ts +46 -0
  337. package/src/layers/contracts/overlay.ts +132 -0
  338. package/src/layers/handlers/enrichment.ts +36 -0
  339. package/src/layers/handlers/overlay.ts +406 -0
  340. package/src/layers/handlers/restLayers.ts +94 -0
  341. package/src/layers/handlers/tiles.ts +25 -0
  342. package/src/layers/rules/layers.ts +212 -0
  343. package/src/layers/rules/overlayInstant.ts +12 -0
  344. package/src/layers/rules/reachabilityIcon.ts +18 -0
  345. package/src/layers/rules/readout.ts +102 -0
  346. package/src/layers/stores/layers.ts +262 -0
  347. package/src/map/contracts/contextmenu.ts +33 -0
  348. package/src/map/contracts/geolocate.ts +37 -0
  349. package/src/map/contracts/map.ts +146 -0
  350. package/src/map/contracts/streetview.ts +53 -0
  351. package/src/map/contracts/terrain.ts +152 -0
  352. package/src/map/handlers/contextMenu.ts +135 -0
  353. package/src/map/handlers/geolocate.ts +52 -0
  354. package/src/map/handlers/map.ts +391 -0
  355. package/src/map/handlers/streetview.ts +94 -0
  356. package/src/map/handlers/terrain.ts +663 -0
  357. package/src/map/rules/baseTerrain.ts +75 -0
  358. package/src/map/rules/clickTargets.ts +464 -0
  359. package/src/map/rules/constraints.ts +32 -0
  360. package/src/map/rules/contextMenuReadout.ts +67 -0
  361. package/src/map/rules/coordinates.ts +71 -0
  362. package/src/map/rules/itineraryFit.ts +8 -0
  363. package/src/map/rules/mapEvents.ts +64 -0
  364. package/src/map/rules/mapProjection.ts +476 -0
  365. package/src/map/rules/terrainReading.ts +62 -0
  366. package/src/plugins/contracts/ids.ts +66 -0
  367. package/src/plugins/contracts/plugin.ts +200 -0
  368. package/src/plugins/contracts/slots.ts +137 -0
  369. package/src/plugins/engines/studioPlugin.ts +1365 -0
  370. package/src/plugins/index.ts +111 -0
  371. package/src/plugins/rules/contributions.ts +152 -0
  372. package/src/plugins/rules/errors.ts +60 -0
  373. package/src/plugins/rules/ids.ts +42 -0
  374. package/src/plugins/rules/validation.ts +249 -0
  375. package/src/rules/listeners.ts +57 -0
  376. package/src/rules/origin.ts +13 -0
  377. package/src/rules/storeWrite.ts +37 -0
  378. package/src/rules/types.ts +136 -0
  379. package/src/seams/index.ts +79 -0
  380. package/src/seams/rules/clock.ts +28 -0
  381. package/src/seams/rules/formatters.ts +209 -0
  382. package/src/seams/rules/ids.ts +102 -0
  383. package/src/seams/rules/links.ts +66 -0
  384. package/src/seams/rules/navigation.ts +222 -0
  385. package/src/seams/rules/notify.ts +49 -0
  386. package/src/seams/rules/persistenceDrawer.ts +220 -0
  387. package/src/seams/rules/saveFile.ts +101 -0
  388. package/src/seams/rules/seams.ts +156 -0
  389. package/src/seams/rules/storage.ts +116 -0
  390. package/src/search/contracts/overlay.ts +74 -0
  391. package/src/search/contracts/search.ts +197 -0
  392. package/src/search/handlers/pois.ts +57 -0
  393. package/src/search/handlers/search.ts +280 -0
  394. package/src/search/rules/params.ts +925 -0
  395. package/src/search/rules/poiGroups.ts +138 -0
  396. package/src/search/rules/searchFetch.ts +139 -0
  397. package/src/search/rules/timeWindow.ts +30 -0
  398. package/src/search/stores/search.ts +51 -0
  399. package/src/segments/contracts/itinerary.ts +433 -0
  400. package/src/segments/contracts/segment.ts +35 -0
  401. package/src/segments/engines/segmentDraft.ts +926 -0
  402. package/src/segments/handlers/chainGuards.ts +67 -0
  403. package/src/segments/handlers/directions.ts +44 -0
  404. package/src/segments/handlers/itineraryEcho.ts +45 -0
  405. package/src/segments/handlers/roadAccessDialog.ts +34 -0
  406. package/src/segments/handlers/segment.ts +111 -0
  407. package/src/segments/handlers/segmentEdit.ts +1341 -0
  408. package/src/segments/handlers/segmentGroups.ts +347 -0
  409. package/src/segments/handlers/segmentStructure.ts +1144 -0
  410. package/src/segments/rules/chain.ts +196 -0
  411. package/src/segments/rules/chainModel.ts +217 -0
  412. package/src/segments/rules/colors.ts +11 -0
  413. package/src/segments/rules/commit.ts +76 -0
  414. package/src/segments/rules/draft.ts +90 -0
  415. package/src/segments/rules/draftDisposition.ts +43 -0
  416. package/src/segments/rules/draftSegmentEdit.ts +129 -0
  417. package/src/segments/rules/engine.ts +222 -0
  418. package/src/segments/rules/groupSave.ts +234 -0
  419. package/src/segments/rules/hazardPrompt.ts +60 -0
  420. package/src/segments/rules/itineraryEcho.ts +40 -0
  421. package/src/segments/rules/liveSegmentProjection.ts +55 -0
  422. package/src/segments/rules/merge.ts +51 -0
  423. package/src/segments/rules/metrics.ts +456 -0
  424. package/src/segments/rules/naming.ts +168 -0
  425. package/src/segments/rules/segmentArming.ts +144 -0
  426. package/src/segments/rules/splitPick.ts +84 -0
  427. package/src/segments/rules/viaSimplify.ts +230 -0
  428. package/src/segments/stores/directions.ts +77 -0
  429. package/src/segments/stores/roadAccessDialog.ts +58 -0
  430. package/src/segments/stores/segmentEdit.ts +922 -0
  431. package/src/segments/stores/segmentGroupEdit.ts +84 -0
  432. package/src/segments/stores/segmentSplit.ts +77 -0
  433. package/src/share/contracts/share.ts +39 -0
  434. package/src/share/contracts/shareLink.ts +63 -0
  435. package/src/share/engines/shareLink.ts +1053 -0
  436. package/src/share/handlers/share.ts +47 -0
  437. package/src/share/handlers/shareLink.ts +231 -0
  438. package/src/share/handlers/shareScope.ts +54 -0
  439. package/src/share/rules/link.ts +89 -0
  440. package/src/share/rules/shareLink.ts +218 -0
  441. package/src/share/rules/targets.ts +92 -0
  442. package/src/share/rules/viewConfig.ts +95 -0
  443. package/src/share/stores/share.ts +58 -0
  444. package/src/strings/fr/index.ts +18 -0
  445. package/src/strings/fr/rules/fr.ts +2368 -0
  446. package/src/strings/index.ts +98 -0
  447. package/src/strings/rules/confirmCopy.ts +156 -0
  448. package/src/strings/rules/draftToolNames.ts +94 -0
  449. package/src/strings/rules/en.ts +2519 -0
  450. package/src/strings/rules/failureAlert.ts +115 -0
  451. package/src/strings/rules/formError.ts +400 -0
  452. package/src/strings/rules/maneuvers.ts +107 -0
  453. package/src/strings/rules/outputOptions.ts +126 -0
  454. package/src/strings/rules/publicationState.ts +100 -0
  455. package/src/strings/rules/routeHazardCopy.ts +62 -0
  456. package/src/strings/rules/searchLabels.ts +50 -0
  457. package/src/strings/rules/segmentChainVerbs.ts +62 -0
  458. package/src/strings/rules/studioCopy.ts +130 -0
  459. package/src/strings/rules/unitOptions.ts +119 -0
  460. package/src/testing/checkedBus.ts +226 -0
  461. package/src/testing/index.ts +34 -0
  462. package/src/testing/plugins.ts +106 -0
  463. package/src/testing/studio.ts +267 -0
  464. package/src/testing/urlSeam.ts +153 -0
  465. package/src/time/index.ts +12 -0
  466. package/src/time/rules/sun.ts +78 -0
  467. package/src/video/contracts/cameraSchemas.ts +266 -0
  468. package/src/video/contracts/profileSchemas.ts +37 -0
  469. package/src/video/contracts/video.ts +601 -0
  470. package/src/video/handlers/video.ts +1638 -0
  471. package/src/video/handlers/videoDirector.ts +114 -0
  472. package/src/video/rules/previewRefresh.ts +76 -0
  473. package/src/video/rules/profileSource.ts +51 -0
  474. package/src/video/rules/routeSpans.ts +79 -0
  475. package/src/video/rules/shotDefaults.ts +28 -0
  476. package/src/video/rules/stepOrder.ts +17 -0
  477. package/src/video/rules/videoSnapshot.ts +136 -0
  478. package/src/video/stores/directorThreads.ts +167 -0
  479. package/src/video/stores/videoExport.ts +290 -0
  480. package/src/viewer/contracts/preferences.ts +40 -0
  481. package/src/viewer/handlers/preferences.ts +91 -0
  482. package/src/viewer/rules/capabilities.ts +42 -0
  483. package/src/viewer/rules/config.ts +266 -0
  484. package/src/viewer/rules/context.ts +375 -0
  485. package/src/viewer/rules/ownership.ts +134 -0
  486. package/src/viewer/rules/platformViewer.ts +198 -0
  487. package/src/viewer/rules/scope.ts +197 -0
  488. package/src/viewer/rules/url.ts +145 -0
  489. package/src/viewer/rules/viewer.ts +307 -0
  490. package/src/viewer/rules/viewerSeam.ts +49 -0
  491. package/src/viewer/rules/viewerUnits.ts +34 -0
  492. package/src/waypoints/contracts/itinerary.ts +417 -0
  493. package/src/waypoints/handlers/poiWaypointStyle.ts +32 -0
  494. package/src/waypoints/handlers/waypointDetailsDialog.ts +38 -0
  495. package/src/waypoints/handlers/waypointEdit.ts +1073 -0
  496. package/src/waypoints/rules/amenities.ts +30 -0
  497. package/src/waypoints/rules/defaults.ts +31 -0
  498. package/src/waypoints/rules/details.ts +213 -0
  499. package/src/waypoints/rules/detailsDraft.ts +312 -0
  500. package/src/waypoints/rules/detailsPreview.ts +76 -0
  501. package/src/waypoints/rules/detailsSave.ts +356 -0
  502. package/src/waypoints/rules/draftDirty.ts +45 -0
  503. package/src/waypoints/rules/icons.ts +32 -0
  504. package/src/waypoints/rules/liveWaypoint.ts +63 -0
  505. package/src/waypoints/rules/naming.ts +185 -0
  506. package/src/waypoints/rules/sections.ts +77 -0
  507. package/src/waypoints/rules/waypointDraft.ts +62 -0
  508. package/src/waypoints/stores/waypointDetails.ts +62 -0
  509. package/src/waypoints/stores/waypointEdit.ts +566 -0
  510. package/src/zones/contracts/collection.ts +37 -0
  511. package/src/zones/contracts/zone.ts +528 -0
  512. package/src/zones/engines/zoneForm.ts +1773 -0
  513. package/src/zones/handlers/restZones.ts +287 -0
  514. package/src/zones/handlers/zonePublish.ts +206 -0
  515. package/src/zones/handlers/zoneUnpublish.ts +56 -0
  516. package/src/zones/handlers/zones.ts +2254 -0
  517. package/src/zones/rules/geometry.ts +946 -0
  518. package/src/zones/rules/zoneDefaults.ts +34 -0
  519. package/src/zones/rules/zoneDraft.ts +54 -0
  520. package/src/zones/rules/zoneForm.ts +563 -0
  521. package/src/zones/rules/zoneMetadata.ts +29 -0
  522. package/src/zones/rules/zoneSource.ts +87 -0
  523. package/src/zones/rules/zoneSourceRefusal.ts +104 -0
  524. package/src/zones/stores/zoneEdit.ts +998 -0
@@ -0,0 +1,2854 @@
1
+ 'use strict';
2
+
3
+ var chunkQFO5CZG2_cjs = require('../chunk-QFO5CZG2.cjs');
4
+ var chunk7NBRCENN_cjs = require('../chunk-7NBRCENN.cjs');
5
+ var chunkNCLA6DKD_cjs = require('../chunk-NCLA6DKD.cjs');
6
+ var chunkOQSYFH3Z_cjs = require('../chunk-OQSYFH3Z.cjs');
7
+ var chunkPACIO4NS_cjs = require('../chunk-PACIO4NS.cjs');
8
+ var chunkOP37FKW6_cjs = require('../chunk-OP37FKW6.cjs');
9
+ var chunkEOKRXXAC_cjs = require('../chunk-EOKRXXAC.cjs');
10
+ var chunkQL63MUEW_cjs = require('../chunk-QL63MUEW.cjs');
11
+ var agent = require('@mountaya/elements/agent');
12
+ var geo = require('@mountaya/elements/geo');
13
+ var z = require('zod');
14
+ var vanilla = require('zustand/vanilla');
15
+
16
+ function _interopNamespace(e) {
17
+ if (e && e.__esModule) return e;
18
+ var n = Object.create(null);
19
+ if (e) {
20
+ Object.keys(e).forEach(function (k) {
21
+ if (k !== 'default') {
22
+ var d = Object.getOwnPropertyDescriptor(e, k);
23
+ Object.defineProperty(n, k, d.get ? d : {
24
+ enumerable: true,
25
+ get: function () { return e[k]; }
26
+ });
27
+ }
28
+ });
29
+ }
30
+ n.default = e;
31
+ return Object.freeze(n);
32
+ }
33
+
34
+ var z__namespace = /*#__PURE__*/_interopNamespace(z);
35
+
36
+ // src/chrome/handlers/stateDelta.ts
37
+ var editingOf = (ui) => {
38
+ if (ui.segmentEditSession) {
39
+ return [ui.segmentEditSession.segmentId ?? null, "segment"];
40
+ }
41
+ if (ui.waypointEditSession) {
42
+ return [ui.waypointEditSession.waypointId ?? null, "waypoint"];
43
+ }
44
+ if (ui.zoneEditSession) {
45
+ return [ui.zoneEditSession.zoneId ?? null, "zone"];
46
+ }
47
+ return [null, null];
48
+ };
49
+ var captureStudioState = (ctx) => {
50
+ const ui = ctx.ui.getState();
51
+ const itinerary = ui.activeItinerary;
52
+ const [editingId, editingKind] = editingOf(ui);
53
+ return {
54
+ activeOverlay: ui.activeOverlay ?? null,
55
+ editingId,
56
+ editingKind,
57
+ itineraryId: itinerary?.id ?? null,
58
+ itineraryName: itinerary?.name ?? null,
59
+ segmentCount: itinerary?.segments.length ?? 0,
60
+ selectionId: ui.selection?.id ?? null,
61
+ selectionKind: ui.selection?.kind ?? null,
62
+ waypointCount: itinerary?.waypoints.length ?? 0
63
+ };
64
+ };
65
+ var diffStudioState = (before, after) => {
66
+ const delta = {};
67
+ let changed = false;
68
+ for (const key of Object.keys(after)) {
69
+ if (before[key] !== after[key]) {
70
+ Object.assign(delta, { [key]: after[key] });
71
+ changed = true;
72
+ }
73
+ }
74
+ return changed ? delta : void 0;
75
+ };
76
+ var segmentTargetSchema = z__namespace.object({ segmentId: z__namespace.string().min(1) });
77
+ var waypointTargetSchema = z__namespace.object({ waypointId: z__namespace.string().min(1) });
78
+ var contracts = chunkOQSYFH3Z_cjs.studioToolContracts;
79
+ var agentEditLockTarget = (name, input) => {
80
+ const contract = contracts[name];
81
+ if (contract?.capability !== "editor") {
82
+ return null;
83
+ }
84
+ const segment = segmentTargetSchema.safeParse(input);
85
+ if (segment.success) {
86
+ return { id: segment.data.segmentId, kind: "segment" };
87
+ }
88
+ const waypoint = waypointTargetSchema.safeParse(input);
89
+ if (waypoint.success) {
90
+ return { id: waypoint.data.waypointId, kind: "waypoint" };
91
+ }
92
+ return null;
93
+ };
94
+ var agentHandoffTools = /* @__PURE__ */ new Set([
95
+ "studio.itinerary.segment.editPropose",
96
+ "studio.itinerary.waypoint.editPropose"
97
+ ]);
98
+ var agentTakesEntityBack = (name, input) => !agentHandoffTools.has(name) && agentEditLockTarget(name, input) !== null;
99
+
100
+ // src/agent/rules/copilotOrganization.ts
101
+ var copilotOrganizationId = (state) => {
102
+ if (state.activeItinerary) {
103
+ return state.activeItinerary.organization_id;
104
+ }
105
+ if (state.activeZone) {
106
+ return state.activeZone.organization_id;
107
+ }
108
+ return state.zoneEditSession?.intent === "create" ? state.zoneEditSession.organizationId : void 0;
109
+ };
110
+
111
+ // src/agent/rules/router.ts
112
+ var routerStateFrom = (ctx) => {
113
+ const ui = ctx.ui.getState();
114
+ const editSession = ui.segmentEditSession ? "segment" : ui.waypointEditSession ? "waypoint" : ui.zoneEditSession ? "zone" : null;
115
+ const openResource = ui.activeZone !== null ? "zone" : ui.activeItinerary !== null ? "itinerary" : null;
116
+ return {
117
+ editSession,
118
+ importDraft: ui.importSession !== null,
119
+ openResource,
120
+ suggestDraft: ui.suggestSession !== null,
121
+ videoOpen: ui.videoExport !== null
122
+ };
123
+ };
124
+ var compareIds = (a, b) => {
125
+ if (a === b) {
126
+ return 0;
127
+ }
128
+ return a < b ? -1 : 1;
129
+ };
130
+ var createStudioRouter = ({
131
+ playbook,
132
+ skillRoutes,
133
+ surfaceLocks,
134
+ surfaces: surfaceTable
135
+ }) => {
136
+ const wideFallbackSurfaces = () => surfaceTable.filter((surface) => surface.wideFallback).map((surface) => surface.id);
137
+ const alwaysOn = () => surfaceTable.filter((surface) => surface.always).map((surface) => surface.id);
138
+ const lockHolds = (lock, state) => state[lock.field] === lock.equals;
139
+ const MAX_TASK_SURFACES = 2;
140
+ const MAX_CARRIED_SURFACES = 4;
141
+ const foldApostrophes = (message) => message.replace(/’/g, "'");
142
+ const matchSkillRoutes = (message) => {
143
+ const lowered = message.toLowerCase();
144
+ const hits = skillRoutes.map((route) => ({
145
+ matches: route.intents.filter((intent) => intent !== "" && lowered.includes(intent)).length,
146
+ route
147
+ })).filter((entry) => entry.matches > 0).sort((a, b) => b.matches - a.matches || compareIds(a.route.id, b.route.id)).slice(0, 3);
148
+ const surfaces = [];
149
+ for (const hit of hits) {
150
+ for (const id of hit.route.surfaces) {
151
+ if (surfaces.length >= MAX_CARRIED_SURFACES) {
152
+ return surfaces;
153
+ }
154
+ if (!surfaces.includes(id)) {
155
+ surfaces.push(id);
156
+ }
157
+ }
158
+ }
159
+ return surfaces;
160
+ };
161
+ const surfacePatterns = new Map(
162
+ surfaceTable.map((surface) => [
163
+ surface.id,
164
+ surface.keywords.map(
165
+ // Unicode-aware word boundaries, not \b. \b is defined by ASCII \w
166
+ // transitions, so a keyword starting or ending on an accented letter
167
+ // ("météo", "vidéo", "évite") could NEVER match: there is no \w transition
168
+ // at "é", so \bé matches nothing. Half the product's languages is French.
169
+ //
170
+ // The LEADING boundary excludes letters but not digits: people glue a
171
+ // number onto a unit ("target 12km", "600m ascent"), and a digit-blind
172
+ // boundary would make the unit keyword unmatchable exactly in the messages
173
+ // it exists for. A letter still blocks ("workman" does not fire "km"); the
174
+ // trailing boundary keeps digits so "km2" stays a non-match.
175
+ (keyword) => new RegExp(
176
+ `(?<![\\p{L}_])${keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\p{L}\\p{N}_])`,
177
+ "iu"
178
+ )
179
+ )
180
+ ])
181
+ );
182
+ const scoreSurface = (surface, message) => {
183
+ let score = 0;
184
+ for (const pattern of surfacePatterns.get(surface.id) ?? []) {
185
+ if (pattern.test(message)) {
186
+ score += 1;
187
+ }
188
+ }
189
+ return score;
190
+ };
191
+ const selectSurfaces2 = (message, state = {}, previous = []) => {
192
+ const core = alwaysOn();
193
+ const known = new Set(surfaceTable.map((surface) => surface.id));
194
+ const folded = foldApostrophes(message);
195
+ const locked = surfaceLocks.filter((lock) => lockHolds(lock, state)).map((lock) => lock.surface).filter((id) => known.has(id) && !core.includes(id)).slice(0, MAX_TASK_SURFACES);
196
+ const skillDriven = matchSkillRoutes(folded).filter(
197
+ (id) => known.has(id) && !core.includes(id)
198
+ );
199
+ const scored = surfaceTable.filter((surface) => !surface.always && surface.keywords.length > 0).map((surface) => ({ id: surface.id, score: scoreSurface(surface, folded) })).filter((entry) => entry.score > 0).sort((a, b) => b.score - a.score || compareIds(a.id, b.id));
200
+ const keywordMatched = scored.slice(0, MAX_TASK_SURFACES).map((entry) => entry.id);
201
+ const matched = [];
202
+ for (const id of [...locked, ...skillDriven, ...keywordMatched]) {
203
+ if (matched.length >= MAX_CARRIED_SURFACES) {
204
+ break;
205
+ }
206
+ if (!matched.includes(id)) {
207
+ matched.push(id);
208
+ }
209
+ }
210
+ let carried = previous.filter((id) => known.has(id) && !core.includes(id));
211
+ if (carried.length > MAX_CARRIED_SURFACES) {
212
+ carried = [];
213
+ }
214
+ if (matched.length === 0) {
215
+ if (carried.length > 0) {
216
+ return { reason: "sticky", surfaces: [...core, ...carried] };
217
+ }
218
+ return {
219
+ reason: "wide",
220
+ surfaces: wideFallbackSurfaces()
221
+ };
222
+ }
223
+ if (carried.length > 0 && matched.every((id) => carried.includes(id))) {
224
+ return { reason: "sticky", surfaces: [...core, ...carried] };
225
+ }
226
+ let reason = "intent";
227
+ if (locked.length > 0) {
228
+ reason = "lock";
229
+ } else if (skillDriven.length > 0) {
230
+ reason = "skill";
231
+ }
232
+ return { reason, surfaces: [...core, ...matched] };
233
+ };
234
+ const surfaceTools2 = (surfaces) => {
235
+ const wanted = new Set(surfaces);
236
+ const tools = /* @__PURE__ */ new Set();
237
+ for (const surface of surfaceTable) {
238
+ if (!wanted.has(surface.id)) {
239
+ continue;
240
+ }
241
+ for (const member of surface.members) {
242
+ tools.add(member);
243
+ }
244
+ }
245
+ return tools;
246
+ };
247
+ const recoveryFor2 = (tool, code) => {
248
+ if (!code) {
249
+ return void 0;
250
+ }
251
+ return playbook.find((entry) => entry.id === tool)?.recovery.find((item) => item.code === code)?.do;
252
+ };
253
+ return { recoveryFor: recoveryFor2, selectSurfaces: selectSurfaces2, surfaceTools: surfaceTools2 };
254
+ };
255
+
256
+ // src/agent/rules/stateDelta.ts
257
+ var studioStateDelta = {
258
+ capture: captureStudioState,
259
+ diff: diffStudioState
260
+ };
261
+
262
+ // src/agent/rules/playbook.gen.ts
263
+ var PLAYBOOK = [
264
+ {
265
+ confirms: false,
266
+ description: "Classify an existing line by surface, way type, trail difficulty, and steepness. Typed operation first, and anything else only when none of them fits.",
267
+ id: "analyzeGeometry",
268
+ kind: "read",
269
+ recovery: [
270
+ { code: "invalid-input", do: "Coordinates are [longitude, latitude] pairs. A saved segment's positions carry an altitude, and a routed one is a GeometryCollection: take its LineString, drop the altitude, and retry once." }
271
+ ],
272
+ surfaces: ["routing"]
273
+ },
274
+ {
275
+ confirms: false,
276
+ description: "Run a raw read-only GraphQL query against the Data API. Typed operation first, and anything else only when none of them fits.",
277
+ id: "data.query",
278
+ kind: "read",
279
+ recovery: [
280
+ { code: "invalid-input", do: "Do not iterate on the syntax. Switch to the typed operation that covers the question." },
281
+ { code: "forbidden", do: "The query attempted a write or an unpermitted root field. It will not succeed rewritten." }
282
+ ],
283
+ surfaces: ["advanced"]
284
+ },
285
+ {
286
+ confirms: false,
287
+ description: "Compute a route between waypoints for an activity, with its distance, duration, and geometry. You intend to change the user's route. This alone changes nothing; propose the edit.",
288
+ id: "directions.compute",
289
+ kind: "read",
290
+ recovery: [
291
+ { code: "invalid-input", do: "Check dimensionality and coordinate order, then retry once." },
292
+ { code: "not-found", do: "Report it as a real answer, not a failure. The network may genuinely not connect them for this activity." },
293
+ { code: "rate-limited", do: "Stop computing alternatives and report what you have." }
294
+ ],
295
+ surfaces: ["routing"]
296
+ },
297
+ {
298
+ confirms: false,
299
+ description: "Compute the area reachable from one or more origins within a time or distance budget. Typed operation first, and anything else only when none of them fits.",
300
+ id: "isochrones",
301
+ kind: "read",
302
+ recovery: [
303
+ { code: "invalid-input", do: "Reduce the budget and retry once. Very large ranges are refused rather than truncated." },
304
+ { code: "upgrade-required", do: "The organization does not hold the Data API. Say so; do not retry." }
305
+ ],
306
+ surfaces: ["zones"]
307
+ },
308
+ {
309
+ confirms: false,
310
+ description: "Compute travel time and distance between many origins and destinations in one call. Typed operation first, and anything else only when none of them fits.",
311
+ id: "matrix",
312
+ kind: "read",
313
+ recovery: [
314
+ { code: "invalid-input", do: "Indices are into the locations array. Rebuild them and retry once with fewer points." },
315
+ { code: "rate-limited", do: "Stop. Rank what you already have rather than waiting." }
316
+ ],
317
+ surfaces: ["routing"]
318
+ },
319
+ {
320
+ capability: "authenticated",
321
+ confirms: false,
322
+ description: 'Resolve a named place to coordinates. Named place, free text, category, or "propose me something".',
323
+ id: "studio.data.geocode",
324
+ kind: "read",
325
+ recovery: [
326
+ { code: "not-found", do: "No place by that name. Try search, which matches loosely, before telling the user it does not exist." },
327
+ { code: "rate-limited", do: "Stop looking things up. Work with what you have and say so." }
328
+ ],
329
+ surfaces: ["discovery"]
330
+ },
331
+ {
332
+ capability: "authenticated",
333
+ confirms: false,
334
+ description: 'List points of interest of a category within an area. Named place, free text, category, or "propose me something".',
335
+ id: "studio.data.pois",
336
+ kind: "read",
337
+ recovery: [
338
+ { code: "invalid-input", do: "A bbox is [minLongitude, minLatitude, maxLongitude, maxLatitude]. Rebuild it and retry once." }
339
+ ],
340
+ surfaces: ["discovery"]
341
+ },
342
+ {
343
+ capability: "authenticated",
344
+ confirms: false,
345
+ description: 'Name the place at a coordinate. Named place, free text, category, or "propose me something".',
346
+ id: "studio.data.reverseGeocode",
347
+ kind: "read",
348
+ recovery: [
349
+ { code: "not-found", do: "Nothing named there. Describe the point by its position on the route instead." }
350
+ ],
351
+ surfaces: ["discovery"]
352
+ },
353
+ {
354
+ capability: "authenticated",
355
+ confirms: false,
356
+ description: 'Search free text across places, points of interest, and itineraries, collections, and zones the user can see. Named place, free text, category, or "propose me something".',
357
+ id: "studio.data.search",
358
+ kind: "read",
359
+ recovery: [
360
+ { code: "rate-limited", do: "Stop searching. Report what you have already found." }
361
+ ],
362
+ surfaces: ["discovery"]
363
+ },
364
+ {
365
+ capability: "editor",
366
+ confirms: false,
367
+ description: "Copy an itinerary, or a continuous stretch of it, into a new itinerary. Not for moving or renaming an itinerary; this always leaves the original in place and adds a second one.",
368
+ id: "studio.itinerary.duplicate",
369
+ kind: "mutate",
370
+ recovery: [
371
+ { code: "draft-open", do: "A proposal is not a saved itinerary and has nothing to copy. Tell the user to save or discard the draft first, and stop." },
372
+ { code: "invalid-input", do: "Re-read the itinerary and keep an unbroken stretch, or leave segmentIds and waypointIds out to copy it whole, before retrying once." },
373
+ { code: "upgrade-required", do: "This organization's agreement does not include this action. Say so and stop. Do not retry, and do not copy the itinerary elsewhere unless the user asks." },
374
+ { code: "forbidden", do: "Report which organization was refused and offer the ones they can write to, then stop." },
375
+ { code: "conflict", do: "When the refusal names the itinerary holding the name, ask the user for another name and copy under it. Otherwise this same copy is still being made and may yet land: wait a moment and look for the new itinerary before telling the user it failed, and do not copy again while it may appear. Never resend a write that may still land." },
376
+ { code: "limit-reached", do: "The personal space is full. Say so and stop; do not retry, and do not copy the itinerary elsewhere unless the user asks." }
377
+ ],
378
+ surfaces: ["authoring"]
379
+ },
380
+ {
381
+ capability: "authenticated",
382
+ confirms: false,
383
+ description: "Read the open itinerary: its segments, waypoints, and elevation summary. The narrowest read that answers the question.",
384
+ id: "studio.itinerary.getActive",
385
+ kind: "read",
386
+ recovery: [
387
+ { code: "not-found", do: "No itinerary is open. Ask the user to open one rather than creating one uninvited." }
388
+ ],
389
+ surfaces: ["core"]
390
+ },
391
+ {
392
+ capability: "editor",
393
+ confirms: false,
394
+ description: "Present a run of neighbouring segments as one named, coloured leg on the elevation profile. Not for actually joining the segments into one; that is studio.itinerary.segment.merge.",
395
+ id: "studio.itinerary.group.create",
396
+ kind: "mutate",
397
+ recovery: [
398
+ { code: "draft-open", do: "A proposal has no stored segments to group. Tell the user to save or discard the draft first, and stop." },
399
+ { code: "invalid-input", do: "Re-read the itinerary, pick neighbours in chain order, and retry once." },
400
+ { code: "conflict", do: "Re-read the itinerary. If the group you asked for is there, it landed: do not make it again. Otherwise tell the user which group holds the segment. Do not retry blind: edit or remove that group first, only if the user agrees. When no group holds it yet, wait a moment and re-read once more, since a conflict can mean the write is still being made. Never resend a write that may still land." },
401
+ { code: "collab-locked", do: "Report who holds it and stop. Grouping is serialized to one editor at a time." },
402
+ { code: "not-found", do: "Re-read the itinerary; the chain changed underneath you." },
403
+ { code: "upgrade-required", do: "This organization's agreement does not include this action. Say so and stop. Do not retry, and do not copy the itinerary elsewhere unless the user asks." }
404
+ ],
405
+ surfaces: ["authoring"]
406
+ },
407
+ {
408
+ capability: "editor",
409
+ confirms: false,
410
+ description: "Dissolve a group so its segments read as separate legs again. Not for deleting segments. This removes a label; the route is untouched. Deleting a segment is its own verb.",
411
+ id: "studio.itinerary.group.delete",
412
+ kind: "mutate",
413
+ recovery: [
414
+ { code: "draft-open", do: "A proposal carries no stored groups. Tell the user to save or discard the draft first, and stop." },
415
+ { code: "collab-locked", do: "Report who holds it and stop. Group edits are serialized to one editor at a time." },
416
+ { code: "conflict", do: "Re-read the itinerary. If the group is gone, the dissolve landed: do not make it again. If it is still there, wait a moment and re-read once more, since a conflict can mean the write is still being made, and dissolve it again only if it remains. Never resend a write that may still land." },
417
+ { code: "not-found", do: "Re-read the itinerary. It may already have been dissolved, including automatically, when a merge or a delete dropped its run below two segments." },
418
+ { code: "upgrade-required", do: "This organization's agreement does not include this action. Say so and stop. Do not retry, and do not copy the itinerary elsewhere unless the user asks." }
419
+ ],
420
+ surfaces: ["authoring"]
421
+ },
422
+ {
423
+ capability: "editor",
424
+ confirms: false,
425
+ description: "Change which run of segments an existing group covers. Not for renaming or recolouring; that is studio.itinerary.group.update.",
426
+ id: "studio.itinerary.group.setRange",
427
+ kind: "mutate",
428
+ recovery: [
429
+ { code: "draft-open", do: "A proposal carries no stored groups. Tell the user to save or discard the draft first, and stop." },
430
+ { code: "invalid-input", do: "Re-read the itinerary, rebuild the full membership in chain order, and retry once. If the user wanted the group gone, dissolve it instead." },
431
+ { code: "collab-locked", do: "Report who holds it and stop. Group edits are serialized to one editor at a time." },
432
+ { code: "conflict", do: "Re-read the itinerary. If the group already spans the run you sent, the change landed: do not make it again. Otherwise tell the user which group now holds the segment. Do not retry blind: the run they asked for may no longer be free. When no other group holds it, wait a moment and re-read once more, since a conflict can mean the write is still being made. Never resend a write that may still land." },
433
+ { code: "not-found", do: "Re-read the itinerary; the chain changed underneath you." },
434
+ { code: "upgrade-required", do: "This organization's agreement does not include this action. Say so and stop. Do not retry, and do not copy the itinerary elsewhere unless the user asks." }
435
+ ],
436
+ surfaces: ["authoring"]
437
+ },
438
+ {
439
+ capability: "editor",
440
+ confirms: false,
441
+ description: "Change what an existing group is called, what colour it paints, or the pace it is timed at. Not for changing which segments the group covers; that is studio.itinerary.group.setRange.",
442
+ id: "studio.itinerary.group.update",
443
+ kind: "mutate",
444
+ recovery: [
445
+ { code: "draft-open", do: "A proposal carries no stored groups. Tell the user to save or discard the draft first, and stop." },
446
+ { code: "invalid-input", do: "Correct the field the message names and retry once. A speed of zero is not a pace; send null if the user wanted the override removed." },
447
+ { code: "collab-locked", do: "Report who holds it and stop. Group edits are serialized to one editor at a time." },
448
+ { code: "conflict", do: "Re-read the itinerary. If the group already reads as you asked, the change landed: do not make it again. If it does not, wait a moment and re-read once more, since a conflict can mean the write is still being made, then apply the user's change to the group as it stands now, and retry once. Never resend a write that may still land." },
449
+ { code: "not-found", do: "Re-read the itinerary; it may have been dissolved underneath you." },
450
+ { code: "upgrade-required", do: "This organization's agreement does not include this action. Say so and stop. Do not retry, and do not copy the itinerary elsewhere unless the user asks." }
451
+ ],
452
+ surfaces: ["authoring"]
453
+ },
454
+ {
455
+ capability: "editor",
456
+ confirms: false,
457
+ description: "Append a new routed segment to the end of the open itinerary, through 2\u201345 vias. Ask when they have not said which, and where. A wrong guess rewrites their work.",
458
+ id: "studio.itinerary.segment.create",
459
+ kind: "mutate",
460
+ recovery: [
461
+ { code: "invalid-input", do: "Coordinates are [longitude, latitude], longitude first. Simplify to the working range and retry once." },
462
+ { code: "conflict", do: "Re-read the itinerary. If the segment you appended is there, the append landed: do not make it again. If it is not, wait a moment and re-read once more, since a conflict can mean the write is still being made, and rebuild the append against the current revision only if it is still absent. Never resend a write that may still land." },
463
+ { code: "collab-locked", do: "Report who holds it and stop." },
464
+ { code: "upgrade-required", do: "This organization's agreement does not include this action. Say so and stop. Do not retry, and do not copy the itinerary elsewhere unless the user asks." }
465
+ ],
466
+ surfaces: ["routing"]
467
+ },
468
+ {
469
+ capability: "editor",
470
+ confirms: false,
471
+ description: "Propose new via points for a segment, opening a live editable draft the user reviews and saves. Propose opens a draft the user saves. The agent never commits.",
472
+ id: "studio.itinerary.segment.editPropose",
473
+ kind: "propose",
474
+ recovery: [
475
+ { code: "edit-in-progress", do: "Read the live draft. Iterate on it rather than starting a new one." },
476
+ { code: "collab-locked", do: "Report who holds it and stop. Retrying will not acquire the lock." },
477
+ { code: "conflict", do: "Re-read the itinerary and rebuild the proposal against the current revision." },
478
+ { code: "invalid-input", do: "Coordinates are [longitude, latitude], longitude first, and the cap is 45. Reduce to the working range of two to six and retry once." }
479
+ ],
480
+ surfaces: ["routing"]
481
+ },
482
+ {
483
+ capability: "editor",
484
+ confirms: false,
485
+ description: "Add a new segment INSIDE the chain, after a named segment or at the head, and renumber what follows. Ask when they have not said which, and where. A wrong guess rewrites their work.",
486
+ id: "studio.itinerary.segment.insert",
487
+ kind: "mutate",
488
+ recovery: [
489
+ { code: "draft-open", do: "A proposal has nothing to insert into. Tell the user to save or discard the draft first, and stop." },
490
+ { code: "invalid-input", do: "Append with studio.itinerary.segment.create when the gap is at the end. Otherwise re-read the chain and retry once with a valid anchor." },
491
+ { code: "collab-locked", do: "Report who holds it and stop." },
492
+ { code: "upgrade-required", do: "This organization's agreement does not include this action. Say so and stop. Do not retry, and do not copy the itinerary elsewhere unless the user asks." },
493
+ { code: "forbidden", do: "Report which organization refused the edit and stop. Nothing changed." },
494
+ { code: "conflict", do: "Re-read the itinerary; the anchor you picked may have moved or gone. If the segment you inserted is there, the insert landed: do not make it again. If it is not, wait a moment and re-read once more, since a conflict can mean the write is still being made, and insert again only if it is still absent. Never resend a write that may still land." }
495
+ ],
496
+ surfaces: ["routing"]
497
+ },
498
+ {
499
+ capability: "editor",
500
+ confirms: true,
501
+ description: "Join a segment with the one that follows it, leaving a single segment in their place. Not for making two segments merely READ as one leg; that is studio.itinerary.group.create.",
502
+ id: "studio.itinerary.segment.merge",
503
+ kind: "mutate",
504
+ recovery: [
505
+ { code: "draft-open", do: "A proposal has no stored segments to join. Tell the user to save or discard the draft first, and stop." },
506
+ { code: "invalid-input", do: "Nothing was changed. The refusal states the limit the two segments pass together, such as the 45 waypoints of a routed merge or the 10,000 positions of a freehand one. Report it and stop; do not thin the user's via points or line to make the merge fit." },
507
+ { code: "collab-locked", do: "Report who holds it and stop. Both segments must be free to merge." },
508
+ { code: "conflict", do: "Re-read the itinerary. If the two segments are already one, the merge landed: do not make it again. Otherwise check the segment is not last, that both use the same engine and belong to the same group or to none, and re-decide which pair the user meant before retrying once. When nothing in the itinerary explains the refusal, wait a moment and re-read first, since a conflict can mean the write is still being made. Never resend a write that may still land." },
509
+ { code: "upgrade-required", do: "This organization's agreement does not include this action. Say so and stop. Do not retry, and do not copy the itinerary elsewhere unless the user asks." }
510
+ ],
511
+ surfaces: ["routing"]
512
+ },
513
+ {
514
+ capability: "editor",
515
+ confirms: true,
516
+ description: "Switch one segment between following the trail network and following the line as drawn. Not for making the route take a different path; that is studio.itinerary.segment.editPropose.",
517
+ id: "studio.itinerary.segment.setMode",
518
+ kind: "mutate",
519
+ recovery: [
520
+ { code: "draft-open", do: "A proposal has no stored segment whose engine could change. Tell the user to save or discard the draft first, and stop." },
521
+ { code: "invalid-input", do: "Nothing was written. When the refusal names the engine the segment already uses, there is nothing to change: say so. Otherwise report that the line cannot be routed and leave the segment freehand. Do not retry the same call." },
522
+ { code: "collab-locked", do: "Report who holds it and stop." },
523
+ { code: "conflict", do: "Re-read the itinerary. If the segment already uses the engine you asked for, the switch landed: do not make it again. If it does not, wait a moment and re-read once more, since a conflict can mean the write is still being made, and switch again only if it is still unchanged. Never resend a write that may still land." },
524
+ { code: "internal", do: "The segment is unchanged. Report the failure and retry once at most." },
525
+ { code: "upgrade-required", do: "This organization's agreement does not include this action. Say so and stop. Do not retry, and do not copy the itinerary elsewhere unless the user asks." }
526
+ ],
527
+ surfaces: ["routing"]
528
+ },
529
+ {
530
+ capability: "editor",
531
+ confirms: true,
532
+ description: "Cut one segment in two at a point along its length, given as a fraction of that length. Not for making the route go somewhere else; that is studio.itinerary.segment.editPropose.",
533
+ id: "studio.itinerary.segment.split",
534
+ kind: "mutate",
535
+ recovery: [
536
+ { code: "draft-open", do: "A proposal has no stored segment to cut. Tell the user to save or discard the draft first, and stop." },
537
+ { code: "invalid-input", do: "Pick a point further from both ends and retry once." },
538
+ { code: "collab-locked", do: "Report who holds it and stop." },
539
+ { code: "upgrade-required", do: "This organization's agreement does not include this action. Say so and stop. Do not retry, and do not copy the itinerary elsewhere unless the user asks." },
540
+ { code: "forbidden", do: "Report which organization refused the edit and stop. Nothing changed." },
541
+ { code: "conflict", do: "Re-read the itinerary; the length you based the fraction on may have changed. If the segment is already split where you asked, the split landed: do not make it again. If it is not, wait a moment and re-read once more, since a conflict can mean the write is still being made, and split again only if it is still whole. Never resend a write that may still land." }
542
+ ],
543
+ surfaces: ["routing"]
544
+ },
545
+ {
546
+ capability: "editor",
547
+ confirms: false,
548
+ description: "Write a segment's geometry directly, the path a human drag-and-drop takes. Propose opens a draft the user saves. The agent never commits.",
549
+ id: "studio.itinerary.segment.updateGeometry",
550
+ kind: "mutate",
551
+ recovery: [
552
+ { code: "capability-denied", do: "Expected. Propose the edit instead." }
553
+ ],
554
+ surfaces: ["routing"]
555
+ },
556
+ {
557
+ capability: "authenticated",
558
+ confirms: false,
559
+ description: "Read the map viewport: centre, zoom, bearing, and pitch. The narrowest read that answers the question.",
560
+ id: "studio.map.getView",
561
+ kind: "read",
562
+ recovery: [
563
+ { code: "internal", do: "The map is not ready. Proceed without it and bound your work by the itinerary instead." }
564
+ ],
565
+ surfaces: ["core"]
566
+ },
567
+ {
568
+ capability: "authenticated",
569
+ confirms: false,
570
+ description: "List the overlays the scope in view can draw, with their kind and category. You already listed them in this run and the scope has not moved since.",
571
+ id: "studio.overlay.listAvailable",
572
+ kind: "read",
573
+ recovery: [
574
+ { code: "internal", do: "Proceed without the catalog and let studio.overlay.set report not-found for an identifier that does not exist, rather than blocking the task." }
575
+ ],
576
+ surfaces: ["terrain"]
577
+ },
578
+ {
579
+ capability: "embedding",
580
+ confirms: false,
581
+ description: "Show or hide a raster overlay on the map for the user to look at. Overlays are for the user's eyes. Numbers come from sampling, never from a visual.",
582
+ id: "studio.overlay.set",
583
+ kind: "mutate",
584
+ recovery: [
585
+ { code: "invalid-input", do: "Call studio.overlay.listAvailable and pick from the catalog it returns." },
586
+ { code: "capability-denied", do: "The caller cannot change overlays. Report what you found in words instead." },
587
+ { code: "upgrade-required", do: "Report what you found in words instead, and say overlays are not available in this scope. Do not retry." }
588
+ ],
589
+ surfaces: ["terrain"]
590
+ },
591
+ {
592
+ capability: "authenticated",
593
+ confirms: false,
594
+ description: "Read what is currently selected. The narrowest read that answers the question.",
595
+ id: "studio.selection.get",
596
+ kind: "read",
597
+ recovery: [
598
+ { code: "capability-denied", do: "The caller cannot read the studio. Ask the user what they meant instead." }
599
+ ],
600
+ surfaces: ["core"]
601
+ },
602
+ {
603
+ capability: "authenticated",
604
+ confirms: false,
605
+ description: "Open the share-link dialog for one itinerary or one collection, named by its kind and id. Not for the map running inside a page of their own. That is the embed wizard, not a link.",
606
+ id: "studio.share.open",
607
+ kind: "navigate",
608
+ recovery: [
609
+ { code: "forbidden", do: "Report why rather than retrying. There is no second route to a link." },
610
+ { code: "not-found", do: "Re-read the itineraries or collections the user can see and confirm which one they meant." },
611
+ { code: "capability-denied", do: "The caller cannot open studio dialogs. Say the link has to be made from the studio." }
612
+ ],
613
+ surfaces: ["sharing", "collections"]
614
+ },
615
+ {
616
+ capability: "authenticated",
617
+ confirms: false,
618
+ description: "Read the whole studio state: itinerary, open zone, selection, open edit draft, overlays, viewport, preferences. The narrowest read that answers the question.",
619
+ id: "studio.state.get",
620
+ kind: "read",
621
+ recovery: [
622
+ { code: "internal", do: "Fall back to the narrow reads (selection, viewport, active itinerary) and proceed with what you can establish." }
623
+ ],
624
+ surfaces: ["core"]
625
+ },
626
+ {
627
+ confirms: false,
628
+ description: 'Propose candidate routes matching activity, distance, and ascent constraints. Named place, free text, category, or "propose me something".',
629
+ id: "suggestions",
630
+ kind: "read",
631
+ recovery: [
632
+ { code: "not-found", do: "No candidates fit. Loosen the tightest constraint once, then report that the ask is too narrow." },
633
+ { code: "invalid-input", do: "A real answer, not a failure. Try a different start point once; if it repeats, say the area cannot be suggested from there and offer to draw the route with directions instead, which the user can take across it knowingly." },
634
+ { code: "upgrade-required", do: "The organization does not hold the Data API. Say so; do not retry." }
635
+ ],
636
+ surfaces: ["discovery"]
637
+ },
638
+ {
639
+ confirms: false,
640
+ description: "Sample elevation, slope and aspect over a rectangular grid of the DEM. A few known points, along a known line, or over an unknown area.",
641
+ id: "terrainGrid",
642
+ kind: "read",
643
+ recovery: [
644
+ { code: "invalid-input", do: "The box may cover at most 100 km\xB2: shrink it around the feature, about 10 km a side, rather than reusing the view bounds; resolution does not change the area. Keep cols and rows between 2 and 64, then retry once." },
645
+ { code: "rate-limited", do: "Stop sampling. Report what you already have rather than waiting." },
646
+ { code: "upgrade-required", do: "The organization does not hold the Data API. Say so; do not retry." }
647
+ ],
648
+ surfaces: ["terrain"]
649
+ },
650
+ {
651
+ confirms: false,
652
+ description: "Sample the surface at a fixed interval along a geometry. A few known points, along a known line, or over an unknown area.",
653
+ id: "terrainProfile",
654
+ kind: "read",
655
+ recovery: [
656
+ { code: "invalid-input", do: "Coordinates are [longitude, latitude] pairs, longitude first. A saved segment's positions carry an altitude, and a routed one is a GeometryCollection: take its LineString, drop the altitude, and retry once with spacing at the default." },
657
+ { code: "rate-limited", do: "Stop sampling. Report what you already have rather than waiting." }
658
+ ],
659
+ surfaces: ["terrain"]
660
+ },
661
+ {
662
+ confirms: false,
663
+ description: "Sample elevation, slope, and aspect at specific coordinates. A few known points, along a known line, or over an unknown area.",
664
+ id: "terrainSamples",
665
+ kind: "read",
666
+ recovery: [
667
+ { code: "invalid-input", do: "Coordinates are [longitude, latitude], longitude first. Split the batch and retry once." },
668
+ { code: "upgrade-required", do: "The organization does not hold the Data API. Say so; do not retry." }
669
+ ],
670
+ surfaces: ["terrain"]
671
+ }
672
+ ];
673
+
674
+ // src/agent/rules/surfaces.gen.ts
675
+ var SURFACES = [
676
+ {
677
+ always: true,
678
+ id: "core",
679
+ keywords: [],
680
+ members: [
681
+ "studio.alert.dismiss",
682
+ "studio.alert.show",
683
+ "studio.itinerary.getActive",
684
+ "studio.map.applyCamera",
685
+ "studio.map.fitBounds",
686
+ "studio.map.fitBoundsOrFly",
687
+ "studio.map.fitBoundsToSegment",
688
+ "studio.map.getView",
689
+ "studio.map.resetNorth",
690
+ "studio.map.zoomIn",
691
+ "studio.map.zoomOut",
692
+ "studio.overlay.getActive",
693
+ "studio.panel.close",
694
+ "studio.panel.toggle",
695
+ "studio.preferences.set",
696
+ "studio.question.ask",
697
+ "studio.selection.get",
698
+ "studio.sidenav.back",
699
+ "studio.state.get",
700
+ "studio.tabs.close",
701
+ "studio.tabs.create",
702
+ "studio.tabs.open",
703
+ "studio.tabs.switch"
704
+ ],
705
+ purpose: "Read the world, move the map, talk to the user. Needed by every run.",
706
+ title: "Core",
707
+ wideFallback: true
708
+ },
709
+ {
710
+ always: false,
711
+ id: "routing",
712
+ keywords: ["reroute", "via", "waypoint order", "steeper", "flatter", "avoid", "detour", "shorter", "longer", "how long", "compare", "split", "cut", "merge", "join", "insert", "freehand", "routed", "engine", "\xE9vite", "\xE9viter", "contourne", "contourner", "d\xE9tour", "passe par", "passer par", "plus court", "plus courte", "plus long", "plus longue", "plus raide", "moins raide", "raccourci", "trac\xE9", "couper", "scinder", "fusionner", "joindre", "ins\xE9rer", "trac\xE9 libre", "moteur"],
713
+ members: [
714
+ "analyzeGeometry",
715
+ "directions.compute",
716
+ "matrix",
717
+ "studio.itinerary.directions.close",
718
+ "studio.itinerary.directions.open",
719
+ "studio.itinerary.segment.create",
720
+ "studio.itinerary.segment.editBegin",
721
+ "studio.itinerary.segment.editCancel",
722
+ "studio.itinerary.segment.editCommit",
723
+ "studio.itinerary.segment.editPropose",
724
+ "studio.itinerary.segment.editRedo",
725
+ "studio.itinerary.segment.editUndo",
726
+ "studio.itinerary.segment.insert",
727
+ "studio.itinerary.segment.insertBegin",
728
+ "studio.itinerary.segment.merge",
729
+ "studio.itinerary.segment.recolor",
730
+ "studio.itinerary.segment.remove",
731
+ "studio.itinerary.segment.rename",
732
+ "studio.itinerary.segment.roadAccessClose",
733
+ "studio.itinerary.segment.roadAccessOpen",
734
+ "studio.itinerary.segment.select",
735
+ "studio.itinerary.segment.setMode",
736
+ "studio.itinerary.segment.setSpeed",
737
+ "studio.itinerary.segment.split",
738
+ "studio.itinerary.segment.splitPickBegin",
739
+ "studio.itinerary.segment.splitPickCancel",
740
+ "studio.itinerary.segment.splitPickSet",
741
+ "studio.itinerary.segment.updateGeometry",
742
+ "studio.itinerary.segment.via.promptClose",
743
+ "studio.itinerary.segment.via.promptOpen",
744
+ "studio.itinerary.segment.via.remove",
745
+ "studio.itinerary.segment.via.repeat",
746
+ "studio.segment.length",
747
+ "studio.segment.pointAtFraction"
748
+ ],
749
+ purpose: "Change the geometry of an existing route by proposing vias for the user to save.",
750
+ title: "Segment routing and editing",
751
+ wideFallback: true
752
+ },
753
+ {
754
+ always: false,
755
+ id: "terrain",
756
+ keywords: ["elevation", "slope", "aspect", "steep", "north face", "hillshade", "snow", "weather", "overlay", "altitude", "d\xE9nivel\xE9", "pente", "orientation", "exposition", "raide", "versant", "face nord", "relief", "ombrage", "neige", "m\xE9t\xE9o", "vent", "calque", "couche"],
757
+ members: [
758
+ "studio.itinerary.profile.sheet.set",
759
+ "studio.itinerary.profileMarker.set",
760
+ "studio.overlay.category.set",
761
+ "studio.overlay.enrichment.set",
762
+ "studio.overlay.listAvailable",
763
+ "studio.overlay.pois.display.set",
764
+ "studio.overlay.pois.group.set",
765
+ "studio.overlay.sampleAlongSegment",
766
+ "studio.overlay.sampleAt",
767
+ "studio.overlay.set",
768
+ "studio.overlay.timestamp.set",
769
+ "studio.terrain.set",
770
+ "terrainGrid",
771
+ "terrainProfile",
772
+ "terrainSamples"
773
+ ],
774
+ purpose: "Measure the surface (elevation, slope, aspect) and control what the user sees on it.",
775
+ title: "Terrain and overlays",
776
+ wideFallback: true
777
+ },
778
+ {
779
+ always: false,
780
+ id: "authoring",
781
+ keywords: ["create", "copy", "duplicate", "rename", "delete", "colour", "icon", "emphasis", "waypoint", "name it", "group", "stage", "leg", "cr\xE9e", "cr\xE9er", "copie", "copier", "dupliquer", "renomme", "renommer", "supprime", "supprimer", "couleur", "ic\xF4ne", "\xE9tape", "point de passage", "groupe", "grouper"],
782
+ members: [
783
+ "itinerary.get",
784
+ "studio.itinerary.activate",
785
+ "studio.itinerary.create",
786
+ "studio.itinerary.createOpen",
787
+ "studio.itinerary.delete",
788
+ "studio.itinerary.duplicate",
789
+ "studio.itinerary.emphasis.set",
790
+ "studio.itinerary.exclusions.set",
791
+ "studio.itinerary.group.create",
792
+ "studio.itinerary.group.delete",
793
+ "studio.itinerary.group.modal.close",
794
+ "studio.itinerary.group.modal.open",
795
+ "studio.itinerary.group.setRange",
796
+ "studio.itinerary.group.update",
797
+ "studio.itinerary.openForEdit",
798
+ "studio.itinerary.rename",
799
+ "studio.itinerary.tiles.refresh",
800
+ "studio.itinerary.update",
801
+ "studio.itinerary.waypoint.create",
802
+ "studio.itinerary.waypoint.detailsClose",
803
+ "studio.itinerary.waypoint.detailsOpen",
804
+ "studio.itinerary.waypoint.editBegin",
805
+ "studio.itinerary.waypoint.editCancel",
806
+ "studio.itinerary.waypoint.editCommit",
807
+ "studio.itinerary.waypoint.editPropose",
808
+ "studio.itinerary.waypoint.editRedo",
809
+ "studio.itinerary.waypoint.editSetColor",
810
+ "studio.itinerary.waypoint.editSetIcon",
811
+ "studio.itinerary.waypoint.editSetName",
812
+ "studio.itinerary.waypoint.editSetPosition",
813
+ "studio.itinerary.waypoint.editUndo",
814
+ "studio.itinerary.waypoint.recolor",
815
+ "studio.itinerary.waypoint.remove",
816
+ "studio.itinerary.waypoint.rename",
817
+ "studio.itinerary.waypoint.select",
818
+ "studio.itinerary.waypoint.setDetails",
819
+ "studio.itinerary.waypoint.setIcon"
820
+ ],
821
+ purpose: "Create, copy, rename, restyle, and delete itineraries, their waypoints, and their segment groups.",
822
+ title: "Itinerary authoring",
823
+ wideFallback: true
824
+ },
825
+ {
826
+ always: false,
827
+ id: "discovery",
828
+ keywords: ["find", "near", "where is", "hut", "peak", "parking", "suggest", "propose a route", "plan a route", "plan me a route", "loop", "plan", "target", "ascent", "km", "options", "trouve", "trouver", "cherche", "chercher", "pr\xE8s de", "autour de", "o\xF9 est", "refuge", "sommet", "col", "boucle", "sugg\xE8re", "sugg\xE9rer", "propose", "proposer", "planifie", "planifier", "g\xE9n\xE8re", "g\xE9n\xE9rer", "objectif", "ascension", "mont\xE9e"],
829
+ members: [
830
+ "studio.contextmenu.close",
831
+ "studio.contextmenu.open",
832
+ "studio.data.geocode",
833
+ "studio.data.pois",
834
+ "studio.data.reverseGeocode",
835
+ "studio.data.search",
836
+ "studio.geolocate.confirm",
837
+ "studio.geolocate.prompt.close",
838
+ "studio.geolocate.prompt.open",
839
+ "studio.itinerary.suggest.applyCandidate",
840
+ "studio.itinerary.suggest.beginPick",
841
+ "studio.itinerary.suggest.cancelPick",
842
+ "studio.itinerary.suggest.clearDraft",
843
+ "studio.itinerary.suggest.commit",
844
+ "studio.itinerary.suggest.discard",
845
+ "studio.itinerary.suggest.generate",
846
+ "studio.itinerary.suggest.select",
847
+ "studio.itinerary.suggest.setActivity",
848
+ "studio.itinerary.suggest.setAscent",
849
+ "studio.itinerary.suggest.setCollections",
850
+ "studio.itinerary.suggest.setDistance",
851
+ "studio.itinerary.suggest.setEnd",
852
+ "studio.itinerary.suggest.setName",
853
+ "studio.itinerary.suggest.setOrganization",
854
+ "studio.itinerary.suggest.setPrivate",
855
+ "studio.itinerary.suggest.setRouteType",
856
+ "studio.itinerary.suggest.setSpeed",
857
+ "studio.itinerary.suggest.setStart",
858
+ "studio.itinerary.suggest.startFrom",
859
+ "studio.itinerary.suggest.toggleKeep",
860
+ "studio.itinerary.suggestOpen",
861
+ "studio.map.locate",
862
+ "suggestions"
863
+ ],
864
+ purpose: "Find a place, a point of interest, or a candidate route to start from.",
865
+ title: "Places and route discovery",
866
+ wideFallback: true
867
+ },
868
+ {
869
+ always: false,
870
+ id: "zones",
871
+ keywords: ["zone", "area", "reachability", "isochrone", "hazard", "perimeter", "sector", "radius", "how far can I get", "reachable", "secteur", "p\xE9rim\xE8tre", "rayon", "accessible", "danger"],
872
+ members: [
873
+ "isochrones",
874
+ "studio.zone.beginOriginPick",
875
+ "studio.zone.cancelOriginPick",
876
+ "studio.zone.create",
877
+ "studio.zone.createBegin",
878
+ "studio.zone.delete",
879
+ "studio.zone.editBegin",
880
+ "studio.zone.editCancel",
881
+ "studio.zone.editCommit",
882
+ "studio.zone.editPropose",
883
+ "studio.zone.editRedo",
884
+ "studio.zone.editUndo",
885
+ "studio.zone.open",
886
+ "studio.zone.openForEdit",
887
+ "studio.zone.openForView",
888
+ "studio.zone.publish",
889
+ "studio.zone.reachabilityPreview",
890
+ "studio.zone.recompute",
891
+ "studio.zone.setCreateMethod",
892
+ "studio.zone.setLevel",
893
+ "studio.zone.setOrigin",
894
+ "studio.zone.unpublish",
895
+ "studio.zone.update"
896
+ ],
897
+ purpose: "Draw and maintain zones, the map areas marking reachability, hazard, or interest.",
898
+ title: "Zones",
899
+ wideFallback: true
900
+ },
901
+ {
902
+ always: false,
903
+ id: "collections",
904
+ keywords: ["collection", "group", "folder", "add to", "organize", "tidy up", "groupe", "dossier", "ajoute \xE0", "ajouter \xE0", "range", "ranger", "organise", "organiser"],
905
+ members: [
906
+ "studio.collection.addItinerary",
907
+ "studio.collection.addZone",
908
+ "studio.collection.create",
909
+ "studio.collection.createClose",
910
+ "studio.collection.createOpen",
911
+ "studio.collection.delete",
912
+ "studio.collection.editClose",
913
+ "studio.collection.editOpen",
914
+ "studio.collection.manage.close",
915
+ "studio.collection.manage.open",
916
+ "studio.collection.openForEdit",
917
+ "studio.collection.removeItinerary",
918
+ "studio.collection.removeZone",
919
+ "studio.collection.reorderItinerary",
920
+ "studio.collection.update",
921
+ "studio.share.close",
922
+ "studio.share.open"
923
+ ],
924
+ purpose: "Group itineraries and zones into a folder the whole organization shares.",
925
+ title: "Collections",
926
+ wideFallback: true
927
+ },
928
+ {
929
+ always: false,
930
+ id: "import",
931
+ keywords: ["import", "GPX", "upload", "from Strava", "from Garmin", "from a file", "importe", "importer", "t\xE9l\xE9verse", "t\xE9l\xE9verser", "depuis un fichier", "depuis strava", "depuis garmin"],
932
+ members: [
933
+ "studio.itinerary.import.clearDraft",
934
+ "studio.itinerary.import.confirm",
935
+ "studio.itinerary.import.discard",
936
+ "studio.itinerary.import.open",
937
+ "studio.itinerary.import.setActivity",
938
+ "studio.itinerary.import.setCollections",
939
+ "studio.itinerary.import.setGranularity",
940
+ "studio.itinerary.import.setName",
941
+ "studio.itinerary.import.setOrganization",
942
+ "studio.itinerary.import.setPrivate",
943
+ "studio.itinerary.import.setProvider",
944
+ "studio.itinerary.import.setSegmentModes",
945
+ "studio.itinerary.import.submitPreview",
946
+ "studio.itinerary.import.toggleMode"
947
+ ],
948
+ purpose: "Bring an external track into the studio and reconcile it before saving.",
949
+ title: "Import",
950
+ wideFallback: true
951
+ },
952
+ {
953
+ always: false,
954
+ id: "sharing",
955
+ keywords: ["export", "GPX", "download", "share", "link", "embed", "iframe", "exporte", "exporter", "t\xE9l\xE9charge", "t\xE9l\xE9charger", "partage", "partager", "lien", "int\xE9gration"],
956
+ members: [
957
+ "studio.embed.close",
958
+ "studio.embed.open",
959
+ "studio.itinerary.export",
960
+ "studio.itinerary.export.close",
961
+ "studio.itinerary.export.open",
962
+ "studio.share.close",
963
+ "studio.share.open"
964
+ ],
965
+ purpose: "Get an itinerary or a collection out of the studio, as a file, a link, or an embedded map.",
966
+ title: "Export, share, and embed",
967
+ wideFallback: true
968
+ },
969
+ {
970
+ always: false,
971
+ id: "streetview",
972
+ keywords: ["street view", "ground level", "what does it look like", "photo", "\xE0 quoi ressemble", "au niveau du sol", "vue immersive"],
973
+ members: [
974
+ "studio.streetview.close",
975
+ "studio.streetview.corridor.set",
976
+ "studio.streetview.coverage.set",
977
+ "studio.streetview.move",
978
+ "studio.streetview.open"
979
+ ],
980
+ purpose: "Inspect a location at ground level along a route corridor.",
981
+ title: "Street view",
982
+ wideFallback: true
983
+ },
984
+ {
985
+ always: false,
986
+ id: "video",
987
+ keywords: ["video", "flythrough", "shot", "orbit", "record", "export video", "vid\xE9o", "survol", "orbite", "filme", "filmer"],
988
+ members: [
989
+ "studio.video.cancel",
990
+ "studio.video.close",
991
+ "studio.video.download",
992
+ "studio.video.duration.set",
993
+ "studio.video.mode.set",
994
+ "studio.video.open",
995
+ "studio.video.orbit",
996
+ "studio.video.output.set",
997
+ "studio.video.plan.get",
998
+ "studio.video.preset.set",
999
+ "studio.video.preview.pause",
1000
+ "studio.video.preview.play",
1001
+ "studio.video.preview.seek",
1002
+ "studio.video.preview.start",
1003
+ "studio.video.preview.stop",
1004
+ "studio.video.profile.design.set",
1005
+ "studio.video.profile.language.set",
1006
+ "studio.video.profile.toggle",
1007
+ "studio.video.profile.units.set",
1008
+ "studio.video.record",
1009
+ "studio.video.route.set",
1010
+ "studio.video.shot.add",
1011
+ "studio.video.shot.addHold",
1012
+ "studio.video.shot.remove",
1013
+ "studio.video.shot.set",
1014
+ "studio.video.step.set"
1015
+ ],
1016
+ purpose: "Compose a flythrough video of a route. Owned by the Video Director, not the studio co-pilot.",
1017
+ title: "Video director",
1018
+ wideFallback: false
1019
+ },
1020
+ {
1021
+ always: false,
1022
+ id: "advanced",
1023
+ keywords: ["graphql", "data api", "raw query", "requ\xEAte brute"],
1024
+ members: [
1025
+ "data.query",
1026
+ "data.schema"
1027
+ ],
1028
+ purpose: "Escape hatch for geospatial questions no typed operation covers. Off by default: a typed operation is always the better answer when one exists.",
1029
+ title: "Raw Data API access",
1030
+ wideFallback: false
1031
+ }
1032
+ ];
1033
+ var SURFACE_LOCKS = [
1034
+ { equals: "segment", field: "editSession", surface: "routing" },
1035
+ { equals: "waypoint", field: "editSession", surface: "authoring" },
1036
+ { equals: true, field: "suggestDraft", surface: "discovery" },
1037
+ { equals: "zone", field: "editSession", surface: "zones" },
1038
+ { equals: "zone", field: "openResource", surface: "zones" },
1039
+ { equals: true, field: "importDraft", surface: "import" },
1040
+ { equals: true, field: "videoOpen", surface: "video" }
1041
+ ];
1042
+ var SKILL_ROUTES = [
1043
+ {
1044
+ id: "analyze-terrain-along-route",
1045
+ intents: [
1046
+ "how steep is this",
1047
+ "where does it get hard",
1048
+ "is this north facing",
1049
+ "what's the terrain like",
1050
+ "how exposed is this route",
1051
+ "how technical is this trail",
1052
+ "is this route hard underfoot",
1053
+ "c'est raide",
1054
+ "c'est technique",
1055
+ "o\xF9 \xE7a devient dur",
1056
+ "comment est le terrain",
1057
+ "est-ce expos\xE9",
1058
+ "orient\xE9 nord"
1059
+ ],
1060
+ surfaces: ["terrain"]
1061
+ },
1062
+ {
1063
+ id: "build-route-from-scratch",
1064
+ intents: [
1065
+ "plan a route from",
1066
+ "create a new route",
1067
+ "i want to go from the village to the hut",
1068
+ "make me a loop starting here",
1069
+ "planifie un itin\xE9raire",
1070
+ "cr\xE9e un itin\xE9raire",
1071
+ "fais-moi une boucle depuis",
1072
+ "du village au refuge"
1073
+ ],
1074
+ surfaces: ["authoring", "discovery", "routing"]
1075
+ },
1076
+ {
1077
+ id: "compare-alternative-routes",
1078
+ intents: [
1079
+ "which way is better",
1080
+ "compare these two",
1081
+ "worth going via",
1082
+ "what if i went the other way",
1083
+ "quel chemin est mieux",
1084
+ "compare ces deux",
1085
+ "\xE7a vaut le coup de passer par",
1086
+ "par l'autre c\xF4t\xE9"
1087
+ ],
1088
+ surfaces: ["routing", "terrain"]
1089
+ },
1090
+ {
1091
+ id: "create-reachability-zone",
1092
+ intents: [
1093
+ "how far can i get in 2 hours",
1094
+ "what's within an hour of the hut",
1095
+ "draw the reachable area from here",
1096
+ "mark everything within 5 km on foot",
1097
+ "jusqu'o\xF9 puis-je aller",
1098
+ "\xE0 moins d'une heure",
1099
+ "dessine la zone accessible",
1100
+ "accessible \xE0 pied"
1101
+ ],
1102
+ surfaces: ["discovery", "zones"]
1103
+ },
1104
+ {
1105
+ id: "create-zone-from-terrain-threshold",
1106
+ intents: [
1107
+ "mark everything steeper than",
1108
+ "highlight the north facing slopes",
1109
+ "show me the avalanche terrain here",
1110
+ "draw a zone over the steep part",
1111
+ "marque tout ce qui est plus raide",
1112
+ "les pentes orient\xE9es nord",
1113
+ "le terrain avalancheux",
1114
+ "dessine une zone sur les pentes"
1115
+ ],
1116
+ surfaces: ["terrain", "zones"]
1117
+ },
1118
+ {
1119
+ id: "export-and-share",
1120
+ intents: [
1121
+ "export this as gpx",
1122
+ "send this to my watch",
1123
+ "share this route",
1124
+ "share this collection",
1125
+ "give me a link",
1126
+ "embed this on my site",
1127
+ "exporte en gpx",
1128
+ "envoie sur ma montre",
1129
+ "partage cet itin\xE9raire",
1130
+ "partage cette collection",
1131
+ "donne-moi un lien",
1132
+ "int\xE8gre sur mon site"
1133
+ ],
1134
+ surfaces: ["sharing"]
1135
+ },
1136
+ {
1137
+ id: "find-and-add-waypoints",
1138
+ intents: [
1139
+ "are there huts on this route",
1140
+ "where can i park",
1141
+ "add a water stop",
1142
+ "mark the summit",
1143
+ "des refuges sur ce parcours",
1144
+ "o\xF9 me garer",
1145
+ "ajoute une \xE9tape",
1146
+ "marque le sommet",
1147
+ "un point d'eau"
1148
+ ],
1149
+ surfaces: ["discovery", "authoring"]
1150
+ },
1151
+ {
1152
+ id: "generate-route-suggestions",
1153
+ intents: [
1154
+ "suggest a route",
1155
+ "find me a 20 km loop",
1156
+ "something with 1000 m of climbing near here",
1157
+ "what can i do around",
1158
+ "sugg\xE8re un itin\xE9raire",
1159
+ "propose une boucle",
1160
+ "boucle de",
1161
+ "avec du d\xE9nivel\xE9 pr\xE8s de",
1162
+ "que faire autour de",
1163
+ "g\xE9n\xE8re des itin\xE9raires",
1164
+ "propose des itin\xE9raires",
1165
+ "itin\xE9raires de",
1166
+ "d\xE9nivel\xE9 positif",
1167
+ "point de d\xE9part"
1168
+ ],
1169
+ surfaces: ["discovery", "authoring"]
1170
+ },
1171
+ {
1172
+ id: "increase-route-ascent",
1173
+ intents: [
1174
+ "make it steeper",
1175
+ "more climbing",
1176
+ "meters of elevation gain",
1177
+ "metres of elevation gain",
1178
+ "harder version of this route",
1179
+ "i want more vertical",
1180
+ "plus raide",
1181
+ "plus de d\xE9nivel\xE9",
1182
+ "plus de mont\xE9e",
1183
+ "version plus dure",
1184
+ "ajoute du d\xE9nivel\xE9",
1185
+ "de d\xE9nivel\xE9 en plus"
1186
+ ],
1187
+ surfaces: ["terrain", "routing"]
1188
+ },
1189
+ {
1190
+ id: "modify-existing-segment",
1191
+ intents: [
1192
+ "reroute this",
1193
+ "avoid the",
1194
+ "go via",
1195
+ "make it shorter",
1196
+ "take the other side of the valley",
1197
+ "keep it off the road",
1198
+ "modifie le trac\xE9",
1199
+ "\xE9vite",
1200
+ "passe par",
1201
+ "plus court",
1202
+ "raccourcis",
1203
+ "int\xE8gre la boucle",
1204
+ "int\xE8gre cette boucle",
1205
+ "ajoute cette boucle"
1206
+ ],
1207
+ surfaces: ["routing", "discovery"]
1208
+ },
1209
+ {
1210
+ id: "prepare-map-for-editing",
1211
+ intents: [
1212
+ "let's work on this route",
1213
+ "open my route",
1214
+ "i want to edit this",
1215
+ "show me the whole thing",
1216
+ "travaillons sur",
1217
+ "ouvre mon itin\xE9raire",
1218
+ "je veux modifier",
1219
+ "montre-moi tout le parcours"
1220
+ ],
1221
+ surfaces: ["routing"]
1222
+ },
1223
+ {
1224
+ id: "visualize-terrain",
1225
+ intents: [
1226
+ "show me the steepness",
1227
+ "turn on hillshade",
1228
+ "can i see the snow depth",
1229
+ "display the aspect",
1230
+ "montre la pente",
1231
+ "affiche la pente",
1232
+ "active le calque",
1233
+ "montre le relief",
1234
+ "hauteur de neige"
1235
+ ],
1236
+ surfaces: ["terrain"]
1237
+ }
1238
+ ];
1239
+
1240
+ // src/agent/rules/studioRouter.ts
1241
+ var studioRouter = createStudioRouter({
1242
+ playbook: PLAYBOOK,
1243
+ skillRoutes: SKILL_ROUTES,
1244
+ surfaceLocks: SURFACE_LOCKS,
1245
+ surfaces: SURFACES
1246
+ });
1247
+ var recoveryFor = studioRouter.recoveryFor;
1248
+ var selectSurfaces = studioRouter.selectSurfaces;
1249
+ var surfaceTools = studioRouter.surfaceTools;
1250
+ var addendumFor = (addendum, tool, code) => {
1251
+ if (addendum === void 0) {
1252
+ return void 0;
1253
+ }
1254
+ let answered;
1255
+ try {
1256
+ answered = addendum(tool, code);
1257
+ } catch (fault) {
1258
+ chunkPACIO4NS_cjs.surfaceFault(fault);
1259
+ return void 0;
1260
+ }
1261
+ const sentence = typeof answered === "string" ? answered.trim() : "";
1262
+ return sentence === "" ? void 0 : sentence;
1263
+ };
1264
+ var studioRecoveryFor = (tool, code, addendum) => {
1265
+ if (code === void 0 || code === "") {
1266
+ return void 0;
1267
+ }
1268
+ const recovery = recoveryFor(tool, code);
1269
+ const extra = addendumFor(addendum, tool, code);
1270
+ if (recovery === void 0 || extra === void 0) {
1271
+ return recovery ?? extra;
1272
+ }
1273
+ return `${recovery} ${extra}`;
1274
+ };
1275
+ var transcriptObserver = (config) => {
1276
+ const { draftWarning, errorCopy, writer } = config;
1277
+ return {
1278
+ onChecksUnmet: writer.appendChecksUnmet,
1279
+ onError: (message, code) => writer.appendError(agent.resolveAgentError(message, code, errorCopy(), draftWarning?.())),
1280
+ onMessage: writer.setAssistantMessage,
1281
+ onMessageDelta: writer.appendAssistantDelta,
1282
+ onRunId: writer.setRunId,
1283
+ onStateChange: writer.setSessionState,
1284
+ onToolActivity: writer.setActiveTool,
1285
+ onToolCall: (name, input, toolCallId) => writer.appendToolActivity({ input: agent.boundedInputJson(input), name, toolCallId }),
1286
+ onToolResult: writer.settleToolActivity
1287
+ };
1288
+ };
1289
+ var WITHHELD_TAB_ID = "withheld";
1290
+ var idleThread = (runId) => ({
1291
+ pendingConfirmation: null,
1292
+ runId,
1293
+ state: "awaiting_input",
1294
+ transcript: []
1295
+ });
1296
+ var heldThread = (threads, threadId) => Object.hasOwn(threads, threadId) ? threads[threadId] : void 0;
1297
+ var updateThread = (threads, threadId, transform) => {
1298
+ const thread = heldThread(threads, threadId);
1299
+ if (!thread) {
1300
+ return threads;
1301
+ }
1302
+ return { ...threads, [threadId]: transform(thread) };
1303
+ };
1304
+ var initialState = {
1305
+ activeId: null,
1306
+ activeTabId: null,
1307
+ order: [],
1308
+ threads: {}
1309
+ };
1310
+ var createAgentThreadsStore = () => vanilla.createStore((set) => ({
1311
+ ...initialState,
1312
+ addCopilotTab: (threadId) => set((current) => {
1313
+ if (heldThread(current.threads, threadId)) {
1314
+ return current;
1315
+ }
1316
+ return {
1317
+ activeId: threadId,
1318
+ activeTabId: threadId,
1319
+ order: [...current.order, threadId],
1320
+ threads: { ...current.threads, [threadId]: idleThread(null) }
1321
+ };
1322
+ }),
1323
+ answerQuestion: (threadId, entryId, label) => set((current) => ({
1324
+ threads: updateThread(current.threads, threadId, (thread) => ({
1325
+ ...thread,
1326
+ // The shared helper never re-settles: a double click races the send,
1327
+ // and the first answer is the one that was sent.
1328
+ transcript: agent.answerQuestionEntry(thread.transcript, entryId, label)
1329
+ }))
1330
+ })),
1331
+ appendAssistantDelta: (threadId, delta) => set((current) => ({
1332
+ threads: updateThread(current.threads, threadId, (thread) => ({
1333
+ ...thread,
1334
+ transcript: agent.accumulateAssistant(thread.transcript, delta)
1335
+ }))
1336
+ })),
1337
+ appendChecksUnmet: (threadId, unmet) => set((current) => ({
1338
+ threads: updateThread(current.threads, threadId, (thread) => ({
1339
+ ...thread,
1340
+ // A warning, not an error: the run answered and is still healthy, but
1341
+ // the workspace does not back part of what the answer claims. The
1342
+ // shared helper drops an empty list, so a stray empty event renders
1343
+ // nothing rather than an empty orange box.
1344
+ transcript: agent.appendWarningEntry(thread.transcript, unmet)
1345
+ }))
1346
+ })),
1347
+ appendError: (threadId, message) => set((current) => ({
1348
+ threads: updateThread(current.threads, threadId, (thread) => ({
1349
+ ...thread,
1350
+ // The failure is a turn in the conversation, not a transient banner:
1351
+ // appended as its own error entry so it renders in the assistant's lane
1352
+ // and survives in the history as the reply to the turn that failed.
1353
+ transcript: agent.appendErrorEntry(thread.transcript, message)
1354
+ }))
1355
+ })),
1356
+ appendQuestion: (threadId, question) => set((current) => ({
1357
+ threads: updateThread(current.threads, threadId, (thread) => ({
1358
+ ...thread,
1359
+ // The shared helper is idempotent by call id, so a replayed frame
1360
+ // emitting the same asking call twice appends no duplicate card.
1361
+ transcript: agent.appendQuestionEntry(thread.transcript, question)
1362
+ }))
1363
+ })),
1364
+ appendSuggestions: (threadId, suggestions) => set((current) => ({
1365
+ threads: updateThread(current.threads, threadId, (thread) => ({
1366
+ ...thread,
1367
+ // The shared helper is idempotent by entry id (a replayed settle
1368
+ // appends no duplicate card), drops an empty batch, and settles any
1369
+ // prior open batch, whose candidates a regenerate replaced.
1370
+ transcript: agent.appendSuggestionsEntry(thread.transcript, suggestions)
1371
+ }))
1372
+ })),
1373
+ appendToolActivity: (threadId, activity) => set((current) => ({
1374
+ threads: updateThread(current.threads, threadId, (thread) => ({
1375
+ ...thread,
1376
+ // The shared helper is idempotent by call id, so a re-render or a
1377
+ // replayed frame emitting the same call twice appends no duplicate row.
1378
+ transcript: agent.appendActivityEntry(thread.transcript, activity)
1379
+ }))
1380
+ })),
1381
+ appendUserMessage: (threadId, content) => set((current) => ({
1382
+ threads: updateThread(current.threads, threadId, (thread) => ({
1383
+ ...thread,
1384
+ // Any user message settles the open question AND suggestions cards
1385
+ // first: whether the user tapped an option/row (already settled, a
1386
+ // no-op here) or typed their own words, the reply supersedes the
1387
+ // buttons and they go inert.
1388
+ transcript: agent.appendUserEntry(
1389
+ agent.settleOpenSuggestionEntries(agent.settleOpenQuestionEntries(thread.transcript)),
1390
+ content
1391
+ )
1392
+ }))
1393
+ })),
1394
+ chooseSuggestion: (threadId, entryId, seed) => set((current) => ({
1395
+ threads: updateThread(current.threads, threadId, (thread) => ({
1396
+ ...thread,
1397
+ // The shared helper never re-settles: a double click races the staging
1398
+ // chain, and the first pick is the one that ran.
1399
+ transcript: agent.chooseSuggestionEntry(thread.transcript, entryId, seed)
1400
+ }))
1401
+ })),
1402
+ clearPendingConfirmation: (threadId) => set((current) => ({
1403
+ threads: updateThread(current.threads, threadId, (thread) => ({
1404
+ ...thread,
1405
+ pendingConfirmation: null
1406
+ }))
1407
+ })),
1408
+ closeCopilotTab: (threadId) => set((current) => {
1409
+ if (threadId === chunkNCLA6DKD_cjs.SEARCH_TAB_ID || threadId === WITHHELD_TAB_ID) {
1410
+ return current;
1411
+ }
1412
+ const order = current.order.filter((id) => id !== threadId);
1413
+ const { [threadId]: _closed, ...threads } = current.threads;
1414
+ const activeId = current.activeId === threadId ? order.at(-1) ?? null : current.activeId;
1415
+ const activeTabId = current.activeTabId === threadId ? activeId ?? chunkNCLA6DKD_cjs.SEARCH_TAB_ID : current.activeTabId;
1416
+ return { activeId, activeTabId, order, threads };
1417
+ }),
1418
+ closeThread: (threadId) => set((current) => {
1419
+ const order = current.order.filter((id) => id !== threadId);
1420
+ const { [threadId]: _closed, ...threads } = current.threads;
1421
+ const activeId = current.activeId === threadId ? order.at(-1) ?? null : current.activeId;
1422
+ const activeTabId = current.activeTabId === threadId ? activeId ?? chunkNCLA6DKD_cjs.SEARCH_TAB_ID : current.activeTabId;
1423
+ return { activeId, activeTabId, order, threads };
1424
+ }),
1425
+ createThread: (threadId, runId = null) => set((current) => {
1426
+ if (heldThread(current.threads, threadId)) {
1427
+ return current;
1428
+ }
1429
+ return {
1430
+ activeId: threadId,
1431
+ order: [...current.order, threadId],
1432
+ threads: { ...current.threads, [threadId]: idleThread(runId) }
1433
+ };
1434
+ }),
1435
+ setActive: (threadId) => set((current) => heldThread(current.threads, threadId) ? { activeId: threadId } : current),
1436
+ setActiveTab: (tabId) => set((current) => {
1437
+ if (tabId === chunkNCLA6DKD_cjs.SEARCH_TAB_ID) {
1438
+ return { activeTabId: chunkNCLA6DKD_cjs.SEARCH_TAB_ID };
1439
+ }
1440
+ if (tabId === WITHHELD_TAB_ID) {
1441
+ return { activeTabId: WITHHELD_TAB_ID };
1442
+ }
1443
+ if (!heldThread(current.threads, tabId)) {
1444
+ return current;
1445
+ }
1446
+ return { activeId: tabId, activeTabId: tabId };
1447
+ }),
1448
+ // The run's own index rides onto the settled turn, so a rating on it names the
1449
+ // message the backend will see rather than the position it happens to occupy in
1450
+ // this browser's transcript, which a reload mid-run resets to zero.
1451
+ setAssistantMessage: (threadId, content, messageIndex) => set((current) => ({
1452
+ threads: updateThread(current.threads, threadId, (thread) => ({
1453
+ ...thread,
1454
+ transcript: agent.replaceAssistant(thread.transcript, content, messageIndex)
1455
+ }))
1456
+ })),
1457
+ setPendingConfirmation: (threadId, confirmation) => set((current) => ({
1458
+ threads: updateThread(current.threads, threadId, (thread) => ({
1459
+ ...thread,
1460
+ pendingConfirmation: confirmation
1461
+ }))
1462
+ })),
1463
+ setRunId: (threadId, runId) => set((current) => ({
1464
+ threads: updateThread(current.threads, threadId, (thread) => ({ ...thread, runId }))
1465
+ })),
1466
+ setSessionState: (threadId, state) => set((current) => ({
1467
+ threads: updateThread(current.threads, threadId, (thread) => ({ ...thread, state }))
1468
+ })),
1469
+ settleToolActivity: (threadId, toolCallId, outcome) => set((current) => ({
1470
+ threads: updateThread(current.threads, threadId, (thread) => ({
1471
+ ...thread,
1472
+ // The shared helper settles the latest running row for the id, appends
1473
+ // an already-settled row for a server tool the host saw no call for,
1474
+ // and never re-settles a terminal row.
1475
+ transcript: agent.settleActivityEntry(thread.transcript, toolCallId, outcome)
1476
+ }))
1477
+ }))
1478
+ }));
1479
+ var selectAgentDriving = (state) => state.order.some((id) => state.threads[id]?.state === "running");
1480
+
1481
+ // src/agent/engines/agentThreads.ts
1482
+ var QUESTION_TOOL = "studio.question.ask";
1483
+ var GENERATE_TOOL = "studio.itinerary.suggest.generate";
1484
+ var ACCESS_REVOKED = "access-revoked";
1485
+ var holdRejection = (dispatched) => {
1486
+ Promise.resolve(dispatched).then(void 0, () => void 0);
1487
+ };
1488
+ var isOutcome = (answered) => typeof answered === "object" && answered !== null && "ok" in answered && typeof answered.ok === "boolean";
1489
+ var restorableThreads = (named) => {
1490
+ const kept = /* @__PURE__ */ new Map();
1491
+ const entries = Array.isArray(named) ? named : [];
1492
+ for (const entry of entries) {
1493
+ if (kept.size >= chunkNCLA6DKD_cjs.MAX_OPEN_COPILOT_TABS) {
1494
+ break;
1495
+ }
1496
+ if (typeof entry !== "object" || entry === null) {
1497
+ continue;
1498
+ }
1499
+ const id = "id" in entry ? entry.id : void 0;
1500
+ const runId = "runId" in entry ? entry.runId : void 0;
1501
+ if (typeof id !== "string" || id === "" || id === chunkNCLA6DKD_cjs.SEARCH_TAB_ID || id === WITHHELD_TAB_ID || kept.has(id)) {
1502
+ continue;
1503
+ }
1504
+ kept.set(id, { id, runId: typeof runId === "string" && runId !== "" ? runId : null });
1505
+ }
1506
+ return [...kept.values()];
1507
+ };
1508
+ var AgentThreadsEngine = class {
1509
+ config;
1510
+ ids;
1511
+ store;
1512
+ tabs;
1513
+ subscriptions = /* @__PURE__ */ new Set();
1514
+ /** The store subscription the listeners are notified through, while the engine runs. */
1515
+ releaseStore = null;
1516
+ /** The UI store the driving flag is mirrored into, while the engine runs. */
1517
+ mirrored = null;
1518
+ /**
1519
+ * What the URL named at construction, kept while the viewer the seed read is withheld the
1520
+ * co-pilot and restored for that viewer once entitled. Null for a seed that read an entitled
1521
+ * viewer, and once restored.
1522
+ */
1523
+ unrestored = null;
1524
+ /** The viewer seam the engine hears a change of the entitlement from, while it runs. */
1525
+ heard = null;
1526
+ /** One host per thread: its session and its started guard. */
1527
+ hosts = /* @__PURE__ */ new Map();
1528
+ /** The resolver of each thread's parked confirmation. */
1529
+ confirmations = /* @__PURE__ */ new Map();
1530
+ /** The surfaces each thread's run is routed to; a thread with none offers every tool. */
1531
+ surfaces = /* @__PURE__ */ new Map();
1532
+ /** The last message each thread routed on, replayed by a re-route from state. */
1533
+ lastRouted = /* @__PURE__ */ new Map();
1534
+ /** The generate call that owns the workspace's one suggest session, and its thread. */
1535
+ suggestBatchOwner = null;
1536
+ /** The suggestions cards whose pick is still applying, by entry id. */
1537
+ stagingPicks = /* @__PURE__ */ new Set();
1538
+ /**
1539
+ * The threads whose last message is out and whose turn the session has not picked up. While
1540
+ * a thread is here, its session's `awaiting_input` is the run being readied and never the
1541
+ * turn settling.
1542
+ */
1543
+ awaitingTurn = /* @__PURE__ */ new Set();
1544
+ /**
1545
+ * The state each thread's session last reported, and no entry for one that has reported none,
1546
+ * which reads `awaiting_input`. It says whether a message is sent into a turn under way, which
1547
+ * the session answers with no report of `running`.
1548
+ */
1549
+ sessionStates = /* @__PURE__ */ new Map();
1550
+ /** Whether nobody is watching. A parked engine opens nothing and answers no command. */
1551
+ parked = true;
1552
+ disposed = false;
1553
+ /**
1554
+ * The tab strip the studio's tab verbs mutate through. Every member but the two reads,
1555
+ * `countOpen` and `hasTab`, does nothing while the engine is parked, and an opening member
1556
+ * then answers the tab already shown.
1557
+ */
1558
+ tabSurface = {
1559
+ addCopilotTab: () => this.live() ? this.openTab() : this.shownTab(),
1560
+ closeCopilotTab: (tabId) => {
1561
+ if (this.live()) {
1562
+ this.closeTab(tabId);
1563
+ }
1564
+ },
1565
+ // The Search and withheld pseudo-tabs are not in `order`, so its length is exactly the
1566
+ // number of conversations the create gate compares against the limit.
1567
+ countOpen: () => this.store.getState().order.length,
1568
+ // The strip holds Search, each open conversation and, for a viewer withheld the co-pilot,
1569
+ // the withheld tab, and no other id.
1570
+ hasTab: (tabId) => tabId === chunkNCLA6DKD_cjs.SEARCH_TAB_ID || tabId === WITHHELD_TAB_ID && this.withheld() || this.store.getState().order.includes(tabId),
1571
+ openCopilot: () => this.live() ? this.openOrReveal() : this.shownTab(),
1572
+ reset: () => {
1573
+ if (this.live()) {
1574
+ this.resetThreads();
1575
+ }
1576
+ },
1577
+ setActiveTab: (tabId) => {
1578
+ if (this.live()) {
1579
+ this.showTab(tabId);
1580
+ }
1581
+ }
1582
+ };
1583
+ /**
1584
+ * Constructing one seeds the store and does nothing else: it reads the URL seam once and the
1585
+ * viewer's entitlement as it stands, builds no host, opens no run and writes no URL. A React
1586
+ * binding constructs during a render React is free to throw away, and a constructor with a side
1587
+ * effect outside its own store would leave the discarded copy acting.
1588
+ */
1589
+ constructor(options) {
1590
+ const { ids, store, tabs, ...config } = options;
1591
+ this.config = config;
1592
+ this.ids = ids;
1593
+ this.tabs = tabs;
1594
+ this.store = store ?? createAgentThreadsStore();
1595
+ this.seed(config.threadsUrl?.readOnce() ?? {});
1596
+ }
1597
+ /** getSnapshot returns the conversations' state, by reference and stable between changes. */
1598
+ getSnapshot() {
1599
+ return this.store.getState();
1600
+ }
1601
+ /**
1602
+ * subscribe registers a listener for every change of the snapshot, and returns its own
1603
+ * unsubscribe, which is idempotent.
1604
+ *
1605
+ * The first listener resumes the engine and the last one leaving parks it, which is the whole
1606
+ * lifecycle a component can express correctly: React tears an effect down and sets it up
1607
+ * again with the same object under StrictMode, so a latch here would leave a live surface
1608
+ * bound to a dead engine. Each call is its own subscription, so two owners subscribing one
1609
+ * shared function each hold the engine until they release it.
1610
+ */
1611
+ subscribe(listener) {
1612
+ if (this.disposed) {
1613
+ return () => {
1614
+ };
1615
+ }
1616
+ const subscription = { listener };
1617
+ this.subscriptions.add(subscription);
1618
+ if (this.parked) {
1619
+ this.resume();
1620
+ }
1621
+ return () => {
1622
+ if (!this.subscriptions.delete(subscription) || this.subscriptions.size > 0) {
1623
+ return;
1624
+ }
1625
+ if (!this.parked) {
1626
+ this.park();
1627
+ }
1628
+ };
1629
+ }
1630
+ /**
1631
+ * configure replaces the configuration. Nothing is asked and no session is rebuilt: every
1632
+ * member is read when it is used, so a binding may call this on every render and an unchanged
1633
+ * configuration costs an assignment. Two things move with the context: the driving flag's
1634
+ * mirror, when it carries a different UI store (the store it leaves is reset, and the new one is
1635
+ * brought in line with the conversations), and the subscription to the viewer, when it carries
1636
+ * a different viewer.
1637
+ */
1638
+ configure(config) {
1639
+ this.config = config;
1640
+ if (this.mirrored !== null && this.mirrored !== config.context.ui) {
1641
+ this.releaseMirror();
1642
+ this.mirrorInto(config.context.ui);
1643
+ }
1644
+ if (this.heard !== null && this.heard.viewer !== config.context.viewer) {
1645
+ this.hearViewer(config.context.viewer);
1646
+ this.restoreForEntitled();
1647
+ }
1648
+ }
1649
+ /**
1650
+ * dispose parks the engine and drops every listener, for good.
1651
+ *
1652
+ * Idempotent, and every call after it is a no-op rather than an error, a subscription
1653
+ * included: an owner torn down mid-run should not have to guard the calls it already queued.
1654
+ */
1655
+ dispose() {
1656
+ if (this.disposed) {
1657
+ return;
1658
+ }
1659
+ if (!this.parked) {
1660
+ this.park();
1661
+ }
1662
+ this.disposed = true;
1663
+ this.subscriptions.clear();
1664
+ }
1665
+ /**
1666
+ * answerQuestion settles the active conversation's question card with the picked option, then
1667
+ * sends its label as the next message. Settling first is what makes the send's sweep of open
1668
+ * cards leave the pick marked.
1669
+ *
1670
+ * It does nothing unless `entryId` names a question card of the conversation that is still
1671
+ * open: a second answer to one card, and an answer to a card a typed reply already settled,
1672
+ * send no message, since the run is waiting on neither.
1673
+ */
1674
+ answerQuestion(entryId, label) {
1675
+ const threadId = this.activeThread();
1676
+ if (threadId === null || !this.hasOpenQuestion(threadId, entryId)) {
1677
+ return;
1678
+ }
1679
+ this.store.getState().answerQuestion(threadId, entryId, label);
1680
+ this.send(threadId, label);
1681
+ }
1682
+ /**
1683
+ * chooseSuggestion applies one suggested route from a suggestions card, settles the card, and
1684
+ * sends the pick's label as the next message.
1685
+ *
1686
+ * The pick is applied client-side through `studio.itinerary.suggest.applyCandidate`, which
1687
+ * reshapes the segment the batch was generated for or appends the route as a new one, so the
1688
+ * route is on the map before the model reads the reply. It applies to the open itinerary and
1689
+ * never creates one. A second pick on a card whose apply is still out does nothing, since two
1690
+ * appends would put the route in the itinerary twice. A failed apply leaves the card open and
1691
+ * writes the staging error, so the user can pick again; an apply a host's bus rejects, or
1692
+ * answers with no result, is a failed one. A pick whose confirmation was withheld (the user
1693
+ * kept a staged draft the apply would drop, or left the prompt to expire) leaves the card open
1694
+ * and writes nothing. A pick whose apply lands after the engine parked, or after its
1695
+ * conversation closed, writes nothing and opens no run.
1696
+ */
1697
+ chooseSuggestion(entryId, seed, label) {
1698
+ const threadId = this.activeThread();
1699
+ if (threadId === null || this.stagingPicks.has(entryId)) {
1700
+ return;
1701
+ }
1702
+ this.stagingPicks.add(entryId);
1703
+ void this.applyPick(threadId, entryId, seed, label);
1704
+ }
1705
+ /** closeAiTab closes one conversation through `studio.tabs.close`. */
1706
+ closeAiTab(tabId) {
1707
+ if (this.live()) {
1708
+ holdRejection(this.config.bus.dispatch(this.tabsContext(), "studio.tabs.close", { tabId }));
1709
+ }
1710
+ }
1711
+ /** newAiTab opens a conversation through `studio.tabs.create`. */
1712
+ newAiTab() {
1713
+ if (this.live()) {
1714
+ holdRejection(
1715
+ this.config.bus.dispatch(this.tabsContext(), "studio.tabs.create", {
1716
+ kind: "copilot"
1717
+ })
1718
+ );
1719
+ }
1720
+ }
1721
+ /**
1722
+ * previewCandidate paints one staged suggestion on the map through
1723
+ * `studio.itinerary.suggest.select`, the call the suggestions panel's own rows make, so
1724
+ * hovering a card option and hovering a panel row cannot diverge.
1725
+ */
1726
+ previewCandidate(seed) {
1727
+ if (this.live()) {
1728
+ holdRejection(
1729
+ this.config.bus.dispatch(this.config.context, "studio.itinerary.suggest.select", {
1730
+ seed
1731
+ })
1732
+ );
1733
+ }
1734
+ }
1735
+ /**
1736
+ * resolveConfirmation settles the active conversation's confirmation card with the user's
1737
+ * decision and clears the card. With nothing pending (a stale click after a stop already
1738
+ * settled it) it does nothing.
1739
+ */
1740
+ resolveConfirmation(approved) {
1741
+ const threadId = this.activeThread();
1742
+ if (threadId === null) {
1743
+ return;
1744
+ }
1745
+ const resolve = this.confirmations.get(threadId);
1746
+ if (resolve === void 0) {
1747
+ return;
1748
+ }
1749
+ this.confirmations.delete(threadId);
1750
+ this.store.getState().clearPendingConfirmation(threadId);
1751
+ resolve(approved);
1752
+ }
1753
+ /**
1754
+ * stopActive ends the active conversation's run: it denies a pending confirmation, asks the
1755
+ * gateway to close the run (a run the session gave up reading included), swaps a fresh session
1756
+ * in under the same thread so the next message opens a clean run, drops the run id and parks
1757
+ * the thread on `awaiting_input`. The close is what stops the run spending model budget: a
1758
+ * session torn down without it leaves the run going until the gateway's own timeout. The
1759
+ * transcript stays, since a stop is the user's choice rather than a failure.
1760
+ */
1761
+ stopActive() {
1762
+ const threadId = this.activeThread();
1763
+ if (threadId === null) {
1764
+ return;
1765
+ }
1766
+ this.denyPendingConfirmation(threadId);
1767
+ this.ensureHost(threadId).restart();
1768
+ this.store.getState().setRunId(threadId, null);
1769
+ this.settle(threadId);
1770
+ this.syncUrl();
1771
+ }
1772
+ /**
1773
+ * submit sends a message into the active conversation: the first one opens a run scoped to
1774
+ * the organization of the resource the co-pilot is open on, with the studio snapshot as its
1775
+ * context, and a later one is delivered into the open run.
1776
+ *
1777
+ * The conversation reads `running` from the submit, so the workspace locks and a surface
1778
+ * offers its Stop before the run's context is captured and its start is made. It returns to
1779
+ * `awaiting_input` when the turn settles, and at once when there is no organization to scope
1780
+ * a run to or the gateway refuses the start.
1781
+ */
1782
+ submit(message) {
1783
+ const threadId = this.activeThread();
1784
+ if (threadId !== null) {
1785
+ this.send(threadId, message);
1786
+ }
1787
+ }
1788
+ /** switchTab shows another tab, a conversation or a pseudo-tab, through `studio.tabs.switch`. */
1789
+ switchTab(tabId) {
1790
+ if (this.live()) {
1791
+ holdRejection(this.config.bus.dispatch(this.tabsContext(), "studio.tabs.switch", { tabId }));
1792
+ }
1793
+ }
1794
+ /**
1795
+ * live reports whether something watches the engine, which is when it acts. Every command asks
1796
+ * it first, so a live engine restores the URL's conversations for a viewer entitled since the
1797
+ * seed (see {@link restoreForEntitled}) ahead of the act: a host whose viewer tells no change
1798
+ * still meets them there.
1799
+ */
1800
+ live() {
1801
+ if (this.parked || this.disposed) {
1802
+ return false;
1803
+ }
1804
+ this.restoreForEntitled();
1805
+ return true;
1806
+ }
1807
+ /**
1808
+ * isOpen reports whether an answer for a conversation still has somewhere to land: the engine
1809
+ * is live and the conversation has not closed. An answer that arrives after either belongs to
1810
+ * nobody.
1811
+ */
1812
+ isOpen(threadId) {
1813
+ return this.live() && this.store.getState().threads[threadId] !== void 0;
1814
+ }
1815
+ /** activeThread is the conversation a command acts on, or null while the engine is not live. */
1816
+ activeThread() {
1817
+ return this.live() ? this.store.getState().activeId : null;
1818
+ }
1819
+ /** shownTab is the tab the strip shows, what an opening tab verb answers while parked. */
1820
+ shownTab() {
1821
+ return this.store.getState().activeTabId ?? chunkNCLA6DKD_cjs.SEARCH_TAB_ID;
1822
+ }
1823
+ /**
1824
+ * withheld reads whether the viewer is withheld the co-pilot, from the viewer seam as it
1825
+ * answers now. A membership resolves after a host has mounted and an entitlement can lapse
1826
+ * mid-session, so the answer is never held: each decision that turns on it asks again.
1827
+ */
1828
+ withheld() {
1829
+ return !this.config.context.viewer.hasEntitlement("copilot");
1830
+ }
1831
+ /**
1832
+ * seed writes the conversations a mount opens with, from the URL and the entitlement.
1833
+ *
1834
+ * A viewer withheld the co-pilot is restored none, whatever the URL names: their one way into
1835
+ * the co-pilot is the withheld tab. What the URL named is kept for them, and
1836
+ * {@link restoreForEntitled} restores it once they are entitled.
1837
+ */
1838
+ seed(mirrored) {
1839
+ if (this.withheld()) {
1840
+ this.unrestored = mirrored;
1841
+ this.store.getState().setActiveTab(
1842
+ mirrored.activeThreadId === WITHHELD_TAB_ID ? WITHHELD_TAB_ID : chunkNCLA6DKD_cjs.SEARCH_TAB_ID
1843
+ );
1844
+ return;
1845
+ }
1846
+ this.restore(mirrored);
1847
+ }
1848
+ /**
1849
+ * restore writes the conversations of an entitled viewer, from what the URL names, and answers
1850
+ * the ids it created.
1851
+ *
1852
+ * The URL's list passes through {@link restorableThreads} first, and a conversation already
1853
+ * open keeps its place. With none to restore, a viewer holding no conversation is opened a
1854
+ * fresh one, and the panel lands on Search. Otherwise it lands on the tab the URL names when
1855
+ * that tab is now open, and on Search when it is not: the withheld tab is never an entitled
1856
+ * viewer's.
1857
+ */
1858
+ restore(mirrored) {
1859
+ const state = this.store.getState();
1860
+ const named = restorableThreads(mirrored.threads).filter(
1861
+ ({ id }) => !Object.hasOwn(state.threads, id)
1862
+ );
1863
+ const initial = mirrored.activeThreadId;
1864
+ if (named.length === 0) {
1865
+ const created = state.order.length === 0 ? [this.ids.next()] : [];
1866
+ for (const id of created) {
1867
+ state.createThread(id);
1868
+ }
1869
+ state.setActiveTab(chunkNCLA6DKD_cjs.SEARCH_TAB_ID);
1870
+ return created;
1871
+ }
1872
+ for (const { id, runId } of named) {
1873
+ state.createThread(id, runId);
1874
+ }
1875
+ const open = this.store.getState().order;
1876
+ state.setActiveTab(
1877
+ initial !== void 0 && (initial === chunkNCLA6DKD_cjs.SEARCH_TAB_ID || open.includes(initial)) ? initial : chunkNCLA6DKD_cjs.SEARCH_TAB_ID
1878
+ );
1879
+ return named.map(({ id }) => id);
1880
+ }
1881
+ /**
1882
+ * restoreForEntitled restores what the URL named at construction for a viewer the seed read as
1883
+ * withheld and the viewer seam now answers as entitled. It runs once: a viewer who loses the
1884
+ * entitlement afterwards and regains it is not restored a second time. A live engine connects
1885
+ * each conversation it restores, so one carrying a run id reconnects to its run; a parked one
1886
+ * leaves that to the next resume. The URL is written with what the restore holds: a withheld
1887
+ * viewer's reveal may have mirrored the withheld tab over the conversations it named.
1888
+ */
1889
+ restoreForEntitled() {
1890
+ const mirrored = this.unrestored;
1891
+ if (mirrored === null || this.withheld()) {
1892
+ return;
1893
+ }
1894
+ this.unrestored = null;
1895
+ const created = this.restore(mirrored);
1896
+ this.syncUrl();
1897
+ if (!this.parked && !this.disposed) {
1898
+ for (const id of created) {
1899
+ this.connect(id);
1900
+ }
1901
+ }
1902
+ }
1903
+ /**
1904
+ * hearViewer subscribes to a viewer seam's changes, releasing the one heard before, so a
1905
+ * viewer entitled while the engine runs is restored the URL's conversations as the seam tells.
1906
+ */
1907
+ hearViewer(viewer) {
1908
+ this.heard?.release();
1909
+ this.heard = null;
1910
+ let release = () => void 0;
1911
+ this.tellSeam(() => {
1912
+ release = viewer.subscribe(() => this.restoreForEntitled());
1913
+ });
1914
+ this.heard = { release, viewer };
1915
+ }
1916
+ /**
1917
+ * connect builds a thread's host and resumes its session, reconnecting to the run the thread
1918
+ * carries. A resume that faults drops the stale run id, mirrors the drop and leaves the
1919
+ * conversation usable, through the thread's faults, which also tell the host a reconnect
1920
+ * refused 401.
1921
+ */
1922
+ connect(threadId) {
1923
+ this.ensureHost(threadId).resume(
1924
+ this.store.getState().threads[threadId]?.runId ?? null,
1925
+ (error) => this.faultsFor(threadId).resumeFailed(error)
1926
+ );
1927
+ }
1928
+ /** resume starts the engine for its first subscriber. */
1929
+ resume() {
1930
+ this.restoreForEntitled();
1931
+ this.parked = false;
1932
+ this.releaseStore = this.store.subscribe((state) => {
1933
+ this.syncDriving(state);
1934
+ chunkPACIO4NS_cjs.notifyListeners(Array.from(this.subscriptions, ({ listener }) => listener));
1935
+ });
1936
+ this.mirrorInto(this.config.context.ui);
1937
+ for (const id of [...this.store.getState().order]) {
1938
+ this.connect(id);
1939
+ }
1940
+ this.hearViewer(this.config.context.viewer);
1941
+ this.tellSeam(() => this.tabs?.register(this.tabSurface));
1942
+ }
1943
+ /** park stops the engine when its last subscriber leaves. */
1944
+ park() {
1945
+ this.parked = true;
1946
+ this.releaseStore?.();
1947
+ this.releaseStore = null;
1948
+ for (const host of this.hosts.values()) {
1949
+ host.dispose();
1950
+ }
1951
+ this.awaitingTurn.clear();
1952
+ this.sessionStates.clear();
1953
+ this.settleStreamingThreads();
1954
+ for (const threadId of [...this.confirmations.keys()]) {
1955
+ this.denyPendingConfirmation(threadId);
1956
+ }
1957
+ this.releaseMirror();
1958
+ const heard = this.heard;
1959
+ this.heard = null;
1960
+ if (heard !== null) {
1961
+ this.tellSeam(heard.release);
1962
+ }
1963
+ this.tellSeam(() => this.tabs?.unregister());
1964
+ }
1965
+ /**
1966
+ * tellSeam calls one of the host's seams the engine writes to on its own paths: the URL
1967
+ * mirror and the tab strip's slot. A seam that throws stops neither the resume, the park nor
1968
+ * the command that reached it, and its fault is surfaced apart, as a listener's is.
1969
+ */
1970
+ tellSeam(tell) {
1971
+ try {
1972
+ tell();
1973
+ } catch (fault) {
1974
+ chunkPACIO4NS_cjs.surfaceFault(fault);
1975
+ }
1976
+ }
1977
+ /**
1978
+ * send hands a message to a thread's host, with the conversation on `running` from this
1979
+ * moment: the workspace is the model's from the submit, across the capture of the run's
1980
+ * context, its start and the opening of its stream.
1981
+ *
1982
+ * Written before the host is called, so a submit the host answers at once (no organization
1983
+ * to scope a run to) returns the conversation to `awaiting_input` through its fault.
1984
+ */
1985
+ send(threadId, message) {
1986
+ if (this.sessionStates.get(threadId) !== "running") {
1987
+ this.awaitingTurn.add(threadId);
1988
+ }
1989
+ this.writeSessionState(threadId, "running");
1990
+ this.ensureHost(threadId).submit(message);
1991
+ }
1992
+ /**
1993
+ * settle returns a conversation to `awaiting_input`: its turn settled, its run faulted or was
1994
+ * stopped. It ends the wait for a turn, so the next report of its session is read as it is.
1995
+ */
1996
+ settle(threadId) {
1997
+ this.awaitingTurn.delete(threadId);
1998
+ this.writeSessionState(threadId, "awaiting_input");
1999
+ }
2000
+ /**
2001
+ * reportSessionState writes the lifecycle state a thread's session reports, while the engine
2002
+ * is live.
2003
+ *
2004
+ * A session reports `ended` as it is disposed, and the park disposes every one of them. The
2005
+ * park ends no conversation, so what its teardown reports is not written: a conversation that
2006
+ * never ran keeps reading `awaiting_input`, and a host reading the store sees no state the
2007
+ * park passed through.
2008
+ *
2009
+ * While a thread waits on its turn, its session's `awaiting_input` is not written either: a
2010
+ * session that read a run before reports it as it readies the next one, which would lower the
2011
+ * lock between the submit and the turn. The wait ends when the session reports `running`,
2012
+ * which it does from the message it takes, and its reports are the conversation's from
2013
+ * there: the turn's settle is one of them, whether or not the turn carried a frame of its own.
2014
+ */
2015
+ reportSessionState(threadId, state) {
2016
+ this.sessionStates.set(threadId, state);
2017
+ if (!this.live() || state === "awaiting_input" && this.awaitingTurn.has(threadId)) {
2018
+ return;
2019
+ }
2020
+ this.awaitingTurn.delete(threadId);
2021
+ this.writeSessionState(threadId, state);
2022
+ }
2023
+ /** writeSessionState writes a thread's state when it differs from the one it reads. */
2024
+ writeSessionState(threadId, state) {
2025
+ const thread = this.store.getState().threads[threadId];
2026
+ if (thread !== void 0 && thread.state !== state) {
2027
+ this.store.getState().setSessionState(threadId, state);
2028
+ }
2029
+ }
2030
+ /** hasOpenQuestion reports whether `entryId` is a question card the thread has not settled. */
2031
+ hasOpenQuestion(threadId, entryId) {
2032
+ return this.store.getState().threads[threadId]?.transcript.some(
2033
+ (entry) => entry.role === "question" && entry.id === entryId && !entry.settled
2034
+ ) ?? false;
2035
+ }
2036
+ /**
2037
+ * settleStreamingThreads returns every conversation that reads `running` to `awaiting_input`
2038
+ * once the park has disposed its session.
2039
+ *
2040
+ * No session streams the turn any more, and the session the next resume builds starts on
2041
+ * `awaiting_input` and reports a change only. A conversation left on `running` would raise
2042
+ * the driving lock at that resume with nothing to lower it. Its run id stays, so the resume
2043
+ * reconnects the run and the turn's frames report `running` again.
2044
+ */
2045
+ settleStreamingThreads() {
2046
+ const { order, threads } = this.store.getState();
2047
+ for (const id of order) {
2048
+ if (threads[id]?.state === "running") {
2049
+ this.store.getState().setSessionState(id, "awaiting_input");
2050
+ }
2051
+ }
2052
+ }
2053
+ /** mirrorInto starts mirroring the driving flag into `ui`, brought in line at once. */
2054
+ mirrorInto(ui) {
2055
+ this.mirrored = ui;
2056
+ this.syncDriving(this.store.getState());
2057
+ }
2058
+ /**
2059
+ * releaseMirror stops mirroring, leaving the UI store with no driving flag, no edit lock and
2060
+ * no hand-off: a studio the co-pilot left is never stranded inert.
2061
+ */
2062
+ releaseMirror() {
2063
+ const ui = this.mirrored;
2064
+ if (ui === null) {
2065
+ return;
2066
+ }
2067
+ this.mirrored = null;
2068
+ ui.getState().setAgentDriving(false);
2069
+ ui.getState().agentClearEditLocks();
2070
+ ui.getState().setAgentHandoff(null);
2071
+ }
2072
+ /**
2073
+ * syncDriving writes the driving flag through to the UI store on a real flip only, so a token
2074
+ * stream does not churn it.
2075
+ *
2076
+ * When the runs yield the workspace, the entities they locked are released, except the one a
2077
+ * run left in an open edit session for the user to adjust and save: that draft outlives the
2078
+ * run, and so does the co-pilot's authorship of it.
2079
+ */
2080
+ syncDriving(state) {
2081
+ const ui = this.mirrored;
2082
+ if (ui === null) {
2083
+ return;
2084
+ }
2085
+ const driving = selectAgentDriving(state);
2086
+ if (ui.getState().agentDriving === driving) {
2087
+ return;
2088
+ }
2089
+ ui.getState().setAgentDriving(driving);
2090
+ if (!driving) {
2091
+ ui.getState().agentClearEditLocks(chunkOQSYFH3Z_cjs.agentHandoffTarget(ui.getState()));
2092
+ }
2093
+ }
2094
+ /** syncUrl mirrors the thread ids, their run ids and the active tab through the URL seam. */
2095
+ syncUrl() {
2096
+ const state = this.store.getState();
2097
+ const threads = state.order.map((id) => ({ id, runId: state.threads[id]?.runId ?? null }));
2098
+ this.tellSeam(
2099
+ () => this.config.threadsUrl?.write({ activeThreadId: state.activeTabId ?? null, threads })
2100
+ );
2101
+ }
2102
+ /**
2103
+ * tabsContext is the tool context a tab verb is dispatched with: the studio's own, with this
2104
+ * engine's tab strip layered over it and every other seam left live.
2105
+ */
2106
+ tabsContext() {
2107
+ return chunk7NBRCENN_cjs.layerToolContext(this.config.context, { tabs: this.tabSurface });
2108
+ }
2109
+ /** ensureHost returns a thread's host, building it on first use. */
2110
+ ensureHost(threadId) {
2111
+ let host = this.hosts.get(threadId);
2112
+ if (host === void 0) {
2113
+ host = this.hostFor(threadId);
2114
+ this.hosts.set(threadId, host);
2115
+ }
2116
+ return host;
2117
+ }
2118
+ /**
2119
+ * hostFor builds one thread's host. The run is scoped to the organization of the resource the
2120
+ * co-pilot is open on, read through the rule the panel's gate reads, so a run opens for the
2121
+ * organization whose card the panel shows and a personal resource opens none. A snapshot that
2122
+ * fails to build opens the run without a context rather than blocking the message.
2123
+ */
2124
+ hostFor(threadId) {
2125
+ return agent.createConversationHost({
2126
+ appendUserMessage: (message) => this.store.getState().appendUserMessage(threadId, message),
2127
+ buildContext: () => chunkNCLA6DKD_cjs.buildStudioSnapshot(this.config.context).catch(() => void 0),
2128
+ buildSession: () => this.sessionFor(threadId),
2129
+ onMissingOrganization: () => this.faultsFor(threadId).missingOrganization(),
2130
+ onSendFault: (error, runGone) => this.faultsFor(threadId).recover(runGone, error),
2131
+ onStartError: (organizationId, error, runId) => this.faultsFor(threadId).handleStartError(organizationId, error, runId),
2132
+ resolveOrganizationId: () => copilotOrganizationId(this.config.context.ui.getState()),
2133
+ routeForMessage: (message) => this.routeForMessage(threadId, message),
2134
+ routeForState: () => this.routeForState(threadId)
2135
+ });
2136
+ }
2137
+ /**
2138
+ * sessionFor builds one thread's session. Both confirmation gates, the server tool's and the
2139
+ * client tool's the bus raises through `ctx.confirm`, park on that thread's in-chat card, and
2140
+ * a client tool's card reads its localized body with the request's values, so a merge names
2141
+ * the rows it is about to join.
2142
+ */
2143
+ sessionFor(threadId) {
2144
+ this.sessionStates.delete(threadId);
2145
+ return new agent.AgentEngine({
2146
+ bus: this.config.bus,
2147
+ confirmServerTool: (confirmation) => this.requestConfirmation(
2148
+ threadId,
2149
+ confirmation.name,
2150
+ this.config.strings.confirm.serverToolFallback(confirmation.name)
2151
+ ),
2152
+ // Layered rather than spread: a spread would evaluate the context's late-bound getters once,
2153
+ // and a session built before the map mounts would carry no map for its whole life.
2154
+ ctx: chunk7NBRCENN_cjs.layerToolContext(this.config.context, {
2155
+ confirm: (request) => this.requestConfirmation(
2156
+ threadId,
2157
+ request.name,
2158
+ chunkOP37FKW6_cjs.confirmSentence(this.config.strings, request.descriptionLabel, request.values) ?? request.description
2159
+ ),
2160
+ origin: "agent"
2161
+ }),
2162
+ observer: this.observerFor(threadId),
2163
+ // What a tool moved rides its result, and a failure carries the playbook's recovery: the
2164
+ // playbook tells the model both, so a session without them would answer every call bare.
2165
+ // The host's addendum is read at the failure, so a host that changes it reaches the
2166
+ // sessions it already built.
2167
+ recoveryFor: (tool, code) => studioRecoveryFor(tool, code, this.config.recoveryAddendum),
2168
+ routesServerTools: this.config.routesServerTools,
2169
+ stateDelta: studioStateDelta,
2170
+ toolSurface: () => {
2171
+ const surfaces = this.surfaces.get(threadId);
2172
+ return surfaces === void 0 ? void 0 : surfaceTools(surfaces);
2173
+ },
2174
+ transport: this.config.transport
2175
+ });
2176
+ }
2177
+ /**
2178
+ * observerFor maps one thread's session onto its transcript, then layers the co-pilot's own
2179
+ * side effects over it: the URL mirror of a new run id, the question card, the suggest
2180
+ * session's owner, the edit lock and the hand-off, the suggestions card and the re-route.
2181
+ */
2182
+ observerFor(threadId) {
2183
+ const store = this.store;
2184
+ const transcript = transcriptObserver({
2185
+ draftWarning: () => ({
2186
+ note: this.config.strings.prompt.budgetDraftOpen,
2187
+ // Whether a draft sits unsaved is a fact about the moment the run ends. `editingKind`
2188
+ // counts a create armed with no id yet, which is just as losable.
2189
+ open: captureStudioState(this.config.context).editingKind !== null
2190
+ }),
2191
+ errorCopy: () => this.config.errorCopy,
2192
+ writer: {
2193
+ appendAssistantDelta: (delta) => store.getState().appendAssistantDelta(threadId, delta),
2194
+ appendChecksUnmet: (unmet) => store.getState().appendChecksUnmet(threadId, unmet),
2195
+ appendError: (message) => store.getState().appendError(threadId, message),
2196
+ appendToolActivity: (activity) => store.getState().appendToolActivity(threadId, activity),
2197
+ setAssistantMessage: (content, messageIndex) => store.getState().setAssistantMessage(threadId, content, messageIndex),
2198
+ setRunId: (runId) => store.getState().setRunId(threadId, runId),
2199
+ setSessionState: (state) => this.reportSessionState(threadId, state),
2200
+ settleToolActivity: (toolCallId, outcome) => store.getState().settleToolActivity(threadId, toolCallId, outcome)
2201
+ }
2202
+ });
2203
+ return {
2204
+ ...transcript,
2205
+ onError: (message, code) => {
2206
+ transcript.onError?.(message, code);
2207
+ if (code === ACCESS_REVOKED) {
2208
+ this.tellSeam(() => this.config.invalidateMemberships?.());
2209
+ }
2210
+ },
2211
+ onRunId: (runId) => {
2212
+ transcript.onRunId?.(runId);
2213
+ this.syncUrl();
2214
+ },
2215
+ onToolCall: (name, input, toolCallId) => {
2216
+ if (this.appendQuestionCard(threadId, name, input, toolCallId)) {
2217
+ return;
2218
+ }
2219
+ if (name === GENERATE_TOOL) {
2220
+ this.suggestBatchOwner = { threadId, toolCallId };
2221
+ }
2222
+ const ui = this.config.context.ui;
2223
+ const target = agentEditLockTarget(name, input);
2224
+ if (target !== null) {
2225
+ ui.getState().agentLockEntity(target.kind, target.id);
2226
+ }
2227
+ if (agentTakesEntityBack(name, input)) {
2228
+ ui.getState().setAgentHandoff(null);
2229
+ }
2230
+ transcript.onToolCall?.(name, input, toolCallId);
2231
+ },
2232
+ onToolResult: (toolCallId, outcome) => {
2233
+ const settledGenerate = outcome.status === "ok" && this.isGenerate(threadId, toolCallId);
2234
+ transcript.onToolResult?.(toolCallId, outcome);
2235
+ if (settledGenerate) {
2236
+ this.appendSuggestionsCard(threadId, toolCallId);
2237
+ }
2238
+ this.hosts.get(threadId)?.reroute();
2239
+ }
2240
+ };
2241
+ }
2242
+ /**
2243
+ * appendQuestionCard renders a question call as its own card, parsed with the tool's own
2244
+ * schema, and reports whether it did. A malformed input falls through to the ordinary
2245
+ * activity row, whose dispatch then settles red, which is the honest rendering of that call.
2246
+ */
2247
+ appendQuestionCard(threadId, name, input, toolCallId) {
2248
+ if (name !== QUESTION_TOOL) {
2249
+ return false;
2250
+ }
2251
+ const parsed = chunkOQSYFH3Z_cjs.questionToolContracts[QUESTION_TOOL].input.safeParse(input);
2252
+ if (!parsed.success) {
2253
+ return false;
2254
+ }
2255
+ this.store.getState().appendQuestion(threadId, {
2256
+ options: parsed.data.options.map((option) => ({
2257
+ description: option.description ?? null,
2258
+ label: option.label
2259
+ })),
2260
+ question: parsed.data.question,
2261
+ toolCallId
2262
+ });
2263
+ return true;
2264
+ }
2265
+ /** isGenerate reports whether a thread recorded `toolCallId` as a generate's activity row. */
2266
+ isGenerate(threadId, toolCallId) {
2267
+ return this.store.getState().threads[threadId]?.transcript.some(
2268
+ (entry) => entry.role === "activity" && entry.id === toolCallId && entry.name === GENERATE_TOOL
2269
+ ) ?? false;
2270
+ }
2271
+ /**
2272
+ * appendSuggestionsCard renders the live suggest session's candidates as the thread's
2273
+ * suggestions card, keyed off the generating call so a replayed settle appends no duplicate,
2274
+ * and frames the batch once while the thread is the tab on screen.
2275
+ *
2276
+ * It snapshots the SESSION, never the model's echo, so every candidate shows its true colour
2277
+ * and metrics. A settle whose call no longer owns the session renders nothing: another thread
2278
+ * re-pointed the session, and its candidates belong to that conversation.
2279
+ */
2280
+ appendSuggestionsCard(threadId, toolCallId) {
2281
+ const owner = this.suggestBatchOwner;
2282
+ if (owner?.threadId !== threadId || owner.toolCallId !== toolCallId) {
2283
+ return;
2284
+ }
2285
+ const context = this.config.context;
2286
+ const candidates = chunkOQSYFH3Z_cjs.selectSuggestionSession(context.ui.getState())?.candidates ?? [];
2287
+ if (candidates.length === 0) {
2288
+ return;
2289
+ }
2290
+ const entryId = `${toolCallId}:card`;
2291
+ const transcript = this.store.getState().threads[threadId]?.transcript ?? [];
2292
+ if (transcript.some((entry) => entry.id === entryId)) {
2293
+ return;
2294
+ }
2295
+ this.store.getState().appendSuggestions(threadId, {
2296
+ candidates: candidates.map((candidate) => ({
2297
+ ascentMeters: candidate.ascentMeters,
2298
+ color: candidate.color,
2299
+ distanceMeters: candidate.distanceMeters,
2300
+ durationSeconds: candidate.durationSeconds,
2301
+ seed: candidate.seed
2302
+ })),
2303
+ entryId
2304
+ });
2305
+ if (this.store.getState().activeTabId !== threadId) {
2306
+ return;
2307
+ }
2308
+ const bounds = geo.boundsOf(candidates.map((candidate) => candidate.geometry));
2309
+ if (bounds) {
2310
+ holdRejection(this.config.bus.dispatch(context, "studio.map.fitBounds", { bounds }));
2311
+ }
2312
+ }
2313
+ /**
2314
+ * stagePick applies one suggested route through the bus, and answers how it ended.
2315
+ *
2316
+ * A tool bus's dispatch never rejects and always answers a result, and a host's own may do
2317
+ * neither: an apply that rejects answers the refusal the bus would have made of the throw, and
2318
+ * one whose answer states no outcome is refused as `internal`.
2319
+ */
2320
+ async stagePick(seed) {
2321
+ const context = this.config.context;
2322
+ try {
2323
+ const applied = await this.config.bus.dispatch(
2324
+ context,
2325
+ "studio.itinerary.suggest.applyCandidate",
2326
+ {
2327
+ seed,
2328
+ segmentName: chunkOQSYFH3Z_cjs.defaultSegmentName(
2329
+ context.ui.getState().activeItinerary?.segments?.length ?? 0
2330
+ )
2331
+ }
2332
+ );
2333
+ if (isOutcome(applied)) {
2334
+ return applied;
2335
+ }
2336
+ return {
2337
+ code: "internal",
2338
+ error: "the apply of a suggested route answered no result",
2339
+ ok: false
2340
+ };
2341
+ } catch (err) {
2342
+ return chunkQL63MUEW_cjs.failureFromThrown(err);
2343
+ }
2344
+ }
2345
+ /**
2346
+ * applyPick runs one suggestions-card pick, releasing the card's guard however it ends.
2347
+ *
2348
+ * The apply asks before it drops a staged draft. A reader who keeps theirs (a confirmation
2349
+ * denied or left to expire) refused nothing: the card stays pickable and nothing is written.
2350
+ */
2351
+ async applyPick(threadId, entryId, seed, label) {
2352
+ try {
2353
+ const applied = await this.stagePick(seed);
2354
+ if (!this.isOpen(threadId)) {
2355
+ return;
2356
+ }
2357
+ if (!applied.ok) {
2358
+ if (chunkEOKRXXAC_cjs.isConfirmationWithheld(applied)) {
2359
+ return;
2360
+ }
2361
+ this.store.getState().appendError(threadId, this.config.strings.prompt.suggestionsStageError);
2362
+ return;
2363
+ }
2364
+ this.store.getState().chooseSuggestion(threadId, entryId, seed);
2365
+ this.send(threadId, label);
2366
+ } finally {
2367
+ this.stagingPicks.delete(entryId);
2368
+ }
2369
+ }
2370
+ /**
2371
+ * requestConfirmation parks a thread's decision on its in-chat card. A decision already parked
2372
+ * on the thread is denied first, so no resolver is stranded, and one requested while the
2373
+ * engine is parked, or for a conversation that has closed, is denied at once: no card could
2374
+ * show it.
2375
+ */
2376
+ requestConfirmation(threadId, name, summary) {
2377
+ if (!this.isOpen(threadId)) {
2378
+ return Promise.resolve(false);
2379
+ }
2380
+ return new Promise((resolve) => {
2381
+ this.confirmations.get(threadId)?.(false);
2382
+ this.confirmations.set(threadId, resolve);
2383
+ this.store.getState().setPendingConfirmation(threadId, { name, summary });
2384
+ });
2385
+ }
2386
+ /** denyPendingConfirmation denies a thread's parked decision, if any, and clears its card. */
2387
+ denyPendingConfirmation(threadId) {
2388
+ const resolve = this.confirmations.get(threadId);
2389
+ if (resolve !== void 0) {
2390
+ this.confirmations.delete(threadId);
2391
+ resolve(false);
2392
+ }
2393
+ this.store.getState().clearPendingConfirmation(threadId);
2394
+ }
2395
+ /**
2396
+ * faultsFor binds the shared fault handling to one thread. The missing-organization line
2397
+ * depends on why there is none, read when the fault happens: with nothing open it asks for an
2398
+ * itinerary or a zone, and with a personal one open it says the co-pilot works on an
2399
+ * organization's.
2400
+ */
2401
+ faultsFor(threadId) {
2402
+ const { context, invalidateAiConfig, invalidateMemberships, onSignInRefused, strings } = this.config;
2403
+ const store = this.store;
2404
+ return agent.createConversationFaults({
2405
+ copy: {
2406
+ generic: strings.prompt.errorGeneric,
2407
+ missingOrganization: copilotOrganizationId(context.ui.getState()) === null ? strings.copilot.errorPersonalResource : strings.copilot.errorNoResource,
2408
+ noAccess: strings.copilot.errorNoAccess,
2409
+ notConfigured: strings.copilot.errorNotConfigured,
2410
+ notEntitled: strings.copilot.withheld,
2411
+ rateLimited: strings.prompt.errorRateLimited,
2412
+ tooLarge: strings.prompt.errorTooLarge
2413
+ },
2414
+ invalidateAiConfig,
2415
+ invalidateMemberships,
2416
+ // A fault that dropped the run id has to reach the URL, or a reload would resume a run
2417
+ // that is gone.
2418
+ onSettled: () => this.syncUrl(),
2419
+ onSignInRefused,
2420
+ writer: {
2421
+ appendError: (message) => store.getState().appendError(threadId, message),
2422
+ setRunId: (runId) => store.getState().setRunId(threadId, runId),
2423
+ // A fault ends the wait for a turn that will not come, so the state it writes (every one
2424
+ // returns the conversation to `awaiting_input`) lands as it is.
2425
+ setSessionState: (state) => {
2426
+ this.awaitingTurn.delete(threadId);
2427
+ this.writeSessionState(threadId, state);
2428
+ }
2429
+ }
2430
+ });
2431
+ }
2432
+ /** routeForMessage picks the surfaces a thread's next turn offers, from its message. */
2433
+ routeForMessage(threadId, message) {
2434
+ this.lastRouted.set(threadId, message);
2435
+ this.route(threadId, message);
2436
+ }
2437
+ /**
2438
+ * routeForState re-picks from live state, replaying the thread's last message: its words
2439
+ * carry the keyword and skill matches, and dropping them would narrow the manifest at the
2440
+ * moment the run needs it wider.
2441
+ */
2442
+ routeForState(threadId) {
2443
+ this.route(threadId, this.lastRouted.get(threadId) ?? "");
2444
+ }
2445
+ /** route records a thread's pick, with its previous one as the stickiness input. */
2446
+ route(threadId, message) {
2447
+ const decision = selectSurfaces(
2448
+ message,
2449
+ routerStateFrom(this.config.context),
2450
+ this.surfaces.get(threadId) ?? []
2451
+ );
2452
+ this.surfaces.set(threadId, decision.surfaces);
2453
+ }
2454
+ /** openTab opens a conversation, with its host built so the tools and a submit find it. */
2455
+ openTab() {
2456
+ const id = this.ids.next();
2457
+ this.store.getState().addCopilotTab(id);
2458
+ this.ensureHost(id);
2459
+ this.syncUrl();
2460
+ return id;
2461
+ }
2462
+ /**
2463
+ * closeTab finishes one conversation's run and disposes its session, and the others run on.
2464
+ *
2465
+ * A pending confirmation is denied, and the suggest session is discarded when it is headless
2466
+ * (no draft, no open panel) and this thread staged it or nobody did: a session the human is
2467
+ * using stays, and so does one another conversation owns. Closing the last conversation of an
2468
+ * entitled viewer opens a fresh one, so the strip always carries one.
2469
+ */
2470
+ closeTab(tabId) {
2471
+ this.hosts.get(tabId)?.finish();
2472
+ this.hosts.delete(tabId);
2473
+ this.surfaces.delete(tabId);
2474
+ this.lastRouted.delete(tabId);
2475
+ this.awaitingTurn.delete(tabId);
2476
+ this.sessionStates.delete(tabId);
2477
+ this.denyPendingConfirmation(tabId);
2478
+ const context = this.config.context;
2479
+ const owner = this.suggestBatchOwner;
2480
+ const session = chunkOQSYFH3Z_cjs.selectSuggestionSession(context.ui.getState());
2481
+ if (session !== null && !session.draft && context.ui.getState().openContent !== "suggest" && (owner === null || owner.threadId === tabId)) {
2482
+ this.suggestBatchOwner = null;
2483
+ holdRejection(this.config.bus.dispatch(context, "studio.itinerary.suggest.discard", {}));
2484
+ }
2485
+ this.store.getState().closeCopilotTab(tabId);
2486
+ if (!this.withheld() && this.store.getState().order.length === 0) {
2487
+ this.openTab();
2488
+ return;
2489
+ }
2490
+ this.syncUrl();
2491
+ }
2492
+ /**
2493
+ * showTab points the panel at a tab and mirrors it. The withheld tab is Search for an entitled
2494
+ * viewer, so no caller shows them the host's own content over their conversations.
2495
+ */
2496
+ showTab(tabId) {
2497
+ this.store.getState().setActiveTab(tabId === WITHHELD_TAB_ID && !this.withheld() ? chunkNCLA6DKD_cjs.SEARCH_TAB_ID : tabId);
2498
+ this.syncUrl();
2499
+ }
2500
+ /**
2501
+ * resetThreads clears the co-pilot for a switched-to resource: every conversation closes, so
2502
+ * the one about the resource being left cannot leak into the next, and the panel lands on
2503
+ * Search behind the fresh conversation the last close opens.
2504
+ */
2505
+ resetThreads() {
2506
+ for (const id of [...this.store.getState().order]) {
2507
+ this.closeTab(id);
2508
+ }
2509
+ this.showTab(chunkNCLA6DKD_cjs.SEARCH_TAB_ID);
2510
+ }
2511
+ /**
2512
+ * openOrReveal reveals the co-pilot, focusing a conversation rather than opening a second one:
2513
+ * a withheld viewer lands on the withheld tab, an entitled one on their latest
2514
+ * conversation, and a new one opens only when there is none.
2515
+ */
2516
+ openOrReveal() {
2517
+ if (this.withheld()) {
2518
+ this.showTab(WITHHELD_TAB_ID);
2519
+ return WITHHELD_TAB_ID;
2520
+ }
2521
+ const existing = this.store.getState().order.at(-1);
2522
+ if (existing !== void 0) {
2523
+ this.showTab(existing);
2524
+ return existing;
2525
+ }
2526
+ return this.openTab();
2527
+ }
2528
+ };
2529
+ var DirectorChatEngine = class {
2530
+ config;
2531
+ store;
2532
+ subscriptions = /* @__PURE__ */ new Set();
2533
+ /** The store subscription the listeners are notified through, while the engine runs. */
2534
+ releaseStore = null;
2535
+ /** The conversation's host: its one session and its started guard, built on first use. */
2536
+ host = null;
2537
+ /**
2538
+ * Whether the last instruction is out and the session has not picked its turn up. While it
2539
+ * is, the session's `awaiting_input` is the run being readied and never the turn settling.
2540
+ */
2541
+ awaitingTurn = false;
2542
+ /**
2543
+ * The state the conversation's session last reported, `awaiting_input` for one that has
2544
+ * reported none. It says whether an instruction is sent into a turn under way, which the
2545
+ * session answers with no report of `running`.
2546
+ */
2547
+ sessionState = "awaiting_input";
2548
+ /** Whether nobody is watching. A parked engine opens nothing and answers no command. */
2549
+ parked = true;
2550
+ disposed = false;
2551
+ /**
2552
+ * Constructing one holds the options and does nothing else: no host, no session, no run. A
2553
+ * React binding constructs during a render React is free to throw away.
2554
+ */
2555
+ constructor(options) {
2556
+ const { store, ...config } = options;
2557
+ this.config = config;
2558
+ this.store = store ?? chunkQFO5CZG2_cjs.createVideoDirectorStore();
2559
+ }
2560
+ /** getSnapshot returns the conversation's state, by reference and stable between changes. */
2561
+ getSnapshot() {
2562
+ return this.store.getState();
2563
+ }
2564
+ /**
2565
+ * subscribe registers a listener for every change of the snapshot, and returns its own
2566
+ * unsubscribe, which is idempotent. The first listener starts the engine, reconnecting the
2567
+ * run a park left behind, and the last one leaving parks it; each call is its own
2568
+ * subscription.
2569
+ */
2570
+ subscribe(listener) {
2571
+ if (this.disposed) {
2572
+ return () => {
2573
+ };
2574
+ }
2575
+ const subscription = { listener };
2576
+ this.subscriptions.add(subscription);
2577
+ if (this.parked) {
2578
+ this.resume();
2579
+ }
2580
+ return () => {
2581
+ if (!this.subscriptions.delete(subscription) || this.subscriptions.size > 0) {
2582
+ return;
2583
+ }
2584
+ if (!this.parked) {
2585
+ this.park();
2586
+ }
2587
+ };
2588
+ }
2589
+ /**
2590
+ * configure replaces the configuration. Nothing is asked and no session is rebuilt, since
2591
+ * every member is read when it is used, so a binding may call this on every render.
2592
+ */
2593
+ configure(config) {
2594
+ this.config = config;
2595
+ }
2596
+ /**
2597
+ * dispose parks the engine and drops every listener, for good, and asks the gateway to close
2598
+ * the conversation's run: nothing reads it again, and a run left open spends model budget
2599
+ * until the gateway's own timeout. The conversation is left on `awaiting_input` with no run
2600
+ * id and its transcript intact. Idempotent, and every call after it is a no-op rather than an
2601
+ * error.
2602
+ */
2603
+ dispose() {
2604
+ if (this.disposed) {
2605
+ return;
2606
+ }
2607
+ this.disposed = true;
2608
+ this.closeRun();
2609
+ if (!this.parked) {
2610
+ this.park();
2611
+ }
2612
+ this.subscriptions.clear();
2613
+ const { runId, state } = this.store.getState();
2614
+ if (runId !== null || state !== "awaiting_input") {
2615
+ this.store.getState().stopRun();
2616
+ }
2617
+ }
2618
+ /**
2619
+ * stop ends the run: the gateway is asked to close it (a run the session gave up reading
2620
+ * included), a fresh session is swapped in so the next instruction opens a clean run, and the
2621
+ * conversation is parked on `awaiting_input`. The close is what stops the run spending model
2622
+ * budget: a session torn down without it leaves the run going until the gateway's own timeout.
2623
+ * The transcript stays, since a stop is the user's choice and nothing the run did may vanish.
2624
+ */
2625
+ stop() {
2626
+ if (!this.live()) {
2627
+ return;
2628
+ }
2629
+ this.ensureHost().restart();
2630
+ this.awaitingTurn = false;
2631
+ this.store.getState().stopRun();
2632
+ }
2633
+ /**
2634
+ * submit sends an instruction: the first one opens a run scoped to the wizard itinerary's
2635
+ * organization, with the camera plan as its context, and a later one is delivered into the
2636
+ * open run.
2637
+ *
2638
+ * The conversation reads `running` from the submit, so a surface offers its Stop before the
2639
+ * run has started. It returns to `awaiting_input` when the turn settles, and at once when the
2640
+ * itinerary's organization is not known yet or the gateway refuses the start.
2641
+ */
2642
+ submit(message) {
2643
+ if (!this.live()) {
2644
+ return;
2645
+ }
2646
+ this.awaitingTurn = this.sessionState !== "running";
2647
+ this.writeSessionState("running");
2648
+ this.ensureHost().submit(message);
2649
+ }
2650
+ /** live reports whether something watches the engine, which is when it acts. */
2651
+ live() {
2652
+ return !this.parked && !this.disposed;
2653
+ }
2654
+ /**
2655
+ * resume starts the engine for its first subscriber, and reconnects the run a park left
2656
+ * behind. A reconnect that faults drops the stale run id and leaves the conversation usable.
2657
+ * With no run to reconnect it builds nothing: the session is built by the first instruction.
2658
+ */
2659
+ resume() {
2660
+ this.parked = false;
2661
+ this.releaseStore = this.store.subscribe(() => {
2662
+ chunkPACIO4NS_cjs.notifyListeners(Array.from(this.subscriptions, ({ listener }) => listener));
2663
+ });
2664
+ const { runId } = this.store.getState();
2665
+ if (runId !== null) {
2666
+ this.ensureHost().resume(runId, () => {
2667
+ this.store.getState().setRunId(null);
2668
+ this.settle();
2669
+ });
2670
+ }
2671
+ }
2672
+ /**
2673
+ * park stops the engine when its last subscriber leaves: the session is disposed with no
2674
+ * close, so the run goes on at the gateway and the conversation keeps its id for the next
2675
+ * subscriber to reconnect.
2676
+ *
2677
+ * A conversation that read `running` settles on `awaiting_input`: no session streams it any
2678
+ * more, and the session the next resume builds starts on `awaiting_input` and reports a
2679
+ * change only. A conversation at rest is left as it is, so a remount writes nothing.
2680
+ */
2681
+ park() {
2682
+ this.parked = true;
2683
+ this.releaseStore?.();
2684
+ this.releaseStore = null;
2685
+ this.host?.dispose();
2686
+ this.awaitingTurn = false;
2687
+ if (this.store.getState().state === "running") {
2688
+ this.store.getState().setSessionState("awaiting_input");
2689
+ }
2690
+ }
2691
+ /**
2692
+ * closeRun asks the gateway to close the conversation's run, for {@link dispose}.
2693
+ *
2694
+ * While the engine runs, the session holds the run and knows whether a close is still owed,
2695
+ * so the host finishes it. After a park no session holds it: the close is posted through the
2696
+ * transport for the run id the park kept, unless that run had already ended. A close the
2697
+ * gateway refuses is dropped, since the run it names is gone or expires on the gateway's own
2698
+ * timeout, and nothing is left to report it to.
2699
+ */
2700
+ closeRun() {
2701
+ if (!this.parked) {
2702
+ this.host?.finish();
2703
+ return;
2704
+ }
2705
+ const { runId, state } = this.store.getState();
2706
+ if (runId !== null && state !== "ended") {
2707
+ void this.config.transport.sendInput(runId, { type: "close" }).catch(() => void 0);
2708
+ }
2709
+ }
2710
+ /**
2711
+ * settle returns the conversation to `awaiting_input`: its turn settled or its run faulted.
2712
+ * It ends the wait for a turn, so the next report of its session is read as it is.
2713
+ */
2714
+ settle() {
2715
+ this.awaitingTurn = false;
2716
+ this.writeSessionState("awaiting_input");
2717
+ }
2718
+ /**
2719
+ * reportSessionState writes the lifecycle state the session reports, while the engine is
2720
+ * live: a session reports `ended` as the park disposes it, and the park ends no conversation.
2721
+ * While the conversation waits on its turn, the session's `awaiting_input` is not written
2722
+ * either: it is the run being readied. The wait ends when the session reports `running`,
2723
+ * which it does from the message it takes, and its reports are the conversation's from
2724
+ * there: the turn's settle is one of them, whether or not the turn carried a frame of its own.
2725
+ */
2726
+ reportSessionState(state) {
2727
+ this.sessionState = state;
2728
+ if (!this.live() || state === "awaiting_input" && this.awaitingTurn) {
2729
+ return;
2730
+ }
2731
+ this.awaitingTurn = false;
2732
+ this.writeSessionState(state);
2733
+ }
2734
+ /** writeSessionState writes the conversation's state when it differs from the one it reads. */
2735
+ writeSessionState(state) {
2736
+ if (this.store.getState().state !== state) {
2737
+ this.store.getState().setSessionState(state);
2738
+ }
2739
+ }
2740
+ /** ensureHost returns the conversation's host, building it on first use. */
2741
+ ensureHost() {
2742
+ this.host ??= agent.createConversationHost({
2743
+ appendUserMessage: (message) => this.store.getState().appendUserMessage(message),
2744
+ buildContext: () => Promise.resolve(chunkQFO5CZG2_cjs.buildVideoSnapshot(this.config.context) ?? void 0),
2745
+ buildSession: () => this.session(),
2746
+ onMissingOrganization: () => this.faults().missingOrganization(),
2747
+ onSendFault: (error, runGone) => this.faults().recover(runGone, error),
2748
+ onStartError: (organizationId, error, runId) => this.faults().handleStartError(organizationId, error, runId),
2749
+ resolveOrganizationId: () => this.config.organizationId
2750
+ });
2751
+ return this.host;
2752
+ }
2753
+ /** session builds the conversation's session over the camera-scoped bus. */
2754
+ session() {
2755
+ const store = this.store;
2756
+ this.sessionState = "awaiting_input";
2757
+ return new agent.AgentEngine({
2758
+ bus: this.config.bus,
2759
+ // A destructive server tool gets the studio's own prompt, built from its name. The camera
2760
+ // verbs never take this path; the contract of a session requires a gate regardless.
2761
+ confirmServerTool: (confirmation) => this.config.context.confirm?.({
2762
+ description: this.config.strings.confirm.serverToolFallback(confirmation.name),
2763
+ input: void 0,
2764
+ name: confirmation.name
2765
+ }) ?? Promise.resolve(false),
2766
+ ctx: this.config.context,
2767
+ // No draft warning: the camera verbs arm no edit session, so a budget ceiling has no
2768
+ // draft to lose.
2769
+ observer: transcriptObserver({
2770
+ errorCopy: () => this.config.errorCopy,
2771
+ writer: {
2772
+ appendAssistantDelta: (delta) => store.getState().appendAssistantDelta(delta),
2773
+ appendError: (message) => store.getState().appendError(message),
2774
+ appendToolActivity: (activity) => store.getState().appendToolActivity(activity),
2775
+ setActiveTool: (summary) => store.getState().setActiveTool(summary),
2776
+ setAssistantMessage: (content) => store.getState().setAssistantMessage(content),
2777
+ setRunId: (runId) => store.getState().setRunId(runId),
2778
+ setSessionState: (state) => this.reportSessionState(state),
2779
+ settleToolActivity: (toolCallId, outcome) => store.getState().settleToolActivity(toolCallId, outcome)
2780
+ }
2781
+ }),
2782
+ // The director's own prompt: the co-pilot's would teach itineraries, zones and overlays to
2783
+ // a run whose whole manifest is the camera verbs.
2784
+ profile: "video-director",
2785
+ // A failed camera verb carries the playbook's recovery, and the host's addendum read at the
2786
+ // failure. No state delta: the camera verbs move no part of the studio one reports.
2787
+ recoveryFor: (tool, code) => studioRecoveryFor(tool, code, this.config.recoveryAddendum),
2788
+ transport: this.config.transport
2789
+ });
2790
+ }
2791
+ /**
2792
+ * faults binds the shared fault handling to the conversation. No URL is mirrored, so nothing
2793
+ * follows a fault that dropped the run id.
2794
+ */
2795
+ faults() {
2796
+ const { invalidateAiConfig, strings } = this.config;
2797
+ const store = this.store;
2798
+ return agent.createConversationFaults({
2799
+ copy: {
2800
+ generic: strings.prompt.errorGeneric,
2801
+ missingOrganization: strings.director.errorNoOrganization,
2802
+ noAccess: strings.copilot.errorNoAccess,
2803
+ notConfigured: strings.copilot.errorNotConfigured,
2804
+ notEntitled: strings.copilot.withheld,
2805
+ rateLimited: strings.prompt.errorRateLimited,
2806
+ tooLarge: strings.prompt.errorTooLarge
2807
+ },
2808
+ invalidateAiConfig,
2809
+ writer: {
2810
+ appendError: (message) => store.getState().appendError(message),
2811
+ setRunId: (runId) => store.getState().setRunId(runId),
2812
+ // A fault ends the wait for a turn that will not come, so the state it writes lands as
2813
+ // it is.
2814
+ setSessionState: (state) => {
2815
+ this.awaitingTurn = false;
2816
+ this.writeSessionState(state);
2817
+ }
2818
+ }
2819
+ });
2820
+ }
2821
+ };
2822
+
2823
+ // src/agent/rules/agentErrorCopy.ts
2824
+ var agentErrorCopy = (strings) => ({
2825
+ accessRevoked: strings.prompt.errorAccessRevoked,
2826
+ budget: {
2827
+ cost: strings.prompt.budgetCost,
2828
+ generic: strings.prompt.budgetGeneric,
2829
+ turns: strings.prompt.budgetTurns
2830
+ },
2831
+ generic: strings.prompt.errorGeneric,
2832
+ looping: strings.prompt.errorLooping,
2833
+ notConfigured: strings.copilot.errorNotConfigured,
2834
+ rateLimited: strings.prompt.errorRateLimited
2835
+ });
2836
+
2837
+ Object.defineProperty(exports, "SEARCH_TAB_ID", {
2838
+ enumerable: true,
2839
+ get: function () { return chunkNCLA6DKD_cjs.SEARCH_TAB_ID; }
2840
+ });
2841
+ exports.AgentThreadsEngine = AgentThreadsEngine;
2842
+ exports.DirectorChatEngine = DirectorChatEngine;
2843
+ exports.PLAYBOOK = PLAYBOOK;
2844
+ exports.SURFACES = SURFACES;
2845
+ exports.WITHHELD_TAB_ID = WITHHELD_TAB_ID;
2846
+ exports.agentErrorCopy = agentErrorCopy;
2847
+ exports.copilotOrganizationId = copilotOrganizationId;
2848
+ exports.createAgentThreadsStore = createAgentThreadsStore;
2849
+ exports.recoveryFor = recoveryFor;
2850
+ exports.selectAgentDriving = selectAgentDriving;
2851
+ exports.selectSurfaces = selectSurfaces;
2852
+ exports.surfaceTools = surfaceTools;
2853
+ //# sourceMappingURL=index.cjs.map
2854
+ //# sourceMappingURL=index.cjs.map