@mountaya/studio 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/LICENCE.fr.txt +280 -0
- package/LICENSE.txt +262 -0
- package/README.md +917 -2
- package/dist/agent/index.cjs +2854 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +1257 -0
- package/dist/agent/index.d.ts +1257 -0
- package/dist/agent/index.js +2818 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/bus-BwiNiXdH.d.ts +514 -0
- package/dist/bus-DzmhPwdK.d.cts +514 -0
- package/dist/chainModel-B23pEP_1.d.cts +127 -0
- package/dist/chainModel-B23pEP_1.d.ts +127 -0
- package/dist/chunk-2HFY7ETU.js +5721 -0
- package/dist/chunk-2HFY7ETU.js.map +1 -0
- package/dist/chunk-355TOXSB.js +72 -0
- package/dist/chunk-355TOXSB.js.map +1 -0
- package/dist/chunk-4ZCUZVSV.js +10275 -0
- package/dist/chunk-4ZCUZVSV.js.map +1 -0
- package/dist/chunk-6HEKY3NF.js +95 -0
- package/dist/chunk-6HEKY3NF.js.map +1 -0
- package/dist/chunk-7GFLGGBX.cjs +8 -0
- package/dist/chunk-7GFLGGBX.cjs.map +1 -0
- package/dist/chunk-7NBRCENN.cjs +19 -0
- package/dist/chunk-7NBRCENN.cjs.map +1 -0
- package/dist/chunk-AF5GCXE3.js +8 -0
- package/dist/chunk-AF5GCXE3.js.map +1 -0
- package/dist/chunk-CJDIFRGZ.cjs +2005 -0
- package/dist/chunk-CJDIFRGZ.cjs.map +1 -0
- package/dist/chunk-CNPZY7N3.js +349 -0
- package/dist/chunk-CNPZY7N3.js.map +1 -0
- package/dist/chunk-DZJHTWSF.cjs +45 -0
- package/dist/chunk-DZJHTWSF.cjs.map +1 -0
- package/dist/chunk-EABIHHWA.js +42 -0
- package/dist/chunk-EABIHHWA.js.map +1 -0
- package/dist/chunk-EKZWV6RS.cjs +415 -0
- package/dist/chunk-EKZWV6RS.cjs.map +1 -0
- package/dist/chunk-EOKRXXAC.cjs +24 -0
- package/dist/chunk-EOKRXXAC.cjs.map +1 -0
- package/dist/chunk-F73W2ZTJ.js +1126 -0
- package/dist/chunk-F73W2ZTJ.js.map +1 -0
- package/dist/chunk-H4DVOZ5O.js +1897 -0
- package/dist/chunk-H4DVOZ5O.js.map +1 -0
- package/dist/chunk-HI52PBFT.cjs +10314 -0
- package/dist/chunk-HI52PBFT.cjs.map +1 -0
- package/dist/chunk-IDBXFBLG.cjs +1225 -0
- package/dist/chunk-IDBXFBLG.cjs.map +1 -0
- package/dist/chunk-LBWTJZUJ.js +297 -0
- package/dist/chunk-LBWTJZUJ.js.map +1 -0
- package/dist/chunk-NCLA6DKD.cjs +310 -0
- package/dist/chunk-NCLA6DKD.cjs.map +1 -0
- package/dist/chunk-O4MC5DPD.js +19 -0
- package/dist/chunk-O4MC5DPD.js.map +1 -0
- package/dist/chunk-OP37FKW6.cjs +98 -0
- package/dist/chunk-OP37FKW6.cjs.map +1 -0
- package/dist/chunk-OQSYFH3Z.cjs +5945 -0
- package/dist/chunk-OQSYFH3Z.cjs.map +1 -0
- package/dist/chunk-PACIO4NS.cjs +26 -0
- package/dist/chunk-PACIO4NS.cjs.map +1 -0
- package/dist/chunk-PSZ2R3TC.cjs +75 -0
- package/dist/chunk-PSZ2R3TC.cjs.map +1 -0
- package/dist/chunk-QFO5CZG2.cjs +136 -0
- package/dist/chunk-QFO5CZG2.cjs.map +1 -0
- package/dist/chunk-QL63MUEW.cjs +140 -0
- package/dist/chunk-QL63MUEW.cjs.map +1 -0
- package/dist/chunk-RFUPPVZO.js +17 -0
- package/dist/chunk-RFUPPVZO.js.map +1 -0
- package/dist/chunk-RPG2LWMP.js +23 -0
- package/dist/chunk-RPG2LWMP.js.map +1 -0
- package/dist/chunk-TIBXK6B7.cjs +12 -0
- package/dist/chunk-TIBXK6B7.cjs.map +1 -0
- package/dist/chunk-UU65VNEV.js +381 -0
- package/dist/chunk-UU65VNEV.js.map +1 -0
- package/dist/chunk-VGX6TR2I.js +209 -0
- package/dist/chunk-VGX6TR2I.js.map +1 -0
- package/dist/chunk-WUTDDBVP.js +130 -0
- package/dist/chunk-WUTDDBVP.js.map +1 -0
- package/dist/chunk-WVQQLKCI.cjs +224 -0
- package/dist/chunk-WVQQLKCI.cjs.map +1 -0
- package/dist/chunk-WZYXG3SE.js +111 -0
- package/dist/chunk-WZYXG3SE.js.map +1 -0
- package/dist/chunk-XDI2X3KE.js +6 -0
- package/dist/chunk-XDI2X3KE.js.map +1 -0
- package/dist/chunk-XKHLRIC7.cjs +381 -0
- package/dist/chunk-XKHLRIC7.cjs.map +1 -0
- package/dist/context-DNtd2WUv.d.cts +11666 -0
- package/dist/context-DgB72Bur.d.ts +11666 -0
- package/dist/directorThreads-CqmvsV8b.d.cts +80 -0
- package/dist/directorThreads-CqmvsV8b.d.ts +80 -0
- package/dist/en-Bu4Ti9Ev.d.cts +2315 -0
- package/dist/en-Bu4Ti9Ev.d.ts +2315 -0
- package/dist/engines/index.cjs +3446 -0
- package/dist/engines/index.cjs.map +1 -0
- package/dist/engines/index.d.cts +2216 -0
- package/dist/engines/index.d.ts +2216 -0
- package/dist/engines/index.js +3416 -0
- package/dist/engines/index.js.map +1 -0
- package/dist/handlers/index.cjs +99 -0
- package/dist/handlers/index.cjs.map +1 -0
- package/dist/handlers/index.d.cts +445 -0
- package/dist/handlers/index.d.ts +445 -0
- package/dist/handlers/index.js +42 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/index.cjs +4562 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7297 -0
- package/dist/index.d.ts +7297 -0
- package/dist/index.js +3223 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/index.cjs +977 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.cts +313 -0
- package/dist/plugins/index.d.ts +313 -0
- package/dist/plugins/index.js +933 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/saveFile-j-1kkApx.d.cts +123 -0
- package/dist/saveFile-j-1kkApx.d.ts +123 -0
- package/dist/seams/index.cjs +152 -0
- package/dist/seams/index.cjs.map +1 -0
- package/dist/seams/index.d.cts +485 -0
- package/dist/seams/index.d.ts +485 -0
- package/dist/seams/index.js +79 -0
- package/dist/seams/index.js.map +1 -0
- package/dist/shareLink-B6hlt942.d.ts +144 -0
- package/dist/shareLink-C7rIMb7x.d.ts +527 -0
- package/dist/shareLink-CnTxxXjp.d.cts +144 -0
- package/dist/shareLink-DyZVYH2V.d.cts +527 -0
- package/dist/strings/fr/index.cjs +2121 -0
- package/dist/strings/fr/index.cjs.map +1 -0
- package/dist/strings/fr/index.d.cts +19 -0
- package/dist/strings/fr/index.d.ts +19 -0
- package/dist/strings/fr/index.js +2119 -0
- package/dist/strings/fr/index.js.map +1 -0
- package/dist/strings/index.cjs +2678 -0
- package/dist/strings/index.cjs.map +1 -0
- package/dist/strings/index.d.cts +731 -0
- package/dist/strings/index.d.ts +731 -0
- package/dist/strings/index.js +2644 -0
- package/dist/strings/index.js.map +1 -0
- package/dist/studioPlugin-C3C7VjMy.d.ts +847 -0
- package/dist/studioPlugin-Cf3OBNUv.d.cts +847 -0
- package/dist/tabs-B2nRO4p_.d.cts +15 -0
- package/dist/tabs-B2nRO4p_.d.ts +15 -0
- package/dist/testing/index.cjs +292 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +306 -0
- package/dist/testing/index.d.ts +306 -0
- package/dist/testing/index.js +284 -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 +43 -0
- package/dist/time/index.d.ts +43 -0
- package/dist/time/index.js +26 -0
- package/dist/time/index.js.map +1 -0
- package/dist/types-BzJRV6UI.d.cts +845 -0
- package/dist/types-BzJRV6UI.d.ts +845 -0
- package/dist/zoneForm-CdYNtnnA.d.cts +320 -0
- package/dist/zoneForm-mG85yt5e.d.ts +320 -0
- package/package.json +225 -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 +28 -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 +454 -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 +858 -0
- package/src/bus/rules/confirmation.ts +22 -0
- package/src/bus/rules/defineRegistry.ts +26 -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 +805 -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 +573 -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 +87 -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 +213 -0
- package/src/embed/rules/snippet.ts +531 -0
- package/src/embed/rules/tableCode.ts +269 -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 +1086 -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 +1052 -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 +200 -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 +209 -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 +34 -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 +198 -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,1257 @@
|
|
|
1
|
+
import { AgentTransport } from '@mountaya/client/events';
|
|
2
|
+
import { QuestionOption, SuggestionCardCandidate, PendingConfirmation, AgentEngineState, ToolActivityOutcome, ConversationState, TranscriptEntry, AgentErrorCopy, ToolDispatcher } from '@mountaya/elements/agent';
|
|
3
|
+
import { StudioToolContext, StudioToolInputs, UiState } from '../index.cjs';
|
|
4
|
+
import { ToolBus } from '../index.cjs';
|
|
5
|
+
import { TabSurface } from '../index.cjs';
|
|
6
|
+
import { StudioIds } from '../seams/index.cjs';
|
|
7
|
+
import { StudioStrings } from '../strings/index.cjs';
|
|
8
|
+
import * as zustand_vanilla from 'zustand/vanilla';
|
|
9
|
+
import { VideoDirectorStoreApi, VideoDirectorState } from '../index.cjs';
|
|
10
|
+
export { S as SEARCH_TAB_ID } from '../tabs-B2nRO4p_.cjs';
|
|
11
|
+
import 'zod';
|
|
12
|
+
import '@mountaya/client';
|
|
13
|
+
import '@mountaya/elements/camera';
|
|
14
|
+
import '@mountaya/elements/map-client';
|
|
15
|
+
import '@mountaya/elements/seams';
|
|
16
|
+
import 'geojson';
|
|
17
|
+
import '@mountaya/elements/data';
|
|
18
|
+
import '@mountaya/elements/errors';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* RouterState is the slice of the studio snapshot the router reads. It is
|
|
22
|
+
* deliberately narrow and structural rather than the whole snapshot: the router
|
|
23
|
+
* is a pure function, and a wide input would let it drift into depending on
|
|
24
|
+
* things that have nothing to do with which tools a task needs.
|
|
25
|
+
*
|
|
26
|
+
* Every field is here because a surface lock of the compiled tables reads it, which
|
|
27
|
+
* its suite asserts both ways: a lock naming a field this interface does not carry
|
|
28
|
+
* fails to compile in lockHolds, and a field no lock reads is a slice the router
|
|
29
|
+
* pays to assemble and never consults.
|
|
30
|
+
*/
|
|
31
|
+
interface RouterState {
|
|
32
|
+
/** The kind of edit session currently armed, if any. */
|
|
33
|
+
editSession?: "segment" | "waypoint" | "zone" | null | undefined;
|
|
34
|
+
/** Whether an import draft is open. */
|
|
35
|
+
importDraft?: boolean | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The kind of resource the editor currently holds open, if any. It is distinct
|
|
38
|
+
* from `editSession`, which reports only an ARMED geometry engine: a computed
|
|
39
|
+
* zone is open without arming one (reshaping it by hand would replace the query
|
|
40
|
+
* it is generated from), so a run about the zone the user is looking at has no
|
|
41
|
+
* armed session to be recognised by.
|
|
42
|
+
*/
|
|
43
|
+
openResource?: "itinerary" | "zone" | null | undefined;
|
|
44
|
+
/** Whether a route-suggestion draft is open. */
|
|
45
|
+
suggestDraft?: boolean | undefined;
|
|
46
|
+
/** Whether the video wizard is open. */
|
|
47
|
+
videoOpen?: boolean | undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* RouterDecision is the routed surface set plus why it was chosen. The reason is
|
|
51
|
+
* not decoration: a misroute is otherwise invisible, and recording which signal
|
|
52
|
+
* fired is what makes the router's accuracy measurable once telemetry carries
|
|
53
|
+
* the surfaces a run actually used.
|
|
54
|
+
*/
|
|
55
|
+
interface RouterDecision {
|
|
56
|
+
reason: "lock" | "skill" | "intent" | "sticky" | "wide";
|
|
57
|
+
surfaces: readonly string[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* recoveryFor returns what to do about a specific failure of a specific tool, or undefined when
|
|
62
|
+
* the playbook has nothing for that pair.
|
|
63
|
+
*/
|
|
64
|
+
declare const recoveryFor: (tool: string, code: string | undefined) => string | undefined;
|
|
65
|
+
/** selectSurfaces chooses the surfaces a turn's manifest is built from. */
|
|
66
|
+
declare const selectSurfaces: (message: string, state?: RouterState, previous?: readonly string[]) => RouterDecision;
|
|
67
|
+
/** surfaceTools resolves a surface set to the tool names it permits. */
|
|
68
|
+
declare const surfaceTools: (surfaces: readonly string[]) => ReadonlySet<string>;
|
|
69
|
+
/**
|
|
70
|
+
* RecoveryAddendum is a host's own remedy for a failed call, which the model reads after the
|
|
71
|
+
* playbook's recovery for that call.
|
|
72
|
+
*
|
|
73
|
+
* The playbook ships with the studio and states what any host's model can do about a failure:
|
|
74
|
+
* stop, report it, change the arguments. What a reader can do about it in one product, such as
|
|
75
|
+
* where a scope that holds the feature is or which settings page adds what is missing, is that
|
|
76
|
+
* product's to say, and this is where it says it.
|
|
77
|
+
*
|
|
78
|
+
* It is asked for every failed call that carries a code, with the tool's name and the code, and
|
|
79
|
+
* answers the sentence to append or undefined for none. A blank answer appends nothing, and a
|
|
80
|
+
* throw appends nothing and reaches the program as an uncaught error on a microtask, so the
|
|
81
|
+
* model still reads the playbook's recovery.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* import type { RecoveryAddendum } from "@mountaya/studio/agent";
|
|
86
|
+
*
|
|
87
|
+
* const recoveryAddendum: RecoveryAddendum = (_tool, code) =>
|
|
88
|
+
* code === "upgrade-required"
|
|
89
|
+
* ? "Offer the organizations listed on the account page, which include this feature."
|
|
90
|
+
* : undefined;
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
type RecoveryAddendum = (tool: string, code: string) => string | undefined;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The co-pilot's slice of the URL: which conversations are open, and which run each one waits
|
|
97
|
+
* on.
|
|
98
|
+
*
|
|
99
|
+
* Declared beside the engine that reads it rather than beside a React provider, because the
|
|
100
|
+
* seam is what a host answers and {@link AgentThreadsEngine} is what asks: a host that binds the
|
|
101
|
+
* co-pilot to a router of its own, or drives the engine from a surface of its own, names both
|
|
102
|
+
* types without installing a framework binding.
|
|
103
|
+
*/
|
|
104
|
+
/**
|
|
105
|
+
* AgentThreadMirror is one in-flight conversation as a URL carries it: which thread, and which
|
|
106
|
+
* run it is waiting on.
|
|
107
|
+
*/
|
|
108
|
+
interface AgentThreadMirror {
|
|
109
|
+
id: string;
|
|
110
|
+
runId: string | null;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* AgentThreadsUrlSeam is how a host lets the co-pilot survive a reload.
|
|
114
|
+
*
|
|
115
|
+
* Two members and no router, for the reason {@link StudioUrlSeam} gives: a surface that mirrors
|
|
116
|
+
* state would otherwise have to know a route tree, a path and a search schema by name, and none
|
|
117
|
+
* of those are its own. `readOnce` is the init source, read once when the engine is constructed
|
|
118
|
+
* and never subscribed: the seed creates each thread once, and a subscribing read would create
|
|
119
|
+
* it again every time the mirror it just wrote came back. `write` mirrors the current set.
|
|
120
|
+
*
|
|
121
|
+
* A host may hand `readOnce` what its URL spelled, unbounded and unchecked. The engine restores
|
|
122
|
+
* at most `MAX_OPEN_COPILOT_TABS` threads from it, none under a pseudo-tab's id (`SEARCH_TAB_ID`,
|
|
123
|
+
* `WITHHELD_TAB_ID`), and none for a viewer withheld the co-pilot. It skips an entry that is no
|
|
124
|
+
* thread, restores nothing from a `threads` that is no list, and throws on neither.
|
|
125
|
+
*
|
|
126
|
+
* It is a seam of its own rather than a widening of {@link MirroredSearch}, and that is a
|
|
127
|
+
* decision about who the studio is for: the mirrored values there are scalars every studio wants
|
|
128
|
+
* in its URL, where a run id is a Mountaya-shaped fact a licensee may well want nowhere near
|
|
129
|
+
* theirs.
|
|
130
|
+
*
|
|
131
|
+
* Its absence is defined: nothing is restored and nothing is mirrored, so the co-pilot opens on
|
|
132
|
+
* a fresh conversation, which is exactly right for an embed or a render-free test.
|
|
133
|
+
*/
|
|
134
|
+
interface AgentThreadsUrlSeam {
|
|
135
|
+
readOnce: () => {
|
|
136
|
+
activeThreadId?: string | undefined;
|
|
137
|
+
threads?: readonly AgentThreadMirror[] | undefined;
|
|
138
|
+
};
|
|
139
|
+
write: (next: {
|
|
140
|
+
activeThreadId: string | null;
|
|
141
|
+
threads: readonly AgentThreadMirror[];
|
|
142
|
+
}) => void;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* WITHHELD_TAB_ID is the reserved id of the co-pilot tab a viewer without the `copilot`
|
|
147
|
+
* entitlement lands on. It is never a conversation's id (those come from the ids seam) and never
|
|
148
|
+
* in the threads map, so the panel branches on it by value: while it is the active tab, the panel
|
|
149
|
+
* renders whatever the host's co-pilot seam answers in place of a conversation. An entitled viewer
|
|
150
|
+
* never lands on it: a URL that names it restores Search for them, and the tab verbs answer
|
|
151
|
+
* `not-found` for it.
|
|
152
|
+
*
|
|
153
|
+
* The id says WHERE, never WHAT. Nothing in this package draws what stands there: the node
|
|
154
|
+
* rendered there is the host's, read off their seam, so the studio puts no commercial terms in
|
|
155
|
+
* front of a licensee's users. It is a URL value too (a reload restores the tab it names), which
|
|
156
|
+
* is why it is published rather than private.
|
|
157
|
+
*/
|
|
158
|
+
declare const WITHHELD_TAB_ID = "withheld";
|
|
159
|
+
/**
|
|
160
|
+
* ThreadState is one chat's reactive state: its run id (null until a run opens),
|
|
161
|
+
* the run lifecycle the panel renders against, the role-structured transcript
|
|
162
|
+
* (errors AND tool actions live in the transcript as their own turns, not separate
|
|
163
|
+
* fields), and the destructive-tool confirmation the run is currently waiting on
|
|
164
|
+
* (null unless a card is showing). One studio workspace hosts many of these:
|
|
165
|
+
* switching tabs switches which thread's state the panel shows, never the shared
|
|
166
|
+
* map/itinerary.
|
|
167
|
+
*/
|
|
168
|
+
interface ThreadState extends ConversationState<TranscriptEntry> {
|
|
169
|
+
pendingConfirmation: PendingConfirmation | null;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* AgentThreadsState is the studio's whole set of chats: the ordered thread ids
|
|
173
|
+
* (tab order), the active AI thread, the active TAB (which may be the search
|
|
174
|
+
* pseudo-tab or an AI thread), and each thread's state keyed by id. The order
|
|
175
|
+
* array drives the tab strip; the map holds the per-thread reactive state read
|
|
176
|
+
* with narrow selectors so a streaming token re-renders only the active panel.
|
|
177
|
+
*
|
|
178
|
+
* activeTabId is the SINGLE source of truth for which tab the panel shows. It
|
|
179
|
+
* is SEARCH_TAB_ID when the search pseudo-tab is active, an AI thread id when
|
|
180
|
+
* one of the AI tabs is active, or null only when no AI tabs exist AND search
|
|
181
|
+
* is also not selected (a transient state `AgentThreadsEngine` does not produce).
|
|
182
|
+
* activeId mirrors the active AI thread (so the agent surface keeps writing to
|
|
183
|
+
* the right thread when search is selected); switching back to an AI tab
|
|
184
|
+
* re-points activeTabId to activeId.
|
|
185
|
+
*/
|
|
186
|
+
interface AgentThreadsState {
|
|
187
|
+
activeId: string | null;
|
|
188
|
+
activeTabId: string | null;
|
|
189
|
+
order: string[];
|
|
190
|
+
threads: Record<string, ThreadState>;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* AgentThreadsActions mutate the chat set. The engine (the only writer)
|
|
194
|
+
* calls these as the sessions it owns report run ids, state transitions, and
|
|
195
|
+
* streamed/settled text; the UI only reads.
|
|
196
|
+
*
|
|
197
|
+
* - createThread seeds an idle thread; closeThread drops it and re-points the active
|
|
198
|
+
* thread.
|
|
199
|
+
* - The transcript mutators append a user turn, append/accumulate an assistant turn,
|
|
200
|
+
* append an error turn, and reset on a fresh run. appendToolActivity records one tool
|
|
201
|
+
* action as a permanent row keyed by its call id, and settleToolActivity settles that
|
|
202
|
+
* row in place once the tool returns.
|
|
203
|
+
* - setActiveTab points the panel at either the search pseudo-tab or an AI thread id;
|
|
204
|
+
* addCopilotTab and closeCopilotTab are the tab-level wrappers the tool bus dispatches
|
|
205
|
+
* through (Search is implicit and never created or closed).
|
|
206
|
+
* - setPendingConfirmation and clearPendingConfirmation raise and drop the in-chat
|
|
207
|
+
* confirmation card a destructive tool blocks on; a fresh user message does NOT clear
|
|
208
|
+
* it: only the user's decision, a stop, or session teardown does.
|
|
209
|
+
* - appendQuestion records a structured question as an open card keyed by its call id;
|
|
210
|
+
* answerQuestion settles that card with the picked label; a typed user message settles
|
|
211
|
+
* every still-open card with no pick, since the reply supersedes the buttons.
|
|
212
|
+
* - appendSuggestions records a generated route-candidate batch as an open card
|
|
213
|
+
* (superseding any prior open batch); chooseSuggestion settles that card with the
|
|
214
|
+
* picked candidate's seed; a typed user message settles every still-open suggestions
|
|
215
|
+
* card too, since the run may be about to regenerate.
|
|
216
|
+
*/
|
|
217
|
+
interface AgentThreadsActions {
|
|
218
|
+
addCopilotTab: (threadId: string) => void;
|
|
219
|
+
answerQuestion: (threadId: string, entryId: string, label: string) => void;
|
|
220
|
+
appendAssistantDelta: (threadId: string, delta: string) => void;
|
|
221
|
+
appendChecksUnmet: (threadId: string, unmet: readonly string[]) => void;
|
|
222
|
+
appendError: (threadId: string, message: string) => void;
|
|
223
|
+
appendQuestion: (threadId: string, question: {
|
|
224
|
+
options: readonly QuestionOption[];
|
|
225
|
+
question: string;
|
|
226
|
+
toolCallId: string;
|
|
227
|
+
}) => void;
|
|
228
|
+
appendSuggestions: (threadId: string, suggestions: {
|
|
229
|
+
candidates: readonly SuggestionCardCandidate[];
|
|
230
|
+
entryId: string;
|
|
231
|
+
}) => void;
|
|
232
|
+
appendToolActivity: (threadId: string, activity: {
|
|
233
|
+
input: string | null;
|
|
234
|
+
name: string;
|
|
235
|
+
toolCallId: string;
|
|
236
|
+
}) => void;
|
|
237
|
+
appendUserMessage: (threadId: string, content: string) => void;
|
|
238
|
+
chooseSuggestion: (threadId: string, entryId: string, seed: number) => void;
|
|
239
|
+
clearPendingConfirmation: (threadId: string) => void;
|
|
240
|
+
closeCopilotTab: (threadId: string) => void;
|
|
241
|
+
closeThread: (threadId: string) => void;
|
|
242
|
+
createThread: (threadId: string, runId?: string | null) => void;
|
|
243
|
+
setActive: (threadId: string) => void;
|
|
244
|
+
setActiveTab: (tabId: string) => void;
|
|
245
|
+
setAssistantMessage: (threadId: string, content: string, messageIndex?: number) => void;
|
|
246
|
+
setPendingConfirmation: (threadId: string, confirmation: PendingConfirmation) => void;
|
|
247
|
+
setRunId: (threadId: string, runId: string | null) => void;
|
|
248
|
+
setSessionState: (threadId: string, state: AgentEngineState) => void;
|
|
249
|
+
settleToolActivity: (threadId: string, toolCallId: string, outcome: ToolActivityOutcome) => void;
|
|
250
|
+
}
|
|
251
|
+
/** AgentThreadsStore is the store's whole value: the {@link AgentThreadsState} and its actions. */
|
|
252
|
+
type AgentThreadsStore = AgentThreadsActions & AgentThreadsState;
|
|
253
|
+
/**
|
|
254
|
+
* AgentThreadsStoreApi is the vanilla store {@link createAgentThreadsStore} builds, the
|
|
255
|
+
* object an `AgentThreadsEngine` writes and a surface reads with narrow selectors.
|
|
256
|
+
*/
|
|
257
|
+
type AgentThreadsStoreApi = ReturnType<typeof createAgentThreadsStore>;
|
|
258
|
+
/**
|
|
259
|
+
* createAgentThreadsStore builds the per-mount vanilla store for the studio's
|
|
260
|
+
* chats. `AgentThreadsEngine` writes it, and builds one when its host passes none;
|
|
261
|
+
* the tab strip and the prompt panel read it with narrow selectors, so a
|
|
262
|
+
* high-frequency token update re-renders only the components that select the
|
|
263
|
+
* changing thread.
|
|
264
|
+
*
|
|
265
|
+
* It is one literal on purpose: every action is a transition over the one `set`
|
|
266
|
+
* this closure holds, each a few lines that name a transcript rule, so a split
|
|
267
|
+
* by concern would pass `set` between modules and move no decision out.
|
|
268
|
+
*/
|
|
269
|
+
declare const createAgentThreadsStore: () => zustand_vanilla.StoreApi<AgentThreadsStore>;
|
|
270
|
+
/**
|
|
271
|
+
* selectAgentDriving is true while any conversation reads `running`: from the
|
|
272
|
+
* moment its message is sent, which is before a first message's run exists,
|
|
273
|
+
* until its turn settles. It is the single derived flag the studio reads to
|
|
274
|
+
* lock every human interaction surface and dim the workspace: the agent and a
|
|
275
|
+
* clicking human share one bus + tool context, so the lock cannot be a
|
|
276
|
+
* bus-capability gate (that would block the agent too) and must live at the UI
|
|
277
|
+
* layer keyed off this run state. Reads the order array once and
|
|
278
|
+
* short-circuits on the first running thread.
|
|
279
|
+
*/
|
|
280
|
+
declare const selectAgentDriving: (state: AgentThreadsState) => boolean;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* AgentThreadsTabsSeam is where an {@link AgentThreadsEngine} publishes its tab strip, so a
|
|
284
|
+
* studio verb dispatched from outside the co-pilot (`studio.tabs.create` from an editor's
|
|
285
|
+
* "ask the co-pilot" entry) reaches the engine's threads through `ctx.tabs`.
|
|
286
|
+
*
|
|
287
|
+
* The engine registers its surface when the first subscriber resumes it and unregisters it
|
|
288
|
+
* when the last one parks it, so a tab verb dispatched while nothing watches the co-pilot
|
|
289
|
+
* answers the structured failure an absent `ctx.tabs` defines. A host whose tool context reads
|
|
290
|
+
* `tabs` through a late-bound getter answers both members with the slot that getter reads.
|
|
291
|
+
*/
|
|
292
|
+
interface AgentThreadsTabsSeam {
|
|
293
|
+
/** Publishes the engine's tab surface. */
|
|
294
|
+
readonly register: (surface: TabSurface) => void;
|
|
295
|
+
/** Withdraws it, after which a tab verb answers a structured failure. */
|
|
296
|
+
readonly unregister: () => void;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* AgentThreadsConfig is what the co-pilot's conversations run against, all of it replaceable
|
|
300
|
+
* mid-life through {@link AgentThreadsEngine.configure}.
|
|
301
|
+
*
|
|
302
|
+
* Every member is read when it is used rather than when the engine is built: a session built
|
|
303
|
+
* after a change runs on the new transport and bus, and an error or a confirmation card raised
|
|
304
|
+
* after a locale change reads the new words.
|
|
305
|
+
*/
|
|
306
|
+
interface AgentThreadsConfig {
|
|
307
|
+
/**
|
|
308
|
+
* The studio's bus, whole. A run reads the manifest it advertises for the context's
|
|
309
|
+
* capabilities and dispatches with the model as its origin, and the engine dispatches the tab,
|
|
310
|
+
* framing and suggestion verbs through it.
|
|
311
|
+
*/
|
|
312
|
+
readonly bus: ToolBus<StudioToolContext, StudioToolInputs>;
|
|
313
|
+
/**
|
|
314
|
+
* The studio's tool context, which every conversation drives. A run's dispatches layer the
|
|
315
|
+
* in-chat confirmation and the agent origin over it with `layerToolContext`, so its late-bound
|
|
316
|
+
* getters (the map, the tabs, the collaboration session) stay live.
|
|
317
|
+
*/
|
|
318
|
+
readonly context: StudioToolContext;
|
|
319
|
+
/**
|
|
320
|
+
* The localized copy a terminal run error resolves onto, the same object the video director
|
|
321
|
+
* reads, so the two surfaces phrase a budget ceiling or a rate limit identically.
|
|
322
|
+
*/
|
|
323
|
+
readonly errorCopy: AgentErrorCopy;
|
|
324
|
+
/**
|
|
325
|
+
* Marks an organization's AI configuration stale after a start the gateway refused for want
|
|
326
|
+
* of one. Omitted, the refusal still surfaces its words and the configuration is re-read on
|
|
327
|
+
* the next natural fetch, the defined answer for a host with no cache of its own.
|
|
328
|
+
*/
|
|
329
|
+
readonly invalidateAiConfig?: ((organizationId: string) => void) | undefined;
|
|
330
|
+
/**
|
|
331
|
+
* Marks the viewer's memberships stale after the gateway refused or ended a run for want of
|
|
332
|
+
* access: a start or its stream answered 402, 403 or 404, a follow-up found its run gone, or a
|
|
333
|
+
* run ended `access-revoked` because its member may not run it there any more (no write role in
|
|
334
|
+
* its organization, or an agreement that does not include Map Studio). The co-pilot's gate reads
|
|
335
|
+
* the memberships, so the notice that follows the refresh says why the co-pilot is withheld.
|
|
336
|
+
* Omitted, the refusal still surfaces its words and the memberships are re-read on the next
|
|
337
|
+
* natural fetch.
|
|
338
|
+
*/
|
|
339
|
+
readonly invalidateMemberships?: (() => void) | undefined;
|
|
340
|
+
/**
|
|
341
|
+
* Tells the host the API refused the credential a run rides on: its start, its stream (a
|
|
342
|
+
* restored run's included) or a message into it answered 401. Under the browser's own session
|
|
343
|
+
* that is a sign-in the API no longer accepts, after a sign-out or a revoked session, so the
|
|
344
|
+
* host asks whether the person is still signed in and, when nobody is, sends them to sign in.
|
|
345
|
+
* Called once per refusal, once the fault is written. A 401 says nothing of the viewer's
|
|
346
|
+
* access, so the memberships are not read again for it.
|
|
347
|
+
*
|
|
348
|
+
* Pass it where the runs ride the browser's own session. Under a publishable key a 401 refuses
|
|
349
|
+
* the key or the session token beside it, which is no sign-in a host can ask about. Omitted, a
|
|
350
|
+
* refusal still surfaces its words.
|
|
351
|
+
*/
|
|
352
|
+
readonly onSignInRefused?: (() => void) | undefined;
|
|
353
|
+
/**
|
|
354
|
+
* The host's own remedy for a failed call, appended to the playbook's recovery the model reads
|
|
355
|
+
* with it. Omitted, the model reads the playbook's recovery alone.
|
|
356
|
+
*/
|
|
357
|
+
readonly recoveryAddendum?: RecoveryAddendum | undefined;
|
|
358
|
+
/**
|
|
359
|
+
* Whether a run names the server tools its model sees, from the tools the conversation's
|
|
360
|
+
* surfaces route to: a run's start and each routing update then carry the routed set.
|
|
361
|
+
*
|
|
362
|
+
* Off by default, and to stay off under a publishable key, the credential a studio embedded in
|
|
363
|
+
* a product runs under: a run under a key calls no server tool, and the API refuses a start or
|
|
364
|
+
* an update that names any. Off, a run names none and keeps every server tool its credential
|
|
365
|
+
* reaches. A host on the browser's own session turns it on to narrow them.
|
|
366
|
+
*
|
|
367
|
+
* @default false
|
|
368
|
+
*/
|
|
369
|
+
readonly routesServerTools?: boolean | undefined;
|
|
370
|
+
/** The words the conversations write: fault lines, confirmation cards, the staging error. */
|
|
371
|
+
readonly strings: Pick<StudioStrings, "confirm" | "copilot" | "editing" | "editor" | "prompt" | "share">;
|
|
372
|
+
/**
|
|
373
|
+
* How the open conversations survive a reload. Its `readOnce` is read by the constructor
|
|
374
|
+
* alone, from the options; replacing the seam later changes where `write` mirrors to.
|
|
375
|
+
* Omitted, nothing is restored and nothing is mirrored.
|
|
376
|
+
*/
|
|
377
|
+
readonly threadsUrl?: AgentThreadsUrlSeam | undefined;
|
|
378
|
+
/** The event transport every run is started, sent into and read over. */
|
|
379
|
+
readonly transport: AgentTransport;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* AgentThreadsEngineOptions is the {@link AgentThreadsConfig} an engine starts with, plus the
|
|
383
|
+
* settings fixed for its life.
|
|
384
|
+
*/
|
|
385
|
+
interface AgentThreadsEngineOptions extends AgentThreadsConfig {
|
|
386
|
+
/**
|
|
387
|
+
* Where a new conversation's id comes from. Pass the host's `ids` seam, or
|
|
388
|
+
* `sequentialStudioIds()` where the ids must be a function of the input.
|
|
389
|
+
*/
|
|
390
|
+
readonly ids: StudioIds;
|
|
391
|
+
/**
|
|
392
|
+
* The store the conversations are written into, for a host that reads it with narrow
|
|
393
|
+
* selectors of its own. It is seeded by the constructor, so it starts empty.
|
|
394
|
+
*
|
|
395
|
+
* @default a new `createAgentThreadsStore()`
|
|
396
|
+
*/
|
|
397
|
+
readonly store?: AgentThreadsStoreApi | undefined;
|
|
398
|
+
/**
|
|
399
|
+
* Where the tab strip is published while the engine runs. Omitted, a tab verb dispatched
|
|
400
|
+
* from outside the co-pilot answers a structured failure, and the engine's own tab commands
|
|
401
|
+
* still work.
|
|
402
|
+
*/
|
|
403
|
+
readonly tabs?: AgentThreadsTabsSeam | undefined;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* AgentThreadsEngine runs the studio co-pilot's concurrent conversations: one `AgentEngine`
|
|
407
|
+
* session per thread, each driving the same studio through the same bus and tool context, so
|
|
408
|
+
* switching tabs switches the conversation and never the workspace.
|
|
409
|
+
*
|
|
410
|
+
* The snapshot is the threads store's state (`AgentThreadsState`): the tab order, the active
|
|
411
|
+
* tab, and each thread's run id, lifecycle state, transcript and pending confirmation. A
|
|
412
|
+
* surface reads it with narrow selectors over the store rather than re-rendering on every
|
|
413
|
+
* streamed token. No member of {@link AgentThreadsConfig} keys it, so there is no previous
|
|
414
|
+
* question whose answer a configuration change could show.
|
|
415
|
+
*
|
|
416
|
+
* What the conversations do, in the order a run meets it:
|
|
417
|
+
*
|
|
418
|
+
* - **Seeding.** The constructor restores the threads the URL names, with their run ids, and
|
|
419
|
+
* the tab it names when that tab still exists; otherwise it lands on Search, with one fresh
|
|
420
|
+
* thread for a viewer entitled to the co-pilot and none for one who is not. It restores at
|
|
421
|
+
* most `MAX_OPEN_COPILOT_TABS` threads, never one under a pseudo-tab's id, and none at all for a
|
|
422
|
+
* viewer withheld the co-pilot: the URL is the visitor's to write, so the engine bounds it
|
|
423
|
+
* and a host's route need not. What the URL names is kept for a viewer withheld at
|
|
424
|
+
* construction, and restored once that viewer is entitled: when the viewer seam tells the
|
|
425
|
+
* change, at the next resume, or ahead of the next command, whichever comes first, and once,
|
|
426
|
+
* and the URL is written with the conversations that restore holds. The entitlement is read
|
|
427
|
+
* from the viewer seam wherever the engine acts on it, so a reveal or a close made after the
|
|
428
|
+
* change follows the viewer as it stands then.
|
|
429
|
+
* - **Routing.** Every message picks the surfaces its turn offers, keeping the thread's
|
|
430
|
+
* previous pick as the stickiness input, and a tool settle re-picks from live state with the
|
|
431
|
+
* thread's last message, so a surface the run unlocks reaches the manifest before its next
|
|
432
|
+
* turn.
|
|
433
|
+
* - **Turns.** A conversation reads `running` from the moment its message is sent, so the
|
|
434
|
+
* workspace locks before the run's context is captured and its start is made. It returns to
|
|
435
|
+
* `awaiting_input` when the turn settles, which its session reports, and at once when the
|
|
436
|
+
* message opens no run.
|
|
437
|
+
* - **Confirmations.** A destructive tool, server or client, raises an in-chat card instead of a
|
|
438
|
+
* modal. The user's decision, a stop, a tab close or a park settles it, so a run never waits
|
|
439
|
+
* on a decision that can no longer arrive.
|
|
440
|
+
* - **Tool calls.** An editor verb locks the entity it names for the run, a verb that takes an
|
|
441
|
+
* entity back lowers the hand-off, a question renders as a card, and a settled generate
|
|
442
|
+
* renders the live suggest session as a suggestions card, framed once while its thread is on
|
|
443
|
+
* screen. The suggest session is one workspace-wide slot, so only the generate that still
|
|
444
|
+
* owns it may render or discard it.
|
|
445
|
+
* - **Faults.** A start refused for access or configuration, a submit with no organization to
|
|
446
|
+
* scope a run to, and a stream that faults each land as an error turn and re-enable input.
|
|
447
|
+
*
|
|
448
|
+
* Every listener is told of a change, and one that throws stops neither the engine nor the
|
|
449
|
+
* listeners after it: its fault reaches the program as an uncaught error on a microtask, never
|
|
450
|
+
* as the outcome of a command or of a session's callback. A URL seam or a tab seam that throws
|
|
451
|
+
* is answered the same way.
|
|
452
|
+
*
|
|
453
|
+
* The lifecycle is the listeners, the way `SearchEngine`'s is. The first subscriber builds a
|
|
454
|
+
* host per thread, reconnects every thread that has a run id, mirrors the driving flag into
|
|
455
|
+
* `ctx.ui`, subscribes to the viewer seam and publishes the tab strip; the last unsubscribe
|
|
456
|
+
* disposes every host, denies every parked confirmation, resets the driving flag, the edit locks
|
|
457
|
+
* and the hand-off, releases the viewer seam and withdraws the tab strip. A configuration that
|
|
458
|
+
* carries another UI store or another viewer moves the mirror or the subscription to it. A park
|
|
459
|
+
* ends no conversation: each keeps its run id, so the next resume reconnects it, and reads the
|
|
460
|
+
* state it read, except one that read `running`, which settles on `awaiting_input`. React's
|
|
461
|
+
* StrictMode mounts, unmounts and mounts again, which parks and resumes with one live session per
|
|
462
|
+
* thread at the end. A command does nothing while the engine is parked or disposed: a run opened
|
|
463
|
+
* with nobody watching could be neither seen nor stopped. {@link AgentThreadsEngine.dispose} is
|
|
464
|
+
* the latch, for an owner that is not a component.
|
|
465
|
+
*
|
|
466
|
+
* A reconnect is read by a new session, which its thread's host hands the position the parked
|
|
467
|
+
* session had reached in the run's stream. The stream resumes after it, so the transcript the
|
|
468
|
+
* park kept is written to by the frames it has not read and by no frame a second time. A thread
|
|
469
|
+
* restored from the URL has no such position and an empty transcript: its run's history is read
|
|
470
|
+
* from the first event and writes each entry once.
|
|
471
|
+
*
|
|
472
|
+
* No clock and no timer: nothing here waits on product time. Ids come from the `ids` option,
|
|
473
|
+
* so a thread id is as deterministic as the host's seam.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```ts
|
|
477
|
+
* import type { AgentTransport } from "@mountaya/client/events";
|
|
478
|
+
* import type { StudioToolContext, StudioToolInputs, ToolBus } from "@mountaya/studio";
|
|
479
|
+
* import {
|
|
480
|
+
* AgentThreadsEngine,
|
|
481
|
+
* type AgentThreadsState,
|
|
482
|
+
* agentErrorCopy,
|
|
483
|
+
* } from "@mountaya/studio/agent";
|
|
484
|
+
* import { sequentialStudioIds } from "@mountaya/studio/seams";
|
|
485
|
+
* import { studioStrings } from "@mountaya/studio/strings";
|
|
486
|
+
*
|
|
487
|
+
* declare const bus: ToolBus<StudioToolContext, StudioToolInputs>;
|
|
488
|
+
* declare const context: StudioToolContext;
|
|
489
|
+
* declare const transport: AgentTransport;
|
|
490
|
+
* declare function render(state: AgentThreadsState): void;
|
|
491
|
+
*
|
|
492
|
+
* const threads = new AgentThreadsEngine({
|
|
493
|
+
* bus,
|
|
494
|
+
* context,
|
|
495
|
+
* errorCopy: agentErrorCopy(studioStrings.en),
|
|
496
|
+
* ids: sequentialStudioIds("thread"),
|
|
497
|
+
* strings: studioStrings.en,
|
|
498
|
+
* transport,
|
|
499
|
+
* });
|
|
500
|
+
* const release = threads.subscribe(() => render(threads.getSnapshot()));
|
|
501
|
+
*
|
|
502
|
+
* threads.submit("Plan a loop from here");
|
|
503
|
+
* release();
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
declare class AgentThreadsEngine {
|
|
507
|
+
private config;
|
|
508
|
+
private readonly ids;
|
|
509
|
+
private readonly store;
|
|
510
|
+
private readonly tabs;
|
|
511
|
+
private readonly subscriptions;
|
|
512
|
+
/** The store subscription the listeners are notified through, while the engine runs. */
|
|
513
|
+
private releaseStore;
|
|
514
|
+
/** The UI store the driving flag is mirrored into, while the engine runs. */
|
|
515
|
+
private mirrored;
|
|
516
|
+
/**
|
|
517
|
+
* What the URL named at construction, kept while the viewer the seed read is withheld the
|
|
518
|
+
* co-pilot and restored for that viewer once entitled. Null for a seed that read an entitled
|
|
519
|
+
* viewer, and once restored.
|
|
520
|
+
*/
|
|
521
|
+
private unrestored;
|
|
522
|
+
/** The viewer seam the engine hears a change of the entitlement from, while it runs. */
|
|
523
|
+
private heard;
|
|
524
|
+
/** One host per thread: its session and its started guard. */
|
|
525
|
+
private readonly hosts;
|
|
526
|
+
/** The resolver of each thread's parked confirmation. */
|
|
527
|
+
private readonly confirmations;
|
|
528
|
+
/** The surfaces each thread's run is routed to; a thread with none offers every tool. */
|
|
529
|
+
private readonly surfaces;
|
|
530
|
+
/** The last message each thread routed on, replayed by a re-route from state. */
|
|
531
|
+
private readonly lastRouted;
|
|
532
|
+
/** The generate call that owns the workspace's one suggest session, and its thread. */
|
|
533
|
+
private suggestBatchOwner;
|
|
534
|
+
/** The suggestions cards whose pick is still applying, by entry id. */
|
|
535
|
+
private readonly stagingPicks;
|
|
536
|
+
/**
|
|
537
|
+
* The threads whose last message is out and whose turn the session has not picked up. While
|
|
538
|
+
* a thread is here, its session's `awaiting_input` is the run being readied and never the
|
|
539
|
+
* turn settling.
|
|
540
|
+
*/
|
|
541
|
+
private readonly awaitingTurn;
|
|
542
|
+
/**
|
|
543
|
+
* The state each thread's session last reported, and no entry for one that has reported none,
|
|
544
|
+
* which reads `awaiting_input`. It says whether a message is sent into a turn under way, which
|
|
545
|
+
* the session answers with no report of `running`.
|
|
546
|
+
*/
|
|
547
|
+
private readonly sessionStates;
|
|
548
|
+
/** Whether nobody is watching. A parked engine opens nothing and answers no command. */
|
|
549
|
+
private parked;
|
|
550
|
+
private disposed;
|
|
551
|
+
/**
|
|
552
|
+
* The tab strip the studio's tab verbs mutate through. Every member but the two reads,
|
|
553
|
+
* `countOpen` and `hasTab`, does nothing while the engine is parked, and an opening member
|
|
554
|
+
* then answers the tab already shown.
|
|
555
|
+
*/
|
|
556
|
+
private readonly tabSurface;
|
|
557
|
+
/**
|
|
558
|
+
* Constructing one seeds the store and does nothing else: it reads the URL seam once and the
|
|
559
|
+
* viewer's entitlement as it stands, builds no host, opens no run and writes no URL. A React
|
|
560
|
+
* binding constructs during a render React is free to throw away, and a constructor with a side
|
|
561
|
+
* effect outside its own store would leave the discarded copy acting.
|
|
562
|
+
*/
|
|
563
|
+
constructor(options: AgentThreadsEngineOptions);
|
|
564
|
+
/** getSnapshot returns the conversations' state, by reference and stable between changes. */
|
|
565
|
+
getSnapshot(): AgentThreadsState;
|
|
566
|
+
/**
|
|
567
|
+
* subscribe registers a listener for every change of the snapshot, and returns its own
|
|
568
|
+
* unsubscribe, which is idempotent.
|
|
569
|
+
*
|
|
570
|
+
* The first listener resumes the engine and the last one leaving parks it, which is the whole
|
|
571
|
+
* lifecycle a component can express correctly: React tears an effect down and sets it up
|
|
572
|
+
* again with the same object under StrictMode, so a latch here would leave a live surface
|
|
573
|
+
* bound to a dead engine. Each call is its own subscription, so two owners subscribing one
|
|
574
|
+
* shared function each hold the engine until they release it.
|
|
575
|
+
*/
|
|
576
|
+
subscribe(listener: () => void): () => void;
|
|
577
|
+
/**
|
|
578
|
+
* configure replaces the configuration. Nothing is asked and no session is rebuilt: every
|
|
579
|
+
* member is read when it is used, so a binding may call this on every render and an unchanged
|
|
580
|
+
* configuration costs an assignment. Two things move with the context: the driving flag's
|
|
581
|
+
* mirror, when it carries a different UI store (the store it leaves is reset, and the new one is
|
|
582
|
+
* brought in line with the conversations), and the subscription to the viewer, when it carries
|
|
583
|
+
* a different viewer.
|
|
584
|
+
*/
|
|
585
|
+
configure(config: AgentThreadsConfig): void;
|
|
586
|
+
/**
|
|
587
|
+
* dispose parks the engine and drops every listener, for good.
|
|
588
|
+
*
|
|
589
|
+
* Idempotent, and every call after it is a no-op rather than an error, a subscription
|
|
590
|
+
* included: an owner torn down mid-run should not have to guard the calls it already queued.
|
|
591
|
+
*/
|
|
592
|
+
dispose(): void;
|
|
593
|
+
/**
|
|
594
|
+
* answerQuestion settles the active conversation's question card with the picked option, then
|
|
595
|
+
* sends its label as the next message. Settling first is what makes the send's sweep of open
|
|
596
|
+
* cards leave the pick marked.
|
|
597
|
+
*
|
|
598
|
+
* It does nothing unless `entryId` names a question card of the conversation that is still
|
|
599
|
+
* open: a second answer to one card, and an answer to a card a typed reply already settled,
|
|
600
|
+
* send no message, since the run is waiting on neither.
|
|
601
|
+
*/
|
|
602
|
+
answerQuestion(entryId: string, label: string): void;
|
|
603
|
+
/**
|
|
604
|
+
* chooseSuggestion applies one suggested route from a suggestions card, settles the card, and
|
|
605
|
+
* sends the pick's label as the next message.
|
|
606
|
+
*
|
|
607
|
+
* The pick is applied client-side through `studio.itinerary.suggest.applyCandidate`, which
|
|
608
|
+
* reshapes the segment the batch was generated for or appends the route as a new one, so the
|
|
609
|
+
* route is on the map before the model reads the reply. It applies to the open itinerary and
|
|
610
|
+
* never creates one. A second pick on a card whose apply is still out does nothing, since two
|
|
611
|
+
* appends would put the route in the itinerary twice. A failed apply leaves the card open and
|
|
612
|
+
* writes the staging error, so the user can pick again; an apply a host's bus rejects, or
|
|
613
|
+
* answers with no result, is a failed one. A pick whose confirmation was withheld (the user
|
|
614
|
+
* kept a staged draft the apply would drop, or left the prompt to expire) leaves the card open
|
|
615
|
+
* and writes nothing. A pick whose apply lands after the engine parked, or after its
|
|
616
|
+
* conversation closed, writes nothing and opens no run.
|
|
617
|
+
*/
|
|
618
|
+
chooseSuggestion(entryId: string, seed: number, label: string): void;
|
|
619
|
+
/** closeAiTab closes one conversation through `studio.tabs.close`. */
|
|
620
|
+
closeAiTab(tabId: string): void;
|
|
621
|
+
/** newAiTab opens a conversation through `studio.tabs.create`. */
|
|
622
|
+
newAiTab(): void;
|
|
623
|
+
/**
|
|
624
|
+
* previewCandidate paints one staged suggestion on the map through
|
|
625
|
+
* `studio.itinerary.suggest.select`, the call the suggestions panel's own rows make, so
|
|
626
|
+
* hovering a card option and hovering a panel row cannot diverge.
|
|
627
|
+
*/
|
|
628
|
+
previewCandidate(seed: number): void;
|
|
629
|
+
/**
|
|
630
|
+
* resolveConfirmation settles the active conversation's confirmation card with the user's
|
|
631
|
+
* decision and clears the card. With nothing pending (a stale click after a stop already
|
|
632
|
+
* settled it) it does nothing.
|
|
633
|
+
*/
|
|
634
|
+
resolveConfirmation(approved: boolean): void;
|
|
635
|
+
/**
|
|
636
|
+
* stopActive ends the active conversation's run: it denies a pending confirmation, asks the
|
|
637
|
+
* gateway to close the run (a run the session gave up reading included), swaps a fresh session
|
|
638
|
+
* in under the same thread so the next message opens a clean run, drops the run id and parks
|
|
639
|
+
* the thread on `awaiting_input`. The close is what stops the run spending model budget: a
|
|
640
|
+
* session torn down without it leaves the run going until the gateway's own timeout. The
|
|
641
|
+
* transcript stays, since a stop is the user's choice rather than a failure.
|
|
642
|
+
*/
|
|
643
|
+
stopActive(): void;
|
|
644
|
+
/**
|
|
645
|
+
* submit sends a message into the active conversation: the first one opens a run scoped to
|
|
646
|
+
* the organization of the resource the co-pilot is open on, with the studio snapshot as its
|
|
647
|
+
* context, and a later one is delivered into the open run.
|
|
648
|
+
*
|
|
649
|
+
* The conversation reads `running` from the submit, so the workspace locks and a surface
|
|
650
|
+
* offers its Stop before the run's context is captured and its start is made. It returns to
|
|
651
|
+
* `awaiting_input` when the turn settles, and at once when there is no organization to scope
|
|
652
|
+
* a run to or the gateway refuses the start.
|
|
653
|
+
*/
|
|
654
|
+
submit(message: string): void;
|
|
655
|
+
/** switchTab shows another tab, a conversation or a pseudo-tab, through `studio.tabs.switch`. */
|
|
656
|
+
switchTab(tabId: string): void;
|
|
657
|
+
/**
|
|
658
|
+
* live reports whether something watches the engine, which is when it acts. Every command asks
|
|
659
|
+
* it first, so a live engine restores the URL's conversations for a viewer entitled since the
|
|
660
|
+
* seed (see {@link restoreForEntitled}) ahead of the act: a host whose viewer tells no change
|
|
661
|
+
* still meets them there.
|
|
662
|
+
*/
|
|
663
|
+
private live;
|
|
664
|
+
/**
|
|
665
|
+
* isOpen reports whether an answer for a conversation still has somewhere to land: the engine
|
|
666
|
+
* is live and the conversation has not closed. An answer that arrives after either belongs to
|
|
667
|
+
* nobody.
|
|
668
|
+
*/
|
|
669
|
+
private isOpen;
|
|
670
|
+
/** activeThread is the conversation a command acts on, or null while the engine is not live. */
|
|
671
|
+
private activeThread;
|
|
672
|
+
/** shownTab is the tab the strip shows, what an opening tab verb answers while parked. */
|
|
673
|
+
private shownTab;
|
|
674
|
+
/**
|
|
675
|
+
* withheld reads whether the viewer is withheld the co-pilot, from the viewer seam as it
|
|
676
|
+
* answers now. A membership resolves after a host has mounted and an entitlement can lapse
|
|
677
|
+
* mid-session, so the answer is never held: each decision that turns on it asks again.
|
|
678
|
+
*/
|
|
679
|
+
private withheld;
|
|
680
|
+
/**
|
|
681
|
+
* seed writes the conversations a mount opens with, from the URL and the entitlement.
|
|
682
|
+
*
|
|
683
|
+
* A viewer withheld the co-pilot is restored none, whatever the URL names: their one way into
|
|
684
|
+
* the co-pilot is the withheld tab. What the URL named is kept for them, and
|
|
685
|
+
* {@link restoreForEntitled} restores it once they are entitled.
|
|
686
|
+
*/
|
|
687
|
+
private seed;
|
|
688
|
+
/**
|
|
689
|
+
* restore writes the conversations of an entitled viewer, from what the URL names, and answers
|
|
690
|
+
* the ids it created.
|
|
691
|
+
*
|
|
692
|
+
* The URL's list passes through {@link restorableThreads} first, and a conversation already
|
|
693
|
+
* open keeps its place. With none to restore, a viewer holding no conversation is opened a
|
|
694
|
+
* fresh one, and the panel lands on Search. Otherwise it lands on the tab the URL names when
|
|
695
|
+
* that tab is now open, and on Search when it is not: the withheld tab is never an entitled
|
|
696
|
+
* viewer's.
|
|
697
|
+
*/
|
|
698
|
+
private restore;
|
|
699
|
+
/**
|
|
700
|
+
* restoreForEntitled restores what the URL named at construction for a viewer the seed read as
|
|
701
|
+
* withheld and the viewer seam now answers as entitled. It runs once: a viewer who loses the
|
|
702
|
+
* entitlement afterwards and regains it is not restored a second time. A live engine connects
|
|
703
|
+
* each conversation it restores, so one carrying a run id reconnects to its run; a parked one
|
|
704
|
+
* leaves that to the next resume. The URL is written with what the restore holds: a withheld
|
|
705
|
+
* viewer's reveal may have mirrored the withheld tab over the conversations it named.
|
|
706
|
+
*/
|
|
707
|
+
private restoreForEntitled;
|
|
708
|
+
/**
|
|
709
|
+
* hearViewer subscribes to a viewer seam's changes, releasing the one heard before, so a
|
|
710
|
+
* viewer entitled while the engine runs is restored the URL's conversations as the seam tells.
|
|
711
|
+
*/
|
|
712
|
+
private hearViewer;
|
|
713
|
+
/**
|
|
714
|
+
* connect builds a thread's host and resumes its session, reconnecting to the run the thread
|
|
715
|
+
* carries. A resume that faults drops the stale run id, mirrors the drop and leaves the
|
|
716
|
+
* conversation usable, through the thread's faults, which also tell the host a reconnect
|
|
717
|
+
* refused 401.
|
|
718
|
+
*/
|
|
719
|
+
private connect;
|
|
720
|
+
/** resume starts the engine for its first subscriber. */
|
|
721
|
+
private resume;
|
|
722
|
+
/** park stops the engine when its last subscriber leaves. */
|
|
723
|
+
private park;
|
|
724
|
+
/**
|
|
725
|
+
* tellSeam calls one of the host's seams the engine writes to on its own paths: the URL
|
|
726
|
+
* mirror and the tab strip's slot. A seam that throws stops neither the resume, the park nor
|
|
727
|
+
* the command that reached it, and its fault is surfaced apart, as a listener's is.
|
|
728
|
+
*/
|
|
729
|
+
private tellSeam;
|
|
730
|
+
/**
|
|
731
|
+
* send hands a message to a thread's host, with the conversation on `running` from this
|
|
732
|
+
* moment: the workspace is the model's from the submit, across the capture of the run's
|
|
733
|
+
* context, its start and the opening of its stream.
|
|
734
|
+
*
|
|
735
|
+
* Written before the host is called, so a submit the host answers at once (no organization
|
|
736
|
+
* to scope a run to) returns the conversation to `awaiting_input` through its fault.
|
|
737
|
+
*/
|
|
738
|
+
private send;
|
|
739
|
+
/**
|
|
740
|
+
* settle returns a conversation to `awaiting_input`: its turn settled, its run faulted or was
|
|
741
|
+
* stopped. It ends the wait for a turn, so the next report of its session is read as it is.
|
|
742
|
+
*/
|
|
743
|
+
private settle;
|
|
744
|
+
/**
|
|
745
|
+
* reportSessionState writes the lifecycle state a thread's session reports, while the engine
|
|
746
|
+
* is live.
|
|
747
|
+
*
|
|
748
|
+
* A session reports `ended` as it is disposed, and the park disposes every one of them. The
|
|
749
|
+
* park ends no conversation, so what its teardown reports is not written: a conversation that
|
|
750
|
+
* never ran keeps reading `awaiting_input`, and a host reading the store sees no state the
|
|
751
|
+
* park passed through.
|
|
752
|
+
*
|
|
753
|
+
* While a thread waits on its turn, its session's `awaiting_input` is not written either: a
|
|
754
|
+
* session that read a run before reports it as it readies the next one, which would lower the
|
|
755
|
+
* lock between the submit and the turn. The wait ends when the session reports `running`,
|
|
756
|
+
* which it does from the message it takes, and its reports are the conversation's from
|
|
757
|
+
* there: the turn's settle is one of them, whether or not the turn carried a frame of its own.
|
|
758
|
+
*/
|
|
759
|
+
private reportSessionState;
|
|
760
|
+
/** writeSessionState writes a thread's state when it differs from the one it reads. */
|
|
761
|
+
private writeSessionState;
|
|
762
|
+
/** hasOpenQuestion reports whether `entryId` is a question card the thread has not settled. */
|
|
763
|
+
private hasOpenQuestion;
|
|
764
|
+
/**
|
|
765
|
+
* settleStreamingThreads returns every conversation that reads `running` to `awaiting_input`
|
|
766
|
+
* once the park has disposed its session.
|
|
767
|
+
*
|
|
768
|
+
* No session streams the turn any more, and the session the next resume builds starts on
|
|
769
|
+
* `awaiting_input` and reports a change only. A conversation left on `running` would raise
|
|
770
|
+
* the driving lock at that resume with nothing to lower it. Its run id stays, so the resume
|
|
771
|
+
* reconnects the run and the turn's frames report `running` again.
|
|
772
|
+
*/
|
|
773
|
+
private settleStreamingThreads;
|
|
774
|
+
/** mirrorInto starts mirroring the driving flag into `ui`, brought in line at once. */
|
|
775
|
+
private mirrorInto;
|
|
776
|
+
/**
|
|
777
|
+
* releaseMirror stops mirroring, leaving the UI store with no driving flag, no edit lock and
|
|
778
|
+
* no hand-off: a studio the co-pilot left is never stranded inert.
|
|
779
|
+
*/
|
|
780
|
+
private releaseMirror;
|
|
781
|
+
/**
|
|
782
|
+
* syncDriving writes the driving flag through to the UI store on a real flip only, so a token
|
|
783
|
+
* stream does not churn it.
|
|
784
|
+
*
|
|
785
|
+
* When the runs yield the workspace, the entities they locked are released, except the one a
|
|
786
|
+
* run left in an open edit session for the user to adjust and save: that draft outlives the
|
|
787
|
+
* run, and so does the co-pilot's authorship of it.
|
|
788
|
+
*/
|
|
789
|
+
private syncDriving;
|
|
790
|
+
/** syncUrl mirrors the thread ids, their run ids and the active tab through the URL seam. */
|
|
791
|
+
private syncUrl;
|
|
792
|
+
/**
|
|
793
|
+
* tabsContext is the tool context a tab verb is dispatched with: the studio's own, with this
|
|
794
|
+
* engine's tab strip layered over it and every other seam left live.
|
|
795
|
+
*/
|
|
796
|
+
private tabsContext;
|
|
797
|
+
/** ensureHost returns a thread's host, building it on first use. */
|
|
798
|
+
private ensureHost;
|
|
799
|
+
/**
|
|
800
|
+
* hostFor builds one thread's host. The run is scoped to the organization of the resource the
|
|
801
|
+
* co-pilot is open on, read through the rule the panel's gate reads, so a run opens for the
|
|
802
|
+
* organization whose card the panel shows and a personal resource opens none. A snapshot that
|
|
803
|
+
* fails to build opens the run without a context rather than blocking the message.
|
|
804
|
+
*/
|
|
805
|
+
private hostFor;
|
|
806
|
+
/**
|
|
807
|
+
* sessionFor builds one thread's session. Both confirmation gates, the server tool's and the
|
|
808
|
+
* client tool's the bus raises through `ctx.confirm`, park on that thread's in-chat card, and
|
|
809
|
+
* a client tool's card reads its localized body with the request's values, so a merge names
|
|
810
|
+
* the rows it is about to join.
|
|
811
|
+
*/
|
|
812
|
+
private sessionFor;
|
|
813
|
+
/**
|
|
814
|
+
* observerFor maps one thread's session onto its transcript, then layers the co-pilot's own
|
|
815
|
+
* side effects over it: the URL mirror of a new run id, the question card, the suggest
|
|
816
|
+
* session's owner, the edit lock and the hand-off, the suggestions card and the re-route.
|
|
817
|
+
*/
|
|
818
|
+
private observerFor;
|
|
819
|
+
/**
|
|
820
|
+
* appendQuestionCard renders a question call as its own card, parsed with the tool's own
|
|
821
|
+
* schema, and reports whether it did. A malformed input falls through to the ordinary
|
|
822
|
+
* activity row, whose dispatch then settles red, which is the honest rendering of that call.
|
|
823
|
+
*/
|
|
824
|
+
private appendQuestionCard;
|
|
825
|
+
/** isGenerate reports whether a thread recorded `toolCallId` as a generate's activity row. */
|
|
826
|
+
private isGenerate;
|
|
827
|
+
/**
|
|
828
|
+
* appendSuggestionsCard renders the live suggest session's candidates as the thread's
|
|
829
|
+
* suggestions card, keyed off the generating call so a replayed settle appends no duplicate,
|
|
830
|
+
* and frames the batch once while the thread is the tab on screen.
|
|
831
|
+
*
|
|
832
|
+
* It snapshots the SESSION, never the model's echo, so every candidate shows its true colour
|
|
833
|
+
* and metrics. A settle whose call no longer owns the session renders nothing: another thread
|
|
834
|
+
* re-pointed the session, and its candidates belong to that conversation.
|
|
835
|
+
*/
|
|
836
|
+
private appendSuggestionsCard;
|
|
837
|
+
/**
|
|
838
|
+
* stagePick applies one suggested route through the bus, and answers how it ended.
|
|
839
|
+
*
|
|
840
|
+
* A tool bus's dispatch never rejects and always answers a result, and a host's own may do
|
|
841
|
+
* neither: an apply that rejects answers the refusal the bus would have made of the throw, and
|
|
842
|
+
* one whose answer states no outcome is refused as `internal`.
|
|
843
|
+
*/
|
|
844
|
+
private stagePick;
|
|
845
|
+
/**
|
|
846
|
+
* applyPick runs one suggestions-card pick, releasing the card's guard however it ends.
|
|
847
|
+
*
|
|
848
|
+
* The apply asks before it drops a staged draft. A reader who keeps theirs (a confirmation
|
|
849
|
+
* denied or left to expire) refused nothing: the card stays pickable and nothing is written.
|
|
850
|
+
*/
|
|
851
|
+
private applyPick;
|
|
852
|
+
/**
|
|
853
|
+
* requestConfirmation parks a thread's decision on its in-chat card. A decision already parked
|
|
854
|
+
* on the thread is denied first, so no resolver is stranded, and one requested while the
|
|
855
|
+
* engine is parked, or for a conversation that has closed, is denied at once: no card could
|
|
856
|
+
* show it.
|
|
857
|
+
*/
|
|
858
|
+
private requestConfirmation;
|
|
859
|
+
/** denyPendingConfirmation denies a thread's parked decision, if any, and clears its card. */
|
|
860
|
+
private denyPendingConfirmation;
|
|
861
|
+
/**
|
|
862
|
+
* faultsFor binds the shared fault handling to one thread. The missing-organization line
|
|
863
|
+
* depends on why there is none, read when the fault happens: with nothing open it asks for an
|
|
864
|
+
* itinerary or a zone, and with a personal one open it says the co-pilot works on an
|
|
865
|
+
* organization's.
|
|
866
|
+
*/
|
|
867
|
+
private faultsFor;
|
|
868
|
+
/** routeForMessage picks the surfaces a thread's next turn offers, from its message. */
|
|
869
|
+
private routeForMessage;
|
|
870
|
+
/**
|
|
871
|
+
* routeForState re-picks from live state, replaying the thread's last message: its words
|
|
872
|
+
* carry the keyword and skill matches, and dropping them would narrow the manifest at the
|
|
873
|
+
* moment the run needs it wider.
|
|
874
|
+
*/
|
|
875
|
+
private routeForState;
|
|
876
|
+
/** route records a thread's pick, with its previous one as the stickiness input. */
|
|
877
|
+
private route;
|
|
878
|
+
/** openTab opens a conversation, with its host built so the tools and a submit find it. */
|
|
879
|
+
private openTab;
|
|
880
|
+
/**
|
|
881
|
+
* closeTab finishes one conversation's run and disposes its session, and the others run on.
|
|
882
|
+
*
|
|
883
|
+
* A pending confirmation is denied, and the suggest session is discarded when it is headless
|
|
884
|
+
* (no draft, no open panel) and this thread staged it or nobody did: a session the human is
|
|
885
|
+
* using stays, and so does one another conversation owns. Closing the last conversation of an
|
|
886
|
+
* entitled viewer opens a fresh one, so the strip always carries one.
|
|
887
|
+
*/
|
|
888
|
+
private closeTab;
|
|
889
|
+
/**
|
|
890
|
+
* showTab points the panel at a tab and mirrors it. The withheld tab is Search for an entitled
|
|
891
|
+
* viewer, so no caller shows them the host's own content over their conversations.
|
|
892
|
+
*/
|
|
893
|
+
private showTab;
|
|
894
|
+
/**
|
|
895
|
+
* resetThreads clears the co-pilot for a switched-to resource: every conversation closes, so
|
|
896
|
+
* the one about the resource being left cannot leak into the next, and the panel lands on
|
|
897
|
+
* Search behind the fresh conversation the last close opens.
|
|
898
|
+
*/
|
|
899
|
+
private resetThreads;
|
|
900
|
+
/**
|
|
901
|
+
* openOrReveal reveals the co-pilot, focusing a conversation rather than opening a second one:
|
|
902
|
+
* a withheld viewer lands on the withheld tab, an entitled one on their latest
|
|
903
|
+
* conversation, and a new one opens only when there is none.
|
|
904
|
+
*/
|
|
905
|
+
private openOrReveal;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* DirectorChatConfig is what the video director's conversation runs against, all of it
|
|
910
|
+
* replaceable mid-life through {@link DirectorChatEngine.configure}. Every member is read when
|
|
911
|
+
* it is used, so a session built after a change runs on the new values.
|
|
912
|
+
*/
|
|
913
|
+
interface DirectorChatConfig {
|
|
914
|
+
/**
|
|
915
|
+
* The bus the run advertises and dispatches through: the camera-scoped one
|
|
916
|
+
* `createVideoDirectorBus` builds, so the model is offered the camera verbs and nothing that
|
|
917
|
+
* edits an itinerary or the map.
|
|
918
|
+
*/
|
|
919
|
+
readonly bus: ToolDispatcher<StudioToolContext>;
|
|
920
|
+
/**
|
|
921
|
+
* The studio's tool context. The camera verbs dispatch through it unscoped, so they edit the
|
|
922
|
+
* same camera plan a slider does and keep each handler's own entitlement gate; only the manifest
|
|
923
|
+
* is narrowed, by the bus.
|
|
924
|
+
*/
|
|
925
|
+
readonly context: StudioToolContext;
|
|
926
|
+
/** The localized copy a terminal run error resolves onto, the co-pilot's own object. */
|
|
927
|
+
readonly errorCopy: AgentErrorCopy;
|
|
928
|
+
/**
|
|
929
|
+
* Marks an organization's AI configuration stale after a start the gateway refused for want
|
|
930
|
+
* of one, which turns the wizard's director slot into its setup card. Omitted, the refusal
|
|
931
|
+
* still surfaces its words.
|
|
932
|
+
*/
|
|
933
|
+
readonly invalidateAiConfig?: ((organizationId: string) => void) | undefined;
|
|
934
|
+
/**
|
|
935
|
+
* The organization that owns the wizard's itinerary, or null while its detail loads. It is
|
|
936
|
+
* the wizard's own itinerary rather than the studio's open one, which may be another or none,
|
|
937
|
+
* so a run is never scoped to the wrong organization; a submit before it loads writes the
|
|
938
|
+
* still-loading line instead of opening a run.
|
|
939
|
+
*/
|
|
940
|
+
readonly organizationId: string | null;
|
|
941
|
+
/**
|
|
942
|
+
* The host's own remedy for a failed camera verb, appended to the playbook's recovery the model
|
|
943
|
+
* reads with it. Omitted, the model reads the playbook's recovery alone.
|
|
944
|
+
*/
|
|
945
|
+
readonly recoveryAddendum?: RecoveryAddendum | undefined;
|
|
946
|
+
/** The words the conversation writes: fault lines and the server-tool confirmation prompt. */
|
|
947
|
+
readonly strings: Pick<StudioStrings, "confirm" | "copilot" | "director" | "prompt">;
|
|
948
|
+
/** The event transport the run is started, sent into and read over. */
|
|
949
|
+
readonly transport: AgentTransport;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* DirectorChatEngineOptions is the {@link DirectorChatConfig} an engine starts with, plus the
|
|
953
|
+
* store it writes, which is fixed for its life.
|
|
954
|
+
*/
|
|
955
|
+
interface DirectorChatEngineOptions extends DirectorChatConfig {
|
|
956
|
+
/**
|
|
957
|
+
* The store the conversation is written into, for a host that reads it with narrow selectors
|
|
958
|
+
* of its own.
|
|
959
|
+
*
|
|
960
|
+
* @default a new `createVideoDirectorStore()`
|
|
961
|
+
*/
|
|
962
|
+
readonly store?: VideoDirectorStoreApi | undefined;
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* DirectorChatEngine runs the video wizard's AI director: one conversation, one `AgentEngine`
|
|
966
|
+
* session over the camera-scoped bus, with the camera plan as the run's context.
|
|
967
|
+
*
|
|
968
|
+
* The snapshot is the director store's state (`VideoDirectorState`): the run id, the lifecycle
|
|
969
|
+
* state, the transcript and the live tool summary the directing indicator reads. No member of
|
|
970
|
+
* {@link DirectorChatConfig} keys it, so there is no previous question whose answer a
|
|
971
|
+
* configuration change could show.
|
|
972
|
+
*
|
|
973
|
+
* Its failures are the co-pilot's, handled by the same fault rules and phrased by the same
|
|
974
|
+
* copy, so a refused start, a lost credential and a budget ceiling read identically on both
|
|
975
|
+
* surfaces. It differs from {@link AgentThreadsEngine} in three deliberate ways: it mirrors no
|
|
976
|
+
* driving flag into `ctx.ui`, whose studio-wide lock would freeze the wizard it lives in; it
|
|
977
|
+
* confirms a destructive server tool through the context's own `confirm` rather than an in-chat
|
|
978
|
+
* card, since its camera verbs are all non-destructive client tools and the path is a backstop;
|
|
979
|
+
* and it persists no run id, so a reload opens a fresh conversation.
|
|
980
|
+
*
|
|
981
|
+
* A conversation reads `running` from the moment an instruction is sent, before its run has
|
|
982
|
+
* started, and returns to `awaiting_input` when the turn settles, which its session reports,
|
|
983
|
+
* and at once when the instruction opens no run.
|
|
984
|
+
*
|
|
985
|
+
* Every listener is told of a change, and one that throws stops neither the engine nor the
|
|
986
|
+
* listeners after it: its fault reaches the program as an uncaught error on a microtask, never
|
|
987
|
+
* as the outcome of a command.
|
|
988
|
+
*
|
|
989
|
+
* The lifecycle is the listeners. The first subscriber starts it, and the last unsubscribe
|
|
990
|
+
* parks it: the session is disposed, which aborts an open run's stream and asks the gateway
|
|
991
|
+
* nothing, and the conversation keeps its run id and its transcript, so the next subscriber
|
|
992
|
+
* reconnects the run, as {@link AgentThreadsEngine} does. A park ends no conversation: one that
|
|
993
|
+
* read `running` settles on `awaiting_input`, and any other reads the state it read.
|
|
994
|
+
* React's StrictMode mounts, unmounts and mounts again, which parks and resumes with the run
|
|
995
|
+
* still going. A command does nothing while the engine is parked or disposed.
|
|
996
|
+
*
|
|
997
|
+
* The reconnect is read by a new session, which the conversation's host hands the position the
|
|
998
|
+
* parked session had reached in the run's stream. The stream resumes after it, so the transcript
|
|
999
|
+
* the park kept is written to by the frames it has not read and by no frame a second time.
|
|
1000
|
+
*
|
|
1001
|
+
* {@link DirectorChatEngine.dispose} is the latch, for an owner that is not a component, and
|
|
1002
|
+
* the one teardown that ends the run: the gateway is asked to close it, since nothing reads it
|
|
1003
|
+
* again. A binding whose surface goes away for good calls it, or {@link DirectorChatEngine.stop}
|
|
1004
|
+
* first, so the run stops spending model budget then and not at the gateway's own timeout.
|
|
1005
|
+
*
|
|
1006
|
+
* @example
|
|
1007
|
+
* ```ts
|
|
1008
|
+
* import type { AgentTransport } from "@mountaya/client/events";
|
|
1009
|
+
* import type { StudioToolContext } from "@mountaya/studio";
|
|
1010
|
+
* import { agentErrorCopy, DirectorChatEngine } from "@mountaya/studio/agent";
|
|
1011
|
+
* import { createVideoDirectorBus } from "@mountaya/studio/handlers";
|
|
1012
|
+
* import { studioStrings } from "@mountaya/studio/strings";
|
|
1013
|
+
*
|
|
1014
|
+
* declare const context: StudioToolContext;
|
|
1015
|
+
* declare const transport: AgentTransport;
|
|
1016
|
+
* declare function render(state: ReturnType<DirectorChatEngine["getSnapshot"]>): void;
|
|
1017
|
+
*
|
|
1018
|
+
* const director = new DirectorChatEngine({
|
|
1019
|
+
* bus: createVideoDirectorBus(),
|
|
1020
|
+
* context,
|
|
1021
|
+
* errorCopy: agentErrorCopy(studioStrings.en),
|
|
1022
|
+
* organizationId: "org-1",
|
|
1023
|
+
* strings: studioStrings.en,
|
|
1024
|
+
* transport,
|
|
1025
|
+
* });
|
|
1026
|
+
* const release = director.subscribe(() => render(director.getSnapshot()));
|
|
1027
|
+
*
|
|
1028
|
+
* director.submit("Orbit the summit, then pull back");
|
|
1029
|
+
* release();
|
|
1030
|
+
* ```
|
|
1031
|
+
*/
|
|
1032
|
+
declare class DirectorChatEngine {
|
|
1033
|
+
private config;
|
|
1034
|
+
private readonly store;
|
|
1035
|
+
private readonly subscriptions;
|
|
1036
|
+
/** The store subscription the listeners are notified through, while the engine runs. */
|
|
1037
|
+
private releaseStore;
|
|
1038
|
+
/** The conversation's host: its one session and its started guard, built on first use. */
|
|
1039
|
+
private host;
|
|
1040
|
+
/**
|
|
1041
|
+
* Whether the last instruction is out and the session has not picked its turn up. While it
|
|
1042
|
+
* is, the session's `awaiting_input` is the run being readied and never the turn settling.
|
|
1043
|
+
*/
|
|
1044
|
+
private awaitingTurn;
|
|
1045
|
+
/**
|
|
1046
|
+
* The state the conversation's session last reported, `awaiting_input` for one that has
|
|
1047
|
+
* reported none. It says whether an instruction is sent into a turn under way, which the
|
|
1048
|
+
* session answers with no report of `running`.
|
|
1049
|
+
*/
|
|
1050
|
+
private sessionState;
|
|
1051
|
+
/** Whether nobody is watching. A parked engine opens nothing and answers no command. */
|
|
1052
|
+
private parked;
|
|
1053
|
+
private disposed;
|
|
1054
|
+
/**
|
|
1055
|
+
* Constructing one holds the options and does nothing else: no host, no session, no run. A
|
|
1056
|
+
* React binding constructs during a render React is free to throw away.
|
|
1057
|
+
*/
|
|
1058
|
+
constructor(options: DirectorChatEngineOptions);
|
|
1059
|
+
/** getSnapshot returns the conversation's state, by reference and stable between changes. */
|
|
1060
|
+
getSnapshot(): VideoDirectorState;
|
|
1061
|
+
/**
|
|
1062
|
+
* subscribe registers a listener for every change of the snapshot, and returns its own
|
|
1063
|
+
* unsubscribe, which is idempotent. The first listener starts the engine, reconnecting the
|
|
1064
|
+
* run a park left behind, and the last one leaving parks it; each call is its own
|
|
1065
|
+
* subscription.
|
|
1066
|
+
*/
|
|
1067
|
+
subscribe(listener: () => void): () => void;
|
|
1068
|
+
/**
|
|
1069
|
+
* configure replaces the configuration. Nothing is asked and no session is rebuilt, since
|
|
1070
|
+
* every member is read when it is used, so a binding may call this on every render.
|
|
1071
|
+
*/
|
|
1072
|
+
configure(config: DirectorChatConfig): void;
|
|
1073
|
+
/**
|
|
1074
|
+
* dispose parks the engine and drops every listener, for good, and asks the gateway to close
|
|
1075
|
+
* the conversation's run: nothing reads it again, and a run left open spends model budget
|
|
1076
|
+
* until the gateway's own timeout. The conversation is left on `awaiting_input` with no run
|
|
1077
|
+
* id and its transcript intact. Idempotent, and every call after it is a no-op rather than an
|
|
1078
|
+
* error.
|
|
1079
|
+
*/
|
|
1080
|
+
dispose(): void;
|
|
1081
|
+
/**
|
|
1082
|
+
* stop ends the run: the gateway is asked to close it (a run the session gave up reading
|
|
1083
|
+
* included), a fresh session is swapped in so the next instruction opens a clean run, and the
|
|
1084
|
+
* conversation is parked on `awaiting_input`. The close is what stops the run spending model
|
|
1085
|
+
* budget: a session torn down without it leaves the run going until the gateway's own timeout.
|
|
1086
|
+
* The transcript stays, since a stop is the user's choice and nothing the run did may vanish.
|
|
1087
|
+
*/
|
|
1088
|
+
stop(): void;
|
|
1089
|
+
/**
|
|
1090
|
+
* submit sends an instruction: the first one opens a run scoped to the wizard itinerary's
|
|
1091
|
+
* organization, with the camera plan as its context, and a later one is delivered into the
|
|
1092
|
+
* open run.
|
|
1093
|
+
*
|
|
1094
|
+
* The conversation reads `running` from the submit, so a surface offers its Stop before the
|
|
1095
|
+
* run has started. It returns to `awaiting_input` when the turn settles, and at once when the
|
|
1096
|
+
* itinerary's organization is not known yet or the gateway refuses the start.
|
|
1097
|
+
*/
|
|
1098
|
+
submit(message: string): void;
|
|
1099
|
+
/** live reports whether something watches the engine, which is when it acts. */
|
|
1100
|
+
private live;
|
|
1101
|
+
/**
|
|
1102
|
+
* resume starts the engine for its first subscriber, and reconnects the run a park left
|
|
1103
|
+
* behind. A reconnect that faults drops the stale run id and leaves the conversation usable.
|
|
1104
|
+
* With no run to reconnect it builds nothing: the session is built by the first instruction.
|
|
1105
|
+
*/
|
|
1106
|
+
private resume;
|
|
1107
|
+
/**
|
|
1108
|
+
* park stops the engine when its last subscriber leaves: the session is disposed with no
|
|
1109
|
+
* close, so the run goes on at the gateway and the conversation keeps its id for the next
|
|
1110
|
+
* subscriber to reconnect.
|
|
1111
|
+
*
|
|
1112
|
+
* A conversation that read `running` settles on `awaiting_input`: no session streams it any
|
|
1113
|
+
* more, and the session the next resume builds starts on `awaiting_input` and reports a
|
|
1114
|
+
* change only. A conversation at rest is left as it is, so a remount writes nothing.
|
|
1115
|
+
*/
|
|
1116
|
+
private park;
|
|
1117
|
+
/**
|
|
1118
|
+
* closeRun asks the gateway to close the conversation's run, for {@link dispose}.
|
|
1119
|
+
*
|
|
1120
|
+
* While the engine runs, the session holds the run and knows whether a close is still owed,
|
|
1121
|
+
* so the host finishes it. After a park no session holds it: the close is posted through the
|
|
1122
|
+
* transport for the run id the park kept, unless that run had already ended. A close the
|
|
1123
|
+
* gateway refuses is dropped, since the run it names is gone or expires on the gateway's own
|
|
1124
|
+
* timeout, and nothing is left to report it to.
|
|
1125
|
+
*/
|
|
1126
|
+
private closeRun;
|
|
1127
|
+
/**
|
|
1128
|
+
* settle returns the conversation to `awaiting_input`: its turn settled or its run faulted.
|
|
1129
|
+
* It ends the wait for a turn, so the next report of its session is read as it is.
|
|
1130
|
+
*/
|
|
1131
|
+
private settle;
|
|
1132
|
+
/**
|
|
1133
|
+
* reportSessionState writes the lifecycle state the session reports, while the engine is
|
|
1134
|
+
* live: a session reports `ended` as the park disposes it, and the park ends no conversation.
|
|
1135
|
+
* While the conversation waits on its turn, the session's `awaiting_input` is not written
|
|
1136
|
+
* either: it is the run being readied. The wait ends when the session reports `running`,
|
|
1137
|
+
* which it does from the message it takes, and its reports are the conversation's from
|
|
1138
|
+
* there: the turn's settle is one of them, whether or not the turn carried a frame of its own.
|
|
1139
|
+
*/
|
|
1140
|
+
private reportSessionState;
|
|
1141
|
+
/** writeSessionState writes the conversation's state when it differs from the one it reads. */
|
|
1142
|
+
private writeSessionState;
|
|
1143
|
+
/** ensureHost returns the conversation's host, building it on first use. */
|
|
1144
|
+
private ensureHost;
|
|
1145
|
+
/** session builds the conversation's session over the camera-scoped bus. */
|
|
1146
|
+
private session;
|
|
1147
|
+
/**
|
|
1148
|
+
* faults binds the shared fault handling to the conversation. No URL is mirrored, so nothing
|
|
1149
|
+
* follows a fault that dropped the run id.
|
|
1150
|
+
*/
|
|
1151
|
+
private faults;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
/**
|
|
1155
|
+
* agentErrorCopy builds the localized copy a terminal run error resolves onto, from the studio's
|
|
1156
|
+
* strings.
|
|
1157
|
+
*
|
|
1158
|
+
* Its answer is the `errorCopy` both {@link AgentThreadsEngine} and {@link DirectorChatEngine}
|
|
1159
|
+
* take, and what `resolveAgentError` of `@mountaya/elements/agent` chooses between: a budget
|
|
1160
|
+
* ceiling by the dimension it exhausted, a rate limit, a run that stopped itself for repeating one
|
|
1161
|
+
* action, a run stopped because its member may not run it there any more (no write role in its
|
|
1162
|
+
* organization, or an agreement that does not include Map Studio), an organization with no AI
|
|
1163
|
+
* provider configured, and the generic line for everything else. Every AI surface builds its copy
|
|
1164
|
+
* here, so the co-pilot and the video director phrase one failure in the same words whoever mounted
|
|
1165
|
+
* them: the failure is the gateway's, never the surface's.
|
|
1166
|
+
*
|
|
1167
|
+
* `strings` is the two sections it reads, in the language already resolved. Pass the bundle
|
|
1168
|
+
* `resolveStudioStrings` answers, or the two sections alone. Pure: it holds nothing and reads no
|
|
1169
|
+
* language of its own, so a locale change is a second call with the new bundle. A binding that
|
|
1170
|
+
* hands the answer to an engine on every render memoizes the call on the bundle.
|
|
1171
|
+
*
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```ts
|
|
1174
|
+
* declare const strings: StudioStrings;
|
|
1175
|
+
* declare const options: Omit<AgentThreadsEngineOptions, "errorCopy">;
|
|
1176
|
+
*
|
|
1177
|
+
* const threads = new AgentThreadsEngine({ ...options, errorCopy: agentErrorCopy(strings) });
|
|
1178
|
+
* ```
|
|
1179
|
+
*/
|
|
1180
|
+
declare const agentErrorCopy: (strings: Pick<StudioStrings, "copilot" | "prompt">) => AgentErrorCopy;
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* copilotOrganizationId reads the organization a co-pilot run is scoped to off the open editor
|
|
1184
|
+
* resource, and tells the two ways of having none apart.
|
|
1185
|
+
*
|
|
1186
|
+
* - A string is the organization that owns the open resource, and a run opens for it.
|
|
1187
|
+
* - `null` is an open resource that belongs to no organization: a personal itinerary or zone.
|
|
1188
|
+
* A run belongs to an organization, whose AI provider it runs on, so there is no run to open,
|
|
1189
|
+
* and the reader is told why rather than asked to open the thing they already have open.
|
|
1190
|
+
* - `undefined` is nothing open at all, and asking the reader to open something is right.
|
|
1191
|
+
*
|
|
1192
|
+
* The open resource decides, never whether its organization is set. A personal itinerary is an
|
|
1193
|
+
* answer rather than a gap, so it is not filled in from a zone open beside it, which would open
|
|
1194
|
+
* the run for an organization the itinerary is not in. An open itinerary decides first, then a
|
|
1195
|
+
* saved zone, then an armed zone create, whose organization rides the session because nothing is
|
|
1196
|
+
* persisted yet. An edit session carries no organization of its own: the zone it edits answers.
|
|
1197
|
+
*
|
|
1198
|
+
* One rule for every surface that asks, because the question comes up in more than one place:
|
|
1199
|
+
* whether the co-pilot panel offers a run at all, and which organization a run it starts opens
|
|
1200
|
+
* for. Reading each from here is what keeps the card a reader sees and the run that opens from
|
|
1201
|
+
* disagreeing about which resource the co-pilot is on.
|
|
1202
|
+
*/
|
|
1203
|
+
declare const copilotOrganizationId: (state: UiState) => string | null | undefined;
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* GeneratedPlaybookEntry is one tool's compiled playbook: the description the
|
|
1207
|
+
* model reads, plus the classification a parity test holds against the live tool
|
|
1208
|
+
* definition. The authored YAML carries far more (examples, mistakes, recovery);
|
|
1209
|
+
* none of it ships to a model, so none of it is here.
|
|
1210
|
+
*/
|
|
1211
|
+
interface GeneratedPlaybookEntry {
|
|
1212
|
+
/** Mirrors the tool's capability. Absent for a Data API operation. */
|
|
1213
|
+
capability?: string | undefined;
|
|
1214
|
+
confirms: boolean;
|
|
1215
|
+
description: string;
|
|
1216
|
+
id: string;
|
|
1217
|
+
kind: string;
|
|
1218
|
+
/**
|
|
1219
|
+
* What to do about a specific failure code. Attached to a failing result rather
|
|
1220
|
+
* than stated in the prompt, so it costs nothing for the codes that never fire
|
|
1221
|
+
* and arrives at the moment it is actionable.
|
|
1222
|
+
*/
|
|
1223
|
+
recovery: readonly GeneratedRecovery[];
|
|
1224
|
+
surfaces: readonly string[];
|
|
1225
|
+
}
|
|
1226
|
+
/** GeneratedRecovery is the instruction for one failure code. */
|
|
1227
|
+
interface GeneratedRecovery {
|
|
1228
|
+
code: string;
|
|
1229
|
+
do: string;
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* PLAYBOOK is the compiled entry table, sorted by id.
|
|
1233
|
+
*/
|
|
1234
|
+
declare const PLAYBOOK: readonly GeneratedPlaybookEntry[];
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* GeneratedSurface is one semantic tool subset, with the routing hints the
|
|
1238
|
+
* surface router reads.
|
|
1239
|
+
*/
|
|
1240
|
+
interface GeneratedSurface {
|
|
1241
|
+
always: boolean;
|
|
1242
|
+
id: string;
|
|
1243
|
+
keywords: readonly string[];
|
|
1244
|
+
members: readonly string[];
|
|
1245
|
+
purpose: string;
|
|
1246
|
+
title: string;
|
|
1247
|
+
wideFallback: boolean;
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* SURFACES is the compiled surface table. Membership patterns are expanded at
|
|
1251
|
+
* generation, so a pattern matching nothing fails the build rather than quietly
|
|
1252
|
+
* yielding an empty surface.
|
|
1253
|
+
*/
|
|
1254
|
+
declare const SURFACES: readonly GeneratedSurface[];
|
|
1255
|
+
|
|
1256
|
+
export { AgentThreadsEngine, DirectorChatEngine, PLAYBOOK, SURFACES, WITHHELD_TAB_ID, agentErrorCopy, copilotOrganizationId, createAgentThreadsStore, recoveryFor, selectAgentDriving, selectSurfaces, surfaceTools };
|
|
1257
|
+
export type { AgentThreadMirror, AgentThreadsActions, AgentThreadsConfig, AgentThreadsEngineOptions, AgentThreadsState, AgentThreadsStore, AgentThreadsStoreApi, AgentThreadsTabsSeam, AgentThreadsUrlSeam, DirectorChatConfig, DirectorChatEngineOptions, GeneratedPlaybookEntry, GeneratedRecovery, GeneratedSurface, RecoveryAddendum, RouterDecision, RouterState, ThreadState };
|