@buffcore/admin-shell 0.8.41 → 0.8.42

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 (115) 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/workbench/app/ServedPrototype.js +19 -1
  20. package/dist/workbench/app/StudioApp.js +29 -20
  21. package/dist/workbench/app/actions.d.ts +3 -1
  22. package/dist/workbench/app/actions.js +8 -2
  23. package/dist/workbench/app/ask-card.d.ts +10 -0
  24. package/dist/workbench/app/ask-card.js +34 -0
  25. package/dist/workbench/app/chat-session.d.ts +32 -0
  26. package/dist/workbench/app/chat.d.ts +37 -0
  27. package/dist/workbench/app/frame.js +4 -2
  28. package/dist/workbench/app/host-part-loader.d.ts +5 -2
  29. package/dist/workbench/app/host-part-module.d.ts +17 -0
  30. package/dist/workbench/app/host-part-module.js +55 -0
  31. package/dist/workbench/app/host-parts.d.ts +2 -11
  32. package/dist/workbench/app/host-parts.js +53 -67
  33. package/dist/workbench/app/level-choice.d.ts +3 -0
  34. package/dist/workbench/app/mount.d.ts +4 -1
  35. package/dist/workbench/app/mount.js +2 -2
  36. package/dist/workbench/app/panel-cards.d.ts +3 -3
  37. package/dist/workbench/app/panel-cards.js +3 -2
  38. package/dist/workbench/app/places.d.ts +17 -2
  39. package/dist/workbench/app/places.js +14 -2
  40. package/dist/workbench/app/scene-address.d.ts +10 -0
  41. package/dist/workbench/app/scene-address.js +14 -0
  42. package/dist/workbench/app/studio-post.js +1 -0
  43. package/dist/workbench/app/test/loop-fixture.d.ts +22 -0
  44. package/dist/workbench/app/usePrototypeUi.js +14 -0
  45. package/dist/workbench/app/work.d.ts +7 -7
  46. package/dist/workbench/host-theme.d.ts +3 -0
  47. package/dist/workbench/host-theme.js +14 -0
  48. package/dist/workbench/index.d.ts +1 -0
  49. package/dist/workbench/index.js +1 -0
  50. package/dist/workbench/studio/frame/HostRailEntries.d.ts +3 -0
  51. package/dist/workbench/studio/frame/HostRailEntries.js +15 -0
  52. package/dist/workbench/studio/frame/HostSide.d.ts +6 -0
  53. package/dist/workbench/studio/frame/HostSide.js +31 -0
  54. package/dist/workbench/studio/frame/LevelChip.js +2 -1
  55. package/dist/workbench/studio/frame/LevelChoices.js +24 -8
  56. package/dist/workbench/studio/frame/NeverAskSetting.d.ts +7 -0
  57. package/dist/workbench/studio/frame/NeverAskSetting.js +24 -0
  58. package/dist/workbench/studio/frame/PanelList.js +5 -2
  59. package/dist/workbench/studio/frame/PanelNotice.js +2 -1
  60. package/dist/workbench/studio/frame/PanelScenes.d.ts +5 -0
  61. package/dist/workbench/studio/frame/PanelScenes.js +38 -0
  62. package/dist/workbench/studio/frame/PermissionAskCard.d.ts +18 -0
  63. package/dist/workbench/studio/frame/PermissionAskCard.js +60 -0
  64. package/dist/workbench/studio/frame/PermissionAskFold.d.ts +12 -0
  65. package/dist/workbench/studio/frame/PermissionAskFold.js +54 -0
  66. package/dist/workbench/studio/frame/Place.d.ts +6 -2
  67. package/dist/workbench/studio/frame/Place.js +13 -5
  68. package/dist/workbench/studio/frame/SettingsSheet.js +6 -1
  69. package/dist/workbench/studio/frame/StudioRail.js +2 -1
  70. package/dist/workbench/studio/frame/panelControls.d.ts +17 -0
  71. package/dist/workbench/studio/i18n/frame.en.d.ts +26 -0
  72. package/dist/workbench/studio/i18n/frame.en.js +26 -0
  73. package/dist/workbench/studio/i18n/frame.es.json +27 -1
  74. package/dist/workbench/studio/i18n/levels.en.d.ts +5 -0
  75. package/dist/workbench/studio/i18n/levels.en.js +5 -0
  76. package/dist/workbench/studio/i18n/levels.es.json +6 -1
  77. package/dist/workbench/studio/i18n/loop.en.d.ts +4 -0
  78. package/dist/workbench/studio/i18n/loop.en.js +4 -0
  79. package/dist/workbench/studio/i18n/loop.es.json +4 -0
  80. package/dist/workbench/studio/i18n/save.en.d.ts +1 -3
  81. package/dist/workbench/studio/i18n/save.en.js +13 -15
  82. package/dist/workbench/studio/i18n/save.es.json +14 -16
  83. package/dist/workbench/studio/i18n/structure.en.d.ts +6 -0
  84. package/dist/workbench/studio/i18n/structure.en.js +6 -0
  85. package/dist/workbench/studio/i18n/structure.es.d.ts +6 -0
  86. package/dist/workbench/studio/i18n/structure.es.js +6 -0
  87. package/dist/workbench/studio/loop/PrototypePage.js +4 -3
  88. package/dist/workbench/studio/loop/PrototypeScenes.js +1 -2
  89. package/dist/workbench/studio/loop/PrototypeSimplePage.js +7 -6
  90. package/dist/workbench/studio/loop/PrototypeSnapshot.js +5 -1
  91. package/dist/workbench/studio/loop/ReviewedSave.d.ts +1 -1
  92. package/dist/workbench/studio/loop/ReviewedSave.js +2 -10
  93. package/dist/workbench/studio/loop/ServedBrand.js +3 -3
  94. package/dist/workbench/studio/loop/StructurePage.d.ts +2 -0
  95. package/dist/workbench/studio/loop/StructurePage.js +1 -1
  96. package/dist/workbench/studio/loop/StructurePreview.js +4 -4
  97. package/dist/workbench/studio/loop/StructurePrompts.js +9 -4
  98. package/dist/workbench/studio/loop/step-state.d.ts +1 -1
  99. package/dist/workbench/studio/loop/step-state.js +9 -8
  100. package/dist/workbench/studio/loop/structure-answers.d.ts +8 -0
  101. package/dist/workbench/studio/loop/structure-answers.js +34 -0
  102. package/dist/workbench/studio/loop/usePlanningDraft.js +2 -1
  103. package/dist/workbench/studio/loop/usePlanningSave.d.ts +16 -2
  104. package/dist/workbench/studio/loop/usePlanningSave.js +40 -2
  105. package/dist/workbench/studio/loop/usePrototypeRecord.js +5 -4
  106. package/dist/workbench/studio/loop/useReviewedSave.d.ts +9 -4
  107. package/dist/workbench/studio/loop/useReviewedSave.js +89 -30
  108. package/dist/workbench/studio/run/LiveServers.js +1 -1
  109. package/dist/workbench/studio/run/ReleasePage.js +1 -1
  110. package/dist/workbench/studio/run/ReleasesPage.js +2 -2
  111. package/dist/workbench/studio/run/ServedRelease.js +1 -1
  112. package/dist/workbench/studio/work/work-test-data.d.ts +3 -0
  113. package/package.json +6 -6
  114. package/vite.d.ts +6 -1
  115. package/vite.js +78 -5
