opencode-azure-devops-pr-review 0.3.2 → 0.3.3

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,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.3 — 2026-10-31
4
+
5
+ - AZPR is tested with OpenCode 2.2.4 instead of 2.1.4. The runtime needed no
6
+ change: on both hosts the same review sends byte-identical model requests.
7
+ Upgrading OpenCode migrates its database irreversibly; stop the service and
8
+ back up `opencode.db` first.
9
+ - `/pr-check` names the OpenCode version in a row of its own and warns when it
10
+ is not the tested one; reviews still run. Receipts no longer end with a
11
+ host notice.
12
+ - A used-up usage or spend limit stops the stage at once: AZPR refuses
13
+ OpenCode's retries and starts no new session, and the receipt names the
14
+ limit. This covers OpenCode 2.2.3's ChatGPT and OpenCode Go usage limits and
15
+ OpenCode's spend limits besides the provider quota and the free-model limit;
16
+ before, a used-up ChatGPT limit was retried as a rate limit.
17
+ - AZPR subscribes only to the session events that show a review progressing;
18
+ OpenCode 2.2.0 and later deliver no others.
19
+ - On OpenCode 2.2.4, `NO_PROXY` always lists `127.0.0.1`, `localhost` and
20
+ `::1`, and Bun honours `NO_PROXY` even for `azure.proxy`. Azure DevOps is
21
+ unaffected; the company-network guide now says to keep `dev.azure.com` out of
22
+ `NO_PROXY` when it must use the proxy. Test-only Azure DevOps base URLs may
23
+ use any 127.0.0.0/8 address, so the proxy scenario can still be tested.
24
+ - The host smoke test adds a foreign MCP server behind CodeMode and an image
25
+ model, and checks that private reviewers see neither those tools nor image
26
+ generation while ordinary sessions keep them.
27
+
3
28
  ## 0.3.2 — 2026-10-30
4
29
 
