@noppu-labs/opencode-permission-reviewer 3.1.0 → 3.2.0

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
@@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.2.0] - 2026-10-23
11
+
12
+ ### Changed
13
+
14
+ - OpenCode V2 hosts before 2.0.22 are no longer supported; V2 now requires
15
+ `>=2.0.22 <3`. The reviewer relies on plugin-context APIs introduced in
16
+ 2.0.22.
17
+ - On OpenCode V2 the reviewer now runs through the plugin's own context by
18
+ default, so it works in every server mode (background service, standalone, or
19
+ `serve`) with no setup. `OPENCODE_PERMISSION_REVIEWER_HOST_URL` and
20
+ `OPENCODE_PASSWORD` remain an explicit override for an independent server.
21
+
22
+ ### Removed
23
+
24
+ - OpenCode V2 registered-service discovery (`service.json`) is gone; the host
25
+ connection no longer uses it, and it is no longer needed in any server mode.
26
+
27
+ ### Fixed
28
+
29
+ - When the reviewer reaches a different OpenCode server than the one it runs in, the error now
30
+ says which server it reached and which settings point it at the right one.
31
+ - Jev answers where a supporting judgement (risk, authorization, scope, evidence, or basis) is
32
+ within 0.02 of the most probable option are no longer treated as invalid. The allow, deny,
33
+ or escalate outcome itself must still be the most probable option.
34
+
10
35
  ## [3.1.0] - 2026-10-21
11
36
 
12
37
  ### Added
package/MIGRATION.md CHANGED
@@ -6,7 +6,7 @@ in `tests/compatibility/host-contracts.json`.
6
6
 
7
7
  | Setting | V1 | V2 |
8
8
  | ---------------------- | ----------------------------- | ------------------------------------- |
9
- | Host | 1.18.29 or newer V1 | >=2.0.3 <3 |
9
+ | Host | 1.18.29 or newer V1 | >=2.0.22 <3 |
10
10
  | Server config key | `plugin` | `plugins` |
11
11
  | Entry with options | `[package, options]` | `{package, options}` |
12
12
  | Terminal config | `tui.json` or `tui.jsonc` | Global `cli.json` |
@@ -35,12 +35,9 @@ trusted restrictions.
35
35
  The reviewer model must be configured globally in OpenCode so its isolated
36
36
  location can resolve it without loading project providers or instructions.
37
37
 
38
- V2 service discovery reads OpenCode's local authenticated service registration
39
- instead of probing version-specific health endpoints. The registration must
40
- match the running host version, identify a live process, and use a loopback URL;
41
- the reviewer then proves the plugin instance through its own RPC identity. It
42
- never starts a service. An independent server requires these trusted environment
43
- settings:
38
+ On V2 the reviewer drives the review through the plugin context, so it works
39
+ in every server mode with no setup. An independent server overrides the
40
+ in-process host with these trusted environment settings:
44
41
 
