@mountaya/studio 0.0.0-stage → 0.2.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 (521) hide show
  1. package/CHANGELOG.md +69 -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 +2600 -0
  6. package/dist/agent/index.cjs.map +1 -0
  7. package/dist/agent/index.d.cts +1237 -0
  8. package/dist/agent/index.d.ts +1237 -0
  9. package/dist/agent/index.js +2581 -0
  10. package/dist/agent/index.js.map +1 -0
  11. package/dist/chunk-3Oi_Zrtm.js +9 -0
  12. package/dist/chunk-3Oi_Zrtm.js.map +1 -0
  13. package/dist/chunk-B18OPIu_.js +6 -0
  14. package/dist/chunk-B18OPIu_.js.map +1 -0
  15. package/dist/chunk-B5Uz3Qct.cjs +15 -0
  16. package/dist/chunk-B5Uz3Qct.cjs.map +1 -0
  17. package/dist/chunk-BBEJwkd3.d.cts +839 -0
  18. package/dist/chunk-BIEc_SkR.cjs +29 -0
  19. package/dist/chunk-BIEc_SkR.cjs.map +1 -0
  20. package/dist/chunk-BKMFOe-N.js +171 -0
  21. package/dist/chunk-BKMFOe-N.js.map +1 -0
  22. package/dist/chunk-BP4uy7E1.d.ts +11583 -0
  23. package/dist/chunk-BSHTsFiB.js +1403 -0
  24. package/dist/chunk-BSHTsFiB.js.map +1 -0
  25. package/dist/chunk-BTUUABGI.js +17 -0
  26. package/dist/chunk-BTUUABGI.js.map +1 -0
  27. package/dist/chunk-BaPiaz5X.cjs +115 -0
  28. package/dist/chunk-BaPiaz5X.cjs.map +1 -0
  29. package/dist/chunk-BeCVpkYr.cjs +542 -0
  30. package/dist/chunk-BeCVpkYr.cjs.map +1 -0
  31. package/dist/chunk-BgngsvK8.cjs +6202 -0
  32. package/dist/chunk-BgngsvK8.cjs.map +1 -0
  33. package/dist/chunk-BhInd7CJ.d.cts +253 -0
  34. package/dist/chunk-Bn6ZbxkS.cjs +27 -0
  35. package/dist/chunk-By9ZnkVI.js +60 -0
  36. package/dist/chunk-By9ZnkVI.js.map +1 -0
  37. package/dist/chunk-BzqPhxsz.cjs +367 -0
  38. package/dist/chunk-BzqPhxsz.cjs.map +1 -0
  39. package/dist/chunk-C2mMX81q.d.ts +443 -0
  40. package/dist/chunk-C2rr9Q0V.cjs +1402 -0
  41. package/dist/chunk-C2rr9Q0V.cjs.map +1 -0
  42. package/dist/chunk-CDJCbwIQ.d.cts +78 -0
  43. package/dist/chunk-CLGvBOVH.d.cts +1654 -0
  44. package/dist/chunk-COdw1dc6.d.ts +525 -0
  45. package/dist/chunk-CQCJnT2i.d.ts +511 -0
  46. package/dist/chunk-CSyHY67q.cjs +353 -0
  47. package/dist/chunk-CSyHY67q.cjs.map +1 -0
  48. package/dist/chunk-CiK1Iqrv.js +950 -0
  49. package/dist/chunk-CiK1Iqrv.js.map +1 -0
  50. package/dist/chunk-CmJBgSwZ.cjs +24 -0
  51. package/dist/chunk-CmJBgSwZ.cjs.map +1 -0
  52. package/dist/chunk-CnrsRK2u.cjs +83 -0
  53. package/dist/chunk-CnrsRK2u.cjs.map +1 -0
  54. package/dist/chunk-Co782_9r.js +326 -0
  55. package/dist/chunk-Co782_9r.js.map +1 -0
  56. package/dist/chunk-Csr3KDpZ.cjs +32 -0
  57. package/dist/chunk-Csr3KDpZ.cjs.map +1 -0
  58. package/dist/chunk-CwkmccXv.js +89 -0
  59. package/dist/chunk-CwkmccXv.js.map +1 -0
  60. package/dist/chunk-D0Q4iL9B.cjs +255 -0
  61. package/dist/chunk-D0Q4iL9B.cjs.map +1 -0
  62. package/dist/chunk-DFwiSzUS.cjs +72 -0
  63. package/dist/chunk-DFwiSzUS.cjs.map +1 -0
  64. package/dist/chunk-DIFayl2P.d.cts +443 -0
  65. package/dist/chunk-DIGF58ux.d.cts +525 -0
  66. package/dist/chunk-DKuuuld5.js +101 -0
  67. package/dist/chunk-DKuuuld5.js.map +1 -0
  68. package/dist/chunk-DMePkFEo.js +5054 -0
  69. package/dist/chunk-DMePkFEo.js.map +1 -0
  70. package/dist/chunk-DO5SIBgu.js +305 -0
  71. package/dist/chunk-DO5SIBgu.js.map +1 -0
  72. package/dist/chunk-DOQ_7eE5.d.ts +6662 -0
  73. package/dist/chunk-DThaaNeb.d.cts +15 -0
  74. package/dist/chunk-DThaaNeb.d.ts +15 -0
  75. package/dist/chunk-DUQzjUJy.d.ts +78 -0
  76. package/dist/chunk-DX37IPhV.cjs +1903 -0
  77. package/dist/chunk-DX37IPhV.cjs.map +1 -0
  78. package/dist/chunk-Damps5Tk.cjs +155 -0
  79. package/dist/chunk-Damps5Tk.cjs.map +1 -0
  80. package/dist/chunk-DbK5PhpJ.d.ts +1654 -0
  81. package/dist/chunk-De0vAASv.d.ts +253 -0
  82. package/dist/chunk-DhSZ7YZt.d.cts +6662 -0
  83. package/dist/chunk-DjEvqvPA.cjs +43 -0
  84. package/dist/chunk-DjEvqvPA.cjs.map +1 -0
  85. package/dist/chunk-DkwDzwvu.d.cts +121 -0
  86. package/dist/chunk-DkwDzwvu.d.ts +121 -0
  87. package/dist/chunk-Dmszv9If.js +71 -0
  88. package/dist/chunk-Dmszv9If.js.map +1 -0
  89. package/dist/chunk-Dp_ftNWY.d.cts +511 -0
  90. package/dist/chunk-DsHQySz0.js +31 -0
  91. package/dist/chunk-DsHQySz0.js.map +1 -0
  92. package/dist/chunk-DwoUyHHh.js +281 -0
  93. package/dist/chunk-DwoUyHHh.js.map +1 -0
  94. package/dist/chunk-IaIDQflj.d.cts +2315 -0
  95. package/dist/chunk-IaIDQflj.d.ts +2315 -0
  96. package/dist/chunk-cVXLsZfL.d.ts +839 -0
  97. package/dist/chunk-mIaCX9EJ.d.cts +11583 -0
  98. package/dist/chunk-nJQxbOwQ.cjs +8962 -0
  99. package/dist/chunk-nJQxbOwQ.cjs.map +1 -0
  100. package/dist/chunk-o9jaxhCO.js +8852 -0
  101. package/dist/chunk-o9jaxhCO.js.map +1 -0
  102. package/dist/chunk-p-Tt_Lwz.js +14 -0
  103. package/dist/chunk-p-Tt_Lwz.js.map +1 -0
  104. package/dist/engines/index.cjs +2091 -0
  105. package/dist/engines/index.cjs.map +1 -0
  106. package/dist/engines/index.d.cts +2176 -0
  107. package/dist/engines/index.d.ts +2176 -0
  108. package/dist/engines/index.js +2075 -0
  109. package/dist/engines/index.js.map +1 -0
  110. package/dist/handlers/index.cjs +53 -0
  111. package/dist/handlers/index.cjs.map +1 -0
  112. package/dist/handlers/index.d.cts +403 -0
  113. package/dist/handlers/index.d.ts +403 -0
  114. package/dist/handlers/index.js +33 -0
  115. package/dist/handlers/index.js.map +1 -0
  116. package/dist/index.cjs +3511 -0
  117. package/dist/index.cjs.map +1 -0
  118. package/dist/index.d.cts +8 -0
  119. package/dist/index.d.ts +8 -0
  120. package/dist/index.js +3033 -0
  121. package/dist/index.js.map +1 -0
  122. package/dist/plugins/index.cjs +510 -0
  123. package/dist/plugins/index.cjs.map +1 -0
  124. package/dist/plugins/index.d.cts +296 -0
  125. package/dist/plugins/index.d.ts +296 -0
  126. package/dist/plugins/index.js +489 -0
  127. package/dist/plugins/index.js.map +1 -0
  128. package/dist/seams/index.cjs +89 -0
  129. package/dist/seams/index.cjs.map +1 -0
  130. package/dist/seams/index.d.cts +452 -0
  131. package/dist/seams/index.d.ts +452 -0
  132. package/dist/seams/index.js +49 -0
  133. package/dist/seams/index.js.map +1 -0
  134. package/dist/strings/fr/index.cjs +2135 -0
  135. package/dist/strings/fr/index.cjs.map +1 -0
  136. package/dist/strings/fr/index.d.cts +17 -0
  137. package/dist/strings/fr/index.d.ts +17 -0
  138. package/dist/strings/fr/index.js +2130 -0
  139. package/dist/strings/fr/index.js.map +1 -0
  140. package/dist/strings/index.cjs +2384 -0
  141. package/dist/strings/index.cjs.map +1 -0
  142. package/dist/strings/index.d.cts +3 -0
  143. package/dist/strings/index.d.ts +3 -0
  144. package/dist/strings/index.js +2353 -0
  145. package/dist/strings/index.js.map +1 -0
  146. package/dist/testing/index.cjs +230 -0
  147. package/dist/testing/index.cjs.map +1 -0
  148. package/dist/testing/index.d.cts +246 -0
  149. package/dist/testing/index.d.ts +246 -0
  150. package/dist/testing/index.js +219 -0
  151. package/dist/testing/index.js.map +1 -0
  152. package/dist/time/index.cjs +28 -0
  153. package/dist/time/index.cjs.map +1 -0
  154. package/dist/time/index.d.cts +41 -0
  155. package/dist/time/index.d.ts +41 -0
  156. package/dist/time/index.js +23 -0
  157. package/dist/time/index.js.map +1 -0
  158. package/package.json +224 -4
  159. package/src/agent/engines/agentThreads.ts +1601 -0
  160. package/src/agent/engines/directorChat.ts +500 -0
  161. package/src/agent/index.ts +67 -0
  162. package/src/agent/rules/agentEditLock.ts +115 -0
  163. package/src/agent/rules/agentErrorCopy.ts +44 -0
  164. package/src/agent/rules/copilotOrganization.ts +36 -0
  165. package/src/agent/rules/playbook.gen.ts +444 -0
  166. package/src/agent/rules/router.ts +518 -0
  167. package/src/agent/rules/stateDelta.ts +29 -0
  168. package/src/agent/rules/studioRouter.ts +123 -0
  169. package/src/agent/rules/surfaces.gen.ts +633 -0
  170. package/src/agent/rules/threadsUrl.ts +48 -0
  171. package/src/agent/rules/transcriptObserver.ts +90 -0
  172. package/src/agent/stores/agentThreads.ts +451 -0
  173. package/src/bus/contracts/noData.ts +18 -0
  174. package/src/bus/contracts/shared.ts +172 -0
  175. package/src/bus/contracts/studioTools.ts +224 -0
  176. package/src/bus/rules/bus.ts +857 -0
  177. package/src/bus/rules/confirmation.ts +22 -0
  178. package/src/bus/rules/defineRegistry.ts +24 -0
  179. package/src/bus/rules/errors.ts +401 -0
  180. package/src/bus/rules/handlerErrors.ts +103 -0
  181. package/src/bus/rules/handlerRegistry.ts +627 -0
  182. package/src/bus/rules/inputSchema.ts +232 -0
  183. package/src/bus/rules/invalidInput.ts +441 -0
  184. package/src/bus/rules/lateBoundTools.ts +100 -0
  185. package/src/bus/rules/studioRegistry.ts +324 -0
  186. package/src/bus/rules/studioToolBus.ts +73 -0
  187. package/src/bus/rules/types.ts +804 -0
  188. package/src/chrome/contracts/alert.ts +42 -0
  189. package/src/chrome/contracts/itinerary.ts +26 -0
  190. package/src/chrome/contracts/map.ts +23 -0
  191. package/src/chrome/contracts/overlay.ts +46 -0
  192. package/src/chrome/contracts/panel.ts +29 -0
  193. package/src/chrome/contracts/question.ts +52 -0
  194. package/src/chrome/contracts/selection.ts +26 -0
  195. package/src/chrome/contracts/sidenav.ts +23 -0
  196. package/src/chrome/contracts/snapshot.ts +319 -0
  197. package/src/chrome/contracts/state.ts +22 -0
  198. package/src/chrome/contracts/tabs.ts +56 -0
  199. package/src/chrome/handlers/alert.ts +91 -0
  200. package/src/chrome/handlers/introspection.ts +180 -0
  201. package/src/chrome/handlers/panels.ts +42 -0
  202. package/src/chrome/handlers/question.ts +24 -0
  203. package/src/chrome/handlers/sidenav.ts +116 -0
  204. package/src/chrome/handlers/snapshot.ts +451 -0
  205. package/src/chrome/handlers/stateDelta.ts +125 -0
  206. package/src/chrome/handlers/tabs.ts +143 -0
  207. package/src/chrome/handlers/timestamp.ts +19 -0
  208. package/src/chrome/rules/agentSelectors.ts +210 -0
  209. package/src/chrome/rules/mapAlert.ts +13 -0
  210. package/src/chrome/rules/question.ts +25 -0
  211. package/src/chrome/rules/tabs.ts +13 -0
  212. package/src/chrome/stores/activeDraftSession.ts +134 -0
  213. package/src/chrome/stores/chrome.ts +527 -0
  214. package/src/chrome/stores/uiStore.ts +575 -0
  215. package/src/collab/contracts/collab.ts +261 -0
  216. package/src/collab/handlers/collab.ts +468 -0
  217. package/src/collab/rules/toolNames.ts +33 -0
  218. package/src/collab/stores/collab.ts +899 -0
  219. package/src/collections/contracts/collection.ts +182 -0
  220. package/src/collections/handlers/collectionAttach.ts +141 -0
  221. package/src/collections/handlers/collections.ts +499 -0
  222. package/src/collections/handlers/heldCollection.ts +42 -0
  223. package/src/collections/handlers/restCollections.ts +386 -0
  224. package/src/collections/rules/collections.ts +138 -0
  225. package/src/collections/rules/entityCollections.ts +53 -0
  226. package/src/collections/stores/collections.ts +133 -0
  227. package/src/data/contracts/data.ts +233 -0
  228. package/src/data/contracts/itinerary.ts +71 -0
  229. package/src/data/handlers/activityResolve.ts +76 -0
  230. package/src/data/handlers/data.ts +200 -0
  231. package/src/data/handlers/graphql.ts +26 -0
  232. package/src/data/handlers/mutationSink.ts +1577 -0
  233. package/src/data/handlers/profile.ts +83 -0
  234. package/src/data/handlers/writeThrough.ts +417 -0
  235. package/src/data/rules/cache.ts +181 -0
  236. package/src/data/rules/dataTypes.ts +40 -0
  237. package/src/data/rules/keys.ts +106 -0
  238. package/src/data/rules/persistence.ts +1058 -0
  239. package/src/data/rules/requestBody.ts +43 -0
  240. package/src/data/rules/restErrors.ts +354 -0
  241. package/src/data/rules/sessionSurface.ts +156 -0
  242. package/src/data/rules/toolResultData.ts +73 -0
  243. package/src/data/rules/uuid.ts +24 -0
  244. package/src/edit/contracts/edit.ts +37 -0
  245. package/src/edit/contracts/itinerary.ts +57 -0
  246. package/src/edit/handlers/draftCommit.ts +257 -0
  247. package/src/edit/handlers/editDiscard.ts +34 -0
  248. package/src/edit/handlers/editLock.ts +949 -0
  249. package/src/edit/handlers/editor.ts +203 -0
  250. package/src/edit/handlers/formUnsaved.ts +24 -0
  251. package/src/edit/rules/draftMetadata.ts +117 -0
  252. package/src/edit/rules/editKeyboard.ts +222 -0
  253. package/src/edit/rules/editShortcuts.ts +102 -0
  254. package/src/edit/rules/editTooltip.ts +174 -0
  255. package/src/edit/rules/editorTaken.ts +49 -0
  256. package/src/edit/rules/history.ts +26 -0
  257. package/src/edit/rules/unsavedWork.ts +60 -0
  258. package/src/edit/stores/editorReservation.ts +70 -0
  259. package/src/edit/stores/formsUnsaved.ts +54 -0
  260. package/src/embed/contracts/embed.ts +48 -0
  261. package/src/embed/engines/embedFraming.ts +1329 -0
  262. package/src/embed/engines/embedReady.ts +353 -0
  263. package/src/embed/engines/framingPageSession.ts +169 -0
  264. package/src/embed/handlers/embed.ts +130 -0
  265. package/src/embed/rules/allowedDomains.ts +71 -0
  266. package/src/embed/rules/bridgeMessages.ts +224 -0
  267. package/src/embed/rules/defaults.ts +173 -0
  268. package/src/embed/rules/displaySeed.ts +115 -0
  269. package/src/embed/rules/embedAllowlist.ts +146 -0
  270. package/src/embed/rules/embedConstraints.ts +215 -0
  271. package/src/embed/rules/embedElements.ts +277 -0
  272. package/src/embed/rules/embedSectionFields.ts +126 -0
  273. package/src/embed/rules/embedSecurity.ts +116 -0
  274. package/src/embed/rules/fieldDependencies.ts +89 -0
  275. package/src/embed/rules/fieldOptions.ts +138 -0
  276. package/src/embed/rules/layerOptions.ts +161 -0
  277. package/src/embed/rules/readyProtocol.ts +66 -0
  278. package/src/embed/rules/safetyRules.ts +215 -0
  279. package/src/embed/rules/snippet.ts +531 -0
  280. package/src/embed/rules/tableCode.ts +270 -0
  281. package/src/embed/stores/embed.ts +60 -0
  282. package/src/embed/stores/embedContent.ts +77 -0
  283. package/src/engines/index.ts +81 -0
  284. package/src/handlers/index.ts +66 -0
  285. package/src/index.ts +1065 -0
  286. package/src/itinerary/contracts/itinerary.ts +705 -0
  287. package/src/itinerary/engines/itineraryPace.ts +612 -0
  288. package/src/itinerary/engines/profileMarker.ts +238 -0
  289. package/src/itinerary/handlers/importStaging.ts +352 -0
  290. package/src/itinerary/handlers/itinerary.ts +572 -0
  291. package/src/itinerary/handlers/itineraryDuplicate.ts +177 -0
  292. package/src/itinerary/handlers/itineraryExport.ts +117 -0
  293. package/src/itinerary/handlers/itineraryImport.ts +783 -0
  294. package/src/itinerary/handlers/itineraryPublish.ts +118 -0
  295. package/src/itinerary/handlers/itinerarySelection.ts +354 -0
  296. package/src/itinerary/handlers/itinerarySuggest.ts +1186 -0
  297. package/src/itinerary/handlers/itineraryUnpublish.ts +101 -0
  298. package/src/itinerary/handlers/publicationScope.ts +118 -0
  299. package/src/itinerary/handlers/restItineraries.ts +752 -0
  300. package/src/itinerary/handlers/restItineraryExport.ts +70 -0
  301. package/src/itinerary/handlers/restItineraryImport.ts +311 -0
  302. package/src/itinerary/handlers/restItineraryPace.ts +87 -0
  303. package/src/itinerary/handlers/restItineraryRecord.ts +36 -0
  304. package/src/itinerary/handlers/suggestParams.ts +379 -0
  305. package/src/itinerary/handlers/suggestStaging.ts +363 -0
  306. package/src/itinerary/handlers/surfaceOpen.ts +389 -0
  307. package/src/itinerary/rules/activity.ts +139 -0
  308. package/src/itinerary/rules/analysis.ts +42 -0
  309. package/src/itinerary/rules/ceiling.ts +49 -0
  310. package/src/itinerary/rules/createFlow.ts +107 -0
  311. package/src/itinerary/rules/densify.ts +440 -0
  312. package/src/itinerary/rules/draftSurface.ts +219 -0
  313. package/src/itinerary/rules/editorView.ts +83 -0
  314. package/src/itinerary/rules/export.ts +159 -0
  315. package/src/itinerary/rules/friendlyName.ts +77 -0
  316. package/src/itinerary/rules/import.ts +1050 -0
  317. package/src/itinerary/rules/importFiles.ts +140 -0
  318. package/src/itinerary/rules/importTotals.ts +77 -0
  319. package/src/itinerary/rules/liveSegment.ts +712 -0
  320. package/src/itinerary/rules/lngLat.ts +17 -0
  321. package/src/itinerary/rules/mapSync.ts +100 -0
  322. package/src/itinerary/rules/previewRender.ts +416 -0
  323. package/src/itinerary/rules/profileReadout.ts +216 -0
  324. package/src/itinerary/rules/routing.ts +707 -0
  325. package/src/itinerary/rules/suggest.ts +522 -0
  326. package/src/itinerary/rules/suggestionPreview.ts +119 -0
  327. package/src/itinerary/rules/view.ts +61 -0
  328. package/src/itinerary/stores/importSession.ts +319 -0
  329. package/src/itinerary/stores/itinerary.ts +331 -0
  330. package/src/itinerary/stores/itineraryDuplicate.ts +76 -0
  331. package/src/itinerary/stores/sessionIdentity.ts +43 -0
  332. package/src/itinerary/stores/suggestSession.ts +418 -0
  333. package/src/layers/contracts/itinerary.ts +46 -0
  334. package/src/layers/contracts/overlay.ts +132 -0
  335. package/src/layers/handlers/enrichment.ts +36 -0
  336. package/src/layers/handlers/overlay.ts +406 -0
  337. package/src/layers/handlers/restLayers.ts +94 -0
  338. package/src/layers/handlers/tiles.ts +25 -0
  339. package/src/layers/rules/layers.ts +212 -0
  340. package/src/layers/rules/overlayInstant.ts +12 -0
  341. package/src/layers/rules/reachabilityIcon.ts +18 -0
  342. package/src/layers/rules/readout.ts +102 -0
  343. package/src/layers/stores/layers.ts +262 -0
  344. package/src/map/contracts/contextmenu.ts +33 -0
  345. package/src/map/contracts/geolocate.ts +37 -0
  346. package/src/map/contracts/map.ts +146 -0
  347. package/src/map/contracts/streetview.ts +53 -0
  348. package/src/map/contracts/terrain.ts +152 -0
  349. package/src/map/handlers/contextMenu.ts +135 -0
  350. package/src/map/handlers/geolocate.ts +52 -0
  351. package/src/map/handlers/map.ts +391 -0
  352. package/src/map/handlers/streetview.ts +94 -0
  353. package/src/map/handlers/terrain.ts +663 -0
  354. package/src/map/rules/baseTerrain.ts +75 -0
  355. package/src/map/rules/clickTargets.ts +464 -0
  356. package/src/map/rules/constraints.ts +32 -0
  357. package/src/map/rules/contextMenuReadout.ts +67 -0
  358. package/src/map/rules/coordinates.ts +71 -0
  359. package/src/map/rules/itineraryFit.ts +8 -0
  360. package/src/map/rules/mapEvents.ts +64 -0
  361. package/src/map/rules/mapProjection.ts +476 -0
  362. package/src/map/rules/terrainReading.ts +62 -0
  363. package/src/plugins/contracts/ids.ts +66 -0
  364. package/src/plugins/contracts/plugin.ts +202 -0
  365. package/src/plugins/contracts/slots.ts +137 -0
  366. package/src/plugins/engines/studioPlugin.ts +1365 -0
  367. package/src/plugins/index.ts +111 -0
  368. package/src/plugins/rules/contributions.ts +152 -0
  369. package/src/plugins/rules/errors.ts +60 -0
  370. package/src/plugins/rules/ids.ts +42 -0
  371. package/src/plugins/rules/validation.ts +249 -0
  372. package/src/rules/listeners.ts +57 -0
  373. package/src/rules/origin.ts +13 -0
  374. package/src/rules/storeWrite.ts +37 -0
  375. package/src/rules/types.ts +136 -0
  376. package/src/seams/index.ts +79 -0
  377. package/src/seams/rules/clock.ts +28 -0
  378. package/src/seams/rules/formatters.ts +211 -0
  379. package/src/seams/rules/ids.ts +102 -0
  380. package/src/seams/rules/links.ts +66 -0
  381. package/src/seams/rules/navigation.ts +222 -0
  382. package/src/seams/rules/notify.ts +49 -0
  383. package/src/seams/rules/persistenceDrawer.ts +220 -0
  384. package/src/seams/rules/saveFile.ts +101 -0
  385. package/src/seams/rules/seams.ts +156 -0
  386. package/src/seams/rules/storage.ts +116 -0
  387. package/src/search/contracts/overlay.ts +74 -0
  388. package/src/search/contracts/search.ts +197 -0
  389. package/src/search/handlers/pois.ts +57 -0
  390. package/src/search/handlers/search.ts +280 -0
  391. package/src/search/rules/params.ts +925 -0
  392. package/src/search/rules/poiGroups.ts +138 -0
  393. package/src/search/rules/searchFetch.ts +139 -0
  394. package/src/search/rules/timeWindow.ts +30 -0
  395. package/src/search/stores/search.ts +51 -0
  396. package/src/segments/contracts/itinerary.ts +433 -0
  397. package/src/segments/contracts/segment.ts +35 -0
  398. package/src/segments/engines/segmentDraft.ts +926 -0
  399. package/src/segments/handlers/chainGuards.ts +67 -0
  400. package/src/segments/handlers/directions.ts +44 -0
  401. package/src/segments/handlers/itineraryEcho.ts +45 -0
  402. package/src/segments/handlers/roadAccessDialog.ts +34 -0
  403. package/src/segments/handlers/segment.ts +111 -0
  404. package/src/segments/handlers/segmentEdit.ts +1341 -0
  405. package/src/segments/handlers/segmentGroups.ts +347 -0
  406. package/src/segments/handlers/segmentStructure.ts +1144 -0
  407. package/src/segments/rules/chain.ts +196 -0
  408. package/src/segments/rules/chainModel.ts +217 -0
  409. package/src/segments/rules/colors.ts +11 -0
  410. package/src/segments/rules/commit.ts +76 -0
  411. package/src/segments/rules/draft.ts +90 -0
  412. package/src/segments/rules/draftDisposition.ts +43 -0
  413. package/src/segments/rules/draftSegmentEdit.ts +129 -0
  414. package/src/segments/rules/engine.ts +222 -0
  415. package/src/segments/rules/groupSave.ts +234 -0
  416. package/src/segments/rules/hazardPrompt.ts +60 -0
  417. package/src/segments/rules/itineraryEcho.ts +40 -0
  418. package/src/segments/rules/liveSegmentProjection.ts +55 -0
  419. package/src/segments/rules/merge.ts +51 -0
  420. package/src/segments/rules/metrics.ts +456 -0
  421. package/src/segments/rules/naming.ts +168 -0
  422. package/src/segments/rules/segmentArming.ts +144 -0
  423. package/src/segments/rules/splitPick.ts +84 -0
  424. package/src/segments/rules/viaSimplify.ts +230 -0
  425. package/src/segments/stores/directions.ts +77 -0
  426. package/src/segments/stores/roadAccessDialog.ts +58 -0
  427. package/src/segments/stores/segmentEdit.ts +922 -0
  428. package/src/segments/stores/segmentGroupEdit.ts +84 -0
  429. package/src/segments/stores/segmentSplit.ts +77 -0
  430. package/src/share/contracts/share.ts +39 -0
  431. package/src/share/contracts/shareLink.ts +63 -0
  432. package/src/share/engines/shareLink.ts +1053 -0
  433. package/src/share/handlers/share.ts +47 -0
  434. package/src/share/handlers/shareLink.ts +231 -0
  435. package/src/share/handlers/shareScope.ts +54 -0
  436. package/src/share/rules/link.ts +89 -0
  437. package/src/share/rules/shareLink.ts +218 -0
  438. package/src/share/rules/targets.ts +92 -0
  439. package/src/share/rules/viewConfig.ts +95 -0
  440. package/src/share/stores/share.ts +58 -0
  441. package/src/strings/fr/index.ts +18 -0
  442. package/src/strings/fr/rules/fr.ts +2368 -0
  443. package/src/strings/index.ts +98 -0
  444. package/src/strings/rules/confirmCopy.ts +156 -0
  445. package/src/strings/rules/draftToolNames.ts +94 -0
  446. package/src/strings/rules/en.ts +2519 -0
  447. package/src/strings/rules/failureAlert.ts +115 -0
  448. package/src/strings/rules/formError.ts +400 -0
  449. package/src/strings/rules/maneuvers.ts +107 -0
  450. package/src/strings/rules/outputOptions.ts +126 -0
  451. package/src/strings/rules/publicationState.ts +100 -0
  452. package/src/strings/rules/routeHazardCopy.ts +62 -0
  453. package/src/strings/rules/searchLabels.ts +50 -0
  454. package/src/strings/rules/segmentChainVerbs.ts +62 -0
  455. package/src/strings/rules/studioCopy.ts +130 -0
  456. package/src/strings/rules/unitOptions.ts +119 -0
  457. package/src/testing/checkedBus.ts +226 -0
  458. package/src/testing/index.ts +30 -0
  459. package/src/testing/plugins.ts +106 -0
  460. package/src/testing/studio.ts +267 -0
  461. package/src/testing/urlSeam.ts +153 -0
  462. package/src/time/index.ts +12 -0
  463. package/src/time/rules/sun.ts +78 -0
  464. package/src/video/contracts/cameraSchemas.ts +266 -0
  465. package/src/video/contracts/profileSchemas.ts +37 -0
  466. package/src/video/contracts/video.ts +601 -0
  467. package/src/video/handlers/video.ts +1638 -0
  468. package/src/video/handlers/videoDirector.ts +114 -0
  469. package/src/video/rules/previewRefresh.ts +76 -0
  470. package/src/video/rules/profileSource.ts +51 -0
  471. package/src/video/rules/routeSpans.ts +79 -0
  472. package/src/video/rules/shotDefaults.ts +28 -0
  473. package/src/video/rules/stepOrder.ts +17 -0
  474. package/src/video/rules/videoSnapshot.ts +136 -0
  475. package/src/video/stores/directorThreads.ts +167 -0
  476. package/src/video/stores/videoExport.ts +290 -0
  477. package/src/viewer/contracts/preferences.ts +40 -0
  478. package/src/viewer/handlers/preferences.ts +91 -0
  479. package/src/viewer/rules/capabilities.ts +42 -0
  480. package/src/viewer/rules/config.ts +266 -0
  481. package/src/viewer/rules/context.ts +375 -0
  482. package/src/viewer/rules/ownership.ts +134 -0
  483. package/src/viewer/rules/platformViewer.ts +199 -0
  484. package/src/viewer/rules/scope.ts +197 -0
  485. package/src/viewer/rules/url.ts +145 -0
  486. package/src/viewer/rules/viewer.ts +307 -0
  487. package/src/viewer/rules/viewerSeam.ts +49 -0
  488. package/src/viewer/rules/viewerUnits.ts +34 -0
  489. package/src/waypoints/contracts/itinerary.ts +417 -0
  490. package/src/waypoints/handlers/poiWaypointStyle.ts +32 -0
  491. package/src/waypoints/handlers/waypointDetailsDialog.ts +38 -0
  492. package/src/waypoints/handlers/waypointEdit.ts +1073 -0
  493. package/src/waypoints/rules/amenities.ts +30 -0
  494. package/src/waypoints/rules/defaults.ts +31 -0
  495. package/src/waypoints/rules/details.ts +213 -0
  496. package/src/waypoints/rules/detailsDraft.ts +312 -0
  497. package/src/waypoints/rules/detailsPreview.ts +76 -0
  498. package/src/waypoints/rules/detailsSave.ts +356 -0
  499. package/src/waypoints/rules/draftDirty.ts +45 -0
  500. package/src/waypoints/rules/icons.ts +32 -0
  501. package/src/waypoints/rules/liveWaypoint.ts +63 -0
  502. package/src/waypoints/rules/naming.ts +185 -0
  503. package/src/waypoints/rules/sections.ts +77 -0
  504. package/src/waypoints/rules/waypointDraft.ts +62 -0
  505. package/src/waypoints/stores/waypointDetails.ts +62 -0
  506. package/src/waypoints/stores/waypointEdit.ts +566 -0
  507. package/src/zones/contracts/collection.ts +37 -0
  508. package/src/zones/contracts/zone.ts +528 -0
  509. package/src/zones/engines/zoneForm.ts +1773 -0
  510. package/src/zones/handlers/restZones.ts +287 -0
  511. package/src/zones/handlers/zonePublish.ts +206 -0
  512. package/src/zones/handlers/zoneUnpublish.ts +56 -0
  513. package/src/zones/handlers/zones.ts +2254 -0
  514. package/src/zones/rules/geometry.ts +946 -0
  515. package/src/zones/rules/zoneDefaults.ts +34 -0
  516. package/src/zones/rules/zoneDraft.ts +54 -0
  517. package/src/zones/rules/zoneForm.ts +563 -0
  518. package/src/zones/rules/zoneMetadata.ts +29 -0
  519. package/src/zones/rules/zoneSource.ts +87 -0
  520. package/src/zones/rules/zoneSourceRefusal.ts +104 -0
  521. package/src/zones/stores/zoneEdit.ts +998 -0
