sliccy 5.37.0 → 5.38.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 (123) hide show
  1. package/dist/node-server/_cloud_core/src/operations/resume.d.ts.map +1 -1
  2. package/dist/node-server/_cloud_core/src/operations/resume.js +33 -14
  3. package/dist/node-server/_cloud_core/tests/resume.test.js +107 -0
  4. package/dist/node-server/_shared/agent-wire-types.d.ts +196 -0
  5. package/dist/node-server/_shared/agent-wire-types.d.ts.map +1 -0
  6. package/dist/node-server/_shared/agent-wire-types.js +14 -0
  7. package/dist/node-server/_shared/agent-wire-types.js.map +1 -0
  8. package/dist/node-server/_shared/index.d.ts +2 -0
  9. package/dist/node-server/_shared/index.d.ts.map +1 -1
  10. package/dist/node-server/_shared/index.js +2 -0
  11. package/dist/node-server/_shared/index.js.map +1 -1
  12. package/dist/node-server/_shared/tray-sync-protocol.d.ts +436 -0
  13. package/dist/node-server/_shared/tray-sync-protocol.d.ts.map +1 -0
  14. package/dist/node-server/_shared/tray-sync-protocol.js +74 -0
  15. package/dist/node-server/_shared/tray-sync-protocol.js.map +1 -0
  16. package/dist/ui/assets/{account-store-BtdLP25D.js → account-store-BwqAgZxU.js} +3 -3
  17. package/dist/ui/assets/{account-store-C_XObYxS.js → account-store-jq6qbUYX.js} +2 -2
  18. package/dist/ui/assets/{adobe-CiIVU_Wv.js → adobe-CX-m4g6u.js} +2 -2
  19. package/dist/ui/assets/{adobe-Czsyjk5B.js → adobe-WD3NmGw5.js} +1 -1
  20. package/dist/ui/assets/{adobe-oauth-state-DiSnFEyL.js → adobe-oauth-state-4qYBVaiH.js} +1 -1
  21. package/dist/ui/assets/{adobe-oauth-state-Dg32GYJc.js → adobe-oauth-state-D0BLWPxR.js} +1 -1
  22. package/dist/ui/assets/{agent-message-to-chat-CRELISUW.js → agent-message-to-chat-Cs5mSYoo.js} +1 -1
  23. package/dist/ui/assets/{apps-Ce_xQqqd.js → apps-DxyJHt8m.js} +1 -1
  24. package/dist/ui/assets/{azure-openai-B4FX_29V.js → azure-openai-BRATetQh.js} +1 -1
  25. package/dist/ui/assets/{azure-openai-BYOoBpQn.js → azure-openai-WKXB1UzI.js} +1 -1
  26. package/dist/ui/assets/{cdp-IDGN5yWS.js → cdp-FrTDh4u0.js} +1 -1
  27. package/dist/ui/assets/{cerebras-CPP1xch3.js → cerebras-BNA0YSdc.js} +1 -1
  28. package/dist/ui/assets/{cerebras-DDT006sn.js → cerebras-DFxSTvw_.js} +1 -1
  29. package/dist/ui/assets/{composer-speech-BVrOfKlO.js → composer-speech-CpZRlNH5.js} +1 -1
  30. package/dist/ui/assets/{connect-surface-CHvb8DSX.js → connect-surface-D3qbd8TF.js} +1 -1
  31. package/dist/ui/assets/dip-BHuDjvWz.js +1 -0
  32. package/dist/ui/assets/{dist-DbGcTJlD.js → dist-BK_2Z4jS.js} +1 -1
  33. package/dist/ui/assets/{dist-CJGfNeYL.js → dist-CXwxWROf.js} +1 -1
  34. package/dist/ui/assets/{ensure-speech-assets-DzJP_ah0.js → ensure-speech-assets-X-L3SzyP.js} +1 -1
  35. package/dist/ui/assets/esp8266-StTHoYkD.js +1 -0
  36. package/dist/ui/assets/{esptool-operations-C2NywTVj.js → esptool-operations-B4Na8HtV.js} +2 -2
  37. package/dist/ui/assets/{fs-C_ebIjiT.js → fs-Df7sYx74.js} +2 -2
  38. package/dist/ui/assets/{fs-alPNRsiG.js → fs-_oUixkbC.js} +1 -1
  39. package/dist/ui/assets/{github-DybmCV3q.js → github-DP3GZpGL.js} +2 -2
  40. package/dist/ui/assets/{github-copilot-CVb6Atwv.js → github-copilot-C-u2FH3z.js} +1 -1
  41. package/dist/ui/assets/{github-copilot-B39qSAmX.js → github-copilot-CLufoxzh.js} +1 -1
  42. package/dist/ui/assets/{github-BbazgdtU.js → github-yl1nGUsi.js} +1 -1
  43. package/dist/ui/assets/{hear-BVUuCwWZ.js → hear-B5lHtYAF.js} +1 -1
  44. package/dist/ui/assets/{hear-YP69TAqr.js → hear-fb2DonIO.js} +1 -1
  45. package/dist/ui/assets/js-realm-worker-DIIEYNmq.js +50 -0
  46. package/dist/ui/assets/{kernel-worker-Bon_aPbd.js → kernel-worker-KfiNrFZa.js} +1005 -1005
  47. package/dist/ui/assets/{kokoro-engine-Bd2iynBB.js → kokoro-engine-OU1aAvil.js} +1 -1
  48. package/dist/ui/assets/{lick-ws-bridge-CToHfPYo.js → lick-ws-bridge-B2l6WCah.js} +1 -1
  49. package/dist/ui/assets/{lick-ws-bridge-Dw6eo9wW.js → lick-ws-bridge-Bo-PcDzf.js} +1 -1
  50. package/dist/ui/assets/{local-llm-C198J03B.js → local-llm-CH4nP1O7.js} +1 -1
  51. package/dist/ui/assets/main-BRGhWT87.js +24 -0
  52. package/dist/ui/assets/{main-cherry-DdlW49Q5.js → main-cherry-C4cWQqKP.js} +1 -1
  53. package/dist/ui/assets/mount-BY80h7gg.js +1 -0
  54. package/dist/ui/assets/{mount-C7iODc8d.js → mount-DhOF_XqM.js} +2 -2
  55. package/dist/ui/assets/{mount-bridge-client-VA_GLWNL.js → mount-bridge-client-mzFXy2FO.js} +1 -1
  56. package/dist/ui/assets/{new-session-CVpbJwqJ.js → new-session-O_pJGNWT.js} +2 -2
  57. package/dist/ui/assets/{oauth-bootstrap-6WNqJOGB.js → oauth-bootstrap-DdCI42FH.js} +2 -2
  58. package/dist/ui/assets/{oauth-service-DdejFjWa.js → oauth-service-8K-X1_wU.js} +1 -1
  59. package/dist/ui/assets/{oauth-service-DALcoLdp.js → oauth-service-_jFyYPI1.js} +1 -1
  60. package/dist/ui/assets/{openai-codex-ByT7NrgU.js → openai-codex-C-ks8BZ0.js} +1 -1
  61. package/dist/ui/assets/{openai-codex-CHaTGKCv.js → openai-codex-CQrj7t7D.js} +1 -1
  62. package/dist/ui/assets/page-follower-tray-fdN8h0wO.js +5 -0
  63. package/dist/ui/assets/{panel-rpc-handlers-SlTMgubf.js → panel-rpc-handlers-C1k8E3xd.js} +2 -2
  64. package/dist/ui/assets/{port-bridge-client-HYsuFrMw.js → port-bridge-client-4I4keX4E.js} +1 -1
  65. package/dist/ui/assets/{port-bridge-client-CbHZI-MK.js → port-bridge-client-Dl2l4qs-.js} +1 -1
  66. package/dist/ui/assets/{provider-wvpI16HO.js → provider-BQoQEo8P.js} +2 -2
  67. package/dist/ui/assets/{provider-CLXX3KHx.js → provider-CcuRQnMD.js} +1 -1
  68. package/dist/ui/assets/provider-store-access-B9Ys_8L2.js +1 -0
  69. package/dist/ui/assets/provider-store-access-wha2-eHY.js +1 -0
  70. package/dist/ui/assets/{providers-BO-8FFwz.js → providers-BchxMUCc.js} +2 -2
  71. package/dist/ui/assets/{providers-DlSd_BVD.js → providers-CyCzc4hF.js} +1 -1
  72. package/dist/ui/assets/{proxied-fetch-CaWoNw-n.js → proxied-fetch-9Y1yFIti.js} +1 -1
  73. package/dist/ui/assets/proxied-fetch-C0UCD_nd.js +1 -0
  74. package/dist/ui/assets/{quick-llm-BpSztOYA.js → quick-llm-fbwxAu3B.js} +1 -1
  75. package/dist/ui/assets/remote-cdp-transport-m_T16Bkr.js +1 -0
  76. package/dist/ui/assets/{secret-env-zIJToV_E.js → secret-env-BK4_mrXD.js} +1 -1
  77. package/dist/ui/assets/{secret-topology-k6-rjoyS.js → secret-topology-wZsuRrlb.js} +1 -1
  78. package/dist/ui/assets/{secrets-bridge-client-2HszvKw8.js → secrets-bridge-client-Cr8LDWEK.js} +1 -1
  79. package/dist/ui/assets/session-freezer-CP8ekx83.js +1 -0
  80. package/dist/ui/assets/{speak-jtxkz5Bb.js → speak-C-EBs9ff.js} +1 -1
  81. package/dist/ui/assets/{speak-SFLBDxI4.js → speak-DG-t8G-C.js} +1 -1
  82. package/dist/ui/assets/{sprinkle-manager-BAc-gBVb.js → sprinkle-manager-BzQIGsTC.js} +1 -1
  83. package/dist/ui/assets/{src-YN73WJ67.js → src-CAHYy5iz.js} +1 -1
  84. package/dist/ui/assets/{store-D0U9PK1f.js → store-BUckW3YY.js} +1 -1
  85. package/dist/ui/assets/{sudo-5ISkrT7v.js → sudo-D3lH5S3Q.js} +1 -1
  86. package/dist/ui/assets/{transformers-env-BQUsr-h9.js → transformers-env-BJuly8Ix.js} +1 -1
  87. package/dist/ui/assets/{transformers-env-CkeqVcSF.js → transformers-env-Dd33Tfgn.js} +1 -1
  88. package/dist/ui/assets/{tray-leader-CnF4B3pD.js → tray-leader-GpsWLsgj.js} +1 -1
  89. package/dist/ui/assets/{tray-leave-runtime-D40kDbba.js → tray-leave-runtime-BEmffF77.js} +1 -1
  90. package/dist/ui/assets/{upgrade-detection-DjV2wxcI.js → upgrade-detection-DsyQcX-f.js} +1 -1
  91. package/dist/ui/assets/{voice-reply-DDgEQ0N-.js → voice-reply-BPXpUIGh.js} +1 -1
  92. package/dist/ui/assets/{wc-attach-DWOPkvBs.js → wc-attach-DgMYE0jy.js} +3 -3
  93. package/dist/ui/assets/{wc-extension-DR2I1azo.js → wc-extension-Cq-Arv3C.js} +2 -2
  94. package/dist/ui/assets/{wc-float-label-DXWATTwk.js → wc-float-label-Ca6eHC5P.js} +1 -1
  95. package/dist/ui/assets/{wc-follower-BKAW8cHY.js → wc-follower-CdWd2sEh.js} +3 -3
  96. package/dist/ui/assets/{wc-live-CrLI_0CH.js → wc-live-CCm6sZlD.js} +5 -5
  97. package/dist/ui/assets/{wc-nav-DFqPWaUK.js → wc-nav-Dxl6HRHC.js} +2 -2
  98. package/dist/ui/assets/{wc-onboarding-C9rCuWNf.js → wc-onboarding-DJCP0L_g.js} +2 -2
  99. package/dist/ui/assets/{wc-placeholder-J1FH8G70.js → wc-placeholder-BmRL3s-1.js} +3 -3
  100. package/dist/ui/assets/{wc-settings-CQoEk2K5.js → wc-settings-Chrc3Nh6.js} +3 -3
  101. package/dist/ui/assets/{wc-shell-B-akB5VI.js → wc-shell-BOmrvZSa.js} +3 -3
  102. package/dist/ui/assets/{wc-sprinkles-Ccxd1yb3.js → wc-sprinkles-D_ia6rFM.js} +2 -2
  103. package/dist/ui/assets/wc-tray-BCRxHf7g.js +2 -0
  104. package/dist/ui/assets/{whisper-engine-BJaXJdvL.js → whisper-engine-B4DFC652.js} +1 -1
  105. package/dist/ui/assets/{whisper-session-B3WkTRmf.js → whisper-session-B__paJv7.js} +2 -2
  106. package/dist/ui/assets/{xai-grok-BL6nieLS.js → xai-grok-CgWUsJuR.js} +1 -1
  107. package/dist/ui/assets/{xai-grok-WsQKFuk3.js → xai-grok-CpRv8TEz.js} +1 -1
  108. package/dist/ui/index.html +8 -8
  109. package/dist/ui/llm-proxy-sw.js +1 -1
  110. package/dist/ui/packages/webapp/index.html +8 -8
  111. package/package.json +2 -2
  112. package/dist/ui/assets/dip-DNFD9pM1.js +0 -1
  113. package/dist/ui/assets/esp8266-BNgMfI2Y.js +0 -1
  114. package/dist/ui/assets/js-realm-worker-wU5ANqny.js +0 -50
  115. package/dist/ui/assets/main-B4KvrInv.js +0 -24
  116. package/dist/ui/assets/mount-BocPpaNr.js +0 -1
  117. package/dist/ui/assets/page-follower-tray-COiGo3oj.js +0 -5
  118. package/dist/ui/assets/provider-store-access-COMIbRsS.js +0 -1
  119. package/dist/ui/assets/provider-store-access-DbRWJWRv.js +0 -1
  120. package/dist/ui/assets/proxied-fetch-BG3drLHR.js +0 -1
  121. package/dist/ui/assets/remote-cdp-transport-ZG2v9Vg-.js +0 -1
  122. package/dist/ui/assets/session-freezer-DfrdCNmm.js +0 -1
  123. package/dist/ui/assets/wc-tray-BTEJSl_b.js +0 -2
