@rig-c/review 2.4.0 → 2.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rig-c/review",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "type": "module",
5
5
  "description": "Local human rig inspection and structured feedback export",
6
6
  "license": "MIT",
package/src/job-act.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import {
3
- JOB_ACT_SCHEMA, JOB_PLAN_BOUND_SIGNOFF_STAGES, JOB_RESERVED_ACT_KINDS,
3
+ JOB_ACT_SCHEMA, JOB_ENABLED_ACT_KINDS, JOB_PLAN_BOUND_SIGNOFF_STAGES, JOB_RESERVED_ACT_KINDS,
4
4
  type JobAct, type JobActValues, type JobPendingAsk, type JobReviewerBinding,
5
5
  type JobSourceBinding, type JobSubject, type JobUISubmission,
6
6
  } from './job-contract.ts';
@@ -70,7 +70,7 @@ export function parseUISubmission(value: unknown): JobUISubmission {
70
70
  if ((JOB_RESERVED_ACT_KINDS as readonly unknown[]).includes(item.kind)) throw new JobError('JOB_ACT_KIND_DISABLED');
71
71
  jobId(item.publicationId); jobId(item.askId); jobId(item.pageId); jobId(item.displayedNonce); jobId(item.submissionId);
72
72
  jobInteger(item.expectedGeneration);
73
- if (!['interview-picks', 'checkpoint', 'parts-verdict', 'review-verdict', 'signoff'].includes(String(item.kind))) {
73
+ if (!(JOB_ENABLED_ACT_KINDS as readonly string[]).includes(String(item.kind))) {
74
74
  throw new JobError('JOB_ACT_INVALID');
75
75
  }
76
76
  return item as unknown as JobUISubmission;
package/src/job-cli.ts CHANGED
@@ -103,10 +103,26 @@ export async function jobCommand(args: readonly string[], options: JobCLIOptions
103
103
  headers: { 'Content-Type': 'application/json', Authorization: 'Bearer ' + capability },
104
104
  body: JSON.stringify(input.request),
105
105
  });
106
- const bytes = await response.arrayBuffer();
107
- if (bytes.byteLength > 1024 * 1024) throw new JobError('JOB_BODY_LIMIT');
106
+ const reader = response.body?.getReader();
107
+ if (!reader) throw new JobError('JOB_REQUEST_INVALID');
108
+ const chunks: Uint8Array[] = [];
109
+ let size = 0;
110
+ try {
111
+ for (;;) {
112
+ const { done, value } = await reader.read();
113
+ if (done) break;
114
+ size += value.byteLength;
115
+ if (size > 1024 * 1024) {
116
+ try { void reader.cancel().catch(() => {}); } catch {}
117
+ throw new JobError('JOB_BODY_LIMIT');
118
+ }
119
+ chunks.push(value);
120
+ }
121
+ } finally {
122
+ reader.releaseLock();
123
+ }
108
124
  let value: unknown;
109
- try { value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes)); }
125
+ try { value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks, size))); }
110
126
  catch { throw new JobError('JOB_REQUEST_INVALID'); }
111
127
  assertJobApiSchema(value !== null && typeof value === 'object' ? (value as { schema?: unknown }).schema : undefined);
112
128
  write(JSON.stringify(value));