@@ -0,0 +1,2581 @@
1
+ import { r as isConfirmationWithheld } from "../chunk-p-Tt_Lwz.js";
2
+ import { a as failureFromThrown } from "../chunk-DKuuuld5.js";
3
+ import { Kt as defaultSegmentName, f as agentHandoffTarget, h as studioToolContracts, m as selectSuggestionSession, sn as questionToolContracts } from "../chunk-DMePkFEo.js";
4
+ import { c as buildStudioSnapshot, o as SEARCH_TAB_ID } from "../chunk-DwoUyHHh.js";
5
+ import { n as surfaceFault, t as notifyListeners } from "../chunk-BTUUABGI.js";
6
+ import { n as confirmSentence } from "../chunk-Dmszv9If.js";
7
+ import { t as layerToolContext } from "../chunk-3Oi_Zrtm.js";
8
+ import { r as buildVideoSnapshot, t as createVideoDirectorStore } from "../chunk-CwkmccXv.js";
9
+ import * as z$1 from "zod";
10
+ import { boundsOf } from "@mountaya/elements/geo";
11
+ import { createStore } from "zustand/vanilla";
12
+ import { AgentEngine, accumulateAssistant, answerQuestionEntry, appendActivityEntry, appendErrorEntry, appendQuestionEntry, appendSuggestionsEntry, appendUserEntry, appendWarningEntry, boundedInputJson, chooseSuggestionEntry, createConversationFaults, createConversationHost, replaceAssistant, resolveAgentError, settleActivityEntry, settleOpenQuestionEntries, settleOpenSuggestionEntries } from "@mountaya/elements/agent";
13
+ const editingOf = (ui) => {
14
+ if (ui.segmentEditSession) return [ui.segmentEditSession.segmentId ?? null, "segment"];
15
+ if (ui.waypointEditSession) return [ui.waypointEditSession.waypointId ?? null, "waypoint"];
16
+ if (ui.zoneEditSession) return [ui.zoneEditSession.zoneId ?? null, "zone"];
17
+ return [null, null];
18
+ };
19
+ const captureStudioState = (ctx) => {
20
+ const ui = ctx.ui.getState();
21
+ const itinerary = ui.activeItinerary;
22
+ const [editingId, editingKind] = editingOf(ui);
23
+ return {
24
+ activeOverlay: ui.activeOverlay ?? null,
25
+ editingId,
26
+ editingKind,
27
+ itineraryId: itinerary?.id ?? null,
28
+ itineraryName: itinerary?.name ?? null,
29
+ segmentCount: itinerary?.segments.length ?? 0,
30
+ selectionId: ui.selection?.id ?? null,
31
+ selectionKind: ui.selection?.kind ?? null,
32
+ waypointCount: itinerary?.waypoints.length ?? 0
33
+ };
34
+ };
35
+ const diffStudioState = (before, after) => {
36
+ const delta = {};
37
+ let changed = false;
38
+ for (const key of Object.keys(after)) if (before[key] !== after[key]) {
39
+ Object.assign(delta, { [key]: after[key] });
40
+ changed = true;
41
+ }
42
+ return changed ? delta : void 0;
43
+ };
44
+ const segmentTargetSchema = z$1.object({ segmentId: z$1.string().min(1) });
45
+ const waypointTargetSchema = z$1.object({ waypointId: z$1.string().min(1) });
46
+ const contracts = studioToolContracts;
47
+ const agentEditLockTarget = (name, input) => {
48
+ if (contracts[name]?.capability !== "editor") return null;
49
+ const segment = segmentTargetSchema.safeParse(input);
50
+ if (segment.success) return {
51
+ id: segment.data.segmentId,
52
+ kind: "segment"
53
+ };
54
+ const waypoint = waypointTargetSchema.safeParse(input);
55
+ if (waypoint.success) return {
56
+ id: waypoint.data.waypointId,
57
+ kind: "waypoint"
58
+ };
59
+ return null;
60
+ };
61
+ const agentHandoffTools = /* @__PURE__ */ new Set(["studio.itinerary.segment.editPropose", "studio.itinerary.waypoint.editPropose"]);
62
+ const agentTakesEntityBack = (name, input) => !agentHandoffTools.has(name) && agentEditLockTarget(name, input) !== null;
63
+ const copilotOrganizationId = (state) => {
64
+ if (state.activeItinerary) return state.activeItinerary.organization_id;
65
+ if (state.activeZone) return state.activeZone.organization_id;
66
+ return state.zoneEditSession?.intent === "create" ? state.zoneEditSession.organizationId : void 0;
67
+ };
68
+ const routerStateFrom = (ctx) => {
69
+ const ui = ctx.ui.getState();
70
+ const editSession = ui.segmentEditSession ? "segment" : ui.waypointEditSession ? "waypoint" : ui.zoneEditSession ? "zone" : null;
71
+ const openResource = ui.activeZone !== null ? "zone" : ui.activeItinerary !== null ? "itinerary" : null;
72
+ return {
73
+ editSession,
74
+ importDraft: ui.importSession !== null,
75
+ openResource,
76
+ suggestDraft: ui.suggestSession !== null,
77
+ videoOpen: ui.videoExport !== null
78
+ };
79
+ };
80
+ const compareIds = (a, b) => {
81
+ if (a === b) return 0;
82
+ return a < b ? -1 : 1;
83
+ };
84
+ const createStudioRouter = ({ playbook, skillRoutes, surfaceLocks, surfaces: surfaceTable }) => {
85
+ const wideFallbackSurfaces = () => surfaceTable.filter((surface) => surface.wideFallback).map((surface) => surface.id);
86
+ const alwaysOn = () => surfaceTable.filter((surface) => surface.always).map((surface) => surface.id);
87
+ const lockHolds = (lock, state) => state[lock.field] === lock.equals;
88
+ const MAX_TASK_SURFACES = 2;
89
+ const MAX_CARRIED_SURFACES = 4;
90
+ const foldApostrophes = (message) => message.replace(/’/g, "'");
91
+ const matchSkillRoutes = (message) => {
92
+ const lowered = message.toLowerCase();
93
+ const hits = skillRoutes.map((route) => ({
94
+ matches: route.intents.filter((intent) => intent !== "" && lowered.includes(intent)).length,
95
+ route
96
+ })).filter((entry) => entry.matches > 0).sort((a, b) => b.matches - a.matches || compareIds(a.route.id, b.route.id)).slice(0, 3);
97
+ const surfaces = [];
98
+ for (const hit of hits) for (const id of hit.route.surfaces) {
99
+ if (surfaces.length >= MAX_CARRIED_SURFACES) return surfaces;
100
+ if (!surfaces.includes(id)) surfaces.push(id);
101
+ }
102
+ return surfaces;
103
+ };
104
+ const surfacePatterns = new Map(surfaceTable.map((surface) => [surface.id, surface.keywords.map((keyword) => new RegExp(`(?<![\\p{L}_])${keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\p{L}\\p{N}_])`, "iu"))]));
105
+ const scoreSurface = (surface, message) => {
106
+ let score = 0;
107
+ for (const pattern of surfacePatterns.get(surface.id) ?? []) if (pattern.test(message)) score += 1;
108
+ return score;
109
+ };
110
+ const selectSurfaces = (message, state = {}, previous = []) => {
111
+ const core = alwaysOn();
112
+ const known = new Set(surfaceTable.map((surface) => surface.id));
113
+ const folded = foldApostrophes(message);
114
+ 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);
115
+ const skillDriven = matchSkillRoutes(folded).filter((id) => known.has(id) && !core.includes(id));
116
+ const keywordMatched = surfaceTable.filter((surface) => !surface.always && surface.keywords.length > 0).map((surface) => ({
117
+ id: surface.id,
118
+ score: scoreSurface(surface, folded)
119
+ })).filter((entry) => entry.score > 0).sort((a, b) => b.score - a.score || compareIds(a.id, b.id)).slice(0, MAX_TASK_SURFACES).map((entry) => entry.id);
120
+ const matched = [];
121
+ for (const id of [
122
+ ...locked,
123
+ ...skillDriven,
124
+ ...keywordMatched
125
+ ]) {
126
+ if (matched.length >= MAX_CARRIED_SURFACES) break;
127
+ if (!matched.includes(id)) matched.push(id);
128
+ }
129
+ let carried = previous.filter((id) => known.has(id) && !core.includes(id));
130
+ if (carried.length > MAX_CARRIED_SURFACES) carried = [];
131
+ if (matched.length === 0) {
132
+ if (carried.length > 0) return {
133
+ reason: "sticky",
134
+ surfaces: [...core, ...carried]
135
+ };
136
+ return {
137
+ reason: "wide",
138
+ surfaces: wideFallbackSurfaces()
139
+ };
140
+ }
141
+ if (carried.length > 0 && matched.every((id) => carried.includes(id))) return {
142
+ reason: "sticky",
143
+ surfaces: [...core, ...carried]
144
+ };
145
+ let reason = "intent";
146
+ if (locked.length > 0) reason = "lock";
147
+ else if (skillDriven.length > 0) reason = "skill";
148
+ return {
149
+ reason,
150
+ surfaces: [...core, ...matched]
151
+ };
152
+ };
153
+ const surfaceTools = (surfaces) => {
154
+ const wanted = new Set(surfaces);
155
+ const tools = /* @__PURE__ */ new Set();
156
+ for (const surface of surfaceTable) {
157
+ if (!wanted.has(surface.id)) continue;
158
+ for (const member of surface.members) tools.add(member);
159
+ }
160
+ return tools;
161
+ };
162
+ const recoveryFor = (tool, code) => {
163
+ if (!code) return;
164
+ return playbook.find((entry) => entry.id === tool)?.recovery.find((item) => item.code === code)?.do;
165
+ };
166
+ return {
167
+ recoveryFor,
168
+ selectSurfaces,
169
+ surfaceTools
170
+ };
171
+ };
172
+ const studioStateDelta = {
173
+ capture: captureStudioState,
174
+ diff: diffStudioState
175
+ };
176
+ const PLAYBOOK = [
177
+ {
178
+ confirms: false,
179
+ 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.",
180
+ id: "analyzeGeometry",
181
+ kind: "read",
182
+ recovery: [{
183
+ code: "invalid-input",
184
+ 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."
185
+ }],
186
+ surfaces: ["routing"]
187
+ },
188
+ {
189
+ confirms: false,
190
+ description: "Run a raw read-only GraphQL query against the Data API. Typed operation first, and anything else only when none of them fits.",
191
+ id: "data.query",
192
+ kind: "read",
193
+ recovery: [{
194
+ code: "invalid-input",
195
+ do: "Do not iterate on the syntax. Switch to the typed operation that covers the question."
196
+ }, {
197
+ code: "forbidden",
198
+ do: "The query attempted a write or an unpermitted root field. It will not succeed rewritten."
199
+ }],
200
+ surfaces: ["advanced"]
201
+ },
202
+ {
203
+ confirms: false,
204
+ 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.",
205
+ id: "directions.compute",
206
+ kind: "read",
207
+ recovery: [
208
+ {
209
+ code: "invalid-input",
210
+ do: "Check dimensionality and coordinate order, then retry once."
211
+ },
212
+ {
213
+ code: "not-found",
214
+ do: "Report it as a real answer, not a failure. The network may genuinely not connect them for this activity."
215
+ },
216
+ {
217
+ code: "rate-limited",
218
+ do: "Stop computing alternatives and report what you have."
219
+ }
220
+ ],
221
+ surfaces: ["routing"]
222
+ },
223
+ {
224
+ confirms: false,
225
+ 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.",
226
+ id: "isochrones",
227
+ kind: "read",
228
+ recovery: [{
229
+ code: "invalid-input",
230
+ do: "Reduce the budget and retry once. Very large ranges are refused rather than truncated."
231
+ }, {
232
+ code: "upgrade-required",
233
+ do: "The organization does not hold the Data API. Say so; do not retry."
234
+ }],
235
+ surfaces: ["zones"]
236
+ },
237
+ {
238
+ confirms: false,
239
+ 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.",
240
+ id: "matrix",
241
+ kind: "read",
242
+ recovery: [{
243
+ code: "invalid-input",
244
+ do: "Indices are into the locations array. Rebuild them and retry once with fewer points."
245
+ }, {
246
+ code: "rate-limited",
247
+ do: "Stop. Rank what you already have rather than waiting."
248
+ }],
249
+ surfaces: ["routing"]
250
+ },
251
+ {
252
+ capability: "authenticated",
253
+ confirms: false,
254
+ description: "Resolve a named place to coordinates. Named place, free text, category, or \"propose me something\".",
255
+ id: "studio.data.geocode",
256
+ kind: "read",
257
+ recovery: [{
258
+ code: "not-found",
259
+ do: "No place by that name. Try search, which matches loosely, before telling the user it does not exist."
260
+ }, {
261
+ code: "rate-limited",
262
+ do: "Stop looking things up. Work with what you have and say so."
263
+ }],
264
+ surfaces: ["discovery"]
265
+ },
266
+ {
267
+ capability: "authenticated",
268
+ confirms: false,
269
+ description: "List points of interest of a category within an area. Named place, free text, category, or \"propose me something\".",
270
+ id: "studio.data.pois",
271
+ kind: "read",
272
+ recovery: [{
273
+ code: "invalid-input",
274
+ do: "A bbox is [minLongitude, minLatitude, maxLongitude, maxLatitude]. Rebuild it and retry once."
275
+ }],
276
+ surfaces: ["discovery"]
277
+ },
278
+ {
279
+ capability: "authenticated",
280
+ confirms: false,
281
+ description: "Name the place at a coordinate. Named place, free text, category, or \"propose me something\".",
282
+ id: "studio.data.reverseGeocode",
283
+ kind: "read",
284
+ recovery: [{
285
+ code: "not-found",
286
+ do: "Nothing named there. Describe the point by its position on the route instead."
287
+ }],
288
+ surfaces: ["discovery"]
289
+ },
290
+ {
291
+ capability: "authenticated",
292
+ confirms: false,
293
+ 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\".",
294
+ id: "studio.data.search",
295
+ kind: "read",
296
+ recovery: [{
297
+ code: "rate-limited",
298
+ do: "Stop searching. Report what you have already found."
299
+ }],
300
+ surfaces: ["discovery"]
301
+ },
302
+ {
303
+ capability: "editor",
304
+ confirms: false,
305
+ 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.",
306
+ id: "studio.itinerary.duplicate",
307
+ kind: "mutate",
308
+ recovery: [
309
+ {
310
+ code: "draft-open",
311
+ 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."
312
+ },
313
+ {
314
+ code: "invalid-input",
315
+ do: "Re-read the itinerary and keep an unbroken stretch, or leave segmentIds and waypointIds out to copy it whole, before retrying once."
316
+ },
317
+ {
318
+ code: "upgrade-required",
319
+ 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."
320
+ },
321
+ {
322
+ code: "forbidden",
323
+ do: "Report which organization was refused and offer the ones they can write to, then stop."
324
+ },
325
+ {
326
+ code: "conflict",
327
+ 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."
328
+ },
329
+ {
330
+ code: "limit-reached",
331
+ do: "The personal space is full. Say so and stop; do not retry, and do not copy the itinerary elsewhere unless the user asks."
332
+ }
333
+ ],
334
+ surfaces: ["authoring"]
335
+ },
336
+ {
337
+ capability: "authenticated",
338
+ confirms: false,
339
+ description: "Read the open itinerary: its segments, waypoints, and elevation summary. The narrowest read that answers the question.",
340
+ id: "studio.itinerary.getActive",
341
+ kind: "read",
342
+ recovery: [{
343
+ code: "not-found",
344
+ do: "No itinerary is open. Ask the user to open one rather than creating one uninvited."
345
+ }],
346
+ surfaces: ["core"]
347
+ },
348
+ {
349
+ capability: "editor",
350
+ confirms: false,
351
+ 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.",
352
+ id: "studio.itinerary.group.create",
353
+ kind: "mutate",
354
+ recovery: [
355
+ {
356
+ code: "draft-open",
357
+ do: "A proposal has no stored segments to group. Tell the user to save or discard the draft first, and stop."
358
+ },
359
+ {
360
+ code: "invalid-input",
361
+ do: "Re-read the itinerary, pick neighbours in chain order, and retry once."
362
+ },
363
+ {
364
+ code: "conflict",
365
+ 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."
366
+ },
367
+ {
368
+ code: "collab-locked",
369
+ do: "Report who holds it and stop. Grouping is serialized to one editor at a time."
370
+ },
371
+ {
372
+ code: "not-found",
373
+ do: "Re-read the itinerary; the chain changed underneath you."
374
+ },
375
+ {
376
+ code: "upgrade-required",
377
+ 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."
378
+ }
379
+ ],
380
+ surfaces: ["authoring"]
381
+ },
382
+ {
383
+ capability: "editor",
384
+ confirms: false,
385
+ 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.",
386
+ id: "studio.itinerary.group.delete",
387
+ kind: "mutate",
388
+ recovery: [
389
+ {
390
+ code: "draft-open",
391
+ do: "A proposal carries no stored groups. Tell the user to save or discard the draft first, and stop."
392
+ },
393
+ {
394
+ code: "collab-locked",
395
+ do: "Report who holds it and stop. Group edits are serialized to one editor at a time."
396
+ },
397
+ {
398
+ code: "conflict",
399
+ 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."
400
+ },
401
+ {
402
+ code: "not-found",
403
+ 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."
404
+ },
405
+ {
406
+ code: "upgrade-required",
407
+ 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."
408
+ }
409
+ ],
410
+ surfaces: ["authoring"]
411
+ },
412
+ {
413
+ capability: "editor",
414
+ confirms: false,
415
+ description: "Change which run of segments an existing group covers. Not for renaming or recolouring; that is studio.itinerary.group.update.",
416
+ id: "studio.itinerary.group.setRange",
417
+ kind: "mutate",
418
+ recovery: [
419
+ {
420
+ code: "draft-open",
421
+ do: "A proposal carries no stored groups. Tell the user to save or discard the draft first, and stop."
422
+ },
423
+ {
424
+ code: "invalid-input",
425
+ 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."
426
+ },
427
+ {
428
+ code: "collab-locked",
429
+ do: "Report who holds it and stop. Group edits are serialized to one editor at a time."
430
+ },
431
+ {
432
+ code: "conflict",
433
+ 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."
434
+ },
435
+ {
436
+ code: "not-found",
437
+ do: "Re-read the itinerary; the chain changed underneath you."
438
+ },
439
+ {
440
+ code: "upgrade-required",
441
+ 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."
442
+ }
443
+ ],
444
+ surfaces: ["authoring"]
445
+ },
446
+ {
447
+ capability: "editor",
448
+ confirms: false,
449
+ 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.",
450
+ id: "studio.itinerary.group.update",
451
+ kind: "mutate",
452
+ recovery: [
453
+ {
454
+ code: "draft-open",
455
+ do: "A proposal carries no stored groups. Tell the user to save or discard the draft first, and stop."
456
+ },
457
+ {
458
+ code: "invalid-input",
459
+ 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."
460
+ },
461
+ {
462
+ code: "collab-locked",
463
+ do: "Report who holds it and stop. Group edits are serialized to one editor at a time."
464
+ },
465
+ {
466
+ code: "conflict",
467
+ 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."
468
+ },
469
+ {
470
+ code: "not-found",
471
+ do: "Re-read the itinerary; it may have been dissolved underneath you."
472
+ },
473
+ {
474
+ code: "upgrade-required",
475
+ 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."
476
+ }
477
+ ],
478
+ surfaces: ["authoring"]
479
+ },
480
+ {
481
+ capability: "editor",
482
+ confirms: false,
483
+ description: "Append a new routed segment to the end of the open itinerary, through 2–45 vias. Ask when they have not said which, and where. A wrong guess rewrites their work.",
484
+ id: "studio.itinerary.segment.create",
485
+ kind: "mutate",
486
+ recovery: [
487
+ {
488
+ code: "invalid-input",
489
+ do: "Coordinates are [longitude, latitude], longitude first. Simplify to the working range and retry once."
490
+ },
491
+ {
492
+ code: "conflict",
493
+ 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."
494
+ },
495
+ {
496
+ code: "collab-locked",
497
+ do: "Report who holds it and stop."
498
+ },
499
+ {
500
+ code: "upgrade-required",
501
+ 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."
502
+ }
503
+ ],
504
+ surfaces: ["routing"]
505
+ },
506
+ {
507
+ capability: "editor",
508
+ confirms: false,
509
+ 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.",
510
+ id: "studio.itinerary.segment.editPropose",
511
+ kind: "propose",
512
+ recovery: [
513
+ {
514
+ code: "edit-in-progress",
515
+ do: "Read the live draft. Iterate on it rather than starting a new one."
516
+ },
517
+ {
518
+ code: "collab-locked",
519
+ do: "Report who holds it and stop. Retrying will not acquire the lock."
520
+ },
521
+ {
522
+ code: "conflict",
523
+ do: "Re-read the itinerary and rebuild the proposal against the current revision."
524
+ },
525
+ {
526
+ code: "invalid-input",
527
+ do: "Coordinates are [longitude, latitude], longitude first, and the cap is 45. Reduce to the working range of two to six and retry once."
528
+ }
529
+ ],
530
+ surfaces: ["routing"]
531
+ },
532
+ {
533
+ capability: "editor",
534
+ confirms: false,
535
+ 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.",
536
+ id: "studio.itinerary.segment.insert",
537
+ kind: "mutate",
538
+ recovery: [
539
+ {
540
+ code: "draft-open",
541
+ do: "A proposal has nothing to insert into. Tell the user to save or discard the draft first, and stop."
542
+ },
543
+ {
544
+ code: "invalid-input",
545
+ 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."
546
+ },
547
+ {
548
+ code: "collab-locked",
549
+ do: "Report who holds it and stop."
550
+ },
551
+ {
552
+ code: "upgrade-required",
553
+ 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."
554
+ },
555
+ {
556
+ code: "forbidden",
557
+ do: "Report which organization refused the edit and stop. Nothing changed."
558
+ },
559
+ {
560
+ code: "conflict",
561
+ 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."
562
+ }
563
+ ],
564
+ surfaces: ["routing"]
565
+ },
566
+ {
567
+ capability: "editor",
568
+ confirms: true,
569
+ 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.",
570
+ id: "studio.itinerary.segment.merge",
571
+ kind: "mutate",
572
+ recovery: [
573
+ {
574
+ code: "draft-open",
575
+ do: "A proposal has no stored segments to join. Tell the user to save or discard the draft first, and stop."
576
+ },
577
+ {
578
+ code: "invalid-input",
579
+ 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."
580
+ },
581
+ {
582
+ code: "collab-locked",
583
+ do: "Report who holds it and stop. Both segments must be free to merge."
584
+ },
585
+ {
586
+ code: "conflict",
587
+ 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."
588
+ },
589
+ {
590
+ code: "upgrade-required",
591
+ 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."
592
+ }
593
+ ],
594
+ surfaces: ["routing"]
595
+ },
596
+ {
597
+ capability: "editor",
598
+ confirms: true,
599
+ 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.",
600
+ id: "studio.itinerary.segment.setMode",
601
+ kind: "mutate",
602
+ recovery: [
603
+ {
604
+ code: "draft-open",
605
+ do: "A proposal has no stored segment whose engine could change. Tell the user to save or discard the draft first, and stop."
606
+ },
607
+ {
608
+ code: "invalid-input",
609
+ 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."
610
+ },
611
+ {
612
+ code: "collab-locked",
613
+ do: "Report who holds it and stop."
614
+ },
615
+ {
616
+ code: "conflict",
617
+ 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."
618
+ },
619
+ {
620
+ code: "internal",
621
+ do: "The segment is unchanged. Report the failure and retry once at most."
622
+ },
623
+ {
624
+ code: "upgrade-required",
625
+ 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."
626
+ }
627
+ ],
628
+ surfaces: ["routing"]
629
+ },
630
+ {
631
+ capability: "editor",
632
+ confirms: true,
633
+ 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.",
634
+ id: "studio.itinerary.segment.split",
635
+ kind: "mutate",
636
+ recovery: [
637
+ {
638
+ code: "draft-open",
639
+ do: "A proposal has no stored segment to cut. Tell the user to save or discard the draft first, and stop."
640
+ },
641
+ {
642
+ code: "invalid-input",
643
+ do: "Pick a point further from both ends and retry once."
644
+ },
645
+ {
646
+ code: "collab-locked",
647
+ do: "Report who holds it and stop."
648
+ },
649
+ {
650
+ code: "upgrade-required",
651
+ 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."
652
+ },
653
+ {
654
+ code: "forbidden",
655
+ do: "Report which organization refused the edit and stop. Nothing changed."
656
+ },
657
+ {
658
+ code: "conflict",
659
+ 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."
660
+ }
661
+ ],
662
+ surfaces: ["routing"]
663
+ },
664
+ {
665
+ capability: "editor",
666
+ confirms: false,
667
+ 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.",
668
+ id: "studio.itinerary.segment.updateGeometry",
669
+ kind: "mutate",
670
+ recovery: [{
671
+ code: "capability-denied",
672
+ do: "Expected. Propose the edit instead."
673
+ }],
674
+ surfaces: ["routing"]
675
+ },
676
+ {
677
+ capability: "authenticated",
678
+ confirms: false,
679
+ description: "Read the map viewport: centre, zoom, bearing, and pitch. The narrowest read that answers the question.",
680
+ id: "studio.map.getView",
681
+ kind: "read",
682
+ recovery: [{
683
+ code: "internal",
684
+ do: "The map is not ready. Proceed without it and bound your work by the itinerary instead."
685
+ }],
686
+ surfaces: ["core"]
687
+ },
688
+ {
689
+ capability: "authenticated",
690
+ confirms: false,
691
+ 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.",
692
+ id: "studio.overlay.listAvailable",
693
+ kind: "read",
694
+ recovery: [{
695
+ code: "internal",
696
+ 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."
697
+ }],
698
+ surfaces: ["terrain"]
699
+ },
700
+ {
701
+ capability: "embedding",
702
+ confirms: false,
703
+ 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.",
704
+ id: "studio.overlay.set",
705
+ kind: "mutate",
706
+ recovery: [
707
+ {
708
+ code: "invalid-input",
709
+ do: "Call studio.overlay.listAvailable and pick from the catalog it returns."
710
+ },
711
+ {
712
+ code: "capability-denied",
713
+ do: "The caller cannot change overlays. Report what you found in words instead."
714
+ },
715
+ {
716
+ code: "upgrade-required",
717
+ do: "Report what you found in words instead, and say overlays are not available in this scope. Do not retry."
718
+ }
719
+ ],
720
+ surfaces: ["terrain"]
721
+ },
722
+ {
723
+ capability: "authenticated",
724
+ confirms: false,
725
+ description: "Read what is currently selected. The narrowest read that answers the question.",
726
+ id: "studio.selection.get",
727
+ kind: "read",
728
+ recovery: [{
729
+ code: "capability-denied",
730
+ do: "The caller cannot read the studio. Ask the user what they meant instead."
731
+ }],
732
+ surfaces: ["core"]
733
+ },
734
+ {
735
+ capability: "authenticated",
736
+ confirms: false,
737
+ 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.",
738
+ id: "studio.share.open",
739
+ kind: "navigate",
740
+ recovery: [
741
+ {
742
+ code: "forbidden",
743
+ do: "Report why rather than retrying. There is no second route to a link."
744
+ },
745
+ {
746
+ code: "not-found",
747
+ do: "Re-read the itineraries or collections the user can see and confirm which one they meant."
748
+ },
749
+ {
750
+ code: "capability-denied",
751
+ do: "The caller cannot open studio dialogs. Say the link has to be made from the studio."
752
+ }
753
+ ],
754
+ surfaces: ["sharing", "collections"]
755
+ },
756
+ {
757
+ capability: "authenticated",
758
+ confirms: false,
759
+ description: "Read the whole studio state: itinerary, open zone, selection, open edit draft, overlays, viewport, preferences. The narrowest read that answers the question.",
760
+ id: "studio.state.get",
761
+ kind: "read",
762
+ recovery: [{
763
+ code: "internal",
764
+ do: "Fall back to the narrow reads (selection, viewport, active itinerary) and proceed with what you can establish."
765
+ }],
766
+ surfaces: ["core"]
767
+ },
768
+ {
769
+ confirms: false,
770
+ description: "Propose candidate routes matching activity, distance, and ascent constraints. Named place, free text, category, or \"propose me something\".",
771
+ id: "suggestions",
772
+ kind: "read",
773
+ recovery: [
774
+ {
775
+ code: "not-found",
776
+ do: "No candidates fit. Loosen the tightest constraint once, then report that the ask is too narrow."
777
+ },
778
+ {
779
+ code: "invalid-input",
780
+ 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."
781
+ },
782
+ {
783
+ code: "upgrade-required",
784
+ do: "The organization does not hold the Data API. Say so; do not retry."
785
+ }
786
+ ],
787
+ surfaces: ["discovery"]
788
+ },
789
+ {
790
+ confirms: false,
791
+ 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.",
792
+ id: "terrainGrid",
793
+ kind: "read",
794
+ recovery: [
795
+ {
796
+ code: "invalid-input",
797
+ do: "The box may cover at most 100 km²: 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."
798
+ },
799
+ {
800
+ code: "rate-limited",
801
+ do: "Stop sampling. Report what you already have rather than waiting."
802
+ },
803
+ {
804
+ code: "upgrade-required",
805
+ do: "The organization does not hold the Data API. Say so; do not retry."
806
+ }
807
+ ],
808
+ surfaces: ["terrain"]
809
+ },
810
+ {
811
+ confirms: false,
812
+ description: "Sample the surface at a fixed interval along a geometry. A few known points, along a known line, or over an unknown area.",
813
+ id: "terrainProfile",
814
+ kind: "read",
815
+ recovery: [{
816
+ code: "invalid-input",
817
+ 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."
818
+ }, {
819
+ code: "rate-limited",
820
+ do: "Stop sampling. Report what you already have rather than waiting."
821
+ }],
822
+ surfaces: ["terrain"]
823
+ },
824
+ {
825
+ confirms: false,
826
+ description: "Sample elevation, slope, and aspect at specific coordinates. A few known points, along a known line, or over an unknown area.",
827
+ id: "terrainSamples",
828
+ kind: "read",
829
+ recovery: [{
830
+ code: "invalid-input",
831
+ do: "Coordinates are [longitude, latitude], longitude first. Split the batch and retry once."
832
+ }, {
833
+ code: "upgrade-required",
834
+ do: "The organization does not hold the Data API. Say so; do not retry."
835
+ }],
836
+ surfaces: ["terrain"]
837
+ }
838
+ ];
839
+ const SURFACES = [
840
+ {
841
+ always: true,
842
+ id: "core",
843
+ keywords: [],
844
+ members: [
845
+ "studio.alert.dismiss",
846
+ "studio.alert.show",
847
+ "studio.itinerary.getActive",
848
+ "studio.map.applyCamera",
849
+ "studio.map.fitBounds",
850
+ "studio.map.fitBoundsOrFly",
851
+ "studio.map.fitBoundsToSegment",
852
+ "studio.map.getView",
853
+ "studio.map.resetNorth",
854
+ "studio.map.zoomIn",
855
+ "studio.map.zoomOut",
856
+ "studio.overlay.getActive",
857
+ "studio.panel.close",
858
+ "studio.panel.toggle",
859
+ "studio.preferences.set",
860
+ "studio.question.ask",
861
+ "studio.selection.get",
862
+ "studio.sidenav.back",
863
+ "studio.state.get",
864
+ "studio.tabs.close",
865
+ "studio.tabs.create",
866
+ "studio.tabs.open",
867
+ "studio.tabs.switch"
868
+ ],
869
+ purpose: "Read the world, move the map, talk to the user. Needed by every run.",
870
+ title: "Core",
871
+ wideFallback: true
872
+ },
873
+ {
874
+ always: false,
875
+ id: "routing",
876
+ keywords: [
877
+ "reroute",
878
+ "via",
879
+ "waypoint order",
880
+ "steeper",
881
+ "flatter",
882
+ "avoid",
883
+ "detour",
884
+ "shorter",
885
+ "longer",
886
+ "how long",
887
+ "compare",
888
+ "split",
889
+ "cut",
890
+ "merge",
891
+ "join",
892
+ "insert",
893
+ "freehand",
894
+ "routed",
895
+ "engine",
896
+ "évite",
897
+ "éviter",
898
+ "contourne",
899
+ "contourner",
900
+ "détour",
901
+ "passe par",
902
+ "passer par",
903
+ "plus court",
904
+ "plus courte",
905
+ "plus long",
906
+ "plus longue",
907
+ "plus raide",
908
+ "moins raide",
909
+ "raccourci",
910
+ "tracé",
911
+ "couper",
912
+ "scinder",
913
+ "fusionner",
914
+ "joindre",
915
+ "insérer",
916
+ "tracé libre",
917
+ "moteur"
918
+ ],
919
+ members: [
920
+ "analyzeGeometry",
921
+ "directions.compute",
922
+ "matrix",
923
+ "studio.itinerary.directions.close",
924
+ "studio.itinerary.directions.open",
925
+ "studio.itinerary.segment.create",
926
+ "studio.itinerary.segment.editBegin",
927
+ "studio.itinerary.segment.editCancel",
928
+ "studio.itinerary.segment.editCommit",
929
+ "studio.itinerary.segment.editPropose",
930
+ "studio.itinerary.segment.editRedo",
931
+ "studio.itinerary.segment.editUndo",
932
+ "studio.itinerary.segment.insert",
933
+ "studio.itinerary.segment.insertBegin",
934
+ "studio.itinerary.segment.merge",
935
+ "studio.itinerary.segment.recolor",
936
+ "studio.itinerary.segment.remove",
937
+ "studio.itinerary.segment.rename",
938
+ "studio.itinerary.segment.roadAccessClose",
939
+ "studio.itinerary.segment.roadAccessOpen",
940
+ "studio.itinerary.segment.select",
941
+ "studio.itinerary.segment.setMode",
942
+ "studio.itinerary.segment.setSpeed",
943
+ "studio.itinerary.segment.split",
944
+ "studio.itinerary.segment.splitPickBegin",
945
+ "studio.itinerary.segment.splitPickCancel",
946
+ "studio.itinerary.segment.splitPickSet",
947
+ "studio.itinerary.segment.updateGeometry",
948
+ "studio.itinerary.segment.via.promptClose",
949
+ "studio.itinerary.segment.via.promptOpen",
950
+ "studio.itinerary.segment.via.remove",
951
+ "studio.itinerary.segment.via.repeat",
952
+ "studio.segment.length",
953
+ "studio.segment.pointAtFraction"
954
+ ],
955
+ purpose: "Change the geometry of an existing route by proposing vias for the user to save.",
956
+ title: "Segment routing and editing",
957
+ wideFallback: true
958
+ },
959
+ {
960
+ always: false,
961
+ id: "terrain",
962
+ keywords: [
963
+ "elevation",
964
+ "slope",
965
+ "aspect",
966
+ "steep",
967
+ "north face",
968
+ "hillshade",
969
+ "snow",
970
+ "weather",
971
+ "overlay",
972
+ "altitude",
973
+ "dénivelé",
974
+ "pente",
975
+ "orientation",
976
+ "exposition",
977
+ "raide",
978
+ "versant",
979
+ "face nord",
980
+ "relief",
981
+ "ombrage",
982
+ "neige",
983
+ "météo",
984
+ "vent",
985
+ "calque",
986
+ "couche"
987
+ ],
988
+ members: [
989
+ "studio.itinerary.profile.sheet.set",
990
+ "studio.itinerary.profileMarker.set",
991
+ "studio.overlay.category.set",
992
+ "studio.overlay.enrichment.set",
993
+ "studio.overlay.listAvailable",
994
+ "studio.overlay.pois.display.set",
995
+ "studio.overlay.pois.group.set",
996
+ "studio.overlay.sampleAlongSegment",
997
+ "studio.overlay.sampleAt",
998
+ "studio.overlay.set",
999
+ "studio.overlay.timestamp.set",
1000
+ "studio.terrain.set",
1001
+ "terrainGrid",
1002
+ "terrainProfile",
1003
+ "terrainSamples"
1004
+ ],
1005
+ purpose: "Measure the surface (elevation, slope, aspect) and control what the user sees on it.",
1006
+ title: "Terrain and overlays",
1007
+ wideFallback: true
1008
+ },
1009
+ {
1010
+ always: false,
1011
+ id: "authoring",
1012
+ keywords: [
1013
+ "create",
1014
+ "copy",
1015
+ "duplicate",
1016
+ "rename",
1017
+ "delete",
1018
+ "colour",
1019
+ "icon",
1020
+ "emphasis",
1021
+ "waypoint",
1022
+ "name it",
1023
+ "group",
1024
+ "stage",
1025
+ "leg",
1026
+ "crée",
1027
+ "créer",
1028
+ "copie",
1029
+ "copier",
1030
+ "dupliquer",
1031
+ "renomme",
1032
+ "renommer",
1033
+ "supprime",
1034
+ "supprimer",
1035
+ "couleur",
1036
+ "icône",
1037
+ "étape",
1038
+ "point de passage",
1039
+ "groupe",
1040
+ "grouper"
1041
+ ],
1042
+ members: [
1043
+ "itinerary.get",
1044
+ "studio.itinerary.activate",
1045
+ "studio.itinerary.create",
1046
+ "studio.itinerary.createOpen",
1047
+ "studio.itinerary.delete",
1048
+ "studio.itinerary.duplicate",
1049
+ "studio.itinerary.emphasis.set",
1050
+ "studio.itinerary.exclusions.set",
1051
+ "studio.itinerary.group.create",
1052
+ "studio.itinerary.group.delete",
1053
+ "studio.itinerary.group.modal.close",
1054
+ "studio.itinerary.group.modal.open",
1055
+ "studio.itinerary.group.setRange",
1056
+ "studio.itinerary.group.update",
1057
+ "studio.itinerary.openForEdit",
1058
+ "studio.itinerary.rename",
1059
+ "studio.itinerary.tiles.refresh",
1060
+ "studio.itinerary.update",
1061
+ "studio.itinerary.waypoint.create",
1062
+ "studio.itinerary.waypoint.detailsClose",
1063
+ "studio.itinerary.waypoint.detailsOpen",
1064
+ "studio.itinerary.waypoint.editBegin",
1065
+ "studio.itinerary.waypoint.editCancel",
1066
+ "studio.itinerary.waypoint.editCommit",
1067
+ "studio.itinerary.waypoint.editPropose",
1068
+ "studio.itinerary.waypoint.editRedo",
1069
+ "studio.itinerary.waypoint.editSetColor",
1070
+ "studio.itinerary.waypoint.editSetIcon",
1071
+ "studio.itinerary.waypoint.editSetName",
1072
+ "studio.itinerary.waypoint.editSetPosition",
1073
+ "studio.itinerary.waypoint.editUndo",
1074
+ "studio.itinerary.waypoint.recolor",
1075
+ "studio.itinerary.waypoint.remove",
1076
+ "studio.itinerary.waypoint.rename",
1077
+ "studio.itinerary.waypoint.select",
1078
+ "studio.itinerary.waypoint.setDetails",
1079
+ "studio.itinerary.waypoint.setIcon"
1080
+ ],
1081
+ purpose: "Create, copy, rename, restyle, and delete itineraries, their waypoints, and their segment groups.",
1082
+ title: "Itinerary authoring",
1083
+ wideFallback: true
1084
+ },
1085
+ {
1086
+ always: false,
1087
+ id: "discovery",
1088
+ keywords: [
1089
+ "find",
1090
+ "near",
1091
+ "where is",
1092
+ "hut",
1093
+ "peak",
1094
+ "parking",
1095
+ "suggest",
1096
+ "propose a route",
1097
+ "plan a route",
1098
+ "plan me a route",
1099
+ "loop",
1100
+ "plan",
1101
+ "target",
1102
+ "ascent",
1103
+ "km",
1104
+ "options",
1105
+ "trouve",
1106
+ "trouver",
1107
+ "cherche",
1108
+ "chercher",
1109
+ "près de",
1110
+ "autour de",
1111
+ "où est",
1112
+ "refuge",
1113
+ "sommet",
1114
+ "col",
1115
+ "boucle",
1116
+ "suggère",
1117
+ "suggérer",
1118
+ "propose",
1119
+ "proposer",
1120
+ "planifie",
1121
+ "planifier",
1122
+ "génère",
1123
+ "générer",
1124
+ "objectif",
1125
+ "ascension",
1126
+ "montée"
1127
+ ],
1128
+ members: [
1129
+ "studio.contextmenu.close",
1130
+ "studio.contextmenu.open",
1131
+ "studio.data.geocode",
1132
+ "studio.data.pois",
1133
+ "studio.data.reverseGeocode",
1134
+ "studio.data.search",
1135
+ "studio.geolocate.confirm",
1136
+ "studio.geolocate.prompt.close",
1137
+ "studio.geolocate.prompt.open",
1138
+ "studio.itinerary.suggest.applyCandidate",
1139
+ "studio.itinerary.suggest.beginPick",
1140
+ "studio.itinerary.suggest.cancelPick",
1141
+ "studio.itinerary.suggest.clearDraft",
1142
+ "studio.itinerary.suggest.commit",
1143
+ "studio.itinerary.suggest.discard",
1144
+ "studio.itinerary.suggest.generate",
1145
+ "studio.itinerary.suggest.select",
1146
+ "studio.itinerary.suggest.setActivity",
1147
+ "studio.itinerary.suggest.setAscent",
1148
+ "studio.itinerary.suggest.setCollections",
1149
+ "studio.itinerary.suggest.setDistance",
1150
+ "studio.itinerary.suggest.setEnd",
1151
+ "studio.itinerary.suggest.setName",
1152
+ "studio.itinerary.suggest.setOrganization",
1153
+ "studio.itinerary.suggest.setPrivate",
1154
+ "studio.itinerary.suggest.setRouteType",
1155
+ "studio.itinerary.suggest.setSpeed",
1156
+ "studio.itinerary.suggest.setStart",
1157
+ "studio.itinerary.suggest.startFrom",
1158
+ "studio.itinerary.suggest.toggleKeep",
1159
+ "studio.itinerary.suggestOpen",
1160
+ "studio.map.locate",
1161
+ "suggestions"
1162
+ ],
1163
+ purpose: "Find a place, a point of interest, or a candidate route to start from.",
1164
+ title: "Places and route discovery",
1165
+ wideFallback: true
1166
+ },
1167
+ {
1168
+ always: false,
1169
+ id: "zones",
1170
+ keywords: [
1171
+ "zone",
1172
+ "area",
1173
+ "reachability",
1174
+ "isochrone",
1175
+ "hazard",
1176
+ "perimeter",
1177
+ "sector",
1178
+ "radius",
1179
+ "how far can I get",
1180
+ "reachable",
1181
+ "secteur",
1182
+ "périmètre",
1183
+ "rayon",
1184
+ "accessible",
1185
+ "danger"
1186
+ ],
1187
+ members: [
1188
+ "isochrones",
1189
+ "studio.zone.beginOriginPick",
1190
+ "studio.zone.cancelOriginPick",
1191
+ "studio.zone.create",
1192
+ "studio.zone.createBegin",
1193
+ "studio.zone.delete",
1194
+ "studio.zone.editBegin",
1195
+ "studio.zone.editCancel",
1196
+ "studio.zone.editCommit",
1197
+ "studio.zone.editPropose",
1198
+ "studio.zone.editRedo",
1199
+ "studio.zone.editUndo",
1200
+ "studio.zone.open",
1201
+ "studio.zone.openForEdit",
1202
+ "studio.zone.openForView",
1203
+ "studio.zone.publish",
1204
+ "studio.zone.reachabilityPreview",
1205
+ "studio.zone.recompute",
1206
+ "studio.zone.setCreateMethod",
1207
+ "studio.zone.setLevel",
1208
+ "studio.zone.setOrigin",
1209
+ "studio.zone.unpublish",
1210
+ "studio.zone.update"
1211
+ ],
1212
+ purpose: "Draw and maintain zones, the map areas marking reachability, hazard, or interest.",
1213
+ title: "Zones",
1214
+ wideFallback: true
1215
+ },
1216
+ {
1217
+ always: false,
1218
+ id: "collections",
1219
+ keywords: [
1220
+ "collection",
1221
+ "group",
1222
+ "folder",
1223
+ "add to",
1224
+ "organize",
1225
+ "tidy up",
1226
+ "groupe",
1227
+ "dossier",
1228
+ "ajoute à",
1229
+ "ajouter à",
1230
+ "range",
1231
+ "ranger",
1232
+ "organise",
1233
+ "organiser"
1234
+ ],
1235
+ members: [
1236
+ "studio.collection.addItinerary",
1237
+ "studio.collection.addZone",
1238
+ "studio.collection.create",
1239
+ "studio.collection.createClose",
1240
+ "studio.collection.createOpen",
1241
+ "studio.collection.delete",
1242
+ "studio.collection.editClose",
1243
+ "studio.collection.editOpen",
1244
+ "studio.collection.manage.close",
1245
+ "studio.collection.manage.open",
1246
+ "studio.collection.openForEdit",
1247
+ "studio.collection.removeItinerary",
1248
+ "studio.collection.removeZone",
1249
+ "studio.collection.reorderItinerary",
1250
+ "studio.collection.update",
1251
+ "studio.share.close",
1252
+ "studio.share.open"
1253
+ ],
1254
+ purpose: "Group itineraries and zones into a folder the whole organization shares.",
1255
+ title: "Collections",
1256
+ wideFallback: true
1257
+ },
1258
+ {
1259
+ always: false,
1260
+ id: "import",
1261
+ keywords: [
1262
+ "import",
1263
+ "GPX",
1264
+ "upload",
1265
+ "from Strava",
1266
+ "from Garmin",
1267
+ "from a file",
1268
+ "importe",
1269
+ "importer",
1270
+ "téléverse",
1271
+ "téléverser",
1272
+ "depuis un fichier",
1273
+ "depuis strava",
1274
+ "depuis garmin"
1275
+ ],
1276
+ members: [
1277
+ "studio.itinerary.import.clearDraft",
1278
+ "studio.itinerary.import.confirm",
1279
+ "studio.itinerary.import.discard",
1280
+ "studio.itinerary.import.open",
1281
+ "studio.itinerary.import.setActivity",
1282
+ "studio.itinerary.import.setCollections",
1283
+ "studio.itinerary.import.setGranularity",
1284
+ "studio.itinerary.import.setName",
1285
+ "studio.itinerary.import.setOrganization",
1286
+ "studio.itinerary.import.setPrivate",
1287
+ "studio.itinerary.import.setProvider",
1288
+ "studio.itinerary.import.setSegmentModes",
1289
+ "studio.itinerary.import.submitPreview",
1290
+ "studio.itinerary.import.toggleMode"
1291
+ ],
1292
+ purpose: "Bring an external track into the studio and reconcile it before saving.",
1293
+ title: "Import",
1294
+ wideFallback: true
1295
+ },
1296
+ {
1297
+ always: false,
1298
+ id: "sharing",
1299
+ keywords: [
1300
+ "export",
1301
+ "GPX",
1302
+ "download",
1303
+ "share",
1304
+ "link",
1305
+ "embed",
1306
+ "iframe",
1307
+ "exporte",
1308
+ "exporter",
1309
+ "télécharge",
1310
+ "télécharger",
1311
+ "partage",
1312
+ "partager",
1313
+ "lien",
1314
+ "intégration"
1315
+ ],
1316
+ members: [
1317
+ "studio.embed.close",
1318
+ "studio.embed.open",
1319
+ "studio.itinerary.export",
1320
+ "studio.itinerary.export.close",
1321
+ "studio.itinerary.export.open",
1322
+ "studio.share.close",
1323
+ "studio.share.open"
1324
+ ],
1325
+ purpose: "Get an itinerary or a collection out of the studio, as a file, a link, or an embedded map.",
1326
+ title: "Export, share, and embed",
1327
+ wideFallback: true
1328
+ },
1329
+ {
1330
+ always: false,
1331
+ id: "streetview",
1332
+ keywords: [
1333
+ "street view",
1334
+ "ground level",
1335
+ "what does it look like",
1336
+ "photo",
1337
+ "à quoi ressemble",
1338
+ "au niveau du sol",
1339
+ "vue immersive"
1340
+ ],
1341
+ members: [
1342
+ "studio.streetview.close",
1343
+ "studio.streetview.corridor.set",
1344
+ "studio.streetview.coverage.set",
1345
+ "studio.streetview.move",
1346
+ "studio.streetview.open"
1347
+ ],
1348
+ purpose: "Inspect a location at ground level along a route corridor.",
1349
+ title: "Street view",
1350
+ wideFallback: true
1351
+ },
1352
+ {
1353
+ always: false,
1354
+ id: "video",
1355
+ keywords: [
1356
+ "video",
1357
+ "flythrough",
1358
+ "shot",
1359
+ "orbit",
1360
+ "record",
1361
+ "export video",
1362
+ "vidéo",
1363
+ "survol",
1364
+ "orbite",
1365
+ "filme",
1366
+ "filmer"
1367
+ ],
1368
+ members: [
1369
+ "studio.video.cancel",
1370
+ "studio.video.close",
1371
+ "studio.video.download",
1372
+ "studio.video.duration.set",
1373
+ "studio.video.mode.set",
1374
+ "studio.video.open",
1375
+ "studio.video.orbit",
1376
+ "studio.video.output.set",
1377
+ "studio.video.plan.get",
1378
+ "studio.video.preset.set",
1379
+ "studio.video.preview.pause",
1380
+ "studio.video.preview.play",
1381
+ "studio.video.preview.seek",
1382
+ "studio.video.preview.start",
1383
+ "studio.video.preview.stop",
1384
+ "studio.video.profile.design.set",
1385
+ "studio.video.profile.language.set",
1386
+ "studio.video.profile.toggle",
1387
+ "studio.video.profile.units.set",
1388
+ "studio.video.record",
1389
+ "studio.video.route.set",
1390
+ "studio.video.shot.add",
1391
+ "studio.video.shot.addHold",
1392
+ "studio.video.shot.remove",
1393
+ "studio.video.shot.set",
1394
+ "studio.video.step.set"
1395
+ ],
1396
+ purpose: "Compose a flythrough video of a route. Owned by the Video Director, not the studio co-pilot.",
1397
+ title: "Video director",
1398
+ wideFallback: false
1399
+ },
1400
+ {
1401
+ always: false,
1402
+ id: "advanced",
1403
+ keywords: [
1404
+ "graphql",
1405
+ "data api",
1406
+ "raw query",
1407
+ "requête brute"
1408
+ ],
1409
+ members: ["data.query", "data.schema"],
1410
+ purpose: "Escape hatch for geospatial questions no typed operation covers. Off by default: a typed operation is always the better answer when one exists.",
1411
+ title: "Raw Data API access",
1412
+ wideFallback: false
1413
+ }
1414
+ ];
1415
+ const studioRouter = createStudioRouter({
1416
+ playbook: PLAYBOOK,
1417
+ skillRoutes: [
1418
+ {
1419
+ id: "analyze-terrain-along-route",
1420
+ intents: [
1421
+ "how steep is this",
1422
+ "where does it get hard",
1423
+ "is this north facing",
1424
+ "what's the terrain like",
1425
+ "how exposed is this route",
1426
+ "how technical is this trail",
1427
+ "is this route hard underfoot",
1428
+ "c'est raide",
1429
+ "c'est technique",
1430
+ "où ça devient dur",
1431
+ "comment est le terrain",
1432
+ "est-ce exposé",
1433
+ "orienté nord"
1434
+ ],
1435
+ surfaces: ["terrain"]
1436
+ },
1437
+ {
1438
+ id: "build-route-from-scratch",
1439
+ intents: [
1440
+ "plan a route from",
1441
+ "create a new route",
1442
+ "i want to go from the village to the hut",
1443
+ "make me a loop starting here",
1444
+ "planifie un itinéraire",
1445
+ "crée un itinéraire",
1446
+ "fais-moi une boucle depuis",
1447
+ "du village au refuge"
1448
+ ],
1449
+ surfaces: [
1450
+ "authoring",
1451
+ "discovery",
1452
+ "routing"
1453
+ ]
1454
+ },
1455
+ {
1456
+ id: "compare-alternative-routes",
1457
+ intents: [
1458
+ "which way is better",
1459
+ "compare these two",
1460
+ "worth going via",
1461
+ "what if i went the other way",
1462
+ "quel chemin est mieux",
1463
+ "compare ces deux",
1464
+ "ça vaut le coup de passer par",
1465
+ "par l'autre côté"
1466
+ ],
1467
+ surfaces: ["routing", "terrain"]
1468
+ },
1469
+ {
1470
+ id: "create-reachability-zone",
1471
+ intents: [
1472
+ "how far can i get in 2 hours",
1473
+ "what's within an hour of the hut",
1474
+ "draw the reachable area from here",
1475
+ "mark everything within 5 km on foot",
1476
+ "jusqu'où puis-je aller",
1477
+ "à moins d'une heure",
1478
+ "dessine la zone accessible",
1479
+ "accessible à pied"
1480
+ ],
1481
+ surfaces: ["discovery", "zones"]
1482
+ },
1483
+ {
1484
+ id: "create-zone-from-terrain-threshold",
1485
+ intents: [
1486
+ "mark everything steeper than",
1487
+ "highlight the north facing slopes",
1488
+ "show me the avalanche terrain here",
1489
+ "draw a zone over the steep part",
1490
+ "marque tout ce qui est plus raide",
1491
+ "les pentes orientées nord",
1492
+ "le terrain avalancheux",
1493
+ "dessine une zone sur les pentes"
1494
+ ],
1495
+ surfaces: ["terrain", "zones"]
1496
+ },
1497
+ {
1498
+ id: "export-and-share",
1499
+ intents: [
1500
+ "export this as gpx",
1501
+ "send this to my watch",
1502
+ "share this route",
1503
+ "share this collection",
1504
+ "give me a link",
1505
+ "embed this on my site",
1506
+ "exporte en gpx",
1507
+ "envoie sur ma montre",
1508
+ "partage cet itinéraire",
1509
+ "partage cette collection",
1510
+ "donne-moi un lien",
1511
+ "intègre sur mon site"
1512
+ ],
1513
+ surfaces: ["sharing"]
1514
+ },
1515
+ {
1516
+ id: "find-and-add-waypoints",
1517
+ intents: [
1518
+ "are there huts on this route",
1519
+ "where can i park",
1520
+ "add a water stop",
1521
+ "mark the summit",
1522
+ "des refuges sur ce parcours",
1523
+ "où me garer",
1524
+ "ajoute une étape",
1525
+ "marque le sommet",
1526
+ "un point d'eau"
1527
+ ],
1528
+ surfaces: ["discovery", "authoring"]
1529
+ },
1530
+ {
1531
+ id: "generate-route-suggestions",
1532
+ intents: [
1533
+ "suggest a route",
1534
+ "find me a 20 km loop",
1535
+ "something with 1000 m of climbing near here",
1536
+ "what can i do around",
1537
+ "suggère un itinéraire",
1538
+ "propose une boucle",
1539
+ "boucle de",
1540
+ "avec du dénivelé près de",
1541
+ "que faire autour de",
1542
+ "génère des itinéraires",
1543
+ "propose des itinéraires",
1544
+ "itinéraires de",
1545
+ "dénivelé positif",
1546
+ "point de départ"
1547
+ ],
1548
+ surfaces: ["discovery", "authoring"]
1549
+ },
1550
+ {
1551
+ id: "increase-route-ascent",
1552
+ intents: [
1553
+ "make it steeper",
1554
+ "more climbing",
1555
+ "meters of elevation gain",
1556
+ "metres of elevation gain",
1557
+ "harder version of this route",
1558
+ "i want more vertical",
1559
+ "plus raide",
1560
+ "plus de dénivelé",
1561
+ "plus de montée",
1562
+ "version plus dure",
1563
+ "ajoute du dénivelé",
1564
+ "de dénivelé en plus"
1565
+ ],
1566
+ surfaces: ["terrain", "routing"]
1567
+ },
1568
+ {
1569
+ id: "modify-existing-segment",
1570
+ intents: [
1571
+ "reroute this",
1572
+ "avoid the",
1573
+ "go via",
1574
+ "make it shorter",
1575
+ "take the other side of the valley",
1576
+ "keep it off the road",
1577
+ "modifie le tracé",
1578
+ "évite",
1579
+ "passe par",
1580
+ "plus court",
1581
+ "raccourcis",
1582
+ "intègre la boucle",
1583
+ "intègre cette boucle",
1584
+ "ajoute cette boucle"
1585
+ ],
1586
+ surfaces: ["routing", "discovery"]
1587
+ },
1588
+ {
1589
+ id: "prepare-map-for-editing",
1590
+ intents: [
1591
+ "let's work on this route",
1592
+ "open my route",
1593
+ "i want to edit this",
1594
+ "show me the whole thing",
1595
+ "travaillons sur",
1596
+ "ouvre mon itinéraire",
1597
+ "je veux modifier",
1598
+ "montre-moi tout le parcours"
1599
+ ],
1600
+ surfaces: ["routing"]
1601
+ },
1602
+ {
1603
+ id: "visualize-terrain",
1604
+ intents: [
1605
+ "show me the steepness",
1606
+ "turn on hillshade",
1607
+ "can i see the snow depth",
1608
+ "display the aspect",
1609
+ "montre la pente",
1610
+ "affiche la pente",
1611
+ "active le calque",
1612
+ "montre le relief",
1613
+ "hauteur de neige"
1614
+ ],
1615
+ surfaces: ["terrain"]
1616
+ }
1617
+ ],
1618
+ surfaceLocks: [
1619
+ {
1620
+ equals: "segment",
1621
+ field: "editSession",
1622
+ surface: "routing"
1623
+ },
1624
+ {
1625
+ equals: "waypoint",
1626
+ field: "editSession",
1627
+ surface: "authoring"
1628
+ },
1629
+ {
1630
+ equals: true,
1631
+ field: "suggestDraft",
1632
+ surface: "discovery"
1633
+ },
1634
+ {
1635
+ equals: "zone",
1636
+ field: "editSession",
1637
+ surface: "zones"
1638
+ },
1639
+ {
1640
+ equals: "zone",
1641
+ field: "openResource",
1642
+ surface: "zones"
1643
+ },
1644
+ {
1645
+ equals: true,
1646
+ field: "importDraft",
1647
+ surface: "import"
1648
+ },
1649
+ {
1650
+ equals: true,
1651
+ field: "videoOpen",
1652
+ surface: "video"
1653
+ }
1654
+ ],
1655
+ surfaces: SURFACES
1656
+ });
1657
+ const recoveryFor = studioRouter.recoveryFor;
1658
+ const selectSurfaces = studioRouter.selectSurfaces;
1659
+ const surfaceTools = studioRouter.surfaceTools;
1660
+ const addendumFor = (addendum, tool, code) => {
1661
+ if (addendum === void 0) return;
1662
+ let answered;
1663
+ try {
1664
+ answered = addendum(tool, code);
1665
+ } catch (fault) {
1666
+ surfaceFault(fault);
1667
+ return;
1668
+ }
1669
+ const sentence = typeof answered === "string" ? answered.trim() : "";
1670
+ return sentence === "" ? void 0 : sentence;
1671
+ };
1672
+ const studioRecoveryFor = (tool, code, addendum) => {
1673
+ if (code === void 0 || code === "") return;
1674
+ const recovery = recoveryFor(tool, code);
1675
+ const extra = addendumFor(addendum, tool, code);
1676
+ if (recovery === void 0 || extra === void 0) return recovery ?? extra;
1677
+ return `${recovery} ${extra}`;
1678
+ };
1679
+ const transcriptObserver = (config) => {
1680
+ const { draftWarning, errorCopy, writer } = config;
1681
+ return {
1682
+ onChecksUnmet: writer.appendChecksUnmet,
1683
+ onError: (message, code) => writer.appendError(resolveAgentError(message, code, errorCopy(), draftWarning?.())),
1684
+ onMessage: writer.setAssistantMessage,
1685
+ onMessageDelta: writer.appendAssistantDelta,
1686
+ onRunId: writer.setRunId,
1687
+ onStateChange: writer.setSessionState,
1688
+ onToolActivity: writer.setActiveTool,
1689
+ onToolCall: (name, input, toolCallId) => writer.appendToolActivity({
1690
+ input: boundedInputJson(input),
1691
+ name,
1692
+ toolCallId
1693
+ }),
1694
+ onToolResult: writer.settleToolActivity
1695
+ };
1696
+ };
1697
+ const WITHHELD_TAB_ID = "withheld";
1698
+ const idleThread = (runId) => ({
1699
+ pendingConfirmation: null,
1700
+ runId,
1701
+ state: "awaiting_input",
1702
+ transcript: []
1703
+ });
1704
+ const heldThread = (threads, threadId) => Object.hasOwn(threads, threadId) ? threads[threadId] : void 0;
1705
+ const updateThread = (threads, threadId, transform) => {
1706
+ const thread = heldThread(threads, threadId);
1707
+ if (!thread) return threads;
1708
+ return {
1709
+ ...threads,
1710
+ [threadId]: transform(thread)
1711
+ };
1712
+ };
1713
+ const initialState = {
1714
+ activeId: null,
1715
+ activeTabId: null,
1716
+ order: [],
1717
+ threads: {}
1718
+ };
1719
+ const createAgentThreadsStore = () => createStore((set) => ({
1720
+ ...initialState,
1721
+ addCopilotTab: (threadId) => set((current) => {
1722
+ if (heldThread(current.threads, threadId)) return current;
1723
+ return {
1724
+ activeId: threadId,
1725
+ activeTabId: threadId,
1726
+ order: [...current.order, threadId],
1727
+ threads: {
1728
+ ...current.threads,
1729
+ [threadId]: idleThread(null)
1730
+ }
1731
+ };
1732
+ }),
1733
+ answerQuestion: (threadId, entryId, label) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1734
+ ...thread,
1735
+ transcript: answerQuestionEntry(thread.transcript, entryId, label)
1736
+ })) })),
1737
+ appendAssistantDelta: (threadId, delta) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1738
+ ...thread,
1739
+ transcript: accumulateAssistant(thread.transcript, delta)
1740
+ })) })),
1741
+ appendChecksUnmet: (threadId, unmet) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1742
+ ...thread,
1743
+ transcript: appendWarningEntry(thread.transcript, unmet)
1744
+ })) })),
1745
+ appendError: (threadId, message) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1746
+ ...thread,
1747
+ transcript: appendErrorEntry(thread.transcript, message)
1748
+ })) })),
1749
+ appendQuestion: (threadId, question) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1750
+ ...thread,
1751
+ transcript: appendQuestionEntry(thread.transcript, question)
1752
+ })) })),
1753
+ appendSuggestions: (threadId, suggestions) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1754
+ ...thread,
1755
+ transcript: appendSuggestionsEntry(thread.transcript, suggestions)
1756
+ })) })),
1757
+ appendToolActivity: (threadId, activity) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1758
+ ...thread,
1759
+ transcript: appendActivityEntry(thread.transcript, activity)
1760
+ })) })),
1761
+ appendUserMessage: (threadId, content) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1762
+ ...thread,
1763
+ transcript: appendUserEntry(settleOpenSuggestionEntries(settleOpenQuestionEntries(thread.transcript)), content)
1764
+ })) })),
1765
+ chooseSuggestion: (threadId, entryId, seed) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1766
+ ...thread,
1767
+ transcript: chooseSuggestionEntry(thread.transcript, entryId, seed)
1768
+ })) })),
1769
+ clearPendingConfirmation: (threadId) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1770
+ ...thread,
1771
+ pendingConfirmation: null
1772
+ })) })),
1773
+ closeCopilotTab: (threadId) => set((current) => {
1774
+ if (threadId === "search" || threadId === "withheld") return current;
1775
+ const order = current.order.filter((id) => id !== threadId);
1776
+ const { [threadId]: _closed, ...threads } = current.threads;
1777
+ const activeId = current.activeId === threadId ? order.at(-1) ?? null : current.activeId;
1778
+ return {
1779
+ activeId,
1780
+ activeTabId: current.activeTabId === threadId ? activeId ?? "search" : current.activeTabId,
1781
+ order,
1782
+ threads
1783
+ };
1784
+ }),
1785
+ closeThread: (threadId) => set((current) => {
1786
+ const order = current.order.filter((id) => id !== threadId);
1787
+ const { [threadId]: _closed, ...threads } = current.threads;
1788
+ const activeId = current.activeId === threadId ? order.at(-1) ?? null : current.activeId;
1789
+ return {
1790
+ activeId,
1791
+ activeTabId: current.activeTabId === threadId ? activeId ?? "search" : current.activeTabId,
1792
+ order,
1793
+ threads
1794
+ };
1795
+ }),
1796
+ createThread: (threadId, runId = null) => set((current) => {
1797
+ if (heldThread(current.threads, threadId)) return current;
1798
+ return {
1799
+ activeId: threadId,
1800
+ order: [...current.order, threadId],
1801
+ threads: {
1802
+ ...current.threads,
1803
+ [threadId]: idleThread(runId)
1804
+ }
1805
+ };
1806
+ }),
1807
+ setActive: (threadId) => set((current) => heldThread(current.threads, threadId) ? { activeId: threadId } : current),
1808
+ setActiveTab: (tabId) => set((current) => {
1809
+ if (tabId === "search") return { activeTabId: SEARCH_TAB_ID };
1810
+ if (tabId === "withheld") return { activeTabId: WITHHELD_TAB_ID };
1811
+ if (!heldThread(current.threads, tabId)) return current;
1812
+ return {
1813
+ activeId: tabId,
1814
+ activeTabId: tabId
1815
+ };
1816
+ }),
1817
+ setAssistantMessage: (threadId, content, messageIndex) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1818
+ ...thread,
1819
+ transcript: replaceAssistant(thread.transcript, content, messageIndex)
1820
+ })) })),
1821
+ setPendingConfirmation: (threadId, confirmation) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1822
+ ...thread,
1823
+ pendingConfirmation: confirmation
1824
+ })) })),
1825
+ setRunId: (threadId, runId) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1826
+ ...thread,
1827
+ runId
1828
+ })) })),
1829
+ setSessionState: (threadId, state) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1830
+ ...thread,
1831
+ state
1832
+ })) })),
1833
+ settleToolActivity: (threadId, toolCallId, outcome) => set((current) => ({ threads: updateThread(current.threads, threadId, (thread) => ({
1834
+ ...thread,
1835
+ transcript: settleActivityEntry(thread.transcript, toolCallId, outcome)
1836
+ })) }))
1837
+ }));
1838
+ const selectAgentDriving = (state) => state.order.some((id) => state.threads[id]?.state === "running");
1839
+ const QUESTION_TOOL = "studio.question.ask";
1840
+ const GENERATE_TOOL = "studio.itinerary.suggest.generate";
1841
+ const ACCESS_REVOKED = "access-revoked";
1842
+ const holdRejection = (dispatched) => {
1843
+ Promise.resolve(dispatched).then(void 0, () => void 0);
1844
+ };
1845
+ const isOutcome = (answered) => typeof answered === "object" && answered !== null && "ok" in answered && typeof answered.ok === "boolean";
1846
+ const restorableThreads = (named) => {
1847
+ const kept = /* @__PURE__ */ new Map();
1848
+ const entries = Array.isArray(named) ? named : [];
1849
+ for (const entry of entries) {
1850
+ if (kept.size >= 1) break;
1851
+ if (typeof entry !== "object" || entry === null) continue;
1852
+ const id = "id" in entry ? entry.id : void 0;
1853
+ const runId = "runId" in entry ? entry.runId : void 0;
1854
+ if (typeof id !== "string" || id === "" || id === "search" || id === "withheld" || kept.has(id)) continue;
1855
+ kept.set(id, {
1856
+ id,
1857
+ runId: typeof runId === "string" && runId !== "" ? runId : null
1858
+ });
1859
+ }
1860
+ return [...kept.values()];
1861
+ };
1862
+ var AgentThreadsEngine = class {
1863
+ config;
1864
+ ids;
1865
+ store;
1866
+ tabs;
1867
+ subscriptions = /* @__PURE__ */ new Set();
1868
+ releaseStore = null;
1869
+ mirrored = null;
1870
+ unrestored = null;
1871
+ heard = null;
1872
+ hosts = /* @__PURE__ */ new Map();
1873
+ confirmations = /* @__PURE__ */ new Map();
1874
+ surfaces = /* @__PURE__ */ new Map();
1875
+ lastRouted = /* @__PURE__ */ new Map();
1876
+ suggestBatchOwner = null;
1877
+ stagingPicks = /* @__PURE__ */ new Set();
1878
+ awaitingTurn = /* @__PURE__ */ new Set();
1879
+ sessionStates = /* @__PURE__ */ new Map();
1880
+ parked = true;
1881
+ disposed = false;
1882
+ tabSurface = {
1883
+ addCopilotTab: () => this.live() ? this.openTab() : this.shownTab(),
1884
+ closeCopilotTab: (tabId) => {
1885
+ if (this.live()) this.closeTab(tabId);
1886
+ },
1887
+ countOpen: () => this.store.getState().order.length,
1888
+ hasTab: (tabId) => tabId === "search" || tabId === "withheld" && this.withheld() || this.store.getState().order.includes(tabId),
1889
+ openCopilot: () => this.live() ? this.openOrReveal() : this.shownTab(),
1890
+ reset: () => {
1891
+ if (this.live()) this.resetThreads();
1892
+ },
1893
+ setActiveTab: (tabId) => {
1894
+ if (this.live()) this.showTab(tabId);
1895
+ }
1896
+ };
1897
+ constructor(options) {
1898
+ const { ids, store, tabs, ...config } = options;
1899
+ this.config = config;
1900
+ this.ids = ids;
1901
+ this.tabs = tabs;
1902
+ this.store = store ?? createAgentThreadsStore();
1903
+ this.seed(config.threadsUrl?.readOnce() ?? {});
1904
+ }
1905
+ getSnapshot() {
1906
+ return this.store.getState();
1907
+ }
1908
+ subscribe(listener) {
1909
+ if (this.disposed) return () => {};
1910
+ const subscription = { listener };
1911
+ this.subscriptions.add(subscription);
1912
+ if (this.parked) this.resume();
1913
+ return () => {
1914
+ if (!this.subscriptions.delete(subscription) || this.subscriptions.size > 0) return;
1915
+ if (!this.parked) this.park();
1916
+ };
1917
+ }
1918
+ configure(config) {
1919
+ this.config = config;
1920
+ if (this.mirrored !== null && this.mirrored !== config.context.ui) {
1921
+ this.releaseMirror();
1922
+ this.mirrorInto(config.context.ui);
1923
+ }
1924
+ if (this.heard !== null && this.heard.viewer !== config.context.viewer) {
1925
+ this.hearViewer(config.context.viewer);
1926
+ this.restoreForEntitled();
1927
+ }
1928
+ }
1929
+ dispose() {
1930
+ if (this.disposed) return;
1931
+ if (!this.parked) this.park();
1932
+ this.disposed = true;
1933
+ this.subscriptions.clear();
1934
+ }
1935
+ answerQuestion(entryId, label) {
1936
+ const threadId = this.activeThread();
1937
+ if (threadId === null || !this.hasOpenQuestion(threadId, entryId)) return;
1938
+ this.store.getState().answerQuestion(threadId, entryId, label);
1939
+ this.send(threadId, label);
1940
+ }
1941
+ chooseSuggestion(entryId, seed, label) {
1942
+ const threadId = this.activeThread();
1943
+ if (threadId === null || this.stagingPicks.has(entryId)) return;
1944
+ this.stagingPicks.add(entryId);
1945
+ this.applyPick(threadId, entryId, seed, label);
1946
+ }
1947
+ closeAiTab(tabId) {
1948
+ if (this.live()) holdRejection(this.config.bus.dispatch(this.tabsContext(), "studio.tabs.close", { tabId }));
1949
+ }
1950
+ newAiTab() {
1951
+ if (this.live()) holdRejection(this.config.bus.dispatch(this.tabsContext(), "studio.tabs.create", { kind: "copilot" }));
1952
+ }
1953
+ previewCandidate(seed) {
1954
+ if (this.live()) holdRejection(this.config.bus.dispatch(this.config.context, "studio.itinerary.suggest.select", { seed }));
1955
+ }
1956
+ resolveConfirmation(approved) {
1957
+ const threadId = this.activeThread();
1958
+ if (threadId === null) return;
1959
+ const resolve = this.confirmations.get(threadId);
1960
+ if (resolve === void 0) return;
1961
+ this.confirmations.delete(threadId);
1962
+ this.store.getState().clearPendingConfirmation(threadId);
1963
+ resolve(approved);
1964
+ }
1965
+ stopActive() {
1966
+ const threadId = this.activeThread();
1967
+ if (threadId === null) return;
1968
+ this.denyPendingConfirmation(threadId);
1969
+ this.ensureHost(threadId).restart();
1970
+ this.store.getState().setRunId(threadId, null);
1971
+ this.settle(threadId);
1972
+ this.syncUrl();
1973
+ }
1974
+ submit(message) {
1975
+ const threadId = this.activeThread();
1976
+ if (threadId !== null) this.send(threadId, message);
1977
+ }
1978
+ switchTab(tabId) {
1979
+ if (this.live()) holdRejection(this.config.bus.dispatch(this.tabsContext(), "studio.tabs.switch", { tabId }));
1980
+ }
1981
+ live() {
1982
+ if (this.parked || this.disposed) return false;
1983
+ this.restoreForEntitled();
1984
+ return true;
1985
+ }
1986
+ isOpen(threadId) {
1987
+ return this.live() && this.store.getState().threads[threadId] !== void 0;
1988
+ }
1989
+ activeThread() {
1990
+ return this.live() ? this.store.getState().activeId : null;
1991
+ }
1992
+ shownTab() {
1993
+ return this.store.getState().activeTabId ?? "search";
1994
+ }
1995
+ withheld() {
1996
+ return !this.config.context.viewer.hasEntitlement("copilot");
1997
+ }
1998
+ seed(mirrored) {
1999
+ if (this.withheld()) {
2000
+ this.unrestored = mirrored;
2001
+ this.store.getState().setActiveTab(mirrored.activeThreadId === "withheld" ? WITHHELD_TAB_ID : SEARCH_TAB_ID);
2002
+ return;
2003
+ }
2004
+ this.restore(mirrored);
2005
+ }
2006
+ restore(mirrored) {
2007
+ const state = this.store.getState();
2008
+ const named = restorableThreads(mirrored.threads).filter(({ id }) => !Object.hasOwn(state.threads, id));
2009
+ const initial = mirrored.activeThreadId;
2010
+ if (named.length === 0) {
2011
+ const created = state.order.length === 0 ? [this.ids.next()] : [];
2012
+ for (const id of created) state.createThread(id);
2013
+ state.setActiveTab(SEARCH_TAB_ID);
2014
+ return created;
2015
+ }
2016
+ for (const { id, runId } of named) state.createThread(id, runId);
2017
+ const open = this.store.getState().order;
2018
+ state.setActiveTab(initial !== void 0 && (initial === "search" || open.includes(initial)) ? initial : SEARCH_TAB_ID);
2019
+ return named.map(({ id }) => id);
2020
+ }
2021
+ restoreForEntitled() {
2022
+ const mirrored = this.unrestored;
2023
+ if (mirrored === null || this.withheld()) return;
2024
+ this.unrestored = null;
2025
+ const created = this.restore(mirrored);
2026
+ this.syncUrl();
2027
+ if (!this.parked && !this.disposed) for (const id of created) this.connect(id);
2028
+ }
2029
+ hearViewer(viewer) {
2030
+ this.heard?.release();
2031
+ this.heard = null;
2032
+ let release = () => void 0;
2033
+ this.tellSeam(() => {
2034
+ release = viewer.subscribe(() => this.restoreForEntitled());
2035
+ });
2036
+ this.heard = {
2037
+ release,
2038
+ viewer
2039
+ };
2040
+ }
2041
+ connect(threadId) {
2042
+ this.ensureHost(threadId).resume(this.store.getState().threads[threadId]?.runId ?? null, (error) => this.faultsFor(threadId).resumeFailed(error));
2043
+ }
2044
+ resume() {
2045
+ this.restoreForEntitled();
2046
+ this.parked = false;
2047
+ this.releaseStore = this.store.subscribe((state) => {
2048
+ this.syncDriving(state);
2049
+ notifyListeners(Array.from(this.subscriptions, ({ listener }) => listener));
2050
+ });
2051
+ this.mirrorInto(this.config.context.ui);
2052
+ for (const id of [...this.store.getState().order]) this.connect(id);
2053
+ this.hearViewer(this.config.context.viewer);
2054
+ this.tellSeam(() => this.tabs?.register(this.tabSurface));
2055
+ }
2056
+ park() {
2057
+ this.parked = true;
2058
+ this.releaseStore?.();
2059
+ this.releaseStore = null;
2060
+ for (const host of this.hosts.values()) host.dispose();
2061
+ this.awaitingTurn.clear();
2062
+ this.sessionStates.clear();
2063
+ this.settleStreamingThreads();
2064
+ for (const threadId of [...this.confirmations.keys()]) this.denyPendingConfirmation(threadId);
2065
+ this.releaseMirror();
2066
+ const heard = this.heard;
2067
+ this.heard = null;
2068
+ if (heard !== null) this.tellSeam(heard.release);
2069
+ this.tellSeam(() => this.tabs?.unregister());
2070
+ }
2071
+ tellSeam(tell) {
2072
+ try {
2073
+ tell();
2074
+ } catch (fault) {
2075
+ surfaceFault(fault);
2076
+ }
2077
+ }
2078
+ send(threadId, message) {
2079
+ if (this.sessionStates.get(threadId) !== "running") this.awaitingTurn.add(threadId);
2080
+ this.writeSessionState(threadId, "running");
2081
+ this.ensureHost(threadId).submit(message);
2082
+ }
2083
+ settle(threadId) {
2084
+ this.awaitingTurn.delete(threadId);
2085
+ this.writeSessionState(threadId, "awaiting_input");
2086
+ }
2087
+ reportSessionState(threadId, state) {
2088
+ this.sessionStates.set(threadId, state);
2089
+ if (!this.live() || state === "awaiting_input" && this.awaitingTurn.has(threadId)) return;
2090
+ this.awaitingTurn.delete(threadId);
2091
+ this.writeSessionState(threadId, state);
2092
+ }
2093
+ writeSessionState(threadId, state) {
2094
+ const thread = this.store.getState().threads[threadId];
2095
+ if (thread !== void 0 && thread.state !== state) this.store.getState().setSessionState(threadId, state);
2096
+ }
2097
+ hasOpenQuestion(threadId, entryId) {
2098
+ return this.store.getState().threads[threadId]?.transcript.some((entry) => entry.role === "question" && entry.id === entryId && !entry.settled) ?? false;
2099
+ }
2100
+ settleStreamingThreads() {
2101
+ const { order, threads } = this.store.getState();
2102
+ for (const id of order) if (threads[id]?.state === "running") this.store.getState().setSessionState(id, "awaiting_input");
2103
+ }
2104
+ mirrorInto(ui) {
2105
+ this.mirrored = ui;
2106
+ this.syncDriving(this.store.getState());
2107
+ }
2108
+ releaseMirror() {
2109
+ const ui = this.mirrored;
2110
+ if (ui === null) return;
2111
+ this.mirrored = null;
2112
+ ui.getState().setAgentDriving(false);
2113
+ ui.getState().agentClearEditLocks();
2114
+ ui.getState().setAgentHandoff(null);
2115
+ }
2116
+ syncDriving(state) {
2117
+ const ui = this.mirrored;
2118
+ if (ui === null) return;
2119
+ const driving = selectAgentDriving(state);
2120
+ if (ui.getState().agentDriving === driving) return;
2121
+ ui.getState().setAgentDriving(driving);
2122
+ if (!driving) ui.getState().agentClearEditLocks(agentHandoffTarget(ui.getState()));
2123
+ }
2124
+ syncUrl() {
2125
+ const state = this.store.getState();
2126
+ const threads = state.order.map((id) => ({
2127
+ id,
2128
+ runId: state.threads[id]?.runId ?? null
2129
+ }));
2130
+ this.tellSeam(() => this.config.threadsUrl?.write({
2131
+ activeThreadId: state.activeTabId ?? null,
2132
+ threads
2133
+ }));
2134
+ }
2135
+ tabsContext() {
2136
+ return layerToolContext(this.config.context, { tabs: this.tabSurface });
2137
+ }
2138
+ ensureHost(threadId) {
2139
+ let host = this.hosts.get(threadId);
2140
+ if (host === void 0) {
2141
+ host = this.hostFor(threadId);
2142
+ this.hosts.set(threadId, host);
2143
+ }
2144
+ return host;
2145
+ }
2146
+ hostFor(threadId) {
2147
+ return createConversationHost({
2148
+ appendUserMessage: (message) => this.store.getState().appendUserMessage(threadId, message),
2149
+ buildContext: () => buildStudioSnapshot(this.config.context).catch(() => void 0),
2150
+ buildSession: () => this.sessionFor(threadId),
2151
+ onMissingOrganization: () => this.faultsFor(threadId).missingOrganization(),
2152
+ onSendFault: (error, runGone) => this.faultsFor(threadId).recover(runGone, error),
2153
+ onStartError: (organizationId, error, runId) => this.faultsFor(threadId).handleStartError(organizationId, error, runId),
2154
+ resolveOrganizationId: () => copilotOrganizationId(this.config.context.ui.getState()),
2155
+ routeForMessage: (message) => this.routeForMessage(threadId, message),
2156
+ routeForState: () => this.routeForState(threadId)
2157
+ });
2158
+ }
2159
+ sessionFor(threadId) {
2160
+ this.sessionStates.delete(threadId);
2161
+ return new AgentEngine({
2162
+ bus: this.config.bus,
2163
+ confirmServerTool: (confirmation) => this.requestConfirmation(threadId, confirmation.name, this.config.strings.confirm.serverToolFallback(confirmation.name)),
2164
+ ctx: layerToolContext(this.config.context, {
2165
+ confirm: (request) => this.requestConfirmation(threadId, request.name, confirmSentence(this.config.strings, request.descriptionLabel, request.values) ?? request.description),
2166
+ origin: "agent"
2167
+ }),
2168
+ observer: this.observerFor(threadId),
2169
+ recoveryFor: (tool, code) => studioRecoveryFor(tool, code, this.config.recoveryAddendum),
2170
+ routesServerTools: this.config.routesServerTools,
2171
+ stateDelta: studioStateDelta,
2172
+ toolSurface: () => {
2173
+ const surfaces = this.surfaces.get(threadId);
2174
+ return surfaces === void 0 ? void 0 : surfaceTools(surfaces);
2175
+ },
2176
+ transport: this.config.transport
2177
+ });
2178
+ }
2179
+ observerFor(threadId) {
2180
+ const store = this.store;
2181
+ const transcript = transcriptObserver({
2182
+ draftWarning: () => ({
2183
+ note: this.config.strings.prompt.budgetDraftOpen,
2184
+ open: captureStudioState(this.config.context).editingKind !== null
2185
+ }),
2186
+ errorCopy: () => this.config.errorCopy,
2187
+ writer: {
2188
+ appendAssistantDelta: (delta) => store.getState().appendAssistantDelta(threadId, delta),
2189
+ appendChecksUnmet: (unmet) => store.getState().appendChecksUnmet(threadId, unmet),
2190
+ appendError: (message) => store.getState().appendError(threadId, message),
2191
+ appendToolActivity: (activity) => store.getState().appendToolActivity(threadId, activity),
2192
+ setAssistantMessage: (content, messageIndex) => store.getState().setAssistantMessage(threadId, content, messageIndex),
2193
+ setRunId: (runId) => store.getState().setRunId(threadId, runId),
2194
+ setSessionState: (state) => this.reportSessionState(threadId, state),
2195
+ settleToolActivity: (toolCallId, outcome) => store.getState().settleToolActivity(threadId, toolCallId, outcome)
2196
+ }
2197
+ });
2198
+ return {
2199
+ ...transcript,
2200
+ onError: (message, code) => {
2201
+ transcript.onError?.(message, code);
2202
+ if (code === ACCESS_REVOKED) this.tellSeam(() => this.config.invalidateMemberships?.());
2203
+ },
2204
+ onRunId: (runId) => {
2205
+ transcript.onRunId?.(runId);
2206
+ this.syncUrl();
2207
+ },
2208
+ onToolCall: (name, input, toolCallId) => {
2209
+ if (this.appendQuestionCard(threadId, name, input, toolCallId)) return;
2210
+ if (name === GENERATE_TOOL) this.suggestBatchOwner = {
2211
+ threadId,
2212
+ toolCallId
2213
+ };
2214
+ const ui = this.config.context.ui;
2215
+ const target = agentEditLockTarget(name, input);
2216
+ if (target !== null) ui.getState().agentLockEntity(target.kind, target.id);
2217
+ if (agentTakesEntityBack(name, input)) ui.getState().setAgentHandoff(null);
2218
+ transcript.onToolCall?.(name, input, toolCallId);
2219
+ },
2220
+ onToolResult: (toolCallId, outcome) => {
2221
+ const settledGenerate = outcome.status === "ok" && this.isGenerate(threadId, toolCallId);
2222
+ transcript.onToolResult?.(toolCallId, outcome);
2223
+ if (settledGenerate) this.appendSuggestionsCard(threadId, toolCallId);
2224
+ this.hosts.get(threadId)?.reroute();
2225
+ }
2226
+ };
2227
+ }
2228
+ appendQuestionCard(threadId, name, input, toolCallId) {
2229
+ if (name !== QUESTION_TOOL) return false;
2230
+ const parsed = questionToolContracts[QUESTION_TOOL].input.safeParse(input);
2231
+ if (!parsed.success) return false;
2232
+ this.store.getState().appendQuestion(threadId, {
2233
+ options: parsed.data.options.map((option) => ({
2234
+ description: option.description ?? null,
2235
+ label: option.label
2236
+ })),
2237
+ question: parsed.data.question,
2238
+ toolCallId
2239
+ });
2240
+ return true;
2241
+ }
2242
+ isGenerate(threadId, toolCallId) {
2243
+ return this.store.getState().threads[threadId]?.transcript.some((entry) => entry.role === "activity" && entry.id === toolCallId && entry.name === GENERATE_TOOL) ?? false;
2244
+ }
2245
+ appendSuggestionsCard(threadId, toolCallId) {
2246
+ const owner = this.suggestBatchOwner;
2247
+ if (owner?.threadId !== threadId || owner.toolCallId !== toolCallId) return;
2248
+ const context = this.config.context;
2249
+ const candidates = selectSuggestionSession(context.ui.getState())?.candidates ?? [];
2250
+ if (candidates.length === 0) return;
2251
+ const entryId = `${toolCallId}:card`;
2252
+ if ((this.store.getState().threads[threadId]?.transcript ?? []).some((entry) => entry.id === entryId)) return;
2253
+ this.store.getState().appendSuggestions(threadId, {
2254
+ candidates: candidates.map((candidate) => ({
2255
+ ascentMeters: candidate.ascentMeters,
2256
+ color: candidate.color,
2257
+ distanceMeters: candidate.distanceMeters,
2258
+ durationSeconds: candidate.durationSeconds,
2259
+ seed: candidate.seed
2260
+ })),
2261
+ entryId
2262
+ });
2263
+ if (this.store.getState().activeTabId !== threadId) return;
2264
+ const bounds = boundsOf(candidates.map((candidate) => candidate.geometry));
2265
+ if (bounds) holdRejection(this.config.bus.dispatch(context, "studio.map.fitBounds", { bounds }));
2266
+ }
2267
+ async stagePick(seed) {
2268
+ const context = this.config.context;
2269
+ try {
2270
+ const applied = await this.config.bus.dispatch(context, "studio.itinerary.suggest.applyCandidate", {
2271
+ seed,
2272
+ segmentName: defaultSegmentName(context.ui.getState().activeItinerary?.segments?.length ?? 0)
2273
+ });
2274
+ if (isOutcome(applied)) return applied;
2275
+ return {
2276
+ code: "internal",
2277
+ error: "the apply of a suggested route answered no result",
2278
+ ok: false
2279
+ };
2280
+ } catch (err) {
2281
+ return failureFromThrown(err);
2282
+ }
2283
+ }
2284
+ async applyPick(threadId, entryId, seed, label) {
2285
+ try {
2286
+ const applied = await this.stagePick(seed);
2287
+ if (!this.isOpen(threadId)) return;
2288
+ if (!applied.ok) {
2289
+ if (isConfirmationWithheld(applied)) return;
2290
+ this.store.getState().appendError(threadId, this.config.strings.prompt.suggestionsStageError);
2291
+ return;
2292
+ }
2293
+ this.store.getState().chooseSuggestion(threadId, entryId, seed);
2294
+ this.send(threadId, label);
2295
+ } finally {
2296
+ this.stagingPicks.delete(entryId);
2297
+ }
2298
+ }
2299
+ requestConfirmation(threadId, name, summary) {
2300
+ if (!this.isOpen(threadId)) return Promise.resolve(false);
2301
+ return new Promise((resolve) => {
2302
+ this.confirmations.get(threadId)?.(false);
2303
+ this.confirmations.set(threadId, resolve);
2304
+ this.store.getState().setPendingConfirmation(threadId, {
2305
+ name,
2306
+ summary
2307
+ });
2308
+ });
2309
+ }
2310
+ denyPendingConfirmation(threadId) {
2311
+ const resolve = this.confirmations.get(threadId);
2312
+ if (resolve !== void 0) {
2313
+ this.confirmations.delete(threadId);
2314
+ resolve(false);
2315
+ }
2316
+ this.store.getState().clearPendingConfirmation(threadId);
2317
+ }
2318
+ faultsFor(threadId) {
2319
+ const { context, invalidateAiConfig, invalidateMemberships, onSignInRefused, strings } = this.config;
2320
+ const store = this.store;
2321
+ return createConversationFaults({
2322
+ copy: {
2323
+ generic: strings.prompt.errorGeneric,
2324
+ missingOrganization: copilotOrganizationId(context.ui.getState()) === null ? strings.copilot.errorPersonalResource : strings.copilot.errorNoResource,
2325
+ noAccess: strings.copilot.errorNoAccess,
2326
+ notConfigured: strings.copilot.errorNotConfigured,
2327
+ notEntitled: strings.copilot.withheld,
2328
+ rateLimited: strings.prompt.errorRateLimited,
2329
+ tooLarge: strings.prompt.errorTooLarge
2330
+ },
2331
+ invalidateAiConfig,
2332
+ invalidateMemberships,
2333
+ onSettled: () => this.syncUrl(),
2334
+ onSignInRefused,
2335
+ writer: {
2336
+ appendError: (message) => store.getState().appendError(threadId, message),
2337
+ setRunId: (runId) => store.getState().setRunId(threadId, runId),
2338
+ setSessionState: (state) => {
2339
+ this.awaitingTurn.delete(threadId);
2340
+ this.writeSessionState(threadId, state);
2341
+ }
2342
+ }
2343
+ });
2344
+ }
2345
+ routeForMessage(threadId, message) {
2346
+ this.lastRouted.set(threadId, message);
2347
+ this.route(threadId, message);
2348
+ }
2349
+ routeForState(threadId) {
2350
+ this.route(threadId, this.lastRouted.get(threadId) ?? "");
2351
+ }
2352
+ route(threadId, message) {
2353
+ const decision = selectSurfaces(message, routerStateFrom(this.config.context), this.surfaces.get(threadId) ?? []);
2354
+ this.surfaces.set(threadId, decision.surfaces);
2355
+ }
2356
+ openTab() {
2357
+ const id = this.ids.next();
2358
+ this.store.getState().addCopilotTab(id);
2359
+ this.ensureHost(id);
2360
+ this.syncUrl();
2361
+ return id;
2362
+ }
2363
+ closeTab(tabId) {
2364
+ this.hosts.get(tabId)?.finish();
2365
+ this.hosts.delete(tabId);
2366
+ this.surfaces.delete(tabId);
2367
+ this.lastRouted.delete(tabId);
2368
+ this.awaitingTurn.delete(tabId);
2369
+ this.sessionStates.delete(tabId);
2370
+ this.denyPendingConfirmation(tabId);
2371
+ const context = this.config.context;
2372
+ const owner = this.suggestBatchOwner;
2373
+ const session = selectSuggestionSession(context.ui.getState());
2374
+ if (session !== null && !session.draft && context.ui.getState().openContent !== "suggest" && (owner === null || owner.threadId === tabId)) {
2375
+ this.suggestBatchOwner = null;
2376
+ holdRejection(this.config.bus.dispatch(context, "studio.itinerary.suggest.discard", {}));
2377
+ }
2378
+ this.store.getState().closeCopilotTab(tabId);
2379
+ if (!this.withheld() && this.store.getState().order.length === 0) {
2380
+ this.openTab();
2381
+ return;
2382
+ }
2383
+ this.syncUrl();
2384
+ }
2385
+ showTab(tabId) {
2386
+ this.store.getState().setActiveTab(tabId === "withheld" && !this.withheld() ? SEARCH_TAB_ID : tabId);
2387
+ this.syncUrl();
2388
+ }
2389
+ resetThreads() {
2390
+ for (const id of [...this.store.getState().order]) this.closeTab(id);
2391
+ this.showTab(SEARCH_TAB_ID);
2392
+ }
2393
+ openOrReveal() {
2394
+ if (this.withheld()) {
2395
+ this.showTab(WITHHELD_TAB_ID);
2396
+ return WITHHELD_TAB_ID;
2397
+ }
2398
+ const existing = this.store.getState().order.at(-1);
2399
+ if (existing !== void 0) {
2400
+ this.showTab(existing);
2401
+ return existing;
2402
+ }
2403
+ return this.openTab();
2404
+ }
2405
+ };
2406
+ var DirectorChatEngine = class {
2407
+ config;
2408
+ store;
2409
+ subscriptions = /* @__PURE__ */ new Set();
2410
+ releaseStore = null;
2411
+ host = null;
2412
+ awaitingTurn = false;
2413
+ sessionState = "awaiting_input";
2414
+ parked = true;
2415
+ disposed = false;
2416
+ constructor(options) {
2417
+ const { store, ...config } = options;
2418
+ this.config = config;
2419
+ this.store = store ?? createVideoDirectorStore();
2420
+ }
2421
+ getSnapshot() {
2422
+ return this.store.getState();
2423
+ }
2424
+ subscribe(listener) {
2425
+ if (this.disposed) return () => {};
2426
+ const subscription = { listener };
2427
+ this.subscriptions.add(subscription);
2428
+ if (this.parked) this.resume();
2429
+ return () => {
2430
+ if (!this.subscriptions.delete(subscription) || this.subscriptions.size > 0) return;
2431
+ if (!this.parked) this.park();
2432
+ };
2433
+ }
2434
+ configure(config) {
2435
+ this.config = config;
2436
+ }
2437
+ dispose() {
2438
+ if (this.disposed) return;
2439
+ this.disposed = true;
2440
+ this.closeRun();
2441
+ if (!this.parked) this.park();
2442
+ this.subscriptions.clear();
2443
+ const { runId, state } = this.store.getState();
2444
+ if (runId !== null || state !== "awaiting_input") this.store.getState().stopRun();
2445
+ }
2446
+ stop() {
2447
+ if (!this.live()) return;
2448
+ this.ensureHost().restart();
2449
+ this.awaitingTurn = false;
2450
+ this.store.getState().stopRun();
2451
+ }
2452
+ submit(message) {
2453
+ if (!this.live()) return;
2454
+ this.awaitingTurn = this.sessionState !== "running";
2455
+ this.writeSessionState("running");
2456
+ this.ensureHost().submit(message);
2457
+ }
2458
+ live() {
2459
+ return !this.parked && !this.disposed;
2460
+ }
2461
+ resume() {
2462
+ this.parked = false;
2463
+ this.releaseStore = this.store.subscribe(() => {
2464
+ notifyListeners(Array.from(this.subscriptions, ({ listener }) => listener));
2465
+ });
2466
+ const { runId } = this.store.getState();
2467
+ if (runId !== null) this.ensureHost().resume(runId, () => {
2468
+ this.store.getState().setRunId(null);
2469
+ this.settle();
2470
+ });
2471
+ }
2472
+ park() {
2473
+ this.parked = true;
2474
+ this.releaseStore?.();
2475
+ this.releaseStore = null;
2476
+ this.host?.dispose();
2477
+ this.awaitingTurn = false;
2478
+ if (this.store.getState().state === "running") this.store.getState().setSessionState("awaiting_input");
2479
+ }
2480
+ closeRun() {
2481
+ if (!this.parked) {
2482
+ this.host?.finish();
2483
+ return;
2484
+ }
2485
+ const { runId, state } = this.store.getState();
2486
+ if (runId !== null && state !== "ended") this.config.transport.sendInput(runId, { type: "close" }).catch(() => void 0);
2487
+ }
2488
+ settle() {
2489
+ this.awaitingTurn = false;
2490
+ this.writeSessionState("awaiting_input");
2491
+ }
2492
+ reportSessionState(state) {
2493
+ this.sessionState = state;
2494
+ if (!this.live() || state === "awaiting_input" && this.awaitingTurn) return;
2495
+ this.awaitingTurn = false;
2496
+ this.writeSessionState(state);
2497
+ }
2498
+ writeSessionState(state) {
2499
+ if (this.store.getState().state !== state) this.store.getState().setSessionState(state);
2500
+ }
2501
+ ensureHost() {
2502
+ this.host ??= createConversationHost({
2503
+ appendUserMessage: (message) => this.store.getState().appendUserMessage(message),
2504
+ buildContext: () => Promise.resolve(buildVideoSnapshot(this.config.context) ?? void 0),
2505
+ buildSession: () => this.session(),
2506
+ onMissingOrganization: () => this.faults().missingOrganization(),
2507
+ onSendFault: (error, runGone) => this.faults().recover(runGone, error),
2508
+ onStartError: (organizationId, error, runId) => this.faults().handleStartError(organizationId, error, runId),
2509
+ resolveOrganizationId: () => this.config.organizationId
2510
+ });
2511
+ return this.host;
2512
+ }
2513
+ session() {
2514
+ const store = this.store;
2515
+ this.sessionState = "awaiting_input";
2516
+ return new AgentEngine({
2517
+ bus: this.config.bus,
2518
+ confirmServerTool: (confirmation) => this.config.context.confirm?.({
2519
+ description: this.config.strings.confirm.serverToolFallback(confirmation.name),
2520
+ input: void 0,
2521
+ name: confirmation.name
2522
+ }) ?? Promise.resolve(false),
2523
+ ctx: this.config.context,
2524
+ observer: transcriptObserver({
2525
+ errorCopy: () => this.config.errorCopy,
2526
+ writer: {
2527
+ appendAssistantDelta: (delta) => store.getState().appendAssistantDelta(delta),
2528
+ appendError: (message) => store.getState().appendError(message),
2529
+ appendToolActivity: (activity) => store.getState().appendToolActivity(activity),
2530
+ setActiveTool: (summary) => store.getState().setActiveTool(summary),
2531
+ setAssistantMessage: (content) => store.getState().setAssistantMessage(content),
2532
+ setRunId: (runId) => store.getState().setRunId(runId),
2533
+ setSessionState: (state) => this.reportSessionState(state),
2534
+ settleToolActivity: (toolCallId, outcome) => store.getState().settleToolActivity(toolCallId, outcome)
2535
+ }
2536
+ }),
2537
+ profile: "video-director",
2538
+ recoveryFor: (tool, code) => studioRecoveryFor(tool, code, this.config.recoveryAddendum),
2539
+ transport: this.config.transport
2540
+ });
2541
+ }
2542
+ faults() {
2543
+ const { invalidateAiConfig, strings } = this.config;
2544
+ const store = this.store;
2545
+ return createConversationFaults({
2546
+ copy: {
2547
+ generic: strings.prompt.errorGeneric,
2548
+ missingOrganization: strings.director.errorNoOrganization,
2549
+ noAccess: strings.copilot.errorNoAccess,
2550
+ notConfigured: strings.copilot.errorNotConfigured,
2551
+ notEntitled: strings.copilot.withheld,
2552
+ rateLimited: strings.prompt.errorRateLimited,
2553
+ tooLarge: strings.prompt.errorTooLarge
2554
+ },
2555
+ invalidateAiConfig,
2556
+ writer: {
2557
+ appendError: (message) => store.getState().appendError(message),
2558
+ setRunId: (runId) => store.getState().setRunId(runId),
2559
+ setSessionState: (state) => {
2560
+ this.awaitingTurn = false;
2561
+ this.writeSessionState(state);
2562
+ }
2563
+ }
2564
+ });
2565
+ }
2566
+ };
2567
+ const agentErrorCopy = (strings) => ({
2568
+ accessRevoked: strings.prompt.errorAccessRevoked,
2569
+ budget: {
2570
+ cost: strings.prompt.budgetCost,
2571
+ generic: strings.prompt.budgetGeneric,
2572
+ turns: strings.prompt.budgetTurns
2573
+ },
2574
+ generic: strings.prompt.errorGeneric,
2575
+ looping: strings.prompt.errorLooping,
2576
+ notConfigured: strings.copilot.errorNotConfigured,
2577
+ rateLimited: strings.prompt.errorRateLimited
2578
+ });
2579
+ export { AgentThreadsEngine, DirectorChatEngine, PLAYBOOK, SEARCH_TAB_ID, SURFACES, WITHHELD_TAB_ID, agentErrorCopy, copilotOrganizationId, createAgentThreadsStore, recoveryFor, selectAgentDriving, selectSurfaces, surfaceTools };
2580
+
2581
+ //# sourceMappingURL=index.js.map