opencode-azure-devops-pr-review 0.4.0 → 0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,77 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1 — 2026-11-16
4
+
5
+ AZPR is tested with OpenCode 2.3.0 instead of 2.2.4, and two things that went
6
+ wrong on 2.3.0 are fixed. The same release also passed its host fixtures on
7
+ OpenCode 2.2.4, where `/pr-check` shows the OpenCode WARNING row. The
8
+ reviewer and verifier instructions are those of 0.4.0, and no setting is new.
9
+
10
+ OpenCode 2.3.0:
11
+
12
+ - A review no longer wakes your conversation's own model. OpenCode 2.3.0
13
+ hands every answer of a child session to its parent and lets the parent's
14
+ model respond to it. AZPR's private sessions were children of the
15
+ conversation, so on 2.3.0 that model, with its edit and shell tools,
16
+ received the reviewers' raw output and AZPR's notices and answered each
17
+ one: 7 of the 12 model requests of a 2-file review in the test fixture.
18
+ Private sessions are now sessions of their own, created where the
19
+ conversation is. What the reviewers, the verifier and the comment planner
20
+ are sent did not change.
21
+ - A model stream that breaks off mid-answer no longer fails the stage.
22
+ OpenCode 2.3.0 retries the interrupted step by itself instead of asking the
23
+ model to continue. AZPR did not recognise that and ran the stage again in a
24
+ new session, and a second interruption failed it. It now takes the retried
25
+ step's answer; the receipt counts such steps as `step-retries`.
26
+ - The inactivity watchdog, the retry of a provider 503, the refused background
27
+ summary and the context-overflow split work on 2.3.0 as before.
28
+
29
+ Private sessions in the session list:
30
+
31
+ - OpenCode lists a session without a parent like a conversation, so AZPR's
32
+ private sessions now appear next to your conversations, titled
33
+ `[AZPR <id>] …`; a plugin cannot archive them. When a review ends, AZPR
34
+ therefore deletes its sessions at once, except the one that holds the report
35
+ or draft, which the receipt names. A comment run keeps none: its receipt
36
+ carries the preview or the publication result. Until now a completed review
37
+ kept all of its sessions until it was evicted. The kept session is deleted
38
+ with its review, as before (the newest 20 are kept).
39
+ - A review's receipt says how many sessions were deleted (`Session notice`).
40
+ - While `debug.enabled` is on, every session is still kept until the review
41
+ is evicted, so each review adds all of its sessions to the list. Turn debug
42
+ off for everyday use; `deletePrivateSessions: false` keeps everything too.
43
+ - A review that an OpenCode restart interrupts leaves its sessions in the
44
+ list: AZPR had not recorded them yet. Delete those yourself.
45
+ - A session whose deletion failed or timed out stays on record: it is
46
+ deleted with its review, or, when no review keeps it, tried again after
47
+ every later run and closed to AZPR commands meanwhile. Such a session used
48
+ to be forgotten. A command typed in a session that is being deleted is
49
+ refused. A session OpenCode creates only after its stage was cancelled is
50
+ deleted when it arrives.
51
+ - A new review cannot be started from a saved review's own session, also after
52
+ an OpenCode restart; until now only the running process refused that.
53
+ - Each private session carries `metadata.azpr` with its run, role and
54
+ conversation (and, for a comment run, the review), so tools that list
55
+ sessions can tell AZPR's sessions from conversations without reading titles.
56
+
57
+ Tools:
58
+
59
+ - A reviewer's tool call that OpenCode stops ends at once instead of when its
60
+ Azure DevOps request returns. The request only that call waits for (a folder
61
+ listing of one level, the PR's threads) is aborted; a file, a recursive
62
+ listing or the repository archive, which the run's other sessions may be
63
+ waiting for too, is still read to the end and kept for them.
64
+
65
+ Documentation:
66
+
67
+ - A model entry that lets the provider choose the model for each session,
68
+ such as GitHub Copilot's Auto in OpenCode 2.2.7 and later, cannot be an AZPR
69
+ model: AZPR refuses a request on another model than the configured one, and
70
+ `/pr-check` does not detect such an entry.
71
+ - While a provider's host cannot be reached, OpenCode 2.3.0 retries the
72
+ request for up to an hour. AZPR allows those retries, so a review waits
73
+ instead of failing; `/pr-stop` ends it.
74
+
3
75
  ## 0.4.0 — 2026-11-14
4
76
 
5
77
  Two defaults change. They apply where a settings file does not name the
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![CI](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/actions/workflows/ci.yml?query=branch%3Amain)
4
4
  [![npm](https://img.shields.io/npm/v/opencode-azure-devops-pr-review)](https://www.npmjs.com/package/opencode-azure-devops-pr-review)
5
5
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
6
- [![Tested with OpenCode 2.2.4](https://img.shields.io/badge/OpenCode-2.2.4%20tested-blue)](docs/VALIDATION.md)
6
+ [![Tested with OpenCode 2.3.0](https://img.shields.io/badge/OpenCode-2.3.0%20tested-blue)](docs/VALIDATION.md)
7
7
 
8
8
  **Review Azure DevOps pull requests from a URL. No checkout required.**
9
9
 
@@ -52,7 +52,7 @@ is an actual capture excerpt with identifying UI removed and its text unchanged.
52
52
  [company networks](docs/ENTERPRISE.md#company-networks) first):
53
53
 
54
54
  ```sh
55
- opencode plugin add opencode-azure-devops-pr-review@0.4.0
55
+ opencode plugin add opencode-azure-devops-pr-review@0.4.1
56
56
  ```
57
57
 
58
58
  2. Follow the [quickstart](docs/QUICKSTART.md) to save your PAT in a private
@@ -301,11 +301,11 @@ models and runs.
301
301
 
302
302
  | Component | Tested target |
303
303
  | --- | --- |
304
- | OpenCode | **OpenCode CLI 2.2.4** (`@opencode/cli`; V2 plugin API). On another OpenCode 2.x, `/pr-check` shows an OpenCode WARNING row and reviews still run. OpenCode 1.x is not supported. |
304
+ | OpenCode | **OpenCode CLI 2.3.0** (`@opencode/cli`; V2 plugin API). On another OpenCode 2.x, `/pr-check` shows an OpenCode WARNING row and reviews still run. OpenCode 1.x is not supported. |
305
305
  | Operating system | **Ubuntu 22.04** (validation environment: WSL2). Other operating systems are not yet validated. |
306
306
  | Azure | **Azure DevOps Services**, REST API **7.1**. Azure DevOps Server is not supported by the current URL handling. |
307
307
  | Installation | OpenCode's plugin manager with the npm package or the versioned Git package, or the source installer with POSIX `sh` and Python 3; no plugin build step or npm dependencies. |
308
- | Models | Your OpenCode provider/model IDs with tool support. Each mode checks the models it uses. |
308
+ | Models | Your OpenCode provider/model IDs with tool support. Each mode checks the models it uses. Name a concrete model, not one that routes each session to another model (see [configuration](#configuration)). |
309
309
 
310
310
  The npm package, the Git package and the release source archive contain the
311
311
  same runtime. A fresh installation exposes `/pr-setup` before
@@ -400,17 +400,17 @@ Azure DevOps REST API with the runtime's built-in `fetch`.
400
400
  Install the npm package with OpenCode's plugin manager:
401
401
 
402
402
  ```sh
403
- opencode plugin add opencode-azure-devops-pr-review@0.4.0
403
+ opencode plugin add opencode-azure-devops-pr-review@0.4.1
404
404
  ```
405
405
 
406
406
  The same release is also a versioned Git package, which needs Git but not the
407
407
  npm registry:
408
408
 
409
409
  ```sh
410
- opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.0'
410
+ opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.1'
411
411
  ```
412
412
 
413
- Add only one of them. OpenCode 2.2.4 loads the plugin into a running OpenCode
413
+ Add only one of them. OpenCode 2.3.0 loads the plugin into a running OpenCode
414
414
  service within a few seconds; if `/pr-setup` does not appear in a new
415
415
  conversation, run `opencode service restart`. Then run `/pr-setup` for setup
416
416
  instructions. Native packages
@@ -421,7 +421,7 @@ To select another configuration file, use an absolute path in the host config:
421
421
  ```json
422
422
  {
423
423
  "plugins": [{
424
- "package": "opencode-azure-devops-pr-review@0.4.0",
424
+ "package": "opencode-azure-devops-pr-review@0.4.1",
425
425
  "options": { "settingsFile": "/absolute/path/to/azpr/settings.json" }
426
426
  }]
427
427
  }
@@ -440,13 +440,13 @@ with a new version adds a second entry**: OpenCode keeps running the version
440
440
  listed first and reports the new one as `Duplicate plugin ID: azpr` (from
441
441
  0.3.1, `/pr-check` also warns about it). Upgrade when no AZPR command is
442
442
  running, since
443
- OpenCode 2.2.4 replaces the running plugin as soon as its entry changes.
443
+ OpenCode 2.3.0 replaces the running plugin as soon as its entry changes.
444
444
 
445
445
  For an entry that `opencode plugin add` created, add the new version and,
446
446
  only when that succeeds, remove the previous one:
447
447
 
448
448
  ```sh
449
- opencode plugin add opencode-azure-devops-pr-review@0.4.0 &&
449
+ opencode plugin add opencode-azure-devops-pr-review@0.4.1 &&
450
450
  opencode plugin remove opencode-azure-devops-pr-review@PREVIOUS_VERSION
451
451
  ```
452
452
 
@@ -469,7 +469,8 @@ configuration needs no new `/pr-setup`. `opencode plugin list` should then
469
469
  show a single `azpr` row with the new version (from 0.3.1, `/pr-check` names
470
470
  it too); if it still shows the previous one, run `opencode service restart`.
471
471
  Exact versions stay pinned, so `opencode plugin update` leaves them unchanged.
472
- See the [0.4.0 release notes](docs/releases/v0.4.0.md) for what changed and the
472
+ See the [0.4.1 release notes](docs/releases/v0.4.1.md) for what changed, the
473
+ [0.4.0 release notes](docs/releases/v0.4.0.md) for commands without review IDs and the
473
474
  [0.2.0 release notes](docs/releases/v0.2.0.md) for automatic comments. A
474
475
  preview follows each COMPLETE review unless `afterReview` says otherwise;
475
476
  automatic publication stays off unless you configure it or request it with a
@@ -480,8 +481,8 @@ review command flag.
480
481
  <details>
481
482
  <summary>Source installation and replacement</summary>
482
483
 
483
- Download the [v0.4.0 source archive](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/archive/refs/tags/v0.4.0.tar.gz)
484
- and extract it, or check out tag `v0.4.0`. The installer needs POSIX `sh` and
484
+ Download the [v0.4.1 source archive](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/archive/refs/tags/v0.4.1.tar.gz)
485
+ and extract it, or check out tag `v0.4.1`. The installer needs POSIX `sh` and
485
486
  Python 3's standard library. From that source directory:
486
487
 
487
488
  ```sh
@@ -610,6 +611,13 @@ never blocks `/pr-review`. Comment planning uses the review's risk model
610
611
  turns on the severity rating. Left out or empty, no rating runs and the
611
612
  verifier's severity is final.
612
613
 
614
+ Name the model that should do the work. AZPR binds every private session to
615
+ the exact model in its settings and refuses a request that OpenCode sends on
616
+ another one, so an entry that lets the provider pick the model for each
617
+ session, such as GitHub Copilot's **Auto** (OpenCode 2.2.7 and later), cannot
618
+ be an AZPR model: its sessions fail with `Model mismatch`. `/pr-check` finds
619
+ such an entry in the model catalog and does not detect this.
620
+
613
621
  | Role | Focus and useful model capabilities |
614
622
  | --- | --- |
615
623
  | `functional` | Requirements, boundaries, state changes, API compatibility and regressions. Strong code comprehension in the project's language. |
@@ -675,7 +683,7 @@ copies that different reviewers get can each produce a finding.
675
683
  | `runTimeoutSeconds` | `null` (no whole-command timer); an integer 10–7200 enables one. |
676
684
  | `shell` | `deny`: private reviewers cannot run shell commands (the tool is hidden). `ask`: each command needs your approval in OpenCode. `inherit`: host permissions decide. |
677
685
  | `progressNotices` | `true`: short PROGRESS notices in the invoking conversation. |
678
- | `deletePrivateSessions` | `true`: AZPR deletes its private reviewer sessions once they are no longer needed (see [retention](#retention-and-privacy)); `false` keeps every session. |
686
+ | `deletePrivateSessions` | `true`: when a command ends, AZPR deletes its private reviewer sessions except the one that holds the review's report (see [retention](#retention-and-privacy)); `false` keeps every session. |
679
687
  | `afterReview.quick` / `.review` / `.deep` | What follows a COMPLETE review of that mode; `preview` each.<br>`preview`: plan a comment preview (a model runs; nothing is posted).<br>`none`: nothing follows; run `/pr-comment` yourself.<br>`publish`: plan the comments and post them as the PAT owner; a comment that a safeguard holds back waits for a person.<br>A flag after the PR URL (`--preview`, `--publish`, `--no-comment`) overrides it for one run. See [automatic comments](#automatic-comments). |
680
688
  | `azure.organization` | Required. The `<org>` of `https://dev.azure.com/<org>`; PR URLs of other organizations are refused. |
681
689
  | `azure.pat` | A personal access token for that organization with **Code (Read)** and **Pull Request Threads (Read & write)**, or `""` when `azure.patFile` is set. Sent only to `https://dev.azure.com/<org>` and never logged. |
@@ -690,7 +698,7 @@ copies that different reviewers get can each produce a finding.
690
698
  | `workflow.shardFindings` | At most `15` findings per verification session; one file's findings stay in the same session (a file is split only when it alone has more). |
691
699
  | `workflow.parallelSessions` | `8` (1–16) reviewer sessions at once within a command; it matters only for a PR of more than one shard. Lower it, to `4` for example, when the provider limits your request rate, or with OpenCode's claude-agent provider on a machine with little memory: each of its sessions keeps a process of about 200 MB for minutes after it ends. Comment planning runs at most two pages at once (one when this is `1`). |
692
700
  | `workflow.repairAttempts` | `2` correction turns when an answer breaks the output contract. A quick review's one follow-up turn for unfinished work uses the same budget. |
693
- | `workflow.stageRetries` | `1` new-session retry after a transient failure (provider 429/5xx, interrupted stream) or an inactivity stop. A used-up usage or spend limit (provider quota, ChatGPT or OpenCode Go usage limit, OpenCode free-model or spend limit) is named and not retried, whatever its status, and AZPR refuses OpenCode's own retries of it. |
701
+ | `workflow.stageRetries` | `1` new-session retry after a transient failure (provider 429/5xx, an interrupted stream that OpenCode did not recover by itself) or an inactivity stop. While the provider's host cannot be reached (no DNS answer, no route), OpenCode 2.3.0 retries the request by itself for up to an hour; AZPR allows that, so the review waits instead of failing, and `/pr-stop` ends it. A used-up usage or spend limit (provider quota, ChatGPT or OpenCode Go usage limit, OpenCode free-model or spend limit) is named and not retried, whatever its status, and AZPR refuses OpenCode's own retries of it. |
694
702
  | `workflow.stageIdleSeconds` | `600` (`0` turns it off, otherwise 60–7200): a reviewer stage that shows no activity this long while it waits on OpenCode (the model stream, a tool or the host stopped responding) is stopped with `failure=idle` and an error naming its last activity, then retried in a new session. Every model request, streamed chunk of output, tool start or end and announced host retry restarts the window, so a stage that keeps working, including a long answer that keeps streaming, is never cut. With shell allowed, an approval or a command that takes longer counts as inactivity. |
695
703
  | `debug.enabled` / `debug.directory` / `debug.keepRuns` | `false` / `""` / `20` run directories kept (`0` keeps all); see [debugging](docs/DEBUGGING.md). |
696
704
 
@@ -942,12 +950,22 @@ are removed automatically. A receipt that cannot reach the conversation is saved
942
950
  under `receipts/` there. `/pr-comment` only accepts reviews started in the same
943
951
  conversation (or from one of that review's sessions).
944
952
 
945
- OpenCode does not delete sessions by itself, so AZPR removes its private
946
- reviewer sessions (`deletePrivateSessions`, on by default): a completed review's
947
- sessions go when the review is evicted, since `/pr-comment` needs them until
948
- then. A review that did not complete keeps only the session holding its report
949
- or draft (every session while debug is enabled), and these kept sessions follow
950
- the same limit of 20 runs. Your own conversations are never deleted.
953
+ AZPR's private reviewer sessions are sessions of their own, not children of
954
+ your conversation: OpenCode 2.3.0 hands every answer of a child session to its
955
+ parent and lets the parent's model respond to it. OpenCode therefore lists them
956
+ next to your conversations, titled `[AZPR <id>] …`, and does not delete
957
+ sessions by itself, so AZPR removes them (`deletePrivateSessions`, on by
958
+ default). When a review ends, only the session that holds its report or draft
959
+ stays, which is the one the receipt names, and the other sessions are deleted
960
+ at once; a comment run keeps none, since its receipt carries the preview or
961
+ the publication result. That one session goes when its review is evicted (a
962
+ review that did not complete follows the same limit of 20 runs). A session
963
+ OpenCode did not delete when asked stays on record: it goes with its review,
964
+ or, when no review keeps it, takes no AZPR commands and is tried again after
965
+ every later run. While debug is enabled every session is kept until its
966
+ review is evicted, so turn `debug.enabled` off for everyday use if the list
967
+ gets long. A review that an OpenCode restart interrupts leaves its sessions in
968
+ the list; delete those yourself. Your own conversations are never deleted.
951
969
 
952
970
  ## Development and removal
953
971
 
@@ -973,8 +991,8 @@ and a loopback fake Azure DevOps REST service in disposable directories under
973
991
  Uninstall without `--apply` previews; `--apply` archives only this package under
974
992
  `azpr-v2-backups` and leaves the private state directory for you to delete.
975
993
  For a native installation, remove the entry you added, for example
976
- `opencode plugin remove opencode-azure-devops-pr-review@0.4.0` or
977
- `opencode plugin remove 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.0'`;
994
+ `opencode plugin remove opencode-azure-devops-pr-review@0.4.1` or
995
+ `opencode plugin remove 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.1'`;
978
996
  the external settings, PAT file and private review state remain available.
979
997
 
980
998
  [Architecture](docs/ARCHITECTURE.md), [commenting](docs/COMMENTING.md),
@@ -987,7 +1005,7 @@ or personal model selections.
987
1005
  ## License and releases
988
1006
 
989
1007
  [MIT](LICENSE), copyright 2026 WTLAIB. See the [changelog](CHANGELOG.md) for the
990
- release scope, [v0.4.0](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.4.0)
1008
+ release scope, [v0.4.1](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.4.1)
991
1009
  for downloads, the [npm package](https://www.npmjs.com/package/opencode-azure-devops-pr-review),
992
1010
  [v0.2.0](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.2.0)
993
1011
  for the recorded demonstration, and [releasing](docs/RELEASING.md) for the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-azure-devops-pr-review",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "description": "Azure DevOps PR reviews from a URL in OpenCode, with no checkout, configurable models, separate verification, and comment previews you can adjust before posting",
6
6
  "scripts": {
@@ -266,6 +266,7 @@ function renderStageReceipt(stage) {
266
266
  ['repair-turns', stage.repairs?.length],
267
267
  ['stream-continuations', stage.hostContinuations],
268
268
  ['continuation-restarts', stage.continuationRestarts],
269
+ ['step-retries', stage.hostStepRetries],
269
270
  ['blocked-native-tools', stage.blockedNativeToolCalls],
270
271
  ['observed-tool-errors', stage.toolFailures],
271
272
  ['tool-timeouts', stage.toolTimeouts],
@@ -290,6 +291,7 @@ export function renderReceipt(run, report, status, error, settings) {
290
291
  if (run.draft) body += run.mode === 'quick'
291
292
  ? '\nIncomplete draft notice: the quick review did not complete; its observations are unconfirmed and not input for PR comments.\n'
292
293
  : '\nIncomplete draft notice: initial observations are unconfirmed because verification did not complete; they are not input for PR comments.\n';
294
+ if (run.sessionsRemoved) body += `\nSession notice: ${run.sessionsRemoved} reviewer session(s) of this run were deleted when it ended; only a session that holds the report or draft is kept (deletePrivateSessions). debug.enabled keeps them all.\n`;
293
295
  body += renderDiagnosticNotices(run, settings);
294
296
  body += run.mode === 'check'
295
297
  ? '\nStatus: READY means AZPR can read the PR through the Azure DevOps REST API; it does not review or approve the PR.\n'
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
  },
@@ -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
  }