rig-review 2.13.0 → 4.0.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.
- package/README.md +1 -1
- package/docs/PARTS_VIEW.md +1 -1
- package/docs/REVIEW_PACKAGE.md +32 -91
- package/docs/STABILITY.md +27 -194
- package/docs/WORKFLOWS.md +0 -107
- package/package.json +1 -1
- package/skills/rig-review/SKILL.md +11 -25
- package/src/build.ts +2 -2
- package/src/direction-inspection.ts +6 -2
- package/src/front.ts +4 -193
- package/src/interview-scene.ts +3 -3
- package/src/job-act.ts +1 -35
- package/src/job-api.ts +27 -19
- package/src/job-cli.ts +3 -3
- package/src/job-contract.ts +14 -50
- package/src/job-front.ts +17 -44
- package/src/job-host.ts +1 -4
- package/src/job-session.ts +22 -10
- package/src/job-source.ts +3 -17
- package/src/job-store.ts +80 -6
- package/src/job-worker.ts +1 -47
- package/src/manifest.ts +23 -4
- package/src/open.ts +2 -3
- package/src/scene-inspection.ts +50 -0
- package/src/server.ts +1 -1
- package/web/catalog-en.ts +37 -27
- package/web/catalog-ko.ts +37 -27
- package/web/compare.css +0 -4
- package/web/direction-panel.ts +22 -6
- package/web/inspector-blocks.ts +8 -4
- package/web/job-rig-capture.ts +62 -12
- package/web/job-rig-screen.ts +75 -55
- package/web/job-session.ts +89 -1091
- package/web/main.ts +113 -56
- package/web/parts-viewport-provider.ts +8 -3
- package/web/retained-frame-stage.ts +7 -7
- package/web/rig-host.ts +5 -3
- package/web/rig-viewport-provider.ts +2 -0
- package/web/scene-plates.ts +57 -4
- package/web/styles.css +12 -82
- package/web/viewport-capture.ts +12 -2
- package/web/workspace-ui.ts +5 -6
- package/src/front-worker.ts +0 -2
- package/src/job-hub.ts +0 -304
- package/src/job-image-set.ts +0 -73
- package/web/job-hub.ts +0 -160
package/src/job-image-set.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type {JobImageSetInput, JobImageSourceBinding} from './job-contract.ts';
|
|
2
|
-
import {exactObject, jobHash, jobObject, jobPath, jobSha, jobText, requestDigest} from './job-api.ts';
|
|
3
|
-
import {JobError} from './job-store.ts';
|
|
4
|
-
|
|
5
|
-
/** Check discovery before sending an image ask, including against older hubs. */
|
|
6
|
-
export function assertJobImageSetCapability(capabilities: unknown): void {
|
|
7
|
-
if (!capabilities || typeof capabilities !== 'object' ||
|
|
8
|
-
(capabilities as {imageSetVerdict?: unknown}).imageSetVerdict !== true) {
|
|
9
|
-
throw new JobError('JOB_IMAGE_SET_UNSUPPORTED');
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type ImageSetBinding = Pick<JobImageSourceBinding, 'imageSet' | 'imageSetDigest' | 'duplicateHashes'>;
|
|
14
|
-
type ImageSetRead = {kind: 'bytes'; readBytes: (path: string) => Uint8Array} | {kind: 'sealed'};
|
|
15
|
-
|
|
16
|
-
/** One declared-shape/digest codec; only byte preparation reads and hashes assets. */
|
|
17
|
-
function imageSetBinding(input: JobImageSetInput, read: ImageSetRead): ImageSetBinding {
|
|
18
|
-
try { jobObject(input, ['purpose', 'images']); }
|
|
19
|
-
catch { throw new JobError('JOB_IMAGE_SET_INVALID'); }
|
|
20
|
-
if (input.purpose !== 'plate-adoption' || !Array.isArray(input.images) ||
|
|
21
|
-
input.images.length < 2 || input.images.length > 8) throw new JobError('JOB_IMAGE_SET_INVALID');
|
|
22
|
-
const names = new Set<string>(), paths = new Set<string>();
|
|
23
|
-
const hashes = new Map<string, string[]>();
|
|
24
|
-
const images = input.images.map(raw => {
|
|
25
|
-
let name: string;
|
|
26
|
-
try {
|
|
27
|
-
jobObject(raw, ['role', 'name', 'path', 'sha256']);
|
|
28
|
-
name = jobText(raw.name);
|
|
29
|
-
if (raw.sha256 !== undefined) jobSha(raw.sha256);
|
|
30
|
-
} catch { throw new JobError('JOB_IMAGE_SET_INVALID'); }
|
|
31
|
-
if (!['source', 'candidate', 'reference'].includes(raw.role)) throw new JobError('JOB_IMAGE_SET_ROLE_INVALID');
|
|
32
|
-
let path: string;
|
|
33
|
-
try { path = jobPath(raw.path); }
|
|
34
|
-
catch { throw new JobError('JOB_IMAGE_SET_PATH_REFUSED'); }
|
|
35
|
-
if (names.has(name)) throw new JobError('JOB_IMAGE_SET_DUPLICATE_NAME');
|
|
36
|
-
if (paths.has(path)) throw new JobError('JOB_IMAGE_SET_DUPLICATE_PATH');
|
|
37
|
-
names.add(name); paths.add(path);
|
|
38
|
-
let sha256: string;
|
|
39
|
-
if (read.kind === 'bytes') {
|
|
40
|
-
let bytes: Uint8Array;
|
|
41
|
-
try { bytes = read.readBytes(path); }
|
|
42
|
-
catch { throw new JobError('JOB_IMAGE_SET_PATH_REFUSED'); }
|
|
43
|
-
sha256 = jobHash(bytes);
|
|
44
|
-
if (raw.sha256 !== undefined && raw.sha256 !== sha256) throw new JobError('JOB_SOURCE_MISMATCH');
|
|
45
|
-
} else {
|
|
46
|
-
try { sha256 = jobSha(raw.sha256); }
|
|
47
|
-
catch { throw new JobError('JOB_IMAGE_SET_INVALID'); }
|
|
48
|
-
}
|
|
49
|
-
const group = hashes.get(sha256) ?? [];
|
|
50
|
-
group.push(name); hashes.set(sha256, group);
|
|
51
|
-
return {role: raw.role, name, path, sha256};
|
|
52
|
-
});
|
|
53
|
-
if (images.filter(image => image.role === 'source').length !== 1 ||
|
|
54
|
-
!images.some(image => image.role === 'candidate')) throw new JobError('JOB_IMAGE_SET_ROLE_INVALID');
|
|
55
|
-
const canonical = images.map(({role, name, sha256}) => ({role, name, sha256}));
|
|
56
|
-
return {imageSet: {purpose: input.purpose, images}, imageSetDigest: jobHash(JSON.stringify(canonical)),
|
|
57
|
-
duplicateHashes: [...hashes].filter(([, names]) => names.length > 1).map(([sha256, names]) => ({names, sha256}))};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** Hash the actual bytes. Array order and exact Unicode strings are significant. */
|
|
61
|
-
export function prepareJobImageSet(input: JobImageSetInput,
|
|
62
|
-
readBytes: (path: string) => Uint8Array): ImageSetBinding {
|
|
63
|
-
return imageSetBinding(input, {kind: 'bytes', readBytes});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** Decode declared sealed identities without a byte reader or a native freshness claim. */
|
|
67
|
-
export function parseJobImageSetBinding(value: unknown): ImageSetBinding {
|
|
68
|
-
const raw = exactObject(value, ['imageSet', 'imageSetDigest', 'duplicateHashes'], 'JOB_IMAGE_SET_INVALID');
|
|
69
|
-
const binding = imageSetBinding(raw.imageSet as JobImageSetInput, {kind: 'sealed'});
|
|
70
|
-
if (jobSha(raw.imageSetDigest) !== binding.imageSetDigest ||
|
|
71
|
-
requestDigest(raw.duplicateHashes) !== requestDigest(binding.duplicateHashes)) throw new JobError('JOB_IMAGE_SET_INVALID');
|
|
72
|
-
return binding;
|
|
73
|
-
}
|
package/web/job-hub.ts
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import {createRetainedFrameStage, mountRetainedWorkspace} from './retained-frame-stage.ts';
|
|
2
|
-
import {hashCapabilityAccess} from './instance-access.ts';
|
|
3
|
-
/** Owner-only job selection. Each retained frame owns its existing job window and draft. */
|
|
4
|
-
import type {JobHubList, JobHubRow} from '../src/job-hub.ts';
|
|
5
|
-
|
|
6
|
-
export const JOB_HUB_READY = 'rig-review-job-hub-ready/1';
|
|
7
|
-
export const JOB_HUB_VISIBILITY = 'rig-review-job-hub-visibility/1';
|
|
8
|
-
export interface JobHubBinding {
|
|
9
|
-
incarnation: string;
|
|
10
|
-
jobId: string;
|
|
11
|
-
publicationId: string | null;
|
|
12
|
-
sourceHash: string | null;
|
|
13
|
-
}
|
|
14
|
-
export function jobHubMessageMatches(event: Pick<MessageEvent, 'origin' | 'source' | 'data'>,
|
|
15
|
-
origin: string, source: MessageEventSource | null, binding: JobHubBinding, kind: 'ready' | 'visibility'): boolean {
|
|
16
|
-
if (!source || event.origin !== origin || event.source !== source || !event.data || typeof event.data !== 'object') return false;
|
|
17
|
-
const value = event.data;
|
|
18
|
-
const keys = ['schema', 'incarnation', 'jobId', 'publicationId', 'sourceHash', ...(kind === 'visibility' ? ['visible', 'language'] : [])];
|
|
19
|
-
return !Object.keys(value).some(key => !keys.includes(key)) &&
|
|
20
|
-
value.schema === (kind === 'ready' ? JOB_HUB_READY : JOB_HUB_VISIBILITY) &&
|
|
21
|
-
value.incarnation === binding.incarnation && value.jobId === binding.jobId &&
|
|
22
|
-
value.publicationId === binding.publicationId && value.sourceHash === binding.sourceHash &&
|
|
23
|
-
(binding.publicationId === null && binding.sourceHash === null ||
|
|
24
|
-
typeof binding.publicationId === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(binding.publicationId) &&
|
|
25
|
-
typeof binding.sourceHash === 'string' && /^[a-f0-9]{64}$/.test(binding.sourceHash)) &&
|
|
26
|
-
(kind === 'ready' || typeof value.visible === 'boolean' && ['en', 'ko'].includes(value.language));
|
|
27
|
-
}
|
|
28
|
-
export function checkedJobHubLocation(href: string) {
|
|
29
|
-
const url = new URL(href), incarnation = url.searchParams.get('workspace');
|
|
30
|
-
if (url.pathname !== '/hub/' || !incarnation || !/^[a-f0-9-]{36}$/.test(incarnation) ||
|
|
31
|
-
[...url.searchParams.keys()].some(key => !['workspace', 'lang'].includes(key) || url.searchParams.getAll(key).length !== 1) ||
|
|
32
|
-
url.searchParams.has('lang') && !['en', 'ko'].includes(url.searchParams.get('lang')!)) throw new Error('JOB_REQUEST_INVALID');
|
|
33
|
-
return {url, incarnation};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function checkedJobHubList(value: JobHubList, incarnation: string): JobHubList {
|
|
37
|
-
if (value?.schema !== 'rig-review-job-hub/1' || value.incarnation !== incarnation ||
|
|
38
|
-
!Number.isSafeInteger(value.limit) || value.limit < 1 || value.limit > 32 ||
|
|
39
|
-
!Array.isArray(value.jobs) || value.jobs.length > value.limit) throw new Error('JOB_HUB_STATE_INVALID');
|
|
40
|
-
const ids = new Set<string>();
|
|
41
|
-
for (const job of value.jobs) {
|
|
42
|
-
if (!job || typeof job.jobId !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(job.jobId) || ids.has(job.jobId) ||
|
|
43
|
-
!['active', 'closed'].includes(job.status) || !Number.isSafeInteger(job.generation) || job.generation < 0 ||
|
|
44
|
-
!Number.isSafeInteger(job.pendingCount) || job.pendingCount < 0 || job.publication !== null &&
|
|
45
|
-
(!job.publication || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(job.publication.publicationId) ||
|
|
46
|
-
!/^[a-f0-9]{64}$/.test(job.publication.instanceKey) || !/^[a-f0-9]{64}$/.test(job.publication.sourceHash) ||
|
|
47
|
-
typeof job.publication.label !== 'string' || job.publication.label.length > 512)) throw new Error('JOB_HUB_STATE_INVALID');
|
|
48
|
-
ids.add(job.jobId);
|
|
49
|
-
}
|
|
50
|
-
return value;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export async function mountJobHub(root: HTMLElement): Promise<() => void> {
|
|
54
|
-
const i18n = await import('./i18n.ts');
|
|
55
|
-
const {t, getLanguage} = i18n;
|
|
56
|
-
let storage: Storage | null = null;
|
|
57
|
-
try {storage = sessionStorage;} catch { /* Memory-only access. */ }
|
|
58
|
-
const {url: locationURL, incarnation} = checkedJobHubLocation(location.href);
|
|
59
|
-
const capability = hashCapabilityAccess(locationURL, 'rig-review-job-hub/1:' + locationURL.origin + ':' + incarnation,
|
|
60
|
-
() => storage, href => history.replaceState(history.state, '', href), {strip: 'always-after-storage', storedValue: 'validate', fallback: ''});
|
|
61
|
-
const access = {incarnation, capability};
|
|
62
|
-
const requestedLanguage = new URL(location.href).searchParams.get('lang');
|
|
63
|
-
if (requestedLanguage === 'en' || requestedLanguage === 'ko') i18n.setLanguagePreference(requestedLanguage);
|
|
64
|
-
const workspace = mountRetainedWorkspace({root, kind: 'hub'});
|
|
65
|
-
const {stage, language} = workspace;
|
|
66
|
-
type Frame = {frame: HTMLIFrameElement; row: JobHubRow; binding: JobHubBinding; announced?: JobHubBinding};
|
|
67
|
-
const cancellation = new AbortController();
|
|
68
|
-
let current: JobHubList | null = null, disposed = false;
|
|
69
|
-
let status = 'job.hubHint', timer: ReturnType<typeof setTimeout> | undefined;
|
|
70
|
-
const binding = (row: JobHubRow): JobHubBinding => ({incarnation: access.incarnation, jobId: row.jobId,
|
|
71
|
-
publicationId: row.publication?.publicationId ?? null, sourceHash: row.publication?.sourceHash ?? null});
|
|
72
|
-
const retained = createRetainedFrameStage<Frame>({stage, limit: () => current!.limit, key: entry => entry.row.jobId,
|
|
73
|
-
message: entry => ({...entry.binding, schema: JOB_HUB_VISIBILITY}), language: getLanguage, origin: location.origin,
|
|
74
|
-
visibilityOrder: 'after-state', languageChange: 'selection'});
|
|
75
|
-
function render() {
|
|
76
|
-
workspace.render({
|
|
77
|
-
lang: getLanguage(), heading: t('job.hubTitle'), listLabel: t('job.hubJobs'),
|
|
78
|
-
languageLabel: t('interview.language'), englishLabel: t('English'), koreanLabel: t('Korean'),
|
|
79
|
-
message: t(status), selected: retained.selected,
|
|
80
|
-
items: (current?.jobs ?? []).map(row => ({
|
|
81
|
-
key: row.jobId, dataset: {jobId: row.jobId}, label: row.publication?.label || row.jobId,
|
|
82
|
-
state: row.status === 'closed' ? t('job.hubClosed') : t('job.hubPending', [row.pendingCount]),
|
|
83
|
-
detail: row.publication?.sourceHash ?? '',
|
|
84
|
-
onSelect: () => {void select(row).catch(() => {status = 'JOB_HUB_REQUEST_REFUSED'; render();});},
|
|
85
|
-
})),
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
async function select(row: JobHubRow) {
|
|
89
|
-
const selection = retained.beginSelection();
|
|
90
|
-
let entry = retained.get(row.jobId);
|
|
91
|
-
if (!entry && row.status === 'closed') {
|
|
92
|
-
status = 'job.hubClosed'; retained.select(row.jobId); render(); return;
|
|
93
|
-
}
|
|
94
|
-
if (!entry) {
|
|
95
|
-
if (!current || retained.atLimit()) throw new Error('JOB_HUB_LIMIT');
|
|
96
|
-
const response = await fetch('/hub/api/jobs/' + row.jobId + '/open', {method: 'POST',
|
|
97
|
-
headers: {'Content-Type': 'application/json', 'X-Review-Capability': access.capability},
|
|
98
|
-
body: JSON.stringify({schema: 'rig-review-job-hub/1', incarnation: access.incarnation}),
|
|
99
|
-
signal: AbortSignal.any([cancellation.signal, AbortSignal.timeout(5000)])});
|
|
100
|
-
const grant = await response.json();
|
|
101
|
-
if (!response.ok) throw new Error('JOB_HUB_REQUEST_REFUSED');
|
|
102
|
-
if (!retained.isCurrent(selection)) return;
|
|
103
|
-
if (grant.schema !== 'rig-review-job-hub/1' || grant.incarnation !== access.incarnation || grant.jobId !== row.jobId ||
|
|
104
|
-
grant.entry !== '/jobs/' + row.jobId + '/?hub=' + access.incarnation || !/^[a-f0-9]{64}$/.test(grant.capability)) throw new Error('JOB_HUB_STATE_INVALID');
|
|
105
|
-
const url = new URL(grant.entry, location.origin); url.searchParams.set('lang', getLanguage()); url.hash = 'cap=' + grant.capability;
|
|
106
|
-
const frame = retained.createFrame(row.publication?.label || row.jobId, url.href);
|
|
107
|
-
entry = {frame, row, binding: {...binding(row), publicationId: null, sourceHash: null}};
|
|
108
|
-
retained.retain(entry);
|
|
109
|
-
}
|
|
110
|
-
status = 'job.hubHint'; retained.select(row.jobId); render();
|
|
111
|
-
}
|
|
112
|
-
function ready(event: MessageEvent) {
|
|
113
|
-
const entry = retained.get(event.data?.jobId);
|
|
114
|
-
if (!entry || !current) return;
|
|
115
|
-
const candidate: JobHubBinding = {incarnation: access.incarnation, jobId: entry.row.jobId,
|
|
116
|
-
publicationId: event.data?.publicationId, sourceHash: event.data?.sourceHash};
|
|
117
|
-
if (!jobHubMessageMatches(event, location.origin, entry.frame.contentWindow, candidate, 'ready')) return;
|
|
118
|
-
entry.announced = candidate;
|
|
119
|
-
if (jobHubMessageMatches(event, location.origin, entry.frame.contentWindow, binding(entry.row), 'ready')) {
|
|
120
|
-
entry.binding = candidate; retained.visibility(entry);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
async function refresh() {
|
|
124
|
-
try {
|
|
125
|
-
const response = await fetch('/hub/api/jobs', {headers: {'X-Review-Capability': access.capability},
|
|
126
|
-
signal: AbortSignal.any([cancellation.signal, AbortSignal.timeout(5000)])});
|
|
127
|
-
if (!response.ok) throw new Error('JOB_HUB_REQUEST_REFUSED');
|
|
128
|
-
current = checkedJobHubList(await response.json(), access.incarnation);
|
|
129
|
-
for (const row of current.jobs) {
|
|
130
|
-
const entry = retained.get(row.jobId);
|
|
131
|
-
if (!entry) continue;
|
|
132
|
-
entry.row = row;
|
|
133
|
-
if (entry.announced && JSON.stringify(entry.announced) === JSON.stringify(binding(row))) entry.binding = entry.announced;
|
|
134
|
-
retained.visibility(entry);
|
|
135
|
-
}
|
|
136
|
-
render();
|
|
137
|
-
if (!retained.selected && current.jobs[0]) await select(current.jobs[0]);
|
|
138
|
-
} catch {if (!disposed) {status = 'JOB_HUB_REQUEST_REFUSED'; render();}}
|
|
139
|
-
finally {if (!disposed) timer = setTimeout(() => {void refresh();}, 1000);}
|
|
140
|
-
}
|
|
141
|
-
language.onchange = () => {i18n.setLinkLanguage(null); i18n.setLanguagePreference(language.value === 'ko' ? 'ko' : 'en');};
|
|
142
|
-
const unlocalize = i18n.onLanguageChange(() => {render(); retained.languageChanged();});
|
|
143
|
-
globalThis.addEventListener('message', ready);
|
|
144
|
-
const stop = () => {
|
|
145
|
-
if (disposed) return;
|
|
146
|
-
disposed = true; retained.dispose(); clearTimeout(timer); cancellation.abort(); unlocalize();
|
|
147
|
-
globalThis.removeEventListener('message', ready); globalThis.removeEventListener('pagehide', stop);
|
|
148
|
-
};
|
|
149
|
-
globalThis.addEventListener('pagehide', stop, {once: true});
|
|
150
|
-
render(); void refresh(); return stop;
|
|
151
|
-
}
|
|
152
|
-
if (typeof document !== 'undefined' && typeof location !== 'undefined' && location.pathname === '/hub/') {
|
|
153
|
-
const root = document.getElementById('app');
|
|
154
|
-
if (root && !root.childElementCount) {
|
|
155
|
-
void mountJobHub(root).catch(async () => {
|
|
156
|
-
const {t} = await import('./i18n.ts');
|
|
157
|
-
root.textContent = t('JOB_HUB_REQUEST_REFUSED');
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|