@buffcore/admin-shell 0.8.41 → 0.8.43

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 (156) hide show
  1. package/dist/admin.js +2 -1
  2. package/dist/components/Button.d.ts +2 -2
  3. package/dist/components/Button.js +7 -2
  4. package/dist/components/DeviceFrame.d.ts +6 -1
  5. package/dist/components/DeviceFrame.js +2 -2
  6. package/dist/components/look.d.ts +5 -0
  7. package/dist/components/look.js +5 -0
  8. package/dist/console-settings.js +4 -1
  9. package/dist/design-fonts.d.ts +5 -0
  10. package/dist/design-fonts.js +20 -0
  11. package/dist/prototype/PageLook.js +3 -2
  12. package/dist/prototype/create.d.ts +3 -1
  13. package/dist/prototype/create.js +0 -1
  14. package/dist/prototype/page.d.ts +19 -2
  15. package/dist/prototype/page.js +20 -2
  16. package/dist/prototype/shown.js +1 -1
  17. package/dist/prototype/viewer.d.ts +2 -0
  18. package/dist/prototype/viewer.js +6 -2
  19. package/dist/screens/assistant/use-ask.d.ts +4 -3
  20. package/dist/workbench/app/ServedAgents.js +4 -1
  21. package/dist/workbench/app/ServedComp.d.ts +3 -0
  22. package/dist/workbench/app/ServedComp.js +33 -0
  23. package/dist/workbench/app/ServedPrototype.js +28 -1
  24. package/dist/workbench/app/StudioApp.js +29 -20
  25. package/dist/workbench/app/actions.d.ts +10 -1
  26. package/dist/workbench/app/actions.js +9 -2
  27. package/dist/workbench/app/ask-card.d.ts +10 -0
  28. package/dist/workbench/app/ask-card.js +34 -0
  29. package/dist/workbench/app/chat-session.d.ts +34 -0
  30. package/dist/workbench/app/chat.d.ts +39 -0
  31. package/dist/workbench/app/frame.js +4 -2
  32. package/dist/workbench/app/fresh.d.ts +63 -0
  33. package/dist/workbench/app/fresh.js +66 -0
  34. package/dist/workbench/app/host-part-loader.d.ts +5 -2
  35. package/dist/workbench/app/host-part-module.d.ts +17 -0
  36. package/dist/workbench/app/host-part-module.js +55 -0
  37. package/dist/workbench/app/host-parts.d.ts +2 -11
  38. package/dist/workbench/app/host-parts.js +53 -67
  39. package/dist/workbench/app/level-choice.d.ts +3 -0
  40. package/dist/workbench/app/mount.d.ts +4 -1
  41. package/dist/workbench/app/mount.js +2 -2
  42. package/dist/workbench/app/panel-cards.d.ts +3 -3
  43. package/dist/workbench/app/panel-cards.js +3 -2
  44. package/dist/workbench/app/places.d.ts +18 -3
  45. package/dist/workbench/app/places.js +14 -2
  46. package/dist/workbench/app/prototype-comp.d.ts +46 -0
  47. package/dist/workbench/app/prototype-comp.js +77 -0
  48. package/dist/workbench/app/prototype.d.ts +1 -1
  49. package/dist/workbench/app/prototype.js +3 -1
  50. package/dist/workbench/app/scene-address.d.ts +10 -0
  51. package/dist/workbench/app/scene-address.js +14 -0
  52. package/dist/workbench/app/studio-post.js +1 -0
  53. package/dist/workbench/app/test/loop-fixture.d.ts +35 -8
  54. package/dist/workbench/app/usePrototypeUi.js +14 -0
  55. package/dist/workbench/app/useStudio.d.ts +43 -1
  56. package/dist/workbench/app/useStudio.js +8 -1
  57. package/dist/workbench/host-theme.d.ts +3 -0
  58. package/dist/workbench/host-theme.js +14 -0
  59. package/dist/workbench/index.d.ts +1 -0
  60. package/dist/workbench/index.js +1 -0
  61. package/dist/workbench/studio/frame/HostRailEntries.d.ts +3 -0
  62. package/dist/workbench/studio/frame/HostRailEntries.js +15 -0
  63. package/dist/workbench/studio/frame/HostSide.d.ts +6 -0
  64. package/dist/workbench/studio/frame/HostSide.js +31 -0
  65. package/dist/workbench/studio/frame/LevelChip.js +2 -1
  66. package/dist/workbench/studio/frame/LevelChoices.js +24 -8
  67. package/dist/workbench/studio/frame/LimitCard.d.ts +5 -0
  68. package/dist/workbench/studio/frame/LimitCard.js +26 -0
  69. package/dist/workbench/studio/frame/NeverAskSetting.d.ts +7 -0
  70. package/dist/workbench/studio/frame/NeverAskSetting.js +24 -0
  71. package/dist/workbench/studio/frame/PanelList.js +5 -2
  72. package/dist/workbench/studio/frame/PanelMessage.js +3 -0
  73. package/dist/workbench/studio/frame/PanelNotice.js +2 -1
  74. package/dist/workbench/studio/frame/PanelScenes.d.ts +5 -0
  75. package/dist/workbench/studio/frame/PanelScenes.js +38 -0
  76. package/dist/workbench/studio/frame/PermissionAskCard.d.ts +18 -0
  77. package/dist/workbench/studio/frame/PermissionAskCard.js +60 -0
  78. package/dist/workbench/studio/frame/PermissionAskFold.d.ts +12 -0
  79. package/dist/workbench/studio/frame/PermissionAskFold.js +54 -0
  80. package/dist/workbench/studio/frame/Place.d.ts +6 -2
  81. package/dist/workbench/studio/frame/Place.js +13 -5
  82. package/dist/workbench/studio/frame/SettingsSheet.js +6 -1
  83. package/dist/workbench/studio/frame/StudioRail.js +2 -1
  84. package/dist/workbench/studio/frame/panelControls.d.ts +17 -0
  85. package/dist/workbench/studio/frame/panelLines.d.ts +1 -0
  86. package/dist/workbench/studio/frame/panelLines.js +2 -1
  87. package/dist/workbench/studio/i18n/comp.en.d.ts +26 -0
  88. package/dist/workbench/studio/i18n/comp.en.js +26 -0
  89. package/dist/workbench/studio/i18n/comp.es.d.ts +26 -0
  90. package/dist/workbench/studio/i18n/comp.es.js +25 -0
  91. package/dist/workbench/studio/i18n/frame.en.d.ts +39 -0
  92. package/dist/workbench/studio/i18n/frame.en.js +39 -0
  93. package/dist/workbench/studio/i18n/frame.es.json +40 -1
  94. package/dist/workbench/studio/i18n/fresh.en.d.ts +19 -0
  95. package/dist/workbench/studio/i18n/fresh.en.js +20 -0
  96. package/dist/workbench/studio/i18n/fresh.es.json +18 -0
  97. package/dist/workbench/studio/i18n/index.js +6 -0
  98. package/dist/workbench/studio/i18n/levels.en.d.ts +5 -0
  99. package/dist/workbench/studio/i18n/levels.en.js +5 -0
  100. package/dist/workbench/studio/i18n/levels.es.json +6 -1
  101. package/dist/workbench/studio/i18n/loop.en.d.ts +4 -0
  102. package/dist/workbench/studio/i18n/loop.en.js +4 -0
  103. package/dist/workbench/studio/i18n/loop.es.json +4 -0
  104. package/dist/workbench/studio/i18n/save.en.d.ts +1 -3
  105. package/dist/workbench/studio/i18n/save.en.js +13 -15
  106. package/dist/workbench/studio/i18n/save.es.json +14 -16
  107. package/dist/workbench/studio/i18n/structure.en.d.ts +6 -0
  108. package/dist/workbench/studio/i18n/structure.en.js +6 -0
  109. package/dist/workbench/studio/i18n/structure.es.d.ts +6 -0
  110. package/dist/workbench/studio/i18n/structure.es.js +6 -0
  111. package/dist/workbench/studio/loop/AgentsPage.d.ts +4 -1
  112. package/dist/workbench/studio/loop/AgentsPage.js +5 -4
  113. package/dist/workbench/studio/loop/CritiqueNote.d.ts +4 -0
  114. package/dist/workbench/studio/loop/CritiqueNote.js +9 -0
  115. package/dist/workbench/studio/loop/FreshLookPanel.d.ts +21 -0
  116. package/dist/workbench/studio/loop/FreshLookPanel.js +60 -0
  117. package/dist/workbench/studio/loop/PrototypeComp.d.ts +25 -0
  118. package/dist/workbench/studio/loop/PrototypeComp.js +78 -0
  119. package/dist/workbench/studio/loop/PrototypePage.d.ts +7 -0
  120. package/dist/workbench/studio/loop/PrototypePage.js +4 -3
  121. package/dist/workbench/studio/loop/PrototypeScenes.js +1 -2
  122. package/dist/workbench/studio/loop/PrototypeSimplePage.js +15 -7
  123. package/dist/workbench/studio/loop/PrototypeSnapshot.d.ts +3 -0
  124. package/dist/workbench/studio/loop/PrototypeSnapshot.js +7 -2
  125. package/dist/workbench/studio/loop/ReviewSetting.d.ts +6 -0
  126. package/dist/workbench/studio/loop/ReviewSetting.js +14 -0
  127. package/dist/workbench/studio/loop/ReviewedSave.d.ts +1 -1
  128. package/dist/workbench/studio/loop/ReviewedSave.js +2 -10
  129. package/dist/workbench/studio/loop/SaveStep.d.ts +3 -0
  130. package/dist/workbench/studio/loop/SaveStep.js +3 -1
  131. package/dist/workbench/studio/loop/ServedBrand.js +3 -3
  132. package/dist/workbench/studio/loop/ServedPlanning.js +1 -1
  133. package/dist/workbench/studio/loop/StructurePage.d.ts +7 -0
  134. package/dist/workbench/studio/loop/StructurePage.js +3 -2
  135. package/dist/workbench/studio/loop/StructurePreview.js +4 -4
  136. package/dist/workbench/studio/loop/StructurePrompts.js +9 -4
  137. package/dist/workbench/studio/loop/SurfaceChoice.d.ts +7 -0
  138. package/dist/workbench/studio/loop/SurfaceChoice.js +20 -0
  139. package/dist/workbench/studio/loop/step-state.d.ts +1 -1
  140. package/dist/workbench/studio/loop/step-state.js +9 -8
  141. package/dist/workbench/studio/loop/structure-answers.d.ts +8 -0
  142. package/dist/workbench/studio/loop/structure-answers.js +34 -0
  143. package/dist/workbench/studio/loop/usePlanningDraft.js +7 -2
  144. package/dist/workbench/studio/loop/usePlanningSave.d.ts +16 -2
  145. package/dist/workbench/studio/loop/usePlanningSave.js +40 -2
  146. package/dist/workbench/studio/loop/usePrototypeRecord.js +5 -4
  147. package/dist/workbench/studio/loop/useReviewedSave.d.ts +9 -4
  148. package/dist/workbench/studio/loop/useReviewedSave.js +89 -30
  149. package/dist/workbench/studio/run/LiveServers.js +1 -1
  150. package/dist/workbench/studio/run/ReleasePage.js +1 -1
  151. package/dist/workbench/studio/run/ReleasesPage.js +2 -2
  152. package/dist/workbench/studio/run/ServedRelease.js +1 -1
  153. package/dist/workbench/studio/work/work-test-data.d.ts +9 -4
  154. package/package.json +6 -6
  155. package/vite.d.ts +6 -1
  156. package/vite.js +78 -5
