@buffcore/admin-shell 0.8.43 → 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/workbench/app/ServedPrototype.d.ts +2 -0
- package/dist/workbench/app/ServedPrototype.js +6 -1
- package/dist/workbench/app/__snapshots__/places-dom.test.tsx.snap +30 -3
- package/dist/workbench/app/chat-session.d.ts +2 -2
- package/dist/workbench/app/chat.d.ts +2 -2
- package/dist/workbench/app/frame.js +5 -1
- package/dist/workbench/app/pages.js +10 -2
- package/dist/workbench/app/test/loop-fixture.d.ts +3 -1
- package/dist/workbench/studio/frame/Composer.js +13 -10
- package/dist/workbench/studio/frame/SettingsSheet.js +10 -9
- package/dist/workbench/studio/frame/StudioFrame.js +4 -3
- 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/frame.en.d.ts +3 -0
- package/dist/workbench/studio/i18n/frame.en.js +4 -1
- package/dist/workbench/studio/i18n/frame.es.json +4 -1
- 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/PrototypePreview.js +34 -29
- 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/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 +1 -0
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PROTOTYPE_LIVENESS, PROTOTYPE_WAIT, prototypeHeartbeat, prototypeHello, prototypeNavigationId, prototypeReply, } from './prototype-bridge.js';
|
|
1
|
+
import { PROTOTYPE_LIVENESS, PROTOTYPE_WAIT, prototypeHeartbeat, prototypeHello, prototypeNavigationId, prototypePlayer, prototypeReply, } from './prototype-bridge.js';
|
|
2
2
|
/** A deadline seen later than this (ms) was missed by the page, not by the app. */
|
|
3
3
|
const LATE_SLACK = 1_000;
|
|
4
4
|
/* Event x state -> readiness / nonce issued / controls / deadline
|
|
@@ -25,6 +25,11 @@ const LATE_SLACK = 1_000;
|
|
|
25
25
|
* Error/refused reply or hello -> failed / revoke port+nonce / off / cancel
|
|
26
26
|
* Failed/closed + hello or beat -> unchanged; restart needs a new session
|
|
27
27
|
* Disposal -> closed / revoke port+nonce / off / cancel
|
|
28
|
+
* Player note on that port -> this document plays show messages (an older app sends none)
|
|
29
|
+
* Later reply on that port -> only its step caption is taken; journeys and controls unchanged
|
|
30
|
+
* show() on a player document -> kept as the wanted choice; sent on the current port once alive
|
|
31
|
+
* Hello again (the app reloaded) -> the wanted choice is sent again on the new port once alive
|
|
32
|
+
* show() otherwise, or failed -> false: nothing kept, the caller reloads the frame instead
|
|
28
33
|
* A nonce is not a capability: even one copied into name/storage cannot renew via window messages.
|
|
29
34
|
* Only that hello's port carries replies/beats; the app closes it and clears its nonce on pagehide.
|
|
30
35
|
*/
|
|
@@ -37,6 +42,10 @@ export function watchPrototypeDocument(input) {
|
|
|
37
42
|
let timedOutSilently = false;
|
|
38
43
|
let phase = 'waiting';
|
|
39
44
|
let published = false;
|
|
45
|
+
/** This document said it plays show messages; the choice it should show; what was sent to it. */
|
|
46
|
+
let player = false;
|
|
47
|
+
let wanted;
|
|
48
|
+
let sent;
|
|
40
49
|
let deadline = 0;
|
|
41
50
|
let timer;
|
|
42
51
|
const revoke = () => {
|
|
@@ -124,6 +133,8 @@ export function watchPrototypeDocument(input) {
|
|
|
124
133
|
forgiven = false;
|
|
125
134
|
discovery = undefined;
|
|
126
135
|
published = false;
|
|
136
|
+
player = false;
|
|
137
|
+
sent = undefined;
|
|
127
138
|
nonce = prototypeNavigationId();
|
|
128
139
|
port = hello.port;
|
|
129
140
|
input.publish({});
|
|
@@ -135,7 +146,17 @@ export function watchPrototypeDocument(input) {
|
|
|
135
146
|
return;
|
|
136
147
|
// Expiry turns controls off, but a valid late proof on this document's port can revive it.
|
|
137
148
|
lapsed();
|
|
138
|
-
|
|
149
|
+
if (prototypePlayer(message.data, expected)) {
|
|
150
|
+
player = true;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
// Once the journeys are known, only a later reply is read as one; heartbeats skip that parse.
|
|
154
|
+
const reply = discovery === undefined ||
|
|
155
|
+
(typeof message.data === 'string' && message.data.includes('"ape:prototype:reply"'))
|
|
156
|
+
? prototypeReply(message.data, expected)
|
|
157
|
+
: undefined;
|
|
158
|
+
if (reply && discovery !== undefined)
|
|
159
|
+
return caption(reply);
|
|
139
160
|
if (reply && 'cause' in reply)
|
|
140
161
|
return fail('reply', reply.cause);
|
|
141
162
|
if (reply) {
|
|
@@ -144,6 +165,7 @@ export function watchPrototypeDocument(input) {
|
|
|
144
165
|
if (phase === 'alive') {
|
|
145
166
|
published = true;
|
|
146
167
|
input.publish(discovery);
|
|
168
|
+
flush();
|
|
147
169
|
}
|
|
148
170
|
return;
|
|
149
171
|
}
|
|
@@ -159,6 +181,7 @@ export function watchPrototypeDocument(input) {
|
|
|
159
181
|
published = true;
|
|
160
182
|
input.publish(discovery);
|
|
161
183
|
}
|
|
184
|
+
flush();
|
|
162
185
|
};
|
|
163
186
|
current.start();
|
|
164
187
|
try {
|
|
@@ -174,12 +197,65 @@ export function watchPrototypeDocument(input) {
|
|
|
174
197
|
fail();
|
|
175
198
|
}
|
|
176
199
|
};
|
|
200
|
+
/**
|
|
201
|
+
* A later reply (the app re-sends one when its step changes) updates only the step caption: the
|
|
202
|
+
* journeys, liveness and controls stay as the first reply and the beats made them. A refused
|
|
203
|
+
* later reply is ignored, as before.
|
|
204
|
+
*/
|
|
205
|
+
const caption = (reply) => {
|
|
206
|
+
if (!discovery || !('discovery' in reply))
|
|
207
|
+
return;
|
|
208
|
+
const { stepCaption: old, ...rest } = discovery;
|
|
209
|
+
const next = reply.discovery.stepCaption;
|
|
210
|
+
if (JSON.stringify(old) === JSON.stringify(next))
|
|
211
|
+
return;
|
|
212
|
+
discovery = next ? { ...rest, stepCaption: next } : rest;
|
|
213
|
+
if (published)
|
|
214
|
+
input.publish(discovery);
|
|
215
|
+
};
|
|
216
|
+
/** Sends the wanted choice once to the current document, when it is alive and plays them. */
|
|
217
|
+
const flush = () => {
|
|
218
|
+
if (!wanted || sent === wanted || !player || !port || !nonce)
|
|
219
|
+
return;
|
|
220
|
+
if (phase !== 'alive' || discovery === undefined)
|
|
221
|
+
return;
|
|
222
|
+
const choice = wanted;
|
|
223
|
+
try {
|
|
224
|
+
port.postMessage(JSON.stringify({
|
|
225
|
+
type: 'ape:prototype:show',
|
|
226
|
+
version: 2,
|
|
227
|
+
navigation: input.navigation,
|
|
228
|
+
document: nonce,
|
|
229
|
+
...(choice.journey ? { journey: choice.journey, step: choice.step ?? 0 } : {}),
|
|
230
|
+
...(!choice.journey && choice.data ? { data: choice.data } : {}),
|
|
231
|
+
}));
|
|
232
|
+
sent = choice;
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
// A port that cannot carry it: the next hello's port gets the wanted choice.
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Tells the app which journey and step, or which data, to show, without a reload. It goes only
|
|
240
|
+
* on the private port of the document whose hello passed the origin check. The choice is kept:
|
|
241
|
+
* sent now when that document is alive, else (its port gone stale while it reloads) on the next
|
|
242
|
+
* hello's port. False when the session failed or closed, or the document does not play show
|
|
243
|
+
* messages (an older app): the caller reloads the frame at that choice instead.
|
|
244
|
+
*/
|
|
245
|
+
const show = (choice) => {
|
|
246
|
+
if (phase === 'failed' || phase === 'closed' || !player)
|
|
247
|
+
return false;
|
|
248
|
+
wanted = choice;
|
|
249
|
+
flush();
|
|
250
|
+
return true;
|
|
251
|
+
};
|
|
177
252
|
window.addEventListener('message', receive);
|
|
178
253
|
document.addEventListener('visibilitychange', visibility);
|
|
179
254
|
input.publish({});
|
|
180
255
|
renew(PROTOTYPE_WAIT);
|
|
181
256
|
return {
|
|
182
257
|
alive,
|
|
258
|
+
show,
|
|
183
259
|
fail,
|
|
184
260
|
timedOutSilently: () => timedOutSilently,
|
|
185
261
|
close: () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FrameFailure } from './prototype-document.ts';
|
|
1
|
+
import { type FrameFailure, type PrototypeShow } from './prototype-document.ts';
|
|
2
2
|
/** The session owns document changes; React only publishes its current navigation's answer. */
|
|
3
3
|
export declare function usePrototypeFrame(origin: string, navigation: string,
|
|
4
4
|
/** Remember when the switched address stayed silent so the next navigation uses the given one. */
|
|
@@ -22,5 +22,7 @@ onSwitch?: () => void, running?: boolean): {
|
|
|
22
22
|
cause: import("./prototype-bridge.ts").FrameCause | undefined;
|
|
23
23
|
recoverable: true | undefined;
|
|
24
24
|
alive: () => boolean;
|
|
25
|
+
/** Sends the choice to the running app; false when it could not, and the frame must reload. */
|
|
26
|
+
show: (choice: PrototypeShow) => boolean;
|
|
25
27
|
fail: (status?: FrameFailure) => void | undefined;
|
|
26
28
|
};
|
|
@@ -54,6 +54,8 @@ onSwitch, running) {
|
|
|
54
54
|
cause: current?.value.cause,
|
|
55
55
|
recoverable: current?.value.recoverable,
|
|
56
56
|
alive: () => session.current?.alive() ?? false,
|
|
57
|
+
/** Sends the choice to the running app; false when it could not, and the frame must reload. */
|
|
58
|
+
show: (choice) => session.current?.show(choice) ?? false,
|
|
57
59
|
fail: (status) => session.current?.fail(status),
|
|
58
60
|
};
|
|
59
61
|
}
|
|
@@ -41,6 +41,8 @@ export interface StudioProduct {
|
|
|
41
41
|
branch: string;
|
|
42
42
|
/** Where the work runs, when a host names it; on a person's own computer, none: "This computer". */
|
|
43
43
|
machine?: string;
|
|
44
|
+
/** The host's own launcher starts the agent's turns and applies their limits. */
|
|
45
|
+
hostLaunched?: boolean;
|
|
44
46
|
agent: AgentCard;
|
|
45
47
|
}
|
|
46
48
|
export interface AgentMessage {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buffcore/admin-shell",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.44",
|
|
4
4
|
"description": "The React DOM admin console for a BuffCore product, with its prototype viewer.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "BuffApe",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"@tanstack/react-router": "1.170.42",
|
|
38
38
|
"firebase": "12.19.0",
|
|
39
39
|
"qrcode": "1.5.4",
|
|
40
|
-
"@buffcore/config": "0.8.
|
|
41
|
-
"@buffcore/
|
|
42
|
-
"@buffcore/i18n": "0.8.
|
|
43
|
-
"@buffcore/
|
|
44
|
-
"@buffcore/
|
|
40
|
+
"@buffcore/config": "0.8.44",
|
|
41
|
+
"@buffcore/sdk": "0.8.44",
|
|
42
|
+
"@buffcore/i18n": "0.8.44",
|
|
43
|
+
"@buffcore/tokens": "0.8.44",
|
|
44
|
+
"@buffcore/contracts": "0.8.44"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=19",
|