@rig-c/review 2.0.0 → 2.2.0

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.
@@ -0,0 +1,292 @@
1
+ import {randomBytes, randomUUID} from 'node:crypto';
2
+ import {join} from 'node:path';
3
+ import {readFile, unlink} from 'node:fs/promises';
4
+ import {appRoot, buildWeb} from './build.ts';
5
+ import {createReviewRequestContext} from './server.ts';
6
+ import {createCompareRequestContext} from './compare-server.ts';
7
+ import {createLiveLifecycle, type UpgradableServer} from './live-lifecycle.ts';
8
+ import {prepareOpenTarget} from './open.ts';
9
+ import {sameSecret} from './open-protocol.ts';
10
+ import {boundedBody, frontRoute, maximumUpstreamStreams, stageFrameQuery} from './front.ts';
11
+ import {assertCompareUnchanged} from './compare.ts';
12
+ import {assertReviewUnchanged} from './reference.ts';
13
+ import {parseDesignation, parseRegistry, readPrivate, targetCapability, workspaceDirectory, workspaceError, writePrivate} from './open-workspace-state.ts';
14
+ import {WORKSPACE_BODY_LIMIT, WORKSPACE_REGISTRATION_QUEUE, WORKSPACE_SCHEMA, WORKSPACE_SOCKET_LIMIT,
15
+ WORKSPACE_TARGET_LIMIT, WORKSPACE_TARGETS_SCHEMA, type WorkspaceDesignation, type WorkspaceList,
16
+ type WorkspaceRecord, type WorkspaceStoredTarget, type WorkspaceTargetView} from './open-workspace-contract.ts';
17
+
18
+ type RequestContext = Awaited<ReturnType<typeof createReviewRequestContext>>;
19
+ interface Target {
20
+ stored: WorkspaceStoredTarget;
21
+ view: WorkspaceTargetView;
22
+ context: RequestContext | null;
23
+ check: (() => Promise<void>) | null;
24
+ }
25
+
26
+ const securityHeaders = {
27
+ 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'no-referrer',
28
+ 'Content-Security-Policy': "default-src 'none'; script-src 'self'; style-src 'self'; frame-src 'self'; connect-src 'self'; base-uri 'none'; frame-ancestors 'none'; form-action 'none'",
29
+ };
30
+ const json = (value: unknown, status = 200) => {
31
+ const text = JSON.stringify(value);
32
+ if (Buffer.byteLength(text) > WORKSPACE_BODY_LIMIT) throw workspaceError('WORKSPACE_BODY_LIMIT');
33
+ return new Response(text, {status, headers: {...securityHeaders, 'Content-Type': 'application/json'}});
34
+ };
35
+ const refused = (code: string, status = 409) => json({error: code}, status);
36
+
37
+ export interface OpenWorkspaceOptions {
38
+ stateDir: string;
39
+ fingerprint: string;
40
+ port: number;
41
+ idleMs?: number;
42
+ graceMs?: number;
43
+ }
44
+
45
+ /** One actual listener, with package contexts mounted in-process. */
46
+ export async function startOpenWorkspace(options: OpenWorkspaceOptions) {
47
+ const directory = await workspaceDirectory(options.stateDir);
48
+ const incarnation = randomUUID();
49
+ const ownerCapability = randomBytes(32).toString('hex');
50
+ const registrationCapability = randomBytes(32).toString('hex');
51
+ let targets = new Map<string, Target>();
52
+ let activeStreams = 0, registrations = 0, producing = false, accepting = true;
53
+ let pending = Promise.resolve();
54
+ let rawStop: ((close?: boolean) => void | Promise<void>) | undefined;
55
+ let record: WorkspaceRecord;
56
+ let stopPromise: Promise<void> | undefined;
57
+ const bundles = new Map<'single' | 'compare', Promise<Blob>>();
58
+ const ownerBundle = () => buildWeb('workspace');
59
+ let ownerScript: Promise<Blob> | undefined;
60
+ const busy = () => registrations > 0 || activeStreams > 0 || [...targets.values()].some(target => target.context?.busy());
61
+ const live = createLiveLifecycle({label: 'review workspace', graceMs: options.graceMs,
62
+ unopenedTimeoutMs: options.idleMs, busy, stopServer: () => stop(), log: line => console.error(line)});
63
+
64
+ function list(): WorkspaceList {
65
+ return {schema: WORKSPACE_SCHEMA, incarnation, targets: [...targets.values()].map(target => target.view)};
66
+ }
67
+
68
+ async function prepare(designation: WorkspaceDesignation): Promise<Target> {
69
+ const prepared = await prepareOpenTarget(designation.inputs, {
70
+ stateDir: options.stateDir, cwd: designation.cwd, viewOnly: designation.viewOnly,
71
+ }, options.fingerprint);
72
+ const loaded = prepared.package;
73
+ if (prepared.key !== designation.key || loaded.contentHash !== designation.contentHash) throw workspaceError('WORKSPACE_SOURCE_CHANGED');
74
+ let bundle = bundles.get(loaded.mode);
75
+ if (!bundle) {bundle = buildWeb(loaded.mode); bundles.set(loaded.mode, bundle);}
76
+ const controlToken = loaded.inputs.control ? randomUUID() : undefined;
77
+ const contextOptions = {stateDir: options.stateDir, cwd: designation.cwd, lifecycle: live, bundle: await bundle,
78
+ capability: targetCapability(ownerCapability, incarnation, designation.key),
79
+ open: {key: designation.key, contentHash: designation.contentHash, nonce: incarnation, fingerprint: options.fingerprint},
80
+ ...(controlToken ? {control: {token: controlToken, instanceKey: designation.key}} : {}),
81
+ };
82
+ const context = loaded.mode === 'single'
83
+ ? await createReviewRequestContext(loaded.p, {...contextOptions, joined: loaded.joined,
84
+ initialAnimation: loaded.selection?.name, viewOnly: designation.viewOnly})
85
+ : await createCompareRequestContext(loaded.p, contextOptions);
86
+ const check = () => loaded.mode === 'single' ? assertReviewUnchanged(loaded.p) : assertCompareUnchanged(loaded.p);
87
+ await check();
88
+ return {stored: {designation, ...(controlToken ? {controlToken} : {})}, context, check,
89
+ view: {key: designation.key, contentHash: designation.contentHash,
90
+ title: (loaded.mode === 'single' ? loaded.p.manifest.title : loaded.p.response.title).slice(0, 256),
91
+ mode: loaded.mode, animation: loaded.selection?.name ?? null, viewOnly: designation.viewOnly, unavailable: null,
92
+ entry: `/instances/${designation.key}/?input=${designation.contentHash}&handoff=${designation.key}&workspace=${incarnation}`}};
93
+ }
94
+
95
+ async function persist(next: Map<string, Target>) {
96
+ await writePrivate(join(directory, 'targets.json'), {
97
+ schema: WORKSPACE_TARGETS_SCHEMA, incarnation, targets: [...next.values()].map(target => target.stored),
98
+ });
99
+ }
100
+
101
+ async function register(values: unknown) {
102
+ if (!accepting) throw workspaceError('WORKSPACE_CLOSING');
103
+ if (!Array.isArray(values) || !values.length || values.length > WORKSPACE_TARGET_LIMIT) throw workspaceError('WORKSPACE_REQUEST_INVALID');
104
+ const designations = values.map(parseDesignation);
105
+ const requested = new Set(designations.map(designation => designation.key));
106
+ if (registrations >= WORKSPACE_REGISTRATION_QUEUE) throw workspaceError('WORKSPACE_BUSY');
107
+ registrations++;
108
+ const operation = pending.then(async () => {
109
+ if (!accepting) throw workspaceError('WORKSPACE_CLOSING');
110
+ const next = new Map(targets), created: Target[] = [];
111
+ try {
112
+ for (const designation of designations) {
113
+ const current = next.get(designation.key);
114
+ if (current) {
115
+ if (JSON.stringify(current.stored.designation) !== JSON.stringify(designation)) throw workspaceError('WORKSPACE_TARGET_OPTIONS_MISMATCH');
116
+ if (current.view.unavailable) throw workspaceError('WORKSPACE_SOURCE_CHANGED');
117
+ await current.check?.();
118
+ continue;
119
+ }
120
+ if (next.size >= WORKSPACE_TARGET_LIMIT) throw workspaceError('WORKSPACE_TARGET_LIMIT');
121
+ const target = await prepare(designation);
122
+ created.push(target); next.set(designation.key, target);
123
+ }
124
+ for (const [key, target] of next) {
125
+ if (requested.has(key)) await target.check?.();
126
+ else if (!target.view.unavailable) {
127
+ try {await target.check?.();}
128
+ catch {next.set(key, {...target, view: {...target.view, unavailable: 'WORKSPACE_SOURCE_CHANGED'}});}
129
+ }
130
+ }
131
+ await persist(next);
132
+ targets = next;
133
+ live.rearmUnopened();
134
+ return {schema: WORKSPACE_SCHEMA, incarnation, count: targets.size};
135
+ } catch (error) {for (const target of created) target.context?.stop(); throw error;}
136
+ });
137
+ pending = operation.then(() => {}, () => {});
138
+ try {return await operation;} finally {registrations--;}
139
+ }
140
+
141
+ function stream(response: Response, request: Request, release: () => void) {
142
+ if (!response.body || request.method === 'HEAD') {release(); return response;}
143
+ const reader = response.body.getReader();
144
+ const abort = () => {release(); void reader.cancel().catch(() => {});};
145
+ request.signal.addEventListener('abort', abort, {once: true});
146
+ if (request.signal.aborted) abort();
147
+ const done = () => {request.signal.removeEventListener('abort', abort); release();};
148
+ return new Response(new ReadableStream<Uint8Array>({
149
+ async pull(controller) {
150
+ try {const next = await reader.read(); if (next.done) {done(); controller.close();} else controller.enqueue(next.value);}
151
+ catch (error) {done(); controller.error(error);}
152
+ },
153
+ cancel(reason) {done(); return reader.cancel(reason);},
154
+ }), {status: response.status, headers: response.headers});
155
+ }
156
+
157
+ async function route(request: Request, server: UpgradableServer): Promise<Response | undefined> {
158
+ const url = new URL(request.url);
159
+ if (url.origin !== record.origin) return refused('WORKSPACE_LOOPBACK_REQUIRED', 403);
160
+ const sentOrigin = request.headers.get('origin');
161
+ if (request.headers.get('sec-fetch-site') === 'cross-site' || sentOrigin !== null && sentOrigin !== record.origin) {
162
+ return refused('WORKSPACE_SAME_ORIGIN_REQUIRED', 403);
163
+ }
164
+ const launch = sameSecret(request.headers.get('authorization'), 'Bearer ' + registrationCapability);
165
+ const owner = sameSecret(request.headers.get('X-Review-Capability'), ownerCapability);
166
+ if (url.pathname === '/workspace/api/status') {
167
+ if (request.method !== 'GET' || url.search || !launch) return refused('WORKSPACE_CAPABILITY_REQUIRED', 403);
168
+ return json({schema: WORKSPACE_SCHEMA, incarnation, pid: process.pid, fingerprint: options.fingerprint, runtime: Bun.version});
169
+ }
170
+ if (url.pathname === '/workspace/api/register') {
171
+ if (request.method !== 'POST' || url.search || !launch) return refused('WORKSPACE_CAPABILITY_REQUIRED', 403);
172
+ const body: unknown = JSON.parse(new TextDecoder('utf-8', {fatal: true}).decode(await boundedBody(request, WORKSPACE_BODY_LIMIT)));
173
+ if (!body || typeof body !== 'object' || Array.isArray(body)) return refused('WORKSPACE_REQUEST_INVALID', 400);
174
+ const value = body as Record<string, unknown>;
175
+ if (Object.keys(value).some(key => !['schema', 'incarnation', 'targets'].includes(key)) ||
176
+ value.schema !== WORKSPACE_SCHEMA || value.incarnation !== incarnation) return refused('WORKSPACE_REQUEST_INVALID', 400);
177
+ return json(await register(value.targets));
178
+ }
179
+ if (url.pathname === '/workspace/api/targets') {
180
+ if (request.method !== 'GET' || url.search || !owner) return refused('WORKSPACE_CAPABILITY_REQUIRED', 403);
181
+ return json(list());
182
+ }
183
+ if (url.pathname === '/workspace/live') {
184
+ if (request.method !== 'GET' || url.search || sentOrigin !== record.origin) return refused('WORKSPACE_SAME_ORIGIN_REQUIRED', 403);
185
+ if (live.connections >= WORKSPACE_SOCKET_LIMIT) return refused('WORKSPACE_BUSY', 503);
186
+ return live.upgrade(request, server, securityHeaders);
187
+ }
188
+ if (['/', '/workspace.js', '/workspace.css', '/styles.css'].includes(url.pathname)) {
189
+ if (!['GET', 'HEAD'].includes(request.method)) return refused('WORKSPACE_REQUEST_INVALID', 400);
190
+ if (url.pathname === '/') {
191
+ const keys = [...url.searchParams.keys()];
192
+ if (new Set(keys).size !== keys.length || keys.some(key => !['workspace', 'lang'].includes(key)) ||
193
+ url.searchParams.has('lang') && !['en', 'ko'].includes(url.searchParams.get('lang')!)) {
194
+ return refused('WORKSPACE_REQUEST_INVALID', 400);
195
+ }
196
+ if (url.searchParams.has('workspace') && url.searchParams.get('workspace') !== incarnation) {
197
+ return refused('WORKSPACE_HOST_MISMATCH', 409);
198
+ }
199
+ } else if (url.search && !['?lang=en', '?lang=ko'].includes(url.search)) {
200
+ return refused('WORKSPACE_REQUEST_INVALID', 400);
201
+ }
202
+ const body = url.pathname === '/workspace.js' ? await (ownerScript ??= ownerBundle())
203
+ : await readFile(appRoot + (url.pathname === '/' ? 'web/owner-workspace.html' : url.pathname === '/styles.css' ? 'web/styles.css' : 'web/owner-workspace.css'));
204
+ return new Response(request.method === 'HEAD' ? null : body, {headers: {...securityHeaders,
205
+ 'Content-Type': url.pathname.endsWith('.js') ? 'text/javascript' : url.pathname.endsWith('.css') ? 'text/css' : 'text/html; charset=utf-8'}});
206
+ }
207
+ const match = /^\/instances\/([a-f0-9]{64})(\/.*)$/.exec(url.pathname);
208
+ const target = match && targets.get(match[1]!);
209
+ if (!match || !target) return refused('WORKSPACE_TARGET_UNKNOWN', 404);
210
+ if (!target.context) return refused(target.view.unavailable ?? 'WORKSPACE_TARGET_UNAVAILABLE');
211
+ const path = match[2]!;
212
+ const agentControl = path === '/api/control' || path === '/api/control/commands' || /^\/api\/control\/receipts\/[a-f0-9-]+$/.test(path);
213
+ if (!frontRoute(target.view.mode, request.method, path) && !(agentControl && target.stored.controlToken)) return refused('WORKSPACE_ROUTE_REFUSED', 404);
214
+ const landing = path === '/' || path === '/index.html';
215
+ const stageFrame = path === '/stage-parts.html' || path === '/stage-interview.html';
216
+ if (stageFrame ? !stageFrameQuery(target.view.mode, url.search) : !landing && !!url.search) return refused('FRONT_QUERY_REFUSED', 400);
217
+ if (request.method !== 'GET' && request.method !== 'HEAD' && sentOrigin !== record.origin) return refused('WORKSPACE_SAME_ORIGIN_REQUIRED', 403);
218
+ if (path === '/api/live' && live.connections >= WORKSPACE_SOCKET_LIMIT) return refused('WORKSPACE_BUSY', 503);
219
+ if (activeStreams >= maximumUpstreamStreams) return refused('WORKSPACE_BUSY', 503);
220
+ const producerRequest = request.method === 'POST' && /^\/api\/(?:compare\/[ab]\/)?(?:rebuild|density-strip|bones-check|requirements|environment-check|readings|strip)(?:\/|$)/.test(path);
221
+ if (producerRequest && (producing || [...targets.values()].some(row => row.context?.busy()))) return refused('WORKSPACE_BUSY', 503);
222
+ if (producerRequest) producing = true;
223
+ activeStreams++;
224
+ let released = false;
225
+ const release = () => {if (!released) {released = true; activeStreams--;}};
226
+ try {
227
+ const normalized = new URL(request.url); normalized.pathname = path;
228
+ const inner = new Request(normalized, request);
229
+ const upgrade: UpgradableServer = {upgrade(_inner, details) {return server.upgrade(request, details);}};
230
+ const response = await target.context.handle(inner, Number(url.port), upgrade);
231
+ if (!response) {release(); return undefined;}
232
+ if ((path === '/api/review' || path === '/api/compare') && response.status === 409) target.view.unavailable = 'WORKSPACE_SOURCE_CHANGED';
233
+ if ((path === '/' || path === '/index.html') && response.headers.get('Content-Type')?.startsWith('text/html')) {
234
+ const policy = response.headers.get('Content-Security-Policy');
235
+ if (policy) response.headers.set('Content-Security-Policy', policy.replace("frame-ancestors 'none'", "frame-ancestors 'self'"));
236
+ }
237
+ return stream(response, request, release);
238
+ } catch (error) {release(); throw error;}
239
+ finally {if (producerRequest) producing = false;}
240
+ }
241
+
242
+ function stop() {
243
+ stopPromise ??= (async () => {
244
+ accepting = false;
245
+ await pending;
246
+ live.stop();
247
+ for (const target of targets.values()) target.context?.stop();
248
+ await rawStop?.(true);
249
+ const current = await readPrivate(join(directory, 'host.json'));
250
+ if (current && (current as WorkspaceRecord).incarnation === incarnation) await unlink(join(directory, 'host.json'));
251
+ })();
252
+ return stopPromise;
253
+ }
254
+
255
+ try {
256
+ const previous = await readPrivate(join(directory, 'targets.json'));
257
+ if (previous) {
258
+ for (const stored of parseRegistry(previous).targets) {
259
+ try {targets.set(stored.designation.key, await prepare(stored.designation));}
260
+ catch {
261
+ targets.set(stored.designation.key, {stored, context: null, check: null, view: {
262
+ key: stored.designation.key, contentHash: stored.designation.contentHash, title: stored.designation.inputs.input,
263
+ mode: stored.designation.inputs.compare ? 'compare' : 'single', animation: stored.designation.inputs.animation ?? null,
264
+ viewOnly: stored.designation.viewOnly, unavailable: 'WORKSPACE_SOURCE_CHANGED', entry: '',
265
+ }});
266
+ }
267
+ }
268
+ }
269
+ const server = Bun.serve({hostname: '127.0.0.1', port: options.port, websocket: live.websocket,
270
+ async fetch(request, server) {
271
+ try {return await route(request, server) as Response;}
272
+ catch (error) {
273
+ const message = error instanceof Error ? error.message : '';
274
+ if (message === 'FRONT_BODY_LIMIT') return refused('WORKSPACE_BODY_LIMIT', 413);
275
+ if (message === 'FRONT_BODY_TIMEOUT') return refused('WORKSPACE_BODY_TIMEOUT', 408);
276
+ if (message === 'FRONT_JSON_REQUIRED' || error instanceof SyntaxError) return refused('WORKSPACE_REQUEST_INVALID', 400);
277
+ return refused(/^WORKSPACE_[A-Z_]+$/.test(message) ? message : 'WORKSPACE_REQUEST_REFUSED');
278
+ }
279
+ }});
280
+ rawStop = server.stop.bind(server);
281
+ record = {schema: WORKSPACE_SCHEMA, incarnation, pid: process.pid, uid: process.getuid?.() ?? 0,
282
+ origin: `http://127.0.0.1:${server.port}`, installation: appRoot, fingerprint: options.fingerprint,
283
+ runtime: Bun.version, registrationCapability, ownerCapability};
284
+ await persist(targets);
285
+ await writePrivate(join(directory, 'host.json'), record);
286
+ return {record, live, stop};
287
+ } catch (error) {
288
+ await stop();
289
+ if ((error as NodeJS.ErrnoException).code === 'EADDRINUSE') throw workspaceError(`FRONT_PORT_BUSY: 127.0.0.1:${options.port} is held by another listener; use --direct (or set RIG_REVIEW_FRONT_PORT)`);
290
+ throw error;
291
+ }
292
+ }
package/src/open.ts CHANGED
@@ -125,22 +125,29 @@ async function verifyOpenLoad(p:OpenPackage,viewOnly:boolean,cwd=process.cwd()):
125
125
  }
