@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.
- package/CHANGELOG.md +69 -0
- package/LICENCE.fr.txt +280 -0
- package/LICENSE.txt +262 -0
- package/README.md +917 -2
- package/dist/agent/index.cjs +2600 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +1237 -0
- package/dist/agent/index.d.ts +1237 -0
- package/dist/agent/index.js +2581 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/chunk-3Oi_Zrtm.js +9 -0
- package/dist/chunk-3Oi_Zrtm.js.map +1 -0
- package/dist/chunk-B18OPIu_.js +6 -0
- package/dist/chunk-B18OPIu_.js.map +1 -0
- package/dist/chunk-B5Uz3Qct.cjs +15 -0
- package/dist/chunk-B5Uz3Qct.cjs.map +1 -0
- package/dist/chunk-BBEJwkd3.d.cts +839 -0
- package/dist/chunk-BIEc_SkR.cjs +29 -0
- package/dist/chunk-BIEc_SkR.cjs.map +1 -0
- package/dist/chunk-BKMFOe-N.js +171 -0
- package/dist/chunk-BKMFOe-N.js.map +1 -0
- package/dist/chunk-BP4uy7E1.d.ts +11583 -0
- package/dist/chunk-BSHTsFiB.js +1403 -0
- package/dist/chunk-BSHTsFiB.js.map +1 -0
- package/dist/chunk-BTUUABGI.js +17 -0
- package/dist/chunk-BTUUABGI.js.map +1 -0
- package/dist/chunk-BaPiaz5X.cjs +115 -0
- package/dist/chunk-BaPiaz5X.cjs.map +1 -0
- package/dist/chunk-BeCVpkYr.cjs +542 -0
- package/dist/chunk-BeCVpkYr.cjs.map +1 -0
- package/dist/chunk-BgngsvK8.cjs +6202 -0
- package/dist/chunk-BgngsvK8.cjs.map +1 -0
- package/dist/chunk-BhInd7CJ.d.cts +253 -0
- package/dist/chunk-Bn6ZbxkS.cjs +27 -0
- package/dist/chunk-By9ZnkVI.js +60 -0
- package/dist/chunk-By9ZnkVI.js.map +1 -0
- package/dist/chunk-BzqPhxsz.cjs +367 -0
- package/dist/chunk-BzqPhxsz.cjs.map +1 -0
- package/dist/chunk-C2mMX81q.d.ts +443 -0
- package/dist/chunk-C2rr9Q0V.cjs +1402 -0
- package/dist/chunk-C2rr9Q0V.cjs.map +1 -0
- package/dist/chunk-CDJCbwIQ.d.cts +78 -0
- package/dist/chunk-CLGvBOVH.d.cts +1654 -0
- package/dist/chunk-COdw1dc6.d.ts +525 -0
- package/dist/chunk-CQCJnT2i.d.ts +511 -0
- package/dist/chunk-CSyHY67q.cjs +353 -0
- package/dist/chunk-CSyHY67q.cjs.map +1 -0
- package/dist/chunk-CiK1Iqrv.js +950 -0
- package/dist/chunk-CiK1Iqrv.js.map +1 -0
- package/dist/chunk-CmJBgSwZ.cjs +24 -0
- package/dist/chunk-CmJBgSwZ.cjs.map +1 -0
- package/dist/chunk-CnrsRK2u.cjs +83 -0
- package/dist/chunk-CnrsRK2u.cjs.map +1 -0
- package/dist/chunk-Co782_9r.js +326 -0
- package/dist/chunk-Co782_9r.js.map +1 -0
- package/dist/chunk-Csr3KDpZ.cjs +32 -0
- package/dist/chunk-Csr3KDpZ.cjs.map +1 -0
- package/dist/chunk-CwkmccXv.js +89 -0
- package/dist/chunk-CwkmccXv.js.map +1 -0
- package/dist/chunk-D0Q4iL9B.cjs +255 -0
- package/dist/chunk-D0Q4iL9B.cjs.map +1 -0
- package/dist/chunk-DFwiSzUS.cjs +72 -0
- package/dist/chunk-DFwiSzUS.cjs.map +1 -0
- package/dist/chunk-DIFayl2P.d.cts +443 -0
- package/dist/chunk-DIGF58ux.d.cts +525 -0
- package/dist/chunk-DKuuuld5.js +101 -0
- package/dist/chunk-DKuuuld5.js.map +1 -0
- package/dist/chunk-DMePkFEo.js +5054 -0
- package/dist/chunk-DMePkFEo.js.map +1 -0
- package/dist/chunk-DO5SIBgu.js +305 -0
- package/dist/chunk-DO5SIBgu.js.map +1 -0
- package/dist/chunk-DOQ_7eE5.d.ts +6662 -0
- package/dist/chunk-DThaaNeb.d.cts +15 -0
- package/dist/chunk-DThaaNeb.d.ts +15 -0
- package/dist/chunk-DUQzjUJy.d.ts +78 -0
- package/dist/chunk-DX37IPhV.cjs +1903 -0
- package/dist/chunk-DX37IPhV.cjs.map +1 -0
- package/dist/chunk-Damps5Tk.cjs +155 -0
- package/dist/chunk-Damps5Tk.cjs.map +1 -0
- package/dist/chunk-DbK5PhpJ.d.ts +1654 -0
- package/dist/chunk-De0vAASv.d.ts +253 -0
- package/dist/chunk-DhSZ7YZt.d.cts +6662 -0
- package/dist/chunk-DjEvqvPA.cjs +43 -0
- package/dist/chunk-DjEvqvPA.cjs.map +1 -0
- package/dist/chunk-DkwDzwvu.d.cts +121 -0
- package/dist/chunk-DkwDzwvu.d.ts +121 -0
- package/dist/chunk-Dmszv9If.js +71 -0
- package/dist/chunk-Dmszv9If.js.map +1 -0
- package/dist/chunk-Dp_ftNWY.d.cts +511 -0
- package/dist/chunk-DsHQySz0.js +31 -0
- package/dist/chunk-DsHQySz0.js.map +1 -0
- package/dist/chunk-DwoUyHHh.js +281 -0
- package/dist/chunk-DwoUyHHh.js.map +1 -0
- package/dist/chunk-IaIDQflj.d.cts +2315 -0
- package/dist/chunk-IaIDQflj.d.ts +2315 -0
- package/dist/chunk-cVXLsZfL.d.ts +839 -0
- package/dist/chunk-mIaCX9EJ.d.cts +11583 -0
- package/dist/chunk-nJQxbOwQ.cjs +8962 -0
- package/dist/chunk-nJQxbOwQ.cjs.map +1 -0
- package/dist/chunk-o9jaxhCO.js +8852 -0
- package/dist/chunk-o9jaxhCO.js.map +1 -0
- package/dist/chunk-p-Tt_Lwz.js +14 -0
- package/dist/chunk-p-Tt_Lwz.js.map +1 -0
- package/dist/engines/index.cjs +2091 -0
- package/dist/engines/index.cjs.map +1 -0
- package/dist/engines/index.d.cts +2176 -0
- package/dist/engines/index.d.ts +2176 -0
- package/dist/engines/index.js +2075 -0
- package/dist/engines/index.js.map +1 -0
- package/dist/handlers/index.cjs +53 -0
- package/dist/handlers/index.cjs.map +1 -0
- package/dist/handlers/index.d.cts +403 -0
- package/dist/handlers/index.d.ts +403 -0
- package/dist/handlers/index.js +33 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/index.cjs +3511 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +3033 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/index.cjs +510 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.cts +296 -0
- package/dist/plugins/index.d.ts +296 -0
- package/dist/plugins/index.js +489 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/seams/index.cjs +89 -0
- package/dist/seams/index.cjs.map +1 -0
- package/dist/seams/index.d.cts +452 -0
- package/dist/seams/index.d.ts +452 -0
- package/dist/seams/index.js +49 -0
- package/dist/seams/index.js.map +1 -0
- package/dist/strings/fr/index.cjs +2135 -0
- package/dist/strings/fr/index.cjs.map +1 -0
- package/dist/strings/fr/index.d.cts +17 -0
- package/dist/strings/fr/index.d.ts +17 -0
- package/dist/strings/fr/index.js +2130 -0
- package/dist/strings/fr/index.js.map +1 -0
- package/dist/strings/index.cjs +2384 -0
- package/dist/strings/index.cjs.map +1 -0
- package/dist/strings/index.d.cts +3 -0
- package/dist/strings/index.d.ts +3 -0
- package/dist/strings/index.js +2353 -0
- package/dist/strings/index.js.map +1 -0
- package/dist/testing/index.cjs +230 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +246 -0
- package/dist/testing/index.d.ts +246 -0
- package/dist/testing/index.js +219 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/time/index.cjs +28 -0
- package/dist/time/index.cjs.map +1 -0
- package/dist/time/index.d.cts +41 -0
- package/dist/time/index.d.ts +41 -0
- package/dist/time/index.js +23 -0
- package/dist/time/index.js.map +1 -0
- package/package.json +224 -4
- package/src/agent/engines/agentThreads.ts +1601 -0
- package/src/agent/engines/directorChat.ts +500 -0
- package/src/agent/index.ts +67 -0
- package/src/agent/rules/agentEditLock.ts +115 -0
- package/src/agent/rules/agentErrorCopy.ts +44 -0
- package/src/agent/rules/copilotOrganization.ts +36 -0
- package/src/agent/rules/playbook.gen.ts +444 -0
- package/src/agent/rules/router.ts +518 -0
- package/src/agent/rules/stateDelta.ts +29 -0
- package/src/agent/rules/studioRouter.ts +123 -0
- package/src/agent/rules/surfaces.gen.ts +633 -0
- package/src/agent/rules/threadsUrl.ts +48 -0
- package/src/agent/rules/transcriptObserver.ts +90 -0
- package/src/agent/stores/agentThreads.ts +451 -0
- package/src/bus/contracts/noData.ts +18 -0
- package/src/bus/contracts/shared.ts +172 -0
- package/src/bus/contracts/studioTools.ts +224 -0
- package/src/bus/rules/bus.ts +857 -0
- package/src/bus/rules/confirmation.ts +22 -0
- package/src/bus/rules/defineRegistry.ts +24 -0
- package/src/bus/rules/errors.ts +401 -0
- package/src/bus/rules/handlerErrors.ts +103 -0
- package/src/bus/rules/handlerRegistry.ts +627 -0
- package/src/bus/rules/inputSchema.ts +232 -0
- package/src/bus/rules/invalidInput.ts +441 -0
- package/src/bus/rules/lateBoundTools.ts +100 -0
- package/src/bus/rules/studioRegistry.ts +324 -0
- package/src/bus/rules/studioToolBus.ts +73 -0
- package/src/bus/rules/types.ts +804 -0
- package/src/chrome/contracts/alert.ts +42 -0
- package/src/chrome/contracts/itinerary.ts +26 -0
- package/src/chrome/contracts/map.ts +23 -0
- package/src/chrome/contracts/overlay.ts +46 -0
- package/src/chrome/contracts/panel.ts +29 -0
- package/src/chrome/contracts/question.ts +52 -0
- package/src/chrome/contracts/selection.ts +26 -0
- package/src/chrome/contracts/sidenav.ts +23 -0
- package/src/chrome/contracts/snapshot.ts +319 -0
- package/src/chrome/contracts/state.ts +22 -0
- package/src/chrome/contracts/tabs.ts +56 -0
- package/src/chrome/handlers/alert.ts +91 -0
- package/src/chrome/handlers/introspection.ts +180 -0
- package/src/chrome/handlers/panels.ts +42 -0
- package/src/chrome/handlers/question.ts +24 -0
- package/src/chrome/handlers/sidenav.ts +116 -0
- package/src/chrome/handlers/snapshot.ts +451 -0
- package/src/chrome/handlers/stateDelta.ts +125 -0
- package/src/chrome/handlers/tabs.ts +143 -0
- package/src/chrome/handlers/timestamp.ts +19 -0
- package/src/chrome/rules/agentSelectors.ts +210 -0
- package/src/chrome/rules/mapAlert.ts +13 -0
- package/src/chrome/rules/question.ts +25 -0
- package/src/chrome/rules/tabs.ts +13 -0
- package/src/chrome/stores/activeDraftSession.ts +134 -0
- package/src/chrome/stores/chrome.ts +527 -0
- package/src/chrome/stores/uiStore.ts +575 -0
- package/src/collab/contracts/collab.ts +261 -0
- package/src/collab/handlers/collab.ts +468 -0
- package/src/collab/rules/toolNames.ts +33 -0
- package/src/collab/stores/collab.ts +899 -0
- package/src/collections/contracts/collection.ts +182 -0
- package/src/collections/handlers/collectionAttach.ts +141 -0
- package/src/collections/handlers/collections.ts +499 -0
- package/src/collections/handlers/heldCollection.ts +42 -0
- package/src/collections/handlers/restCollections.ts +386 -0
- package/src/collections/rules/collections.ts +138 -0
- package/src/collections/rules/entityCollections.ts +53 -0
- package/src/collections/stores/collections.ts +133 -0
- package/src/data/contracts/data.ts +233 -0
- package/src/data/contracts/itinerary.ts +71 -0
- package/src/data/handlers/activityResolve.ts +76 -0
- package/src/data/handlers/data.ts +200 -0
- package/src/data/handlers/graphql.ts +26 -0
- package/src/data/handlers/mutationSink.ts +1577 -0
- package/src/data/handlers/profile.ts +83 -0
- package/src/data/handlers/writeThrough.ts +417 -0
- package/src/data/rules/cache.ts +181 -0
- package/src/data/rules/dataTypes.ts +40 -0
- package/src/data/rules/keys.ts +106 -0
- package/src/data/rules/persistence.ts +1058 -0
- package/src/data/rules/requestBody.ts +43 -0
- package/src/data/rules/restErrors.ts +354 -0
- package/src/data/rules/sessionSurface.ts +156 -0
- package/src/data/rules/toolResultData.ts +73 -0
- package/src/data/rules/uuid.ts +24 -0
- package/src/edit/contracts/edit.ts +37 -0
- package/src/edit/contracts/itinerary.ts +57 -0
- package/src/edit/handlers/draftCommit.ts +257 -0
- package/src/edit/handlers/editDiscard.ts +34 -0
- package/src/edit/handlers/editLock.ts +949 -0
- package/src/edit/handlers/editor.ts +203 -0
- package/src/edit/handlers/formUnsaved.ts +24 -0
- package/src/edit/rules/draftMetadata.ts +117 -0
- package/src/edit/rules/editKeyboard.ts +222 -0
- package/src/edit/rules/editShortcuts.ts +102 -0
- package/src/edit/rules/editTooltip.ts +174 -0
- package/src/edit/rules/editorTaken.ts +49 -0
- package/src/edit/rules/history.ts +26 -0
- package/src/edit/rules/unsavedWork.ts +60 -0
- package/src/edit/stores/editorReservation.ts +70 -0
- package/src/edit/stores/formsUnsaved.ts +54 -0
- package/src/embed/contracts/embed.ts +48 -0
- package/src/embed/engines/embedFraming.ts +1329 -0
- package/src/embed/engines/embedReady.ts +353 -0
- package/src/embed/engines/framingPageSession.ts +169 -0
- package/src/embed/handlers/embed.ts +130 -0
- package/src/embed/rules/allowedDomains.ts +71 -0
- package/src/embed/rules/bridgeMessages.ts +224 -0
- package/src/embed/rules/defaults.ts +173 -0
- package/src/embed/rules/displaySeed.ts +115 -0
- package/src/embed/rules/embedAllowlist.ts +146 -0
- package/src/embed/rules/embedConstraints.ts +215 -0
- package/src/embed/rules/embedElements.ts +277 -0
- package/src/embed/rules/embedSectionFields.ts +126 -0
- package/src/embed/rules/embedSecurity.ts +116 -0
- package/src/embed/rules/fieldDependencies.ts +89 -0
- package/src/embed/rules/fieldOptions.ts +138 -0
- package/src/embed/rules/layerOptions.ts +161 -0
- package/src/embed/rules/readyProtocol.ts +66 -0
- package/src/embed/rules/safetyRules.ts +215 -0
- package/src/embed/rules/snippet.ts +531 -0
- package/src/embed/rules/tableCode.ts +270 -0
- package/src/embed/stores/embed.ts +60 -0
- package/src/embed/stores/embedContent.ts +77 -0
- package/src/engines/index.ts +81 -0
- package/src/handlers/index.ts +66 -0
- package/src/index.ts +1065 -0
- package/src/itinerary/contracts/itinerary.ts +705 -0
- package/src/itinerary/engines/itineraryPace.ts +612 -0
- package/src/itinerary/engines/profileMarker.ts +238 -0
- package/src/itinerary/handlers/importStaging.ts +352 -0
- package/src/itinerary/handlers/itinerary.ts +572 -0
- package/src/itinerary/handlers/itineraryDuplicate.ts +177 -0
- package/src/itinerary/handlers/itineraryExport.ts +117 -0
- package/src/itinerary/handlers/itineraryImport.ts +783 -0
- package/src/itinerary/handlers/itineraryPublish.ts +118 -0
- package/src/itinerary/handlers/itinerarySelection.ts +354 -0
- package/src/itinerary/handlers/itinerarySuggest.ts +1186 -0
- package/src/itinerary/handlers/itineraryUnpublish.ts +101 -0
- package/src/itinerary/handlers/publicationScope.ts +118 -0
- package/src/itinerary/handlers/restItineraries.ts +752 -0
- package/src/itinerary/handlers/restItineraryExport.ts +70 -0
- package/src/itinerary/handlers/restItineraryImport.ts +311 -0
- package/src/itinerary/handlers/restItineraryPace.ts +87 -0
- package/src/itinerary/handlers/restItineraryRecord.ts +36 -0
- package/src/itinerary/handlers/suggestParams.ts +379 -0
- package/src/itinerary/handlers/suggestStaging.ts +363 -0
- package/src/itinerary/handlers/surfaceOpen.ts +389 -0
- package/src/itinerary/rules/activity.ts +139 -0
- package/src/itinerary/rules/analysis.ts +42 -0
- package/src/itinerary/rules/ceiling.ts +49 -0
- package/src/itinerary/rules/createFlow.ts +107 -0
- package/src/itinerary/rules/densify.ts +440 -0
- package/src/itinerary/rules/draftSurface.ts +219 -0
- package/src/itinerary/rules/editorView.ts +83 -0
- package/src/itinerary/rules/export.ts +159 -0
- package/src/itinerary/rules/friendlyName.ts +77 -0
- package/src/itinerary/rules/import.ts +1050 -0
- package/src/itinerary/rules/importFiles.ts +140 -0
- package/src/itinerary/rules/importTotals.ts +77 -0
- package/src/itinerary/rules/liveSegment.ts +712 -0
- package/src/itinerary/rules/lngLat.ts +17 -0
- package/src/itinerary/rules/mapSync.ts +100 -0
- package/src/itinerary/rules/previewRender.ts +416 -0
- package/src/itinerary/rules/profileReadout.ts +216 -0
- package/src/itinerary/rules/routing.ts +707 -0
- package/src/itinerary/rules/suggest.ts +522 -0
- package/src/itinerary/rules/suggestionPreview.ts +119 -0
- package/src/itinerary/rules/view.ts +61 -0
- package/src/itinerary/stores/importSession.ts +319 -0
- package/src/itinerary/stores/itinerary.ts +331 -0
- package/src/itinerary/stores/itineraryDuplicate.ts +76 -0
- package/src/itinerary/stores/sessionIdentity.ts +43 -0
- package/src/itinerary/stores/suggestSession.ts +418 -0
- package/src/layers/contracts/itinerary.ts +46 -0
- package/src/layers/contracts/overlay.ts +132 -0
- package/src/layers/handlers/enrichment.ts +36 -0
- package/src/layers/handlers/overlay.ts +406 -0
- package/src/layers/handlers/restLayers.ts +94 -0
- package/src/layers/handlers/tiles.ts +25 -0
- package/src/layers/rules/layers.ts +212 -0
- package/src/layers/rules/overlayInstant.ts +12 -0
- package/src/layers/rules/reachabilityIcon.ts +18 -0
- package/src/layers/rules/readout.ts +102 -0
- package/src/layers/stores/layers.ts +262 -0
- package/src/map/contracts/contextmenu.ts +33 -0
- package/src/map/contracts/geolocate.ts +37 -0
- package/src/map/contracts/map.ts +146 -0
- package/src/map/contracts/streetview.ts +53 -0
- package/src/map/contracts/terrain.ts +152 -0
- package/src/map/handlers/contextMenu.ts +135 -0
- package/src/map/handlers/geolocate.ts +52 -0
- package/src/map/handlers/map.ts +391 -0
- package/src/map/handlers/streetview.ts +94 -0
- package/src/map/handlers/terrain.ts +663 -0
- package/src/map/rules/baseTerrain.ts +75 -0
- package/src/map/rules/clickTargets.ts +464 -0
- package/src/map/rules/constraints.ts +32 -0
- package/src/map/rules/contextMenuReadout.ts +67 -0
- package/src/map/rules/coordinates.ts +71 -0
- package/src/map/rules/itineraryFit.ts +8 -0
- package/src/map/rules/mapEvents.ts +64 -0
- package/src/map/rules/mapProjection.ts +476 -0
- package/src/map/rules/terrainReading.ts +62 -0
- package/src/plugins/contracts/ids.ts +66 -0
- package/src/plugins/contracts/plugin.ts +202 -0
- package/src/plugins/contracts/slots.ts +137 -0
- package/src/plugins/engines/studioPlugin.ts +1365 -0
- package/src/plugins/index.ts +111 -0
- package/src/plugins/rules/contributions.ts +152 -0
- package/src/plugins/rules/errors.ts +60 -0
- package/src/plugins/rules/ids.ts +42 -0
- package/src/plugins/rules/validation.ts +249 -0
- package/src/rules/listeners.ts +57 -0
- package/src/rules/origin.ts +13 -0
- package/src/rules/storeWrite.ts +37 -0
- package/src/rules/types.ts +136 -0
- package/src/seams/index.ts +79 -0
- package/src/seams/rules/clock.ts +28 -0
- package/src/seams/rules/formatters.ts +211 -0
- package/src/seams/rules/ids.ts +102 -0
- package/src/seams/rules/links.ts +66 -0
- package/src/seams/rules/navigation.ts +222 -0
- package/src/seams/rules/notify.ts +49 -0
- package/src/seams/rules/persistenceDrawer.ts +220 -0
- package/src/seams/rules/saveFile.ts +101 -0
- package/src/seams/rules/seams.ts +156 -0
- package/src/seams/rules/storage.ts +116 -0
- package/src/search/contracts/overlay.ts +74 -0
- package/src/search/contracts/search.ts +197 -0
- package/src/search/handlers/pois.ts +57 -0
- package/src/search/handlers/search.ts +280 -0
- package/src/search/rules/params.ts +925 -0
- package/src/search/rules/poiGroups.ts +138 -0
- package/src/search/rules/searchFetch.ts +139 -0
- package/src/search/rules/timeWindow.ts +30 -0
- package/src/search/stores/search.ts +51 -0
- package/src/segments/contracts/itinerary.ts +433 -0
- package/src/segments/contracts/segment.ts +35 -0
- package/src/segments/engines/segmentDraft.ts +926 -0
- package/src/segments/handlers/chainGuards.ts +67 -0
- package/src/segments/handlers/directions.ts +44 -0
- package/src/segments/handlers/itineraryEcho.ts +45 -0
- package/src/segments/handlers/roadAccessDialog.ts +34 -0
- package/src/segments/handlers/segment.ts +111 -0
- package/src/segments/handlers/segmentEdit.ts +1341 -0
- package/src/segments/handlers/segmentGroups.ts +347 -0
- package/src/segments/handlers/segmentStructure.ts +1144 -0
- package/src/segments/rules/chain.ts +196 -0
- package/src/segments/rules/chainModel.ts +217 -0
- package/src/segments/rules/colors.ts +11 -0
- package/src/segments/rules/commit.ts +76 -0
- package/src/segments/rules/draft.ts +90 -0
- package/src/segments/rules/draftDisposition.ts +43 -0
- package/src/segments/rules/draftSegmentEdit.ts +129 -0
- package/src/segments/rules/engine.ts +222 -0
- package/src/segments/rules/groupSave.ts +234 -0
- package/src/segments/rules/hazardPrompt.ts +60 -0
- package/src/segments/rules/itineraryEcho.ts +40 -0
- package/src/segments/rules/liveSegmentProjection.ts +55 -0
- package/src/segments/rules/merge.ts +51 -0
- package/src/segments/rules/metrics.ts +456 -0
- package/src/segments/rules/naming.ts +168 -0
- package/src/segments/rules/segmentArming.ts +144 -0
- package/src/segments/rules/splitPick.ts +84 -0
- package/src/segments/rules/viaSimplify.ts +230 -0
- package/src/segments/stores/directions.ts +77 -0
- package/src/segments/stores/roadAccessDialog.ts +58 -0
- package/src/segments/stores/segmentEdit.ts +922 -0
- package/src/segments/stores/segmentGroupEdit.ts +84 -0
- package/src/segments/stores/segmentSplit.ts +77 -0
- package/src/share/contracts/share.ts +39 -0
- package/src/share/contracts/shareLink.ts +63 -0
- package/src/share/engines/shareLink.ts +1053 -0
- package/src/share/handlers/share.ts +47 -0
- package/src/share/handlers/shareLink.ts +231 -0
- package/src/share/handlers/shareScope.ts +54 -0
- package/src/share/rules/link.ts +89 -0
- package/src/share/rules/shareLink.ts +218 -0
- package/src/share/rules/targets.ts +92 -0
- package/src/share/rules/viewConfig.ts +95 -0
- package/src/share/stores/share.ts +58 -0
- package/src/strings/fr/index.ts +18 -0
- package/src/strings/fr/rules/fr.ts +2368 -0
- package/src/strings/index.ts +98 -0
- package/src/strings/rules/confirmCopy.ts +156 -0
- package/src/strings/rules/draftToolNames.ts +94 -0
- package/src/strings/rules/en.ts +2519 -0
- package/src/strings/rules/failureAlert.ts +115 -0
- package/src/strings/rules/formError.ts +400 -0
- package/src/strings/rules/maneuvers.ts +107 -0
- package/src/strings/rules/outputOptions.ts +126 -0
- package/src/strings/rules/publicationState.ts +100 -0
- package/src/strings/rules/routeHazardCopy.ts +62 -0
- package/src/strings/rules/searchLabels.ts +50 -0
- package/src/strings/rules/segmentChainVerbs.ts +62 -0
- package/src/strings/rules/studioCopy.ts +130 -0
- package/src/strings/rules/unitOptions.ts +119 -0
- package/src/testing/checkedBus.ts +226 -0
- package/src/testing/index.ts +30 -0
- package/src/testing/plugins.ts +106 -0
- package/src/testing/studio.ts +267 -0
- package/src/testing/urlSeam.ts +153 -0
- package/src/time/index.ts +12 -0
- package/src/time/rules/sun.ts +78 -0
- package/src/video/contracts/cameraSchemas.ts +266 -0
- package/src/video/contracts/profileSchemas.ts +37 -0
- package/src/video/contracts/video.ts +601 -0
- package/src/video/handlers/video.ts +1638 -0
- package/src/video/handlers/videoDirector.ts +114 -0
- package/src/video/rules/previewRefresh.ts +76 -0
- package/src/video/rules/profileSource.ts +51 -0
- package/src/video/rules/routeSpans.ts +79 -0
- package/src/video/rules/shotDefaults.ts +28 -0
- package/src/video/rules/stepOrder.ts +17 -0
- package/src/video/rules/videoSnapshot.ts +136 -0
- package/src/video/stores/directorThreads.ts +167 -0
- package/src/video/stores/videoExport.ts +290 -0
- package/src/viewer/contracts/preferences.ts +40 -0
- package/src/viewer/handlers/preferences.ts +91 -0
- package/src/viewer/rules/capabilities.ts +42 -0
- package/src/viewer/rules/config.ts +266 -0
- package/src/viewer/rules/context.ts +375 -0
- package/src/viewer/rules/ownership.ts +134 -0
- package/src/viewer/rules/platformViewer.ts +199 -0
- package/src/viewer/rules/scope.ts +197 -0
- package/src/viewer/rules/url.ts +145 -0
- package/src/viewer/rules/viewer.ts +307 -0
- package/src/viewer/rules/viewerSeam.ts +49 -0
- package/src/viewer/rules/viewerUnits.ts +34 -0
- package/src/waypoints/contracts/itinerary.ts +417 -0
- package/src/waypoints/handlers/poiWaypointStyle.ts +32 -0
- package/src/waypoints/handlers/waypointDetailsDialog.ts +38 -0
- package/src/waypoints/handlers/waypointEdit.ts +1073 -0
- package/src/waypoints/rules/amenities.ts +30 -0
- package/src/waypoints/rules/defaults.ts +31 -0
- package/src/waypoints/rules/details.ts +213 -0
- package/src/waypoints/rules/detailsDraft.ts +312 -0
- package/src/waypoints/rules/detailsPreview.ts +76 -0
- package/src/waypoints/rules/detailsSave.ts +356 -0
- package/src/waypoints/rules/draftDirty.ts +45 -0
- package/src/waypoints/rules/icons.ts +32 -0
- package/src/waypoints/rules/liveWaypoint.ts +63 -0
- package/src/waypoints/rules/naming.ts +185 -0
- package/src/waypoints/rules/sections.ts +77 -0
- package/src/waypoints/rules/waypointDraft.ts +62 -0
- package/src/waypoints/stores/waypointDetails.ts +62 -0
- package/src/waypoints/stores/waypointEdit.ts +566 -0
- package/src/zones/contracts/collection.ts +37 -0
- package/src/zones/contracts/zone.ts +528 -0
- package/src/zones/engines/zoneForm.ts +1773 -0
- package/src/zones/handlers/restZones.ts +287 -0
- package/src/zones/handlers/zonePublish.ts +206 -0
- package/src/zones/handlers/zoneUnpublish.ts +56 -0
- package/src/zones/handlers/zones.ts +2254 -0
- package/src/zones/rules/geometry.ts +946 -0
- package/src/zones/rules/zoneDefaults.ts +34 -0
- package/src/zones/rules/zoneDraft.ts +54 -0
- package/src/zones/rules/zoneForm.ts +563 -0
- package/src/zones/rules/zoneMetadata.ts +29 -0
- package/src/zones/rules/zoneSource.ts +87 -0
- package/src/zones/rules/zoneSourceRefusal.ts +104 -0
- package/src/zones/stores/zoneEdit.ts +998 -0
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import type { StudioToolContext } from "../../viewer/rules/context.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* RouterState is the slice of the studio snapshot the router reads. It is
|
|
5
|
+
* deliberately narrow and structural rather than the whole snapshot: the router
|
|
6
|
+
* is a pure function, and a wide input would let it drift into depending on
|
|
7
|
+
* things that have nothing to do with which tools a task needs.
|
|
8
|
+
*
|
|
9
|
+
* Every field is here because a surface lock of the compiled tables reads it, which
|
|
10
|
+
* its suite asserts both ways: a lock naming a field this interface does not carry
|
|
11
|
+
* fails to compile in lockHolds, and a field no lock reads is a slice the router
|
|
12
|
+
* pays to assemble and never consults.
|
|
13
|
+
*/
|
|
14
|
+
export interface RouterState {
|
|
15
|
+
/** The kind of edit session currently armed, if any. */
|
|
16
|
+
editSession?: "segment" | "waypoint" | "zone" | null | undefined;
|
|
17
|
+
/** Whether an import draft is open. */
|
|
18
|
+
importDraft?: boolean | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The kind of resource the editor currently holds open, if any. It is distinct
|
|
21
|
+
* from `editSession`, which reports only an ARMED geometry engine: a computed
|
|
22
|
+
* zone is open without arming one (reshaping it by hand would replace the query
|
|
23
|
+
* it is generated from), so a run about the zone the user is looking at has no
|
|
24
|
+
* armed session to be recognised by.
|
|
25
|
+
*/
|
|
26
|
+
openResource?: "itinerary" | "zone" | null | undefined;
|
|
27
|
+
/** Whether a route-suggestion draft is open. */
|
|
28
|
+
suggestDraft?: boolean | undefined;
|
|
29
|
+
/** Whether the video wizard is open. */
|
|
30
|
+
videoOpen?: boolean | undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* routerStateFrom reads the router's inputs off the live studio context. It sits
|
|
35
|
+
* here, beside the router, rather than in the surface that calls it: the ui
|
|
36
|
+
* store's shape is this package's concern, and a host that had to assemble
|
|
37
|
+
* RouterState itself would have to learn which slices count as "mid-task".
|
|
38
|
+
*/
|
|
39
|
+
export const routerStateFrom = (ctx: StudioToolContext): RouterState => {
|
|
40
|
+
const ui = ctx.ui.getState();
|
|
41
|
+
|
|
42
|
+
// Mutual exclusion is a store invariant: at most one edit session is armed.
|
|
43
|
+
const editSession = ui.segmentEditSession
|
|
44
|
+
? "segment"
|
|
45
|
+
: ui.waypointEditSession
|
|
46
|
+
? "waypoint"
|
|
47
|
+
: ui.zoneEditSession
|
|
48
|
+
? "zone"
|
|
49
|
+
: null;
|
|
50
|
+
|
|
51
|
+
// The open resource, independent of whether an engine is armed over it. A zone
|
|
52
|
+
// wins over an itinerary because it is the more specific thing to be looking at:
|
|
53
|
+
// a zone is only ever open because the user opened it, while an itinerary can
|
|
54
|
+
// sit open in the background behind it.
|
|
55
|
+
const openResource =
|
|
56
|
+
ui.activeZone !== null ? "zone" : ui.activeItinerary !== null ? "itinerary" : null;
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
editSession,
|
|
60
|
+
importDraft: ui.importSession !== null,
|
|
61
|
+
openResource,
|
|
62
|
+
suggestDraft: ui.suggestSession !== null,
|
|
63
|
+
videoOpen: ui.videoExport !== null,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* RouterDecision is the routed surface set plus why it was chosen. The reason is
|
|
69
|
+
* not decoration: a misroute is otherwise invisible, and recording which signal
|
|
70
|
+
* fired is what makes the router's accuracy measurable once telemetry carries
|
|
71
|
+
* the surfaces a run actually used.
|
|
72
|
+
*/
|
|
73
|
+
export interface RouterDecision {
|
|
74
|
+
reason: "lock" | "skill" | "intent" | "sticky" | "wide";
|
|
75
|
+
surfaces: readonly string[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* RouterSurface is one routable surface as the router reads it: what it is called, which
|
|
80
|
+
* tools it permits, the keywords that reach for it, and the two flags that decide whether it
|
|
81
|
+
* is always on and whether the ignorance fallback may include it.
|
|
82
|
+
*
|
|
83
|
+
* Declared here rather than imported from the compiled table, which is the whole point of
|
|
84
|
+
* this file taking its tables as an argument: the compiled tables are generated artifacts,
|
|
85
|
+
* and the model descriptions and read/write classification in them are product decisions
|
|
86
|
+
* rather than a contract anyone else inherits. Naming the shape structurally lets the
|
|
87
|
+
* compiled tables satisfy it without this module ever knowing they exist.
|
|
88
|
+
*/
|
|
89
|
+
interface RouterSurface {
|
|
90
|
+
always: boolean;
|
|
91
|
+
id: string;
|
|
92
|
+
keywords: readonly string[];
|
|
93
|
+
members: readonly string[];
|
|
94
|
+
wideFallback: boolean;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* RouterSurfaceLock is one snapshot predicate that forces a surface: the state field to read,
|
|
99
|
+
* and the value that arms it.
|
|
100
|
+
*
|
|
101
|
+
* `field` is `keyof RouterState`, which is where the compiled table's own guarantee lands. A
|
|
102
|
+
* lock naming a field {@link RouterState} does not carry fails on the BINDING (one line, at the
|
|
103
|
+
* point the compiled table is handed in) rather than on whichever line happens to index it.
|
|
104
|
+
*/
|
|
105
|
+
interface RouterSurfaceLock {
|
|
106
|
+
equals: string | boolean | null;
|
|
107
|
+
field: keyof RouterState;
|
|
108
|
+
surface: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* RouterSkillRoute is one skill's routing footprint: the literal intent phrasings that
|
|
113
|
+
* retrieve it and the task surfaces its procedure spans.
|
|
114
|
+
*/
|
|
115
|
+
interface RouterSkillRoute {
|
|
116
|
+
id: string;
|
|
117
|
+
intents: readonly string[];
|
|
118
|
+
surfaces: readonly string[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** RouterRecovery is the instruction for one failure code of one tool. */
|
|
122
|
+
interface RouterRecovery {
|
|
123
|
+
code: string;
|
|
124
|
+
do: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** RouterPlaybookEntry is the one part of a playbook entry the router reads. */
|
|
128
|
+
interface RouterPlaybookEntry {
|
|
129
|
+
id: string;
|
|
130
|
+
recovery: readonly RouterRecovery[];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* RouterTables are the compiled tables a router routes with: the surfaces, the locks that
|
|
135
|
+
* force them, the skill routes and the playbook.
|
|
136
|
+
*
|
|
137
|
+
* They arrive as a value rather than as an import, which is the shape every product
|
|
138
|
+
* decision a package would otherwise bake in takes: a host that authors its own surfaces
|
|
139
|
+
* builds a router over them, and the studio binds the ones it ships.
|
|
140
|
+
*/
|
|
141
|
+
interface RouterTables {
|
|
142
|
+
playbook: readonly RouterPlaybookEntry[];
|
|
143
|
+
skillRoutes: readonly RouterSkillRoute[];
|
|
144
|
+
surfaceLocks: readonly RouterSurfaceLock[];
|
|
145
|
+
surfaces: readonly RouterSurface[];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* StudioRouter is what a bound set of tables answers: which surfaces a turn needs, which
|
|
150
|
+
* tools those surfaces permit, and what to do about a named failure.
|
|
151
|
+
*
|
|
152
|
+
* {@link routerStateFrom} is deliberately NOT on it. It reads the live studio context and no
|
|
153
|
+
* table at all, so binding it to a table set would suggest a dependence it does not have.
|
|
154
|
+
*/
|
|
155
|
+
interface StudioRouter {
|
|
156
|
+
recoveryFor: (tool: string, code: string | undefined) => string | undefined;
|
|
157
|
+
selectSurfaces: (
|
|
158
|
+
message: string,
|
|
159
|
+
state?: RouterState,
|
|
160
|
+
previous?: readonly string[],
|
|
161
|
+
) => RouterDecision;
|
|
162
|
+
surfaceTools: (surfaces: readonly string[]) => ReadonlySet<string>;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* compareIds orders two ids by their UTF-16 code units, the same on every machine.
|
|
167
|
+
*
|
|
168
|
+
* A tie between two routes or two surfaces is cut by id, and the cut decides which of them a
|
|
169
|
+
* turn keeps. `localeCompare` reads the runtime's own language, where Estonian sorts `z` before
|
|
170
|
+
* `t`, so the surfaces of one message would depend on the browser's settings. The ids are ASCII,
|
|
171
|
+
* so this is also the byte order the gateway's own ranking cuts its ties by.
|
|
172
|
+
*/
|
|
173
|
+
const compareIds = (a: string, b: string): number => {
|
|
174
|
+
if (a === b) {
|
|
175
|
+
return 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return a < b ? -1 : 1;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* createStudioRouter binds one set of compiled tables into a router.
|
|
183
|
+
*
|
|
184
|
+
* The keyword patterns are compiled ONCE here rather than per call, which is why this is a
|
|
185
|
+
* factory rather than functions each taking the tables: the table is static for the life of a
|
|
186
|
+
* router, and compiling a pattern per keyword per message would be paid in the one pure
|
|
187
|
+
* function that runs on every turn.
|
|
188
|
+
*
|
|
189
|
+
* It is one long closure on purpose. Each function in it is short and reads the same bound
|
|
190
|
+
* tables and the same two limits, and most of its lines are the reasons beside them; a split
|
|
191
|
+
* would pass the tables between modules for no reader's benefit.
|
|
192
|
+
*/
|
|
193
|
+
export const createStudioRouter = ({
|
|
194
|
+
playbook,
|
|
195
|
+
skillRoutes,
|
|
196
|
+
surfaceLocks,
|
|
197
|
+
surfaces: surfaceTable,
|
|
198
|
+
}: RouterTables): StudioRouter => {
|
|
199
|
+
/**
|
|
200
|
+
* wideFallbackSurfaces are the surfaces the fallback below may reach for. Which
|
|
201
|
+
* surfaces those are is a property of the authored table, not a list written here:
|
|
202
|
+
* a surface opts out with `wideFallback: false` in surfaces.yaml, beside the
|
|
203
|
+
* reasoning for it. Naming the ids here instead would let a rename in the YAML
|
|
204
|
+
* silently reopen a surface the fallback is supposed to withhold.
|
|
205
|
+
*/
|
|
206
|
+
const wideFallbackSurfaces = (): readonly string[] =>
|
|
207
|
+
surfaceTable.filter((surface) => surface.wideFallback).map((surface) => surface.id);
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* alwaysOn names the surfaces every manifest carries. They are resolved from the bound
|
|
211
|
+
* table rather than hardcoded, so the always-on surface is a property of surfaces.yaml.
|
|
212
|
+
*/
|
|
213
|
+
const alwaysOn = (): readonly string[] =>
|
|
214
|
+
surfaceTable.filter((surface) => surface.always).map((surface) => surface.id);
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* lockHolds evaluates one generated lock against live state. State beats text: a
|
|
218
|
+
* user with a segment edit armed is editing that segment whatever their next
|
|
219
|
+
* message happens to mention, and routing away from the tools that finish the
|
|
220
|
+
* edit would strand them mid-task.
|
|
221
|
+
*
|
|
222
|
+
* The lock table is compiled from surfaces.yaml rather than written here, and
|
|
223
|
+
* indexing RouterState by the generated field is what makes that safe: a lock
|
|
224
|
+
* naming a field this interface does not carry fails `tsc` on this line. A
|
|
225
|
+
* hand-written table beside the interface would drift from the YAML with nothing
|
|
226
|
+
* to catch it.
|
|
227
|
+
*/
|
|
228
|
+
const lockHolds = (lock: RouterSurfaceLock, state: RouterState): boolean =>
|
|
229
|
+
state[lock.field] === lock.equals;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* MAX_TASK_SURFACES bounds how many surfaces KEYWORD matching rides alongside
|
|
233
|
+
* core. Two keeps a routed manifest small enough to be the point of routing; a
|
|
234
|
+
* message that genuinely spans more than two areas is better served by the
|
|
235
|
+
* top-scoring pair than by quietly reassembling the whole registry.
|
|
236
|
+
*/
|
|
237
|
+
const MAX_TASK_SURFACES = 2;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* MAX_CARRIED_SURFACES bounds how many task surfaces a decision (and therefore
|
|
241
|
+
* the sticky carry) can hold. Four, because a decision unions a state LOCK with
|
|
242
|
+
* intent rather than choosing between them: a skill match routes the skill's whole
|
|
243
|
+
* procedure (up to the three task surfaces generation permits a skill to span) and
|
|
244
|
+
* one lock rides alongside it. A lower cap would hand a run a retrieved procedure
|
|
245
|
+
* naming a tool the manifest excludes.
|
|
246
|
+
*/
|
|
247
|
+
const MAX_CARRIED_SURFACES = 4;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* foldApostrophes rewrites the typographic apostrophe (U+2019) to the ASCII one
|
|
251
|
+
* the tables are authored with, so a message typed on a phone keyboard reads as
|
|
252
|
+
* the same words as one typed on a laptop.
|
|
253
|
+
*
|
|
254
|
+
* It runs ONCE, at the entry, and both matchers read its result. Folding for the
|
|
255
|
+
* skill intents alone would leave the keyword table half-folded: surfaces.yaml
|
|
256
|
+
* permits an apostrophe in a keyword exactly as it does in an intent, and a
|
|
257
|
+
* French keyword like "point d'eau" that matched only one of the two spellings
|
|
258
|
+
* would be a silent routing hole on half the product's languages, the kind that
|
|
259
|
+
* never raises an error and quietly hands the model the wrong tools.
|
|
260
|
+
*/
|
|
261
|
+
const foldApostrophes = (message: string): string => message.replace(/’/g, "'");
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* matchSkillRoutes mirrors the gateway's skill selection exactly (lowercase,
|
|
265
|
+
* literal whole-phrase containment, ranked by matched-intent count then id,
|
|
266
|
+
* capped at three) and returns the task surfaces the matched skills' procedures
|
|
267
|
+
* span, in rank order, capped at MAX_CARRIED_SURFACES by ordered insertion. The
|
|
268
|
+
* top-ranked skill always fits whole (generation bounds one skill at three task
|
|
269
|
+
* surfaces), so the procedure that will actually lead the run is never
|
|
270
|
+
* truncated. It reads an already-folded message (see {@link foldApostrophes}),
|
|
271
|
+
* the other half of that mirror.
|
|
272
|
+
*
|
|
273
|
+
* Mirroring matters more than sharing: the gateway matches the same authored
|
|
274
|
+
* intents in its own code, and the two sides diverging would have retrieval
|
|
275
|
+
* select a card whose tools routing never offered.
|
|
276
|
+
*/
|
|
277
|
+
const matchSkillRoutes = (message: string): readonly string[] => {
|
|
278
|
+
const lowered = message.toLowerCase();
|
|
279
|
+
|
|
280
|
+
const hits = skillRoutes
|
|
281
|
+
.map((route) => ({
|
|
282
|
+
matches: route.intents.filter((intent) => intent !== "" && lowered.includes(intent)).length,
|
|
283
|
+
route,
|
|
284
|
+
}))
|
|
285
|
+
.filter((entry) => entry.matches > 0)
|
|
286
|
+
.sort((a, b) => b.matches - a.matches || compareIds(a.route.id, b.route.id))
|
|
287
|
+
.slice(0, 3);
|
|
288
|
+
|
|
289
|
+
const surfaces: string[] = [];
|
|
290
|
+
for (const hit of hits) {
|
|
291
|
+
for (const id of hit.route.surfaces) {
|
|
292
|
+
if (surfaces.length >= MAX_CARRIED_SURFACES) {
|
|
293
|
+
return surfaces;
|
|
294
|
+
}
|
|
295
|
+
if (!surfaces.includes(id)) {
|
|
296
|
+
surfaces.push(id);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return surfaces;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* surfacePatterns holds one compiled whole-word pattern per keyword per surface,
|
|
306
|
+
* built once per router. The keyword table is static (surfaces.gen.ts), so compiling per
|
|
307
|
+
* call would pay a RegExp construction and an escape pass per keyword per message, in the
|
|
308
|
+
* one pure function that runs on every turn.
|
|
309
|
+
*/
|
|
310
|
+
const surfacePatterns: ReadonlyMap<string, readonly RegExp[]> = new Map(
|
|
311
|
+
surfaceTable.map((surface) => [
|
|
312
|
+
surface.id,
|
|
313
|
+
surface.keywords.map(
|
|
314
|
+
// Unicode-aware word boundaries, not \b. \b is defined by ASCII \w
|
|
315
|
+
// transitions, so a keyword starting or ending on an accented letter
|
|
316
|
+
// ("météo", "vidéo", "évite") could NEVER match: there is no \w transition
|
|
317
|
+
// at "é", so \bé matches nothing. Half the product's languages is French.
|
|
318
|
+
//
|
|
319
|
+
// The LEADING boundary excludes letters but not digits: people glue a
|
|
320
|
+
// number onto a unit ("target 12km", "600m ascent"), and a digit-blind
|
|
321
|
+
// boundary would make the unit keyword unmatchable exactly in the messages
|
|
322
|
+
// it exists for. A letter still blocks ("workman" does not fire "km"); the
|
|
323
|
+
// trailing boundary keeps digits so "km2" stays a non-match.
|
|
324
|
+
(keyword) =>
|
|
325
|
+
new RegExp(
|
|
326
|
+
`(?<![\\p{L}_])${keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\p{L}\\p{N}_])`,
|
|
327
|
+
"iu",
|
|
328
|
+
),
|
|
329
|
+
),
|
|
330
|
+
]),
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* scoreSurface counts how many of a surface's keywords appear in the message.
|
|
335
|
+
* Whole-word matching, so "route" does not fire on "router" and, more to the
|
|
336
|
+
* point, a short keyword cannot match inside an unrelated longer word.
|
|
337
|
+
*/
|
|
338
|
+
const scoreSurface = (surface: RouterSurface, message: string): number => {
|
|
339
|
+
let score = 0;
|
|
340
|
+
for (const pattern of surfacePatterns.get(surface.id) ?? []) {
|
|
341
|
+
if (pattern.test(message)) {
|
|
342
|
+
score += 1;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return score;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* selectSurfaces chooses the surfaces a turn's manifest is built from.
|
|
351
|
+
*
|
|
352
|
+
* The order is load-bearing. Hard state locks come FIRST but they SEED the
|
|
353
|
+
* selection rather than settling it: what the user is in the middle of ranks
|
|
354
|
+
* above what they just typed, yet it never silences it. Intent (the skill
|
|
355
|
+
* procedure, then keywords) fills the room that remains. Stickiness comes last
|
|
356
|
+
* and is the difference between routing paying for itself and costing more than
|
|
357
|
+
* it saves: every surface change invalidates the provider's cached prompt
|
|
358
|
+
* prefix, so a router that flips freely is worse than no router at all.
|
|
359
|
+
*
|
|
360
|
+
* A lock that RETURNED outright would hand a run a read-only manifest for a
|
|
361
|
+
* mutation task: someone mid-segment-edit who asks for route suggestions
|
|
362
|
+
* ("target 12km, 600m ascent, favorise hillshade") would route to core and
|
|
363
|
+
* routing before the keyword table, which scores that message for discovery and
|
|
364
|
+
* terrain, is ever consulted, and the model would be told by its procedure to call
|
|
365
|
+
* suggest tools whose schemas it was never shown.
|
|
366
|
+
*
|
|
367
|
+
* It is a pure function of its inputs (no clock, no network, no model), so it
|
|
368
|
+
* is cheap enough to run per turn and can be reasoned about from its tests.
|
|
369
|
+
*/
|
|
370
|
+
const selectSurfaces = (
|
|
371
|
+
message: string,
|
|
372
|
+
state: RouterState = {},
|
|
373
|
+
previous: readonly string[] = [],
|
|
374
|
+
): RouterDecision => {
|
|
375
|
+
const core = alwaysOn();
|
|
376
|
+
const known = new Set(surfaceTable.map((surface) => surface.id));
|
|
377
|
+
|
|
378
|
+
// One fold, both matchers. See foldApostrophes.
|
|
379
|
+
const folded = foldApostrophes(message);
|
|
380
|
+
|
|
381
|
+
const locked = surfaceLocks
|
|
382
|
+
.filter((lock) => lockHolds(lock, state))
|
|
383
|
+
.map((lock) => lock.surface)
|
|
384
|
+
.filter((id) => known.has(id) && !core.includes(id))
|
|
385
|
+
.slice(0, MAX_TASK_SURFACES);
|
|
386
|
+
|
|
387
|
+
// A matched skill routes its PROCEDURE: retrieval (on the gateway, from the same
|
|
388
|
+
// authored intents) hands the model a card instructing these surfaces' tools, and a
|
|
389
|
+
// manifest that excluded any of them would teach a capability the run does not
|
|
390
|
+
// have. "génère des itinéraires … dénivelé …" is the shape: the keyword table hears
|
|
391
|
+
// only "dénivelé" (terrain) while the card instructs the suggest pipeline, so keywords
|
|
392
|
+
// alone would hand a mutation task a read-only manifest.
|
|
393
|
+
const skillDriven = matchSkillRoutes(folded).filter(
|
|
394
|
+
(id) => known.has(id) && !core.includes(id),
|
|
395
|
+
);
|
|
396
|
+
|
|
397
|
+
const scored = surfaceTable
|
|
398
|
+
.filter((surface) => !surface.always && surface.keywords.length > 0)
|
|
399
|
+
.map((surface) => ({ id: surface.id, score: scoreSurface(surface, folded) }))
|
|
400
|
+
.filter((entry) => entry.score > 0)
|
|
401
|
+
.sort((a, b) => b.score - a.score || compareIds(a.id, b.id));
|
|
402
|
+
|
|
403
|
+
const keywordMatched = scored.slice(0, MAX_TASK_SURFACES).map((entry) => entry.id);
|
|
404
|
+
|
|
405
|
+
// The lock leads, the procedure's surfaces follow, and keyword matches fill
|
|
406
|
+
// whatever room remains. A keyword surface the skill does not span is still
|
|
407
|
+
// signal ("… et montre la météo" alongside a suggestion ask keeps terrain)
|
|
408
|
+
// but never at the cost of evicting a surface the card is about to instruct,
|
|
409
|
+
// nor of the session the user is demonstrably inside.
|
|
410
|
+
const matched: string[] = [];
|
|
411
|
+
for (const id of [...locked, ...skillDriven, ...keywordMatched]) {
|
|
412
|
+
if (matched.length >= MAX_CARRIED_SURFACES) {
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
if (!matched.includes(id)) {
|
|
416
|
+
matched.push(id);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Keep the previous selection unless the message asks for something it does
|
|
421
|
+
// not cover. Re-affirming what is already loaded costs nothing; swapping it
|
|
422
|
+
// costs a full prompt-cache miss.
|
|
423
|
+
let carried = previous.filter((id) => known.has(id) && !core.includes(id));
|
|
424
|
+
|
|
425
|
+
// A legitimate previous selection is never wider than core plus
|
|
426
|
+
// MAX_CARRIED_SURFACES, because every decision below unions into a set bounded
|
|
427
|
+
// by it. Anything wider is the wide fallback echoed back, and wide must not
|
|
428
|
+
// stick: carried forward, one vague message would pin the thread's manifest wide
|
|
429
|
+
// for its whole life, because the wide set overlaps almost any match and the
|
|
430
|
+
// sticky test below would never let go. Ignoring it means the next understood
|
|
431
|
+
// message routes fresh, and the next vague one simply goes wide again.
|
|
432
|
+
if (carried.length > MAX_CARRIED_SURFACES) {
|
|
433
|
+
carried = [];
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
if (matched.length === 0) {
|
|
437
|
+
if (carried.length > 0) {
|
|
438
|
+
return { reason: "sticky", surfaces: [...core, ...carried] };
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// Nothing matched and nothing is carried, so the router has no idea what this
|
|
442
|
+
// turn is about. Returning core alone is the one answer that is certainly
|
|
443
|
+
// wrong: it is not a narrower guess, it is a manifest with nothing in it that
|
|
444
|
+
// could answer, and the run fails having never seen the tool it needed.
|
|
445
|
+
//
|
|
446
|
+
// Width is the safe direction for ignorance. It costs tokens on a minority of
|
|
447
|
+
// turns and makes the decision harder for the model; core-only makes the
|
|
448
|
+
// decision impossible. The alternative instrument, a classifier, is narrow AND
|
|
449
|
+
// can be wrong, which is this failure with more confidence behind it.
|
|
450
|
+
return {
|
|
451
|
+
reason: "wide",
|
|
452
|
+
surfaces: wideFallbackSurfaces(),
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// Sticky only when the message asks for nothing NEW. An "any overlap" test would
|
|
457
|
+
// discard explicit intent: "export a video" matches sharing (carried) plus video
|
|
458
|
+
// (not carried), and the overlap on sharing would return the carried set without
|
|
459
|
+
// the video tools the user asked for by name. What the message asks for beats the
|
|
460
|
+
// cache, and anything the carried set does not cover routes as intent.
|
|
461
|
+
if (carried.length > 0 && matched.every((id) => carried.includes(id))) {
|
|
462
|
+
return { reason: "sticky", surfaces: [...core, ...carried] };
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// A lock that contributed names the decision, because it is the strongest of
|
|
466
|
+
// the three signals even when intent widened what it seeded.
|
|
467
|
+
let reason: RouterDecision["reason"] = "intent";
|
|
468
|
+
if (locked.length > 0) {
|
|
469
|
+
reason = "lock";
|
|
470
|
+
} else if (skillDriven.length > 0) {
|
|
471
|
+
reason = "skill";
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
return { reason, surfaces: [...core, ...matched] };
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* surfaceTools resolves a surface set to the tool names it permits, for
|
|
479
|
+
* {@link ToolBus.manifest}. An unknown surface id contributes nothing rather
|
|
480
|
+
* than throwing: routing is advisory, and a stale id should narrow the manifest,
|
|
481
|
+
* never break a run.
|
|
482
|
+
*/
|
|
483
|
+
const surfaceTools = (surfaces: readonly string[]): ReadonlySet<string> => {
|
|
484
|
+
const wanted = new Set(surfaces);
|
|
485
|
+
const tools = new Set<string>();
|
|
486
|
+
for (const surface of surfaceTable) {
|
|
487
|
+
if (!wanted.has(surface.id)) {
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
for (const member of surface.members) {
|
|
492
|
+
tools.add(member);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return tools;
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* recoveryFor returns what to do about a specific failure of a specific tool, or
|
|
501
|
+
* undefined when the playbook has nothing for that pair.
|
|
502
|
+
*
|
|
503
|
+
* It is a lookup rather than prompt text on purpose. Stated in the system prompt,
|
|
504
|
+
* every tool's every failure mode is paid for on every turn of every run, including
|
|
505
|
+
* the overwhelming majority where nothing fails. Attached to the failing result it
|
|
506
|
+
* costs nothing until it fires, and it arrives at the one moment it is actionable.
|
|
507
|
+
*/
|
|
508
|
+
const recoveryFor = (tool: string, code: string | undefined): string | undefined => {
|
|
509
|
+
if (!code) {
|
|
510
|
+
return undefined;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
return playbook.find((entry) => entry.id === tool)?.recovery.find((item) => item.code === code)
|
|
514
|
+
?.do;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
return { recoveryFor, selectSurfaces, surfaceTools };
|
|
518
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { StateDelta } from "@mountaya/elements/agent";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
captureStudioState,
|
|
5
|
+
diffStudioState,
|
|
6
|
+
type StudioStateFingerprint,
|
|
7
|
+
} from "../../chrome/handlers/stateDelta.js";
|
|
8
|
+
import type { StudioToolContext } from "../../viewer/rules/context.js";
|
|
9
|
+
// oxlint-disable-next-line no-unused-vars -- named by a {@link} below, which an editor follows.
|
|
10
|
+
import type { AgentThreadsEngine } from "../engines/agentThreads.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* studioStateDelta is what the co-pilot's sessions hand the agent loop, so the result of each
|
|
14
|
+
* tool call carries what it moved in the studio's store.
|
|
15
|
+
*
|
|
16
|
+
* The loop asks "capture before, capture after, tell me what changed" and never looks inside the
|
|
17
|
+
* answer. That seam is why `@mountaya/elements/agent` can drive a studio without naming one: what
|
|
18
|
+
* moved is a question only a host can answer, and a host with no state to report omits it and the
|
|
19
|
+
* run reports none. {@link AgentThreadsEngine} builds every session with it, so a host that mounts
|
|
20
|
+
* the co-pilot passes nothing.
|
|
21
|
+
*
|
|
22
|
+
* A value rather than a pair of arguments, because the two halves have to agree about the
|
|
23
|
+
* snapshot: a `capture` from one implementation and a `diff` from another is a delta computed
|
|
24
|
+
* over a shape neither produced, and it fails as a run that quietly reports nothing.
|
|
25
|
+
*/
|
|
26
|
+
export const studioStateDelta: StateDelta<StudioToolContext, StudioStateFingerprint> = {
|
|
27
|
+
capture: captureStudioState,
|
|
28
|
+
diff: diffStudioState,
|
|
29
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { surfaceFault } from "../../rules/listeners.js";
|
|
2
|
+
import { PLAYBOOK } from "./playbook.gen.js";
|
|
3
|
+
import { createStudioRouter } from "./router.js";
|
|
4
|
+
import { SKILL_ROUTES, SURFACE_LOCKS, SURFACES } from "./surfaces.gen.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The studio's router: {@link createStudioRouter} bound to the tables the studio ships.
|
|
8
|
+
*
|
|
9
|
+
* It is a separate module from the router itself because `playbook.gen.ts` and
|
|
10
|
+
* `surfaces.gen.ts` are generated from Mountaya's tool registry, the same descriptions its
|
|
11
|
+
* gateway reads, and a router that imported them could not travel without them. Hence the
|
|
12
|
+
* shape: the product decision arrives as a value, and the machinery that reads it knows
|
|
13
|
+
* nothing about where it came from.
|
|
14
|
+
*
|
|
15
|
+
* The lock table's compile-time guarantee lands HERE. A lock naming a state field the router
|
|
16
|
+
* does not model fails on the argument below, because `RouterSurfaceLock["field"]` is
|
|
17
|
+
* `keyof RouterState` and `GeneratedLockField` has to be assignable to it: one line, at the
|
|
18
|
+
* point the two tables actually meet, rather than on whichever line indexes the field.
|
|
19
|
+
*/
|
|
20
|
+
const studioRouter = createStudioRouter({
|
|
21
|
+
playbook: PLAYBOOK,
|
|
22
|
+
skillRoutes: SKILL_ROUTES,
|
|
23
|
+
surfaceLocks: SURFACE_LOCKS,
|
|
24
|
+
surfaces: SURFACES,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* recoveryFor returns what to do about a specific failure of a specific tool, or undefined when
|
|
29
|
+
* the playbook has nothing for that pair.
|
|
30
|
+
*/
|
|
31
|
+
export const recoveryFor = studioRouter.recoveryFor;
|
|
32
|
+
|
|
33
|
+
/** selectSurfaces chooses the surfaces a turn's manifest is built from. */
|
|
34
|
+
export const selectSurfaces = studioRouter.selectSurfaces;
|
|
35
|
+
|
|
36
|
+
/** surfaceTools resolves a surface set to the tool names it permits. */
|
|
37
|
+
export const surfaceTools = studioRouter.surfaceTools;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* RecoveryAddendum is a host's own remedy for a failed call, which the model reads after the
|
|
41
|
+
* playbook's recovery for that call.
|
|
42
|
+
*
|
|
43
|
+
* The playbook ships with the studio and states what any host's model can do about a failure:
|
|
44
|
+
* stop, report it, change the arguments. What a reader can do about it in one product, such as
|
|
45
|
+
* where a scope that holds the feature is or which settings page adds what is missing, is that
|
|
46
|
+
* product's to say, and this is where it says it.
|
|
47
|
+
*
|
|
48
|
+
* It is asked for every failed call that carries a code, with the tool's name and the code, and
|
|
49
|
+
* answers the sentence to append or undefined for none. A blank answer appends nothing, and a
|
|
50
|
+
* throw appends nothing and reaches the program as an uncaught error on a microtask, so the
|
|
51
|
+
* model still reads the playbook's recovery.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import type { RecoveryAddendum } from "@mountaya/studio/agent";
|
|
56
|
+
*
|
|
57
|
+
* const recoveryAddendum: RecoveryAddendum = (_tool, code) =>
|
|
58
|
+
* code === "upgrade-required"
|
|
59
|
+
* ? "Offer the organizations listed on the account page, which include this feature."
|
|
60
|
+
* : undefined;
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export type RecoveryAddendum = (tool: string, code: string) => string | undefined;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* addendumFor asks the host's addendum about one failure, and answers its sentence trimmed, or
|
|
67
|
+
* undefined where it has none, answers a blank or throws. A throw is surfaced on a microtask.
|
|
68
|
+
*/
|
|
69
|
+
const addendumFor = (
|
|
70
|
+
addendum: RecoveryAddendum | undefined,
|
|
71
|
+
tool: string,
|
|
72
|
+
code: string,
|
|
73
|
+
): string | undefined => {
|
|
74
|
+
if (addendum === undefined) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let answered: unknown;
|
|
79
|
+
try {
|
|
80
|
+
answered = addendum(tool, code);
|
|
81
|
+
} catch (fault) {
|
|
82
|
+
surfaceFault(fault);
|
|
83
|
+
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Read as unknown: the host's answer is typed and not checked, so a value that is no string is
|
|
88
|
+
// no sentence rather than a `TypeError` on the path that reports the failure to the model.
|
|
89
|
+
const sentence = typeof answered === "string" ? answered.trim() : "";
|
|
90
|
+
|
|
91
|
+
return sentence === "" ? undefined : sentence;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* studioRecoveryFor answers the recovery a failed call carries to the model: the playbook's for
|
|
96
|
+
* that tool and code, followed by the host's {@link RecoveryAddendum} where one is stated and
|
|
97
|
+
* answers, or either alone, or undefined where neither says anything.
|
|
98
|
+
*
|
|
99
|
+
* A failure that carries no code, an empty one included, has neither: the playbook keys its
|
|
100
|
+
* recoveries by code, and a host's remedy is for a failure it can name.
|
|
101
|
+
*
|
|
102
|
+
* @param tool - The tool whose call failed.
|
|
103
|
+
* @param code - The code the call failed with, where it carried one.
|
|
104
|
+
* @param addendum - The host's own remedy, where it states one.
|
|
105
|
+
*/
|
|
106
|
+
export const studioRecoveryFor = (
|
|
107
|
+
tool: string,
|
|
108
|
+
code: string | undefined,
|
|
109
|
+
addendum: RecoveryAddendum | undefined,
|
|
110
|
+
): string | undefined => {
|
|
111
|
+
if (code === undefined || code === "") {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const recovery = recoveryFor(tool, code);
|
|
116
|
+
const extra = addendumFor(addendum, tool, code);
|
|
117
|
+
|
|
118
|
+
if (recovery === undefined || extra === undefined) {
|
|
119
|
+
return recovery ?? extra;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return `${recovery} ${extra}`;
|
|
123
|
+
};
|