zidane-ui 9.3.1 → 9.4.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 (255) hide show
  1. package/dist/adapters/live.d.ts +2 -0
  2. package/dist/adapters/live.js +3 -0
  3. package/dist/adapters/server-git-host.js +5 -2
  4. package/dist/adapters/server-host.js +17 -11
  5. package/dist/adapters/server-machines-host.js +7 -0
  6. package/dist/adapters/server-session-host.js +49 -0
  7. package/dist/adapters/server-settings-sections.js +4 -1
  8. package/dist/adapters/sse-host.js +3 -0
  9. package/dist/adapters/sse-protocol.d.ts +10 -0
  10. package/dist/appearance/ZoomIndicator.js +5 -8
  11. package/dist/chat/HostTranscript.js +15 -1
  12. package/dist/chat/SessionStreamsProvider.d.ts +1 -1
  13. package/dist/chat/Transcript.d.ts +3 -2
  14. package/dist/chat/Transcript.js +26 -7
  15. package/dist/chat/composer/ComposerEditor.js +1 -1
  16. package/dist/chat/composer/ModelOptionsPicker.js +6 -2
  17. package/dist/chat/composer/ModelPicker.d.ts +1 -1
  18. package/dist/chat/composer/PlacePicker.d.ts +3 -1
  19. package/dist/chat/composer/PlacePicker.js +5 -1
  20. package/dist/chat/composer/use-draft-target.js +15 -3
  21. package/dist/chat/headless/block-runs.js +26 -1
  22. package/dist/chat/headless/chip-views.js +1 -1
  23. package/dist/chat/headless/draft-target.d.ts +28 -1
  24. package/dist/chat/headless/draft-target.js +22 -1
  25. package/dist/chat/headless/hosts.d.ts +4 -0
  26. package/dist/chat/headless/index.d.ts +25 -25
  27. package/dist/chat/headless/index.js +6 -6
  28. package/dist/chat/headless/markdown-scan.d.ts +0 -2
  29. package/dist/chat/headless/markdown-scan.js +3 -8
  30. package/dist/chat/headless/markdown-stream.js +3 -3
  31. package/dist/chat/headless/prompt-origin.d.ts +2 -0
  32. package/dist/chat/headless/prompt-origin.js +6 -2
  33. package/dist/chat/headless/sidebar/directory.d.ts +10 -1
  34. package/dist/chat/headless/sidebar/directory.js +9 -1
  35. package/dist/chat/headless/sidebar/environment.d.ts +15 -4
  36. package/dist/chat/headless/sidebar/environment.js +27 -9
  37. package/dist/chat/headless/sidebar/index.d.ts +2 -2
  38. package/dist/chat/headless/sidebar/index.js +2 -2
  39. package/dist/chat/headless/sidebar/labels.d.ts +9 -2
  40. package/dist/chat/headless/sidebar/labels.js +8 -1
  41. package/dist/chat/headless/streams/actions.d.ts +2 -2
  42. package/dist/chat/headless/streams/actions.js +1 -1
  43. package/dist/chat/headless/streams/event-bytes.d.ts +12 -1
  44. package/dist/chat/headless/streams/event-bytes.js +13 -1
  45. package/dist/chat/headless/streams/store.d.ts +21 -5
  46. package/dist/chat/headless/streams/store.js +36 -7
  47. package/dist/chat/headless/streams/transcript-map.js +2 -5
  48. package/dist/chat/headless/streams/types.d.ts +2 -1
  49. package/dist/chat/headless/transcript/collapse.js +3 -0
  50. package/dist/chat/index.d.ts +2 -2
  51. package/dist/chat/index.js +2 -2
  52. package/dist/chat/sidebar/ProjectIcon.js +1 -1
  53. package/dist/chat/sidebar/RowChips.js +2 -2
  54. package/dist/chat/sidebar/SessionSidebar.d.ts +6 -0
  55. package/dist/chat/sidebar/SessionSidebar.js +23 -16
  56. package/dist/chat/sidebar/SidebarFilterMenu.js +0 -1
  57. package/dist/chat/sidebar/SidebarFold.js +17 -16
  58. package/dist/chat/sidebar/SidebarSessionRow.d.ts +7 -1
  59. package/dist/chat/sidebar/SidebarSessionRow.js +11 -8
  60. package/dist/chat/sidebar/session-menu.d.ts +4 -0
  61. package/dist/chat/sidebar/session-menu.js +14 -2
  62. package/dist/chat/sidebar/sidebar-live.js +28 -4
  63. package/dist/chat/sidebar/useInboxRows.js +6 -6
  64. package/dist/chat/sidebar/useInboxTriage.js +50 -47
  65. package/dist/chat/sidebar/useSessionSearch.js +19 -18
  66. package/dist/chat/transcript/FileChip.js +28 -0
  67. package/dist/chat/transcript/LazyRow.d.ts +1 -1
  68. package/dist/chat/transcript/LazyRow.js +3 -4
  69. package/dist/chat/transcript/PromptEcho.js +3 -11
  70. package/dist/chat/transcript/SessionChip.d.ts +11 -0
  71. package/dist/chat/transcript/SessionChip.js +34 -0
  72. package/dist/chat/transcript/TranscriptRail.d.ts +1 -1
  73. package/dist/chat/transcript/chip-details.d.ts +11 -0
  74. package/dist/chat/transcript/chip-details.js +17 -1
  75. package/dist/chat/transcript/fold-worker.js +2 -1
  76. package/dist/chat/transcript/fold.js +11 -3
  77. package/dist/chat/transcript/index.d.ts +2 -2
  78. package/dist/chat/transcript/index.js +2 -2
  79. package/dist/chat/transcript/markdown-cache.d.ts +10 -1
  80. package/dist/chat/transcript/markdown-cache.js +37 -4
  81. package/dist/chat/transcript/markdown.js +27 -34
  82. package/dist/chat/transcript/media-gallery.js +13 -16
  83. package/dist/chat/transcript/messages.js +5 -4
  84. package/dist/chat/transcript/prompt.d.ts +1 -1
  85. package/dist/chat/transcript/row-mount.d.ts +27 -8
  86. package/dist/chat/transcript/row-mount.js +114 -80
  87. package/dist/chat/transcript/row-parking.d.ts +27 -0
  88. package/dist/chat/transcript/row-parking.js +37 -1
  89. package/dist/chat/transcript/script-input.d.ts +1 -1
  90. package/dist/chat/transcript/tool-parts.js +0 -1
  91. package/dist/chat/transcript/use-transcript-rows.d.ts +1 -1
  92. package/dist/chat/transcript/useHistoryBackfill.d.ts +42 -0
  93. package/dist/chat/transcript/useHistoryBackfill.js +170 -0
  94. package/dist/chat/transcript/useTranscriptFind.js +2 -4
  95. package/dist/chat/transcript/useTranscriptScroll.d.ts +7 -4
  96. package/dist/chat/transcript/useTranscriptScroll.js +12 -1
  97. package/dist/chat/transcript/useTranscriptSearch.d.ts +2 -2
  98. package/dist/chat/transcript/useTranscriptSearch.js +6 -6
  99. package/dist/chat/transcript/useTranscriptSelectionCopy.d.ts +5 -5
  100. package/dist/chat/transcript/useTranscriptSelectionCopy.js +28 -7
  101. package/dist/code/editor/FileTree.d.ts +2 -0
  102. package/dist/code/editor/FileTree.js +1 -1
  103. package/dist/code/editor/FileView.js +16 -25
  104. package/dist/code/editor/find/useFind.js +17 -17
  105. package/dist/code/editor/useCodeDocument.js +22 -19
  106. package/dist/code/editor/useDetachCleanup.js +4 -3
  107. package/dist/code/use-highlighted-html.js +12 -13
  108. package/dist/components/IconButton.d.ts +3 -1
  109. package/dist/components/IconButton.js +7 -2
  110. package/dist/components/IconButtonTip.d.ts +3 -1
  111. package/dist/components/IconButtonTip.js +2 -1
  112. package/dist/components/RowActionsMenu.js +7 -14
  113. package/dist/components/Tooltip.d.ts +4 -1
  114. package/dist/components/Tooltip.js +8 -6
  115. package/dist/components/assign-ref.d.ts +8 -0
  116. package/dist/components/assign-ref.js +12 -0
  117. package/dist/components/floating/FloatingSurface.js +2 -2
  118. package/dist/components/floating/HoverCard.js +32 -14
  119. package/dist/components/floating/Popover.js +4 -7
  120. package/dist/components/floating/useAnchoredPosition.d.ts +5 -3
  121. package/dist/components/floating/useAnchoredPosition.js +7 -7
  122. package/dist/components/object-key.d.ts +7 -0
  123. package/dist/components/object-key.js +18 -0
  124. package/dist/components/palette/PaletteList.js +2 -7
  125. package/dist/components/tooltip-arming.d.ts +3 -0
  126. package/dist/components/tooltip-arming.js +8 -1
  127. package/dist/core.css +3 -3
  128. package/dist/dist/{index-C6-t1SS9.d.ts → index-BheVJOLc.d.ts} +1 -0
  129. package/dist/dist/index.d.ts +2 -2
  130. package/dist/files/FilesTab.js +0 -1
  131. package/dist/files/TreeColumn.d.ts +2 -4
  132. package/dist/files/TreeColumn.js +0 -5
  133. package/dist/files/headless/host.d.ts +3 -7
  134. package/dist/files/headless/labels.d.ts +0 -1
  135. package/dist/files/headless/labels.js +0 -1
  136. package/dist/files/headless/workspace-diff.js +1 -1
  137. package/dist/files/useCodeReview.js +1 -3
  138. package/dist/files/useFilesDiagnostics.d.ts +1 -1
  139. package/dist/files/useFilesDiagnostics.js +4 -11
  140. package/dist/files/useOpenFiles.js +9 -12
  141. package/dist/files/useWorkspace.d.ts +5 -7
  142. package/dist/files/useWorkspace.js +4 -15
  143. package/dist/git/GitBar.js +5 -3
  144. package/dist/git/MoveSessionDialog.d.ts +18 -8
  145. package/dist/git/MoveSessionDialog.js +32 -53
  146. package/dist/git/MoveToDialog.d.ts +61 -0
  147. package/dist/git/MoveToDialog.js +240 -0
  148. package/dist/git/SandboxManager.js +9 -4
  149. package/dist/git/SyncChip.js +11 -4
  150. package/dist/git/TeleportSessionDialog.d.ts +69 -0
  151. package/dist/git/TeleportSessionDialog.js +440 -0
  152. package/dist/git/headless/host.d.ts +14 -0
  153. package/dist/git/headless/index.d.ts +2 -1
  154. package/dist/git/headless/index.js +2 -1
  155. package/dist/git/headless/labels.d.ts +44 -1
  156. package/dist/git/headless/labels.js +50 -0
  157. package/dist/git/headless/sandboxes.d.ts +1 -1
  158. package/dist/git/headless/sandboxes.js +4 -3
  159. package/dist/git/headless/teleport.d.ts +76 -0
  160. package/dist/git/headless/teleport.js +19 -0
  161. package/dist/git/index.d.ts +4 -2
  162. package/dist/git/index.js +4 -2
  163. package/dist/git/useEnvironmentChoices.d.ts +5 -2
  164. package/dist/git/useEnvironmentChoices.js +12 -4
  165. package/dist/hooks/useLatest.d.ts +8 -0
  166. package/dist/hooks/useLatest.js +17 -0
  167. package/dist/hooks/useMinuteTick.d.ts +6 -2
  168. package/dist/hooks/useMinuteTick.js +12 -6
  169. package/dist/hooks/useNearViewport.js +11 -8
  170. package/dist/index.d.ts +3 -2
  171. package/dist/index.js +2 -1
  172. package/dist/keybindings/KeybindingsProvider.js +3 -4
  173. package/dist/keybindings/headless/catalog.d.ts +1 -1
  174. package/dist/keybindings/headless/catalog.js +18 -0
  175. package/dist/machines/AddServerForm.js +55 -3
  176. package/dist/machines/Banners.d.ts +2 -2
  177. package/dist/machines/Banners.js +3 -3
  178. package/dist/machines/DaemonMenu.js +1 -3
  179. package/dist/machines/HostsSection.js +5 -1
  180. package/dist/machines/OrganizationPanel.d.ts +25 -0
  181. package/dist/machines/OrganizationPanel.js +266 -0
  182. package/dist/machines/PersonalLayerPanel.d.ts +32 -0
  183. package/dist/machines/PersonalLayerPanel.js +360 -0
  184. package/dist/machines/headless/fixture-host.d.ts +10 -0
  185. package/dist/machines/headless/fixture-host.js +44 -0
  186. package/dist/machines/headless/host.d.ts +21 -1
  187. package/dist/machines/headless/index.d.ts +3 -1
  188. package/dist/machines/headless/index.js +3 -1
  189. package/dist/machines/headless/labels.d.ts +55 -0
  190. package/dist/machines/headless/labels.js +58 -1
  191. package/dist/machines/headless/layer.d.ts +64 -0
  192. package/dist/machines/headless/layer.js +56 -0
  193. package/dist/machines/headless/organization.d.ts +38 -0
  194. package/dist/machines/headless/organization.js +44 -0
  195. package/dist/machines/index.d.ts +3 -1
  196. package/dist/machines/index.js +3 -1
  197. package/dist/machines/testing/contract.d.ts +25 -1
  198. package/dist/machines/testing/contract.js +97 -1
  199. package/dist/motion/grow.js +12 -13
  200. package/dist/motion/swap.js +2 -5
  201. package/dist/motion/use-flip-list.d.ts +14 -0
  202. package/dist/motion/use-flip-list.js +17 -12
  203. package/dist/palette/headless/app-sources.js +37 -0
  204. package/dist/palette/headless/labels.js +3 -0
  205. package/dist/server/sse-handler.js +25 -2
  206. package/dist/session/DiffFileTree.js +1 -4
  207. package/dist/session/OpenSessionsDialog.d.ts +46 -0
  208. package/dist/session/OpenSessionsDialog.js +170 -0
  209. package/dist/session/PlanTracker.js +1 -2
  210. package/dist/session/ProjectHome.js +10 -9
  211. package/dist/session/RemindersPanel.js +10 -12
  212. package/dist/session/SecretsPanel.js +2 -1
  213. package/dist/session/SessionPeopleStack.d.ts +23 -0
  214. package/dist/session/SessionPeopleStack.js +65 -0
  215. package/dist/session/SessionPlaceMenu.js +5 -4
  216. package/dist/session/ShareSessionDialog.d.ts +32 -0
  217. package/dist/session/ShareSessionDialog.js +342 -0
  218. package/dist/session/TypingLine.d.ts +22 -0
  219. package/dist/session/TypingLine.js +31 -0
  220. package/dist/session/headless/host.d.ts +40 -1
  221. package/dist/session/headless/index.d.ts +4 -2
  222. package/dist/session/headless/index.js +3 -1
  223. package/dist/session/headless/labels.d.ts +49 -0
  224. package/dist/session/headless/labels.js +56 -0
  225. package/dist/session/headless/people.d.ts +29 -0
  226. package/dist/session/headless/people.js +53 -0
  227. package/dist/session/headless/place.d.ts +5 -0
  228. package/dist/session/headless/place.js +5 -1
  229. package/dist/session/headless/typing.d.ts +37 -0
  230. package/dist/session/headless/typing.js +60 -0
  231. package/dist/session/index.d.ts +5 -1
  232. package/dist/session/index.js +5 -1
  233. package/dist/settings/headless/search.d.ts +1 -1
  234. package/dist/settings/headless/sections-host.d.ts +7 -2
  235. package/dist/settings/section.d.ts +15 -3
  236. package/dist/settings/section.js +15 -3
  237. package/dist/settings/sections/environments/EnvironmentsSection.js +30 -6
  238. package/dist/settings/sections/keybindings/labels.d.ts +3 -0
  239. package/dist/settings/sections/keybindings/labels.js +3 -0
  240. package/dist/settings/sections/keybindings/rows.js +12 -0
  241. package/dist/settings/sections/logs/LogsSection.js +5 -8
  242. package/dist/styles.css +32 -7
  243. package/dist/terminal/HostTerminalSurface.js +28 -30
  244. package/dist/terminal/TerminalPanel.js +4 -12
  245. package/dist/terminal/TerminalProvider.d.ts +10 -2
  246. package/dist/terminal/TerminalProvider.js +10 -2
  247. package/dist/terminal/headless/labels.d.ts +0 -1
  248. package/dist/terminal/headless/labels.js +1 -2
  249. package/dist/terminal/headless/store.js +5 -1
  250. package/dist/workspace/LayoutBudget.js +1 -7
  251. package/package.json +2 -2
  252. package/src/styles/chat.css +3 -1
  253. package/src/styles/palette.css +3 -3
  254. package/src/styles/transcript.css +17 -3
  255. /package/dist/dist/{index-De9AbmxS.d.ts → index-ttmMvjgM.d.ts} +0 -0
