@buffcore/admin-shell 0.8.42 → 0.8.44
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.
- package/dist/screens/assistant/use-ask.d.ts +4 -3
- package/dist/workbench/app/ServedAgents.js +4 -1
- package/dist/workbench/app/ServedComp.d.ts +3 -0
- package/dist/workbench/app/ServedComp.js +33 -0
- package/dist/workbench/app/ServedPrototype.d.ts +2 -0
- package/dist/workbench/app/ServedPrototype.js +15 -1
- package/dist/workbench/app/__snapshots__/places-dom.test.tsx.snap +30 -3
- package/dist/workbench/app/actions.d.ts +7 -0
- package/dist/workbench/app/actions.js +1 -0
- package/dist/workbench/app/chat-session.d.ts +2 -0
- package/dist/workbench/app/chat.d.ts +2 -0
- package/dist/workbench/app/frame.js +5 -1
- package/dist/workbench/app/fresh.d.ts +63 -0
- package/dist/workbench/app/fresh.js +66 -0
- package/dist/workbench/app/pages.js +10 -2
- package/dist/workbench/app/places.d.ts +1 -1
- package/dist/workbench/app/prototype-comp.d.ts +46 -0
- package/dist/workbench/app/prototype-comp.js +77 -0
- package/dist/workbench/app/prototype.d.ts +1 -1
- package/dist/workbench/app/prototype.js +3 -1
- package/dist/workbench/app/test/loop-fixture.d.ts +15 -8
- package/dist/workbench/app/useStudio.d.ts +43 -1
- package/dist/workbench/app/useStudio.js +8 -1
- package/dist/workbench/app/work.d.ts +7 -7
- package/dist/workbench/studio/frame/Composer.js +13 -10
- package/dist/workbench/studio/frame/LimitCard.d.ts +5 -0
- package/dist/workbench/studio/frame/LimitCard.js +26 -0
- package/dist/workbench/studio/frame/PanelMessage.js +3 -0
- package/dist/workbench/studio/frame/SettingsSheet.js +10 -9
- package/dist/workbench/studio/frame/StudioFrame.js +4 -3
- package/dist/workbench/studio/frame/panelLines.d.ts +1 -0
- package/dist/workbench/studio/frame/panelLines.js +2 -1
- package/dist/workbench/studio/frame/scrollbars.d.ts +1 -0
- package/dist/workbench/studio/frame/scrollbars.js +10 -0
- package/dist/workbench/studio/frame/useTurnDraft.d.ts +2 -0
- package/dist/workbench/studio/frame/useTurnDraft.js +12 -9
- package/dist/workbench/studio/i18n/comp.en.d.ts +26 -0
- package/dist/workbench/studio/i18n/comp.en.js +26 -0
- package/dist/workbench/studio/i18n/comp.es.d.ts +26 -0
- package/dist/workbench/studio/i18n/comp.es.js +25 -0
- package/dist/workbench/studio/i18n/frame.en.d.ts +16 -0
- package/dist/workbench/studio/i18n/frame.en.js +16 -0
- package/dist/workbench/studio/i18n/frame.es.json +17 -1
- package/dist/workbench/studio/i18n/fresh.en.d.ts +19 -0
- package/dist/workbench/studio/i18n/fresh.en.js +20 -0
- package/dist/workbench/studio/i18n/fresh.es.json +18 -0
- package/dist/workbench/studio/i18n/index.js +6 -0
- package/dist/workbench/studio/loop/AgentsPage.d.ts +4 -1
- package/dist/workbench/studio/loop/AgentsPage.js +5 -4
- package/dist/workbench/studio/loop/CritiqueNote.d.ts +4 -0
- package/dist/workbench/studio/loop/CritiqueNote.js +9 -0
- package/dist/workbench/studio/loop/FreshLookPanel.d.ts +21 -0
- package/dist/workbench/studio/loop/FreshLookPanel.js +60 -0
- package/dist/workbench/studio/loop/PrototypeApp.d.ts +9 -0
- package/dist/workbench/studio/loop/PrototypeApp.js +6 -4
- package/dist/workbench/studio/loop/PrototypeAttempt.d.ts +2 -1
- package/dist/workbench/studio/loop/PrototypeAttempt.js +40 -16
- package/dist/workbench/studio/loop/PrototypeComp.d.ts +25 -0
- package/dist/workbench/studio/loop/PrototypeComp.js +78 -0
- package/dist/workbench/studio/loop/PrototypePage.d.ts +7 -0
- package/dist/workbench/studio/loop/PrototypePage.js +1 -1
- package/dist/workbench/studio/loop/PrototypePreview.js +34 -29
- package/dist/workbench/studio/loop/PrototypeSimplePage.js +11 -4
- package/dist/workbench/studio/loop/PrototypeSnapshot.d.ts +3 -0
- package/dist/workbench/studio/loop/PrototypeSnapshot.js +2 -1
- package/dist/workbench/studio/loop/ReviewSetting.d.ts +6 -0
- package/dist/workbench/studio/loop/ReviewSetting.js +14 -0
- package/dist/workbench/studio/loop/SaveStep.d.ts +3 -0
- package/dist/workbench/studio/loop/SaveStep.js +3 -1
- package/dist/workbench/studio/loop/ServedPlanning.js +1 -1
- package/dist/workbench/studio/loop/StructurePage.d.ts +5 -0
- package/dist/workbench/studio/loop/StructurePage.js +3 -2
- package/dist/workbench/studio/loop/SurfaceChoice.d.ts +7 -0
- package/dist/workbench/studio/loop/SurfaceChoice.js +20 -0
- package/dist/workbench/studio/loop/prototype-bridge.d.ts +8 -0
- package/dist/workbench/studio/loop/prototype-bridge.js +16 -0
- package/dist/workbench/studio/loop/prototype-document.d.ts +7 -0
- package/dist/workbench/studio/loop/prototype-document.js +78 -2
- package/dist/workbench/studio/loop/usePlanningDraft.js +5 -1
- package/dist/workbench/studio/loop/usePrototypeFrame.d.ts +3 -1
- package/dist/workbench/studio/loop/usePrototypeFrame.js +2 -0
- package/dist/workbench/studio/types.d.ts +2 -0
- package/dist/workbench/studio/work/work-test-data.d.ts +7 -4
- package/package.json +6 -6
|
@@ -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?: "approval" | "commit" | "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?: "approval" | "commit" | "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?: "approval" | "commit" | "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?: "approval" | "commit" | "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
227
229
|
} | undefined;
|
|
228
230
|
permission?: {
|
|
229
231
|
path: string;
|
|
@@ -56,7 +56,11 @@ export function frameProps(state, ui) {
|
|
|
56
56
|
const level = state.agents.file?.level ?? 'guide';
|
|
57
57
|
return {
|
|
58
58
|
onSend: ui.onSend,
|
|
59
|
-
product: {
|
|
59
|
+
product: {
|
|
60
|
+
...state.product,
|
|
61
|
+
agent: footLine(state, ui.t),
|
|
62
|
+
...(state.hostLaunched ? { hostLaunched: true } : {}),
|
|
63
|
+
},
|
|
60
64
|
level,
|
|
61
65
|
onLevel: (value) => ui.actions.level(value),
|
|
62
66
|
rail: { form: 'loop', stage: 'brief' },
|
|
@@ -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
|
+
}
|
|
@@ -43,6 +43,14 @@ export function StudioPages(props) {
|
|
|
43
43
|
pickJourney(id);
|
|
44
44
|
props.actions.go?.('prototype');
|
|
45
45
|
};
|
|
46
|
+
const onPlayed = () => pickJourney(undefined);
|
|
47
|
+
// A Play request lives only until the person leaves Prototype, so it never starts later.
|
|
48
|
+
const shown = useRef(props.page);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (shown.current === 'prototype' && props.page !== 'prototype')
|
|
51
|
+
pickJourney(undefined);
|
|
52
|
+
shown.current = props.page;
|
|
53
|
+
}, [props.page]);
|
|
46
54
|
return (_jsxs(_Fragment, { children: [_jsx(AutoChoices, { viewer: props.state.viewer, choices: props.state.work?.autopilot, page: props.page, onChange: props.onStep &&
|
|
47
55
|
((choice) => props.onStep?.({
|
|
48
56
|
page: choice.step,
|
|
@@ -50,7 +58,7 @@ export function StudioPages(props) {
|
|
|
50
58
|
change: choice.change,
|
|
51
59
|
}, t('studio.auto.changeRequest', {
|
|
52
60
|
step: t(`studio.frame.page.${choice.step === 'merge' ? 'work' : choice.step}`),
|
|
53
|
-
}))) }), _jsx(PageRoute, { ...props, change: change, onChange: props.onChange ?? pickChange, journey: journey, onPlay: onPlay, server: server, onServer: onServer, iconSrc: iconSrc, work: { ui: workUi, onUi: onWorkUi, position: workPosition } })] }));
|
|
61
|
+
}))) }), _jsx(PageRoute, { ...props, change: change, onChange: props.onChange ?? pickChange, journey: journey, onPlay: onPlay, onPlayed: onPlayed, server: server, onServer: onServer, iconSrc: iconSrc, work: { ui: workUi, onUi: onWorkUi, position: workPosition } })] }));
|
|
54
62
|
}
|
|
55
63
|
function PageRoute(props) {
|
|
56
64
|
const { state, page, actions, onComment, onStep, journey, onPlay, server, onServer } = props;
|
|
@@ -63,7 +71,7 @@ function PageRoute(props) {
|
|
|
63
71
|
if (page === 'prototype')
|
|
64
72
|
return (_jsx(ServedPrototype, { every: props.every, change: props.change, version: props.work.position.current.opener === props.change
|
|
65
73
|
? props.work.position.current.version
|
|
66
|
-
: undefined, prototypeTurn: props.prototypeTurn, state: state, actions: actions, onComment: onComment, onStep: onStep, journey: journey }));
|
|
74
|
+
: undefined, prototypeTurn: props.prototypeTurn, state: state, actions: actions, onComment: onComment, onStep: onStep, journey: journey, onPlayed: props.onPlayed }));
|
|
67
75
|
// Fresh means chats known to be none; chats the viewer cannot read are unknown, so the Brief.
|
|
68
76
|
if (page === 'brief' && !briefHasContent(state) && state.chats?.length === 0)
|
|
69
77
|
return _jsx(ServedStart, { state: state, actions: actions, onStep: onStep, onLevel: props.onLevel });
|
|
@@ -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,
|
|
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 = {},
|
|
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);
|
|
@@ -8,6 +8,7 @@ export declare function LoopLocale({ children, locale }: {
|
|
|
8
8
|
}): import("react").JSX.Element;
|
|
9
9
|
export declare function loopApi(initial?: {
|
|
10
10
|
contained?: boolean | undefined;
|
|
11
|
+
hostLaunched?: boolean | undefined;
|
|
11
12
|
viewer?: {
|
|
12
13
|
name: string;
|
|
13
14
|
email?: string | undefined;
|
|
@@ -32,6 +33,7 @@ export declare function loopApi(initial?: {
|
|
|
32
33
|
effort?: Partial<Record<"coding" | "design" | "fixes" | "planning" | "tests" | "validation", "auto" | "high" | "low" | "max" | "medium" | "xhigh">> | undefined;
|
|
33
34
|
level: "auto" | "guide" | "lead" | "review";
|
|
34
35
|
neverAsk?: boolean | undefined;
|
|
36
|
+
review?: boolean | undefined;
|
|
35
37
|
} | null;
|
|
36
38
|
found: {
|
|
37
39
|
id: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
|
|
@@ -86,7 +88,7 @@ export declare function loopApi(initial?: {
|
|
|
86
88
|
approved?: {
|
|
87
89
|
version: number;
|
|
88
90
|
approval: {
|
|
89
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
91
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
90
92
|
signatures: {
|
|
91
93
|
by: string;
|
|
92
94
|
at: string;
|
|
@@ -111,7 +113,7 @@ export declare function loopApi(initial?: {
|
|
|
111
113
|
pending?: {
|
|
112
114
|
version: number;
|
|
113
115
|
approval: {
|
|
114
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
116
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
115
117
|
signatures: {
|
|
116
118
|
by: string;
|
|
117
119
|
at: string;
|
|
@@ -136,7 +138,7 @@ export declare function loopApi(initial?: {
|
|
|
136
138
|
superseded?: {
|
|
137
139
|
version: number;
|
|
138
140
|
approval: {
|
|
139
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
141
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
140
142
|
signatures: {
|
|
141
143
|
by: string;
|
|
142
144
|
at: string;
|
|
@@ -232,12 +234,13 @@ export declare function loopApi(initial?: {
|
|
|
232
234
|
planned?: string | undefined;
|
|
233
235
|
}[];
|
|
234
236
|
notes: string[];
|
|
237
|
+
surface?: "desktop" | "phone" | undefined;
|
|
235
238
|
problem?: string | undefined;
|
|
236
239
|
} | null | undefined;
|
|
237
240
|
themeDirection?: string | undefined;
|
|
238
241
|
themeVoice?: string | undefined;
|
|
239
242
|
brand: {
|
|
240
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
243
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
241
244
|
signatures: {
|
|
242
245
|
by: string;
|
|
243
246
|
at: string;
|
|
@@ -438,6 +441,7 @@ export declare function loopApi(initial?: {
|
|
|
438
441
|
targets: string[];
|
|
439
442
|
refused?: boolean | undefined;
|
|
440
443
|
reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
|
|
444
|
+
limit?: "approval" | "commit" | "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
441
445
|
} | undefined;
|
|
442
446
|
permission?: {
|
|
443
447
|
path: string;
|
|
@@ -462,6 +466,7 @@ export declare function loopApi(initial?: {
|
|
|
462
466
|
}>;
|
|
463
467
|
initial: {
|
|
464
468
|
contained?: boolean | undefined;
|
|
469
|
+
hostLaunched?: boolean | undefined;
|
|
465
470
|
viewer?: {
|
|
466
471
|
name: string;
|
|
467
472
|
email?: string | undefined;
|
|
@@ -486,6 +491,7 @@ export declare function loopApi(initial?: {
|
|
|
486
491
|
effort?: Partial<Record<"coding" | "design" | "fixes" | "planning" | "tests" | "validation", "auto" | "high" | "low" | "max" | "medium" | "xhigh">> | undefined;
|
|
487
492
|
level: "auto" | "guide" | "lead" | "review";
|
|
488
493
|
neverAsk?: boolean | undefined;
|
|
494
|
+
review?: boolean | undefined;
|
|
489
495
|
} | null;
|
|
490
496
|
found: {
|
|
491
497
|
id: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
|
|
@@ -540,7 +546,7 @@ export declare function loopApi(initial?: {
|
|
|
540
546
|
approved?: {
|
|
541
547
|
version: number;
|
|
542
548
|
approval: {
|
|
543
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
549
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
544
550
|
signatures: {
|
|
545
551
|
by: string;
|
|
546
552
|
at: string;
|
|
@@ -565,7 +571,7 @@ export declare function loopApi(initial?: {
|
|
|
565
571
|
pending?: {
|
|
566
572
|
version: number;
|
|
567
573
|
approval: {
|
|
568
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
574
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
569
575
|
signatures: {
|
|
570
576
|
by: string;
|
|
571
577
|
at: string;
|
|
@@ -590,7 +596,7 @@ export declare function loopApi(initial?: {
|
|
|
590
596
|
superseded?: {
|
|
591
597
|
version: number;
|
|
592
598
|
approval: {
|
|
593
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
599
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
594
600
|
signatures: {
|
|
595
601
|
by: string;
|
|
596
602
|
at: string;
|
|
@@ -686,12 +692,13 @@ export declare function loopApi(initial?: {
|
|
|
686
692
|
planned?: string | undefined;
|
|
687
693
|
}[];
|
|
688
694
|
notes: string[];
|
|
695
|
+
surface?: "desktop" | "phone" | undefined;
|
|
689
696
|
problem?: string | undefined;
|
|
690
697
|
} | null | undefined;
|
|
691
698
|
themeDirection?: string | undefined;
|
|
692
699
|
themeVoice?: string | undefined;
|
|
693
700
|
brand: {
|
|
694
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
701
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
695
702
|
signatures: {
|
|
696
703
|
by: string;
|
|
697
704
|
at: string;
|
|
@@ -12,5 +12,47 @@ export declare function useStudio({ token, fetch, every }: StudioAppProps): {
|
|
|
12
12
|
age: string | number | undefined;
|
|
13
13
|
trouble: Trouble | null;
|
|
14
14
|
detail: Notice | undefined;
|
|
15
|
-
actions:
|
|
15
|
+
actions: {
|
|
16
|
+
prototypeHome?: import('./prototype-home.ts').HomeRead;
|
|
17
|
+
snapshot?: (request: import("./prototype-snapshot.ts").SnapshotRequest, signal?: AbortSignal) => Promise<import("./prototype-snapshot.ts").SnapshotRead | undefined>;
|
|
18
|
+
checkAgents?: (signal?: AbortSignal) => Promise<import("@buffcore/contracts/workbench").FoundAgent[] | undefined>;
|
|
19
|
+
prototypeScenes?: (signal?: AbortSignal) => Promise<import("@buffcore/contracts/workbench").PrototypeScenesReply>;
|
|
20
|
+
go?: (page: import("../index.ts").StudioPage) => void;
|
|
21
|
+
readIcon?: (signal: AbortSignal) => Promise<Blob | undefined>;
|
|
22
|
+
uploadIcon?: (file: File) => Promise<unknown>;
|
|
23
|
+
run: (id: string, server?: import("../types.ts").ServerForm) => unknown;
|
|
24
|
+
stack: (action: 'start' | 'stop') => void;
|
|
25
|
+
level: (level: (typeof import("@buffcore/contracts/workbench").LEVELS)[number], neverAsk?: boolean) => void;
|
|
26
|
+
answerPermission?: (chat: string, card: string, answer: 'once' | 'always' | 'deny') => Promise<true | string>;
|
|
27
|
+
approvePrototype?: (change: string, version: number) => unknown;
|
|
28
|
+
chooseSurface?: (surface: 'desktop' | 'phone') => unknown;
|
|
29
|
+
approvePlaces?: (change: string, revision: string) => unknown;
|
|
30
|
+
approve?: (direction: string, fingerprint: string) => unknown;
|
|
31
|
+
approveRelease?: (id: string, server: import("../types.ts").ServerForm) => Promise<unknown>;
|
|
32
|
+
catchUp?: (change: string) => Promise<unknown>;
|
|
33
|
+
send: (id: string, text: string, waitForRefresh?: false) => Promise<boolean>;
|
|
34
|
+
newChat: (body: import("@buffcore/contracts/workbench").NewChat) => Promise<import("@buffcore/contracts/workbench").Chat | undefined>;
|
|
35
|
+
allowFolder?: (id: string, at: number) => Promise<true | string>;
|
|
36
|
+
platformsWanted?: {
|
|
37
|
+
current?: {
|
|
38
|
+
ios: boolean;
|
|
39
|
+
android: boolean;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
stop: (id: string, confirm?: boolean, signal?: AbortSignal) => Promise<import('zod').infer<typeof import("@buffcore/contracts/workbench").stopAnswer> | undefined>;
|
|
43
|
+
answerInChat?: (question: string, key?: string) => void;
|
|
44
|
+
chooseQuestion?: (question: string, number?: number) => void;
|
|
45
|
+
questionChoices?: Record<string, import("./question-transcript.ts").QuestionChoice>;
|
|
46
|
+
questionBusy?: boolean;
|
|
47
|
+
setAgents: (assignment: import("@buffcore/contracts/workbench").AgentAssignment) => void;
|
|
48
|
+
merge: (change: string) => Promise<unknown>;
|
|
49
|
+
markBuilt?: (change: string, version: number, commit: string) => Promise<import("./actions.ts").SaveResult>;
|
|
50
|
+
previewMerge?: (change: string, signal: AbortSignal) => Promise<import("@buffcore/contracts/workbench").MergePreview | undefined>;
|
|
51
|
+
retryTurn?: (chat: string) => Promise<unknown>;
|
|
52
|
+
holdMerges?: (held: boolean) => Promise<unknown>;
|
|
53
|
+
removeWorktree: (change: string) => Promise<unknown>;
|
|
54
|
+
fresh?: import("./fresh.ts").FreshActions;
|
|
55
|
+
save: (step: import("./actions.ts").SaveStep, fingerprint?: string, files?: readonly string[], change?: string) => Promise<import("./actions.ts").SaveResult>;
|
|
56
|
+
comp: import("./prototype-comp.ts").CompReads;
|
|
57
|
+
};
|
|
16
58
|
};
|
|
@@ -2,7 +2,9 @@ import { chatSchema, localTokenRefusalSchema, studioStateSchema, workbenchApi, }
|
|
|
2
2
|
import { useT } from '@buffcore/i18n/react';
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { studioActions } from './actions.js';
|
|
5
|
+
import { freshActions } from './fresh.js';
|
|
5
6
|
import { mergePreviewRead } from './merge-preview.js';
|
|
7
|
+
import { compReads } from './prototype-comp.js';
|
|
6
8
|
import { prototypeHomeRead } from './prototype-home.js';
|
|
7
9
|
import { prototypeScenesRead } from './prototype-scenes.js';
|
|
8
10
|
import { studioPost, studioReadNotice } from './studio-post.js';
|
|
@@ -114,6 +116,11 @@ export function useStudio({ token, fetch = globalThis.fetch, every }) {
|
|
|
114
116
|
// A check and a poll publish into the same state in the order their answers arrive.
|
|
115
117
|
setLastRead((held) => held && { ...held, agents: { ...held.agents, found } });
|
|
116
118
|
});
|
|
119
|
+
actions.fresh = freshActions(fetch, headers, post);
|
|
120
|
+
// The comp's reads keep one identity; its approval posts through the latest `send`.
|
|
121
|
+
const latestSend = useRef(send);
|
|
122
|
+
latestSend.current = send;
|
|
123
|
+
const comp = useMemo(() => compReads(fetch, headers, (path, body) => latestSend.current(path, body)), [fetch, headers]);
|
|
117
124
|
return {
|
|
118
125
|
state,
|
|
119
126
|
gate,
|
|
@@ -123,7 +130,7 @@ export function useStudio({ token, fetch = globalThis.fetch, every }) {
|
|
|
123
130
|
age,
|
|
124
131
|
trouble,
|
|
125
132
|
detail,
|
|
126
|
-
actions,
|
|
133
|
+
actions: { ...actions, comp },
|
|
127
134
|
};
|
|
128
135
|
}
|
|
129
136
|
function withoutLevels(state) {
|