@@ -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;
@@ -126,6 +138,10 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
126
138
  unsaved?: {
127
139
  count?: number | undefined;
128
140
  } | undefined;
141
+ scenes?: {
142
+ key: string;
143
+ title: string;
144
+ }[] | undefined;
129
145
  } | undefined;
130
146
  }[];
131
147
  };
@@ -161,6 +177,18 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
161
177
  at: string;
162
178
  turn: string;
163
179
  } | undefined;
180
+ asking?: {
181
+ id: string;
182
+ tool: string;
183
+ command: string;
184
+ parts: string[];
185
+ once?: boolean | undefined;
186
+ unsure?: {
187
+ why: "budget" | "expression" | "heredoc" | "mention" | "pattern" | "stdin";
188
+ mention?: string | undefined;
189
+ } | undefined;
190
+ at: string;
191
+ } | undefined;
164
192
  messages: {
165
193
  from: "agent" | "system" | "you";
166
194
  text: string;
@@ -211,6 +239,10 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
211
239
  unsaved?: {
212
240
  count?: number | undefined;
213
241
  } | undefined;
242
+ scenes?: {
243
+ key: string;
244
+ title: string;
245
+ }[] | undefined;
214
246
  } | undefined;
215
247
  }[];
216
248
  } | undefined>;