@@ -31,7 +31,9 @@ const DEFAULT_MACHINES_LABELS = {
31
31
  daemon: "The daemon could not do that.",
32
32
  sync: "Could not sync.",
33
33
  invite: "Could not create a join code.",
34
- install: "Could not install the tool."
34
+ install: "Could not install the tool.",
35
+ layer: "Changing what you keep on this server failed.",
36
+ people: "Changing the server's people failed."
35
37
  })[kind],
36
38
  /** "5m" → "5m ago"; a date stays as is. */
37
39
  machinesAgo: (short) => `${short} ago`,
@@ -50,6 +52,9 @@ const DEFAULT_MACHINES_LABELS = {
50
52
  machinesHostName: "Host name",
51
53
  machinesTest: "Test",
52
54
  machinesTesting: "Testing…",
55
+ machinesSignInGoogle: "Sign in with Google",
56
+ machinesSigningIn: "Waiting for the sign-in…",
57
+ machinesSignInCode: (code) => `Enter the code ${code} at`,
53
58
  machinesRename: "Rename",
54
59
  machinesRenaming: "Renaming…",
55
60
  machinesHostActions: (name) => `${name} actions`,
@@ -168,6 +173,7 @@ const DEFAULT_MACHINES_LABELS = {
168
173
  machinesPlaceAddServer: (name) => `Add ${name}`,
169
174
  machinesPlaceMachineGone: (machine, host) => `${machine} is no longer a machine of ${host}. This chat starts on ${host}.`,
170
175
  machinesPlaceFolderGone: (folder) => `${folder} is not there any more. This chat starts in the usual folder.`,
176
+ machinesPlaceUnavailable: (label, reason, fallback) => `${label} can't run in this folder${reason ? ` (${reason.replace(/\.$/, "")})` : ""}. This chat starts in ${fallback}.`,
171
177
  machinesNewChatLabel: (name) => `New chat on ${name}`,
172
178
  machinesFoldersMore: (count) => `${count} more`,
173
179
  machinesStatus: (status) => status,
@@ -266,6 +272,57 @@ const DEFAULT_MACHINES_LABELS = {
266
272
  machinesTokensCancel: "Cancel",
267
273
  /** The folded row under the live tokens. */
268
274
  machinesTokensInactive: (count) => `Revoked and expired (${count})`,
275
+ machinesPeopleTitle: "People",
276
+ machinesPeopleOff: "Everyone who connects here is the same user. Organization mode signs each person in with Google, Slack or a pairing code, keeps their own keys, and lets them share sessions.",
277
+ machinesPeopleTurnOn: "Turn it on where the server runs:",
278
+ machinesPeopleYou: (email, role) => `You are ${email}, ${role === "admin" ? "an admin" : "a user"} here.`,
279
+ machinesPeopleSharingOn: "People can share sessions here.",
280
+ machinesPeopleSharingOff: "Sharing sessions is off on this server. Each person has only their own sessions.",
281
+ machinesPeopleAdd: "Add person",
282
+ machinesPeopleEmail: "Email",
283
+ machinesPeopleAdmin: "Admin",
284
+ machinesPeopleDisabled: "disabled",
285
+ machinesPeopleYouChip: "you",
286
+ machinesPeopleRowActions: (email) => `Actions for ${email}`,
287
+ machinesPeopleMakeAdmin: "Make admin",
288
+ machinesPeopleMakeUser: "Make user",
289
+ machinesPeopleDisable: "Disable",
290
+ machinesPeopleEnable: "Enable",
291
+ machinesPeopleRemoveTitle: (email) => `Remove ${email}?`,
292
+ machinesPeopleRemoveMessage: "Their sessions come to you, and their tokens stop working at once.",
293
+ machinesPeopleDisableTitle: (email) => `Disable ${email}?`,
294
+ machinesPeopleDisableMessage: "Their tokens stop working at once. Enable them again to let them sign in.",
295
+ machinesPeopleRemoved: (sessions) => sessions === 0 ? "Removed." : `Removed. ${sessions} session${sessions === 1 ? "" : "s"} came to you.`,
296
+ machinesLayerTitle: "Yours on this server",
297
+ machinesLayerHint: "Sessions you own here use these on top of the server's. The server never shows a key again.",
298
+ machinesLayerKeys: "API keys",
299
+ machinesLayerKeysEmpty: "No key of yours. Your sessions use the server's keys.",
300
+ machinesLayerAddKey: "Add key",
301
+ machinesLayerProvider: "Provider",
302
+ machinesLayerProviderPlaceholder: "anthropic",
303
+ machinesLayerKey: "Key",
304
+ machinesLayerMcp: "MCP servers",
305
+ machinesLayerMcpEmpty: "No MCP server of yours.",
306
+ machinesLayerAddMcp: "Add server",
307
+ machinesLayerMcpName: "Name",
308
+ machinesLayerMcpUrl: "URL",
309
+ machinesLayerMcpUrlPlaceholder: "https://example.com/mcp",
310
+ machinesLayerSkills: "Skills",
311
+ machinesLayerSkillsEmpty: "No skill of yours.",
312
+ machinesLayerAddSkill: "Add skill",
313
+ machinesLayerSkillName: "Name",
314
+ machinesLayerSkillNamePlaceholder: "release-notes",
315
+ machinesLayerSkillContents: "SKILL.md",
316
+ machinesLayerEdit: "Edit",
317
+ machinesLayerSignIn: "Sign in as you",
318
+ machinesLayerSignOut: "Sign out",
319
+ machinesLayerSystemMd: "SYSTEM.md",
320
+ machinesLayerSystemMdHint: "Replaces the server's. A project's SYSTEM.md still wins.",
321
+ machinesLayerSystemMdUnset: "Not set. The server's SYSTEM.md applies.",
322
+ machinesLayerSaving: "Saving…",
323
+ machinesLayerRowActions: (name) => `Actions for ${name}`,
324
+ machinesLayerRemoveTitle: (name) => `Remove ${name}?`,
325
+ machinesLayerRemoveMessage: "Sessions you own on this server stop using it. The server's own stay.",
269
326
  machinesDaemonMenu: (health) => `Daemon menu, ${health}`,
270
327
  machinesDaemon: "Daemon",
271
328
  machinesDaemonOff: "Daemon mode is off",
@@ -0,0 +1,64 @@
1
+ /**
2
+ * What a user keeps for themselves on a server in organization mode
3
+ * (docs/IDENTITY.md, Per-user layers): API keys, MCP servers, a SYSTEM.md and
4
+ * skills. Sessions they own there use them on top of the server's.
5
+ *
6
+ * {@link serverLayerOver} builds the host member over one transport call, so
7
+ * the zidane-server adapter and the desktop app share it.
8
+ */
9
+ /** One user's layer on one server, as `me.*` reads it: never a key or a secret. */
10
+ export interface PersonalLayer {
11
+ /** The providers the user holds a key for. */
12
+ apiKeys: readonly string[];
13
+ /** Their MCP servers, by name, with the URL of the ones reached over HTTP. */
14
+ mcpServers: readonly {
15
+ name: string;
16
+ url?: string;
17
+ }[];
18
+ /** Their SYSTEM.md; `null`: the server's applies. */
19
+ systemMd: string | null;
20
+ /** Their skills, by name. */
21
+ skills: readonly string[];
22
+ }
23
+ /** The host member for a user's layer (`MachinesHost.layer`). */
24
+ export interface ServerLayer {
25
+ /** The signed-in user's layer on `hostId`; `null` when that server does not sign its users in. */
26
+ read: (hostId: string) => Promise<PersonalLayer | null>;
27
+ /** Keeps the user's API key for a provider. */
28
+ setApiKey: (hostId: string, provider: string, key: string) => Promise<void>;
29
+ /** Removes the user's API key for a provider. */
30
+ removeApiKey: (hostId: string, provider: string) => Promise<void>;
31
+ /** Adds (or replaces) an MCP server reached over streamable HTTP. */
32
+ addMcpServer: (hostId: string, server: {
33
+ name: string;
34
+ url: string;
35
+ }) => Promise<void>;
36
+ /** Removes one of the user's MCP servers. */
37
+ removeMcpServer: (hostId: string, name: string) => Promise<void>;
38
+ /** Forgets the user's own sign-in to an MCP server (they sign in through the host's \`signIn\`); the server's, if any, applies again. */
39
+ signOutMcp: (hostId: string, name: string) => Promise<void>;
40
+ /** `null` removes it. */
41
+ setSystemMd: (hostId: string, contents: string | null) => Promise<void>;
42
+ /** A skill's SKILL.md; `null` when there is none by that name. */
43
+ readSkill: (hostId: string, name: string) => Promise<string | null>;
44
+ /** Adds (or replaces) a skill: its name and its SKILL.md. */
45
+ setSkill: (hostId: string, name: string, contents: string) => Promise<void>;
46
+ /** Removes one of the user's skills. */
47
+ removeSkill: (hostId: string, name: string) => Promise<void>;
48
+ }
49
+ /**
50
+ * One `me.*` call to `hostId`. `signedIn: false` when the server does not
51
+ * sign its users in (no `identity` in its handshake).
52
+ */
53
+ export type LayerCall = (hostId: string, method: string, params: Record<string, unknown>) => Promise<{
54
+ signedIn: false;
55
+ } | {
56
+ signedIn: true;
57
+ result: unknown;
58
+ }>;
59
+ /**
60
+ * The {@link ServerLayer} over one transport call.
61
+ *
62
+ * @param call - One `me.*` call to a server.
63
+ */
64
+ export declare function serverLayerOver(call: LayerCall): ServerLayer;
@@ -0,0 +1,56 @@
1
+ // src/machines/headless/layer.ts
2
+ /**
3
+ * The {@link ServerLayer} over one transport call.
4
+ *
5
+ * @param call - One `me.*` call to a server.
6
+ */
7
+ function serverLayerOver(call) {
8
+ const run = async (hostId, method, params = {}) => {
9
+ const answer = await call(hostId, method, params);
10
+ if (!answer.signedIn) throw new Error("Sign in to this server to keep your own keys, MCP servers and skills.");
11
+ return answer.result;
12
+ };
13
+ const done = async (hostId, method, params) => {
14
+ await run(hostId, method, params);
15
+ };
16
+ return {
17
+ read: async (hostId) => {
18
+ const first = await call(hostId, "me.apiKeys", {});
19
+ if (!first.signedIn) return null;
20
+ const [mcp, systemMd, skills] = await Promise.all([
21
+ run(hostId, "me.mcpServers"),
22
+ run(hostId, "me.systemMd"),
23
+ run(hostId, "me.skills")
24
+ ]);
25
+ return {
26
+ apiKeys: first.result.map((k) => k.provider),
27
+ mcpServers: mcp.map((s) => ({
28
+ name: s.name,
29
+ ...typeof s.url === "string" ? { url: s.url } : {}
30
+ })),
31
+ systemMd: systemMd.contents,
32
+ skills: skills.map((s) => s.name)
33
+ };
34
+ },
35
+ setApiKey: (hostId, provider, key) => done(hostId, "me.setApiKey", {
36
+ provider,
37
+ key
38
+ }),
39
+ removeApiKey: (hostId, provider) => done(hostId, "me.removeApiKey", { provider }),
40
+ addMcpServer: (hostId, server) => done(hostId, "me.upsertMcpServer", { config: {
41
+ name: server.name,
42
+ transport: "streamable-http",
43
+ url: server.url
44
+ } }),
45
+ removeMcpServer: (hostId, name) => done(hostId, "me.removeMcpServer", { name }),
46
+ signOutMcp: (hostId, name) => done(hostId, "me.mcpSignOut", { name }),
47
+ setSystemMd: (hostId, contents) => done(hostId, "me.setSystemMd", { contents }),
48
+ readSkill: async (hostId, name) => (await run(hostId, "me.skill", { name })).contents,
49
+ setSkill: (hostId, name, contents) => done(hostId, "me.setSkill", {
50
+ name,
51
+ contents
52
+ }),
53
+ removeSkill: (hostId, name) => done(hostId, "me.removeSkill", { name })
54
+ };
55
+ }
56
+ export { serverLayerOver };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * A server's organization mode, as its page shows it (docs/IDENTITY.md): whether it signs its users in, who you are
3
+ * there, whether it shares sessions, and its people for an admin (`org.*`). React-free.
4
+ */
5
+ import { HelloResult, OrgUserView, OrganizationStatus } from "zidane/ipc";
6
+ /**
7
+ * The status a handshake says (`null` or absent: not connected, off). The same rule as `organizationStatusOf` in
8
+ * `zidane/ipc`, kept here because a headless module imports only types from the core.
9
+ *
10
+ * @param hello - The server's `hello` answer.
11
+ */
12
+ export declare function organizationStatusOf(hello: Pick<HelloResult, 'identity' | 'methods'> | null | undefined): OrganizationStatus;
13
+ /** What a server's page reads and changes about its organization. */
14
+ export interface ServerOrganization {
15
+ /** Organization mode on the server, and who you are there. */
16
+ status: (hostId: string) => Promise<OrganizationStatus>;
17
+ /** Admin: every person of the organization. */
18
+ users: (hostId: string) => Promise<readonly OrgUserView[]>;
19
+ /** Admin: add a person by email, as an admin or a user. */
20
+ addUser: (hostId: string, input: {
21
+ email: string;
22
+ role: 'admin' | 'user';
23
+ }) => Promise<void>;
24
+ /** Admin: make a person an admin or a user. */
25
+ setRole: (hostId: string, userId: string, role: 'admin' | 'user') => Promise<void>;
26
+ /** Admin: disable a person, or enable them again. */
27
+ setDisabled: (hostId: string, userId: string, disabled: boolean) => Promise<void>;
28
+ /** Resolves how many sessions came to you. */
29
+ removeUser: (hostId: string, userId: string) => Promise<number>;
30
+ }
31
+ /**
32
+ * A {@link ServerOrganization} over a call to the server's `org.*` methods and a read of its status.
33
+ *
34
+ * @param status - The server's status (its handshake).
35
+ * @param call - One `org.*` call on the server.
36
+ */
37
+ export declare function serverOrganizationOver(status: (hostId: string) => Promise<OrganizationStatus>, call: (hostId: string, method: string, params: Record<string, unknown>) => Promise<unknown>): ServerOrganization;
38
+ export type { OrgUserView, OrganizationStatus };
@@ -0,0 +1,44 @@
1
+ // src/machines/headless/organization.ts
2
+ /**
3
+ * The status a handshake says (`null` or absent: not connected, off). The same rule as `organizationStatusOf` in
4
+ * `zidane/ipc`, kept here because a headless module imports only types from the core.
5
+ *
6
+ * @param hello - The server's `hello` answer.
7
+ */
8
+ function organizationStatusOf(hello) {
9
+ return hello?.identity ? {
10
+ mode: "on",
11
+ email: hello.identity.email,
12
+ role: hello.identity.role,
13
+ sharing: hello.methods?.includes("members.get") === true
14
+ } : { mode: "off" };
15
+ }
16
+ /**
17
+ * A {@link ServerOrganization} over a call to the server's `org.*` methods and a read of its status.
18
+ *
19
+ * @param status - The server's status (its handshake).
20
+ * @param call - One `org.*` call on the server.
21
+ */
22
+ function serverOrganizationOver(status, call) {
23
+ return {
24
+ status,
25
+ users: async (hostId) => await call(hostId, "org.users", {}),
26
+ addUser: async (hostId, input) => {
27
+ await call(hostId, "org.addUser", input);
28
+ },
29
+ setRole: async (hostId, userId, role) => {
30
+ await call(hostId, "org.setRole", {
31
+ userId,
32
+ role
33
+ });
34
+ },
35
+ setDisabled: async (hostId, userId, disabled) => {
36
+ await call(hostId, "org.setDisabled", {
37
+ userId,
38
+ disabled
39
+ });
40
+ },
41
+ removeUser: async (hostId, userId) => (await call(hostId, "org.removeUser", { userId })).sessions
42
+ };
43
+ }
44
+ export { organizationStatusOf, serverOrganizationOver };
@@ -9,6 +9,8 @@ import { HostsSection, HostsSectionProps, ServerDetail, ServerDetailProps } from
9
9
  import { HostSyncPanel, HostSyncPanelProps, useHostSync } from "./HostSyncPanel.js";
10
10
  import { MachinesExplainer, MachinesExplainerProps } from "./MachinesExplainer.js";
11
11
  import { MachinesConfirm, MachinesProvider, MachinesProviderProps, useLentServers, useMachinesBridge, useMachinesConfirm, useMachinesHost, useMachinesLabels, useOnlineMachines, usePermitted, usePresenceMap, useServerMachines, useSessionPresence } from "./MachinesProvider.js";
12
+ import { OrganizationPanel, OrganizationPanelProps } from "./OrganizationPanel.js";
13
+ import { PersonalLayerPanel, PersonalLayerPanelProps } from "./PersonalLayerPanel.js";
12
14
  import { useServerAppUpdate, useServerUpdate } from "./server-update.js";
13
15
  import { NewChatsServer, ServerAddedCard, ServerAddedCardProps } from "./ServerAddedCard.js";
14
16
  import { CopyText, CopyTextProps, HOST_NAME_MAX, HOST_TOKEN_MAX, HOST_URL_MAX, ServerCard, ServerCardProps, escapeCancels } from "./ServerCard.js";
@@ -20,4 +22,4 @@ import { SyncAccounts, SyncAccountsProps } from "./SyncAccounts.js";
20
22
  import { SyncMarker, SyncMarkerProps, useServerSyncStatus } from "./SyncMarker.js";
21
23
  import { SyncOutcomeBadge, SyncOutcomeBadgeProps } from "./SyncOutcomeBadge.js";
22
24
  import { TokensPanel, TokensPanelProps } from "./TokensPanel.js";
23
- export { AddMachineDialog, AddMachineDialogProps, AddMachineTab, AddServerForm, AddServerFormProps, CapabilitiesView, CapabilitiesViewProps, CapabilityTags, CapabilityTagsProps, ComposerNotice, ComposerNoticeProps, CopyText, CopyTextProps, DaemonMenu, DaemonMenuProps, DraftPlaceNotice, DraftPlaceNoticeProps, HOST_CARD_ICON_CLASS, HOST_NAME_MAX, HOST_TOKEN_MAX, HOST_URL_MAX, HostCapabilitiesState, HostIcon, type HostIconProps, HostRemovedBanner, HostRemovedBannerProps, HostSignIn, HostSignInProps, HostSyncPanel, HostSyncPanelProps, HostsSection, HostsSectionProps, MachineWaitingBanner, MachineWaitingBannerProps, MachinesConfirm, MachinesExplainer, MachinesExplainerProps, MachinesProvider, MachinesProviderProps, NewChatsServer, OpenAddMachine, ServerAddedCard, ServerAddedCardProps, ServerCard, ServerCardProps, ServerDetail, ServerDetailProps, ServerMachinesPanel, ServerMachinesPanelProps, ServerOfflineBanner, ServerOfflineBannerProps, ServerUpdatePanel, ServerUpdatePanelProps, ShareThisComputerForm, ShareThisComputerFormProps, SyncAccounts, SyncAccountsProps, SyncMarker, SyncMarkerProps, SyncOutcomeBadge, SyncOutcomeBadgeProps, TokensPanel, TokensPanelProps, escapeCancels, hostsSettingsSection, useAddMachine, useHostCapabilities, useHostSync, useLentServers, useMachinesBridge, useMachinesConfirm, useMachinesHost, useMachinesLabels, useOnlineMachines, usePermitted, usePresenceMap, useServerAppUpdate, useServerMachines, useServerSyncStatus, useServerUpdate, useSessionPresence };
25
+ export { AddMachineDialog, AddMachineDialogProps, AddMachineTab, AddServerForm, AddServerFormProps, CapabilitiesView, CapabilitiesViewProps, CapabilityTags, CapabilityTagsProps, ComposerNotice, ComposerNoticeProps, CopyText, CopyTextProps, DaemonMenu, DaemonMenuProps, DraftPlaceNotice, DraftPlaceNoticeProps, HOST_CARD_ICON_CLASS, HOST_NAME_MAX, HOST_TOKEN_MAX, HOST_URL_MAX, HostCapabilitiesState, HostIcon, type HostIconProps, HostRemovedBanner, HostRemovedBannerProps, HostSignIn, HostSignInProps, HostSyncPanel, HostSyncPanelProps, HostsSection, HostsSectionProps, MachineWaitingBanner, MachineWaitingBannerProps, MachinesConfirm, MachinesExplainer, MachinesExplainerProps, MachinesProvider, MachinesProviderProps, NewChatsServer, OpenAddMachine, OrganizationPanel, OrganizationPanelProps, PersonalLayerPanel, PersonalLayerPanelProps, ServerAddedCard, ServerAddedCardProps, ServerCard, ServerCardProps, ServerDetail, ServerDetailProps, ServerMachinesPanel, ServerMachinesPanelProps, ServerOfflineBanner, ServerOfflineBannerProps, ServerUpdatePanel, ServerUpdatePanelProps, ShareThisComputerForm, ShareThisComputerFormProps, SyncAccounts, SyncAccountsProps, SyncMarker, SyncMarkerProps, SyncOutcomeBadge, SyncOutcomeBadgeProps, TokensPanel, TokensPanelProps, escapeCancels, hostsSettingsSection, useAddMachine, useHostCapabilities, useHostSync, useLentServers, useMachinesBridge, useMachinesConfirm, useMachinesHost, useMachinesLabels, useOnlineMachines, usePermitted, usePresenceMap, useServerAppUpdate, useServerMachines, useServerSyncStatus, useServerUpdate, useSessionPresence };
@@ -9,6 +9,8 @@ import { HostsSection, ServerDetail } from "./HostsSection.js";
9
9
  import { HostSyncPanel, useHostSync } from "./HostSyncPanel.js";
10
10
  import { MachinesExplainer } from "./MachinesExplainer.js";
11
11
  import { MachinesProvider, useLentServers, useMachinesBridge, useMachinesConfirm, useMachinesHost, useMachinesLabels, useOnlineMachines, usePermitted, usePresenceMap, useServerMachines, useSessionPresence } from "./MachinesProvider.js";
12
+ import { OrganizationPanel } from "./OrganizationPanel.js";
13
+ import { PersonalLayerPanel } from "./PersonalLayerPanel.js";
12
14
  import { useServerAppUpdate, useServerUpdate } from "./server-update.js";
13
15
  import { ServerAddedCard } from "./ServerAddedCard.js";
14
16
  import { CopyText, HOST_NAME_MAX, HOST_TOKEN_MAX, HOST_URL_MAX, ServerCard, escapeCancels } from "./ServerCard.js";
@@ -20,4 +22,4 @@ import { SyncAccounts } from "./SyncAccounts.js";
20
22
  import { SyncMarker, useServerSyncStatus } from "./SyncMarker.js";
21
23
  import { SyncOutcomeBadge } from "./SyncOutcomeBadge.js";
22
24
  import { TokensPanel } from "./TokensPanel.js";
23
- export { AddMachineDialog, AddServerForm, CapabilitiesView, CapabilityTags, ComposerNotice, CopyText, DaemonMenu, DraftPlaceNotice, HOST_CARD_ICON_CLASS, HOST_NAME_MAX, HOST_TOKEN_MAX, HOST_URL_MAX, HostIcon, HostRemovedBanner, HostSignIn, HostSyncPanel, HostsSection, MachineWaitingBanner, MachinesExplainer, MachinesProvider, ServerAddedCard, ServerCard, ServerDetail, ServerMachinesPanel, ServerOfflineBanner, ServerUpdatePanel, ShareThisComputerForm, SyncAccounts, SyncMarker, SyncOutcomeBadge, TokensPanel, escapeCancels, hostsSettingsSection, useAddMachine, useHostCapabilities, useHostSync, useLentServers, useMachinesBridge, useMachinesConfirm, useMachinesHost, useMachinesLabels, useOnlineMachines, usePermitted, usePresenceMap, useServerAppUpdate, useServerMachines, useServerSyncStatus, useServerUpdate, useSessionPresence };
25
+ export { AddMachineDialog, AddServerForm, CapabilitiesView, CapabilityTags, ComposerNotice, CopyText, DaemonMenu, DraftPlaceNotice, HOST_CARD_ICON_CLASS, HOST_NAME_MAX, HOST_TOKEN_MAX, HOST_URL_MAX, HostIcon, HostRemovedBanner, HostSignIn, HostSyncPanel, HostsSection, MachineWaitingBanner, MachinesExplainer, MachinesProvider, OrganizationPanel, PersonalLayerPanel, ServerAddedCard, ServerCard, ServerDetail, ServerMachinesPanel, ServerOfflineBanner, ServerUpdatePanel, ShareThisComputerForm, SyncAccounts, SyncMarker, SyncOutcomeBadge, TokensPanel, escapeCancels, hostsSettingsSection, useAddMachine, useHostCapabilities, useHostSync, useLentServers, useMachinesBridge, useMachinesConfirm, useMachinesHost, useMachinesLabels, useOnlineMachines, usePermitted, usePresenceMap, useServerAppUpdate, useServerMachines, useServerSyncStatus, useServerUpdate, useSessionPresence };
@@ -20,7 +20,7 @@ import { SessionPresence } from "../headless/presence.js";
20
20
  import { MachinesSyncCapability, MachinesSyncContractBackend, MachinesSyncHarness, MachinesSyncHarnessFactory, describeMachinesSyncContract } from "./sync.contract.js";
21
21
  import { HostCapabilities } from "zidane/chat/pure";
22
22
  /** An optional `MachinesHost` member, by its path. */
23
- export type MachinesHostCapability = 'hosts' | 'refreshHosts' | 'retry' | 'testHost' | 'addHost' | 'renameHost' | 'setHostUrl' | 'removeHost' | 'savedHosts' | 'machines' | 'machines.forget' | 'machines.invite' | 'machines.onJoin' | 'links' | 'links.shareStart' | 'links.shareStop' | 'links.useServer' | 'pickFolder' | 'newChat' | 'updates' | 'updates.check' | 'updates.install' | 'updates.configure' | 'tokens' | 'tokens.create' | 'tokens.revoke' | 'tokens.pair' | 'tokens.onChanged' | 'daemon' | 'daemon.reconnect' | 'daemon.restart' | 'daemon.stopRun' | 'daemon.relaunchApp' | 'presence' | 'capabilities' | 'installTool' | 'permitted';
23
+ export type MachinesHostCapability = 'hosts' | 'refreshHosts' | 'retry' | 'testHost' | 'addHost' | 'renameHost' | 'setHostUrl' | 'removeHost' | 'savedHosts' | 'machines' | 'machines.forget' | 'machines.invite' | 'machines.onJoin' | 'links' | 'links.shareStart' | 'links.shareStop' | 'links.useServer' | 'pickFolder' | 'newChat' | 'updates' | 'updates.check' | 'updates.install' | 'updates.configure' | 'tokens' | 'tokens.create' | 'tokens.revoke' | 'tokens.pair' | 'tokens.onChanged' | 'layer' | 'daemon' | 'daemon.reconnect' | 'daemon.restart' | 'daemon.stopRun' | 'daemon.relaunchApp' | 'presence' | 'capabilities' | 'installTool' | 'permitted';
24
24
  /** What the backend behind the host holds, and what it records. */
25
25
  export interface MachinesHostContractBackend {
26
26
  /**
@@ -41,6 +41,8 @@ export interface MachinesHostContractBackend {
41
41
  update: ServerUpdateStatus$1;
42
42
  /** The server's tokens. Read at each listing; {@link created} and {@link revoked} change it. */
43
43
  tokens: ServerToken[];
44
+ /** The signed-in user's layer on the server (organization mode); {@link answerMe} reads and changes it. */
45
+ layer: ContractLayer;
44
46
  /** This computer's links. Read at each status; the link recorders change it. */
45
47
  links: MachineLinksStatus$1;
46
48
  /** The local daemon's status. */
@@ -126,6 +128,28 @@ export interface MachinesHostHarness {
126
128
  }
127
129
  /** Builds a fresh host (and its backend) for one test. */
128
130
  export type MachinesHostHarnessFactory = (backend: MachinesHostContractBackend) => MachinesHostHarness | Promise<MachinesHostHarness>;
131
+ /** The user's layer as a contract backend holds it. */
132
+ export interface ContractLayer {
133
+ /** The providers the user holds a key for. */
134
+ apiKeys: string[];
135
+ /** Their MCP servers, with the URL of the ones reached over HTTP. */
136
+ mcpServers: {
137
+ name: string;
138
+ url?: string;
139
+ }[];
140
+ /** Their SYSTEM.md; `null`: none. */
141
+ systemMd: string | null;
142
+ /** Their skills: each name's SKILL.md. */
143
+ skills: Record<string, string>;
144
+ }
145
+ /**
146
+ * Answers one \`me.*\` call against {@link ContractLayer}, as zidane-server does: for a harness's backend.
147
+ *
148
+ * @param layer - The layer it reads and changes.
149
+ * @param method - The \`me.*\` method.
150
+ * @param params - Its params.
151
+ */
152
+ export declare function answerMe(layer: ContractLayer, method: string, params: Record<string, unknown>): unknown;
129
153
  /**
130
154
  * Declares the shared `MachinesHost` suite for one implementation.
131
155
  *
@@ -30,6 +30,7 @@ const CAPABILITIES = [
30
30
  "tokens.revoke",
31
31
  "tokens.pair",
32
32
  "tokens.onChanged",
33
+ "layer",
33
34
  "daemon",
34
35
  "daemon.reconnect",
35
36
  "daemon.restart",
@@ -47,10 +48,60 @@ const OBJECTS = /* @__PURE__ */ new Set([
47
48
  "links",
48
49
  "updates",
49
50
  "tokens",
51
+ "layer",
50
52
  "daemon",
51
53
  "presence",
52
54
  "permitted"
53
55
  ]);
56
+ /**
57
+ * Answers one \`me.*\` call against {@link ContractLayer}, as zidane-server does: for a harness's backend.
58
+ *
59
+ * @param layer - The layer it reads and changes.
60
+ * @param method - The \`me.*\` method.
61
+ * @param params - Its params.
62
+ */
63
+ function answerMe(layer, method, params) {
64
+ switch (method) {
65
+ case "me.apiKeys": return layer.apiKeys.map((provider) => ({ provider }));
66
+ case "me.setApiKey":
67
+ layer.apiKeys = [.../* @__PURE__ */ new Set([...layer.apiKeys, params.provider])];
68
+ return;
69
+ case "me.removeApiKey":
70
+ layer.apiKeys = layer.apiKeys.filter((p) => p !== params.provider);
71
+ return;
72
+ case "me.mcpServers": return layer.mcpServers.map((s) => ({ ...s }));
73
+ case "me.upsertMcpServer": {
74
+ const config = params.config;
75
+ layer.mcpServers = [...layer.mcpServers.filter((s) => s.name !== config.name), {
76
+ name: config.name,
77
+ ...config.url ? { url: config.url } : {}
78
+ }];
79
+ return;
80
+ }
81
+ case "me.removeMcpServer":
82
+ layer.mcpServers = layer.mcpServers.filter((s) => s.name !== params.name);
83
+ return;
84
+ case "me.mcpSignOut": return;
85
+ case "me.systemMd": return { contents: layer.systemMd };
86
+ case "me.setSystemMd":
87
+ layer.systemMd = params.contents;
88
+ return;
89
+ case "me.skills": return Object.keys(layer.skills).sort().map((name) => ({ name }));
90
+ case "me.skill": return { contents: layer.skills[params.name] ?? null };
91
+ case "me.setSkill":
92
+ layer.skills = {
93
+ ...layer.skills,
94
+ [params.name]: params.contents
95
+ };
96
+ return;
97
+ case "me.removeSkill": {
98
+ const { [params.name]: _gone, ...rest } = layer.skills;
99
+ layer.skills = rest;
100
+ return;
101
+ }
102
+ default: throw new Error(`unknown method ${method}`);
103
+ }
104
+ }
54
105
  function machine(id, name, status) {
55
106
  return {
56
107
  id,
@@ -89,6 +140,15 @@ function contractBackend() {
89
140
  scope: "client",
90
141
  createdAt: 17e11
91
142
  }],
143
+ layer: {
144
+ apiKeys: ["anthropic"],
145
+ mcpServers: [{
146
+ name: "notes",
147
+ url: "https://notes.example/mcp"
148
+ }],
149
+ systemMd: null,
150
+ skills: { "release-notes": "---\nname: release-notes\n---\nBe brief." }
151
+ },
92
152
  links: {
93
153
  shares: [],
94
154
  uses: []
@@ -592,6 +652,42 @@ function describeMachinesHostContract(name, makeHarness, capabilities) {
592
652
  await waitFor(() => expect(heard).toHaveBeenCalled());
593
653
  expect(backend.tokens.map((t) => t.name)).toContain("from the CLI");
594
654
  });
655
+ it.skipIf(!has("layer"))("keeps what the signed-in user has on the server: keys, MCP servers, skills, SYSTEM.md", async () => {
656
+ const { host, id } = await setup();
657
+ const layer = host.layer;
658
+ expect(await layer.read(id)).toEqual({
659
+ apiKeys: ["anthropic"],
660
+ mcpServers: [{
661
+ name: "notes",
662
+ url: "https://notes.example/mcp"
663
+ }],
664
+ systemMd: null,
665
+ skills: ["release-notes"]
666
+ });
667
+ await layer.setApiKey(id, "openai", "sk-x");
668
+ await layer.removeApiKey(id, "anthropic");
669
+ await layer.addMcpServer(id, {
670
+ name: "docs",
671
+ url: "https://docs.example/mcp"
672
+ });
673
+ await layer.removeMcpServer(id, "notes");
674
+ await layer.signOutMcp(id, "docs");
675
+ await layer.setSystemMd(id, "Answer in French.");
676
+ expect(await layer.readSkill(id, "release-notes")).toContain("Be brief.");
677
+ await layer.setSkill(id, "triage", "Sort issues.");
678
+ await layer.removeSkill(id, "release-notes");
679
+ expect(await layer.read(id)).toEqual({
680
+ apiKeys: ["openai"],
681
+ mcpServers: [{
682
+ name: "docs",
683
+ url: "https://docs.example/mcp"
684
+ }],
685
+ systemMd: "Answer in French.",
686
+ skills: ["triage"]
687
+ });
688
+ await layer.setSystemMd(id, null);
689
+ expect((await layer.read(id))?.systemMd).toBeNull();
690
+ });
595
691
  it.skipIf(!has("capabilities"))("reads what the server can do, and probes again when asked", async () => {
596
692
  const { host, backend, id } = await setup();
597
693
  const caps = await host.capabilities(id);
@@ -667,4 +763,4 @@ function describeMachinesHostContract(name, makeHarness, capabilities) {
667
763
  });
668
764
  });
669
765
  }
670
- export { describeMachinesHostContract, describeMachinesSyncContract };
766
+ export { answerMe, describeMachinesHostContract, describeMachinesSyncContract };
@@ -1,5 +1,5 @@
1
1
  import { readExitMs, readMotionMs } from "./presence.js";
2
- import { useLayoutEffect, useRef, useState } from "react";
2
+ import { useCallback, useLayoutEffect, useRef, useState } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { AnimatePresence as GrowPresence, usePresence } from "motion/react";
5
5
  // src/motion/grow.tsx
@@ -18,25 +18,24 @@ import { AnimatePresence as GrowPresence, usePresence } from "motion/react";
18
18
  */
19
19
  function Grow({ as: Tag = "div", axis = "y", appear, symmetric = false, className = "", style, children, ...rest }) {
20
20
  const [isPresent, safeToRemove] = usePresence();
21
- const ref = useRef(null);
22
- const [entered, setEntered] = useState(!appear);
21
+ const removeRef = useRef(safeToRemove);
23
22
  useLayoutEffect(() => {
24
- if (entered) return;
25
- ref.current?.getBoundingClientRect();
23
+ removeRef.current = safeToRemove;
24
+ });
25
+ const [entered, setEntered] = useState(!appear);
26
+ const enter = useCallback((el) => {
27
+ if (!el) return;
28
+ el.getBoundingClientRect();
26
29
  setEntered(true);
27
- }, [entered]);
30
+ }, []);
28
31
  useLayoutEffect(() => {
29
32
  if (isPresent) return void 0;
30
33
  const ms = symmetric ? Math.max(readMotionMs("settle"), readExitMs()) : readExitMs();
31
- const id = setTimeout(() => safeToRemove?.(), ms);
34
+ const id = setTimeout(() => removeRef.current?.(), ms);
32
35
  return () => clearTimeout(id);
33
- }, [
34
- isPresent,
35
- safeToRemove,
36
- symmetric
37
- ]);
36
+ }, [isPresent, symmetric]);
38
37
  return /* @__PURE__ */ jsx(Tag, {
39
- ref,
38
+ ref: entered ? void 0 : enter,
40
39
  className: `zg-grow ${className}`,
41
40
  "data-shown": entered && isPresent ? "" : void 0,
42
41
  "data-axis": axis === "x" ? "x" : void 0,
@@ -56,11 +56,8 @@ function Crossfade({ activeKey, children, className = "", style, variant = "scal
56
56
  if (timer.current) clearTimeout(timer.current);
57
57
  timer.current = null;
58
58
  const exitMs = readExitMs();
59
- if (exitMs <= 0) {
60
- setPrevious(null);
61
- return;
62
- }
63
- setPrevious(last);
59
+ setPrevious(exitMs > 0 ? last : null);
60
+ if (exitMs <= 0) return;
64
61
  timer.current = setTimeout(() => {
65
62
  timer.current = null;
66
63
  setPrevious(null);
@@ -1,11 +1,23 @@
1
1
  import { FlipList, FlipListOptions, FlipMode } from "./flip-list.js";
2
2
  import { Component, ReactNode } from "react";
3
+ /** How a commit's changes play: {@link UseFlipListOptions}' `animate` and `mode`. */
4
+ export interface FlipPlan {
5
+ /** Animate this commit's changes. False records only (a group folding, a search). */
6
+ animate: boolean;
7
+ /** How this commit's changes play (`fold`: a group folding around rows that stay). */
8
+ mode: FlipMode;
9
+ }
3
10
  /** Options of {@link useFlipList}. */
4
11
  export interface UseFlipListOptions extends FlipListOptions {
5
12
  /** Animate this commit's changes. False records only (a group folding, a search). Default true. */
6
13
  animate?: boolean;
7
14
  /** How this commit's changes play (`fold`: a group folding around rows that stay). Default `list`. */
8
15
  mode?: FlipMode;
16
+ /**
17
+ * Decides `animate` and `mode` as the commit moves the rows, for a list that compares with its commit before
18
+ * (a ref no render reads). Wins over both. Give {@link FlipSnapshot} the same.
19
+ */
20
+ plan?: () => FlipPlan;
9
21
  }
10
22
  /** What {@link useFlipList} returns. */
11
23
  export interface UseFlipList {
@@ -37,6 +49,8 @@ export interface FlipSnapshotProps {
37
49
  animate?: boolean;
38
50
  /** The `mode` given to `useFlipList`: before a `swap`, an image of the list is taken for its fade-through. */
39
51
  mode?: FlipMode;
52
+ /** The `plan` given to `useFlipList`. Wins over `animate` and `mode`. */
53
+ plan?: () => FlipPlan;
40
54
  /** The list's rows. */
41
55
  children?: ReactNode;
42
56
  }