45
42
  ```bash
46
43
  export OPENCODE_PERMISSION_REVIEWER_HOST_URL=http://127.0.0.1:4096
package/README.md CHANGED
@@ -39,7 +39,7 @@ plugin, not affiliated with or endorsed by [Anomaly](https://anoma.ly).
39
39
  ## Requirements
40
40
 
41
41
  - [Bun](https://bun.sh) >= 1.3.0
42
- - [OpenCode](https://opencode.ai) V1 `>=1.18.29 <2` (tested with 1.18.35) or V2 `>=2.0.3 <3`
42
+ - [OpenCode](https://opencode.ai) V1 `>=1.18.29 <2` (tested with 1.18.35) or V2 `>=2.0.22 <3`
43
43
  (tested with 2.0.26)
44
44
  - `git` on `PATH`, used only for read-only Git enrichment. Without it, the reviewer gets no Git
45
45
  snapshot.
package/dist/explain.js CHANGED
@@ -1692,7 +1692,7 @@ async function runVersionChecks(pkg, binary) {
1692
1692
  name: "opencode",
1693
1693
  version: ocVersion ?? "(not found)",
1694
1694
  range: ocRange,
1695
- ok: ocVersion !== void 0 && (!pkg.engines.opencode || satisfies(ocVersion, pkg.engines.opencode)) && (!ocVersion.startsWith("2.") || satisfies(ocVersion, ">=2.0.3 <3"))
1695
+ ok: ocVersion !== void 0 && (!pkg.engines.opencode || satisfies(ocVersion, pkg.engines.opencode)) && (!ocVersion.startsWith("2.") || satisfies(ocVersion, ">=2.0.22 <3"))
1696
1696
  });
1697
1697
  return checks;
1698
1698
  }
@@ -8993,7 +8993,7 @@ function normalizeNative(v) {
8993
8993
  reviewID: "explain-dry-run",
8994
8994
  generation: "explain",
8995
8995
  directory: "",
8996
- hostVersion: "2.0.3"
8996
+ hostVersion: "2.0.22"
8997
8997
  }, v.input);
8998
8998
  }
8999
8999
  function legacyRequest(v, permission) {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { lstat, mkdir, mkdtemp, open, readFile, readlink, realpath, rm, writeFile } from "node:fs/promises";
1
+ import { lstat, mkdir, mkdtemp, open, readlink, realpath, rm, writeFile } from "node:fs/promises";
2
2
  import { homedir, tmpdir } from "node:os";
3
3
  import { basename, dirname, isAbsolute, join, normalize, resolve, sep } from "node:path";
4
- import { closeSync, constants, fchmodSync, fstatSync, openSync, readSync, rmSync, writeSync } from "node:fs";
4
+ import { closeSync, constants, fchmodSync, fstatSync, openSync, readSync, realpathSync, rmSync, writeSync } from "node:fs";
5
5
  import { createHash, randomBytes, randomUUID } from "node:crypto";
6
6
  import { execFile } from "node:child_process";
7
7
  import { promisify } from "node:util";
@@ -13029,9 +13029,13 @@ function exactKeys(value, expected) {
13029
13029
  function finiteProbability(value) {
13030
13030
  return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
13031
13031
  }
13032
+ /** How far below the most probable option a supporting choice may sit:
13033
+ * Jev's probabilities are rounded to hundredths after it chooses. */
13034
+ const SUPPORTING_TIE_TOLERANCE = .02;
13032
13035
  /** The probabilities of a choice answer: exactly the options, each a
13033
- * probability, summing to 1 within 0.02, with `choice` the most probable. */
13034
- function choiceProbabilities(value, options, choice) {
13036
+ * probability, summing to 1 within 0.02, with `choice` at most
13037
+ * `tieTolerance` below the most probable option. */
13038
+ function choiceProbabilities(value, options, choice, tieTolerance = 0) {
13035
13039
  if (typeof value !== "object" || value === null) return;
13036
13040
  const probabilities = value;
13037
13041
  if (!exactKeys(probabilities, options)) return;
@@ -13039,15 +13043,15 @@ function choiceProbabilities(value, options, choice) {
13039
13043
  if (!values.every(finiteProbability)) return;
13040
13044
  const total = values.reduce((sum, probability) => sum + probability, 0);
13041
13045
  if (total < .98 || total > 1.02) return;
13042
- if (probabilities[choice] < Math.max(...values)) return;
13046
+ if (probabilities[choice] + tieTolerance + 1e-9 < Math.max(...values)) return;
13043
13047
  return probabilities;
13044
13048
  }
13045
- function parseChoice(value, options) {
13049
+ function parseChoice(value, options, tieTolerance = 0) {
13046
13050
  if (!isRecord(value)) return;
13047
13051
  const answer = value;
13048
13052
  if (answer.type !== "choice" || !options.includes(answer.choice)) return;
13049
13053
  if (!finiteProbability(answer.confidence)) return;
13050
- const probabilities = choiceProbabilities(answer.probabilities, options, answer.choice);
13054
+ const probabilities = choiceProbabilities(answer.probabilities, options, answer.choice, tieTolerance);
13051
13055
  if (probabilities === void 0) return;
13052
13056
  return {
13053
13057
  choice: answer.choice,
@@ -13124,11 +13128,11 @@ function parseSignals(answers) {
13124
13128
  /** Every answer parsed, or undefined when any choice or signal is invalid. */
13125
13129
  function parseAnswers(answers) {
13126
13130
  const outcome = parseChoice(answers.outcome, OUTCOMES);
13127
- const risk = parseChoice(answers.risk_level, RISKS);
13128
- const authorization = parseChoice(answers.user_authorization, AUTHORIZATIONS);
13129
- const alignment = parseChoice(answers.scope_alignment, ALIGNMENTS);
13130
- const completeness = parseChoice(answers.evidence_completeness, COMPLETENESS);
13131
- const basis = parseChoice(answers.primary_basis, SYSTEM_ONE_BASES);
13131
+ const risk = parseChoice(answers.risk_level, RISKS, SUPPORTING_TIE_TOLERANCE);
13132
+ const authorization = parseChoice(answers.user_authorization, AUTHORIZATIONS, SUPPORTING_TIE_TOLERANCE);
13133
+ const alignment = parseChoice(answers.scope_alignment, ALIGNMENTS, SUPPORTING_TIE_TOLERANCE);
13134
+ const completeness = parseChoice(answers.evidence_completeness, COMPLETENESS, SUPPORTING_TIE_TOLERANCE);
13135
+ const basis = parseChoice(answers.primary_basis, SYSTEM_ONE_BASES, SUPPORTING_TIE_TOLERANCE);
13132
13136
  if (!outcome || !risk || !authorization || !alignment || !completeness || !basis) return;
13133
13137
  const signals = parseSignals(answers);
13134
13138
  if (signals === void 0) return;
@@ -14393,7 +14397,7 @@ function supersedeOnReply(state, pending, event) {
14393
14397
  }
14394
14398
  //#endregion
14395
14399
  //#region package.json
14396
- var version = "3.1.0";
14400
+ var version = "3.2.0";
14397
14401
  //#endregion
14398
14402
  //#region src/core/review-audit-facts.ts
14399
14403
  function evidenceFields$1(evidence) {
@@ -17115,7 +17119,7 @@ function probeCapabilities(client) {
17115
17119
  * OpenCode V2 host versions accepted at setup. A host outside this range
17116
17120
  * fails setup loudly instead of running against an unknown contract.
17117
17121
  */
17118
- const SUPPORTED_V2_RANGE = ">=2.0.3 <3";
17122
+ const SUPPORTED_V2_RANGE = ">=2.0.22 <3";
17119
17123
  /**
17120
17124
  * Guard the legacy adapter against incompatible client shapes.
17121
17125
  *
@@ -17323,6 +17327,29 @@ async function registerReviewerHooks(ctx, sessions) {
17323
17327
  }
17324
17328
  }
17325
17329
  //#endregion
17330
+ //#region src/opencode/v2/isolated-contexts.ts
17331
+ const contexts = /* @__PURE__ */ new Map();
17332
+ /** Canonicalize a directory so the two spellings of a symlinked temp path agree. */
17333
+ function canonical(directory) {
17334
+ try {
17335
+ return realpathSync.native(resolve(directory));
17336
+ } catch {
17337
+ return resolve(directory);
17338
+ }
17339
+ }
17340
+ /** Remember the plugin ctx the isolation bootstrap activated with. */
17341
+ function rememberIsolatedContext(directory, ctx) {
17342
+ contexts.set(canonical(directory), ctx);
17343
+ }
17344
+ /** Forget it once the location is released. */
17345
+ function forgetIsolatedContext(directory) {
17346
+ contexts.delete(canonical(directory));
17347
+ }
17348
+ /** The ctx for an isolated location, or undefined before it activates. */
17349
+ function isolatedContext(directory) {
17350
+ return contexts.get(canonical(directory));
17351
+ }
17352
+ //#endregion
17326
17353
  //#region src/opencode/v2/isolated-location.ts
17327
17354
  const KEY = "opencode-permission-reviewer.isolated-activation";
17328
17355
  const symbol = Symbol.for(KEY);
@@ -17391,6 +17418,27 @@ async function createIsolatedLocation(activate) {
17391
17418
  }
17392
17419
  }
17393
17420
  //#endregion
17421
+ //#region src/opencode/v2/with-abort.ts
17422
+ /** Race a promise against a signal, so a call the host never settles cannot
17423
+ * wedge the location activation. */
17424
+ function withAbort(promise, signal) {
17425
+ return new Promise((resolve, reject) => {
17426
+ if (signal.aborted) {
17427
+ reject(signal.reason);
17428
+ return;
17429
+ }
17430
+ const onAbort = () => reject(signal.reason);
17431
+ signal.addEventListener("abort", onAbort, { once: true });
17432
+ promise.then((value) => {
17433
+ signal.removeEventListener("abort", onAbort);
17434
+ resolve(value);
17435
+ }, (error) => {
17436
+ signal.removeEventListener("abort", onAbort);
17437
+ reject(error);
17438
+ });
17439
+ });
17440
+ }
17441
+ //#endregion
17394
17442
  //#region src/opencode/v2/v2-isolation-activation.ts
17395
17443
  /** Whether a local plugin entry is this attempt's bootstrap, by ID or by its path. */
17396
17444
  function isBootstrap(plugin, root, pluginID) {
@@ -17430,7 +17478,7 @@ function pollDelay(signal) {
17430
17478
  async function waitForIsolationActive(client, directory, pluginID, signal) {
17431
17479
  const root = resolve(directory);
17432
17480
  for (;;) {
17433
- const entry = (await client.plugin.list({ location: { directory } }, { signal })).data.find((plugin) => isBootstrap(plugin, root, pluginID));
17481
+ const entry = (await withAbort(client.plugin.list({ location: { directory } }, { signal }), signal)).data.find((plugin) => isBootstrap(plugin, root, pluginID));
17434
17482
  if (entry !== void 0) {
17435
17483
  if (entry.state.status === "active") return;
17436
17484
  throw new Error(`Reviewer isolation failed to activate: ${entry.state.error}`);
@@ -17449,6 +17497,7 @@ async function openReviewerLocation(client, owner) {
17449
17497
  };
17450
17498
  const isolated = await createIsolatedLocation(async (context) => {
17451
17499
  if (owner.closing()) return async () => {};
17500
+ rememberIsolatedContext(context.location.directory, context);
17452
17501
  const cleanup = await owner.register(context);
17453
17502
  const registration = async () => {
17454
17503
  if (!registrations.delete(registration)) return;
@@ -17460,22 +17509,37 @@ async function openReviewerLocation(client, owner) {
17460
17509
  });
17461
17510
  try {
17462
17511
  const signal = AbortSignal.any([owner.signal, AbortSignal.timeout(15e3)]);
17463
- await waitForIsolationActive(client, isolated.directory, isolated.pluginID, signal);
17464
- if (registrations.size === 0) throw new Error("Reviewer isolation hooks did not activate");
17512
+ const touch = await withAbort(client.mcp.list({ location: { directory: isolated.directory } }, { signal }), signal).then(() => void 0, (error) => error);
17513
+ try {
17514
+ await waitForIsolationActive(client, isolated.directory, isolated.pluginID, signal);
17515
+ if (registrations.size === 0) throw new Error("Reviewer isolation hooks did not activate");
17516
+ } catch (error) {
17517
+ if (touch !== void 0 && error instanceof Error && error.cause === void 0 && error !== touch) throw new Error(error.message, { cause: touch });
17518
+ throw error;
17519
+ }
17465
17520
  return {
17466
17521
  directory: isolated.directory,
17467
17522
  dispose,
17468
- release: isolated.release
17523
+ release: () => {
17524
+ forgetIsolatedContext(isolated.directory);
17525
+ isolated.release();
17526
+ }
17469
17527
  };
17470
17528
  } catch (error) {
17471
17529
  await dispose().catch(() => {});
17530
+ forgetIsolatedContext(isolated.directory);
17472
17531
  isolated.release();
17473
17532
  throw error;
17474
17533
  }
17475
17534
  }
17476
17535
  //#endregion
17477
17536
  //#region src/opencode/v2/v2-review-cleanup.ts
17478
- const isSessionNotFound = (error) => error?._tag === "SessionNotFoundError";
17537
+ /** The HTTP client and the in-process plugin adapter tag a missing session
17538
+ * differently: `SessionNotFoundError` vs `Session.NotFoundError`. */
17539
+ const isSessionNotFound = (error) => {
17540
+ const tag = error?._tag;
17541
+ return tag === "SessionNotFoundError" || tag === "Session.NotFoundError";
17542
+ };
17479
17543
  /** Interrupt the session, then (unless retained) remove it and check it is gone. */
17480
17544
  async function cleanupPass(client, sessionID, config) {
17481
17545
  try {
@@ -17776,52 +17840,39 @@ const ReviewerRpc = {
17776
17840
  events: { "review.updated": { schema: { type: "object" } } }
17777
17841
  };
17778
17842
  //#endregion
17779
- //#region src/opencode/v2/service-registration.ts
17780
- function assertLiveProcess(pid) {
17781
- if (!Number.isSafeInteger(pid) || pid <= 0) throw new Error("Reviewer service registration contains an invalid process ID");
17782
- try {
17783
- process.kill(pid, 0);
17784
- } catch (error) {
17785
- if (error.code !== "EPERM") throw new Error("Reviewer service registration belongs to a process that is not running", { cause: error });
17786
- }
17787
- }
17788
- function registrationPath() {
17789
- return join(process.env.XDG_STATE_HOME ?? join(homedir(), ".local", "state"), "opencode", "service.json");
17790
- }
17791
- /** The registration text, or undefined when no service is registered. */
17792
- function readRegistration(path) {
17793
- return readFile(path, "utf8").catch((error) => {
17794
- if (error.code === "ENOENT") return void 0;
17795
- throw error;
17796
- });
17797
- }
17798
- function parseRegistration(text) {
17799
- let value;
17800
- try {
17801
- value = JSON.parse(text);
17802
- } catch {
17803
- throw new Error("Reviewer service registration is not valid JSON");
17804
- }
17805
- if (typeof value !== "object" || value === null) throw new Error("Reviewer service registration is invalid");
17806
- return value;
17807
- }
17808
- function registeredService(info, version) {
17809
- if (info.version !== version) throw new Error("Reviewer service registration does not match this host version");
17810
- if (typeof info.url !== "string") throw new Error("Reviewer service registration does not contain a URL");
17811
- if (typeof info.password !== "string" || info.password.length === 0) throw new Error("Reviewer service registration does not contain authentication");
17812
- assertLiveProcess(info.pid);
17843
+ //#region src/opencode/v2/in-process-host.ts
17844
+ /** A V2 host backed by this plugin's context. Model and plugin inventories
17845
+ * come from the isolated location's own context, since the plugin context
17846
+ * lists them only for its own location. */
17847
+ function createInProcessHost(ctx) {
17813
17848
  return {
17814
- url: info.url,
17815
- password: info.password
17849
+ session: {
17850
+ create: (input) => ctx.session.create(input),
17851
+ get: (input) => ctx.session.get(input),
17852
+ context: (input) => ctx.session.context(input),
17853
+ prompt: (input) => ctx.session.prompt(input),
17854
+ wait: (input) => ctx.session.wait(input),
17855
+ interrupt: (input) => ctx.session.interrupt(input),
17856
+ remove: (input) => ctx.session.remove(input)
17857
+ },
17858
+ mcp: { list: (input) => ctx.mcp.list(input) },
17859
+ model: { list: async (input) => {
17860
+ if (!input?.location?.directory) throw new Error("Reviewer host call requires the isolated location");
17861
+ const isolated = isolatedContext(input.location.directory);
17862
+ if (!isolated) throw new Error("Reviewer isolated location is not active");
17863
+ return isolated.model.list();
17864
+ } },
17865
+ plugin: { list: async (input) => {
17866
+ if (!input?.location?.directory) throw new Error("Reviewer host call requires the isolated location");
17867
+ const isolated = isolatedContext(input.location.directory);
17868
+ if (!isolated) return {
17869
+ location: { directory: ctx.location.directory },
17870
+ data: []
17871
+ };
17872
+ return isolated.plugin.list();
17873
+ } }
17816
17874
  };
17817
17875
  }
17818
- /** The registered service for this host version with its URL as written, or
17819
- * undefined when no service is registered. */
17820
- async function readRegisteredService(version) {
17821
- const text = await readRegistration(registrationPath());
17822
- if (text === void 0) return void 0;
17823
- return registeredService(parseRegistration(text), version);
17824
- }
17825
17876
  //#endregion
17826
17877
  //#region src/opencode/v2/connection.ts
17827
17878
  const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
@@ -17856,18 +17907,6 @@ function hostCompatibleFetch(delegate = globalThis.fetch) {
17856
17907
  return waitWithLegacyRoute(delegate, input, init, url, session[1]);
17857
17908
  });
17858
17909
  }
17859
- /** The registered service, accepted only on a loopback origin. */
17860
- async function registeredLoopbackService(version) {
17861
- const service = await readRegisteredService(version);
17862
- if (!service) return void 0;
17863
- const endpoint = validateHostEndpoint(service.url);
17864
- if (!LOOPBACK_HOSTS.has(endpoint.hostname)) throw new Error("Reviewer registered service must use a loopback address");
17865
- if (endpoint.pathname !== "/" || endpoint.search || endpoint.hash) throw new Error("Reviewer registered service URL must be a loopback origin");
17866
- return {
17867
- url: endpoint.href,
17868
- password: service.password
17869
- };
17870
- }
17871
17910
  function makeClient(endpoint) {
17872
17911
  return OpenCode.make({
17873
17912
  baseUrl: endpoint.url,
@@ -17875,29 +17914,31 @@ function makeClient(endpoint) {
17875
17914
  fetch: hostCompatibleFetch()
17876
17915
  });
17877
17916
  }
17878
- /** Discover without starting a host; prove identity before accessing sessions. */
17879
- async function connectV2Host(directory, identity, version, signal) {
17917
+ /** The explicit server named by OPENCODE_PERMISSION_REVIEWER_HOST_URL; guards
17918
+ * misuse when reached without the URL. */
17919
+ async function connectV2Host(directory, identity, _version, signal) {
17880
17920
  const url = process.env.OPENCODE_PERMISSION_REVIEWER_HOST_URL;
17881
- let client;
17882
- if (url !== void 0) {
17883
- const endpoint = validateHostEndpoint(url);
17884
- const password = process.env.OPENCODE_PASSWORD ?? process.env.OPENCODE_SERVER_PASSWORD;
17885
- if (!password) throw new Error("Reviewer explicit host connection requires OPENCODE_PASSWORD");
17886
- client = makeClient({
17887
- url: endpoint.href,
17888
- password
17889
- });
17890
- } else {
17891
- const endpoint = await registeredLoopbackService(version);
17892
- if (!endpoint) throw new Error("Reviewer host connection unavailable: use the registered service or configure OPENCODE_PERMISSION_REVIEWER_HOST_URL and OPENCODE_PASSWORD");
17893
- client = makeClient(endpoint);
17894
- }
17921
+ if (url === void 0) throw new Error("Reviewer explicit host connection requires OPENCODE_PERMISSION_REVIEWER_HOST_URL");
17922
+ const endpoint = validateHostEndpoint(url);
17923
+ const source = `${endpoint.href} from OPENCODE_PERMISSION_REVIEWER_HOST_URL`;
17924
+ const password = process.env.OPENCODE_PASSWORD ?? process.env.OPENCODE_SERVER_PASSWORD;
17925
+ if (!password) throw new Error("Reviewer explicit host connection requires OPENCODE_PASSWORD");
17926
+ const client = makeClient({
17927
+ url: endpoint.href,
17928
+ password
17929
+ });
17895
17930
  if (await client.rpc(ReviewerRpc).identity({}, {
17896
17931
  location: { directory },
17897
17932
  signal
17898
- }) !== identity) throw new Error("Reviewer connection does not belong to this host generation");
17933
+ }) !== identity) throw new Error(`Reviewer connection does not belong to this host generation: ${source} is a different OpenCode server than the one running this plugin. Check that OPENCODE_PERMISSION_REVIEWER_HOST_URL names this server, or unset it to review through the server running this plugin`);
17899
17934
  return client;
17900
17935
  }
17936
+ /** The host a review runs against: the explicit server named by
17937
+ * OPENCODE_PERMISSION_REVIEWER_HOST_URL, else this plugin's own context. */
17938
+ async function resolveV2Host(ctx, directory, identity, version, signal) {
17939
+ if (process.env.OPENCODE_PERMISSION_REVIEWER_HOST_URL !== void 0) return connectV2Host(directory, identity, version, signal);
17940
+ return createInProcessHost(ctx);
17941
+ }
17901
17942
  //#endregion
17902
17943
  //#region src/opencode/v2/server-events.ts
17903
17944
  function toolKey(sessionID, messageID, id) {
@@ -18417,7 +18458,7 @@ async function runReview(server, run) {
18417
18458
  timeoutMs: run.budget
18418
18459
  }));
18419
18460
  if ((await attempt.wait(server.ctx.session.get({ sessionID: input.sessionID }))).location.directory !== server.directory) throw new Error("Permission belongs to another location");
18420
- const client = await attempt.wait(server.services.connect(server.directory, server.identity, server.ctx.app.version, attempt.signal)).catch((error) => {
18461
+ const client = await attempt.wait(server.services.connect(server.ctx, server.directory, server.identity, server.ctx.app.version, attempt.signal)).catch((error) => {
18421
18462
  server.connectionState = "failed";
18422
18463
  throw error;
18423
18464
  });
@@ -18653,13 +18694,13 @@ function createServerState(ctx, services) {
18653
18694
  async function setup(ctx) {
18654
18695
  return setupWithServices(ctx, {
18655
18696
  loadConfig: loadResolvedConfig,
18656
- connect: connectV2Host,
18697
+ connect: resolveV2Host,
18657
18698
  createBackend: createV2ReviewerBackend
18658
18699
  });
18659
18700
  }
18660
18701
  /** Host effects are injectable without changing the plugin entry contract. */
18661
18702
  async function setupWithServices(ctx, services) {
18662
- if (!satisfies(ctx.app.version, ">=2.0.3 <3")) throw new Error(`Unsupported OpenCode V2 host ${ctx.app.version}; supported range is ${SUPPORTED_V2_RANGE}`);
18703
+ if (!satisfies(ctx.app.version, ">=2.0.22 <3")) throw new Error(`Unsupported OpenCode V2 host ${ctx.app.version}; supported range is ${SUPPORTED_V2_RANGE}`);
18663
18704
  const server = await registerStatusRpc(createServerState(ctx, services));
18664
18705
  await registerToolHooks(server);
18665
18706
  const eventTask = watchHostEvents(server);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noppu-labs/opencode-permission-reviewer",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Policy-aware permission reviewer for OpenCode V1 and V2",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -73,11 +73,11 @@
73
73
  ],
74
74
  "engines": {
75
75
  "bun": ">=1.3.0",
76
- "opencode": ">=1.18.29 <2 || >=2.0.3 <3"
76
+ "opencode": ">=1.18.29 <2 || >=2.0.22 <3"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "@opencode-ai/plugin": ">=1.18.29 <2",
80
- "@opencode/plugin": ">=2.0.3 <3"
80
+ "@opencode/plugin": ">=2.0.22 <3"
81
81
  },
82
82
  "peerDependenciesMeta": {
83
83
  "@opencode-ai/plugin": {
@@ -91,7 +91,7 @@
91
91
  "@biomejs/biome": "2.5.15",
92
92
  "@opencode-ai/plugin": "1.19.3",
93
93
  "@opencode-ai/sdk": "1.19.3",
94
- "@opencode/plugin": "2.1.1",
94
+ "@opencode/plugin": "2.1.2",
95
95
  "@types/bun": "^1.3.0",
96
96
  "@types/semver": "7.8.0",
97
97
  "fta-cli": "3.1.0",
@@ -100,7 +100,9 @@
100
100
  "typescript": "7.0.2"
101
101
  },
102
102
  "overrides": {
103
- "@babel/core": "7.29.7"
103
+ "@babel/core": "7.29.7",
104
+ "ip-address": "10.7.4",
105
+ "toml": "5.0.1"
104
106
  },
105
107
  "scripts": {
106
108
  "lint": "biome check --error-on-warnings .",
@@ -120,7 +122,7 @@
120
122
  },
121
123
  "dependencies": {
122
124
  "@typesafe-ai/sdk": "0.6.0",
123
- "@opencode/client": "2.1.1",
125
+ "@opencode/client": "2.1.2",
124
126
  "jsonc-parser": "3.3.1",
125
127
  "semver": "7.8.5",
126
128
  "@opentui/core": "0.5.11",