5
30
  - The README starts with actual Azure DevOps output: an inline comment with its
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.1.4](https://img.shields.io/badge/OpenCode-2.1.4%20tested-blue)](docs/VALIDATION.md)
6
+ [![Tested with OpenCode 2.2.4](https://img.shields.io/badge/OpenCode-2.2.4%20tested-blue)](docs/VALIDATION.md)
7
7
 
8
8
  **Review Azure DevOps pull requests from a URL. No checkout required.**
9
9
 
@@ -47,7 +47,7 @@ is an actual capture excerpt with identifying UI removed and its text unchanged.
47
47
  [company networks](docs/ENTERPRISE.md#company-networks) first):
48
48
 
49
49
  ```sh
50
- opencode plugin add opencode-azure-devops-pr-review@0.3.2
50
+ opencode plugin add opencode-azure-devops-pr-review@0.3.3
51
51
  ```
52
52
 
53
53
  2. Follow the [quickstart](docs/QUICKSTART.md) to save your PAT in a private
@@ -171,7 +171,7 @@ general review-accuracy score.
171
171
 
172
172
  | Component | Tested target |
173
173
  | --- | --- |
174
- | OpenCode | **OpenCode CLI 2.1.4** (`@opencode/cli`; V2 plugin API). OpenCode 1.x is not supported. |
174
+ | 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. |
175
175
  | Operating system | **Ubuntu 22.04** (validation environment: WSL2). Other operating systems are not yet validated. |
176
176
  | Azure | **Azure DevOps Services**, REST API **7.1**. Azure DevOps Server is not supported by the current URL handling. |
177
177
  | 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. |
@@ -263,17 +263,17 @@ Azure DevOps REST API with the runtime's built-in `fetch`.
263
263
  Install the npm package with OpenCode's plugin manager:
264
264
 
265
265
  ```sh
266
- opencode plugin add opencode-azure-devops-pr-review@0.3.2
266
+ opencode plugin add opencode-azure-devops-pr-review@0.3.3
267
267
  ```
268
268
 
269
269
  The same release is also a versioned Git package, which needs Git but not the
270
270
  npm registry:
271
271
 
272
272
  ```sh
273
- opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.3.2'
273
+ opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.3.3'
274
274
  ```
275
275
 
276
- Add only one of them. OpenCode 2.1.4 loads the plugin into a running OpenCode
276
+ Add only one of them. OpenCode 2.2.4 loads the plugin into a running OpenCode
277
277
  service within a few seconds; if `/pr-setup` does not appear in a new
278
278
  conversation, run `opencode service restart`. Then run `/pr-setup` for setup
279
279
  instructions. Native packages
@@ -284,7 +284,7 @@ To select another configuration file, use an absolute path in the host config:
284
284
  ```json
285
285
  {
286
286
  "plugins": [{
287
- "package": "opencode-azure-devops-pr-review@0.3.2",
287
+ "package": "opencode-azure-devops-pr-review@0.3.3",
288
288
  "options": { "settingsFile": "/absolute/path/to/azpr/settings.json" }
289
289
  }]
290
290
  }
@@ -303,13 +303,13 @@ with a new version adds a second entry**: OpenCode keeps running the version
303
303
  listed first and reports the new one as `Duplicate plugin ID: azpr` (from
304
304
  0.3.1, `/pr-check` also warns about it). Upgrade when no AZPR command is
305
305
  running, since
306
- OpenCode 2.1.4 replaces the running plugin as soon as its entry changes.
306
+ OpenCode 2.2.4 replaces the running plugin as soon as its entry changes.
307
307
 
308
308
  For an entry that `opencode plugin add` created, add the new version and,
309
309
  only when that succeeds, remove the previous one:
310
310
 
311
311
  ```sh
312
- opencode plugin add opencode-azure-devops-pr-review@0.3.2 &&
312
+ opencode plugin add opencode-azure-devops-pr-review@0.3.3 &&
313
313
  opencode plugin remove opencode-azure-devops-pr-review@PREVIOUS_VERSION
314
314
  ```
315
315
 
@@ -332,7 +332,7 @@ configuration needs no new `/pr-setup`. `opencode plugin list` should then
332
332
  show a single `azpr` row with the new version (from 0.3.1, `/pr-check` names
333
333
  it too); if it still shows the previous one, run `opencode service restart`.
334
334
  Exact versions stay pinned, so `opencode plugin update` leaves them unchanged.
335
- See the [0.3.2 release notes](docs/releases/v0.3.2.md) for what changed and the
335
+ See the [0.3.3 release notes](docs/releases/v0.3.3.md) for what changed and the
336
336
  [0.2.0 release notes](docs/releases/v0.2.0.md) for automatic comments, which
337
337
  remain disabled unless you configure `afterReview` or request them with a
338
338
  review command flag.
@@ -342,8 +342,8 @@ review command flag.
342
342
  <details>
343
343
  <summary>Source installation and replacement</summary>
344
344
 
345
- Download the [v0.3.2 source archive](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/archive/refs/tags/v0.3.2.tar.gz)
346
- and extract it, or check out tag `v0.3.2`. The installer needs POSIX `sh` and
345
+ Download the [v0.3.3 source archive](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/archive/refs/tags/v0.3.3.tar.gz)
346
+ and extract it, or check out tag `v0.3.3`. The installer needs POSIX `sh` and
347
347
  Python 3's standard library. From that source directory:
348
348
 
349
349
  ```sh
@@ -498,14 +498,14 @@ every concrete defect it finds, in any area, as a finding.
498
498
  | `azure.concurrency` | `3` simultaneous Azure DevOps calls across all AZPR commands. |
499
499
  | `azure.callTimeoutSeconds` | `120`; a hung call is aborted and its slot released (reads are retried). |
500
500
  | `azure.archiveMegabytes` | `100` (1–1024): the largest repository zip that content search downloads per run and commit; a larger repository is not searched. It is held in memory during a review. |
501
- | `azure.proxy` | `""`: no AZPR proxy (`HTTPS_PROXY` and `NO_PROXY` in OpenCode's environment still apply). A forward proxy for AZPR's Azure DevOps calls only, such as `http://proxy.example.com:8080`; credentials go in the URL as `http://user:password@host:port` (percent-encoded) and are never shown. See [proxies](docs/AZURE_DEVOPS.md#proxies-and-tls-inspection). |
501
+ | `azure.proxy` | `""`: no AZPR proxy (`HTTPS_PROXY` and `NO_PROXY` in OpenCode's environment still apply; a host in `NO_PROXY` bypasses a set proxy too). A forward proxy for AZPR's Azure DevOps calls only, such as `http://proxy.example.com:8080`; credentials go in the URL as `http://user:password@host:port` (percent-encoded) and are never shown. See [proxies](docs/AZURE_DEVOPS.md#proxies-and-tls-inspection). |
502
502
  | `azure.caFile` | `""`. The absolute path of a PEM file with CA certificates AZPR trusts in addition to the built-in roots, for a proxy that inspects HTTPS. |
503
503
  | `azure.verifyTls` | `true`. `false` skips certificate checks for AZPR's Azure DevOps calls (like `curl -k`), so anyone who can intercept the connection can read the PAT; prefer `azure.caFile`. `/pr-check` warns while it is off. |
504
504
  | `workflow.shardFiles` | `25` changed files per initial-review session. |
505
505
  | `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). |
506
506
  | `workflow.parallelSessions` | `4` reviewer sessions at once within a command; comment planning runs at most two pages at once (one when this is `1`). |
507
507
  | `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. |
508
- | `workflow.stageRetries` | `1` new-session retry after a transient failure (provider 429/5xx, interrupted stream) or an inactivity stop. A used-up provider quota or OpenCode free-model limit is named and not retried, whatever its status. |
508
+ | `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. |
509
509
  | `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. |
510
510
  | `debug.enabled` / `debug.directory` / `debug.keepRuns` | `false` / `""` / `20` run directories kept (`0` keeps all); see [debugging](docs/DEBUGGING.md). |
511
511
 
@@ -761,8 +761,8 @@ and a loopback fake Azure DevOps REST service in disposable directories under
761
761
  Uninstall without `--apply` previews; `--apply` archives only this package under
762
762
  `azpr-v2-backups` and leaves the private state directory for you to delete.
763
763
  For a native installation, remove the entry you added, for example
764
- `opencode plugin remove opencode-azure-devops-pr-review@0.3.2` or
765
- `opencode plugin remove 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.3.2'`;
764
+ `opencode plugin remove opencode-azure-devops-pr-review@0.3.3` or
765
+ `opencode plugin remove 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.3.3'`;
766
766
  the external settings, PAT file and private review state remain available.
767
767
 
768
768
  [Architecture](docs/ARCHITECTURE.md), [commenting](docs/COMMENTING.md),
@@ -775,7 +775,7 @@ or personal model selections.
775
775
  ## License and releases
776
776
 
777
777
  [MIT](LICENSE), copyright 2026 WTLAIB. See the [changelog](CHANGELOG.md) for the
778
- release scope, [v0.3.2](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.3.2)
778
+ release scope, [v0.3.3](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.3.3)
779
779
  for downloads, the [npm package](https://www.npmjs.com/package/opencode-azure-devops-pr-review),
780
780
  [v0.2.0](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.2.0)
781
781
  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.3.2",
3
+ "version": "0.3.3",
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": {
@@ -1,5 +1,4 @@
1
1
  import { ROLES } from './config.mjs';
2
- import { TESTED_HOST_VERSION } from './host.mjs';
3
2
  // Deterministic attribution from invoked reviewer stages, not model-authored claims.
4
3
  const vocabulary = {
5
4
  en: { title: 'AI review provenance', disclaimer: 'AI-generated review, not human approval. Posting through a user account does not imply that person verified these conclusions.', method: 'Independent initial reviews, followed by source-based verification, duplicate merging, and rejection of unsupported findings; not majority voting.', roles: ['Source check', 'Functional review', 'Risk review', 'Verification', 'Duplicate check', 'Quick review'], stage: 'Stage', model: 'Selected provider/model ID', sessions: 'Sessions', count: 'Initial findings', dispositions: 'Finding dispositions', finding: 'Finding', result: 'Result', merged: 'Merged into', extra: 'New verifier findings', note: 'IDs identify the models selected in OpenCode, not independently verified provider backend identities. Host auxiliary models and the original chat model are not part of this ledger.', comment: 'AI-generated review; not human review or approval. Models:',
@@ -273,7 +272,6 @@ export function renderReceipt(run, report, status, error, settings) {
273
272
  ? '\nIncomplete draft notice: the quick review did not complete; its observations are unconfirmed and not input for PR comments.\n'
274
273
  : '\nIncomplete draft notice: initial observations are unconfirmed because verification did not complete; they are not input for PR comments.\n';
275
274
  body += renderDiagnosticNotices(run);
276
- if (run.compatibility && !run.compatibility.tested && run.compatibility.version !== 'unknown') body += `\nHost notice: OpenCode ${run.compatibility.version} differs from the tested ${TESTED_HOST_VERSION}; capabilities were detected at runtime.\n`;
277
275
  body += run.mode === 'check'
278
276
  ? '\nStatus: READY means AZPR can read the PR through the Azure DevOps REST API; it does not review or approve the PR.\n'
279
277
  : run.mode === 'comment'
package/src/azure.mjs CHANGED
@@ -105,14 +105,17 @@ export function targetKey(target) {
105
105
 
106
106
  /**
107
107
  * A REST base URL other than dev.azure.com is accepted only for loopback test
108
- * servers, so a mistaken override can never send the PAT to another host.
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
110
+ * to NO_PROXY, and Bun then bypasses even an explicit proxy, so a proxied test
111
+ * server needs another loopback address.
109
112
  */
110
113
  export function restBaseUrl(override) {
111
114
  if (override === undefined || override === null || override === '') return DEFAULT_BASE_URL;
112
115
  let url;
113
116
  try { url = new URL(override); } catch { throw new Error('[AZPR] The Azure DevOps test base URL is not a valid URL.'); }
114
117
  if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.search || url.hash ||
115
- !['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname)) {
118
+ !(url.hostname === 'localhost' || url.hostname === '[::1]' || /^127(?:\.\d{1,3}){3}$/.test(url.hostname))) {
116
119
  throw new Error('[AZPR] An Azure DevOps base URL override must be a loopback test server.');
117
120
  }
118
121
  return url.href.replace(/\/+$/, '');
package/src/host.mjs CHANGED
@@ -6,9 +6,9 @@
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.1.4';
9
+ export const TESTED_HOST_VERSION = '2.2.4';
10
10
 
11
- // Text OpenCode (2.0.32 through 2.1.4) queues after resuming an interrupted text stream.
11
+ // Text OpenCode (2.0.32 through 2.2.4) queues after resuming an interrupted text stream.
12
12
  export const HOST_CONTINUATION_TEXT = 'The previous response was interrupted. Continue from where you left off without repeating completed content.';
13
13
 
14
14
  // Context message types that mean someone other than the admitted prompt
@@ -57,7 +57,7 @@ export function packageNamed(target, name, repository) {
57
57
  }
58
58
 
59
59
  /**
60
- * This plugin's entries in the host's plugin list. OpenCode 2.1.4 lists
60
+ * This plugin's entries in the host's plugin list. OpenCode 2.1.4 through 2.2.4 list
61
61
  * { id?, source: { type: package|local|builtin|sdk, target?, version? },
62
62
  * state: { status: active|failed, error? } } and keeps only the first entry
63
63
  * of a plugin ID: a second one is listed as failed with "Duplicate plugin ID".
@@ -93,7 +93,7 @@ export function pluginSourceLabel(source) {
93
93
 
94
94
  /**
95
95
  * Session events that show a turn progressing while no hook runs. OpenCode
96
- * 2.1.2 and 2.1.4 emit one delta event per streamed chunk of answer text,
96
+ * 2.1.2 through 2.2.4 emit one delta event per streamed chunk of answer text,
97
97
  * reasoning or tool-call input; the projected session context shows the text
98
98
  * only once the step ends.
99
99
  */
@@ -107,6 +107,13 @@ const PROGRESS_EVENTS = new Map([
107
107
  ['session.step.ended', 'a model step ended'],
108
108
  ]);
109
109
 
110
+ /**
111
+ * The event types to subscribe to. OpenCode 2.2.0 and later deliver only
112
+ * these (`event.subscribe({ types })`); earlier releases ignore the option and
113
+ * `sessionProgress` skips the rest.
114
+ */
115
+ export const PROGRESS_EVENT_TYPES = Object.freeze([...PROGRESS_EVENTS.keys()]);
116
+
110
117
  /** The session and activity a progress event stands for, or null. */
111
118
  export function sessionProgress(event) {
112
119
  const activity = PROGRESS_EVENTS.get(event?.type);
@@ -115,7 +122,7 @@ export function sessionProgress(event) {
115
122
  }
116
123
 
117
124
  /**
118
- * OpenCode runs plugins on Bun (1.4.2 in 2.0.32 and 2.1.2, 1.4.4 in 2.1.4),
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),
119
126
  * whose fetch accepts per-request `proxy` and `tls` options. Node's fetch
120
127
  * silently ignores both, so a configured proxy would be bypassed; callers
121
128
  * refuse instead.
@@ -144,6 +151,22 @@ export function usageTotals(requests) {
144
151
  return { ...total, cachedInputShare: prompt ? Number((total.cacheRead / prompt).toFixed(4)) : null };
145
152
  }
146
153
 
154
+ /**
155
+ * Provider error types that mean a usage or spend limit is used up. Another
156
+ * attempt fails the same way, so AZPR refuses OpenCode's retries of them and
157
+ * starts no new session. OpenCode 2.2.0 added the spend limits and 2.2.3 the
158
+ * ChatGPT and OpenCode Go usage limits; before, a ChatGPT limit arrived as a
159
+ * rate limit.
160
+ */
161
+ export const USED_UP_LIMITS = Object.freeze({
162
+ 'provider.quota': 'The provider reports the usage quota as used up',
163
+ 'provider.free-limit': "OpenCode reports the free model's usage limit as reached",
164
+ 'provider.chatgpt-limit': 'ChatGPT reports the subscription usage limit as reached',
165
+ 'provider.go-limit': 'OpenCode Go reports its usage limit as reached',
166
+ 'provider.budget-limit': 'OpenCode reports the workspace usage limit as reached',
167
+ 'provider.model-budget-limit': "OpenCode reports this model's spend limit as reached",
168
+ });
169
+
147
170
  /** Throw one readable error naming every missing host method. */
148
171
  export function requireMethods(context, paths, purpose) {
149
172
  const missing = paths.filter(path => typeof path.split('.').reduce((value, key) => value?.[key], context) !== 'function');
package/src/runtime.mjs CHANGED
@@ -27,7 +27,7 @@ import { API_VERSION, createAzureClient, fetchTransport, pemCertificates, proxyL
27
27
  import { REVIEW_TOOL_NAMES, reviewToolDefinitions, runReviewTool } from './review-tools.mjs';
28
28
  import { runReview } from './review-work.mjs';
29
29
  import { createReviewStore, stateRoot, REVIEW_LIMIT } from './store.mjs';
30
- import { TESTED_HOST_VERSION, fetchTransportSupported, hostCapabilities, listOf, packageNamed, pluginEntries, pluginSourceLabel, recordOf, requireMethods, sessionProgress, tokenUsage, usageTotals, withoutCredentials } from './host.mjs';
30
+ import { PROGRESS_EVENT_TYPES, TESTED_HOST_VERSION, USED_UP_LIMITS, fetchTransportSupported, hostCapabilities, listOf, packageNamed, pluginEntries, pluginSourceLabel, recordOf, requireMethods, sessionProgress, tokenUsage, usageTotals, withoutCredentials } from './host.mjs';
31
31
  import {
32
32
  reviewProvenance, provenanceReport, commentAttribution, renderFinalReport, renderCommentActions,
33
33
  renderIncompleteDraft, renderReceipt, renderDiagnosticNotices, renderCheckReport, renderPublication,
@@ -412,7 +412,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
412
412
  eventFollowers++;
413
413
  if (eventFeed || disposed || !capabilities.eventSubscribe) return;
414
414
  let iterator;
415
- try { iterator = context.event.subscribe()[Symbol.asyncIterator](); } catch { return; }
415
+ try { iterator = context.event.subscribe({ types: [...PROGRESS_EVENT_TYPES] })[Symbol.asyncIterator](); } catch { return; }
416
416
  eventFeed = iterator;
417
417
  void (async () => {
418
418
  try {
@@ -681,7 +681,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
681
681
  }
682
682
  requireMethods(context, ['session.create', 'session.prompt', 'session.wait', 'session.context', 'session.interrupt', 'session.synthetic'], 'the review workflow');
683
683
  let id; do { id = randomUUID().slice(0, 8); } while (runs.has(id) || completed.has(id));
684
- const run = { ...details, id, active: true, controller: new AbortController(), stages: [], toolText: new Map(), compatibility: capabilities,
684
+ const run = { ...details, id, active: true, controller: new AbortController(), stages: [], toolText: new Map(),
685
685
  deadlineAt: settings.runTimeoutSeconds === null ? null : Date.now() + settings.runTimeoutSeconds * 1000 };
686
686
  runs.set(id, run);
687
687
  sourceRuns.set(run.origin, id);
@@ -765,6 +765,10 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
765
765
  else if (modelSlots('deep').every(slot => settings.models.deep[slot] === settings.models.review[slot])) {
766
766
  checks.push({ name: 'Deep models', ok: true, warning: true, detail: 'models.deep repeats models.review, so /pr-deep would only repeat /pr-review; set stronger models there for the PRs that need them.' });
767
767
  }
768
+ // One OpenCode release is validated; on others, reviews still run and what AZPR needs is detected at runtime.
769
+ const host = capabilities.version === 'unknown' ? 'OpenCode did not report its version' : `OpenCode ${capabilities.version}`;
770
+ checks.push(capabilities.tested ? { name: 'OpenCode', ok: true, detail: `${host}, the tested version.` }
771
+ : { name: 'OpenCode', ok: true, warning: true, detail: `${host}; AZPR is tested with ${TESTED_HOST_VERSION}. Reviews still run: AZPR detects what this OpenCode provides and refuses to start if something it needs is missing.` });
768
772
  checks.push(await installationCheck(run));
769
773
  // What follows a COMPLETE review of each mode; automatic publication posts as the PAT owner.
770
774
  const publishing = MODES.filter(mode => settings.afterReview[mode] === 'publish').map(mode => `/pr-${mode}`);
@@ -1223,7 +1227,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1223
1227
  try {
1224
1228
  const g = authorize(event.sessionID, event.agent, event.model);
1225
1229
  // Refused before anything is sent. Whether the stage overflowed is read from its failed turn: a
1226
- // compaction OpenCode attempts there ends it, a background summary (OpenCode 2.1.4) does not.
1230
+ // compaction OpenCode attempts there ends it, a background summary (OpenCode 2.1.4 and later) does not.
1227
1231
  if (event.kind !== 'primary') {
1228
1232
  throw new Error(event.kind === 'compaction'
1229
1233
  ? '[AZPR] Private review compaction is not authorized; a reviewer whose context fills is split into smaller sessions instead.'
@@ -1243,12 +1247,14 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1243
1247
  if (!ownRole(event.agent) && !seenSessions.has(event.sessionID)) return;
1244
1248
  const g = grants.get(event.sessionID);
1245
1249
  const proposed = event.decision?.retry === true;
1250
+ // A used-up usage or spend limit fails every attempt the same way; the failed turn names it.
1251
+ const usedUp = Object.hasOwn(USED_UP_LIMITS, event.error?.type) ? event.error.type : null;
1246
1252
  let authorized = false;
1247
- try { if (g?.run.active) { authorize(event.sessionID, event.agent, event.model); authorized = true; } } catch { /* Revoked. */ }
1253
+ try { if (g?.run.active && !usedUp) { authorize(event.sessionID, event.agent, event.model); authorized = true; } } catch { /* Revoked. */ }
1248
1254
  if (!authorized) event.decision = { retry: false };
1249
1255
  const attempt = Number.isInteger(event.attempt) ? event.attempt : null;
1250
1256
  const delayMs = Number.isFinite(event.decision?.delay) && event.decision.delay > 0 ? event.decision.delay : 0;
1251
- g?.retryEvents.push({ attempt, proposed, allowed: authorized && proposed, ...(delayMs ? { delayMs } : {}) });
1257
+ g?.retryEvents.push({ attempt, proposed, allowed: authorized && proposed, ...(usedUp ? { usedUp } : {}), ...(delayMs ? { delayMs } : {}) });
1252
1258
  // OpenCode waits before it prepares the request again; that wait is not inactivity.
1253
1259
  if (authorized && proposed) touch(g, `the host scheduled a retry${attempt === null ? '' : ` (attempt ${attempt})`}`, delayMs);
1254
1260
  }));
@@ -1256,7 +1262,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1256
1262
  // Enforce the shell setting and the project boundary, regardless of
1257
1263
  // permission rules the host appends after this plugin. Outside the
1258
1264
  // project only AZPR's own private data is readable; the host's default
1259
- // for other paths is not trusted (OpenCode 2.0.22 asked; 2.0.31 through 2.1.4 allow).
1265
+ // for other paths is not trusted (OpenCode 2.0.22 asked; 2.0.31 through 2.2.4 allow).
1260
1266
  // Private reviewers run unattended: a request that would wait for
1261
1267
  // approval is refused at once. Only shell keeps host approvals, and only
1262
1268
  // when the user allowed it (shell: "ask" or "inherit").
package/src/session.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /** OpenCode V2 session transport. No provider, Azure or HTTP client. */
2
2
  import { isDeepStrictEqual } from 'node:util';
3
- import { FOREIGN_MESSAGE_TYPES, isHostContinuation, requireMethods } from './host.mjs';
3
+ import { FOREIGN_MESSAGE_TYPES, USED_UP_LIMITS, isHostContinuation, requireMethods } from './host.mjs';
4
4
 
5
5
  const pendingAdmissions = new WeakMap();
6
6
  const textValue = value => typeof value === 'string' && value.length > 0;
@@ -104,16 +104,10 @@ function responseError(message, response, execution) {
104
104
  }
105
105
 
106
106
  // Bounded host metadata only; provider bodies can contain private request data.
107
- // Provider errors that a new session cannot fix: the usage limit is used up.
108
- const EXHAUSTED = {
109
- 'provider.quota': 'The provider reports the usage quota as used up',
110
- 'provider.free-limit': "OpenCode reports the free model's usage limit as reached",
111
- };
112
-
113
107
  function providerFailure(final, assistants) {
114
108
  const error = final?.error;
115
109
  if (typeof error?.type !== 'string' || !error.type.startsWith('provider.')) return undefined;
116
- const exhausted = Object.hasOwn(EXHAUSTED, error.type);
110
+ const exhausted = Object.hasOwn(USED_UP_LIMITS, error.type);
117
111
  const status = Number.isInteger(error.status) && error.status >= 400 && error.status <= 599 ? error.status : undefined;
118
112
  if (status === undefined && !exhausted) return undefined;
119
113
  return { ...(status === undefined ? {} : { status }), ...(exhausted ? { exhausted: error.type } : {}),
@@ -171,8 +165,8 @@ export function restartIndex(texts) {
171
165
  * its own failure decides.
172
166
  * - transient: interrupted streams, provider 408/409/425/429/5xx, missing idle,
173
167
  * unexpected host messages.
174
- * - permanent: everything else (authentication, bad request, a used-up quota or
175
- * free-model limit, whatever its HTTP status, cancellation).
168
+ * - permanent: everything else (authentication, bad request, a used-up usage or
169
+ * spend limit, whatever its HTTP status, cancellation).
176
170
  */
177
171
  export function classifyFailure(error) {
178
172
  const execution = error?.execution;
@@ -235,13 +229,13 @@ export async function requestReview(context, { sessionID, text, role, model, met
235
229
  assistantResponses: assistants.length, lastFinish: finish,
236
230
  interrupted: session.outcome === 'interrupted' || terminal?.outcome === 'interrupted' || final?.error?.type === 'aborted' };
237
231
  // OpenCode opens a compaction's message before it asks for the summary, so a compaction it attempted in this
238
- // turn, which AZPR refuses, shows here. A background summary (OpenCode 2.1.4) publishes nothing.
232
+ // turn, which AZPR refuses, shows here. A background summary (OpenCode 2.1.4 and later) publishes nothing.
239
233
  const compaction = turn.filter(message => message?.type === 'compaction').at(-1);
240
234
  if (compaction) execution.compaction = ['running', 'completed', 'failed'].includes(compaction.status) ? compaction.status : 'unknown';
241
235
  const provider = !execution.interrupted && providerFailure(final, assistants);
242
236
  if (provider) execution.provider = provider;
243
237
  const hint = provider?.exhausted
244
- ? ` ${EXHAUSTED[provider.exhausted]} (${provider.exhausted}), so a new session would fail the same way and is not started. Choose another model in the settings or wait until the limit resets.`
238
+ ? ` ${USED_UP_LIMITS[provider.exhausted]} (${provider.exhausted}), so a new session would fail the same way and is not started. Choose another model in the settings or wait until the limit resets.`
245
239
  : [401, 403].includes(provider?.status) ? ' Check provider access and the role\'s tool permissions.' : '';
246
240
  const detail = provider
247
241
  ? `Model provider request failed (${provider.status ? `HTTP ${provider.status}; ` : ''}${provider.toolCallsObserved} tool calls observed).${hint} `