@buffcore/admin-shell 0.8.42 → 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 (61) hide show
  1. package/dist/screens/assistant/use-ask.d.ts +4 -3
  2. package/dist/workbench/app/ServedAgents.js +4 -1
  3. package/dist/workbench/app/ServedComp.d.ts +3 -0
  4. package/dist/workbench/app/ServedComp.js +33 -0
  5. package/dist/workbench/app/ServedPrototype.js +9 -0
  6. package/dist/workbench/app/actions.d.ts +7 -0
  7. package/dist/workbench/app/actions.js +1 -0
  8. package/dist/workbench/app/chat-session.d.ts +2 -0
  9. package/dist/workbench/app/chat.d.ts +2 -0
  10. package/dist/workbench/app/fresh.d.ts +63 -0
  11. package/dist/workbench/app/fresh.js +66 -0
  12. package/dist/workbench/app/places.d.ts +1 -1
  13. package/dist/workbench/app/prototype-comp.d.ts +46 -0
  14. package/dist/workbench/app/prototype-comp.js +77 -0
  15. package/dist/workbench/app/prototype.d.ts +1 -1
  16. package/dist/workbench/app/prototype.js +3 -1
  17. package/dist/workbench/app/test/loop-fixture.d.ts +13 -8
  18. package/dist/workbench/app/useStudio.d.ts +43 -1
  19. package/dist/workbench/app/useStudio.js +8 -1
  20. package/dist/workbench/app/work.d.ts +7 -7
  21. package/dist/workbench/studio/frame/LimitCard.d.ts +5 -0
  22. package/dist/workbench/studio/frame/LimitCard.js +26 -0
  23. package/dist/workbench/studio/frame/PanelMessage.js +3 -0
  24. package/dist/workbench/studio/frame/panelLines.d.ts +1 -0
  25. package/dist/workbench/studio/frame/panelLines.js +2 -1
  26. package/dist/workbench/studio/i18n/comp.en.d.ts +26 -0
  27. package/dist/workbench/studio/i18n/comp.en.js +26 -0
  28. package/dist/workbench/studio/i18n/comp.es.d.ts +26 -0
  29. package/dist/workbench/studio/i18n/comp.es.js +25 -0
  30. package/dist/workbench/studio/i18n/frame.en.d.ts +13 -0
  31. package/dist/workbench/studio/i18n/frame.en.js +13 -0
  32. package/dist/workbench/studio/i18n/frame.es.json +14 -1
  33. package/dist/workbench/studio/i18n/fresh.en.d.ts +19 -0
  34. package/dist/workbench/studio/i18n/fresh.en.js +20 -0
  35. package/dist/workbench/studio/i18n/fresh.es.json +18 -0
  36. package/dist/workbench/studio/i18n/index.js +6 -0
  37. package/dist/workbench/studio/loop/AgentsPage.d.ts +4 -1
  38. package/dist/workbench/studio/loop/AgentsPage.js +5 -4
  39. package/dist/workbench/studio/loop/CritiqueNote.d.ts +4 -0
  40. package/dist/workbench/studio/loop/CritiqueNote.js +9 -0
  41. package/dist/workbench/studio/loop/FreshLookPanel.d.ts +21 -0
  42. package/dist/workbench/studio/loop/FreshLookPanel.js +60 -0
  43. package/dist/workbench/studio/loop/PrototypeComp.d.ts +25 -0
  44. package/dist/workbench/studio/loop/PrototypeComp.js +78 -0
  45. package/dist/workbench/studio/loop/PrototypePage.d.ts +7 -0
  46. package/dist/workbench/studio/loop/PrototypePage.js +1 -1
  47. package/dist/workbench/studio/loop/PrototypeSimplePage.js +11 -4
  48. package/dist/workbench/studio/loop/PrototypeSnapshot.d.ts +3 -0
  49. package/dist/workbench/studio/loop/PrototypeSnapshot.js +2 -1
  50. package/dist/workbench/studio/loop/ReviewSetting.d.ts +6 -0
  51. package/dist/workbench/studio/loop/ReviewSetting.js +14 -0
  52. package/dist/workbench/studio/loop/SaveStep.d.ts +3 -0
  53. package/dist/workbench/studio/loop/SaveStep.js +3 -1
  54. package/dist/workbench/studio/loop/ServedPlanning.js +1 -1
  55. package/dist/workbench/studio/loop/StructurePage.d.ts +5 -0
  56. package/dist/workbench/studio/loop/StructurePage.js +3 -2
  57. package/dist/workbench/studio/loop/SurfaceChoice.d.ts +7 -0
  58. package/dist/workbench/studio/loop/SurfaceChoice.js +20 -0
  59. package/dist/workbench/studio/loop/usePlanningDraft.js +5 -1
  60. package/dist/workbench/studio/work/work-test-data.d.ts +6 -4
  61. package/package.json +6 -6