@@ -0,0 +1,436 @@
1
+ /**
2
+ * Typed sync protocol for tray WebRTC data channels — canonical wire format.
3
+ *
4
+ * Leader → Follower: chat snapshots (single + chunked), streamed agent events,
5
+ * user-message echoes, scoop list, sprinkle list / content / updates,
6
+ * federated CDP (request + response + event), federated tab.open and its
7
+ * reply pair, federated FS (request + response), liveness (ping/pong/status/error).
8
+ *
9
+ * Follower → Leader: user input, abort, snapshot/scoop selection requests,
10
+ * sprinkle refresh + content fetch + lick, target advertisement, federated
11
+ * CDP (request + response + event), federated tab.open and its reply pair,
12
+ * federated FS (request + response), ping/pong.
13
+ *
14
+ * The iOS follower (`packages/ios-app/SliccFollower/Models/SyncProtocol.swift`)
15
+ * mirrors a **subset** of this file: federated `fs.*` in both directions is
16
+ * TS-only; iOS responds to leader-initiated `cdp.request` / `tab.open` (and
17
+ * sends back `cdp.response` / `cdp.event` / `tab.opened`) but does NOT
18
+ * originate either, so the follower-initiated CDP/tab.open paths are also
19
+ * TS-only. The per-variant iOS decision is MECHANICALLY enforced by the
20
+ * golden-fixture corpus
21
+ * (`packages/webapp/src/scoops/tray-sync-protocol-corpus.ts` →
22
+ * `packages/ios-app/.../Fixtures/tray-sync-corpus.json`, decoded by both the
23
+ * vitest and XCTest suites) — adding a variant here fails typecheck there
24
+ * until it gets a fixture + explicit iOS expectation. See
25
+ * `packages/ios-app/CLAUDE.md` "Protocol Mirror Invariant".
26
+ *
27
+ * This module holds the message unions and their payload-adjacent types
28
+ * (types + pure guards only — platform-agnostic by construction). The
29
+ * `TraySyncChannel` wrapper, chunking helpers, and typed factories live in
30
+ * `@slicc/webapp` `scoops/tray-sync-protocol.ts` (they depend on
31
+ * `TrayDataChannelLike` and the webapp logger), which re-exports everything
32
+ * here for webapp-internal importers.
33
+ */
34
+ import type { AgentEvent, ChatMessage, LickEvent, MessageAttachment } from './agent-wire-types.js';
35
+ /**
36
+ * Runtime tag a cherry follower connects with (`StartPageFollowerTrayOptions.runtime`).
37
+ * It is the advertisement-independent signal the leader uses to keep a cooperative
38
+ * cherry host page out of flows it cannot satisfy (teleport selection) — see
39
+ * `tray-leader-sync.ts:getBestFollowerForTeleport`. Kept here, next to the wire
40
+ * format, because both the follower boot (`ui/`) and the leader (`scoops/`) must
41
+ * agree on the exact string without one layer importing the other.
42
+ */
43
+ export declare const CHERRY_RUNTIME_TAG = "slicc-cherry";
44
+ /**
45
+ * Tray sync protocol version, exchanged via the additive `hello` message both
46
+ * sides send on channel open. A peer that never sends `hello` is a legacy
47
+ * build (pre-versioning); a peer with a HIGHER version than ours means this
48
+ * build is outdated — both cases log loudly instead of surfacing as silently
49
+ * missing features. Bump when the wire format changes incompatibly.
50
+ */
51
+ export declare const TRAY_SYNC_PROTOCOL_VERSION = 1;
52
+ /**
53
+ * Additive version handshake, sent by BOTH sides as their first message on
54
+ * channel open. Legacy peers drop it harmlessly (TS: unknown-message warn;
55
+ * iOS: `.unknown`), so it is backward and forward compatible.
56
+ */
57
+ export interface TraySyncHelloMessage {
58
+ type: 'hello';
59
+ protocolVersion: number;
60
+ /** Optional runtime tag of the sender (e.g. 'slicc-standalone'). */
61
+ runtime?: string;
62
+ }
63
+ export type LeaderToFollowerMessage = {
64
+ type: 'snapshot';
65
+ messages: ChatMessage[];
66
+ scoopJid: string;
67
+ } | {
68
+ type: 'snapshot_chunk';
69
+ chunkData: string;
70
+ chunkIndex: number;
71
+ totalChunks: number;
72
+ scoopJid: string;
73
+ } | {
74
+ type: 'agent_event';
75
+ event: AgentEvent;
76
+ scoopJid: string;
77
+ } | {
78
+ type: 'user_message_echo';
79
+ text: string;
80
+ messageId: string;
81
+ scoopJid: string;
82
+ attachments?: MessageAttachment[];
83
+ } | {
84
+ type: 'status';
85
+ scoopStatus: string;
86
+ } | {
87
+ type: 'error';
88
+ error: string;
89
+ } | {
90
+ type: 'scoops.list';
91
+ scoops: ScoopSummary[];
92
+ activeScoopJid: string;
93
+ } | {
94
+ type: 'sprinkles.list';
95
+ sprinkles: SprinkleSummary[];
96
+ } | {
97
+ type: 'sprinkle.content';
98
+ requestId: string;
99
+ sprinkleName: string;
100
+ content: string;
101
+ chunkIndex?: number;
102
+ totalChunks?: number;
103
+ error?: string;
104
+ } | {
105
+ type: 'sprinkle.update';
106
+ sprinkleName: string;
107
+ data: unknown;
108
+ } | {
109
+ type: 'sprinkle.reloaded';
110
+ sprinkleName: string;
111
+ } | {
112
+ type: 'targets.registry';
113
+ targets: TrayTargetEntry[];
114
+ } | {
115
+ type: 'cdp.request';
116
+ requestId: string;
117
+ localTargetId: string;
118
+ method: string;
119
+ params?: Record<string, unknown>;
120
+ sessionId?: string;
121
+ } | {
122
+ type: 'cdp.response';
123
+ requestId: string;
124
+ result?: Record<string, unknown>;
125
+ error?: string;
126
+ chunkData?: string;
127
+ chunkIndex?: number;
128
+ totalChunks?: number;
129
+ } | {
130
+ type: 'cdp.event';
131
+ method: string;
132
+ params: Record<string, unknown>;
133
+ sessionId?: string;
134
+ } | {
135
+ type: 'tab.open';
136
+ requestId: string;
137
+ url: string;
138
+ } | {
139
+ type: 'tab.opened';
140
+ requestId: string;
141
+ targetId: string;
142
+ } | {
143
+ type: 'tab.open.error';
144
+ requestId: string;
145
+ error: string;
146
+ } | {
147
+ type: 'preview.open';
148
+ requestId: string;
149
+ url: string;
150
+ } | {
151
+ type: 'fs.request';
152
+ requestId: string;
153
+ request: TrayFsRequest;
154
+ } | {
155
+ type: 'fs.response';
156
+ requestId: string;
157
+ response: TrayFsResponse;
158
+ } | CherrySliccEventMessage | {
159
+ type: 'theme.apply';
160
+ themeJson: string | null;
161
+ } | TraySyncHelloMessage | {
162
+ type: 'ping';
163
+ } | {
164
+ type: 'pong';
165
+ };
166
+ export type FollowerToLeaderMessage = {
167
+ type: 'user_message';
168
+ text: string;
169
+ messageId: string;
170
+ attachments?: MessageAttachment[];
171
+ } | {
172
+ type: 'abort';
173
+ } | {
174
+ type: 'request_snapshot';
175
+ scoopJid?: string;
176
+ } | {
177
+ type: 'scoops.select';
178
+ scoopJid: string;
179
+ } | {
180
+ type: 'sprinkles.refresh';
181
+ } | {
182
+ type: 'sprinkle.fetch';
183
+ requestId: string;
184
+ sprinkleName: string;
185
+ } | {
186
+ type: 'sprinkle.lick';
187
+ sprinkleName: string;
188
+ body: unknown;
189
+ targetScoop?: string;
190
+ } | {
191
+ type: 'lick';
192
+ event: Omit<LickEvent, 'originFollowerId' | 'originLabel'>;
193
+ } | {
194
+ type: 'targets.advertise';
195
+ targets: RemoteTargetInfo[];
196
+ runtimeId: string;
197
+ } | {
198
+ type: 'cdp.request';
199
+ requestId: string;
200
+ targetRuntimeId: string;
201
+ localTargetId: string;
202
+ method: string;
203
+ params?: Record<string, unknown>;
204
+ sessionId?: string;
205
+ } | {
206
+ type: 'cdp.response';
207
+ requestId: string;
208
+ result?: Record<string, unknown>;
209
+ error?: string;
210
+ chunkData?: string;
211
+ chunkIndex?: number;
212
+ totalChunks?: number;
213
+ } | {
214
+ type: 'cdp.event';
215
+ method: string;
216
+ params: Record<string, unknown>;
217
+ sessionId?: string;
218
+ } | {
219
+ type: 'tab.open';
220
+ requestId: string;
221
+ targetRuntimeId: string;
222
+ url: string;
223
+ } | {
224
+ type: 'tab.opened';
225
+ requestId: string;
226
+ targetId: string;
227
+ } | {
228
+ type: 'tab.open.error';
229
+ requestId: string;
230
+ error: string;
231
+ } | {
232
+ type: 'fs.request';
233
+ requestId: string;
234
+ targetRuntimeId: string;
235
+ request: TrayFsRequest;
236
+ } | {
237
+ type: 'fs.response';
238
+ requestId: string;
239
+ response: TrayFsResponse;
240
+ } | CherryHostEventMessage | TraySyncHelloMessage | {
241
+ type: 'ping';
242
+ } | {
243
+ type: 'pong';
244
+ };
245
+ export interface RemoteTargetInfo {
246
+ targetId: string;
247
+ title: string;
248
+ url: string;
249
+ /** Distinguishes a real browser page from a cooperative cherry host page. */
250
+ kind?: 'browser' | 'cherry' | 'preview';
251
+ /**
252
+ * Only present for kind === 'cherry'. What the host page lends to the leader,
253
+ * expressed in the vocabulary this tray/teleport layer cares about: `network`
254
+ * gates whether the target may serve `Network.*` CDP for teleport-pool
255
+ * selection. NOTE: intentionally a DIFFERENT shape from the SDK handshake
256
+ * `CherryHandshakeHello.capabilities` (`{ navigate; screenshot; openUrl }` in
257
+ * cdp/cherry-host-protocol.ts) — `openUrl` is a sandbox-escape concern at the
258
+ * host SDK boundary, whereas `network` is a teleport-routing concern here.
259
+ * They are mapped, not equal.
260
+ */
261
+ capabilities?: {
262
+ navigate: boolean;
263
+ network: boolean;
264
+ screenshot: boolean;
265
+ };
266
+ }
267
+ /** Host page → cone: a named event emitted by the cherry host page. */
268
+ export interface CherryHostEventMessage {
269
+ type: 'cherry.host_event';
270
+ targetId: string;
271
+ name: string;
272
+ detail?: unknown;
273
+ }
274
+ /** Cone → host page: a named event sent to the cherry host page. */
275
+ export interface CherrySliccEventMessage {
276
+ type: 'cherry.slicc_event';
277
+ targetId: string;
278
+ name: string;
279
+ detail?: unknown;
280
+ }
281
+ export declare function isCherryHostEventMessage(m: unknown): m is CherryHostEventMessage;
282
+ export declare function isCherrySliccEventMessage(m: unknown): m is CherrySliccEventMessage;
283
+ /** Lightweight scoop description sent to followers for their scoop picker / swipe view. */
284
+ export interface ScoopSummary {
285
+ jid: string;
286
+ name: string;
287
+ folder: string;
288
+ isCone: boolean;
289
+ assistantLabel: string;
290
+ trigger?: string;
291
+ }
292
+ /** Lightweight sprinkle description sent to followers for the sprinkle sidebar. */
293
+ export interface SprinkleSummary {
294
+ /** Sprinkle name (basename without .shtml). */
295
+ name: string;
296
+ /** Display title. */
297
+ title: string;
298
+ /** VFS path (used for chunked content fetch). */
299
+ path: string;
300
+ /** Whether this sprinkle is currently open in the leader's UI. */
301
+ open: boolean;
302
+ /** Whether this sprinkle should auto-open. */
303
+ autoOpen: boolean;
304
+ }
305
+ export interface TrayTargetEntry {
306
+ targetId: string;
307
+ localTargetId: string;
308
+ runtimeId: string;
309
+ title: string;
310
+ url: string;
311
+ isLocal: boolean;
312
+ /** Distinguishes a real browser page from a cooperative cherry host page. */
313
+ kind?: 'browser' | 'cherry' | 'preview';
314
+ /**
315
+ * Only present for kind === 'cherry'. What the host page lends to the leader,
316
+ * expressed in the vocabulary this tray/teleport layer cares about: `network`
317
+ * gates whether the target may serve `Network.*` CDP for teleport-pool
318
+ * selection. NOTE: intentionally a DIFFERENT shape from the SDK handshake
319
+ * `CherryHandshakeHello.capabilities` (`{ navigate; screenshot; openUrl }` in
320
+ * cdp/cherry-host-protocol.ts) — `openUrl` is a sandbox-escape concern at the
321
+ * host SDK boundary, whereas `network` is a teleport-routing concern here.
322
+ * They are mapped, not equal.
323
+ */
324
+ capabilities?: {
325
+ navigate: boolean;
326
+ network: boolean;
327
+ screenshot: boolean;
328
+ };
329
+ }
330
+ /** Chrome CDP Network.Cookie shape used for teleporting cookies between runtimes. */
331
+ export interface CookieTeleportCookie {
332
+ name: string;
333
+ value: string;
334
+ domain: string;
335
+ path: string;
336
+ expires: number;
337
+ size: number;
338
+ httpOnly: boolean;
339
+ secure: boolean;
340
+ session: boolean;
341
+ sameSite?: 'Strict' | 'Lax' | 'None';
342
+ priority?: 'Low' | 'Medium' | 'High';
343
+ sameParty?: boolean;
344
+ sourceScheme?: 'Unset' | 'NonSecure' | 'Secure';
345
+ sourcePort?: number;
346
+ partitionKey?: string;
347
+ }
348
+ /** A single FS operation request sent over the data channel. */
349
+ export type TrayFsRequest = {
350
+ op: 'readFile';
351
+ path: string;
352
+ encoding?: 'utf-8' | 'binary';
353
+ } | {
354
+ op: 'writeFile';
355
+ path: string;
356
+ content: string;
357
+ encoding: 'utf-8' | 'base64';
358
+ } | {
359
+ op: 'stat';
360
+ path: string;
361
+ } | {
362
+ op: 'readDir';
363
+ path: string;
364
+ } | {
365
+ op: 'mkdir';
366
+ path: string;
367
+ recursive?: boolean;
368
+ } | {
369
+ op: 'rm';
370
+ path: string;
371
+ recursive?: boolean;
372
+ } | {
373
+ op: 'exists';
374
+ path: string;
375
+ } | {
376
+ op: 'walk';
377
+ path: string;
378
+ };
379
+ /** A single FS operation response. Chunked responses use chunkIndex/totalChunks for large file content. */
380
+ export type TrayFsResponse = {
381
+ ok: true;
382
+ data: TrayFsResponseData;
383
+ chunkIndex?: number;
384
+ totalChunks?: number;
385
+ } | {
386
+ ok: false;
387
+ error: string;
388
+ code?: string;
389
+ };
390
+ /** Possible data payloads for successful FS responses. */
391
+ export type TrayFsResponseData = {
392
+ type: 'file';
393
+ content: string;
394
+ encoding: 'utf-8' | 'base64';
395
+ } | {
396
+ type: 'stat';
397
+ stat: {
398
+ type: 'file' | 'directory' | 'symlink';
399
+ size: number;
400
+ mtime: number;
401
+ ctime: number;
402
+ };
403
+ } | {
404
+ type: 'dirEntries';
405
+ entries: Array<{
406
+ name: string;
407
+ type: 'file' | 'directory' | 'symlink';
408
+ }>;
409
+ } | {
410
+ type: 'exists';
411
+ exists: boolean;
412
+ } | {
413
+ type: 'paths';
414
+ paths: string[];
415
+ } | {
416
+ type: 'void';
417
+ };
418
+ export type TraySyncMessage = LeaderToFollowerMessage | FollowerToLeaderMessage;
419
+ /**
420
+ * Compile-time exhaustiveness guard for protocol dispatchers.
421
+ *
422
+ * Call this from the `default:` branch of a `switch (message.type)` over a
423
+ * protocol union. Because the parameter is `never`, adding a new message
424
+ * variant to the union fails compile in every dispatcher until that
425
+ * dispatcher makes an explicit decision — a documented no-op `case` is
426
+ * allowed, silence is not.
427
+ *
428
+ * Unlike a classic `assertNever` this must NOT throw: at runtime a
429
+ * version-skewed peer (shipped iOS binary, older hosted UI, cherry embed)
430
+ * can legitimately deliver a message type this build doesn't know. It
431
+ * returns the loosely-typed message so the caller can log it loudly.
432
+ */
433
+ export declare function unhandledProtocolMessage(message: never): {
434
+ type?: string;
435
+ };
436
+ //# sourceMappingURL=tray-sync-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tray-sync-protocol.d.ts","sourceRoot":"","sources":["../src/tray-sync-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEnG;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,OAAO,CAAC;IACd,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→ Follower: chat snapshots (single + chunked), streamed agent events,
5
+ * user-message echoes, scoop list, sprinkle list / content / updates,
6
+ * federated CDP (request + response + event), federated tab.open and its
7
+ * reply pair, federated FS (request + response), liveness (ping/pong/status/error).
8
+ *
9
+ * Follower → Leader: user input, abort, snapshot/scoop selection requests,
10
+ * sprinkle refresh + content fetch + lick, target advertisement, federated
11
+ * CDP (request + response + event), federated tab.open and its reply pair,
12
+ * federated FS (request + response), ping/pong.
13
+ *
14
+ * The iOS follower (`packages/ios-app/SliccFollower/Models/SyncProtocol.swift`)
15
+ * mirrors a **subset** of this file: federated `fs.*` in both directions is
16
+ * TS-only; iOS responds to leader-initiated `cdp.request` / `tab.open` (and
17
+ * sends back `cdp.response` / `cdp.event` / `tab.opened`) but does NOT
18
+ * originate either, so the follower-initiated CDP/tab.open paths are also
19
+ * TS-only. The per-variant iOS decision is MECHANICALLY enforced by the
20
+ * golden-fixture corpus
21
+ * (`packages/webapp/src/scoops/tray-sync-protocol-corpus.ts` →
22
+ * `packages/ios-app/.../Fixtures/tray-sync-corpus.json`, decoded by both the
23
+ * vitest and XCTest suites) — adding a variant here fails typecheck there
24
+ * until it gets a fixture + explicit iOS expectation. See
25
+ * `packages/ios-app/CLAUDE.md` "Protocol Mirror Invariant".
26
+ *
27
+ * This module holds the message unions and their payload-adjacent types
28
+ * (types + pure guards only — platform-agnostic by construction). The
29
+ * `TraySyncChannel` wrapper, chunking helpers, and typed factories live in
30
+ * `@slicc/webapp` `scoops/tray-sync-protocol.ts` (they depend on
31
+ * `TrayDataChannelLike` and the webapp logger), which re-exports everything
32
+ * here for webapp-internal importers.
33
+ */
34
+ /**
35
+ * Runtime tag a cherry follower connects with (`StartPageFollowerTrayOptions.runtime`).
36
+ * It is the advertisement-independent signal the leader uses to keep a cooperative
37
+ * cherry host page out of flows it cannot satisfy (teleport selection) — see
38
+ * `tray-leader-sync.ts:getBestFollowerForTeleport`. Kept here, next to the wire
39
+ * format, because both the follower boot (`ui/`) and the leader (`scoops/`) must
40
+ * agree on the exact string without one layer importing the other.
41
+ */
42
+ export const CHERRY_RUNTIME_TAG = 'slicc-cherry';
43
+ /**
44
+ * Tray sync protocol version, exchanged via the additive `hello` message both
45
+ * sides send on channel open. A peer that never sends `hello` is a legacy
46
+ * build (pre-versioning); a peer with a HIGHER version than ours means this
47
+ * build is outdated — both cases log loudly instead of surfacing as silently
48
+ * missing features. Bump when the wire format changes incompatibly.
49
+ */
50
+ export const TRAY_SYNC_PROTOCOL_VERSION = 1;
51
+ export function isCherryHostEventMessage(m) {
52
+ return (typeof m === 'object' && m !== null && m.type === 'cherry.host_event');
53
+ }
54
+ export function isCherrySliccEventMessage(m) {
55
+ return (typeof m === 'object' && m !== null && m.type === 'cherry.slicc_event');
56
+ }
57
+ /**
58
+ * Compile-time exhaustiveness guard for protocol dispatchers.
59
+ *
60
+ * Call this from the `default:` branch of a `switch (message.type)` over a
61
+ * protocol union. Because the parameter is `never`, adding a new message
62
+ * variant to the union fails compile in every dispatcher until that
63
+ * dispatcher makes an explicit decision — a documented no-op `case` is
64
+ * allowed, silence is not.
65
+ *
66
+ * Unlike a classic `assertNever` this must NOT throw: at runtime a
67
+ * version-skewed peer (shipped iOS binary, older hosted UI, cherry embed)
68
+ * can legitimately deliver a message type this build doesn't know. It
69
+ * returns the loosely-typed message so the caller can log it loudly.
70
+ */
71
+ export function unhandledProtocolMessage(message) {
72
+ return message;
73
+ }
74
+ //# sourceMappingURL=tray-sync-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tray-sync-protocol.js","sourceRoot":"","sources":["../src/tray-sync-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAIH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAwK5C,MAAM,UAAU,wBAAwB,CAAC,CAAU;IACjD,OAAO,CACL,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAK,CAAuB,CAAC,IAAI,KAAK,mBAAmB,CAC7F,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,CAAU;IAClD,OAAO,CACL,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAK,CAAuB,CAAC,IAAI,KAAK,oBAAoB,CAC9F,CAAC;AACJ,CAAC;AAqHD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAc;IACrD,OAAO,OAA4B,CAAC;AACtC,CAAC"}