@@ -240,6 +272,11 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
240
272
  ios: boolean;
241
273
  android: boolean;
242
274
  }) => void;
275
+ ask?: {
276
+ asking?: import("../studio/frame/panelControls.ts").Asking;
277
+ answered?: import("../studio/frame/panelControls.ts").AnsweredAsk;
278
+ onAnswer: (answer: import("../studio/frame/panelControls.ts").AskAnswer) => Promise<true | string>;
279
+ };
243
280
  save?: {
244
281
  onSave: () => Promise<void>;
245
282
  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
  };
@@ -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. */
@@ -1,8 +1,11 @@
1
+ import type { Theme } from '@buffcore/tokens';
1
2
  import { type StudioAppProps } from './StudioApp.tsx';
2
3
  export type StudioMountProps = Omit<StudioAppProps, 'dark' | 'onDark'> & {
3
4
  /** The local CLI or host's choice; absent it, the browser chooses. */
4
5
  locale?: string;
6
+ /** A host's theme, checked before it gets here (`createUiServer({ theme })`); absent, the studio's own. */
7
+ theme?: Theme;
5
8
  };
6
- export declare function StudioRoot({ locale, ...props }: StudioMountProps): import("react").JSX.Element;
9
+ export declare function StudioRoot({ locale, theme: hostTheme, ...props }: StudioMountProps): import("react").JSX.Element;
7
10
  /** Mounts the opt-in studio; polling stops when the caller unmounts it. */
8
11
  export declare function mountStudio(element: Element, props: StudioMountProps): () => void;
@@ -11,13 +11,13 @@ import { pageMode } from '../studio/frame/layout.js';
11
11
  import { studioCatalog } from '../studio/i18n/index.js';
12
12
  import { theme } from '../theme.js';
13
13
  import { StudioApp } from './StudioApp.js';