126
126
  /** Managed is the default: the printed URL goes through the one loopback front (127.0.0.1:4318, or
127
127
  * RIG_REVIEW_FRONT_PORT) so browser storage keeps one origin across reopens. `direct` keeps the worker's own port. */
128
- export async function openReview(inputs:OpenInputs,options:{stateDir?:string;idleMs?:number;graceMs?:number;direct?:boolean;viewOnly?:boolean;cwd?:string;frontPort?:number;frontIdleMs?:number}={}):Promise<{url:string;reused:boolean;nonce:string;inputs:OpenInputs;selection:AnimationSelection|null;direct:boolean;build:BuildOpen|null}>{
129
- const direct=options.direct??inputs.direct??false,viewOnly=options.viewOnly??inputs.viewOnly??false,port=direct?0:frontPort(options.frontPort);
128
+ export interface OpenOptions {stateDir?:string;idleMs?:number;graceMs?:number;direct?:boolean;viewOnly?:boolean;cwd?:string;frontPort?:number;frontIdleMs?:number}
129
+ export async function prepareOpenTarget(inputs: OpenInputs, options: OpenOptions = {}, fingerprint?: string) {
130
+ const viewOnly=options.viewOnly??inputs.viewOnly??false;
130
131
  for(const path of [inputs.input,...(inputs.compare!==undefined?[inputs.compare]:[])])await assertOpenInput(path);
131
132
  if(inputs.compare!==undefined&&!inputs.reference)throw new Error('OPEN_REFERENCE_REQUIRED: compare: explicit --reference required');
132
133
  let p:OpenPackage;try{p=await loadOpenPackage(inputs);}catch(error){throw await openRefusal(error,inputs);}
133
- const fingerprint=await openFingerprint(),key=openKey(p,fingerprint);
134
+ fingerprint??=await openFingerprint();const key=openKey(p,fingerprint);
134
135
  // #187: canonical (symlinks and ancestors resolved) and outside every supplied folder: the package, the build root a check package belongs to, the handoff root.
135
136
  const stateDir=destinationDirectory(options.stateDir??defaultStateDir(),'OPEN_STATE_INVALID: the state directory path has a non-directory component or a symlink loop'),roots=p.mode==='single'?stateRoots(p.p):[...stateRoots(p.p.a),...stateRoots(p.p.b)];
136
137
  if(p.mode==='single'&&p.joined&&stateDirInside(stateDir,[{kind:'package',path:p.joined.opened.root}]))throw new Error('OPEN_STATE_INSIDE_PACKAGE: review state must be outside the joined project');
137
138
  const inside=stateDirInside(stateDir,roots);if(inside)throw new Error(`OPEN_STATE_INSIDE_PACKAGE ${inside.kind}: the review state directory must be outside input packages; it is inside the ${inside.kind}; set RIG_REVIEW_STATE_DIR outside it`);
138
139
  await verifyOpenLoad(p,viewOnly,options.cwd);
140
+ const build=p.mode==='single'&&basename(p.p.root)==='check'&&await isBuildRoot(dirname(p.p.root))?{package:p.p.root,handoff:p.p.reviewedSource.handoff??null,reason:p.p.handoffReason}:null;
141
+ return {package:p,key,fingerprint,stateDir,viewOnly,cwd:resolve(options.cwd??process.cwd()),build};
142
+ }
143
+ export async function openReview(inputs:OpenInputs,options:OpenOptions={}):Promise<{url:string;reused:boolean;nonce:string;inputs:OpenInputs;selection:AnimationSelection|null;direct:boolean;build:BuildOpen|null}>{
144
+ const direct=options.direct??inputs.direct??false,port=direct?0:frontPort(options.frontPort);
145
+ const prepared=await prepareOpenTarget(inputs,options);
146
+ const {package:p,key,fingerprint,stateDir,viewOnly,build}=prepared;
139
147
  const control=join(stateDir,'open');await mkdir(control,{recursive:true,mode:0o700});const canonicalControl=await realpath(control);if((await lstat(control)).isSymbolicLink())throw new Error('open.state: control directory cannot be a symlink');
140
148
  const worker=await ensureWorker(p,key,fingerprint,stateDir,canonicalControl,options.idleMs??DEFAULT_UNOPENED_TIMEOUT_MS,options.graceMs,viewOnly,options.cwd);
141
149
  const url=direct?openUrl(worker.row):openUrl(worker.row,await ensureFront({control:canonicalControl,port,fingerprint,idleMs:options.frontIdleMs}));
142
150
  // #149: the check package of a rig-parts build root says which package it opened and which config the handoff took.
143
- const build=p.mode==='single'&&basename(p.p.root)==='check'&&await isBuildRoot(dirname(p.p.root))?{package:p.p.root,handoff:p.p.reviewedSource.handoff??null,reason:p.p.handoffReason}:null;
144
151
  return {url,reused:worker.reused,nonce:worker.row.nonce,inputs:p.inputs,selection:p.selection,direct,build};
145
152
  }
146
153
  async function ensureWorker(p:OpenPackage,key:string,fingerprint:string,stateDir:string,canonicalControl:string,idleMs:number,graceMs?:number,viewOnly=false,cwd=process.cwd()):Promise<{row:RecordFile;reused:boolean}>{
@@ -179,13 +186,19 @@ export async function controlReview(inputs:OpenInputs,commandOptions:{pageId?:st
179
186
  const wait=commandOptions.waitMs??10000;if(!Number.isSafeInteger(wait)||wait<0||wait>30000)throw new Error('CONTROL_WAIT: expected integer 0..30000');
180
187
  const p=await loadOpenPackage({...inputs,control:true}),fingerprint=await openFingerprint(),key=openKey(p,fingerprint);
181
188
  const stateDir=destinationDirectory(commandOptions.stateDir??defaultStateDir(),'CONTROL_STATE: the state directory path has a non-directory component or a symlink loop');
189
+ const workspace=await (await import('./open-workspace-launch.ts')).workspaceControlLocator(stateDir,key);
190
+ let record:{origin:string;controlToken:string;capability:string},prefix='';
191
+ if(workspace){record=workspace;prefix=workspace.prefix;}
192
+ else {
182
193
  const controlDir=join(stateDir,'open');
183
194
  try{if((await lstat(controlDir)).isSymbolicLink())throw new Error('CONTROL_STATE: control directory cannot be a symlink');}catch(error){if((error as NodeJS.ErrnoException).code==='ENOENT')throw new Error('CONTROL_INSTANCE_UNAVAILABLE: open the exact inputs once with --control');throw error;}
184
195
  const file=join(controlDir,key+'.json');try{const info=await lstat(file);if(!info.isFile()||(info.mode&0o077)!==0)throw new Error('CONTROL_STATE: owner-only regular capability record required');}catch(error){if((error as NodeJS.ErrnoException).code==='ENOENT')throw new Error('CONTROL_INSTANCE_UNAVAILABLE: open the exact inputs once with --control');throw error;}
185
- const record=await readRecord(file,key);
186
- if(!record||!record.controlToken||!await alive(record))throw new Error('CONTROL_INSTANCE_UNAVAILABLE: open the exact inputs once with --control');
196
+ const legacy=await readRecord(file,key);
197
+ if(!legacy||!legacy.controlToken||!await alive(legacy))throw new Error('CONTROL_INSTANCE_UNAVAILABLE: open the exact inputs once with --control');
198
+ record={origin:legacy.origin,controlToken:legacy.controlToken,capability:legacy.capability};
199
+ }
187
200
  const headers={Authorization:'Bearer '+record.controlToken,Origin:record.origin,'Content-Type':'application/json',[capabilityHeader]:record.capability};
188
- const get=async(path:string,body?:unknown)=>{const response=await fetch(record.origin+path,{method:body===undefined?'GET':'POST',headers,...(body===undefined?{}:{body:JSON.stringify(body)}),redirect:'error',signal:AbortSignal.timeout(5000)});const value=await readOpenStatus(response,5000);if(!response.ok)throw new Error((value as {error?:string}).error??'CONTROL_REQUEST_FAILED');return value;};
201
+ const get=async(path:string,body?:unknown)=>{const response=await fetch(record.origin+prefix+path,{method:body===undefined?'GET':'POST',headers,...(body===undefined?{}:{body:JSON.stringify(body)}),redirect:'error',signal:AbortSignal.timeout(5000)});const value=await readOpenStatus(response,5000);if(!response.ok)throw new Error((value as {error?:string}).error??'CONTROL_REQUEST_FAILED');return value;};
189
202
  const state=await get('/api/control') as {sourceHash:string;instanceKey:string;pages:{pageId:string;revision:number}[]};
190
203
  if(state.sourceHash!==p.contentHash||state.instanceKey!==key)throw new Error('CONTROL_STALE_BINDING');
191
204
  if(!commandOptions.command)return state;
package/src/server.ts CHANGED
@@ -19,7 +19,7 @@ import { BONES_CHECK_LIMIT, createBonesCheck } from './bones-check.ts';
19
19
  import { createRequirementsCheck } from './requirements-run.ts';
20
20
  import { REQUIREMENTS_LIMIT, RequirementsError } from './requirements.ts';
21
21
  import { createEnvironmentCheck, ENVIRONMENT_CHECK_LIMIT, EnvironmentCheckError } from './environment-check.ts';
22
- import { createLiveLifecycle, LIVE_PATH, type LiveExitInfo, type UpgradableServer } from './live-lifecycle.ts';
22
+ import { createLiveLifecycle, LIVE_PATH, type LiveExitInfo, type LiveLifecycle, type UpgradableServer } from './live-lifecycle.ts';
23
23
  import { homedir } from 'node:os';
24
24
  import { join } from 'node:path';
25
25
  const headers={ 'X-Content-Type-Options':'nosniff','Cache-Control':'no-store','Content-Security-Policy':"default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data:; media-src 'self'; frame-src 'self'; connect-src 'self'; font-src 'self'; base-uri 'none'; frame-ancestors 'none'; form-action 'none'",'Referrer-Policy':'no-referrer'};
@@ -35,13 +35,39 @@ async function bodyJson(req:Request,limit=1024*1024,what='Session payload exceed
35
35
  }
36
36
  /** `capability` (open workers and foreground CLI serving) gates every non-GET request; tests may omit it.
37
37
  * `cwd` is where the producer is looked for after the package's own directories (review's working directory by default). */
38
- export async function startServer(p:ReviewPackage,options:{port?:number;stateDir?:string;joined?:JoinedProject;open?:OpenIdentity;initialAnimation?:string;activity?:()=>void;control?:ControlIdentity;capability?:string;cwd?:string;stripConcurrency?:number;graceMs?:number;unopenedTimeoutMs?:number;exitOnClose?:boolean;onClose?:(info:LiveExitInfo)=>void|Promise<void>;log?:(line:string)=>void;viewOnly?:boolean}={}){
38
+ export interface ReviewServerOptions {
39
+ port?: number;
40
+ stateDir?: string;
41
+ joined?: JoinedProject;
42
+ open?: OpenIdentity;
43
+ initialAnimation?: string;
44
+ activity?: () => void;
45
+ control?: ControlIdentity;
46
+ capability?: string;
47
+ cwd?: string;
48
+ stripConcurrency?: number;
49
+ graceMs?: number;
50
+ unopenedTimeoutMs?: number;
51
+ exitOnClose?: boolean;
52
+ onClose?: (info: LiveExitInfo) => void | Promise<void>;
53
+ log?: (line: string) => void;
54
+ viewOnly?: boolean;
55
+ }
56
+
57
+ export interface ReviewRequestContextOptions extends ReviewServerOptions {
58
+ lifecycle?: LiveLifecycle;
59
+ bundle?: Blob;
60
+ stopServer?: () => void | Promise<void>;
61
+ }
62
+
63
+ /** Package-scoped routes without a listener. An injected lifecycle belongs to its caller. */
64
+ export async function createReviewRequestContext(p: ReviewPackage, options: ReviewRequestContextOptions = {}) {
39
65
  const joined = options.joined;
40
66
  if (joined && !options.capability) throw new Error('Joined interview requires an instance capability');
41
67
  const interview = joined && interviewRoutes(joined.opened.root, joined.designation.picksDir, options.capability!,
42
68
  {...joined, sourceHash:p.sourceHash, version:joined.designation.version,draftId:joined.designation.draftId});
43
69
  let interviewBundle: Promise<Blob> | undefined;
44
- const bundle=await buildWeb();
70
+ const bundle=options.bundle??await buildWeb();
45
71
  const unchanged=()=>assertReviewUnchanged(p);
46
72
  const stateDir=options.stateDir??process.env.RIG_REVIEW_STATE_DIR??join(homedir(),'.local','state','rig-c-review'),starts=[p.root,options.cwd??process.cwd()];
47
73
  const rebuilds=createRebuilds(p,{stateDir,starts,unchanged,bones:p.feedbackCatalog.bones,...(options.stripConcurrency?{stripConcurrency:options.stripConcurrency}:{}),...(options.viewOnly??p.viewOnly?{viewOnly:true}:{})});
@@ -60,16 +86,17 @@ export async function startServer(p:ReviewPackage,options:{port?:number;stateDir
60
86
  // Check under this world (#112): the exported schedule written into scratch; the installed producer's check --environment reads it.
61
87
  const environmentCheck=createEnvironmentCheck(p,{stateDir,starts,unchanged,latest:rebuilds.latest});
62
88
  const control=options.control?createControlServer({identity:options.control,sourceHash:p.sourceHash,mode:'single',unchanged,activity:options.activity}):null;
63
- let rawStop:((closeActiveConnections?:boolean)=>void)|null=null;
64
- const live=createLiveLifecycle({
89
+ const busy=()=>Boolean(rebuilds.busy()||readings.running()||requirements.running()||environmentCheck.running()||bonesCheck.running());
90
+ const ownsLifecycle=options.lifecycle===undefined;
91
+ const live=options.lifecycle??createLiveLifecycle({
65
92
  label:'review',
66
93
  graceMs:options.graceMs,
67
94
  unopenedTimeoutMs:options.unopenedTimeoutMs,
68
95
  exitOnClose:options.exitOnClose,
69
96
  onClose:options.onClose,
70
97
  log:options.log,
71
- busy:()=>Boolean(rebuilds.busy()||readings.running()||requirements.running()||environmentCheck.running()||bonesCheck.running()),
72
- stopServer:()=>{rawStop?.(true);},
98
+ busy,
99
+ stopServer:options.stopServer,
73
100
  });
74
101
  const handle=async(req:Request,port:number|undefined,srv:UpgradableServer):Promise<Response|undefined>=>{try {
75
102
  const url=new URL(req.url);const origin=`http://127.0.0.1:${port}`;
@@ -225,8 +252,22 @@ export async function startServer(p:ReviewPackage,options:{port?:number;stateDir
225
252
  return json({error:'Not found'},404);
226
253
  } finally { live.onRequestEnd(url.pathname); }
227
254
  }catch(e){const message=e instanceof Error?e.message:'Request failed';return json({error:message},message===directionStale || message.startsWith(interviewStale) || message.includes('inputs changed')?409:400);}};
228
- const server=Bun.serve({hostname:'127.0.0.1',port:options.port??4317,websocket:live.websocket,async fetch(req,srv){const res=await handle(req,srv.port,srv);if(!res)return undefined as unknown as Response;return stampOpen(req,res,options.open);}});
255
+ return {
256
+ live,
257
+ busy,
258
+ async handle(req: Request, port: number | undefined, srv: UpgradableServer): Promise<Response | undefined> {
259
+ const response=await handle(req,port,srv);
260
+ return response?stampOpen(req,response,options.open):undefined;
261
+ },
262
+ stop() { if(ownsLifecycle)live.stop(); },
263
+ };
264
+ }
265
+
266
+ export async function startServer(p: ReviewPackage, options: ReviewServerOptions = {}) {
267
+ let rawStop:((closeActiveConnections?:boolean)=>void)|null=null;
268
+ const context=await createReviewRequestContext(p,{...options,stopServer:()=>{rawStop?.(true);}});
269
+ const server=Bun.serve({hostname:'127.0.0.1',port:options.port??4317,websocket:context.live.websocket,async fetch(req,srv){return await context.handle(req,srv.port,srv) as Response;}});
229
270
  rawStop=server.stop.bind(server);
230
- server.stop=((closeActiveConnections?:boolean)=>{live.stop();return rawStop!(closeActiveConnections);}) as typeof server.stop;
231
- return Object.assign(server,{live});
271
+ server.stop=((closeActiveConnections?:boolean)=>{context.stop();return rawStop!(closeActiveConnections);}) as typeof server.stop;
272
+ return Object.assign(server,{live:context.live});
232
273
  }
package/web/catalog-en.ts CHANGED
@@ -1,4 +1,41 @@
1
1
  export const enCatalog: Readonly<Record<string, string>> = {
2
+ "WORKSPACE_BODY_TIMEOUT": "WORKSPACE_BODY_TIMEOUT",
3
+ "rig-review-target/1": "rig-review-target/1",
4
+ "Review workspace": "Review workspace",
5
+ "Review targets": "Review targets",
6
+ "Inspection only": "Inspection only",
7
+ "Review target": "Review target",
8
+ "Select a target. Drafts stay with their original source.": "Select a target. Drafts stay with their original source.",
9
+ "FRONT_QUERY_REFUSED": "FRONT_QUERY_REFUSED",
10
+ "Korean": "Korean",
11
+ "WORKSPACE_BODY_LIMIT": "WORKSPACE_BODY_LIMIT",
12
+ "WORKSPACE_BUSY": "WORKSPACE_BUSY",
13
+ "WORKSPACE_CAPABILITY_REQUIRED": "WORKSPACE_CAPABILITY_REQUIRED",
14
+ "WORKSPACE_CLOSING": "WORKSPACE_CLOSING",
15
+ "WORKSPACE_HOST_MISMATCH": "WORKSPACE_HOST_MISMATCH",
16
+ "WORKSPACE_HOST_UNRESPONSIVE": "WORKSPACE_HOST_UNRESPONSIVE",
17
+ "WORKSPACE_LOOPBACK_REQUIRED": "WORKSPACE_LOOPBACK_REQUIRED",
18
+ "WORKSPACE_OWNER_MISMATCH": "WORKSPACE_OWNER_MISMATCH",
19
+ "WORKSPACE_PORT_BUSY": "WORKSPACE_PORT_BUSY",
20
+ "WORKSPACE_REGISTRATION_REFUSED": "WORKSPACE_REGISTRATION_REFUSED",
21
+ "WORKSPACE_REQUEST_INVALID": "WORKSPACE_REQUEST_INVALID",
22
+ "WORKSPACE_REQUEST_REFUSED": "WORKSPACE_REQUEST_REFUSED",
23
+ "WORKSPACE_ROUTE_REFUSED": "WORKSPACE_ROUTE_REFUSED",
24
+ "WORKSPACE_SAME_ORIGIN_REQUIRED": "WORKSPACE_SAME_ORIGIN_REQUIRED",
25
+ "WORKSPACE_SOURCE_CHANGED": "WORKSPACE_SOURCE_CHANGED",
26
+ "WORKSPACE_START_BUSY": "WORKSPACE_START_BUSY",
27
+ "WORKSPACE_START_REFUSED": "WORKSPACE_START_REFUSED",
28
+ "WORKSPACE_START_TIMEOUT": "WORKSPACE_START_TIMEOUT",
29
+ "WORKSPACE_STATE_INVALID": "WORKSPACE_STATE_INVALID",
30
+ "WORKSPACE_TARGET_LIMIT": "WORKSPACE_TARGET_LIMIT",
31
+ "WORKSPACE_TARGET_OPTIONS_MISMATCH": "WORKSPACE_TARGET_OPTIONS_MISMATCH",
32
+ "WORKSPACE_TARGET_UNAVAILABLE": "WORKSPACE_TARGET_UNAVAILABLE",
33
+ "WORKSPACE_TARGET_UNKNOWN": "WORKSPACE_TARGET_UNKNOWN",
34
+ "rig-review-open-workspace/1": "rig-review-open-workspace/1",
35
+ "rig-review-open-targets/1": "rig-review-open-targets/1",
36
+ "rig-review-workspace-visibility/1": "rig-review-workspace-visibility/1",
37
+ "rig-review-workspace-ready/1": "rig-review-workspace-ready/1",
38
+ "rig-review-owner-workspace/1:": "rig-review-owner-workspace/1:",
2
39
  "Producer check passed": "Producer check passed",
3
40
  "Producer check failed": "Producer check failed",
4
41
  "Producer check unavailable": "Producer check unavailable",
package/web/catalog-ko.ts CHANGED
@@ -1,4 +1,41 @@
1
1
  export const koCatalog: Readonly<Record<string, string>> = {
2
+ "WORKSPACE_BODY_TIMEOUT": "WORKSPACE_BODY_TIMEOUT",
3
+ "rig-review-target/1": "rig-review-target/1",
4
+ "Review workspace": "검토 작업 공간",
5
+ "Review targets": "검토 대상",
6
+ "Inspection only": "살펴보기 전용",
7
+ "Review target": "검토 대상",
8
+ "Select a target. Drafts stay with their original source.": "대상을 선택해. 초안은 원래 소스에 보관돼.",
9
+ "FRONT_QUERY_REFUSED": "FRONT_QUERY_REFUSED",
10
+ "Korean": "한국어",
11
+ "WORKSPACE_BODY_LIMIT": "WORKSPACE_BODY_LIMIT",
12
+ "WORKSPACE_BUSY": "WORKSPACE_BUSY",
13
+ "WORKSPACE_CAPABILITY_REQUIRED": "WORKSPACE_CAPABILITY_REQUIRED",
14
+ "WORKSPACE_CLOSING": "WORKSPACE_CLOSING",
15
+ "WORKSPACE_HOST_MISMATCH": "WORKSPACE_HOST_MISMATCH",
16
+ "WORKSPACE_HOST_UNRESPONSIVE": "WORKSPACE_HOST_UNRESPONSIVE",
17
+ "WORKSPACE_LOOPBACK_REQUIRED": "WORKSPACE_LOOPBACK_REQUIRED",
18
+ "WORKSPACE_OWNER_MISMATCH": "WORKSPACE_OWNER_MISMATCH",
19
+ "WORKSPACE_PORT_BUSY": "WORKSPACE_PORT_BUSY",
20
+ "WORKSPACE_REGISTRATION_REFUSED": "WORKSPACE_REGISTRATION_REFUSED",
21
+ "WORKSPACE_REQUEST_INVALID": "WORKSPACE_REQUEST_INVALID",
22
+ "WORKSPACE_REQUEST_REFUSED": "WORKSPACE_REQUEST_REFUSED",
23
+ "WORKSPACE_ROUTE_REFUSED": "WORKSPACE_ROUTE_REFUSED",
24
+ "WORKSPACE_SAME_ORIGIN_REQUIRED": "WORKSPACE_SAME_ORIGIN_REQUIRED",
25
+ "WORKSPACE_SOURCE_CHANGED": "WORKSPACE_SOURCE_CHANGED",
26
+ "WORKSPACE_START_BUSY": "WORKSPACE_START_BUSY",
27
+ "WORKSPACE_START_REFUSED": "WORKSPACE_START_REFUSED",
28
+ "WORKSPACE_START_TIMEOUT": "WORKSPACE_START_TIMEOUT",
29
+ "WORKSPACE_STATE_INVALID": "WORKSPACE_STATE_INVALID",
30
+ "WORKSPACE_TARGET_LIMIT": "WORKSPACE_TARGET_LIMIT",
31
+ "WORKSPACE_TARGET_OPTIONS_MISMATCH": "WORKSPACE_TARGET_OPTIONS_MISMATCH",
32
+ "WORKSPACE_TARGET_UNAVAILABLE": "WORKSPACE_TARGET_UNAVAILABLE",
33
+ "WORKSPACE_TARGET_UNKNOWN": "WORKSPACE_TARGET_UNKNOWN",
34
+ "rig-review-open-workspace/1": "rig-review-open-workspace/1",
35
+ "rig-review-open-targets/1": "rig-review-open-targets/1",
36
+ "rig-review-workspace-visibility/1": "rig-review-workspace-visibility/1",
37
+ "rig-review-workspace-ready/1": "rig-review-workspace-ready/1",
38
+ "rig-review-owner-workspace/1:": "rig-review-owner-workspace/1:",
2
39
  "Producer check passed": "프로듀서 검사 통과",
3
40
  "Producer check failed": "프로듀서 검사 실패",
4
41
  "Producer check unavailable": "프로듀서 검사 결과 없음",
package/web/compare.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import {bindStageNav} from './stage-nav.ts';
2
+ import {bindWorkspaceVisibility} from './workspace-visibility.ts';
2
3
  import {requireFeedbackFrames} from '../src/stage-comment.ts';
3
4
  import {bindStageComments,type CommentPose} from './stage-comments.ts';
4
5
  import {sharedTurnDials,type TurnDial} from '../src/turn-pad.ts';
@@ -463,6 +464,7 @@ async function start(): Promise<void> {
463
464
  input('scrub').disabled = false; input('time-input').disabled = false; button('seek').disabled = false; button('play').disabled = domain.end === 0;
464
465
  await seekTo(0);configureTurnPad();workspace?.refresh();activeCamera='a';if(cameraSync)alignCameras();fit();for(const id of ['layer-images','layer-mesh','layer-bones'])input(id).disabled=false;renderIdle();const restored=await setupPersistence();setupComments();await pickedTools?.loadInitialSideStatuses();if(!restored&&canRepeatIdle())void playComparison().catch(error=>message(describe(error),true));
465
466
  if(!readOnly&&controlServed)controlDispose=connectControl({sourceHash:data.sourceHash,mode:'compare',route:access.route,headers:()=>access.headers(),observe:controlState,apply:applyControl,onStatus:value=>text('control-state',value)});
467
+ bindWorkspaceVisibility({key:access.key,sourceHash:data.sourceHash,pause:()=>{idleHeld=true;stop();}});
466
468
  } catch (error) { failPair(error); for (const side of ['a', 'b'] as const) if (!players[side]) text(`${side}-empty`, `${side.toUpperCase()} Could not open comparison rig.`); text('reference-empty', 'Check the reference video and comparison inputs.'); }
467
469
  }
468
470
  function sharedBox():PoseBounds|null {const a=assets.a?.stage??players.a?.bounds(),b=assets.b?.stage??players.b?.bounds();return a&&b?unionBounds(a,b):a??b??null;}
package/web/main.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import {bindDirectionPanel} from './direction-panel.ts';
2
+ import {bindWorkspaceVisibility} from './workspace-visibility.ts';
2
3
  import type {DirectionInspection} from '../src/direction-inspection.ts';
3
4
  import {bindStageNav} from './stage-nav.ts';
4
5
  import {timeOnlyBasis,feedbackTimingLabel,requireFeedbackFrames,isTimeOnlyFeedback} from '../src/stage-comment.ts';
@@ -1078,6 +1079,7 @@ async function start(): Promise<void> {
1078
1079
  const restored=await setupPersistence();setupComments();await loadRebuildStatus();void loadRequirements();renderChest();restoreEnvironment();physicsPanel?.restore();bonesPanel?.restore();cutsPanel?.restore();clothPanel?.restore();idlePanel?.restore();rigFieldsPanel?.restore();meshPanel?.restore();void refreshDensityStrip();renderIdle();if(!restored&&canRepeatIdle()&&automaticIdlePreview(assets?.animations.map(item=>item.name)??[],animation,first,!!requestedId))void playPreview();
1079
1080
  // Only an instance that serves agent control is asked for its config: a plain open has no control endpoint (#164).
1080
1081
  if(!readOnly&&writes.control!==false)controlDispose=connectControl({sourceHash:data.sourceHash,mode:'single',route:access.route,headers:()=>access.headers(),observe:controlState,apply:applyControl,onStatus:value=>text('control-state',value)});
1082
+ bindWorkspaceVisibility({key:access.key,sourceHash:data.sourceHash,pause});
1081
1083
  } catch (error) { message(`Could not open review package: ${errorText(error)}`, true); text('dirty', 'Load failed'); }
1082
1084
  }
1083
1085
  /** `feedback` is the review dialog, not an Inspector section: a user action opens it; a restored older bookmark that saved it selects nothing. */
@@ -0,0 +1,14 @@
1
+ html, body, #owner-workspace { height: 100%; margin: 0; }
2
+ #owner-workspace { display: grid; grid-template: auto 1fr / minmax(12rem, 18rem) 1fr; color: var(--fg); background: var(--bg); }
3
+ .owner-header { grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
4
+ .owner-header h1 { margin: 0; font-size: 1rem; }
5
+ .owner-header select { width: auto; min-width: 6rem; max-width: 12rem; flex: 0 0 auto; }
6
+ .owner-status { flex: 1; color: var(--fg-muted); }
7
+ .owner-list { overflow: auto; border-right: 1px solid var(--border); padding: .5rem; }
8
+ .owner-list button { width: 100%; display: grid; gap: .25rem; margin-bottom: .5rem; padding: .75rem; text-align: left; }
9
+ .owner-list button[aria-pressed="true"] { border-color: var(--pass); }
10
+ .owner-target-title { overflow-wrap: anywhere; }
11
+ .owner-target-status, .owner-target-animation { color: var(--fg-muted); font-size: .8rem; }
12
+ .owner-stage { min-width: 0; min-height: 0; position: relative; }
13
+ .owner-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
14
+ .owner-stage iframe[hidden] { display: block !important; visibility: hidden; pointer-events: none; }
@@ -0,0 +1,5 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title></title><link rel="stylesheet" href="/styles.css"><link rel="stylesheet" href="/workspace.css"></head>
4
+ <body><div id="owner-workspace"></div><script type="module" src="/workspace.js"></script></body>
5
+ </html>