opencode-azure-devops-pr-review 0.4.0 → 0.4.2

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/src/azure.mjs CHANGED
@@ -106,7 +106,7 @@ export function targetKey(target) {
106
106
  /**
107
107
  * A REST base URL other than dev.azure.com is accepted only for loopback test
108
108
  * servers, so a mistaken override can never send the PAT to another host. All
109
- * of 127.0.0.0/8 is loopback: OpenCode 2.2.4 adds 127.0.0.1, localhost and ::1
109
+ * of 127.0.0.0/8 is loopback: OpenCode (2.2.4, 2.3.0) adds 127.0.0.1, localhost and ::1
110
110
  * to NO_PROXY, and Bun then bypasses even an explicit proxy, so a proxied test
111
111
  * server needs another loopback address.
112
112
  */
@@ -434,23 +434,26 @@ export function createAzureClient({ organization, pat, baseUrl = DEFAULT_BASE_UR
434
434
  * One REST call through the shared queue. Reads retry transient failures
435
435
  * (network, timeout, throttling, 5xx) twice; writes are never repeated
436
436
  * because publication resolves uncertainty by reading markers back.
437
+ * `signal` also ends a call that only its caller waits for (a tool call
438
+ * the host stopped); a call whose result several callers share takes none.
437
439
  */
438
- async function request(run, { method = 'GET', path, query = {}, body, accept = 'json', maxBytes, label, record = {} }) {
440
+ async function request(run, { method = 'GET', path, query = {}, body, accept = 'json', maxBytes, label, record = {}, signal }) {
439
441
  const url = new URL(`${root}/${path}`);
440
442
  for (const [key, value] of Object.entries(query)) if (value !== undefined && value !== null) url.searchParams.set(key, String(value));
441
443
  url.searchParams.set('api-version', API_VERSION);
442
444
  const retry = method === 'GET';
445
+ const stop = signal ? AbortSignal.any([run.controller.signal, signal]) : run.controller.signal;
443
446
  for (let attempt = 1; ; attempt++) {
444
447
  run.azureCalls = (run.azureCalls ?? 0) + 1;
445
448
  const started = performance.now();
446
449
  const entry = { method, call: label, ...record, attempt };
447
450
  try {
448
- const value = await queue.run(signal => send({ method, url, body, accept, maxBytes }, label, signal), { signal: run.controller.signal, label: `Azure DevOps ${label}` });
451
+ const value = await queue.run(aborting => send({ method, url, body, accept, maxBytes }, label, aborting), { signal: stop, label: `Azure DevOps ${label}` });
449
452
  onCall?.(run, { ...entry, ok: true, durationMs: Math.round(performance.now() - started),
450
453
  ...(value?.bytes ? { bytes: value.bytes.length } : value?.tooLarge ? { bytes: value.size, tooLarge: true } : {}) });
451
454
  return value;
452
455
  } catch (caught) {
453
- if (run.controller.signal.aborted) throw caught;
456
+ if (stop.aborted) throw caught;
454
457
  const error = caught instanceof AzureError ? caught : caught?.timeout
455
458
  ? new AzureError(`Azure DevOps ${label} did not finish within the per-call timeout.`, { kind: 'timeout', transient: true, uncertain: method !== 'GET', cause: caught })
456
459
  : new AzureError(`Azure DevOps ${label} failed: ${clean(caught?.message ?? caught)}`, { kind: 'unexpected', cause: caught });
@@ -459,7 +462,7 @@ export function createAzureClient({ organization, pat, baseUrl = DEFAULT_BASE_UR
459
462
  error: error.message.slice(0, 300), transient: error.transient, willRetry: again });
460
463
  if (again) {
461
464
  run.azureRetries = (run.azureRetries ?? 0) + 1;
462
- await pause(Math.max(retryDelayMs * (attempt === 1 ? 1 : 3), error.retryAfterMs ?? 0), run.controller.signal);
465
+ await pause(Math.max(retryDelayMs * (attempt === 1 ? 1 : 3), error.retryAfterMs ?? 0), stop);
463
466
  continue;
464
467
  }
465
468
  if (attempt > 1) error.message = `${error.message.replace(/\.$/, '')} after ${attempt} attempts.`;
@@ -556,16 +559,19 @@ export function createAzureClient({ organization, pat, baseUrl = DEFAULT_BASE_UR
556
559
  if (file.tooLarge) throw new AzureError(`${file.path} is larger than ${MAX_FILE_BYTES / 1048576} MB at ${version.slice(0, 12)}.`, { kind: 'too-large' });
557
560
  return file.text;
558
561
  },
559
- /** Folder entries at a commit; a recursive listing is read once per run. */
560
- async listItems(run, snapshot, path, version, recursive = false) {
562
+ /**
563
+ * Folder entries at a commit; a recursive listing is read once per run and
564
+ * shared, so only a listing of one level ends with its caller's `signal`.
565
+ */
566
+ async listItems(run, snapshot, path, version, recursive = false, signal) {
561
567
  const scope = normalizePath(path);
562
- const read = async () => {
568
+ const read = async own => {
563
569
  const result = await request(run, { path: `${repo(snapshot)}/items`, label: `folder ${scope}`, record: { path: scope, version: version.slice(0, 12), ...(recursive ? { recursive: true } : {}) },
564
- query: { scopePath: scope, recursionLevel: recursive ? 'Full' : 'OneLevel', 'versionDescriptor.version': version, 'versionDescriptor.versionType': 'commit' } });
570
+ query: { scopePath: scope, recursionLevel: recursive ? 'Full' : 'OneLevel', 'versionDescriptor.version': version, 'versionDescriptor.versionType': 'commit' }, signal: own });
565
571
  if (!Array.isArray(result?.value)) throw new AzureError('Azure DevOps returned no item list.');
566
572
  return result.value;
567
573
  };
568
- if (!recursive) return read();
574
+ if (!recursive) return read(signal);
569
575
  const cache = run.listCache ??= new Map(), key = `${version}\n${scope}`;
570
576
  if (!cache.has(key)) {
571
577
  const pending = read();
@@ -580,9 +586,9 @@ export function createAzureClient({ organization, pat, baseUrl = DEFAULT_BASE_UR
580
586
  query: { scopePath: '/', recursionLevel: 'Full', $format: 'zip', 'versionDescriptor.version': version, 'versionDescriptor.versionType': 'commit' } });
581
587
  return result.tooLarge ? { tooLarge: true, size: result.size } : { bytes: result.bytes };
582
588
  },
583
- /** Every thread on the PR (one call; the API returns all of them). */
584
- async threads(run, snapshot) {
585
- const result = await request(run, { path: `${pullRequest(snapshot)}/threads`, label: 'PR threads' });
589
+ /** Every thread on the PR (one call; the API returns all of them). `signal` ends this caller's read early. */
590
+ async threads(run, snapshot, signal) {
591
+ const result = await request(run, { path: `${pullRequest(snapshot)}/threads`, label: 'PR threads', signal });
586
592
  if (!Array.isArray(result?.value)) throw new AzureError('Azure DevOps returned no thread list; existing comments could not be checked.');
587
593
  return result.value;
588
594
  },
@@ -303,7 +303,9 @@ export const UNCERTAIN_SETTLE_MS = 15 * 60 * 1000;
303
303
 
304
304
  /**
305
305
  * Publish a saved plan with deterministic Azure DevOps calls.
306
- * - Refuses if the PR is no longer active or its source commit changed.
306
+ * - Refuses if the PR's source commit changed. The PR's status stops nothing: a
307
+ * completed or abandoned PR takes comments like an active one, and the
308
+ * result names such a status (`prStatus`) for the receipt.
307
309
  * - Skips items whose marker already exists on the PR (idempotent re-runs).
308
310
  * - Coordinates through `attempts` (per PR, shared by every review; not a
309
311
  * lock between processes): an attempt is saved before its request and
@@ -323,7 +325,6 @@ export async function publishPlan({ run, review, azure, attempts, progress, pers
323
325
  const items = publicationItems(review.plan).filter(item => !only || only.has(item.marker));
324
326
  const ledger = review.publication ??= new Map();
325
327
  const current = await azure.versions(run, review.snapshot);
326
- if (current.status !== 'active') return { status: 'INCOMPLETE', reason: `The PR is ${current.status}; nothing was posted.` };
327
328
  if (current.head !== review.snapshot.head) {
328
329
  return { status: 'STALE', reason: `The PR source commit changed after the review (reviewed ${review.snapshot.head.slice(0, 12)}, current ${current.head.slice(0, 12)}). Run a new review before commenting.` };
329
330
  }
@@ -413,6 +414,7 @@ export async function publishPlan({ run, review, azure, attempts, progress, pers
413
414
  const uncertain = states.filter(state => state === 'UNCERTAIN').length;
414
415
  const reason = halted || (uncertain ? `${uncertain} item(s) may still be created by an earlier attempt whose outcome is unknown; they are not posted again until their marker appears or ${Math.round(settleMs / 60000)} minutes have passed since that attempt. Run the same command again later.` : undefined);
415
416
  const planned = new Set(items.map(item => item.marker));
416
- return { status, readBack, ...(reason ? { reason } : {}), counts: Object.fromEntries([...new Set(states)].map(state => [state, states.filter(s => s === state).length])),
417
+ return { status, readBack, ...(reason ? { reason } : {}), ...(current.status !== 'active' ? { prStatus: current.status } : {}),
418
+ counts: Object.fromEntries([...new Set(states)].map(state => [state, states.filter(s => s === state).length])),
417
419
  ...(compare ? { otherComments: [...present.keys()].filter(marker => !planned.has(marker)).length } : {}) };
418
420
  }
package/src/config.mjs CHANGED
@@ -110,13 +110,60 @@ export const AFTER_REVIEW = Object.freeze(['none', 'preview', 'publish']);
110
110
  // The largest azure.archiveMegabytes: the repository zip for content search is held in memory.
111
111
  export const MAX_ARCHIVE_MEGABYTES = 1024;
112
112
 
113
+ // Whether the panel in OpenCode's terminal UI opens by itself (a run starts, a report or preview arrives) or only with /pr-panel.
114
+ export const TERMINAL_PANEL = Object.freeze(['auto', 'manual']);
115
+
116
+ const deepFreeze = value => { for (const item of Object.values(value)) if (item !== null && typeof item === 'object') deepFreeze(item); return Object.freeze(value); };
117
+ /**
118
+ * Every setting that has a default, with it, in the order of config/settings.example.json. The review
119
+ * models and azure.organization have none: a person chooses them. Validation applies these values to
120
+ * what a settings file leaves out, and withMissingSettings writes them into the file.
121
+ */
122
+ export const SETTING_DEFAULTS = deepFreeze({
123
+ models: { review: { rater: '' }, deep: { functional: '', risk: '', verifier: '', rater: '' }, quick: { reviewer: '' } },
124
+ enabled: true,
125
+ returnReport: 'receipt',
126
+ debug: { enabled: false, directory: '', keepRuns: 20 },
127
+ outputLanguage: 'en',
128
+ runTimeoutSeconds: null,
129
+ shell: 'deny',
130
+ progressNotices: true,
131
+ deletePrivateSessions: true,
132
+ terminalPanel: 'auto',
133
+ afterReview: { quick: 'preview', review: 'preview', deep: 'preview' },
134
+ azure: { pat: '', patFile: '', concurrency: 6, callTimeoutSeconds: 120, archiveMegabytes: 100, proxy: '', caFile: '', verifyTls: true },
135
+ workflow: { shardFiles: 25, shardFindings: 15, parallelSessions: 8, repairAttempts: 2, stageRetries: 1, stageIdleSeconds: 600 },
136
+ });
113
137
  const DEFAULTS = Object.freeze({
114
- afterReview: Object.freeze({ quick: 'preview', review: 'preview', deep: 'preview' }),
115
- azure: Object.freeze({ organization: '', pat: '', patFile: '', concurrency: 6, callTimeoutSeconds: 120, archiveMegabytes: 100, proxy: '', caFile: '', verifyTls: true }),
116
- workflow: Object.freeze({ shardFiles: 25, shardFindings: 15, parallelSessions: 8, repairAttempts: 2, stageRetries: 1, stageIdleSeconds: 600 }),
138
+ afterReview: SETTING_DEFAULTS.afterReview,
139
+ azure: Object.freeze({ organization: '', ...SETTING_DEFAULTS.azure }),
140
+ workflow: SETTING_DEFAULTS.workflow,
117
141
  });
118
142
  const withDefault = (value, fallback) => value === undefined ? fallback : value;
119
143
  const isObject = value => value !== null && typeof value === 'object' && !Array.isArray(value);
144
+
145
+ /**
146
+ * `raw` with every setting it leaves out, at its default: what validation assumes for them anyway, so
147
+ * the result behaves as `raw` does. Values that are there stay as they are, also where they are not
148
+ * what a default expects; new names follow the existing ones. Returns the settings and the names added.
149
+ */
150
+ export function withMissingSettings(raw) {
151
+ const added = [];
152
+ const copy = value => isObject(value) ? Object.fromEntries(Object.entries(value).map(([key, item]) => [key, copy(item)])) : value;
153
+ const fill = (existing, defaults, prefix) => {
154
+ const result = { ...existing };
155
+ for (const [key, value] of Object.entries(defaults)) {
156
+ // A group added as a whole is named once, not once per value in it.
157
+ if (!Object.hasOwn(result, key)) { result[key] = copy(value); added.push(prefix + key); }
158
+ else if (isObject(value) && isObject(result[key])) result[key] = fill(result[key], value, `${prefix}${key}.`);
159
+ }
160
+ return result;
161
+ };
162
+ return { settings: fill(raw, SETTING_DEFAULTS, ''), added };
163
+ }
164
+
165
+ /** A settings file as AZPR writes it: the text setup saves and the one a completed file has. */
166
+ export const settingsText = settings => JSON.stringify(settings, null, 2) + '\n';
120
167
  function keys(value, allowed, at) {
121
168
  if (!isObject(value)) throw new Error(`${at} must be a JSON object.`);
122
169
  // Name an unknown key only when it looks like a setting name: a long one may be a pasted secret.
@@ -160,7 +207,7 @@ export function validateSettings(raw) {
160
207
  throw new Error('settings.mcp is no longer used: AZPR calls the Azure DevOps REST API itself. Move concurrency and callTimeoutSeconds to azure, set azure.organization and azure.patFile (or azure.pat), and remove mcp.');
161
208
  }
162
209
  keys(raw, ['$schema', 'version', 'enabled', 'models', 'debug', 'outputLanguage', 'returnReport', 'runTimeoutSeconds',
163
- 'shell', 'progressNotices', 'deletePrivateSessions', 'afterReview', 'azure', 'workflow'], 'settings');
210
+ 'shell', 'progressNotices', 'deletePrivateSessions', 'terminalPanel', 'afterReview', 'azure', 'workflow'], 'settings');
164
211
  if (raw.version !== 2) throw new Error('settings.version must be 2. Use the V2 settings example; older host layouts are not supported.');
165
212
  if (raw.enabled !== undefined && typeof raw.enabled !== 'boolean') throw new Error('enabled must be boolean.');
166
213
  if (raw.$schema !== undefined && typeof raw.$schema !== 'string') throw new Error('$schema must be a string.');
@@ -183,24 +230,26 @@ export function validateSettings(raw) {
183
230
  }
184
231
  // The optional rater does not count: deep mode is on when its three review roles are set.
185
232
  const deepConfigured = MODEL_SLOTS.deep.filter(slot => models.deep[slot]).length;
186
- const returnReport = withDefault(raw.returnReport, 'receipt');
233
+ const returnReport = withDefault(raw.returnReport, SETTING_DEFAULTS.returnReport);
187
234
  if (!['receipt', 'full'].includes(returnReport)) throw new Error('returnReport must be receipt or full.');
188
- const outputLanguage = languageTag(raw.outputLanguage === undefined ? 'en' : raw.outputLanguage);
189
- const debug = raw.debug === undefined ? { enabled: false, directory: '' } : raw.debug;
235
+ const outputLanguage = languageTag(withDefault(raw.outputLanguage, SETTING_DEFAULTS.outputLanguage));
236
+ const debug = raw.debug === undefined ? { enabled: SETTING_DEFAULTS.debug.enabled, directory: SETTING_DEFAULTS.debug.directory } : raw.debug;
190
237
  keys(debug, ['enabled', 'directory', 'keepRuns'], 'debug');
191
238
  if (typeof debug.enabled !== 'boolean' || (debug.directory !== undefined &&
192
239
  (typeof debug.directory !== 'string' || /[\0\r\n]/.test(debug.directory) || debug.directory.startsWith('~')))) throw new Error('debug requires enabled (boolean) and an optional directory path; use an absolute path or a project-relative path, not ~.');
193
- const keepRuns = withDefault(debug.keepRuns, 20);
240
+ const keepRuns = withDefault(debug.keepRuns, SETTING_DEFAULTS.debug.keepRuns);
194
241
  integer(keepRuns, 'debug.keepRuns', 0, 1000);
195
- const runTimeoutSeconds = withDefault(raw.runTimeoutSeconds, null);
242
+ const runTimeoutSeconds = withDefault(raw.runTimeoutSeconds, SETTING_DEFAULTS.runTimeoutSeconds);
196
243
  if (runTimeoutSeconds !== null) integer(runTimeoutSeconds, 'runTimeoutSeconds', 10, 7200);
197
- const shell = withDefault(raw.shell, 'deny');
244
+ const shell = withDefault(raw.shell, SETTING_DEFAULTS.shell);
198
245
  if (!SHELL_MODES.includes(shell)) throw new Error('shell must be deny, ask or inherit.');
199
- const progressNotices = withDefault(raw.progressNotices, true);
246
+ const progressNotices = withDefault(raw.progressNotices, SETTING_DEFAULTS.progressNotices);
200
247
  if (typeof progressNotices !== 'boolean') throw new Error('progressNotices must be boolean.');
201
- const deletePrivateSessions = withDefault(raw.deletePrivateSessions, true);
248
+ const deletePrivateSessions = withDefault(raw.deletePrivateSessions, SETTING_DEFAULTS.deletePrivateSessions);
202
249
  if (typeof deletePrivateSessions !== 'boolean') throw new Error('deletePrivateSessions must be boolean.');
203
- // A missing mode makes no comments after its reviews.
250
+ const terminalPanel = withDefault(raw.terminalPanel, SETTING_DEFAULTS.terminalPanel);
251
+ if (!TERMINAL_PANEL.includes(terminalPanel)) throw new Error('terminalPanel must be auto or manual.');
252
+ // A mode left out has the default.
204
253
  const afterReview = { ...DEFAULTS.afterReview, ...(raw.afterReview === undefined ? {} : (keys(raw.afterReview, MODES, 'afterReview'), raw.afterReview)) };
205
254
  for (const mode of MODES) if (!AFTER_REVIEW.includes(afterReview[mode])) throw new Error(`afterReview.${mode} must be none, preview or publish.`);
206
255
  const azure = { ...DEFAULTS.azure, ...(raw.azure === undefined ? {} : (keys(raw.azure, Object.keys(DEFAULTS.azure), 'azure'), raw.azure)) };
@@ -233,7 +282,7 @@ export function validateSettings(raw) {
233
282
  const idle = workflow.stageIdleSeconds;
234
283
  if (idle !== 0 && (!Number.isInteger(idle) || idle < 60 || idle > 7200)) throw new Error('workflow.stageIdleSeconds must be 0 (off) or an integer from 60 to 7200.');
235
284
  return { models, debug: { enabled: debug.enabled, directory: debug.directory ?? '', keepRuns },
236
- enabled: raw.enabled !== false, outputLanguage, returnReport, runTimeoutSeconds, shell, progressNotices, deletePrivateSessions, afterReview, azure, workflow,
285
+ enabled: raw.enabled !== false, outputLanguage, returnReport, runTimeoutSeconds, shell, progressNotices, deletePrivateSessions, terminalPanel, afterReview, azure, workflow,
237
286
  deepReady: deepConfigured === MODEL_SLOTS.deep.length,
238
287
  deepPartial: deepConfigured > 0 && deepConfigured < MODEL_SLOTS.deep.length,
239
288
  quickReady: models.quick.reviewer !== '' };
@@ -203,5 +203,6 @@ export function diagnosticResponse(response) {
203
203
  text: raw, textCharacters: raw.length,
204
204
  ...(response?.continuation ? { continuation: { count: response.continuation.count,
205
205
  fragments: response.continuation.fragments.map(diagnosticResponse) } } : {}),
206
+ ...(response?.retriedSteps ? { retriedSteps: response.retriedSteps } : {}),
206
207
  };
207
208
  }
package/src/host.mjs CHANGED
@@ -6,9 +6,10 @@
6
6
  * constant and response normalization lives here so an upgrade has one place
7
7
  * to adjust.
8
8
  */
9
- export const TESTED_HOST_VERSION = '2.2.4';
9
+ export const TESTED_HOST_VERSION = '2.3.0';
10
10
 
11
- // Text OpenCode (2.0.32 through 2.2.4) queues after resuming an interrupted text stream.
11
+ // Text OpenCode 2.0.32 through 2.2.7 queue after resuming an interrupted text stream. OpenCode 2.3.0 retries the
12
+ // interrupted step instead and queues nothing (see `retriedSteps` in session.mjs).
12
13
  export const HOST_CONTINUATION_TEXT = 'The previous response was interrupted. Continue from where you left off without repeating completed content.';
13
14
 
14
15
  // Context message types that mean someone other than the admitted prompt
@@ -57,7 +58,7 @@ export function packageNamed(target, name, repository) {
57
58
  }
58
59
 
59
60
  /**
60
- * This plugin's entries in the host's plugin list. OpenCode 2.1.4 through 2.2.4 list
61
+ * This plugin's entries in the host's plugin list. OpenCode 2.1.4 through 2.3.0 list
61
62
  * { id?, source: { type: package|local|builtin|sdk, target?, version? },
62
63
  * state: { status: active|failed, error? } } and keeps only the first entry
63
64
  * of a plugin ID: a second one is listed as failed with "Duplicate plugin ID".
@@ -93,7 +94,7 @@ export function pluginSourceLabel(source) {
93
94
 
94
95
  /**
95
96
  * Session events that show a turn progressing while no hook runs. OpenCode
96
- * 2.1.2 through 2.2.4 emit one delta event per streamed chunk of answer text,
97
+ * 2.1.2 through 2.3.0 emit one delta event per streamed chunk of answer text,
97
98
  * reasoning or tool-call input; the projected session context shows the text
98
99
  * only once the step ends.
99
100
  */
@@ -122,7 +123,7 @@ export function sessionProgress(event) {
122
123
  }
123
124
 
124
125
  /**
125
- * OpenCode runs plugins on Bun (1.4.2 in 2.0.32 and 2.1.2, 1.4.4 in 2.1.4 through 2.2.4),
126
+ * OpenCode runs plugins on Bun (1.4.2 in 2.0.32 and 2.1.2, 1.4.4 in 2.1.4 through 2.3.0),
126
127
  * whose fetch accepts per-request `proxy` and `tls` options. Node's fetch
127
128
  * silently ignores both, so a configured proxy would be bypassed; callers
128
129
  * refuse instead.
@@ -167,6 +168,13 @@ export const USED_UP_LIMITS = Object.freeze({
167
168
  'provider.model-budget-limit': "OpenCode reports this model's spend limit as reached",
168
169
  });
169
170
 
171
+ /**
172
+ * Whether a rejected session call says the session does not exist. OpenCode
173
+ * 2.2.4 and 2.3.0 reject `session.get` and `session.remove` of such a session
174
+ * with an error whose `_tag` and `name` are `Session.NotFoundError`.
175
+ */
176
+ export const isSessionNotFound = error => (error?._tag ?? error?.name) === 'Session.NotFoundError';
177
+
170
178
  /** Throw one readable error naming every missing host method. */
171
179
  export function requireMethods(context, paths, purpose) {
172
180
  const missing = paths.filter(path => typeof path.split('.').reduce((value, key) => value?.[key], context) !== 'function');
@@ -394,7 +394,8 @@ export async function runReviewTool(name, input, context) {
394
394
  return { ...result, reads: [], text: `${result.text.slice(0, fitEnd(result.text, 0, OUTPUT_BYTES - 200))}\n[Output cut to the tool-output limit; request a narrower range.]` };
395
395
  }
396
396
 
397
- async function reviewTool(name, input, { azure, run, snapshot }) {
397
+ // `signal` is the caller's own stop: it goes only to reads no other session of the run shares.
398
+ async function reviewTool(name, input, { azure, run, snapshot, signal }) {
398
399
  const raw = input && typeof input === 'object' && !Array.isArray(input) ? input : {};
399
400
  // Models often send an optional argument as null or "": that means not given.
400
401
  const args = Object.fromEntries(Object.entries(raw).filter(([, value]) => value !== null && !(typeof value === 'string' && !value.trim())));
@@ -454,12 +455,12 @@ async function reviewTool(name, input, { azure, run, snapshot }) {
454
455
  const path = pathArgument(args.path, '/');
455
456
  const { sha, label } = resolveVersion(args.version, snapshot);
456
457
  if (args.recursive !== undefined && typeof args.recursive !== 'boolean') throw new ToolInputError('recursive must be true or false.');
457
- return renderListing(await azure.listItems(run, snapshot, path, sha, args.recursive === true), { path, label, version: sha });
458
+ return renderListing(await azure.listItems(run, snapshot, path, sha, args.recursive === true, signal), { path, label, version: sha });
458
459
  }
459
460
  if (name === REVIEW_TOOLS.threads) {
460
461
  const path = args.path === undefined ? undefined : pathArgument(args.path);
461
462
  if (args.threadId !== undefined && (!Number.isInteger(args.threadId) || args.threadId < 1)) throw new ToolInputError('threadId must be a positive integer.');
462
- return renderThreads(await azure.threads(run, snapshot), { path, threadId: args.threadId });
463
+ return renderThreads(await azure.threads(run, snapshot, signal), { path, threadId: args.threadId });
463
464
  }
464
465
  throw new ToolInputError(`Unknown AZPR tool ${name}.`);
465
466
  }