@relayflows/sdk 2.0.64 → 2.0.65

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.
@@ -1,4 +1,5 @@
1
1
  import { type CloudConnectionOptions } from './cloud-http.js';
2
+ import { readCloudHumanWaitValue } from './cloud-human-wait.js';
2
3
  export interface CloudAnswerOptions extends CloudConnectionOptions {
3
4
  note?: string;
4
5
  /** Exact original source, including a copy pulled with flows sync. Never executed locally. */
@@ -17,19 +18,21 @@ export declare class CloudAnswerError extends Error {
17
18
  readonly cause: unknown;
18
19
  constructor(answerRecorded: boolean, cause: unknown);
19
20
  }
21
+ interface CloudRecordedHumanAnswer {
22
+ waitId: string;
23
+ answer: boolean;
24
+ note?: string;
25
+ }
20
26
  /**
21
27
  * Accepted answer route shapes are explicit: humanWait (or wait), or openWaits,
22
- * and an optional recorded answer { waitId, answer, note? }. Unknown/ambiguous
23
- * shapes refuse before writes. A closed wait is retryable only with that proof.
28
+ * and an optional recorded humanAnswer (legacy: answer) { waitId, answer, note? }.
29
+ * Unknown fields are additive, but competing or cross-run/wait shapes refuse.
24
30
  */
25
31
  export declare function readCloudHumanWait(runId: string, options?: CloudConnectionOptions): Promise<{
26
- wait: import("./cloud-human-wait.js").CloudHumanWait | undefined;
27
- recorded: {
28
- waitId: string;
29
- answer: boolean;
30
- note: string | undefined;
31
- } | undefined;
32
+ wait?: ReturnType<typeof readCloudHumanWaitValue>;
33
+ recorded?: CloudRecordedHumanAnswer;
32
34
  }>;
33
35
  /** Record a decision and resume only if Cloud still reports the original park. No POST retries. */
34
36
  export declare function answerCloudFlow(runId: string, answer: boolean, options?: CloudAnswerOptions): Promise<CloudResumeReceipt>;
37
+ export {};
35
38
  //# sourceMappingURL=cloud-answer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloud-answer.d.ts","sourceRoot":"","sources":["../src/cloud-answer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyD,KAAK,sBAAsB,EAA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,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,0FAA0F;AAC1F,qBAAa,gBAAiB,SAAQ,KAAK;IAC7B,QAAQ,CAAC,cAAc,EAAE,OAAO;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO;gBAAhD,cAAc,EAAE,OAAO,EAAW,KAAK,EAAE,OAAO;CAKtE;AAED,UAAU,wBAAwB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAqDD;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B;WAjDnF,UAAU,CAAC,OAAO,uBAAuB,CAAC;eACtC,wBAAwB;GAmDpC;AAgGD,mGAAmG;AACnG,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAoDnI"}
@@ -3,6 +3,7 @@ import { readFile } from 'node:fs/promises';
3
3
  import { CloudFlowError, cloudFetch, cloudRunId, isCloudRecord } from './cloud-http.js';
4
4
  import { cloudRunState } from './cloud-run-record.js';
5
5
  import { readCloudHumanWaitValue } from './cloud-human-wait.js';
6
+ import { readCloudRepositoryGrant } from './cloud-repository-grant.js';
6
7
  import { readSurfaceAuthority } from './authored-flow-loader.js';
7
8
  /** Preserves partial success without claiming a failed/ambiguous resume did not start. */
8
9
  export class CloudAnswerError extends Error {
@@ -19,19 +20,18 @@ export class CloudAnswerError extends Error {
19
20
  const route = (runId) => `/api/v1/workflows/runs/${runId}`;
20
21
  const get = (path, options) => cloudFetch(path, options, { method: 'GET', detail: true });
21
22
  const post = (path, body, options) => cloudFetch(path, options, { method: 'POST', body: JSON.stringify(body), detail: true });
22
- /**
23
- * Accepted answer route shapes are explicit: humanWait (or wait), or openWaits,
24
- * and an optional recorded answer { waitId, answer, note? }. Unknown/ambiguous
25
- * shapes refuse before writes. A closed wait is retryable only with that proof.
26
- */
27
- export async function readCloudHumanWait(runId, options = {}) {
28
- cloudRunId(runId);
29
- const body = await get(`${route(runId)}/answer`, options);
23
+ function readCloudHumanAnswerRecord(body, runId) {
30
24
  if (!isCloudRecord(body))
31
25
  throw new CloudFlowError('invalid_response', 'Cloud returned no human answer record.');
32
- if (body.runId !== undefined && body.runId !== runId) {
26
+ if (body.runId !== runId) {
33
27
  throw new CloudFlowError('invalid_response', 'Cloud returned a human answer record for a different run.');
34
28
  }
29
+ if (body.error !== undefined && body.error !== null) {
30
+ throw new CloudFlowError('invalid_response', 'Cloud returned an error beside a human answer record.');
31
+ }
32
+ if (body.ok !== undefined && body.ok !== true) {
33
+ throw new CloudFlowError('invalid_response', 'Cloud explicitly refused the human answer record.');
34
+ }
35
35
  // An absent and a null field mean the same thing everywhere below.
36
36
  const present = (key) => body[key] !== undefined && body[key] !== null;
37
37
  if (['humanWait', 'wait', 'openWaits'].filter(present).length > 1) {
@@ -45,18 +45,40 @@ export async function readCloudHumanWait(runId, options = {}) {
45
45
  const wait = readCloudHumanWaitValue(candidates[0]);
46
46
  if (candidates.length === 1 && !wait)
47
47
  throw new CloudFlowError('invalid_response', 'Cloud returned an invalid open human wait.');
48
- const recorded = body.answer;
48
+ if (['humanAnswer', 'answer'].filter(present).length > 1) {
49
+ throw new CloudFlowError('invalid_response', 'Cloud returned competing recorded human answer fields.');
50
+ }
51
+ const recorded = body.humanAnswer ?? body.answer;
49
52
  if (recorded !== undefined && recorded !== null
50
53
  && (!isCloudRecord(recorded) || !readCloudHumanWaitValue(recorded) || typeof recorded.answer !== 'boolean'
51
54
  || (recorded.note !== undefined && recorded.note !== null && typeof recorded.note !== 'string'))) {
52
55
  throw new CloudFlowError('invalid_response', 'Cloud returned an invalid recorded human answer.');
53
56
  }
57
+ if (wait && isCloudRecord(recorded) && recorded.waitId !== wait.waitId) {
58
+ throw new CloudFlowError('invalid_response', 'Cloud returned a human answer for a different wait.');
59
+ }
54
60
  return { wait, recorded: isCloudRecord(recorded)
55
61
  // Like the wait fields, a null note means absent.
56
62
  ? { waitId: recorded.waitId, answer: recorded.answer,
57
63
  note: typeof recorded.note === 'string' ? recorded.note : undefined }
58
64
  : undefined };
59
65
  }
66
+ /**
67
+ * Accepted answer route shapes are explicit: humanWait (or wait), or openWaits,
68
+ * and an optional recorded humanAnswer (legacy: answer) { waitId, answer, note? }.
69
+ * Unknown fields are additive, but competing or cross-run/wait shapes refuse.
70
+ */
71
+ export async function readCloudHumanWait(runId, options = {}) {
72
+ cloudRunId(runId);
73
+ return readCloudHumanAnswerRecord(await get(`${route(runId)}/answer`, options), runId);
74
+ }
75
+ function normalizedAnswerNote(note) {
76
+ const normalized = note?.trim();
77
+ return normalized === undefined || normalized.length === 0 ? undefined : normalized;
78
+ }
79
+ function sameRecordedAnswer(recorded, waitId, answer, note) {
80
+ return recorded.waitId === waitId && recorded.answer === answer && recorded.note === note;
81
+ }
60
82
  const HEX64 = /^[a-f0-9]{64}$/u;
61
83
  function isSurfaceAuthority(value) {
62
84
  return isCloudRecord(value) && value.packageName === '@relayflows/surface'
@@ -111,6 +133,10 @@ async function resumeBody(record, runId, source) {
111
133
  throw new CloudFlowError('unsupported_source', 'Cannot resume a run with extensions: Cloud must expose their original submissions.');
112
134
  }
113
135
  }
136
+ const repositoryGrant = readCloudRepositoryGrant(authority.repository);
137
+ if (authority.repository !== undefined && repositoryGrant === undefined) {
138
+ throw new CloudFlowError('invalid_response', 'Cloud run carries an invalid repository grant; refusing to widen or alter it.');
139
+ }
114
140
  let workflow = record.workflow;
115
141
  if (source !== undefined) {
116
142
  try {
@@ -134,6 +160,7 @@ async function resumeBody(record, runId, source) {
134
160
  surface: await resumeSurface(authority.source.surface, source),
135
161
  });
136
162
  return { workflow, authoredAuthority, fileType: 'ts', relayflowVersion: 'v2', resume: runId,
163
+ ...(repositoryGrant === undefined ? {} : { repositoryGrant }),
137
164
  ...(typeof record.workspaceId === 'string' ? { workspaceId: record.workspaceId } : {}) };
138
165
  }
139
166
  /** Record a decision and resume only if Cloud still reports the original park. No POST retries. */
@@ -150,18 +177,19 @@ export async function answerCloudFlow(runId, answer, options = {}) {
150
177
  if (!waitId || (state.humanWait && state.humanWait.waitId !== waitId)) {
151
178
  throw new CloudFlowError('invalid_response', 'Cloud answer record does not identify the run’s parked wait.');
152
179
  }
153
- // A recorded answer that omits its optional note does not contradict --note.
154
- if (recorded && (recorded.answer !== answer
155
- || (recorded.note !== undefined && recorded.note !== options.note))) {
180
+ const note = normalizedAnswerNote(options.note);
181
+ if (recorded && !sameRecordedAnswer(recorded, waitId, answer, note)) {
156
182
  throw new CloudFlowError('invalid_input', 'The recorded answer differs; a closed human wait cannot be changed.');
157
183
  }
158
184
  const body = await resumeBody(record, runId, options.source);
159
185
  let answerRecorded = recorded !== undefined;
160
186
  try {
161
187
  if (!answerRecorded) {
162
- const accepted = await post(`${route(runId)}/answer`, { waitId, answer, ...(options.note === undefined ? {} : { note: options.note }) }, options);
163
- // Only an explicit acknowledgement counts; {} or { ok: null } is not a recorded decision.
164
- if (!isCloudRecord(accepted) || accepted.ok !== true || accepted.error !== undefined) {
188
+ const accepted = await post(`${route(runId)}/answer`, { waitId, answer, ...(note === undefined ? {} : { note }) }, options);
189
+ const acknowledged = readCloudHumanAnswerRecord(accepted, runId);
190
+ if (!acknowledged.wait || !acknowledged.recorded
191
+ || acknowledged.wait.waitId !== waitId
192
+ || !sameRecordedAnswer(acknowledged.recorded, waitId, answer, note)) {
165
193
  throw new CloudFlowError('invalid_response', 'Cloud did not confirm the human answer.');
166
194
  }
167
195
  answerRecorded = true;
@@ -1 +1 @@
1
- {"version":3,"file":"cloud-answer.js","sourceRoot":"","sources":["../src/cloud-answer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,M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5
+ baseBranch: string;
6
+ baseSha: string;
7
+ branch: string;
8
+ mode?: 'head';
9
+ workflows?: true;
10
+ access?: 'read';
11
+ }
12
+ /**
13
+ * Rebuild the request portion of persisted Cloud repository authority.
14
+ * Cloud re-admits this request against the persisted identity and current
15
+ * connection; the SDK must neither infer missing authority nor widen it.
16
+ */
17
+ export declare function readCloudRepositoryGrant(value: unknown): CloudRepositoryGrant | undefined;
18
+ //# sourceMappingURL=cloud-repository-grant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-repository-grant.d.ts","sourceRoot":"","sources":["../src/cloud-repository-grant.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAuBD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAoCzF"}
@@ -0,0 +1,61 @@
1
+ import { isCloudRecord } from './cloud-http.js';
2
+ const coordinate = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,99}$/u;
3
+ function validGitlabNamespace(value) {
4
+ if (typeof value !== 'string' || value.length > 255)
5
+ return false;
6
+ const parts = value.split('/');
7
+ return parts.length >= 1 && parts.length <= 20 && parts.every(part => (coordinate.test(part) && !part.endsWith('.') && !part.endsWith('.git') && !part.endsWith('.atom')));
8
+ }
9
+ function validRepositoryBranch(value) {
10
+ return typeof value === 'string'
11
+ && /^[A-Za-z0-9][A-Za-z0-9._/-]{0,199}$/u.test(value)
12
+ && value !== 'HEAD'
13
+ && !value.includes('..')
14
+ && !value.includes('//')
15
+ && value.split('/').every(part => (part !== '' && !part.startsWith('.') && !part.endsWith('.') && !part.endsWith('.lock')));
16
+ }
17
+ /**
18
+ * Rebuild the request portion of persisted Cloud repository authority.
19
+ * Cloud re-admits this request against the persisted identity and current
20
+ * connection; the SDK must neither infer missing authority nor widen it.
21
+ */
22
+ export function readCloudRepositoryGrant(value) {
23
+ if (value === undefined)
24
+ return undefined;
25
+ if (!isCloudRecord(value))
26
+ return undefined;
27
+ const gitlab = value.host === 'gitlab';
28
+ if ((value.host !== undefined && value.host !== 'github' && value.host !== 'gitlab')
29
+ || typeof value.owner !== 'string'
30
+ || !(gitlab ? validGitlabNamespace(value.owner) : coordinate.test(value.owner))
31
+ || typeof value.repo !== 'string'
32
+ || !/^[A-Za-z0-9_.-]{1,100}$/u.test(value.repo)
33
+ || value.repo === '.' || value.repo === '..'
34
+ || (gitlab && (value.repo.endsWith('.git') || value.repo.endsWith('.atom') || value.repo.endsWith('.')))
35
+ || !validRepositoryBranch(value.baseBranch)
36
+ || !validRepositoryBranch(value.branch)
37
+ || (value.mode !== undefined && value.mode !== 'new' && value.mode !== 'head')
38
+ || (value.workflows !== undefined && typeof value.workflows !== 'boolean')
39
+ || (gitlab && value.workflows === true)
40
+ || (value.access !== undefined && value.access !== 'read')
41
+ || (value.access === 'read' && value.workflows === true)
42
+ || (gitlab && value.access === 'read')
43
+ || (value.mode !== 'head' && !value.branch.startsWith('relayflow/'))
44
+ || value.branch === value.baseBranch
45
+ || typeof value.baseSha !== 'string'
46
+ || !/^[a-f0-9]{40}$/u.test(value.baseSha)) {
47
+ return undefined;
48
+ }
49
+ return {
50
+ ...(gitlab ? { host: 'gitlab' } : {}),
51
+ owner: value.owner.toLowerCase(),
52
+ repo: value.repo.toLowerCase(),
53
+ baseBranch: value.baseBranch,
54
+ baseSha: value.baseSha,
55
+ branch: value.branch,
56
+ ...(value.mode === 'head' ? { mode: 'head' } : {}),
57
+ ...(value.workflows === true ? { workflows: true } : {}),
58
+ ...(value.access === 'read' ? { access: 'read' } : {}),
59
+ };
60
+ }
61
+ //# sourceMappingURL=cloud-repository-grant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-repository-grant.js","sourceRoot":"","sources":["../src/cloud-repository-grant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAchD,MAAM,UAAU,GAAG,oCAAoC,CAAC;AAExD,SAAS,oBAAoB,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG;QAAE,OAAO,KAAK,CAAC;IAClE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CACpE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAClG,CAAC,CAAC;AACL,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ;WAC3B,sCAAsC,CAAC,IAAI,CAAC,KAAK,CAAC;WAClD,KAAK,KAAK,MAAM;WAChB,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;WACrB,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;WACrB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAChC,IAAI,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAA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AAK,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjE,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChE,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relayflows/sdk",
3
- "version": "2.0.64",
3
+ "version": "2.0.65",
4
4
  "description": "TypeScript-first authoring SDK for Relayflows. Compiles specs; speaks the journal protocol.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -50,7 +50,7 @@
50
50
  "@modelcontextprotocol/sdk": "^1.30.0",
51
51
  "@relayfile/adapter-core": "0.8.5",
52
52
  "@relayfile/relay-helpers": "0.6.1",
53
- "@relayflows/surface": "2.0.64",
53
+ "@relayflows/surface": "2.0.65",
54
54
  "@types/js-yaml": "^4.0.9",
55
55
  "acorn": "^8.18.0",
56
56
  "ai-hist": "0.4.1",
@@ -3,6 +3,7 @@ import { readFile } from 'node:fs/promises';
3
3
  import { CloudFlowError, cloudFetch, cloudRunId, isCloudRecord, type CloudConnectionOptions } from './cloud-http.js';
4
4
  import { cloudRunState } from './cloud-run-record.js';
5
5
  import { readCloudHumanWaitValue } from './cloud-human-wait.js';
6
+ import { readCloudRepositoryGrant } from './cloud-repository-grant.js';
6
7
  import { readSurfaceAuthority, type SurfaceModuleAuthority } from './authored-flow-loader.js';
7
8
  import type { CloudAuthoredAuthority } from './cloud-run.js';
8
9
 
@@ -29,24 +30,32 @@ export class CloudAnswerError extends Error {
29
30
  }
30
31
  }
31
32
 
33
+ interface CloudRecordedHumanAnswer {
34
+ waitId: string;
35
+ answer: boolean;
36
+ note?: string;
37
+ }
38
+
32
39
  const route = (runId: string): string => `/api/v1/workflows/runs/${runId}`;
33
40
  const get = (path: string, options: CloudConnectionOptions): Promise<unknown> =>
34
41
  cloudFetch(path, options, { method: 'GET', detail: true });
35
42
  const post = (path: string, body: unknown, options: CloudConnectionOptions): Promise<unknown> =>
36
43
  cloudFetch(path, options, { method: 'POST', body: JSON.stringify(body), detail: true });
37
44
 
38
- /**
39
- * Accepted answer route shapes are explicit: humanWait (or wait), or openWaits,
40
- * and an optional recorded answer { waitId, answer, note? }. Unknown/ambiguous
41
- * shapes refuse before writes. A closed wait is retryable only with that proof.
42
- */
43
- export async function readCloudHumanWait(runId: string, options: CloudConnectionOptions = {}) {
44
- cloudRunId(runId);
45
- const body = await get(`${route(runId)}/answer`, options);
45
+ function readCloudHumanAnswerRecord(body: unknown, runId: string): {
46
+ wait?: ReturnType<typeof readCloudHumanWaitValue>;
47
+ recorded?: CloudRecordedHumanAnswer;
48
+ } {
46
49
  if (!isCloudRecord(body)) throw new CloudFlowError('invalid_response', 'Cloud returned no human answer record.');
47
- if (body.runId !== undefined && body.runId !== runId) {
50
+ if (body.runId !== runId) {
48
51
  throw new CloudFlowError('invalid_response', 'Cloud returned a human answer record for a different run.');
49
52
  }
53
+ if (body.error !== undefined && body.error !== null) {
54
+ throw new CloudFlowError('invalid_response', 'Cloud returned an error beside a human answer record.');
55
+ }
56
+ if (body.ok !== undefined && body.ok !== true) {
57
+ throw new CloudFlowError('invalid_response', 'Cloud explicitly refused the human answer record.');
58
+ }
50
59
  // An absent and a null field mean the same thing everywhere below.
51
60
  const present = (key: string): boolean => body[key] !== undefined && body[key] !== null;
52
61
  if (['humanWait', 'wait', 'openWaits'].filter(present).length > 1) {
@@ -59,12 +68,18 @@ export async function readCloudHumanWait(runId: string, options: CloudConnection
59
68
  }
60
69
  const wait = readCloudHumanWaitValue(candidates[0]);
61
70
  if (candidates.length === 1 && !wait) throw new CloudFlowError('invalid_response', 'Cloud returned an invalid open human wait.');
62
- const recorded = body.answer;
71
+ if (['humanAnswer', 'answer'].filter(present).length > 1) {
72
+ throw new CloudFlowError('invalid_response', 'Cloud returned competing recorded human answer fields.');
73
+ }
74
+ const recorded = body.humanAnswer ?? body.answer;
63
75
  if (recorded !== undefined && recorded !== null
64
76
  && (!isCloudRecord(recorded) || !readCloudHumanWaitValue(recorded) || typeof recorded.answer !== 'boolean'
65
77
  || (recorded.note !== undefined && recorded.note !== null && typeof recorded.note !== 'string'))) {
66
78
  throw new CloudFlowError('invalid_response', 'Cloud returned an invalid recorded human answer.');
67
79
  }
80
+ if (wait && isCloudRecord(recorded) && recorded.waitId !== wait.waitId) {
81
+ throw new CloudFlowError('invalid_response', 'Cloud returned a human answer for a different wait.');
82
+ }
68
83
  return { wait, recorded: isCloudRecord(recorded)
69
84
  // Like the wait fields, a null note means absent.
70
85
  ? { waitId: recorded.waitId as string, answer: recorded.answer as boolean,
@@ -72,6 +87,30 @@ export async function readCloudHumanWait(runId: string, options: CloudConnection
72
87
  : undefined };
73
88
  }
74
89
 
90
+ /**
91
+ * Accepted answer route shapes are explicit: humanWait (or wait), or openWaits,
92
+ * and an optional recorded humanAnswer (legacy: answer) { waitId, answer, note? }.
93
+ * Unknown fields are additive, but competing or cross-run/wait shapes refuse.
94
+ */
95
+ export async function readCloudHumanWait(runId: string, options: CloudConnectionOptions = {}) {
96
+ cloudRunId(runId);
97
+ return readCloudHumanAnswerRecord(await get(`${route(runId)}/answer`, options), runId);
98
+ }
99
+
100
+ function normalizedAnswerNote(note: string | undefined): string | undefined {
101
+ const normalized = note?.trim();
102
+ return normalized === undefined || normalized.length === 0 ? undefined : normalized;
103
+ }
104
+
105
+ function sameRecordedAnswer(
106
+ recorded: CloudRecordedHumanAnswer,
107
+ waitId: string,
108
+ answer: boolean,
109
+ note: string | undefined,
110
+ ): boolean {
111
+ return recorded.waitId === waitId && recorded.answer === answer && recorded.note === note;
112
+ }
113
+
75
114
  const HEX64 = /^[a-f0-9]{64}$/u;
76
115
 
77
116
  function isSurfaceAuthority(value: unknown): value is SurfaceModuleAuthority {
@@ -125,6 +164,10 @@ async function resumeBody(record: Record<string, unknown>, runId: string, source
125
164
  throw new CloudFlowError('unsupported_source', 'Cannot resume a run with extensions: Cloud must expose their original submissions.');
126
165
  }
127
166
  }
167
+ const repositoryGrant = readCloudRepositoryGrant(authority.repository);
168
+ if (authority.repository !== undefined && repositoryGrant === undefined) {
169
+ throw new CloudFlowError('invalid_response', 'Cloud run carries an invalid repository grant; refusing to widen or alter it.');
170
+ }
128
171
  let workflow = record.workflow;
129
172
  if (source !== undefined) {
130
173
  try { workflow = await readFile(source, 'utf8'); }
@@ -144,6 +187,7 @@ async function resumeBody(record: Record<string, unknown>, runId: string, source
144
187
  surface: await resumeSurface(authority.source.surface, source),
145
188
  });
146
189
  return { workflow, authoredAuthority, fileType: 'ts', relayflowVersion: 'v2', resume: runId,
190
+ ...(repositoryGrant === undefined ? {} : { repositoryGrant }),
147
191
  ...(typeof record.workspaceId === 'string' ? { workspaceId: record.workspaceId } : {}) };
148
192
  }
149
193
 
@@ -160,18 +204,19 @@ export async function answerCloudFlow(runId: string, answer: boolean, options: C
160
204
  if (!waitId || (state.humanWait && state.humanWait.waitId !== waitId)) {
161
205
  throw new CloudFlowError('invalid_response', 'Cloud answer record does not identify the run’s parked wait.');
162
206
  }
163
- // A recorded answer that omits its optional note does not contradict --note.
164
- if (recorded && (recorded.answer !== answer
165
- || (recorded.note !== undefined && recorded.note !== options.note))) {
207
+ const note = normalizedAnswerNote(options.note);
208
+ if (recorded && !sameRecordedAnswer(recorded, waitId, answer, note)) {
166
209
  throw new CloudFlowError('invalid_input', 'The recorded answer differs; a closed human wait cannot be changed.');
167
210
  }
168
211
  const body = await resumeBody(record as Record<string, unknown>, runId, options.source);
169
212
  let answerRecorded = recorded !== undefined;
170
213
  try {
171
214
  if (!answerRecorded) {
172
- const accepted = await post(`${route(runId)}/answer`, { waitId, answer, ...(options.note === undefined ? {} : { note: options.note }) }, options);
173
- // Only an explicit acknowledgement counts; {} or { ok: null } is not a recorded decision.
174
- if (!isCloudRecord(accepted) || accepted.ok !== true || accepted.error !== undefined) {
215
+ const accepted = await post(`${route(runId)}/answer`, { waitId, answer, ...(note === undefined ? {} : { note }) }, options);
216
+ const acknowledged = readCloudHumanAnswerRecord(accepted, runId);
217
+ if (!acknowledged.wait || !acknowledged.recorded
218
+ || acknowledged.wait.waitId !== waitId
219
+ || !sameRecordedAnswer(acknowledged.recorded, waitId, answer, note)) {
175
220
  throw new CloudFlowError('invalid_response', 'Cloud did not confirm the human answer.');
176
221
  }
177
222
  answerRecorded = true;
@@ -0,0 +1,77 @@
1
+ import { isCloudRecord } from './cloud-http.js';
2
+
3
+ export interface CloudRepositoryGrant {
4
+ host?: 'gitlab';
5
+ owner: string;
6
+ repo: string;
7
+ baseBranch: string;
8
+ baseSha: string;
9
+ branch: string;
10
+ mode?: 'head';
11
+ workflows?: true;
12
+ access?: 'read';
13
+ }
14
+
15
+ const coordinate = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,99}$/u;
16
+
17
+ function validGitlabNamespace(value: unknown): value is string {
18
+ if (typeof value !== 'string' || value.length > 255) return false;
19
+ const parts = value.split('/');
20
+ return parts.length >= 1 && parts.length <= 20 && parts.every(part => (
21
+ coordinate.test(part) && !part.endsWith('.') && !part.endsWith('.git') && !part.endsWith('.atom')
22
+ ));
23
+ }
24
+
25
+ function validRepositoryBranch(value: unknown): value is string {
26
+ return typeof value === 'string'
27
+ && /^[A-Za-z0-9][A-Za-z0-9._/-]{0,199}$/u.test(value)
28
+ && value !== 'HEAD'
29
+ && !value.includes('..')
30
+ && !value.includes('//')
31
+ && value.split('/').every(part => (
32
+ part !== '' && !part.startsWith('.') && !part.endsWith('.') && !part.endsWith('.lock')
33
+ ));
34
+ }
35
+
36
+ /**
37
+ * Rebuild the request portion of persisted Cloud repository authority.
38
+ * Cloud re-admits this request against the persisted identity and current
39
+ * connection; the SDK must neither infer missing authority nor widen it.
40
+ */
41
+ export function readCloudRepositoryGrant(value: unknown): CloudRepositoryGrant | undefined {
42
+ if (value === undefined) return undefined;
43
+ if (!isCloudRecord(value)) return undefined;
44
+ const gitlab = value.host === 'gitlab';
45
+ if ((value.host !== undefined && value.host !== 'github' && value.host !== 'gitlab')
46
+ || typeof value.owner !== 'string'
47
+ || !(gitlab ? validGitlabNamespace(value.owner) : coordinate.test(value.owner))
48
+ || typeof value.repo !== 'string'
49
+ || !/^[A-Za-z0-9_.-]{1,100}$/u.test(value.repo)
50
+ || value.repo === '.' || value.repo === '..'
51
+ || (gitlab && (value.repo.endsWith('.git') || value.repo.endsWith('.atom') || value.repo.endsWith('.')))
52
+ || !validRepositoryBranch(value.baseBranch)
53
+ || !validRepositoryBranch(value.branch)
54
+ || (value.mode !== undefined && value.mode !== 'new' && value.mode !== 'head')
55
+ || (value.workflows !== undefined && typeof value.workflows !== 'boolean')
56
+ || (gitlab && value.workflows === true)
57
+ || (value.access !== undefined && value.access !== 'read')
58
+ || (value.access === 'read' && value.workflows === true)
59
+ || (gitlab && value.access === 'read')
60
+ || (value.mode !== 'head' && !value.branch.startsWith('relayflow/'))
61
+ || value.branch === value.baseBranch
62
+ || typeof value.baseSha !== 'string'
63
+ || !/^[a-f0-9]{40}$/u.test(value.baseSha)) {
64
+ return undefined;
65
+ }
66
+ return {
67
+ ...(gitlab ? { host: 'gitlab' as const } : {}),
68
+ owner: value.owner.toLowerCase(),
69
+ repo: value.repo.toLowerCase(),
70
+ baseBranch: value.baseBranch,
71
+ baseSha: value.baseSha,
72
+ branch: value.branch,
73
+ ...(value.mode === 'head' ? { mode: 'head' as const } : {}),
74
+ ...(value.workflows === true ? { workflows: true as const } : {}),
75
+ ...(value.access === 'read' ? { access: 'read' as const } : {}),
76
+ };
77
+ }