@mountaya/studio 0.1.0 → 0.2.0

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