14
- export function StudioRoot({ locale, ...props }) {
14
+ export function StudioRoot({ locale, theme: hostTheme, ...props }) {
15
15
  const translator = useMemo(() => createI18n({
16
16
  catalogs: [adminCatalog, workbenchCatalog, studioCatalog],
17
17
  locale: matchLocale(locale || globalThis.navigator?.languages, ['en', 'es']),
18
18
  }), [locale]);
19
19
  const [dark, setDark] = useState(() => resolvePageMode(pageMode()) === 'dark');
20
- return (_jsxs(I18nProvider, { translator: translator, children: [_jsx(PageLook, { theme: theme, mode: dark ? 'dark' : 'light', locale: translator.instance.language }), _jsx("div", { style: { height: '100dvh' }, children: _jsx(StudioApp, { ...props, dark: dark, onDark: () => setDark((mode) => !mode) }) })] }));
20
+ return (_jsxs(I18nProvider, { translator: translator, children: [_jsx(PageLook, { theme: hostTheme ?? theme, mode: dark ? 'dark' : 'light', locale: translator.instance.language }), _jsx("div", { style: { height: '100dvh' }, children: _jsx(StudioApp, { ...props, dark: dark, onDark: () => setDark((mode) => !mode) }) })] }));
21
21
  }
22
22
  /** Mounts the opt-in studio; polling stops when the caller unmounts it. */
23
23
  export function mountStudio(element, props) {
@@ -1,10 +1,10 @@
1
1
  import type { StudioState } from '@buffcore/contracts/workbench';
2
- import type { ControlledAgent } from '../studio/frame/panelControls.ts';
2
+ import type { ControlledAgent, TurnControls } from '../studio/frame/panelControls.ts';
3
3
  import type { StudioPage } from '../studio/types.ts';
4
4
  import type { StudioActions } from './actions.ts';
5
5
  /**
6
6
  * The chat's two cards: "Allow this folder" for a person with the settings right (the server
7
7
  * checks it again and reads the folder from the chat), and the platforms card, which only opens
8
- * Setup with the chosen switches.
8
+ * Setup with the chosen switches; and the agent's permission card, when the turn waits on one.
9
9
  */
10
- export declare function withPanelCards(agent: ControlledAgent, state: StudioState, chat: string, actions: StudioActions, onGo: (page: StudioPage) => void, wanted: NonNullable<StudioActions['platformsWanted']>): ControlledAgent;
10
+ export declare function withPanelCards(agent: ControlledAgent, state: StudioState, chat: string, actions: StudioActions, onGo: (page: StudioPage) => void, wanted: NonNullable<StudioActions['platformsWanted']>, ask?: TurnControls['ask']): ControlledAgent;
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * The chat's two cards: "Allow this folder" for a person with the settings right (the server
3
3
  * checks it again and reads the folder from the chat), and the platforms card, which only opens
4
- * Setup with the chosen switches.
4
+ * Setup with the chosen switches; and the agent's permission card, when the turn waits on one.
5
5
  */
6
- export function withPanelCards(agent, state, chat, actions, onGo, wanted) {
6
+ export function withPanelCards(agent, state, chat, actions, onGo, wanted, ask) {
7
7
  actions.platformsWanted = wanted;
8
8
  const rights = state.viewer?.rights;
9
9
  const settings = !rights || rights === 'all' || rights.includes('settings');
@@ -18,6 +18,7 @@ export function withPanelCards(agent, state, chat, actions, onGo, wanted) {
18
18
  ...agent.turn,
19
19
  ...(settings && allow && chat ? { onAllowFolder: (at) => allow(chat, at) } : {}),
20
20
  ...(platforms ? { platforms } : {}),
21
+ ...(ask ? { ask } : {}),
21
22
  onPlatforms: (choice) => {
22
23
  // An absent choice (unknown platforms) opens Setup with nothing chosen.
23
24
  wanted.current = choice;
@@ -5,7 +5,17 @@ export interface HostPart {
5
5
  id: string;
6
6
  /** Host-supplied, already localized badge and navigation label. */
7
7
  label?: string;
8
- draw(state: StudioState, passed?: unknown): ReactNode;
8
+ /** `subject` is the plain JSON a place with one passes (beside a prototype, a release approval, a server card). */
9
+ draw(state: StudioState, passed?: unknown, subject?: unknown): ReactNode;
10
+ }
11
+ /** A host's rail entries, drawn as rail rows; each opens its `page` part of the same id. */
12
+ export interface HostRail {
13
+ label?: string;
14
+ entries: readonly {
15
+ id: string;
16
+ label: string;
17
+ icon?: string;
18
+ }[];
9
19
  }
10
20
  export type HostParts = Partial<Record<DrawPlaceId, readonly HostPart[]>>;
11
21
  type Selection = {
@@ -16,6 +26,7 @@ type Selection = {
16
26
  interface PlacesValue {
17
27
  state: StudioState;
18
28
  parts?: HostParts;
29
+ rail?: HostRail;
19
30
  page: StudioPage;
20
31
  selected?: Selection;
21
32
  select: (place?: DrawPlaceId, id?: string) => void;
@@ -44,8 +55,12 @@ export declare function placeApproval(id: PlaceId, state: StudioState): {
44
55
  by: string;
45
56
  } | undefined;
46
57
  } | undefined;
58
+ /** A subject as plain JSON: no functions, class instances or shared references reach a part. */
59
+ export declare function plainSubject(subject: unknown): unknown;
47
60
  /** Only the container supplies facts; the views read this optional rendering input. */
48
- export declare function StudioPlaces({ state, parts, page, children, }: Pick<PlacesValue, 'state' | 'parts' | 'page'> & {
61
+ export declare function StudioPlaces({ state, parts, rail, page, opened, children, }: Pick<PlacesValue, 'state' | 'parts' | 'rail' | 'page'> & {
62
+ /** A host page or tab open from the start (the review scenes draw one open). */
63
+ opened?: Pick<Selection, 'place' | 'id'>;
49
64
  children: ReactNode;
50
65
  }): import("react").FunctionComponentElement<import("react").ProviderProps<PlacesValue | null>>;
51
66
  export {};
@@ -11,14 +11,26 @@ export function placeApproval(id, state) {
11
11
  ?.approval;
12
12
  return undefined;
13
13
  }
14
+ /** A subject as plain JSON: no functions, class instances or shared references reach a part. */
15
+ export function plainSubject(subject) {
16
+ if (subject === undefined)
17
+ return undefined;
18
+ try {
19
+ return JSON.parse(JSON.stringify(subject));
20
+ }
21
+ catch {
22
+ return undefined;
23
+ }
24
+ }
14
25
  /** Only the container supplies facts; the views read this optional rendering input. */
15
- export function StudioPlaces({ state, parts, page, children, }) {
16
- const [selection, setSelection] = useState();
26
+ export function StudioPlaces({ state, parts, rail, page, opened, children, }) {
27
+ const [selection, setSelection] = useState(opened && { ...opened, page });
17
28
  const selected = selection?.page === page ? selection : undefined;
18
29
  return createElement(PlacesContext.Provider, {
19
30
  value: {
20
31
  state,
21
32
  parts,
33
+ rail,
22
34
  page,
23
35
  selected,
24
36
  select: (place, id) => setSelection(place && id ? { place, id, page } : undefined),
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A reply's scene link: `#/prototype?scene=<key>` opens Prototype with that scene in the preview.
3
+ * The preview takes the scene once and puts the address back to `#/prototype`, so the same link
4
+ * works again after the person moves on.
5
+ */
6
+ export declare const sceneHref: (key: string) => string;
7
+ /** The scene an address asks the preview for, if any. */
8
+ export declare function addressedScene(hash: string): string | undefined;
9
+ /** The page part of an address: `#/prototype?scene=x` is the Prototype page. */
10
+ export declare const addressPath: (hash: string) => string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * A reply's scene link: `#/prototype?scene=<key>` opens Prototype with that scene in the preview.
3
+ * The preview takes the scene once and puts the address back to `#/prototype`, so the same link
4
+ * works again after the person moves on.
5
+ */
6
+ export const sceneHref = (key) => `#/prototype?scene=${encodeURIComponent(key)}`;
7
+ /** The scene an address asks the preview for, if any. */
8
+ export function addressedScene(hash) {
9
+ const match = /^#\/prototype\?(.*)$/.exec(hash);
10
+ const scene = match ? new URLSearchParams(match[1]).get('scene') : null;
11
+ return scene || undefined;
12
+ }
13
+ /** The page part of an address: `#/prototype?scene=x` is the Prototype page. */
14
+ export const addressPath = (hash) => hash.split('?')[0] ?? hash;
@@ -62,6 +62,7 @@ export function studioPost(fetch, headers, read, setDetail, setTrouble, offline)
62
62
  const id = body?.id;
63
63
  if (path === '/api/brand/icon' ||
64
64
  path.endsWith('/allow-folder') ||
65
+ path.endsWith('/permission') ||
65
66
  (path === '/api/run' && typeof id === 'string' && /^(?:enable|disable):/.test(id)))
66
67
  // Only a refusal sentence is shown; any other failed answer is a failure the page words.
67
68
  return typeof result?.error === 'string' ? result : undefined;
@@ -31,6 +31,7 @@ export declare function loopApi(initial?: {
31
31
  model?: Partial<Record<"coding" | "design" | "fixes" | "planning" | "tests" | "validation", string>> | undefined;
32
32
  effort?: Partial<Record<"coding" | "design" | "fixes" | "planning" | "tests" | "validation", "auto" | "high" | "low" | "max" | "medium" | "xhigh">> | undefined;
33
33
  level: "auto" | "guide" | "lead" | "review";
34
+ neverAsk?: boolean | undefined;
34
35
  } | null;
35
36
  found: {
36
37
  id: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
@@ -228,6 +229,7 @@ export declare function loopApi(initial?: {
228
229
  who: string;
229
230
  place: string;
230
231
  main: boolean;
232
+ planned?: string | undefined;
231
233
  }[];
232
234
  notes: string[];
233
235
  problem?: string | undefined;
@@ -337,6 +339,7 @@ export declare function loopApi(initial?: {
337
339
  } | undefined;
338
340
  committedLevel?: "auto" | "guide" | "lead" | "review" | undefined;
339
341
  effectiveLevel?: "auto" | "guide" | "lead" | "review" | undefined;
342
+ neverAsk?: boolean | undefined;
340
343
  level?: {
341
344
  source: "host";
342
345
  where: string;
@@ -388,6 +391,18 @@ export declare function loopApi(initial?: {
388
391
  at: string;
389
392
  turn: string;
390
393
  } | undefined;
394
+ asking?: {
395
+ id: string;
396
+ tool: string;
397
+ command: string;
398
+ parts: string[];
399
+ once?: boolean | undefined;
400
+ unsure?: {
401
+ why: "budget" | "expression" | "heredoc" | "mention" | "pattern" | "stdin";
402
+ mention?: string | undefined;
403
+ } | undefined;
404
+ at: string;
405
+ } | undefined;
391
406
  messages: {
392
407
  from: "agent" | "system" | "you";
393
408
  text: string;
@@ -438,6 +453,10 @@ export declare function loopApi(initial?: {
438
453
  unsaved?: {
439
454
  count?: number | undefined;
440
455
  } | undefined;
456
+ scenes?: {
457
+ key: string;
458
+ title: string;
459
+ }[] | undefined;
441
460
  } | undefined;
442
461
  }[];
443
462
  }>;
@@ -466,6 +485,7 @@ export declare function loopApi(initial?: {
466
485
  model?: Partial<Record<"coding" | "design" | "fixes" | "planning" | "tests" | "validation", string>> | undefined;
467
486
  effort?: Partial<Record<"coding" | "design" | "fixes" | "planning" | "tests" | "validation", "auto" | "high" | "low" | "max" | "medium" | "xhigh">> | undefined;
468
487
  level: "auto" | "guide" | "lead" | "review";
488
+ neverAsk?: boolean | undefined;
469
489
  } | null;
470
490
  found: {
471
491
  id: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
@@ -663,6 +683,7 @@ export declare function loopApi(initial?: {
663
683
  who: string;
664
684
  place: string;
665
685
  main: boolean;
686
+ planned?: string | undefined;
666
687
  }[];
667
688
  notes: string[];
668
689
  problem?: string | undefined;
@@ -772,6 +793,7 @@ export declare function loopApi(initial?: {
772
793
  } | undefined;
773
794
  committedLevel?: "auto" | "guide" | "lead" | "review" | undefined;
774
795
  effectiveLevel?: "auto" | "guide" | "lead" | "review" | undefined;
796
+ neverAsk?: boolean | undefined;
775
797
  level?: {
776
798
  source: "host";
777
799
  where: string;
@@ -1,4 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
+ import { addressedScene } from './scene-address.js';
2
3
  /** Playback belongs to the container; any other canvas choice stops it. */
3
4
  export function usePrototypeUi(journeys, journey, version) {
4
5
  const [ui, setUi] = useState({ journey, version });
@@ -15,6 +16,19 @@ export function usePrototypeUi(journeys, journey, version) {
15
16
  }, 1000);
16
17
  return () => clearInterval(timer);
17
18
  }, [ui.playing, last]);
19
+ // A reply's scene link opens its scene once, then the address is the page again.
20
+ useEffect(() => {
21
+ const take = () => {
22
+ const screen = addressedScene(window.location.hash);
23
+ if (!screen)
24
+ return;
25
+ setUi((current) => ({ ...current, screen, playing: false }));
26
+ window.history.replaceState(null, '', '#/prototype');
27
+ };
28
+ take();
29
+ window.addEventListener('hashchange', take);
30
+ return () => window.removeEventListener('hashchange', take);
31
+ }, []);
18
32
  const update = (patch) => setUi((current) => ({ ...current, ...patch, playing: false }));
19
33
  const player = (action) => {
20
34
  setUi((current) => ({