@@ -1,5 +1,5 @@
1
1
  import { approvalSchema } from '@buffcore/contracts/approvals';
2
- import { allowFolderAnswer, chatSchema, foundAgentSchema, stopAnswer, workbenchApi, } from '@buffcore/contracts/workbench';
2
+ import { allowFolderAnswer, chatSchema, foundAgentSchema, permissionAnswerReply, stopAnswer, workbenchApi, } from '@buffcore/contracts/workbench';
3
3
  import { z } from 'zod';
4
4
  import { readBytes } from '../studio/loop/icon-check.js';
5
5
  import { snapshotRead } from './prototype-snapshot.js';
@@ -64,8 +64,15 @@ export function studioActions(post, prototypeScenes, prototypeHome, previewMerge
64
64
  },
65
65
  run: (id, server) => post('/api/run', { id, ...(server ? { server } : {}) }),
66
66
  stack: (action) => post('/api/stack', { action }),
67
- level: (level) => post('/api/level', { level }),
67
+ level: (level, neverAsk) => post('/api/level', neverAsk === undefined ? { level } : { level, neverAsk }),
68
+ answerPermission: async (chat, id, answer) => {
69
+ const reply = await post(`/api/chats/${chat}/permission`, { id, answer }, undefined, false);
70
+ if (permissionAnswerReply.safeParse(reply).success)
71
+ return true;
72
+ return studioRefusal(reply) ?? '';
73
+ },
68
74
  approvePrototype: (change, version) => post('/api/approve', { kind: 'prototype', change, version }),