@@ -92,7 +92,7 @@ export declare function useAsk(api: Client): {
92
92
  }[] | undefined;
93
93
  }[];
94
94
  approval: {
95
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
95
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
96
96
  signatures: {
97
97
  by: string;
98
98
  at: string;
@@ -210,7 +210,7 @@ export declare function useAsk(api: Client): {
210
210
  }[] | undefined;
211
211
  }[];
212
212
  approval: {
213
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
213
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
214
214
  signatures: {
215
215
  by: string;
216
216
  at: string;
@@ -379,6 +379,7 @@ export declare function useAsk(api: Client): {
379
379
  approval: import("zod").ZodNullable<import("zod").ZodObject<{
380
380
  kind: import("zod").ZodEnum<{
381
381
  brand: "brand";
382
+ comp: "comp";
382
383
  money: "money";
383
384
  places: "places";
384
385
  plan: "plan";
@@ -505,7 +506,7 @@ export declare function useAsk(api: Client): {
505
506
  }[] | undefined;
506
507
  }[];
507
508
  approval: {
508
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
509
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
509
510
  signatures: {
510
511
  by: string;
511
512
  at: string;
@@ -64,7 +64,10 @@ export function ServedAgents({ state, actions }) {
64
64
  busy.current = false;
65
65
  }
66
66
  };
67
- return (_jsxs(_Fragment, { children: [_jsx(AgentsPage, { onChoose: () => {
67
+ return (_jsxs(_Fragment, { children: [_jsx(AgentsPage, { review: {
68
+ on: state.agents.file?.review !== false,
69
+ onChange: blocked ? undefined : actions.fresh?.setting,
70
+ }, onChoose: () => {
68
71
  if (agents.some((agent) => agent.state === 'missing'))
69
72
  void discover();
70
73
  }, onHelp: (agent, need) => {
@@ -0,0 +1,3 @@
1
+ import type { CompSlot } from '../studio/loop/PrototypePage.tsx';
2
+ import { type CompReads } from './prototype-comp.ts';
3
+ export declare function useServedComp(reads: CompReads | undefined, needsRight?: 'approve'): CompSlot | undefined;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // The comp on the served Prototype page: shown first while no look is approved, and on request
3
+ // after. Approving is a person's click; the route records it and refuses an agent.
4
+ import { useT } from '@buffcore/i18n/react';
5
+ import { useState } from 'react';
6
+ import { Button } from '../../components/Button.js';
7
+ import { captionText } from '../../components/styles.js';
8
+ import { PrototypeComp } from '../studio/loop/PrototypeComp.js';
9
+ import { useDesignApproval } from '../studio/loop/useDesignApproval.js';
10
+ import { usePrototypeComp } from './prototype-comp.js';
11
+ export function useServedComp(reads, needsRight) {
12
+ const t = useT();
13
+ const { reply, pictures, reload } = usePrototypeComp(reads);
14
+ const signing = useDesignApproval(`comp:${reply?.fingerprint ?? ''}`);
15
+ const [opened, setOpened] = useState(false);
16
+ if (!reads || !reply?.screens.length)
17
+ return undefined;
18
+ const open = !reply.approved || opened;
19
+ const view = (_jsx(PrototypeComp, { surface: reply.surface, width: reply.width, screens: reply.screens.map((screen) => ({
20
+ key: screen.key,
21
+ title: screen.title,
22
+ light: screen.light && pictures[screen.light],
23
+ dark: screen.dark && pictures[screen.dark],
24
+ })), references: reply.references.map((name) => (name ? pictures[name] : undefined)), approved: reply.approved, approvedBy: reply.approval?.signatures[0]?.by, needsRight: needsRight, result: signing.result, onApprove: reply.fingerprint
25
+ ? () => void signing.approve(async () => {
26
+ const answer = await reads.approve(reply.fingerprint);
27
+ reload();
28
+ return answer;
29
+ })
30
+ : undefined, onClose: reply.approved ? () => setOpened(false) : undefined }));
31
+ const summary = reply.approved && !opened && (_jsxs("div", { style: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 'var(--space-3)' }, children: [_jsx("span", { style: captionText, children: t('studio.comp.approved') }), _jsx(Button, { variant: "secondary", size: "lg", onClick: () => setOpened(true), children: t('studio.comp.open') })] }));
32
+ return { open, view, summary: summary || undefined };
33
+ }
@@ -6,8 +6,10 @@ import { useDesignApproval } from '../studio/loop/useDesignApproval.js';
6
6
  import { viewerCanBuild } from '../studio/loop/usePlanningSave.js';
7
7
  import { usePrototypeRecord } from '../studio/loop/usePrototypeRecord.js';
8
8
  import { catchUpChange } from './catch-up.js';
9
+ import { useFresh } from './fresh.js';
9
10
  import { commentMessage, openPrototype, protoSample, protoView } from './prototype.js';
10
11
  import { usePrototypeHome } from './prototype-home.js';
12
+ import { useServedComp } from './ServedComp.js';
11
13
  import { usePrototypeScenes } from './usePrototypeScenes.js';
12
14
  import { usePrototypeSnapshot } from './usePrototypeSnapshot.js';
13
15
  import { usePrototypeUi } from './usePrototypeUi.js';
@@ -23,8 +25,10 @@ function usePrototypePage(props) {
23
25
  }
24
26
  // A missed probe can omit appUrl, including when a host set a different preview address.
25
27
  const previewUrl = appUrl ?? (sameAddress && running !== true ? address.url : undefined) ?? stack.app;
28
+ const comp = useServedComp(props.actions.comp, model.view.needsRight);
26
29
  return {
27
30
  page: {
31
+ comp,
28
32
  appUrl: stack.state === 'running' ? appUrl : undefined,
29
33
  simple: props.actions.prototypeHome ? { checks: prototypeChecks(model) } : undefined,
30
34
  home: props.actions.prototypeHome
@@ -62,6 +66,9 @@ function usePrototypePage(props) {
62
66
  onSave: () => void model.recording.save(),
63
67
  onStart: model.snapshot.start,
64
68
  onStop: () => void model.snapshot.stop(),
69
+ critique: !model.critique?.change || model.critique.change === model.change
70
+ ? model.critique
71
+ : undefined,
65
72
  onRecord: async () => {
66
73
  if (model.snapshot.reply?.linked)
67
74
  return;
@@ -88,6 +95,7 @@ function usePrototypeModel(props) {
88
95
  if (!state.stackUnconfirmed)
89
96
  confirmed.current = state;
90
97
  const { stack: { output: _output, ...ports }, ...facts } = confirmed.current;
98
+ const critique = useFresh(actions, 'prototype').reply?.critique;
91
99
  const snapshot = usePrototypeSnapshot(actions, { ...facts, stack: ports }, change, own, props.every);
92
100
  const sample = protoSample(state, change, { ...ui, t }, source.scenes);
93
101
  sample.proto.consoleRead = { pending: source.pending, failure: source.failure };
@@ -130,6 +138,7 @@ function usePrototypeModel(props) {
130
138
  source,
131
139
  home,
132
140
  snapshot: { ...snapshot, own, start: takeSnapshot },
141
+ critique,
133
142
  };
134
143
  }
135
144
  function prototypeHandlers(model) {
@@ -2,6 +2,7 @@ import { type AgentAssignment, type Chat, type FoundAgent, type LEVELS, type Mer
2
2
  import { z } from 'zod';
3
3
  import type { StudioPage } from '../studio/types.ts';
4
4
  import type { ServerForm } from '../types.ts';
5
+ import type { FreshActions } from './fresh.ts';
5
6
  import { type SnapshotRead, type SnapshotRequest } from './prototype-snapshot.ts';
6
7
  import type { QuestionChoice } from './question-choices.ts';
7
8
  export declare function studioRefusal(answer: unknown): string | undefined;
@@ -36,6 +37,8 @@ export interface StudioActions {
36
37
  prototypeScenes?: (signal?: AbortSignal) => Promise<PrototypeScenesReply>;
37
38
  go?: (page: StudioPage) => void;
38
39
  readIcon?: (signal: AbortSignal) => Promise<Blob | undefined>;
40
+ /** The comp's reads and its approval (`prototype-comp.ts`). */
41
+ comp?: import('./prototype-comp.ts').CompReads;
39
42
  uploadIcon?: (file: File) => Promise<unknown>;
40
43
  run: (id: string, server?: ServerForm) => unknown;
41
44
  stack: (action: 'start' | 'stop') => void;
@@ -43,6 +46,8 @@ export interface StudioActions {
43
46
  /** A person's answer to the paused turn's card: true, or the refusal sentence. */
44
47
  answerPermission?: (chat: string, card: string, answer: 'once' | 'always' | 'deny') => Promise<true | string>;
45
48
  approvePrototype?: (change: string, version: number) => unknown;
49
+ /** Structure's Which surface comes first, written into the structure file's header. */
50
+ chooseSurface?: (surface: 'desktop' | 'phone') => unknown;
46
51
  approvePlaces?: (change: string, revision: string) => unknown;
47
52
  approve?: (direction: string, fingerprint: string) => unknown;
48
53
  approveRelease?: (id: string, server: ServerForm) => Promise<unknown>;
@@ -71,6 +76,8 @@ export interface StudioActions {
71
76
  retryTurn?: (chat: string) => Promise<unknown>;
72
77
  holdMerges?: (held: boolean) => Promise<unknown>;
73
78
  removeWorktree: (change: string) => Promise<unknown>;
79
+ /** A fresh agent's turns: the review before Save and the critique (fresh.ts). */
80
+ fresh?: FreshActions;
74
81
  save: (step: SaveStep, fingerprint?: string, files?: readonly string[], change?: string) => Promise<SaveResult>;
75
82
  }
76
83
  /** The same commands as the old workbench; only the view changes. */
@@ -72,6 +72,7 @@ export function studioActions(post, prototypeScenes, prototypeHome, previewMerge
72
72
  return studioRefusal(reply) ?? '';
73
73
  },
74
74
  approvePrototype: (change, version) => post('/api/approve', { kind: 'prototype', change, version }),
75
+ chooseSurface: (surface) => post('/api/structure/surface', { surface }),
75
76
  approvePlaces: (change, revision) => post('/api/approve', { kind: 'places', change }, undefined, undefined, revision),
76
77
  approve: (direction, fingerprint) => post('/api/approve', { kind: 'brand', direction, fingerprint }),
77
78
  approveRelease: async (id, server) => {
@@ -79,6 +79,7 @@ export declare function useEcho(chat: Chat, post: (text: string, waitForRefresh?
79
79
  targets: string[];
80
80
  refused?: boolean | undefined;
81
81
  reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
82
+ limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
82
83
  } | undefined;
83
84
  permission?: {
84
85
  path: string;
@@ -174,6 +175,7 @@ export declare function useChatRead(props: StudioAppProps, id: string | null | u
174
175
  targets: string[];
175
176
  refused?: boolean | undefined;
176
177
  reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
178
+ limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
177
179
  } | undefined;
178
180
  permission?: {
179
181
  path: string;
@@ -123,6 +123,7 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
123
123
  targets: string[];
124
124
  refused?: boolean | undefined;
125
125
  reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
126
+ limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
126
127
  } | undefined;
127
128
  permission?: {
128
129
  path: string;
@@ -224,6 +225,7 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
224
225
  targets: string[];
225
226
  refused?: boolean | undefined;
226
227
  reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
228
+ limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
227
229
  } | undefined;
228
230
  permission?: {
229
231
  path: string;
@@ -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
+ }
@@ -34,7 +34,7 @@ interface PlacesValue {
34
34
  export declare const usePlaces: () => PlacesValue | null;
35
35
  /** Only the two approvals in today's facts can supply a record; the rest stay unknown. */
36
36
  export declare function placeApproval(id: PlaceId, state: StudioState): {
37
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
37
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
38
38
  signatures: {
39
39
  by: string;
40
40
  at: string;
@@ -0,0 +1,46 @@
1
+ import { type PrototypeCompReply } from '@buffcore/contracts/workbench';
2
+ export interface CompReads {
3
+ read: (signal?: AbortSignal) => Promise<PrototypeCompReply | undefined>;
4
+ picture: (name: string, signal?: AbortSignal) => Promise<Blob | undefined>;
5
+ approve: (fingerprint: string) => Promise<unknown>;
6
+ }
7
+ export declare function compReads(fetch: typeof globalThis.fetch, headers: Record<string, string>, post: (path: string, body: unknown) => Promise<unknown>): CompReads;
8
+ export declare function usePrototypeComp(reads: CompReads | undefined, every?: number): {
9
+ reply: {
10
+ surface: "desktop" | "phone";
11
+ width: number;
12
+ screens: {
13
+ key: string;
14
+ title: string;
15
+ light?: string | undefined;
16
+ dark?: string | undefined;
17
+ }[];
18
+ references: (string | null)[];
19
+ fingerprint?: string | undefined;
20
+ approved: boolean;
21
+ approval: {
22
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
23
+ signatures: {
24
+ by: string;
25
+ at: string;
26
+ commit: string;
27
+ fingerprint: string;
28
+ role?: string | undefined;
29
+ agent?: string | undefined;
30
+ }[];
31
+ rule?: {
32
+ kind: "one";
33
+ of: string[];
34
+ } | {
35
+ kind: "two";
36
+ of: string[];
37
+ } | {
38
+ kind: "majority";
39
+ of: string[];
40
+ by: string;
41
+ } | undefined;
42
+ } | null;
43
+ } | undefined;
44
+ pictures: Record<string, string>;
45
+ reload: () => void | undefined;
46
+ };
@@ -0,0 +1,77 @@
1
+ // The comp page's reads: the comp (screens, references, approval) and each picture by name, as
2
+ // object addresses the page draws. Re-read while the page is open, so a redrawn comp shows.
3
+ import { prototypeCompReplySchema, workbenchApi, } from '@buffcore/contracts/workbench';
4
+ import { useEffect, useRef, useState } from 'react';
5
+ export function compReads(fetch, headers, post) {
6
+ return {
7
+ read: async (signal) => {
8
+ try {
9
+ const res = await fetch(workbenchApi.prototypeComp, { headers, signal });
10
+ return res.ok ? prototypeCompReplySchema.parse(await res.json()) : undefined;
11
+ }
12
+ catch {
13
+ return undefined;
14
+ }
15
+ },
16
+ picture: async (name, signal) => {
17
+ const res = await fetch(`${workbenchApi.prototypeComp}/picture/${encodeURIComponent(name)}`, {
18
+ headers,
19
+ signal,
20
+ });
21
+ return res.ok ? res.blob() : undefined;
22
+ },
23
+ approve: (fingerprint) => post('/api/approve', { kind: 'comp', fingerprint }),
24
+ };
25
+ }
26
+ /** The pictures' names a reply asks for, with what makes each one new (the comp's fingerprint). */
27
+ const wanted = (reply) => [
28
+ ...reply.screens.flatMap((screen) => [screen.light, screen.dark].filter((n) => n !== undefined)),
29
+ ...reply.references.filter((name) => name !== null),
30
+ ];
31
+ export function usePrototypeComp(reads, every = 5000) {
32
+ const [reply, setReply] = useState();
33
+ const load = useRef(undefined);
34
+ useEffect(() => {
35
+ if (!reads)
36
+ return;
37
+ const request = new AbortController();
38
+ load.current = () => void reads.read(request.signal).then((next) => {
39
+ if (next && !request.signal.aborted)
40
+ setReply(next);
41
+ });
42
+ load.current();
43
+ const timer = setInterval(load.current, every);
44
+ return () => {
45
+ request.abort();
46
+ clearInterval(timer);
47
+ };
48
+ }, [reads, every]);
49
+ // The pictures are read again only when the comp or its references change.
50
+ const key = reply ? JSON.stringify([reply.fingerprint, wanted(reply)]) : '';
51
+ const [pictures, setPictures] = useState();
52
+ useEffect(() => {
53
+ if (!reads || !key)
54
+ return;
55
+ const [, names] = JSON.parse(key);
56
+ const request = new AbortController();
57
+ const urls = {};
58
+ void Promise.all(names.map(async (name) => {
59
+ const blob = await reads.picture(name, request.signal).catch(() => undefined);
60
+ if (blob && !request.signal.aborted)
61
+ urls[name] = URL.createObjectURL(blob);
62
+ })).then(() => {
63
+ if (!request.signal.aborted)
64
+ setPictures({ key, urls });
65
+ });
66
+ return () => {
67
+ request.abort();
68
+ for (const url of Object.values(urls))
69
+ URL.revokeObjectURL(url);
70
+ };
71
+ }, [reads, key]);
72
+ return {
73
+ reply,
74
+ pictures: pictures?.key === key ? pictures.urls : {},
75
+ reload: () => load.current?.(),
76
+ };
77
+ }
@@ -34,4 +34,4 @@ export declare function commentMessage(comment: PrototypeComment, t: T, locale:
34
34
  export declare function openPrototype(state: StudioState): string;
35
35
  export declare function protoView(state: StudioState, change: string, ui: PrototypeUi): ProtoView;
36
36
  /** Empty fields stay empty; the served page never borrows the playground's sample product. */
37
- export declare function protoSample(state: StudioState, change: string, ui?: PrototypeUi, scenes?: readonly PrototypeSceneMetadata[]): PrototypeSample;
37
+ export declare function protoSample(state: StudioState, change: string, ui?: PrototypeUi, listed?: readonly PrototypeSceneMetadata[]): PrototypeSample;
@@ -106,7 +106,9 @@ function comparison(state, change, pair, t = agentT) {
106
106
  }
107
107
  const EMPTY_SCENES = { empty: '', loading: '', error: '', console: '', tablet: '' };
108
108
  /** Empty fields stay empty; the served page never borrows the playground's sample product. */
109
- export function protoSample(state, change, ui = {}, scenes = []) {
109
+ export function protoSample(state, change, ui = {}, listed = []) {
110
+ // The comp's scenes (`comp/`) are the look's proof, never an app screen to open or list.
111
+ const scenes = listed.filter((scene) => !scene.key.startsWith('comp/'));
110
112
  const record = state.versions?.find((entry) => entry.change === change);
111
113
  const plan = state.plan?.changes.find((entry) => entry.id === change);
112
114
  const saved = state.work?.autopilot?.findLast((choice) => choice.step === 'prototype' && choice.change === change);
@@ -32,6 +32,7 @@ export declare function loopApi(initial?: {
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
34
  neverAsk?: boolean | undefined;
35
+ review?: boolean | undefined;
35
36
  } | null;
36
37
  found: {
37
38
  id: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
@@ -86,7 +87,7 @@ export declare function loopApi(initial?: {
86
87
  approved?: {
87
88
  version: number;
88
89
  approval: {
89
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
90
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
90
91
  signatures: {
91
92
  by: string;
92
93
  at: string;
@@ -111,7 +112,7 @@ export declare function loopApi(initial?: {
111
112
  pending?: {
112
113
  version: number;
113
114
  approval: {
114
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
115
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
115
116
  signatures: {
116
117
  by: string;
117
118
  at: string;
@@ -136,7 +137,7 @@ export declare function loopApi(initial?: {
136
137
  superseded?: {
137
138
  version: number;
138
139
  approval: {
139
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
140
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
140
141
  signatures: {
141
142
  by: string;
142
143
  at: string;
@@ -232,12 +233,13 @@ export declare function loopApi(initial?: {
232
233
  planned?: string | undefined;
233
234
  }[];
234
235
  notes: string[];
236
+ surface?: "desktop" | "phone" | undefined;
235
237
  problem?: string | undefined;
236
238
  } | null | undefined;
237
239
  themeDirection?: string | undefined;
238
240
  themeVoice?: string | undefined;
239
241
  brand: {
240
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
242
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
241
243
  signatures: {
242
244
  by: string;
243
245
  at: string;
@@ -438,6 +440,7 @@ export declare function loopApi(initial?: {
438
440
  targets: string[];
439
441
  refused?: boolean | undefined;
440
442
  reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
443
+ limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
441
444
  } | undefined;
442
445
  permission?: {
443
446
  path: string;
@@ -486,6 +489,7 @@ export declare function loopApi(initial?: {
486
489
  effort?: Partial<Record<"coding" | "design" | "fixes" | "planning" | "tests" | "validation", "auto" | "high" | "low" | "max" | "medium" | "xhigh">> | undefined;
487
490
  level: "auto" | "guide" | "lead" | "review";
488
491
  neverAsk?: boolean | undefined;
492
+ review?: boolean | undefined;
489
493
  } | null;
490
494
  found: {
491
495
  id: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
@@ -540,7 +544,7 @@ export declare function loopApi(initial?: {
540
544
  approved?: {
541
545
  version: number;
542
546
  approval: {
543
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
547
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
544
548
  signatures: {
545
549
  by: string;
546
550
  at: string;
@@ -565,7 +569,7 @@ export declare function loopApi(initial?: {
565
569
  pending?: {
566
570
  version: number;
567
571
  approval: {
568
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
572
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
569
573
  signatures: {
570
574
  by: string;
571
575
  at: string;
@@ -590,7 +594,7 @@ export declare function loopApi(initial?: {
590
594
  superseded?: {
591
595
  version: number;
592
596
  approval: {
593
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
597
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
594
598
  signatures: {
595
599
  by: string;
596
600
  at: string;
@@ -686,12 +690,13 @@ export declare function loopApi(initial?: {
686
690
  planned?: string | undefined;
687
691
  }[];
688
692
  notes: string[];
693
+ surface?: "desktop" | "phone" | undefined;
689
694
  problem?: string | undefined;
690
695
  } | null | undefined;
691
696
  themeDirection?: string | undefined;
692
697
  themeVoice?: string | undefined;
693
698
  brand: {
694
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
699
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
695
700
  signatures: {
696
701
  by: string;
697
702
  at: string;