rig-review 2.4.6 → 2.5.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.
@@ -1085,6 +1085,7 @@ the host-owned integration example are in
1085
1085
  - `rig-review session ask <job-url> --generation <n> --key <id> --publication <id> --subject <JSON> [--request-id <id>]`
1086
1086
  - `rig-review session next <job-url> [--after <cursor>] [--wait-ms <n>] [--request-id <id>]`
1087
1087
  - `rig-review session close <job-url> --generation <n> --key <id> --reason <words> [--request-id <id>]`
1088
+ - Consumer only, `rig-review session fetch-act <job-url> --act <actId> --consumer-capability-stdin [--still-out <existing-directory>]`. The trusted consumer pipes its existing grant on stdin. New rig acts require `--still-out`.
1088
1089
  Agent verbs authenticate with `RIG_REVIEW_JOB_AGENT_CAPABILITY` (`Authorization: Bearer …`) against `http://127.0.0.1:<port>/jobs/<jobId>` and refuse `fetch-act` (`JOB_AUTHORITY_REFUSED`). See [Standing live job workflow](WORKFLOWS.md#standing-live-job-workflow) for an ordinary-package launch, bootstrap and explicit close example.
1089
1090
  - **Bootstrap-declared reviewer.** `JobReviewerBinding` (`id` and `role` as `'owner'` or `'delegate'` inside `JobHumanAuthority`) is declared by trusted host bootstrap when opening the window. The browser UI cannot type, edit or override this binding. It records bootstrap-declared provenance rather than keyboard-user authentication. Create maps `role` to its existing `by` authority and preserves the declared reviewer identity.
1090
1091
  - **Trusted host ports and public managed-host startup seam.** `JobHostPorts` separates `handleJobApi` (which accepts agent verbs and consumer `fetch-act` only) from closed same-origin UI routes (`readPublication`, `commitUIAct`, `ackDisplayed`, `jobLiveness`, `subscribeJob`, mounted by `createJobFront` under `/jobs/<jobId>/…` with sealed retained publication routes; the standalone owner HTML root accepts the default or literal `?lang=en` or `?lang=ko` only) that remain unavailable to agent tokens. Raw `Request` objects preserve real `Origin`, capability, body size and abort context. A TypeScript value is never authentication evidence. In the public managed-host startup seam (`startJobHost(options: JobHostOptions): Promise<JobOwnerHost>` from `@rig-c/review/job-host`, where `JobHostOptions extends JobWorkerOptions` adds `readerId?: string`, `bindingId?: string` and `partsEnumeratorId?: string`, frozen in [Public API stability](STABILITY.md#managed-owner-host)), each present hook (`readPublished`, `installWriterBinding`, `partsEnumerator`) requires a nonempty declared ID and a missing hook requires its ID to be absent (`JOB_HOST_OPTION_ID_INVALID`). Equal declared IDs, API/act schemas and actual enumerator versions permit authenticated active-listener reuse across processes and newly allocated function objects via `/jobs/<jobId>/host` (`schema: 'rig-review-job-host/1'`); differing IDs, hook-presence differences and unrecorded older listener IDs fail by name (`JOB_HOST_REUSE_MISMATCH`) with the option name and both IDs while preserving the existing listener. No function hashes are used. `installWriterBinding` receives `{jobId, origin, fetchCapability}` after reuse validation and runs on a matching new or reused host.
@@ -1143,9 +1144,23 @@ use exact member names and human words. Every source identity and digest is
1143
1144
  server-derived. Consumer fetch, human authority, drafts, nonce and cursor rules
1144
1145
  apply through the existing cycle. [Public shapes and refusals](STABILITY.md#image-set-verdict-extension).
1145
1146
 
1147
+ ### Rig verdict still backend
1148
+
1149
+ New rig-review verdicts use `rig-review/act@3` and a top-level `still` with `path`, `sha256`, `camera:"fixed"` and `frame`. The path is exactly `<sha256>.png`. Setup uses `frame:"setup"`. Numeric seconds require `animation` alongside the frame. Other new acts and historical rig acts retain act@2. `JOB_ACT_SCHEMA`, API@2, stored compatibility markers and the twelve public facade runtime exports retain their established values. The rig-specific revision constant is internal to the contract module. Public type exports include `JobRigReviewAct`, `JobRigStill` and `JobRigCapture`.
1150
+
1151
+ The authenticated rig UI submission accepts `capture` alongside the human `value`. Its closed fields are `png` as a PNG data URI, `width`, `height`, `camera`, `framing`, `view`, `frame`, optional `animation`, `playing` and `binding`. Binding contains `publicationId`, `instanceKey`, `sourceHash`, `pageId`, `askId`, `drawGeneration` and `playerGeneration`. The daemon compares source/page/ask/instance identity with the current displayed nonce and derives the hash and filename from validated PNG bytes. Draw provenance is supplied by the authenticated human UI. The PNG is the whole default-camera Rig viewport and its background, with tool overlays excluded. The standing window normally composites the player's model rasters and background into one visible canonical bitmap, with tool overlays kept separate. Capture synchronously makes only an equal-size copy of that committed bitmap. Model rendering and background composition occur exclusively during normal presentation. Whole-device-pixel global translation of the unchanged bitmap preserves capture eligibility. Changes to device-pixel phase, pane-local placement or extent, source binding, or player/frame generation refuse capture. A successful public draw snapshot binds canonical bitmap identity, native dimensions, CSS size and DPR, local placement and device-pixel phase together with the exact time, animation and source before asynchronous PNG encoding. The first full request and human words are retained for reply-loss retry. The inspection transport seeks and pauses playback. Exact-pixel acceptance compares the full model and background in an overlay-free square fixture. Frame chrome lies outside the capture contract. Continuous moving-playback acceptance remains separate in #559.
1152
+
1153
+ Failed capture, nondefault camera/framing, solo/highlight/comparison and mismatched binding refuse by name. Playing is accepted. Raw PNG is bounded to 8 MiB, each axis to 16384 and the decoded image to 16,777,216 pixels. Only authenticated same-origin rig-capture submissions may use a 12 MiB JSON body. Ordinary mutations retain 256 KiB. PNG BLOB, exact act bytes, act, replay, answered ask and event commit in one SQLite transaction. Retried submissions reuse the immutable first act. Close revokes fetch while preserving the act and PNG for the act lifetime.
1154
+
1155
+ The existing consumer POST `/jobs/<jobId>/api` accepts the unchanged fetch-act body and existing bearer grant. Default/JSON Accept returns the existing API envelope. `Accept: application/vnd.rig-review.act+json` returns raw act bytes, and `Accept: image/png` returns the bound PNG for the same actId. Destination paths stay local to the CLI.
1156
+
1157
+ The consumer CLI bounds stdin to 4096 bytes and accepts one existing 64-hex grant with an optional final newline. It bounds raw act reads to 512 KiB and PNG reads to 8 MiB independently of Content-Length. It validates both responses before writing a PNG temporary file inside the existing consumer directory, fsyncs the file, renames it to the content-addressed filename and then writes exact act bytes to stdout. Per-directory local output serialization preserves existing verified PNGs and refuses conflicting files/locks. Pre-stdout failure removes only this invocation's files. A MIDWRITE EPIPE exits nonzero and may leave the installed PNG. The consumer ignores partial stdout on nonzero exit and owns act.json persistence and pair staging.
1158
+
1159
+ The consumer writes successful stdout verbatim as act.json beside the PNG and hashes those exact bytes itself. The act contains the PNG hash only. No self-hash, manifest, envelope, private binding discovery or destination filesystem endpoint is introduced.
1160
+
1146
1161
  ### C4 schema and stored-state compatibility
1147
1162
 
1148
- API@1 and unsupported requests refuse `JOB_REQUEST_INVALID` with `JOB_API_SCHEMA_MISMATCH`, HTTP 400, the current API@2 response schema and unchanged generation. The CLI checks response schema before consuming its value. Consumer writers must also check act@2. JobData and host descriptors carry explicit `apiSchema` and `actSchema` markers. Missing or old stored markers refuse `JOB_STORED_SCHEMA_MISMATCH` before credentials, status or replay. Authenticated active-listener reuse compares declared hook IDs, API/act schemas and the actual enumerator version. A stopped listener can be explicitly restarted for the same job with new valid hook IDs. Old retained documents and approvals remain under their original schemas and are never migrated or relabelled. Legacy one-shot contracts retain their documented boundaries.
1163
+ API@1 and unsupported requests refuse `JOB_REQUEST_INVALID` with `JOB_API_SCHEMA_MISMATCH`, HTTP 400, the current API@2 response schema and unchanged generation. The CLI checks response schema before consuming its value. Consumer writers check act@2 for ordinary/historical acts and act@3 for new rig-review verdicts with a still. JobData and host descriptors carry explicit `apiSchema` and `actSchema` markers. Missing or old stored markers refuse `JOB_STORED_SCHEMA_MISMATCH` before credentials, status or replay. Authenticated active-listener reuse compares declared hook IDs, API/act schemas and the actual enumerator version. A stopped listener can be explicitly restarted for the same job with new valid hook IDs. Old retained documents and approvals remain under their original schemas and are never migrated or relabelled. Legacy one-shot contracts retain their documented boundaries.
1149
1164
 
1150
1165
  The manifest and complete retained image rows enter the composite source hash. Limits are 4096 rows, 128 UTF-16 role units, 4096 path units, 64 MiB per raw file or decoded RGBA allocation and 256 MiB unique retained bytes. Source-bound refusals retain the old head and generation. Reference-set, path, missing-file, PNG, hash and limit details are bounded. A missing row names its official zero-based index, role and manifest-relative path. Create #184 owns its production record projection and consumer checks, which remain pending. [Public boundary](STABILITY.md#parts-enumeration-boundary).
1151
1166
 
package/docs/STABILITY.md CHANGED
@@ -353,6 +353,8 @@ model binding nor a valid image-set binding uses `JOB_ASK_INVALID`.
353
353
 
354
354
  ## Named export inventory
355
355
 
356
+ The backend rig-still extension retains the twelve runtime exports and `JOB_ACT_SCHEMA` at act@2. `JobAct` additionally includes `JobRigReviewAct` at act@3 with top-level `JobRigStill`. The facade adds type-only `JobLegacyAct`, `JobRigReviewAct`, `JobRigStill` and `JobRigCapture` exports. Existing API/store/reuse markers and ordinary/historical acts retain @2. The rig revision constant and transport limits remain internal to `src/job-contract.ts`. Consumer checks distinguish these act revisions as described in [Rig verdict still backend](REVIEW_PACKAGE.md#rig-verdict-still-backend).
357
+
356
358
  The exact runtime exports are listed below. Constants preserve their literal
357
359
  values from the frozen semantic contract.
358
360
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rig-review",
3
- "version": "2.4.6",
3
+ "version": "2.5.0",
4
4
  "type": "module",
5
5
  "description": "Local human rig inspection and structured feedback export",
6
6
  "license": "MIT",
@@ -12,9 +12,54 @@ export function validateCommentCrop(value:unknown):Buffer {return validatePngCro
12
12
  /** Shared bounded PNG validator; callers own their closed comment codecs. */
13
13
  export function validatePngCrop(crop:PngCrop):Buffer {
14
14
  if(!crop||!Number.isSafeInteger(crop.width)||!Number.isSafeInteger(crop.height)||crop.width<1||crop.height<1||crop.width>16384||crop.height>16384||crop.width*crop.height>16777216||typeof crop.png!=='string'||crop.png.length>90*1024*1024||!/^data:image\/png;base64,[A-Za-z0-9+/]+={0,2}$/.test(crop.png)||!/^[a-f0-9]{64}$/.test(crop.sha256)||crop.path!==`comment-crops/${crop.sha256}.png`)throw new Error('COMMENT_CROP_INVALID: bounded content-addressed PNG required');
15
- const c={crop},bytes=Buffer.from(c.crop.png.slice('data:image/png;base64,'.length),'base64');
16
- if(bytes.length<33||bytes.subarray(0,8).toString('hex')!=='89504e470d0a1a0a'||bytes.toString('ascii',12,16)!=='IHDR'||bytes.readUInt32BE(16)!==c.crop.width||bytes.readUInt32BE(20)!==c.crop.height||createHash('sha256').update(bytes).digest('hex')!==c.crop.sha256)throw new Error('COMMENT_CROP_INVALID: PNG signature, dimensions or SHA-256 differ');
17
- const data:Buffer[]=[];let offset=8,ended=false,hasData=false;const color=bytes[25],channels=color===6?4:color===2?3:0;if(bytes[24]!==8||!channels||bytes[26]!==0||bytes[27]!==0||bytes[28]!==0)throw new Error('COMMENT_CROP_INVALID: expected noninterlaced 8-bit RGB/RGBA');while(offset<bytes.length){if(offset+12>bytes.length)throw new Error('COMMENT_CROP_INVALID: truncated PNG chunk');const length=bytes.readUInt32BE(offset),end=offset+12+length;if(end>bytes.length)throw new Error('COMMENT_CROP_INVALID: PNG chunk length');const type=bytes.toString('ascii',offset+4,offset+8);let crc=0xffffffff;for(const n of bytes.subarray(offset+4,end-4)){crc^=n;for(let bit=0;bit<8;bit++)crc=(crc>>>1)^((crc&1)?0xedb88320:0);}if(((crc^0xffffffff)>>>0)!==bytes.readUInt32BE(end-4))throw new Error('COMMENT_CROP_INVALID: PNG chunk CRC');if(type==='IDAT'){hasData=true;data.push(bytes.subarray(offset+8,end-4));}if(type==='acTL')throw new Error('COMMENT_CROP_INVALID: static PNG required');if(type==='IEND'){if(length!==0||end!==bytes.length)throw new Error('COMMENT_CROP_INVALID: PNG end');ended=true;}offset=end;}if(!ended||!hasData)throw new Error('COMMENT_CROP_INVALID: PNG data/end missing');const stride=c.crop.width*channels+1;let inflated:Buffer;try{inflated=inflateSync(Buffer.concat(data),{maxOutputLength:stride*c.crop.height});}catch{throw new Error('COMMENT_CROP_INVALID: bounded PNG data decode');}if(inflated.length!==stride*c.crop.height||Array.from({length:c.crop.height},(_,i)=>inflated[i*stride]).some(n=>n===undefined||n>4))throw new Error('COMMENT_CROP_INVALID: PNG scanlines');return bytes;
15
+ const bytes=Buffer.from(crop.png.slice('data:image/png;base64,'.length),'base64');
16
+ if(createHash('sha256').update(bytes).digest('hex')!==crop.sha256)throw new Error('COMMENT_CROP_INVALID: PNG signature, dimensions or SHA-256 differ');
17
+ return validatePngBytes(bytes,crop.width,crop.height);
18
+ }
19
+
20
+ /** Shared decoded-byte core. Callers enforce their own transport and byte limits. */
21
+ export function validatePngBytes(bytes:Buffer,width:number,height:number):Buffer {
22
+ if(!Number.isSafeInteger(width)||!Number.isSafeInteger(height)||width<1||height<1||
23
+ width>16384||height>16384||width*height>16777216||bytes.length<33||
24
+ bytes.subarray(0,8).toString('hex')!=='89504e470d0a1a0a'||
25
+ bytes.toString('ascii',12,16)!=='IHDR'||bytes.readUInt32BE(16)!==width||bytes.readUInt32BE(20)!==height) {
26
+ throw new Error('COMMENT_CROP_INVALID: PNG signature, dimensions or SHA-256 differ');
27
+ }
28
+ const data:Buffer[]=[];
29
+ let offset=8,ended=false,hasData=false;
30
+ const color=bytes[25],channels=color===6?4:color===2?3:0;
31
+ if(bytes[24]!==8||!channels||bytes[26]!==0||bytes[27]!==0||bytes[28]!==0) {
32
+ throw new Error('COMMENT_CROP_INVALID: expected noninterlaced 8-bit RGB/RGBA');
33
+ }
34
+ while(offset<bytes.length) {
35
+ if(offset+12>bytes.length)throw new Error('COMMENT_CROP_INVALID: truncated PNG chunk');
36
+ const length=bytes.readUInt32BE(offset),end=offset+12+length;
37
+ if(end>bytes.length)throw new Error('COMMENT_CROP_INVALID: PNG chunk length');
38
+ const type=bytes.toString('ascii',offset+4,offset+8);
39
+ let crc=0xffffffff;
40
+ for(const n of bytes.subarray(offset+4,end-4)) {
41
+ crc^=n;
42
+ for(let bit=0;bit<8;bit++)crc=(crc>>>1)^((crc&1)?0xedb88320:0);
43
+ }
44
+ if(((crc^0xffffffff)>>>0)!==bytes.readUInt32BE(end-4))throw new Error('COMMENT_CROP_INVALID: PNG chunk CRC');
45
+ if(type==='IDAT'){hasData=true;data.push(bytes.subarray(offset+8,end-4));}
46
+ if(type==='acTL')throw new Error('COMMENT_CROP_INVALID: static PNG required');
47
+ if(type==='IEND') {
48
+ if(length!==0||end!==bytes.length)throw new Error('COMMENT_CROP_INVALID: PNG end');
49
+ ended=true;
50
+ }
51
+ offset=end;
52
+ }
53
+ if(!ended||!hasData)throw new Error('COMMENT_CROP_INVALID: PNG data/end missing');
54
+ const stride=width*channels+1;
55
+ let inflated:Buffer;
56
+ try{inflated=inflateSync(Buffer.concat(data),{maxOutputLength:stride*height});}
57
+ catch{throw new Error('COMMENT_CROP_INVALID: bounded PNG data decode');}
58
+ if(inflated.length!==stride*height)throw new Error('COMMENT_CROP_INVALID: PNG scanlines');
59
+ for(let row=0;row<height;row++) {
60
+ if(inflated[row*stride]!>4)throw new Error('COMMENT_CROP_INVALID: PNG scanlines');
61
+ }
62
+ return bytes;
18
63
  }
19
64
  const stateRoot=(state?:string)=>state??process.env.RIG_REVIEW_STATE_DIR??join(homedir(),'.local','state','rig-c-review');
20
65
  export async function storePngCrop(crop:PngCrop,state?:string):Promise<void>{
package/src/entry.ts CHANGED
@@ -12,6 +12,7 @@ const sessionUsage = `Usage: rig-review session open <root>
12
12
  rig-review session ask <job-url> --generation <n> --key <id> --publication <id> --subject <JSON>
13
13
  rig-review session next <job-url> [--after <cursor>] [--wait-ms <n>]
14
14
  rig-review session close <job-url> --generation <n> --key <id> --reason <words>
15
+ rig-review session fetch-act <job-url> --act <actId> --consumer-capability-stdin [--still-out <existing-directory>]
15
16
  Open requires RIG_REVIEW_JOB_REVIEWER_ID and RIG_REVIEW_JOB_REVIEWER_ROLE (owner or delegate).
16
17
  RIG_REVIEW_JOB_AGENT_FD optionally delivers the private agent bootstrap on an inherited writable descriptor >= 3.
17
18
  Agent verbs use RIG_REVIEW_JOB_AGENT_CAPABILITY. Create's writer binding is installed by its trusted host callback.`;
package/src/job-act.ts CHANGED
@@ -1,15 +1,16 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import {
3
- JOB_ACT_SCHEMA, JOB_ENABLED_ACT_KINDS, JOB_PLAN_BOUND_SIGNOFF_STAGES, JOB_RESERVED_ACT_KINDS,
3
+ JOB_ACT_SCHEMA, JOB_RIG_REVIEW_ACT_SCHEMA, jobStillByteLimit, JOB_ENABLED_ACT_KINDS, JOB_PLAN_BOUND_SIGNOFF_STAGES, JOB_RESERVED_ACT_KINDS,
4
4
  type JobAct, type JobActValues, type JobPendingAsk, type JobReviewerBinding,
5
- type JobSourceBinding, type JobSubject, type JobUISubmission,
5
+ type JobSourceBinding, type JobSubject, type JobUISubmission, type JobRigCapture, type JobRigStill,
6
6
  } from './job-contract.ts';
7
- import { jobId, jobInteger, jobObject, requestDigest } from './job-api.ts';
7
+ import { jobHash, jobId, jobInteger, jobObject, requestDigest } from './job-api.ts';
8
8
  import { validatePicks } from './interview-picks.ts';
9
9
  import type { JobRetainedSource } from './job-source.ts';
10
10
  import { JobError } from './job-store.ts';
11
11
  import { checkedPath, readRegular } from './interview-project.ts';
12
12
  import { prepareJobImageSet } from './job-image-set.ts';
13
+ import {validatePngBytes} from './comment-crops.ts';
13
14
 
14
15
  function words(value: unknown): string {
15
16
  if (typeof value !== 'string' || value.length > 10_000) throw new JobError('JOB_ACT_INVALID');
@@ -66,16 +67,62 @@ export function bindJobAsk(subject: JobSubject, retained: JobRetainedSource): Jo
66
67
  }
67
68
 
68
69
  export function parseUISubmission(value: unknown): JobUISubmission {
69
- const item = jobObject(value, ['publicationId', 'askId', 'pageId', 'displayedNonce', 'expectedGeneration', 'submissionId', 'kind', 'value']);
70
+ const item = jobObject(value, ['publicationId', 'askId', 'pageId', 'displayedNonce', 'expectedGeneration', 'submissionId', 'kind', 'value', 'capture']);
70
71
  if ((JOB_RESERVED_ACT_KINDS as readonly unknown[]).includes(item.kind)) throw new JobError('JOB_ACT_KIND_DISABLED');
71
72
  jobId(item.publicationId); jobId(item.askId); jobId(item.pageId); jobId(item.displayedNonce); jobId(item.submissionId);
72
73
  jobInteger(item.expectedGeneration);
73
74
  if (!(JOB_ENABLED_ACT_KINDS as readonly string[]).includes(String(item.kind))) {
74
75
  throw new JobError('JOB_ACT_INVALID');
75
76
  }
77
+ if (item.capture !== undefined && (item.kind !== 'review-verdict' ||
78
+ (item.value as {stage?: unknown} | null)?.stage !== 'rig-review')) throw new JobError('JOB_REQUEST_INVALID');
76
79
  return item as unknown as JobUISubmission;
77
80
  }
78
81
 
82
+ /** The browser supplies pixels and draw provenance, never a trusted hash or path. */
83
+ export function prepareJobStill(input: JobUISubmission, ask: JobPendingAsk, retained: JobRetainedSource): {
84
+ readonly still: JobRigStill;
85
+ readonly bytes: Buffer;
86
+ readonly binding: JobRigCapture['binding'];
87
+ } {
88
+ if (input.kind !== 'review-verdict' || !input.capture) throw new JobError('JOB_STILL_CAPTURE_FAILED');
89
+ const capture = jobObject(input.capture, ['png', 'width', 'height', 'camera', 'framing', 'view', 'frame', 'animation', 'playing', 'binding']);
90
+ if (capture.camera !== 'fixed' || capture.framing !== 'default') throw new JobError('JOB_STILL_CAMERA_NOT_FIXED');
91
+ if (capture.view !== 'whole-rig') throw new JobError('JOB_STILL_VIEW_UNSUPPORTED');
92
+ const binding = jobObject(capture.binding, ['publicationId', 'instanceKey', 'sourceHash', 'pageId', 'askId', 'drawGeneration', 'playerGeneration']);
93
+ if (binding.publicationId !== input.publicationId || binding.publicationId !== ask.publicationId ||
94
+ binding.instanceKey !== retained.instanceKey || binding.sourceHash !== retained.source.sourceHash ||
95
+ binding.pageId !== input.pageId || binding.askId !== ask.askId ||
96
+ !Number.isSafeInteger(binding.drawGeneration) || (binding.drawGeneration as number) < 1 ||
97
+ !Number.isSafeInteger(binding.playerGeneration) || (binding.playerGeneration as number) < 0) {
98
+ throw new JobError('JOB_STILL_BINDING_MISMATCH');
99
+ }
100
+ if (typeof capture.playing !== 'boolean') throw new JobError('JOB_STILL_CAPTURE_FAILED');
101
+ const frame = capture.frame;
102
+ if (frame === 'setup') {
103
+ if (capture.animation !== undefined) throw new JobError('JOB_STILL_CAPTURE_FAILED');
104
+ } else {
105
+ if (typeof frame !== 'number' || !Number.isFinite(frame) || frame < 0 ||
106
+ typeof capture.animation !== 'string' || !capture.animation || capture.animation.length > 512 ||
107
+ retained.source.subject === 'image-set' || !retained.source.model) throw new JobError('JOB_STILL_CAPTURE_FAILED');
108
+ const model = JSON.parse(readRegular(checkedPath(retained.snapshotRoot, retained.source.model.path), 64 * 1024 * 1024).toString('utf8'));
109
+ const clip = model.animations?.find((item: {name: string; duration: number}) => item.name === capture.animation);
110
+ if (!clip || !Number.isFinite(clip.duration) || frame > clip.duration) throw new JobError('JOB_STILL_CAPTURE_FAILED');
111
+ }
112
+ const prefix = 'data:image/png;base64,';
113
+ if (typeof capture.png !== 'string' || capture.png.length > prefix.length + Math.ceil(jobStillByteLimit / 3) * 4 ||
114
+ !/^data:image\/png;base64,[A-Za-z0-9+/]+={0,2}$/.test(capture.png)) throw new JobError('JOB_STILL_CAPTURE_FAILED');
115
+ const bytes = Buffer.from(capture.png.slice(prefix.length), 'base64');
116
+ if (bytes.length > jobStillByteLimit || prefix + bytes.toString('base64') !== capture.png) throw new JobError('JOB_STILL_CAPTURE_FAILED');
117
+ try { validatePngBytes(bytes, capture.width as number, capture.height as number); }
118
+ catch { throw new JobError('JOB_STILL_CAPTURE_FAILED'); }
119
+ const sha256 = jobHash(bytes);
120
+ const common = {path: sha256 + '.png', sha256, camera: 'fixed' as const};
121
+ const still: JobRigStill = frame === 'setup' ? {...common, frame} :
122
+ {...common, frame: frame as number, animation: capture.animation as string};
123
+ return {still, bytes, binding: binding as unknown as JobRigCapture['binding']};
124
+ }
125
+
79
126
  /** Only the authenticated UI host invokes this adapter. All source and authority
80
127
  * fields are daemon-owned. Empty/whitespace strings remain exact human words.
81
128
  */
@@ -85,6 +132,7 @@ export function finalizeJobAct(options: {
85
132
  readonly ask: JobPendingAsk;
86
133
  readonly retained: JobRetainedSource;
87
134
  readonly reviewer: JobReviewerBinding;
135
+ readonly still?: JobRigStill;
88
136
  }): JobAct {
89
137
  const { submission, ask, retained, reviewer } = options;
90
138
  if (ask.status !== 'pending') throw new JobError('JOB_ASK_SUPERSEDED');
@@ -182,6 +230,13 @@ export function finalizeJobAct(options: {
182
230
  case 'review-verdict': {
183
231
  const value = jobObject(submission.value, ['stage', 'verdict', 'words']);
184
232
  if (ask.subject.kind !== 'review-verdict' || ask.subject.stage === 'image-review' || value.stage !== ask.subject.stage) throw new JobError('JOB_ACT_INVALID');
233
+ if (ask.subject.stage === 'rig-review') {
234
+ if (!options.still) throw new JobError('JOB_STILL_CAPTURE_FAILED');
235
+ return {...envelope, schema: JOB_RIG_REVIEW_ACT_SCHEMA, kind: 'review-verdict',
236
+ source: {...source, model: source.model!, selector: source.selector as Extract<NonNullable<JobSourceBinding['selector']>, {kind: 'rig'}>},
237
+ value: {stage: 'rig-review', verdict: choice(value.verdict, ['pending', 'approved', 'changes-requested'] as const), words: words(value.words)},
238
+ still: options.still};
239
+ }
185
240
  return { ...envelope, kind: 'review-verdict', source: { ...source, model: source.model!,
186
241
  selector: source.selector as Extract<NonNullable<JobSourceBinding['selector']>, { kind: 'rig' | 'post' }> }, value: {
187
242
  stage: ask.subject.stage, verdict: choice(value.verdict, ['pending', 'approved', 'changes-requested'] as const), words: words(value.words),
package/src/job-api.ts CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  JOB_API_SCHEMA, JOB_PARTS_ENUMERATOR_RANGE, JOB_ENABLED_ACT_KINDS, JOB_RESERVED_ACT_KINDS,
4
4
  type JobAgentRequest, type JobDisplayAcknowledgment, type JobFetchActRequest,
5
5
  type JobHostPorts, type JobResult, type JobSelector, type JobSubject,
6
+ jobCaptureBodyLimit, jobRawActMediaType,
6
7
  } from './job-contract.ts';
7
8
  import { JobError } from './job-store.ts';
8
9
  import type { JobSession } from './job-session.ts';
@@ -183,7 +184,7 @@ export function parseJobRequest(value: unknown): JobAgentRequest | JobFetchActRe
183
184
  throw new JobError('JOB_REQUEST_INVALID');
184
185
  }
185
186
 
186
- export async function jobBody(request: Request): Promise<unknown> {
187
+ export async function jobBody(request: Request, maximum = jobBodyLimit): Promise<unknown> {
187
188
  if (!/^application\/json(?:\s*;|$)/i.test(request.headers.get('content-type') ?? '')) {
188
189
  throw new JobError('JOB_REQUEST_INVALID');
189
190
  }
@@ -204,10 +205,14 @@ export async function jobBody(request: Request): Promise<unknown> {
204
205
  const { done, value } = await Promise.race([reader.read(), interrupted]);
205
206
  if (done) break;
206
207
  size += value.length;
207
- if (size > jobBodyLimit) throw new JobError('JOB_BODY_LIMIT');
208
+ if (size > maximum) throw new JobError('JOB_BODY_LIMIT');
208
209
  chunks.push(value);
209
210
  }
210
- return JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks)));
211
+ const value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks)));
212
+ if (size > jobBodyLimit && (value?.kind !== 'review-verdict' || value?.value?.stage !== 'rig-review' || !value.capture)) {
213
+ throw new JobError('JOB_BODY_LIMIT');
214
+ }
215
+ return value;
211
216
  } catch (error) {
212
217
  void reader.cancel().catch(() => {});
213
218
  if (error instanceof JobError) throw error;
@@ -241,12 +246,12 @@ export function createJobHostPorts(session: JobSession, origin: string): JobHost
241
246
  if (request.headers.get('sec-fetch-site') === 'cross-site' ||
242
247
  (ui ? sent !== origin : sent !== null && sent !== origin)) throw new JobError('JOB_SAME_ORIGIN_REQUIRED');
243
248
  }
244
- async function uiCall<Value>(job: string, request: Request, path: string, action: (body: unknown) => Promise<Value>): Promise<JobResult<Value>> {
249
+ async function uiCall<Value>(job: string, request: Request, path: string, action: (body: unknown) => Promise<Value>, maximum = jobBodyLimit): Promise<JobResult<Value>> {
245
250
  try {
246
251
  if (job !== session.jobId) throw new JobError('JOB_UNKNOWN');
247
252
  gate(request, path, true);
248
253
  session.authorize('ui', request.headers.get('X-Review-Capability'));
249
- return { ok: true, value: await action(await jobBody(request)) };
254
+ return { ok: true, value: await action(await jobBody(request, maximum)) };
250
255
  } catch (error) { return jobFailure(error); }
251
256
  }
252
257
  return {
@@ -257,6 +262,16 @@ export function createJobHostPorts(session: JobSession, origin: string): JobHost
257
262
  input = parseJobRequest(await jobBody(request));
258
263
  if (input.jobId !== session.jobId) throw new JobError('JOB_UNKNOWN');
259
264
  session.authorize(input.verb === 'fetch-act' ? 'consumer' : 'agent', request.headers.get('authorization'));
265
+ if (input.verb === 'fetch-act') {
266
+ const accept = request.headers.get('accept');
267
+ if (accept === jobRawActMediaType || accept === 'image/png') {
268
+ if (request.signal.aborted) throw new JobError('JOB_REQUEST_INVALID');
269
+ const bytes = session.readActExport(input.actId, accept === 'image/png');
270
+ return new Response(new Uint8Array(bytes), {headers: {...responseHeaders,
271
+ 'Content-Type': accept, 'Content-Length': String(bytes.byteLength)}});
272
+ }
273
+ if (accept && accept !== '*/*' && accept !== 'application/json') throw new JobError('JOB_REQUEST_INVALID');
274
+ }
260
275
  const value = await session.execute(input, request.signal);
261
276
  return Response.json({ schema: JOB_API_SCHEMA, verb: input.verb, jobId: input.jobId, requestId: input.requestId,
262
277
  generation: session.status().generation, ok: true, value }, { headers: responseHeaders });
@@ -275,7 +290,7 @@ export function createJobHostPorts(session: JobSession, origin: string): JobHost
275
290
  return { ok: true, value: session.displayPublication(publication) };
276
291
  } catch (error) { return jobFailure(error); }
277
292
  },
278
- commitUIAct: (job, request) => uiCall(job, request, base + '/ui/acts', body => session.commitUIAct(body)),
293
+ commitUIAct: (job, request) => uiCall(job, request, base + '/ui/acts', body => session.commitUIAct(body), jobCaptureBodyLimit),
279
294
  ackDisplayed: (job, request) => uiCall(job, request, base + '/ui/displayed', async body => {
280
295
  const item = jobObject(body, ['publicationId', 'pageId', 'sourceHash']);
281
296
  const ack: JobDisplayAcknowledgment = {
package/src/job-cli.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- import { JOB_API_SCHEMA, type JobAgentRequest } from './job-contract.ts';
3
- import { assertJobApiSchema, jobFailure, parseJobRequest } from './job-api.ts';
2
+ import {closeSync, constants, fstatSync, fsyncSync, lstatSync, openSync, readFileSync, renameSync, unlinkSync, writeSync} from 'node:fs';
3
+ import {join} from 'node:path';
4
+ import { JOB_API_SCHEMA, JOB_ACT_SCHEMA, JOB_RIG_REVIEW_ACT_SCHEMA, jobRawActMediaType, jobStillByteLimit,
5
+ type JobAct, type JobAgentRequest } from './job-contract.ts';
6
+ import { assertJobApiSchema, jobFailure, jobHash, jobId, jobObject, parseJobRequest } from './job-api.ts';
4
7
  import { JobError } from './job-store.ts';
8
+ import {validatePngBytes} from './comment-crops.ts';
9
+ import {destinationDirectory} from './destination-directory.ts';
5
10
 
6
11
  export interface JobCLIOptions {
7
12
  readonly agentCapability?: string;
@@ -13,6 +18,11 @@ export interface JobCLIOptions {
13
18
  readonly fetch?: typeof fetch;
14
19
  readonly signal?: AbortSignal;
15
20
  readonly write?: (text: string) => void;
21
+ /** Trusted in-process consumer adapter only. Production consumers pipe the same grant on stdin. */
22
+ readonly consumerCapability?: string;
23
+ readonly consumerInput?: ReadableStream<Uint8Array>;
24
+ /** Checked partial writes for consumer stdout and disposable output-fault controls. */
25
+ readonly writeBytes?: (bytes: Uint8Array) => number;
16
26
  }
17
27
 
18
28
  const commonFlags = ['generation', 'key', 'request-id'];
@@ -52,15 +62,9 @@ function semanticJSON(value: string): unknown {
52
62
  export function parseJobCLI(args: readonly string[]): { readonly endpoint: string; readonly request: JobAgentRequest } {
53
63
  const [verb, locator, ...rest] = args;
54
64
  if (!verbFlags[verb]) throw new JobError('JOB_REQUEST_INVALID');
55
- let url: URL;
56
- try { url = new URL(locator); }
57
- catch { throw new JobError('JOB_REQUEST_INVALID'); }
58
- const match = /^\/jobs\/([A-Za-z0-9][A-Za-z0-9._-]*)\/?$/.exec(url.pathname);
59
- if (url.protocol !== 'http:' || url.hostname !== '127.0.0.1' || url.username || url.password || url.search || url.hash || !match) {
60
- throw new JobError('JOB_LOOPBACK_REQUIRED');
61
- }
65
+ const {url, job} = jobLocator(locator);
62
66
  const values = flags(rest, verbFlags[verb]);
63
- const base = { schema: JOB_API_SCHEMA, verb, jobId: match[1], requestId: values.get('request-id') ?? randomUUID() };
67
+ const base = { schema: JOB_API_SCHEMA, verb, jobId: job, requestId: values.get('request-id') ?? randomUUID() };
64
68
  let payload: unknown;
65
69
  if (verb === 'next') {
66
70
  payload = { ...base, after: values.get('after') ?? null, waitMs: Number(values.get('wait-ms') ?? '0') };
@@ -85,10 +89,202 @@ export function parseJobCLI(args: readonly string[]): { readonly endpoint: strin
85
89
  }
86
90
  const request = parseJobRequest(payload);
87
91
  if (request.verb === 'fetch-act') throw new JobError('JOB_AUTHORITY_REFUSED');
88
- return { endpoint: `${url.origin}/jobs/${match[1]}/api`, request };
92
+ return { endpoint: `${url.origin}/jobs/${job}/api`, request };
93
+ }
94
+
95
+ function jobLocator(locator: string): {url: URL; job: string} {
96
+ let url: URL;
97
+ try { url = new URL(locator); }
98
+ catch { throw new JobError('JOB_REQUEST_INVALID'); }
99
+ const match = /^\/jobs\/([A-Za-z0-9][A-Za-z0-9._-]*)\/?$/.exec(url.pathname);
100
+ if (url.protocol !== 'http:' || url.hostname !== '127.0.0.1' || url.username || url.password || url.search || url.hash || !match) {
101
+ throw new JobError('JOB_LOOPBACK_REQUIRED');
102
+ }
103
+ return {url, job: match[1]};
104
+ }
105
+
106
+ async function consumerBytes(stream: ReadableStream<Uint8Array> | null, maximum: number, signal?: AbortSignal): Promise<Buffer> {
107
+ if (!stream) throw new JobError('JOB_REQUEST_INVALID');
108
+ const reader = stream.getReader();
109
+ let timer: ReturnType<typeof setTimeout> | undefined;
110
+ let abort: (() => void) | undefined;
111
+ const interrupted = new Promise<never>((_resolve, reject) => {
112
+ abort = () => reject(new JobError('JOB_REQUEST_INVALID'));
113
+ timer = setTimeout(abort, 10_000);
114
+ signal?.addEventListener('abort', abort, {once: true});
115
+ if (signal?.aborted) abort();
116
+ });
117
+ try {
118
+ const chunks: Uint8Array[] = [];
119
+ let length = 0;
120
+ for (;;) {
121
+ const {done, value} = await Promise.race([reader.read(), interrupted]);
122
+ if (done) break;
123
+ length += value.byteLength;
124
+ if (length > maximum) throw new JobError('JOB_BODY_LIMIT');
125
+ chunks.push(value);
126
+ }
127
+ return Buffer.concat(chunks, length);
128
+ } catch (error) {
129
+ void reader.cancel().catch(() => {});
130
+ if (error instanceof JobError) throw error;
131
+ throw new JobError('JOB_REQUEST_INVALID');
132
+ } finally {
133
+ clearTimeout(timer);
134
+ if (abort) signal?.removeEventListener('abort', abort);
135
+ reader.releaseLock();
136
+ }
137
+ }
138
+
139
+ function parseConsumerAct(bytes: Buffer, job: string, actId: string): JobAct {
140
+ let value: unknown;
141
+ try { value = JSON.parse(new TextDecoder('utf-8', {fatal: true}).decode(bytes)); }
142
+ catch { throw new JobError('JOB_REQUEST_INVALID'); }
143
+ const act = jobObject(value, ['schema', 'actId', 'jobId', 'askId', 'publicationId', 'kind', 'authority', 'at', 'source', 'value', 'still']);
144
+ if (act.jobId !== job || act.actId !== actId || (act.schema !== JOB_ACT_SCHEMA && act.schema !== JOB_RIG_REVIEW_ACT_SCHEMA)) {
145
+ throw new JobError('JOB_ACT_INVALID');
146
+ }
147
+ if (act.schema === JOB_RIG_REVIEW_ACT_SCHEMA) {
148
+ if (act.kind !== 'review-verdict' || (act.value as {stage?: unknown})?.stage !== 'rig-review') throw new JobError('JOB_ACT_INVALID');
149
+ const still = jobObject(act.still, ['path', 'sha256', 'camera', 'frame', 'animation']);
150
+ if (typeof still.sha256 !== 'string' || !/^[a-f0-9]{64}$/.test(still.sha256) ||
151
+ still.path !== still.sha256 + '.png' || still.camera !== 'fixed' ||
152
+ (still.frame === 'setup' ? still.animation !== undefined :
153
+ typeof still.frame !== 'number' || !Number.isFinite(still.frame) || still.frame < 0 ||
154
+ typeof still.animation !== 'string' || !still.animation)) throw new JobError('JOB_ACT_INVALID');
155
+ } else if (act.still !== undefined) throw new JobError('JOB_ACT_INVALID');
156
+ return act as unknown as JobAct;
157
+ }
158
+
159
+ function unlinkOwned(path: string, identity: {dev: number; ino: number}): void {
160
+ try {
161
+ const info = lstatSync(path);
162
+ if (info.dev === identity.dev && info.ino === identity.ino) unlinkSync(path);
163
+ } catch (error) {
164
+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw new JobError('JOB_STILL_OUTPUT_FAILED');
165
+ }
166
+ }
167
+
168
+ function outputConsumerAct(actBytes: Buffer, png: Buffer | undefined, act: JobAct, destination: string | undefined, options: JobCLIOptions): void {
169
+ let temporary: string | undefined;
170
+ let temporaryIdentity: {dev: number; ino: number} | undefined;
171
+ let installed: string | undefined;
172
+ let installedIdentity: {dev: number; ino: number} | undefined;
173
+ let lock: string | undefined;
174
+ let lockDescriptor: number | undefined;
175
+ let emitted = 0;
176
+ try {
177
+ if (png && destination && act.schema === JOB_RIG_REVIEW_ACT_SCHEMA) {
178
+ const directory = destinationDirectory(destination, 'JOB_STILL_OUTPUT_FAILED', false);
179
+ lock = join(directory, '.rig-review-still.lock');
180
+ lockDescriptor = openSync(lock, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | constants.O_NOFOLLOW, 0o600);
181
+ const target = join(directory, act.still.path);
182
+ let existing = false;
183
+ try {
184
+ const descriptor = openSync(target, constants.O_RDONLY | constants.O_NOFOLLOW);
185
+ try {
186
+ const info = fstatSync(descriptor);
187
+ if (!info.isFile() || info.size > jobStillByteLimit || jobHash(readFileSync(descriptor)) !== act.still.sha256) {
188
+ throw new JobError('JOB_STILL_OUTPUT_FAILED');
189
+ }
190
+ existing = true;
191
+ } finally { closeSync(descriptor); }
192
+ } catch (error) {
193
+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
194
+ }
195
+ if (!existing) {
196
+ temporary = join(directory, '.rig-review-still-' + randomUUID() + '.tmp');
197
+ const descriptor = openSync(temporary, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | constants.O_NOFOLLOW, 0o600);
198
+ try {
199
+ const owned = fstatSync(descriptor);
200
+ temporaryIdentity = {dev: owned.dev, ino: owned.ino};
201
+ let offset = 0;
202
+ while (offset < png.byteLength) {
203
+ const written = writeSync(descriptor, png, offset, png.byteLength - offset);
204
+ if (written <= 0) throw new JobError('JOB_STILL_OUTPUT_FAILED');
205
+ offset += written;
206
+ }
207
+ fsyncSync(descriptor);
208
+ const info = fstatSync(descriptor);
209
+ installedIdentity = {dev: info.dev, ino: info.ino};
210
+ } finally { closeSync(descriptor); }
211
+ renameSync(temporary, target);
212
+ temporary = undefined;
213
+ installed = target;
214
+ }
215
+ }
216
+ if (options.write && !options.writeBytes) {
217
+ // A legacy callback cannot report partial progress, so preserve an installed PNG on a thrown write.
218
+ emitted = actBytes.byteLength;
219
+ options.write(actBytes.toString('utf8'));
220
+ } else {
221
+ const write = options.writeBytes ?? (bytes => writeSync(1, bytes));
222
+ while (emitted < actBytes.byteLength) {
223
+ const written = write(actBytes.subarray(emitted));
224
+ if (!Number.isSafeInteger(written) || written <= 0 || written > actBytes.byteLength - emitted) throw new JobError('JOB_STILL_OUTPUT_FAILED');
225
+ emitted += written;
226
+ }
227
+ }
228
+ } catch {
229
+ if (emitted === 0 && installed && installedIdentity) {
230
+ unlinkOwned(installed, installedIdentity);
231
+ }
232
+ throw new JobError('JOB_STILL_OUTPUT_FAILED');
233
+ } finally {
234
+ if (temporary && temporaryIdentity) unlinkOwned(temporary, temporaryIdentity);
235
+ if (lockDescriptor !== undefined) {
236
+ const owned = fstatSync(lockDescriptor);
237
+ closeSync(lockDescriptor);
238
+ unlinkOwned(lock!, owned);
239
+ }
240
+ }
241
+ }
242
+
243
+ async function fetchActCommand(args: readonly string[], options: JobCLIOptions): Promise<void> {
244
+ const {url, job} = jobLocator(args[1]);
245
+ const rest = args.slice(2);
246
+ const stdinFlags = rest.filter(value => value === '--consumer-capability-stdin').length;
247
+ if (stdinFlags > 1 || (stdinFlags === 0 && !options.consumerCapability) || (stdinFlags && options.consumerCapability)) throw new JobError('JOB_REQUEST_INVALID');
248
+ const values = flags(rest.filter(value => value !== '--consumer-capability-stdin'), ['act', 'still-out', 'request-id']);
249
+ const actId = jobId(required(values, 'act'));
250
+ const input = options.consumerCapability ?? (await consumerBytes(options.consumerInput ?? Bun.stdin.stream(), 4096, options.signal)).toString('utf8');
251
+ const capability = input.replace(/\r?\n$/, '');
252
+ if (!/^[a-f0-9]{64}$/.test(capability)) throw new JobError('JOB_CAPABILITY_REQUIRED');
253
+ const request = {schema: JOB_API_SCHEMA, verb: 'fetch-act', jobId: job, actId, requestId: values.get('request-id') ?? randomUUID()};
254
+ async function read(accept: string, maximum: number): Promise<Buffer> {
255
+ const response = await (options.fetch ?? fetch)(`${url.origin}/jobs/${job}/api`, {
256
+ method: 'POST', redirect: 'error', signal: options.signal,
257
+ headers: {'Content-Type': 'application/json', Authorization: 'Bearer ' + capability, Accept: accept},
258
+ body: JSON.stringify(request),
259
+ });
260
+ const bytes = await consumerBytes(response.body, maximum, options.signal);
261
+ if (!response.ok) {
262
+ let failure: unknown;
263
+ try { failure = JSON.parse(bytes.toString('utf8')); } catch {}
264
+ const code = (failure as {error?: {code?: unknown}})?.error?.code;
265
+ throw new JobError('JOB_REQUEST_INVALID', typeof code === 'string' && /^JOB_[A-Z_]+$/.test(code) ? code : 'JOB_REQUEST_INVALID');
266
+ }
267
+ if (response.headers.get('content-type')?.split(';')[0] !== accept) throw new JobError('JOB_REQUEST_INVALID');
268
+ return bytes;
269
+ }
270
+ const bytes = await read(jobRawActMediaType, 512 * 1024);
271
+ const act = parseConsumerAct(bytes, job, actId);
272
+ const destination = values.get('still-out');
273
+ if (act.schema === JOB_RIG_REVIEW_ACT_SCHEMA && destination === undefined) throw new JobError('JOB_STILL_OUTPUT_FAILED');
274
+ let png: Buffer | undefined;
275
+ if (destination !== undefined) {
276
+ if (act.schema !== JOB_RIG_REVIEW_ACT_SCHEMA) throw new JobError('JOB_STILL_UNAVAILABLE');
277
+ png = await read('image/png', jobStillByteLimit);
278
+ try {
279
+ if (png.length < 33 || jobHash(png) !== act.still.sha256) throw new Error('hash');
280
+ validatePngBytes(png, png.readUInt32BE(16), png.readUInt32BE(20));
281
+ } catch { throw new JobError('JOB_STILL_CAPTURE_FAILED'); }
282
+ }
283
+ outputConsumerAct(bytes, png, act, destination, options);
89
284
  }
90
285
 
91
286
  export async function jobCommand(args: readonly string[], options: JobCLIOptions = {}): Promise<void> {
287
+ if (args[0] === 'fetch-act') return fetchActCommand(args, options);
92
288
  const write = options.write ?? (text => console.log(text));
93
289
  if (args[0] === 'open') {
94
290
  if (args.length !== 2 || !options.open) throw new JobError('JOB_AUTHORITY_REFUSED', 'Managed job opening requires the Review host');