75
+ chooseSurface: (surface) => post('/api/structure/surface', { surface }),
69
76
  approvePlaces: (change, revision) => post('/api/approve', { kind: 'places', change }, undefined, undefined, revision),
70
77
  approve: (direction, fingerprint) => post('/api/approve', { kind: 'brand', direction, fingerprint }),
71
78
  approveRelease: async (id, server) => {
@@ -0,0 +1,10 @@
1
+ import type { Chat, StudioState } from '@buffcore/contracts/workbench';
2
+ import type { TurnControls } from '../studio/frame/panelControls.ts';
3
+ import type { StudioActions } from './actions.ts';
4
+ /** A person who may answer the agent's permission card: the settings right (the server checks it). */
5
+ export declare function canAnswerAsk(state: StudioState | undefined, actions: StudioActions): boolean;
6
+ /**
7
+ * The paused turn's card for the chat, and the person's answer folded while the same turn goes
8
+ * on; another card or the turn's end clears the fold. Absent without the right to answer.
9
+ */
10
+ export declare function useAskCard(chat: Chat, state: StudioState | undefined, actions: StudioActions): TurnControls['ask'];
@@ -0,0 +1,34 @@
1
+ import { useState } from 'react';
2
+ /** A person who may answer the agent's permission card: the settings right (the server checks it). */
3
+ export function canAnswerAsk(state, actions) {
4
+ const rights = state?.viewer?.rights;
5
+ return (!rights || rights === 'all' || rights.includes('settings')) && !!actions.answerPermission;
6
+ }
7
+ /**
8
+ * The paused turn's card for the chat, and the person's answer folded while the same turn goes
9
+ * on; another card or the turn's end clears the fold. Absent without the right to answer.
10
+ */
11
+ export function useAskCard(chat, state, actions) {
12
+ const [answered, setAnswered] = useState();
13
+ const answer = actions.answerPermission;
14
+ if (!answer || !canAnswerAsk(state, actions) || chat.state !== 'running')
15
+ return undefined;
16
+ const asking = chat.asking;
17
+ const fold = answered?.chat === chat.id && (!asking || asking.id === answered.asking.id)
18
+ ? answered
19
+ : undefined;
20
+ if (!asking && !fold)
21
+ return undefined;
22
+ return {
23
+ ...(asking ? { asking } : {}),
24
+ ...(fold ? { answered: fold } : {}),
25
+ onAnswer: async (choice) => {
26
+ if (!asking)
27
+ return '';
28
+ const result = await answer(chat.id, asking.id, choice);
29
+ if (result === true)
30
+ setAnswered({ chat: chat.id, asking, answer: choice, after: chat.messages.length });
31
+ return result;
32
+ },
33
+ };
34
+ }
@@ -32,6 +32,18 @@ export declare function useEcho(chat: Chat, post: (text: string, waitForRefresh?
32
32
  at: string;
33
33
  turn: string;
34
34
  } | undefined;
35
+ asking?: {
36
+ id: string;
37
+ tool: string;
38
+ command: string;
39
+ parts: string[];
40
+ once?: boolean | undefined;
41
+ unsure?: {
42
+ why: "budget" | "expression" | "heredoc" | "mention" | "pattern" | "stdin";
43
+ mention?: string | undefined;
44
+ } | undefined;
45
+ at: string;
46
+ } | undefined;
35
47
  messages: {
36
48
  from: "agent" | "system" | "you";
37
49
  text: string;
@@ -67,6 +79,7 @@ export declare function useEcho(chat: Chat, post: (text: string, waitForRefresh?
67
79
  targets: string[];
68
80
  refused?: boolean | undefined;
69
81
  reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
82
+ limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
70
83
  } | undefined;
71
84
  permission?: {
72
85
  path: string;
@@ -82,6 +95,10 @@ export declare function useEcho(chat: Chat, post: (text: string, waitForRefresh?
82
95
  unsaved?: {
83
96
  count?: number | undefined;
84
97
  } | undefined;
98
+ scenes?: {
99
+ key: string;
100
+ title: string;
101
+ }[] | undefined;
85
102
  } | undefined;
86
103
  }[];
87
104
  };
@@ -111,6 +128,18 @@ export declare function useChatRead(props: StudioAppProps, id: string | null | u
111
128
  at: string;
112
129
  turn: string;
113
130
  } | undefined;
131
+ asking?: {
132
+ id: string;
133
+ tool: string;
134
+ command: string;
135
+ parts: string[];
136
+ once?: boolean | undefined;
137
+ unsure?: {
138
+ why: "budget" | "expression" | "heredoc" | "mention" | "pattern" | "stdin";
139
+ mention?: string | undefined;
140
+ } | undefined;
141
+ at: string;
142
+ } | undefined;
114
143
  messages: {
115
144
  from: "agent" | "system" | "you";
116
145
  text: string;
@@ -146,6 +175,7 @@ export declare function useChatRead(props: StudioAppProps, id: string | null | u
146
175
  targets: string[];
147
176
  refused?: boolean | undefined;
148
177
  reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
178
+ limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
149
179
  } | undefined;
150
180
  permission?: {
151
181
  path: string;
@@ -161,6 +191,10 @@ export declare function useChatRead(props: StudioAppProps, id: string | null | u
161
191
  unsaved?: {
162
192
  count?: number | undefined;
163
193
  } | undefined;
194
+ scenes?: {
195
+ key: string;
196
+ title: string;
197
+ }[] | undefined;
164
198
  } | undefined;
165
199
  }[];
166
200
  } | undefined;
@@ -76,6 +76,18 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
76
76
  at: string;
77
77
  turn: string;
78
78
  } | undefined;
79
+ asking?: {
80
+ id: string;
81
+ tool: string;
82
+ command: string;
83
+ parts: string[];
84
+ once?: boolean | undefined;
85
+ unsure?: {
86
+ why: "budget" | "expression" | "heredoc" | "mention" | "pattern" | "stdin";
87
+ mention?: string | undefined;
88
+ } | undefined;
89
+ at: string;
90
+ } | undefined;
79
91
  messages: {
80
92
  from: "agent" | "system" | "you";
81
93
  text: string;
@@ -111,6 +123,7 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
111
123
  targets: string[];
112
124
  refused?: boolean | undefined;
113
125
  reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
126
+ limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
114
127
  } | undefined;
115
128
  permission?: {
116
129
  path: string;
@@ -126,6 +139,10 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
126
139
  unsaved?: {
127
140
  count?: number | undefined;
128
141
  } | undefined;
142
+ scenes?: {
143
+ key: string;
144
+ title: string;
145
+ }[] | undefined;
129
146
  } | undefined;
130
147
  }[];
131
148
  };
@@ -161,6 +178,18 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
161
178
  at: string;
162
179
  turn: string;
163
180
  } | undefined;
