@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,47 @@
|
|
|
1
|
+
import type { StudioToolDefinition } from "../../viewer/rules/context.js";
|
|
2
|
+
import { requireShareableScope } from "./shareScope.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* open opens the share-link modal for an itinerary or a collection: it seeds the share slot with
|
|
6
|
+
* the `{ kind, id }` target, which is all the store holds. Opening creates no link: the modal
|
|
7
|
+
* reads the link the resource holds, and creates, resets and disables it only when its reader
|
|
8
|
+
* asks, each through its own `studio.shareLink` verb, keeping the token in its own state. Unlike
|
|
9
|
+
* the embed wizard, sharing needs no entitlement. It does need the edit grant, which reading,
|
|
10
|
+
* creating, resetting and disabling a link all take: a write role in the organization that owns
|
|
11
|
+
* the resource. The modal reads that grant and reads the link only for a reader who holds it, and
|
|
12
|
+
* the API refuses each request to anyone else, so this verb asks only about scope.
|
|
13
|
+
*
|
|
14
|
+
* What it does gate is SCOPE. A share link belongs to an organization, so a personal itinerary
|
|
15
|
+
* or collection can hold none, and a link such a resource still stores resolves to nothing:
|
|
16
|
+
* there is nothing a visitor could reach, so the modal never opens for one. Where this gate
|
|
17
|
+
* cannot see the organization it lets the modal open, and the modal asks the draft itself: for a
|
|
18
|
+
* personal resource it reads and creates nothing and says why. A UX and agent-containment gate,
|
|
19
|
+
* not the security boundary; the API refuses the create itself.
|
|
20
|
+
*/
|
|
21
|
+
export const open: StudioToolDefinition<"studio.share.open"> = {
|
|
22
|
+
handler: (ctx, input) => {
|
|
23
|
+
const personal = requireShareableScope(ctx, input);
|
|
24
|
+
if (personal) {
|
|
25
|
+
return personal;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
ctx.ui.getState().setShare({ id: input.id, kind: input.kind });
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
ok: true,
|
|
32
|
+
summary: `Opened the share-link modal for ${input.kind} ${input.id}.`,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* close closes the share-link modal by clearing the share slot. Ungated like open,
|
|
39
|
+
* so a non-member has the same close path.
|
|
40
|
+
*/
|
|
41
|
+
export const close: StudioToolDefinition<"studio.share.close"> = {
|
|
42
|
+
handler: (ctx) => {
|
|
43
|
+
ctx.ui.getState().setShare(null);
|
|
44
|
+
|
|
45
|
+
return { ok: true, summary: "Closed the share-link modal." };
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { failureFromThrown } from "../../bus/rules/handlerErrors.js";
|
|
2
|
+
import {
|
|
3
|
+
disableCollectionShareLink,
|
|
4
|
+
fetchCollectionShareLink,
|
|
5
|
+
mintCollectionShareLink,
|
|
6
|
+
rotateCollectionShareLink,
|
|
7
|
+
} from "../../collections/handlers/restCollections.js";
|
|
8
|
+
import type { StudioApi, StudioToolDefinition } from "../../viewer/rules/context.js";
|
|
9
|
+
import { issuedShareTokenSchema } from "../contracts/shareLink.js";
|
|
10
|
+
import type { ShareLinkRead } from "../engines/shareLink.js";
|
|
11
|
+
import { tokenlessAnswerRefusal } from "../rules/shareLink.js";
|
|
12
|
+
import { requireShareableScope } from "./shareScope.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* shareLinkFetchers resolves a target's KIND to the endpoints that own its link: the read and
|
|
16
|
+
* every write, so each tool below is one verb across both resources rather than a pair of
|
|
17
|
+
* near-identical tools. The two sets are interchangeable by construction (the same (api, id)
|
|
18
|
+
* call, the same `{ share_token }` answer), which is what giving the grant a KIND buys, where
|
|
19
|
+
* forking the credential vocabulary would not.
|
|
20
|
+
*
|
|
21
|
+
* Keeping the two side by side in one record is deliberate: an id lands on a path
|
|
22
|
+
* through a single indexed read, so a rotate can never reach the other resource's
|
|
23
|
+
* endpoint the way two hand-written branches eventually do.
|
|
24
|
+
*
|
|
25
|
+
* Each entry takes the whole {@link StudioApi} rather than a client, which keeps the two
|
|
26
|
+
* sets one shape: an itinerary's link is read and written through `api.persistence` and a
|
|
27
|
+
* collection's through `api.client`. Threading the client would force the table apart at
|
|
28
|
+
* exactly the point it exists to hold together: a share link is the same verb whichever
|
|
29
|
+
* resource carries it, and only the itinerary half has a seam in front of it.
|
|
30
|
+
*/
|
|
31
|
+
const shareLinkFetchers = {
|
|
32
|
+
collection: {
|
|
33
|
+
disable: (api: StudioApi, id: string) => disableCollectionShareLink(api.client, id),
|
|
34
|
+
mint: (api: StudioApi, id: string) => mintCollectionShareLink(api.client, id),
|
|
35
|
+
read: (api: StudioApi, id: string) => fetchCollectionShareLink(api.client, id),
|
|
36
|
+
rotate: (api: StudioApi, id: string) => rotateCollectionShareLink(api.client, id),
|
|
37
|
+
},
|
|
38
|
+
itinerary: {
|
|
39
|
+
disable: (api: StudioApi, id: string) => api.persistence.disableItineraryShareLink(id),
|
|
40
|
+
mint: (api: StudioApi, id: string) => api.persistence.mintItineraryShareLink(id),
|
|
41
|
+
read: (api: StudioApi, id: string) => api.persistence.fetchItineraryShareLink(id),
|
|
42
|
+
rotate: (api: StudioApi, id: string) => api.persistence.rotateItineraryShareLink(id),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* readShareLink reads the target's share link without setting one, and answers its token, or
|
|
48
|
+
* null where none is set. It is what a share surface asks when it opens, so opening one hands
|
|
49
|
+
* nothing out: creating a link is the reader's own act, `studio.shareLink.mint`.
|
|
50
|
+
*
|
|
51
|
+
* A read and no verb of the bus: nothing changes, so nothing is dispatched, confirmed or
|
|
52
|
+
* reported, and the token it answers enters no transcript. It reads through the seams the verbs
|
|
53
|
+
* write through, an itinerary's link through `api.persistence` and a collection's through
|
|
54
|
+
* `api.client`.
|
|
55
|
+
*
|
|
56
|
+
* It never rejects. A refusal is answered, classified as a handler's throw is: reading a link
|
|
57
|
+
* takes the edit grant creating one takes, so a viewer without it meets `forbidden`, and a local
|
|
58
|
+
* session, which holds no link, meets `no-api`. A context with no api answers `no-api` too, and a
|
|
59
|
+
* link the seam handed over with no token answers the `internal` refusal a mint answers for one.
|
|
60
|
+
*
|
|
61
|
+
* It asks nothing about scope: a surface asks it only for a resource an organization owns, and
|
|
62
|
+
* the API answers for any other whatever it holds.
|
|
63
|
+
*
|
|
64
|
+
* @param context The tool context whose api the link is read through.
|
|
65
|
+
* @param target The resource whose link is read.
|
|
66
|
+
*/
|
|
67
|
+
export const readShareLink: ShareLinkRead = async (context, target) => {
|
|
68
|
+
if (!context.api) {
|
|
69
|
+
return { code: "no-api", error: "read share link: no persistence seam", ok: false };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
const link = await shareLinkFetchers[target.kind].read(context.api, target.id);
|
|
74
|
+
if (link === null) {
|
|
75
|
+
return { ok: true, token: null };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const issued = issuedShareTokenSchema.safeParse({ shareToken: link.share_token });
|
|
79
|
+
|
|
80
|
+
return issued.success
|
|
81
|
+
? { ok: true, token: issued.data.shareToken }
|
|
82
|
+
: tokenlessAnswerRefusal("read");
|
|
83
|
+
} catch (error) {
|
|
84
|
+
return failureFromThrown(error);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* mintShareLink gets-or-creates the target's share link and answers with its token: the
|
|
90
|
+
* reader's Create in a share surface, which reads the link when it opens and creates one only
|
|
91
|
+
* when asked. The mint is idempotent, so a second Create, or one sent after the link was made
|
|
92
|
+
* elsewhere, returns the link that stands rather than retiring a URL the user already sent.
|
|
93
|
+
*
|
|
94
|
+
* Nothing is invalidated after the write, and nothing is read again: the surface that asked
|
|
95
|
+
* takes the token from this answer. It deliberately never rides a resource schema (a resource
|
|
96
|
+
* GET is reachable with the bare publishable key in every embed snippet, so putting a durable
|
|
97
|
+
* read credential there would publish it).
|
|
98
|
+
*
|
|
99
|
+
* Hidden from the LLM manifest. The result is a DURABLE READ CREDENTIAL, and the agent
|
|
100
|
+
* transport forwards `result.data` on the tool-result signal, so a minted token would land
|
|
101
|
+
* verbatim in the model's transcript. Persisting, so it needs the api seam. ctx is the
|
|
102
|
+
* first positional parameter.
|
|
103
|
+
*/
|
|
104
|
+
export const mintShareLink: StudioToolDefinition<"studio.shareLink.mint"> = {
|
|
105
|
+
agentHidden: true,
|
|
106
|
+
handler: async (ctx, input) => {
|
|
107
|
+
if (!ctx.api) {
|
|
108
|
+
return { code: "no-api", error: "mint share link: no persistence seam", ok: false };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Both kinds: a share link belongs to an organization, so a personal itinerary or
|
|
112
|
+
// collection gets none. Gated here as well as on `studio.share.open` because this is the
|
|
113
|
+
// verb that actually mints. The dialog is one way in, and the bus the agent dispatches
|
|
114
|
+
// through is another. A UX and agent-containment gate: the API refuses the mint itself.
|
|
115
|
+
const personal = requireShareableScope(ctx, input);
|
|
116
|
+
if (personal) {
|
|
117
|
+
return personal;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const share = await shareLinkFetchers[input.kind].mint(ctx.api, input.id);
|
|
121
|
+
const issued = issuedShareTokenSchema.safeParse({ shareToken: share.share_token });
|
|
122
|
+
if (!issued.success) {
|
|
123
|
+
return tokenlessAnswerRefusal("mint");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// The token rides `data` alone, never the summary: the summary is the
|
|
127
|
+
// human/LLM-readable line, and a credential has no business in one.
|
|
128
|
+
return {
|
|
129
|
+
data: issued.data,
|
|
130
|
+
ok: true,
|
|
131
|
+
summary: `Minted the share link for ${input.kind} ${input.id}.`,
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* rotateShareLink retires the target's current share token and answers with a fresh
|
|
138
|
+
* one, so a link that leaked stops authorizing reads the moment the owner resets it.
|
|
139
|
+
*
|
|
140
|
+
* It confirms first, in the destructive tone: every URL already handed out breaks, and
|
|
141
|
+
* the people holding them are not in the room to be asked. There is no acknowledge
|
|
142
|
+
* checkbox: the reset is recoverable in the sense that a new link can be sent, and
|
|
143
|
+
* the checkbox is reserved for permanent data loss and shown-once secrets.
|
|
144
|
+
*
|
|
145
|
+
* Rotating needs a write role on the target, as minting does. The API refuses a caller
|
|
146
|
+
* without one, which the client throws as a MountayaForbiddenError and the bus classifies
|
|
147
|
+
* as `forbidden`, so a capability that went stale between the render and the click
|
|
148
|
+
* surfaces as a refusal with the API's own sentence, not a generic failure. Nothing is
|
|
149
|
+
* invalidated or read again: the surface that asked takes the fresh token from this answer.
|
|
150
|
+
*
|
|
151
|
+
* Hidden from the LLM manifest, for the same reason studio.itinerary.publish is:
|
|
152
|
+
* rotating is outward-facing. It breaks access for people outside this session who
|
|
153
|
+
* cannot be consulted, so the decision stays a person's. It also answers with a
|
|
154
|
+
* durable read credential, which must not enter a transcript. Persisting, so it needs
|
|
155
|
+
* the api seam. ctx is the first positional parameter.
|
|
156
|
+
*/
|
|
157
|
+
export const rotateShareLink: StudioToolDefinition<"studio.shareLink.rotate"> = {
|
|
158
|
+
agentHidden: true,
|
|
159
|
+
confirmation: {
|
|
160
|
+
confirmLabel: "share.rotateConfirm.confirm",
|
|
161
|
+
descriptionLabel: "share.rotateConfirm.body",
|
|
162
|
+
titleLabel: "share.rotateConfirm.title",
|
|
163
|
+
tone: "destructive",
|
|
164
|
+
},
|
|
165
|
+
handler: async (ctx, input) => {
|
|
166
|
+
if (!ctx.api) {
|
|
167
|
+
return { code: "no-api", error: "rotate share link: no persistence seam", ok: false };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// A rotation MINTS: clearing the old token is only its first half. So a personal
|
|
171
|
+
// resource is refused here exactly as the mint refuses it, or this would be the way
|
|
172
|
+
// around that gate.
|
|
173
|
+
const personal = requireShareableScope(ctx, input);
|
|
174
|
+
if (personal) {
|
|
175
|
+
return personal;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const share = await shareLinkFetchers[input.kind].rotate(ctx.api, input.id);
|
|
179
|
+
const issued = issuedShareTokenSchema.safeParse({ shareToken: share.share_token });
|
|
180
|
+
if (!issued.success) {
|
|
181
|
+
return tokenlessAnswerRefusal("rotate");
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
data: issued.data,
|
|
186
|
+
ok: true,
|
|
187
|
+
summary: `Reset the share link for ${input.kind} ${input.id}.`,
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
requiresConfirmation: true,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* disableShareLink revokes the target's share link outright: the token is cleared and
|
|
195
|
+
* every URL carrying it stops resolving. Unlike a rotate it hands nothing back, since
|
|
196
|
+
* there is no successor link, so the surface that raised it closes.
|
|
197
|
+
*
|
|
198
|
+
* It confirms in the destructive tone and, like the rotate, carries no acknowledge
|
|
199
|
+
* checkbox: disabling is recoverable by minting again, which is precisely the case the
|
|
200
|
+
* checkbox is NOT for.
|
|
201
|
+
*
|
|
202
|
+
* It needs a write role on the target, as the rotate does, and a refusal arrives as
|
|
203
|
+
* `forbidden`. Nothing is invalidated or read again: the surface that asked holds no link once
|
|
204
|
+
* it settles.
|
|
205
|
+
*
|
|
206
|
+
* Unlike the mint and the rotate it is never scope-gated. It mints nothing, and it is how an
|
|
207
|
+
* owner clears a link a personal itinerary or collection still holds.
|
|
208
|
+
*
|
|
209
|
+
* Hidden from the LLM manifest: revoking is outward-facing, and it is the one verb
|
|
210
|
+
* here whose effect on people outside the session cannot be undone by re-running it.
|
|
211
|
+
* Persisting, so it needs the api seam. ctx is the first positional parameter.
|
|
212
|
+
*/
|
|
213
|
+
export const disableShareLink: StudioToolDefinition<"studio.shareLink.disable"> = {
|
|
214
|
+
agentHidden: true,
|
|
215
|
+
confirmation: {
|
|
216
|
+
confirmLabel: "share.disableConfirm.confirm",
|
|
217
|
+
descriptionLabel: "share.disableConfirm.body",
|
|
218
|
+
titleLabel: "share.disableConfirm.title",
|
|
219
|
+
tone: "destructive",
|
|
220
|
+
},
|
|
221
|
+
handler: async (ctx, input) => {
|
|
222
|
+
if (!ctx.api) {
|
|
223
|
+
return { code: "no-api", error: "disable share link: no persistence seam", ok: false };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
await shareLinkFetchers[input.kind].disable(ctx.api, input.id);
|
|
227
|
+
|
|
228
|
+
return { ok: true, summary: `Disabled the share link for ${input.kind} ${input.id}.` };
|
|
229
|
+
},
|
|
230
|
+
requiresConfirmation: true,
|
|
231
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ToolFailure } from "../../bus/rules/types.js";
|
|
2
|
+
import {
|
|
3
|
+
isKnownPersonal,
|
|
4
|
+
resolveItineraryOrganization,
|
|
5
|
+
} from "../../itinerary/handlers/publicationScope.js";
|
|
6
|
+
import type { StudioToolContext } from "../../viewer/rules/context.js";
|
|
7
|
+
import type { ShareLinkTarget } from "../rules/link.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* isKnownPersonalTarget answers whether the session knows an itinerary or a collection to be
|
|
11
|
+
* PERSONAL, owned by no organization, from what it already holds: an itinerary through the open
|
|
12
|
+
* itinerary and its cached draft ({@link resolveItineraryOrganization}), a collection through its
|
|
13
|
+
* own record in the cache. It fetches nothing, and an organization the session does not know
|
|
14
|
+
* answers false ({@link isKnownPersonal}). Each target answers for itself: the itinerary open on
|
|
15
|
+
* screen never decides a collection.
|
|
16
|
+
*/
|
|
17
|
+
export const isKnownPersonalTarget = (ctx: StudioToolContext, target: ShareLinkTarget): boolean =>
|
|
18
|
+
isKnownPersonal(
|
|
19
|
+
ctx,
|
|
20
|
+
target.kind === "itinerary"
|
|
21
|
+
? resolveItineraryOrganization(ctx, target.id)
|
|
22
|
+
: ctx.api?.cache.get({ id: target.id, kind: "collection" })?.organization_id,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* requireShareableScope refuses a share link for a PERSONAL itinerary or collection, returning
|
|
27
|
+
* the refusal to return or `null` to continue.
|
|
28
|
+
*
|
|
29
|
+
* A share link belongs to an organization. The API mints and rotates none for a resource owned
|
|
30
|
+
* by none, and a link such a resource still stores resolves to nothing, so there is nothing a
|
|
31
|
+
* visitor could reach. Refusing here states that reason in the studio's own words rather than
|
|
32
|
+
* spending a request on the 403 the API answers, and it holds for the co-pilot too: the agent
|
|
33
|
+
* dispatches through this same bus. It is NOT the security boundary; the API is.
|
|
34
|
+
*
|
|
35
|
+
* It reads the target's organization through {@link isKnownPersonalTarget}, which fetches
|
|
36
|
+
* nothing. An unknown organization ALLOWS, for the reason `requireOrganizationOwned` gives.
|
|
37
|
+
*
|
|
38
|
+
* Disabling is never gated. It mints nothing, and it is how an owner clears a link a personal
|
|
39
|
+
* resource still stores.
|
|
40
|
+
*/
|
|
41
|
+
export const requireShareableScope = (
|
|
42
|
+
ctx: StudioToolContext,
|
|
43
|
+
target: ShareLinkTarget,
|
|
44
|
+
): ToolFailure | null => {
|
|
45
|
+
if (!isKnownPersonalTarget(ctx, target)) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
code: "forbidden",
|
|
51
|
+
error: `this ${target.kind} is personal: share links belong to organizations`,
|
|
52
|
+
ok: false,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
|
|
3
|
+
import { originBase } from "../../rules/origin.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* shareLinkTargetSchema is the resource a share link is minted, rotated, or disabled
|
|
7
|
+
* for, and the one the share sheet and the embed wizard open on: an id and the KIND it
|
|
8
|
+
* belongs to. The kind is not a routing convenience: the
|
|
9
|
+
* grant itself carries it. An itinerary token is pure id-equality, reaching
|
|
10
|
+
* exactly the one itinerary it was minted for, while a collection token reaches the
|
|
11
|
+
* collection AND every itinerary and zone inside it, because exposing the set is the
|
|
12
|
+
* entire purpose of a collection link. Naming the kind at the boundary means a caller
|
|
13
|
+
* never has to infer which endpoint an id belongs to, and the two resources share one
|
|
14
|
+
* dialog and the same `studio.shareLink.mint`, `studio.shareLink.rotate` and
|
|
15
|
+
* `studio.shareLink.disable` tools.
|
|
16
|
+
*/
|
|
17
|
+
export const shareLinkTargetSchema = z.object({
|
|
18
|
+
id: z.string(),
|
|
19
|
+
kind: z.enum(["collection", "itinerary"]),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* ShareLinkTarget is the resource a share link is minted for and resolves to, and an embed is
|
|
24
|
+
* authored for, derived from {@link shareLinkTargetSchema}.
|
|
25
|
+
*/
|
|
26
|
+
export type ShareLinkTarget = z.infer<typeof shareLinkTargetSchema>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ShareLinkInput is what a share link encodes: the shared resource and the
|
|
30
|
+
* resource-scoped token that authorizes its read-only view. Exactly one target (an
|
|
31
|
+
* itinerary or a collection), because a token is minted for one resource and
|
|
32
|
+
* the surface has to know which one it was handed. A union rather than two
|
|
33
|
+
* optional fields, so "both" and "neither" cannot be spelled at all: each arm states
|
|
34
|
+
* the other's id as `?: undefined`, so an object carrying both ids matches neither arm.
|
|
35
|
+
*/
|
|
36
|
+
export type ShareLinkInput =
|
|
37
|
+
| {
|
|
38
|
+
/** The collection the link opens. */
|
|
39
|
+
collectionId: string;
|
|
40
|
+
itineraryId?: undefined;
|
|
41
|
+
/** The token minted for that collection. */
|
|
42
|
+
shareToken: string;
|
|
43
|
+
}
|
|
44
|
+
| {
|
|
45
|
+
collectionId?: undefined;
|
|
46
|
+
/** The itinerary the link opens. */
|
|
47
|
+
itineraryId: string;
|
|
48
|
+
/** The token minted for that itinerary. */
|
|
49
|
+
shareToken: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* buildShareSearch turns a ShareLinkInput into the ordered [key, value] pairs the
|
|
54
|
+
* `/studio/share` route reads through shareSearchSchema: the target id under its own
|
|
55
|
+
* key, then the share token. Returned as pairs (not a joined string) so the caller
|
|
56
|
+
* feeds them straight into a URLSearchParams (the same shape buildEmbedSearch
|
|
57
|
+
* returns), which percent-encodes each value. Pure and render-free.
|
|
58
|
+
*
|
|
59
|
+
* The resource is read off the id that holds a value, never off which key the input carries:
|
|
60
|
+
* a caller forwarding an id it may not have states it as undefined, and that id is not stated.
|
|
61
|
+
*
|
|
62
|
+
* @param input The shared resource and its token.
|
|
63
|
+
*/
|
|
64
|
+
export const buildShareSearch = (input: ShareLinkInput): Array<[string, string]> =>
|
|
65
|
+
input.collectionId !== undefined
|
|
66
|
+
? [
|
|
67
|
+
["collection_id", input.collectionId],
|
|
68
|
+
["share_token", input.shareToken],
|
|
69
|
+
]
|
|
70
|
+
: [
|
|
71
|
+
["itinerary_id", input.itineraryId],
|
|
72
|
+
["share_token", input.shareToken],
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* buildShareSrc composes the absolute share URL a visitor opens: the app origin, the
|
|
77
|
+
* `/studio/share` path, and the encoded target id and share token. The token rides in the URL
|
|
78
|
+
* because it IS the link a viewer follows; the surface then forwards it on every read through
|
|
79
|
+
* the `X-Share-Token` header rather than as a query credential.
|
|
80
|
+
*
|
|
81
|
+
* @param origin The app origin the share view is served from, a scheme and a host with no path.
|
|
82
|
+
* A trailing `/` is read as none.
|
|
83
|
+
* @param input The shared resource and its token.
|
|
84
|
+
*/
|
|
85
|
+
export const buildShareSrc = (origin: string, input: ShareLinkInput): string => {
|
|
86
|
+
const params = new URLSearchParams(buildShareSearch(input));
|
|
87
|
+
|
|
88
|
+
return `${originBase(origin)}/studio/share?${params.toString()}`;
|
|
89
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import type { ToolErrorCode, ToolFailure, ToolResult } from "../../bus/rules/types.js";
|
|
2
|
+
import { isPublishableScope } from "../../viewer/rules/scope.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ShareLinkScope says whether a resource can hold a share link at all. A share link belongs to
|
|
6
|
+
* an organization, so the answer is who owns the resource:
|
|
7
|
+
*
|
|
8
|
+
* - `"organization"`: an organization owns it, so its link is read, created, reset and disabled.
|
|
9
|
+
* - `"personal"`: no organization owns it. The API creates and resets nothing for it, so no
|
|
10
|
+
* surface reads or creates one, and Disable stays, because a link the resource still stores
|
|
11
|
+
* stays until its owner clears it.
|
|
12
|
+
* - `"pending"`: the record that answers is still loading. Nothing is read until it does, so a
|
|
13
|
+
* personal resource is never asked about a link it cannot hold.
|
|
14
|
+
*/
|
|
15
|
+
export type ShareLinkScope = "organization" | "pending" | "personal";
|
|
16
|
+
|
|
17
|
+
/** ShareLinkScopeInput is what {@link shareLinkScope} decides from. */
|
|
18
|
+
export interface ShareLinkScopeInput {
|
|
19
|
+
/**
|
|
20
|
+
* Whether the read of the record failed. Read only while `record` is undefined: a record that
|
|
21
|
+
* loaded answers whatever an earlier read did.
|
|
22
|
+
*/
|
|
23
|
+
readonly failed: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The host's predicate for the reader's own scope, `StudioScopeSeam.isPersonalScope`: personal
|
|
26
|
+
* scope has more than one spelling, and the host that knows its own is the one that answers.
|
|
27
|
+
*/
|
|
28
|
+
readonly isPersonalScope: (organizationId: string | null | undefined) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The record that names the resource's owner, or undefined while it has not loaded. Only its
|
|
31
|
+
* `organization_id` is read, which an itinerary and a collection both carry, so a caller hands
|
|
32
|
+
* over the record it holds.
|
|
33
|
+
*/
|
|
34
|
+
readonly record: { readonly organization_id?: string | null | undefined } | undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* shareLinkScope decides whether a resource can hold a share link, from the record that names
|
|
39
|
+
* its owner. It is the one answer every surface that manages a link reads, for an itinerary and
|
|
40
|
+
* for a collection alike:
|
|
41
|
+
*
|
|
42
|
+
* - `"pending"` while the record has not loaded, so nothing is read before the owner is known.
|
|
43
|
+
* - `"organization"` when the read of the record failed. The owner is unknown for good, and an
|
|
44
|
+
* unknown owner leaves the question to the API, which refuses a link no organization owns.
|
|
45
|
+
* - `"organization"` for a record an organization owns, by `isPublishableScope`.
|
|
46
|
+
* - `"personal"` for every other record: one no organization owns, one the host's predicate
|
|
47
|
+
* reads as the reader's own, and one whose owner is still the empty string.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* declare const collection: { organization_id: string | null } | undefined;
|
|
52
|
+
* declare const isError: boolean;
|
|
53
|
+
* declare const isPersonalScope: (organizationId: string | null | undefined) => boolean;
|
|
54
|
+
*
|
|
55
|
+
* const scope = shareLinkScope({ failed: isError, isPersonalScope, record: collection });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export const shareLinkScope = (input: ShareLinkScopeInput): ShareLinkScope => {
|
|
59
|
+
const { failed, isPersonalScope, record } = input;
|
|
60
|
+
|
|
61
|
+
if (record === undefined) {
|
|
62
|
+
return failed ? "organization" : "pending";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return isPublishableScope(record.organization_id, isPersonalScope) ? "organization" : "personal";
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* terminalShareLinkCodes are the classified refusals a second read or a second mint meets again:
|
|
70
|
+
* the caller may not manage the link at all (a viewer outside the owning organization, or a
|
|
71
|
+
* capability the surface was never granted), the resource is gone, or the viewer's agreement does
|
|
72
|
+
* not include what the request needs.
|
|
73
|
+
*
|
|
74
|
+
* Unpublished, because {@link isRetryableShareLinkFailure} is the rule: a surface asks whether a
|
|
75
|
+
* retry is worth offering, never which codes decide it.
|
|
76
|
+
*/
|
|
77
|
+
const terminalShareLinkCodes: ReadonlySet<ToolErrorCode> = new Set<ToolErrorCode>([
|
|
78
|
+
"capability-denied",
|
|
79
|
+
"forbidden",
|
|
80
|
+
"limit-reached",
|
|
81
|
+
"not-found",
|
|
82
|
+
"upgrade-required",
|
|
83
|
+
]);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* isRetryableShareLinkFailure reports whether asking again could turn a refused read of a share
|
|
87
|
+
* link into an answer, or a refused mint into a link.
|
|
88
|
+
*
|
|
89
|
+
* A refusal the caller would meet again is an answer: no permission to manage the link, a
|
|
90
|
+
* capability the surface lacks, a resource that is gone, an agreement that does not include it.
|
|
91
|
+
* A retry there sends the identical request and is refused identically, so a surface withholds
|
|
92
|
+
* it and lets the reason stand alone.
|
|
93
|
+
* Everything else is an interruption a second attempt can clear and keeps the retry: a timeout,
|
|
94
|
+
* a rate limit, a transport error, and a failure that carries no code at all.
|
|
95
|
+
*
|
|
96
|
+
* @param failure The refusal the read or the mint answered.
|
|
97
|
+
*/
|
|
98
|
+
export const isRetryableShareLinkFailure = (failure: ToolFailure): boolean =>
|
|
99
|
+
failure.code === undefined || !terminalShareLinkCodes.has(failure.code);
|
|
100
|
+
|
|
101
|
+
/** What {@link tokenlessAnswerRefusal} says for each verb whose answer holds no token. */
|
|
102
|
+
const tokenlessAnswers: Readonly<Record<"mint" | "read" | "rotate", string>> = {
|
|
103
|
+
mint: "mint share link: the answer holds no share token, so there is no link to show. Mint again.",
|
|
104
|
+
read: "read share link: the answer holds no share token, so there is no link to show. Read it again.",
|
|
105
|
+
rotate:
|
|
106
|
+
"rotate share link: the answer holds no share token. The link it retired may no longer open: read it again to see the link that stands.",
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* tokenlessAnswerRefusal is the refusal of a read, a mint or a reset whose answer holds no share
|
|
111
|
+
* token: never an `ok` a surface would build a dead link from.
|
|
112
|
+
*
|
|
113
|
+
* Stated once, for the places such an answer stops. The handlers and `readShareLink` answer it
|
|
114
|
+
* for a link their persistence seam handed over with no token: the REST fetchers refuse an empty
|
|
115
|
+
* token themselves, and a host's own seam is held by its type alone, where `""` is a string. A
|
|
116
|
+
* `ShareLinkEngine` answers it for a reset whose `ok` answer holds none, since the dispatch a
|
|
117
|
+
* host hands it is held by its type alone as well. `internal`, because nothing in the request is
|
|
118
|
+
* at fault, and it keeps the retry a surface offers (`isRetryableShareLinkFailure`).
|
|
119
|
+
*/
|
|
120
|
+
export const tokenlessAnswerRefusal = (verb: "mint" | "read" | "rotate"): ToolFailure => ({
|
|
121
|
+
code: "internal",
|
|
122
|
+
error: tokenlessAnswers[verb],
|
|
123
|
+
ok: false,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* isShareLinkDisableSettled reports whether a disable left the resource with no active share
|
|
128
|
+
* link, which is what its reader asked for.
|
|
129
|
+
*
|
|
130
|
+
* A disable that ran settles it. So does `not-found` on a `"personal"` resource: its Disable is
|
|
131
|
+
* offered without knowing a link exists, so that answer is the API saying none was active. A
|
|
132
|
+
* surface reports it as done, with words of its own, because the code's shared copy says the
|
|
133
|
+
* resource itself is gone.
|
|
134
|
+
*
|
|
135
|
+
* On any other scope `not-found` stays a failure: the link was minted in the same surface, so a
|
|
136
|
+
* link that is missing went away under it. Every other refusal is a failure in every scope.
|
|
137
|
+
*
|
|
138
|
+
* @param result What `studio.shareLink.disable` answered.
|
|
139
|
+
* @param scope The scope of the resource the disable was sent for.
|
|
140
|
+
*/
|
|
141
|
+
export const isShareLinkDisableSettled = (result: ToolResult, scope: ShareLinkScope): boolean =>
|
|
142
|
+
result.ok || (scope === "personal" && result.code === "not-found");
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* ShareLinkActionAvailability is what one management action of a share link is worth offering:
|
|
146
|
+
*
|
|
147
|
+
* - `"ready"`: live. The viewer may run it and there is something for it to act on.
|
|
148
|
+
* - `"waiting"`: shown and disabled with no reason given, because the record that answers is
|
|
149
|
+
* loading or there is no link (none read yet, or none set), or, in a `ShareLinkEngine`'s
|
|
150
|
+
* snapshot, because an action of the link is in flight. "Not yet" is no refusal.
|
|
151
|
+
* - `"denied"`: shown and disabled, with the rule as its reason. The viewer does not hold the
|
|
152
|
+
* edit grant the link's every verb needs.
|
|
153
|
+
* - `"unavailable"`: not offered at all, because the resource cannot hold what the action makes.
|
|
154
|
+
*/
|
|
155
|
+
export type ShareLinkActionAvailability = "denied" | "ready" | "unavailable" | "waiting";
|
|
156
|
+
|
|
157
|
+
/** ShareLinkActions is the availability of each management action of a share link. */
|
|
158
|
+
export interface ShareLinkActions {
|
|
159
|
+
/** Disable, which revokes the link. Offered in every scope, so never `"unavailable"`. */
|
|
160
|
+
readonly disable: Exclude<ShareLinkActionAvailability, "unavailable">;
|
|
161
|
+
/** Reset, which retires the link's token and issues another. */
|
|
162
|
+
readonly rotate: ShareLinkActionAvailability;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** ShareLinkActionsInput is what {@link shareLinkActions} decides from. */
|
|
166
|
+
export interface ShareLinkActionsInput {
|
|
167
|
+
/**
|
|
168
|
+
* Whether the viewer holds the edit grant on the resource, which reading, creating, resetting
|
|
169
|
+
* and disabling its link all need: a write role in the organization that owns it, or, for a
|
|
170
|
+
* personal resource, its authorship. Read once `scope` is no longer `"pending"`: a caller
|
|
171
|
+
* answers false while the record that answers is loading, and the scope says it is.
|
|
172
|
+
*/
|
|
173
|
+
readonly canManage: boolean;
|
|
174
|
+
/** Whether the resource can hold a link at all. */
|
|
175
|
+
readonly scope: ShareLinkScope;
|
|
176
|
+
/** The link's token, or null while there is none, or none has been read. */
|
|
177
|
+
readonly token: string | null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* shareLinkActions decides what Reset and Disable are worth offering for a share link.
|
|
182
|
+
*
|
|
183
|
+
* Both are always answered, so a surface draws the same action row from its first frame and
|
|
184
|
+
* moves nothing when the read of the link and the capability land:
|
|
185
|
+
*
|
|
186
|
+
* - On an organization's resource both are `"denied"` to a viewer without the edit grant, who is
|
|
187
|
+
* sent no read and so never holds a link, and otherwise wait for a link and then are
|
|
188
|
+
* `"ready"`. A resource with no link set leaves both waiting until the reader creates one.
|
|
189
|
+
* - While the scope is `"pending"` both wait for a link and then follow `canManage`. With no link
|
|
190
|
+
* the refusal is withheld: `canManage` is false for everyone while its record loads, and
|
|
191
|
+
* stating the rule then would state a rule that may not apply.
|
|
192
|
+
* - On a `"personal"` resource Reset is `"unavailable"`, because a reset issues a fresh link and
|
|
193
|
+
* the API refuses one. Disable follows `canManage` alone: there is no token to wait on, and a
|
|
194
|
+
* scope reads personal only once the record that answers the capability has loaded, so a
|
|
195
|
+
* refusal there is an answer.
|
|
196
|
+
*
|
|
197
|
+
* A proactive gate: it decides what a surface offers, and the tool bus and the API refuse a
|
|
198
|
+
* verb the viewer's role does not cover either way.
|
|
199
|
+
*/
|
|
200
|
+
export const shareLinkActions = (input: ShareLinkActionsInput): ShareLinkActions => {
|
|
201
|
+
const { canManage, scope, token } = input;
|
|
202
|
+
|
|
203
|
+
if (scope === "personal") {
|
|
204
|
+
return { disable: canManage ? "ready" : "denied", rotate: "unavailable" };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (scope === "organization" && !canManage) {
|
|
208
|
+
return { disable: "denied", rotate: "denied" };
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (token === null) {
|
|
212
|
+
return { disable: "waiting", rotate: "waiting" };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const availability = canManage ? "ready" : "denied";
|
|
216
|
+
|
|
217
|
+
return { disable: availability, rotate: availability };
|
|
218
|
+
};
|