181
+ asking?: {
182
+ id: string;
183
+ tool: string;
184
+ command: string;
185
+ parts: string[];
186
+ once?: boolean | undefined;
187
+ unsure?: {
188
+ why: "budget" | "expression" | "heredoc" | "mention" | "pattern" | "stdin";
189
+ mention?: string | undefined;
190
+ } | undefined;
191
+ at: string;
192
+ } | undefined;
164
193
  messages: {
165
194
  from: "agent" | "system" | "you";
166
195
  text: string;
@@ -196,6 +225,7 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
196
225
  targets: string[];
197
226
  refused?: boolean | undefined;
198
227
  reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
228
+ limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
199
229
  } | undefined;
200
230
  permission?: {
201
231
  path: string;
@@ -211,6 +241,10 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
211
241
  unsaved?: {
212
242
  count?: number | undefined;
213
243
  } | undefined;
244
+ scenes?: {
245
+ key: string;
246
+ title: string;
247
+ }[] | undefined;
214
248
  } | undefined;
215
249
  }[];
216
250
  } | undefined>;
@@ -240,6 +274,11 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
240
274
  ios: boolean;
241
275
  android: boolean;
242
276
  }) => void;
277
+ ask?: {
278
+ asking?: import("../studio/frame/panelControls.ts").Asking;
279
+ answered?: import("../studio/frame/panelControls.ts").AnsweredAsk;
280
+ onAnswer: (answer: import("../studio/frame/panelControls.ts").AskAnswer) => Promise<true | string>;
281
+ };
243
282
  save?: {
244
283
  onSave: () => Promise<void>;
245
284
  saving: boolean;
@@ -4,6 +4,7 @@ import { footLine } from './agents.js';
4
4
  import { BUILT_PLACES } from './built-places.js';
5
5
  import { panelFor } from './chat.js';
6
6
  import { railStage } from './loop-stage.js';
7
+ import { addressPath } from './scene-address.js';
7
8
  export { BUILT_PLACES } from './built-places.js';
8
9
  export function useStudioTitle(name) {
9
10
  const t = useT();
@@ -15,7 +16,8 @@ export function useStudioTitle(name) {
15
16
  function addressedPage() {
16
17
  if (typeof window === 'undefined')
17
18
  return null;
18
- return BUILT_PLACES.find((page) => window.location.hash === `#/${page}`) ?? null;
19
+ const path = addressPath(window.location.hash);
20
+ return BUILT_PLACES.find((page) => path === `#/${page}`) ?? null;
19
21
  }
20
22
  /** The address wins; a first visit opens the loop's current step once facts arrive. */
21
23
  export function useStudioPage(state) {
@@ -37,7 +39,7 @@ export function useStudioPage(state) {
37
39
  return () => window.removeEventListener('hashchange', read);
38
40
  }, []);
39
41
  const onGo = (next) => {
40
- if (window.location.hash !== `#/${next}`)
42
+ if (addressPath(window.location.hash) !== `#/${next}`)
41
43
  window.history.pushState(null, '', `#/${next}`);
42
44
  setChosen(next);
43
45
  };
@@ -0,0 +1,63 @@
1
+ import { type FreshReply, type FreshStep, type ReviewStep } from '@buffcore/contracts/workbench';
2
+ import type { FreshLook } from '../studio/loop/FreshLookPanel.tsx';
3
+ import type { StudioActions } from './actions.ts';
4
+ export interface FreshActions {
5
+ read: (step: FreshStep, signal: AbortSignal) => Promise<FreshReply | undefined>;
6
+ answer: (step: ReviewStep, id: string, answer: 'take' | 'leave') => Promise<boolean>;
7
+ setting: (on: boolean) => void;
8
+ }
9
+ type Post = (path: string, body: unknown, signal?: AbortSignal, wait?: false) => Promise<unknown>;
10
+ export declare function freshActions(fetch: typeof globalThis.fetch, headers: HeadersInit, post: Post): FreshActions;
11
+ /** The step's fresh turn, read every few seconds while the page is open (faster while it runs). */
12
+ export declare function useFresh(actions: StudioActions, step: FreshStep): {
13
+ reply: {
14
+ review?: {
15
+ state: "done" | "failed" | "running";
16
+ agent: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
17
+ at: string;
18
+ seconds?: number | undefined;
19
+ findings: {
20
+ id: string;
21
+ text: string;
22
+ answer?: "left" | "taken" | undefined;
23
+ }[];
24
+ } | undefined;
25
+ critique?: {
26
+ state: "done" | "failed" | "running";
27
+ agent: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
28
+ at: string;
29
+ seconds?: number | undefined;
30
+ change?: string | undefined;
31
+ report?: string | undefined;
32
+ file?: "design/critique.md" | undefined;
33
+ } | undefined;
34
+ } | undefined;
35
+ refresh: () => Promise<{
36
+ review?: {
37
+ state: "done" | "failed" | "running";
38
+ agent: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
39
+ at: string;
40
+ seconds?: number | undefined;
41
+ findings: {
42
+ id: string;
43
+ text: string;
44
+ answer?: "left" | "taken" | undefined;
45
+ }[];
46
+ } | undefined;
47
+ critique?: {
48
+ state: "done" | "failed" | "running";
49
+ agent: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
50
+ at: string;
51
+ seconds?: number | undefined;
52
+ change?: string | undefined;
53
+ report?: string | undefined;
54
+ file?: "design/critique.md" | undefined;
55
+ } | undefined;
56
+ } | undefined>;
57
+ };
58
+ /**
59
+ * A planning step's findings with Take and Leave. Take sends the finding to the step's chat as the
60
+ * person's next message; only a message that was sent marks it taken.
61
+ */
62
+ export declare function useFreshLook(actions: StudioActions, step: ReviewStep, agent: string, send?: (text: string) => unknown): FreshLook | undefined;
63
+ export {};
@@ -0,0 +1,66 @@
1
+ // A fresh agent's turns, as the page reads them: a planning step's review (its findings, Take and
2
+ // Leave) and the prototype's critique, polled from `/api/fresh/:step`; and the review's setting.
3
+ import { freshReplySchema, } from '@buffcore/contracts/workbench';
4
+ import { useT } from '@buffcore/i18n/react';
5
+ import { useCallback, useState } from 'react';
6
+ import { usePolling } from './usePolling.js';
7
+ export function freshActions(fetch, headers, post) {
8
+ return {
9
+ read: async (step, signal) => {
10
+ const res = await fetch(`/api/fresh/${step}`, { headers, signal });
11
+ if (!res.ok)
12
+ return;
13
+ const reply = freshReplySchema.safeParse(await res.json());
14
+ return reply.success ? reply.data : undefined;
15
+ },
16
+ answer: async (step, id, answer) => {
17
+ const reply = await post(`/api/fresh/${step}/answer`, { id, answer }, undefined, false);
18
+ return reply?.ok === true;
19
+ },
20
+ setting: (on) => void post('/api/agents/review', { on }),
21
+ };
22
+ }
23
+ /** The step's fresh turn, read every few seconds while the page is open (faster while it runs). */
24
+ export function useFresh(actions, step) {
25
+ const [reply, setReply] = useState();
26
+ const read = useCallback(async (signal) => {
27
+ const next = await actions.fresh?.read(step, signal);
28
+ if (!signal.aborted && next)
29
+ setReply(next);
30
+ return next;
31
+ }, [actions.fresh, step]);
32
+ const running = reply?.review?.state === 'running' || reply?.critique?.state === 'running';
33
+ const refresh = usePolling(read, running ? 2000 : 5000, undefined, step);
34
+ return { reply, refresh };
35
+ }
36
+ /**
37
+ * A planning step's findings with Take and Leave. Take sends the finding to the step's chat as the
38
+ * person's next message; only a message that was sent marks it taken.
39
+ */
40
+ export function useFreshLook(actions, step, agent, send) {
41
+ const t = useT();
42
+ const { reply, refresh } = useFresh(actions, step);
43
+ const [busy, setBusy] = useState();
44
+ const fresh = actions.fresh;
45
+ if (!fresh || !reply?.review)
46
+ return;
47
+ const answer = async (id, choice) => {
48
+ if (await fresh.answer(step, id, choice))
49
+ await refresh();
50
+ };
51
+ return {
52
+ review: reply.review,
53
+ agent,
54
+ busy,
55
+ onTake: send
56
+ ? async (finding) => {
57
+ const sent = await send(t('studio.fresh.message', { finding: finding.text }));
58
+ if (sent === false)
59
+ return setBusy(finding.id);
60
+ setBusy(undefined);
61
+ await answer(finding.id, 'take');
62
+ }
63
+ : undefined,
64
+ onLeave: (finding) => void answer(finding.id, 'leave'),
65
+ };
66
+ }
@@ -1,6 +1,9 @@
1
1
  import type { Viewer } from '@buffcore/contracts/workbench';
2
- /** Trusted host code on the same page. This interface is not an isolation boundary. */
2
+ /**
3
+ * Trusted host code on the same page. This interface is not an isolation boundary. A place with a
4
+ * subject passes it third, as plain JSON (`HostSubjects`); other places pass two arguments.
5
+ */
3
6
  export interface StudioHostPartModule {
4
- mount(element: HTMLElement, viewer: Viewer): void | (() => void);
7
+ mount(element: HTMLElement, viewer: Viewer, subject?: unknown): void | (() => void);
5
8
  }
6
9
  export declare function loadHostPart(source: string): Promise<StudioHostPartModule>;
@@ -0,0 +1,17 @@
1
+ import type { Viewer } from '@buffcore/contracts/workbench';
2
+ /**
3
+ * `subject` is the JSON text of the place's subject: the same text keeps the mount through polls, a
4
+ * different text cleans it up and mounts again. Without one, the module gets exactly two arguments.
5
+ */
6
+ export declare function HostPartModule({ source, viewer, subject, name, named, }: {
7
+ source: string;
8
+ viewer: Viewer;
9
+ subject?: string;
10
+ /** What the failure note calls this place: a catalog key, or the host's own words when `named`. */
11
+ name: string;
12
+ named?: boolean;
13
+ }): import("react").JSX.Element;
14
+ /** The adapter owns this note even when the host module never loads. */
15
+ export declare function HostPartFailed({ name }: {
16
+ name: string;
17
+ }): import("react").JSX.Element;
@@ -0,0 +1,55 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useT } from '@buffcore/i18n/react';
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { Panel } from '../../components/Panel.js';
5
+ import { Loading } from '../../components/states.js';
6
+ import { bodyText } from '../../components/styles.js';
7
+ import { loadHostPart } from './host-part-loader.js';
8
+ /**
9
+ * `subject` is the JSON text of the place's subject: the same text keeps the mount through polls, a
10
+ * different text cleans it up and mounts again. Without one, the module gets exactly two arguments.
11
+ */
12
+ export function HostPartModule({ source, viewer, subject, name, named = false, }) {
13
+ const t = useT();
14
+ const element = useRef(null);
15
+ const [status, setStatus] = useState('loading');
16
+ useEffect(() => {
17
+ let active = true;
18
+ // biome-ignore lint/suspicious/noConfusingVoidType: follows the host mount contract.
19
+ let cleanup;
20
+ const target = element.current;
21
+ setStatus('loading');
22
+ void loadHostPart(source)
23
+ .then((module) => {
24
+ if (!active || !target)
25
+ return;
26
+ cleanup =
27
+ subject === undefined
28
+ ? module.mount(target, viewer)
29
+ : module.mount(target, viewer, JSON.parse(subject));
30
+ setStatus('ready');
31
+ })
32
+ .catch(() => {
33
+ if (!active)
34
+ return;
35
+ target?.replaceChildren();
36
+ setStatus('failed');
37
+ });
38
+ return () => {
39
+ active = false;
40
+ try {
41
+ cleanup?.();
42
+ }
43
+ catch {
44
+ /* A broken host must not break the studio. */
45
+ }
46
+ target?.replaceChildren();
47
+ };
48
+ }, [source, viewer, subject]);
49
+ return (_jsxs(_Fragment, { children: [status === 'loading' && _jsx(Loading, {}), status === 'failed' && _jsx(HostPartFailed, { name: named ? name : t(name) }), _jsx("div", { ref: element })] }));
50
+ }
51
+ /** The adapter owns this note even when the host module never loads. */
52
+ export function HostPartFailed({ name }) {
53
+ const t = useT();
54
+ return (_jsx(Panel, { title: name, children: _jsx("p", { role: "status", style: { ...bodyText, margin: 0 }, children: t('host.failed', { name }) }) }));
55
+ }
@@ -1,17 +1,8 @@
1
- import { type HostPartSources, type StudioState, type Viewer } from '@buffcore/contracts/workbench';
1
+ import { type HostPartSources, type StudioState } from '@buffcore/contracts/workbench';
2
2
  import { type ReactNode } from 'react';
3
3
  import type { StudioPage } from '../studio/types.ts';
4
4
  import { type HostParts } from './places.ts';
5
- /** Loading and failures remain local to one existing place. */
6
- export declare function HostPartModule({ source, viewer, place, }: {
7
- source: string;
8
- viewer: Viewer;
9
- place: keyof HostPartSources;
10
- }): import("react").JSX.Element;
11
- /** The adapter owns this note even when the host module never loads. */
12
- export declare function HostPartFailed({ name }: {
13
- name: string;
14
- }): import("react").JSX.Element;
5
+ export { HostPartFailed } from './host-part-module.tsx';
15
6
  /** Only validated public viewer fields enter a module, never the state used by old React parts. */
16
7
  export declare function StudioHostParts({ sources, state, parts, page, children, }: {
17
8
  sources?: HostPartSources;
@@ -1,61 +1,27 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { hostPartSourcesSchema, viewerSchema, } from '@buffcore/contracts/workbench';
3
- import { useT } from '@buffcore/i18n/react';
4
- import { useEffect, useMemo, useRef, useState } from 'react';
5
- import { Panel } from '../../components/Panel.js';
6
- import { Loading } from '../../components/states.js';
7
- import { bodyText } from '../../components/styles.js';
8
- import { loadHostPart } from './host-part-loader.js';
3
+ import { useMemo } from 'react';
4
+ import { HostPartModule } from './host-part-module.js';
9
5
  import { StudioPlaces } from './places.js';
10
- /** Loading and failures remain local to one existing place. */
11
- export function HostPartModule({ source, viewer, place, }) {
12
- const t = useT();
13
- const names = {
14
- 'top.end': 'host.place.machine',
15
- 'agents.end': 'studio.frame.page.agents',
16
- 'top.below': 'host.place.usage',
17
- 'setup.end': 'host.place.setup',
18
- 'issues.top': 'host.place.issues',
19
- };
20
- const element = useRef(null);
21
- const [status, setStatus] = useState('loading');
22
- useEffect(() => {
23
- let active = true;
24
- // biome-ignore lint/suspicious/noConfusingVoidType: follows the host mount contract.
25
- let cleanup;
26
- const target = element.current;
27
- setStatus('loading');
28
- void loadHostPart(source)
29
- .then((module) => {
30
- if (!active || !target)
31
- return;
32
- cleanup = module.mount(target, viewer);
33
- setStatus('ready');
34
- })
35
- .catch(() => {
36
- if (!active)
37
- return;
38
- target?.replaceChildren();
39
- setStatus('failed');
40
- });
41
- return () => {
42
- active = false;
43
- try {
44
- cleanup?.();
45
- }
46
- catch {
47
- /* A broken host must not break the studio. */
48
- }
49
- target?.replaceChildren();
50
- };
51
- }, [source, viewer]);
52
- return (_jsxs(_Fragment, { children: [status === 'loading' && _jsx(Loading, {}), status === 'failed' && _jsx(HostPartFailed, { name: t(names[place]) }), _jsx("div", { ref: element })] }));
53
- }
54
- /** The adapter owns this note even when the host module never loads. */
55
- export function HostPartFailed({ name }) {
56
- const t = useT();
57
- return (_jsx(Panel, { title: name, children: _jsx("p", { role: "status", style: { ...bodyText, margin: 0 }, children: t('host.failed', { name }) }) }));
58
- }
6
+ export { HostPartFailed } from './host-part-module.js';
7
+ /** What a failure note calls each module place, when the host gave no label of its own. */
8
+ const NAMES = {
9
+ 'top.end': 'host.place.machine',
10
+ 'agents.end': 'studio.frame.page.agents',
11
+ 'top.below': 'host.place.usage',
12
+ 'setup.end': 'host.place.setup',
13
+ 'issues.top': 'host.place.issues',
14
+ 'side:prototype': 'host.place.prototype',
15
+ 'approve:release': 'host.place.release',
16
+ 'card:server': 'host.place.server',
17
+ };
18
+ /** The places whose modules get a subject; inside the studio's own cards they wear the host's badge. */
19
+ const SUBJECT_PLACES = new Set([
20
+ 'side:prototype',
21
+ 'approve:release',
22
+ 'card:server',
23
+ ]);
24
+ const BADGED = new Set(['approve:release', 'card:server']);
59
25
  /** Only validated public viewer fields enter a module, never the state used by old React parts. */
60
26
  export function StudioHostParts({ sources, state, parts, page, children, }) {
61
27
  const parsed = viewerSchema.safeParse(state.viewer);
@@ -65,20 +31,40 @@ export function StudioHostParts({ sources, state, parts, page, children, }) {
65
31
  const descriptors = checked.success ? JSON.stringify(checked.data) : undefined;
66
32
  const combined = useMemo(() => {
67
33
  if (!viewer || !descriptors)
68
- return parts;
34
+ return { parts };
35
+ const { rail, label, ...places } = JSON.parse(descriptors);
69
36
  const result = { ...parts };
70
- const entries = Object.entries(JSON.parse(descriptors));
71
- for (const [place, source] of entries) {
37
+ for (const [place, source] of Object.entries(places)) {
72
38
  const id = place;
73
- result[id] = [
74
- ...(parts?.[id] ?? []),
75
- {
76
- id: `module:${id}`,
77
- draw: () => (_jsx(HostPartModule, { source: source, viewer: viewer, place: id }, `${source}:${identity}`)),
39
+ const named = Boolean(BADGED.has(id) && label);
40
+ const part = {
41
+ id: `module:${id}`,
42
+ ...(BADGED.has(id) && label ? { label } : {}),
43
+ draw: (_state, _passed, subject) => {
44
+ const text = SUBJECT_PLACES.has(id) && subject !== undefined ? JSON.stringify(subject) : undefined;
45
+ return (_jsx(HostPartModule, { source: source, viewer: viewer, subject: text, name: named && label ? label : NAMES[id], named: named }, `${source}:${identity}:${text ?? ''}`));
78
46
  },
79
- ];
47
+ };
48
+ result[id] = [...(parts?.[id] ?? []), part];
80
49
  }
81
- return result;
50
+ // The label travels without rail entries too: the phone tab beside the prototype is named by it.
51
+ if (!rail?.length)
52
+ return { parts: result, ...(label ? { rail: { label, entries: [] } } : {}) };
53
+ // Each rail entry is a page part with the entry's id; HostRailEntries draws it as a rail row.
54
+ const pages = rail.map((entry) => ({
55
+ id: `rail:${entry.id}`,
56
+ draw: () => (_jsx(HostPartModule, { source: entry.source, viewer: viewer, name: entry.label, named: true }, `${entry.source}:${identity}`)),
57
+ }));
58
+ result.page = [...(parts?.page ?? []), ...pages];
59
+ const hostRail = {
60
+ ...(label ? { label } : {}),
61
+ entries: rail.map(({ id, label: words, icon }) => ({
62
+ id: `rail:${id}`,
63
+ label: words,
64
+ ...(icon ? { icon } : {}),
65
+ })),
66
+ };
67
+ return { parts: result, rail: hostRail };
82
68
  }, [viewer, descriptors, parts, identity]);
83
- return (_jsx(StudioPlaces, { state: state, parts: combined, page: page, children: children }));
69
+ return (_jsx(StudioPlaces, { state: state, parts: combined.parts, rail: combined.rail, page: page, children: children }));
84
70
  }
@@ -11,6 +11,9 @@ export interface LevelChoice {
11
11
  /** Host-owned settings place and the commit supplying the saved level. */
12
12
  where?: string;
13
13
  commit?: string;
14
+ /** "Never ask" is in effect (Autopilot only); `onNeverAsk` turns it on or off, with the right. */
15
+ neverAsk?: boolean;
16
+ onNeverAsk?: (on: boolean) => void;
14
17
  }
15
18
  export declare const LevelChoiceContext: import("react").Context<LevelChoice | null>;
16
19
  /** A host shows saved facts, never this page's pending or refused selection. */