@noppu-labs/opencode-permission-reviewer 3.2.3 → 3.3.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/dist/rpc.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/modules/status/models/rpc.d.ts
2
1
  /** Portable, read-only protocol. No UI message can approve a permission. */
3
2
  export declare const ReviewerRpc: {
4
3
  readonly id: "opencode-permission-reviewer";
@@ -38,5 +37,4 @@ export declare const ReviewerRpc: {
38
37
  };
39
38
  };
40
39
  };
41
- };
42
- //#endregion
40
+ };
package/dist/rpc.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/modules/status/models/rpc.ts
1
+ // src/modules/status/models/rpc.ts
2
2
  /** Portable, read-only protocol. No UI message can approve a permission. */
3
3
  const ReviewerRpc = {
4
4
  id: "opencode-permission-reviewer",
@@ -27,5 +27,4 @@ const ReviewerRpc = {
27
27
  },
28
28
  events: { "review.updated": { schema: { type: "object" } } }
29
29
  };
30
- //#endregion
31
30
  export { ReviewerRpc };
@@ -0,0 +1,44 @@
1
+ // Generated by scripts/openrouter-decision-models.ts. Edit only `benchmarked` and `incompatible` by hand.
2
+ export interface OpenRouterDecisionModels {
3
+ readonly models: Readonly<Record<string, { readonly benchmarked: boolean }>>;
4
+ readonly incompatible: Readonly<Record<string, string>>;
5
+ }
6
+
7
+ // biome-ignore lint/nursery/useExplicitType: `as const satisfies` keeps the literal ids; an annotation would widen them
8
+ export const OPENROUTER_DECISION_MODELS = {
9
+ models: {
10
+ "cloudflare/clef": { benchmarked: false },
11
+ "cloudflare/clef-flash": { benchmarked: false },
12
+ "cloudflare/clef-omni": { benchmarked: false },
13
+ "inception/mercury-decide": { benchmarked: false },
14
+ "jaredpalmer/kev-4b": { benchmarked: false },
15
+ "liquid/d1": { benchmarked: true },
16
+ "liquid/d1-ultra": { benchmarked: true },
17
+ "liquid/d1.1": { benchmarked: false },
18
+ "microsoft/microsoft-decision-1": { benchmarked: false },
19
+ "nace-ai/drex-max": { benchmarked: false },
20
+ "nace-ai/drex-v1.5": { benchmarked: false },
21
+ "nace-ai/drex-v2.0": { benchmarked: false },
22
+ "openai/gpt-6-luna-decisions": { benchmarked: false },
23
+ "perplexity/pplx-decider-flash-v1.2": { benchmarked: false },
24
+ "perplexity/pplx-decider-v1.2": { benchmarked: false },
25
+ "respan/span-02": { benchmarked: false },
26
+ "togethercomputer/tev1-4b-experimental": { benchmarked: false },
27
+ "typesafe/jev-1.13": { benchmarked: true },
28
+ "typesafe/jev-1.14": { benchmarked: true },
29
+ "upstage/solar-decide": { benchmarked: false },
30
+ "upstage/solar-decide-flash": { benchmarked: false },
31
+ "~liquid/d1-latest": { benchmarked: false },
32
+ "~liquid/d1-ultra-latest": { benchmarked: false },
33
+ "~perplexity/pplx-decider-flash-latest": { benchmarked: false },
34
+ "~perplexity/pplx-decider-latest": { benchmarked: false },
35
+ "~typesafe/jev-latest": { benchmarked: false },
36
+ },
37
+ incompatible: {
38
+ "respan/span-01": "requires a different state shape",
39
+ "respan/span-01-lite": "requires a different state shape",
40
+ "respan/span-01-lite:free": "requires a different state shape",
41
+ "scaledown/classify-1":
42
+ "accepts only plain-string instructions and criteria",
43
+ },
44
+ } as const satisfies OpenRouterDecisionModels;
@@ -0,0 +1,154 @@
1
+ // The providers that serve System One decision models: which model IDs each
2
+ // accepts, where its endpoint lives and which key it reads.
3
+ import {
4
+ OPENROUTER_DECISION_MODELS,
5
+ type OpenRouterDecisionModels,
6
+ } from "./openrouter-decision-models.ts";
7
+
8
+ export interface SystemOneProvider {
9
+ readonly keyEnv: string;
10
+ readonly baseURL?: string;
11
+ /** The key is never sent unless it matches; `message` is the thrown error, never the key. */
12
+ readonly keyShape?: { readonly pattern: RegExp; readonly message: string };
13
+ accepts(modelID: string): boolean;
14
+ acceptsResponse(modelID: string, returned: string): boolean;
15
+ /** Thrown by the invoker before any request. */
16
+ incompatibleReason?(modelID: string): string | undefined;
17
+ /** A non-blocking config warning. */
18
+ configWarning?(modelID: string): string | undefined;
19
+ }
20
+
21
+ const JEV_MODEL = /^jev(?:-|$)/;
22
+ const COMMANDCODE_JEV = "typesafe/jev";
23
+ const LIQUID_DECISION_MODELS: ReadonlySet<string> = new Set(["d1", "d1-ultra"]);
24
+
25
+ export const BASETEN_DECISION_MODELS: ReadonlySet<string> = new Set([
26
+ "decision-models/baseten-elephant-9b-latest",
27
+ "decision-models/baseten-mammoth-27b-latest",
28
+ ]);
29
+
30
+ const isJev = (modelID: string): boolean => JEV_MODEL.test(modelID);
31
+ const returnsJev = (_modelID: string, returned: string): boolean =>
32
+ isJev(returned);
33
+ const sameModel = (modelID: string, returned: string): boolean =>
34
+ returned === modelID;
35
+
36
+ // New Jev and d1 releases count before the weekly list picks them up. A `~`
37
+ // goes only with a `-latest` alias, the only form acceptsResponse can answer.
38
+ const OPENROUTER_FAMILIES: readonly RegExp[] = [
39
+ /^(?:typesafe\/jev-\d[a-z0-9.-]*(?<!-latest)|~typesafe\/jev-latest)$/,
40
+ /^(?:liquid\/d1(?:[-.][a-z0-9.-]*)?(?<!-latest)|~liquid\/d1(?:[-.][a-z0-9.-]*)?-latest)$/,
41
+ ];
42
+ const OPENROUTER_ROUTING_SUFFIX = /:[a-z0-9-]+$/;
43
+ const OPENROUTER_ALIAS = /^~(.+)-latest$/;
44
+
45
+ const escapeRegExp = (value: string): string =>
46
+ value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
47
+
48
+ const OPENROUTER_MODELS: OpenRouterDecisionModels["models"] =
49
+ OPENROUTER_DECISION_MODELS.models;
50
+ const OPENROUTER_INCOMPATIBLE: OpenRouterDecisionModels["incompatible"] =
51
+ OPENROUTER_DECISION_MODELS.incompatible;
52
+
53
+ // The exact id first, so an id listed with its own tag keeps its entry.
54
+ const withoutRoutingSuffix = (modelID: string): readonly string[] => {
55
+ const stripped = modelID.replace(OPENROUTER_ROUTING_SUFFIX, "");
56
+ return stripped === modelID ? [modelID] : [modelID, stripped];
57
+ };
58
+
59
+ const openRouterIncompatibleReason = (modelID: string): string | undefined => {
60
+ for (const id of withoutRoutingSuffix(modelID))
61
+ if (Object.hasOwn(OPENROUTER_INCOMPATIBLE, id))
62
+ return OPENROUTER_INCOMPATIBLE[id];
63
+ return;
64
+ };
65
+
66
+ const openRouterConfigWarning = (modelID: string): string | undefined => {
67
+ const reason = openRouterIncompatibleReason(modelID);
68
+ if (reason !== undefined)
69
+ return `openrouter/${modelID} is known to reject the reviewer's request (${reason}); every review will fail`;
70
+ const listed = withoutRoutingSuffix(modelID).find((id) =>
71
+ Object.hasOwn(OPENROUTER_MODELS, id),
72
+ );
73
+ if (listed !== undefined && OPENROUTER_MODELS[listed]?.benchmarked === true)
74
+ return;
75
+ return `openrouter/${modelID} has not been benchmarked as a reviewer; see REVIEWER-MODELS.md`;
76
+ };
77
+
78
+ const openRouterAccepts = (modelID: string): boolean =>
79
+ openRouterIncompatibleReason(modelID) !== undefined ||
80
+ withoutRoutingSuffix(modelID).some(
81
+ (id) =>
82
+ Object.hasOwn(OPENROUTER_DECISION_MODELS.models, id) ||
83
+ OPENROUTER_FAMILIES.some((family) => family.test(id)),
84
+ );
85
+
86
+ // OpenRouter answers with the dated canonical slug, and an alias with the
87
+ // slug of whichever release it points at.
88
+ const openRouterAcceptsResponse = (
89
+ modelID: string,
90
+ returned: string,
91
+ ): boolean => {
92
+ const base = modelID.replace(OPENROUTER_ROUTING_SUFFIX, "");
93
+ const alias = OPENROUTER_ALIAS.exec(base)?.[1];
94
+ if (alias !== undefined)
95
+ return new RegExp(`^${escapeRegExp(alias)}(?:$|[-.])`).test(returned);
96
+ return (
97
+ returned === base ||
98
+ new RegExp(`^${escapeRegExp(base)}-\\d{8}$`).test(returned)
99
+ );
100
+ };
101
+
102
+ export const SYSTEM_ONE_PROVIDERS: Readonly<Record<string, SystemOneProvider>> =
103
+ {
104
+ opencode: {
105
+ keyEnv: "OPENCODE_API_KEY",
106
+ baseURL: "https://opencode.ai/zen",
107
+ accepts: isJev,
108
+ acceptsResponse: returnsJev,
109
+ },
110
+ "typesafe-ai": {
111
+ keyEnv: "TYPESAFE_API_KEY",
112
+ accepts: isJev,
113
+ acceptsResponse: returnsJev,
114
+ },
115
+ commandcode: {
116
+ keyEnv: "CMD_API_KEY",
117
+ baseURL: "https://api.commandcode.ai/provider",
118
+ accepts: (modelID: string): boolean => modelID === COMMANDCODE_JEV,
119
+ acceptsResponse: (_modelID: string, returned: string): boolean =>
120
+ returned === COMMANDCODE_JEV,
121
+ },
122
+ "liquid-ai": {
123
+ keyEnv: "LIQUID_API_KEY",
124
+ baseURL: "https://api.liquid.ai/decisions",
125
+ keyShape: {
126
+ pattern: /^liquid_[A-Za-z0-9]{32,}$/,
127
+ message:
128
+ 'LIQUID_API_KEY is not a Liquid AI key (expected the "liquid_" prefix)',
129
+ },
130
+ accepts: (modelID: string): boolean =>
131
+ LIQUID_DECISION_MODELS.has(modelID),
132
+ acceptsResponse: sameModel,
133
+ },
134
+ baseten: {
135
+ keyEnv: "BASETEN_API_KEY",
136
+ baseURL: "https://inference.baseten.co",
137
+ accepts: (modelID: string): boolean =>
138
+ BASETEN_DECISION_MODELS.has(modelID),
139
+ acceptsResponse: sameModel,
140
+ },
141
+ openrouter: {
142
+ keyEnv: "OPENROUTER_API_KEY",
143
+ baseURL: "https://openrouter.ai/api",
144
+ keyShape: {
145
+ pattern: /^sk-or-v1-[0-9a-f]{64}$/,
146
+ message:
147
+ 'OPENROUTER_API_KEY is not an OpenRouter key (expected the "sk-or-v1-" prefix)',
148
+ },
149
+ accepts: openRouterAccepts,
150
+ acceptsResponse: openRouterAcceptsResponse,
151
+ incompatibleReason: openRouterIncompatibleReason,
152
+ configWarning: openRouterConfigWarning,
153
+ },
154
+ };
@@ -4,11 +4,17 @@ import type {
4
4
  } from "../../../kernel/reviewer-config.ts";
5
5
  import { nonEmptyStringOr } from "../models/config-fields.ts";
6
6
  import { boundedInteger } from "../models/config-knobs.ts";
7
+ import {
8
+ SYSTEM_ONE_PROVIDERS,
9
+ type SystemOneProvider,
10
+ } from "../models/system-one-providers.ts";
7
11
 
8
- export function splitModel(model: string): {
9
- providerID: string;
10
- modelID: string;
11
- } {
12
+ export interface ModelRef {
13
+ readonly providerID: string;
14
+ readonly modelID: string;
15
+ }
16
+
17
+ export function splitModel(model: string): ModelRef {
12
18
  const slash = model.indexOf("/");
13
19
  if (slash <= 0 || slash === model.length - 1) {
14
20
  throw new Error(
@@ -21,20 +27,24 @@ export function splitModel(model: string): {
21
27
  };
22
28
  }
23
29
 
24
- export function isSystemOneReviewerModel(model: string): boolean {
25
- let parsed: { providerID: string; modelID: string };
30
+ export function systemOneProviderFor(
31
+ model: string,
32
+ ): (ModelRef & { readonly provider: SystemOneProvider }) | undefined {
33
+ let parsed: ModelRef;
26
34
  try {
27
35
  parsed = splitModel(model);
28
36
  } catch {
29
- return false;
37
+ return;
30
38
  }
31
- // Jev uses the typed System One API rather than a chat-session transport.
32
- return (
33
- ((parsed.providerID === "opencode" ||
34
- parsed.providerID === "typesafe-ai") &&
35
- /^jev(?:-|$)/.test(parsed.modelID)) ||
36
- (parsed.providerID === "commandcode" && parsed.modelID === "typesafe/jev")
37
- );
39
+ if (!Object.hasOwn(SYSTEM_ONE_PROVIDERS, parsed.providerID)) return;
40
+ const provider = SYSTEM_ONE_PROVIDERS[parsed.providerID];
41
+ if (!provider?.accepts(parsed.modelID)) return;
42
+ return { provider, ...parsed };
43
+ }
44
+
45
+ export function isSystemOneReviewerModel(model: string): boolean {
46
+ // System One models use the typed System One API rather than a chat-session transport.
47
+ return systemOneProviderFor(model) !== undefined;
38
48
  }
39
49
 
40
50
  export function isProviderModelId(value: unknown): value is string {
@@ -1,5 +1,8 @@
1
1
  import type { ReviewerConfig } from "../../../kernel/reviewer-config.ts";
2
- import { isSystemOneReviewerModel } from "./reviewer-model.ts";
2
+ import {
3
+ isSystemOneReviewerModel,
4
+ systemOneProviderFor,
5
+ } from "./reviewer-model.ts";
3
6
 
4
7
  /** The least review time a hand-off needs; with less the request escalates. */
5
8
  export const HANDOFF_BUDGET_FLOOR_MS = 15_000;
@@ -38,15 +41,15 @@ export function systemOneRoutingWarnings(config: ReviewerConfig): string[] {
38
41
  if (config.systemOneEscalation === "reasoning-first") {
39
42
  warnings.push(
40
43
  cause === "not-jev"
41
- ? 'systemOneEscalation "reasoning-first" is inactive: the reviewer model is not Jev'
42
- : 'systemOneEscalation "reasoning-first" is inactive: no escalationReviewer is configured; Jev escalations still go to you',
44
+ ? 'systemOneEscalation "reasoning-first" is inactive: the reviewer model is not a System One model'
45
+ : 'systemOneEscalation "reasoning-first" is inactive: no escalationReviewer is configured; System One escalations still go to you',
43
46
  );
44
47
  }
45
48
  if (config.systemOneDenialReview) {
46
49
  warnings.push(
47
50
  cause === "not-jev"
48
- ? "systemOneDenialReview is inactive: the reviewer model is not Jev"
49
- : "systemOneDenialReview is inactive: no escalationReviewer is configured; Jev denials stay final",
51
+ ? "systemOneDenialReview is inactive: the reviewer model is not a System One model"
52
+ : "systemOneDenialReview is inactive: no escalationReviewer is configured; System One denials stay final",
50
53
  );
51
54
  }
52
55
  return warnings;
@@ -63,6 +66,13 @@ function budgetFloorWarnings(config: ReviewerConfig): string[] {
63
66
  ];
64
67
  }
65
68
 
69
+ /** System One is never the escalation reviewer, so only `model` is checked. */
70
+ export function systemOneModelWarnings(config: ReviewerConfig): string[] {
71
+ const target = systemOneProviderFor(config.model);
72
+ const warning = target?.provider.configWarning?.(target.modelID);
73
+ return warning === undefined ? [] : [warning];
74
+ }
75
+
66
76
  const PREVIEW_CHARS = 80;
67
77
 
68
78
  /** A warning names the value; it does not reproduce it. */
@@ -102,6 +112,7 @@ export function withSystemOneRoutingWarnings(
102
112
  const warnings = [
103
113
  ...invalidValueWarnings(config, source),
104
114
  ...systemOneRoutingWarnings(config),
115
+ ...systemOneModelWarnings(config),
105
116
  ...budgetFloorWarnings(config),
106
117
  ];
107
118
  return warnings.length === 0
@@ -1,6 +1,13 @@
1
1
  // Ships to the TUI (the action fit) and runs on the server (the bounded action
2
2
  // and segment texts), so it must not import a server-only module.
3
3
 
4
+ import {
5
+ codePointUnits,
6
+ type TextUnit,
7
+ type UnitSplitter,
8
+ unitsColumns,
9
+ } from "../../../utils/text-units.ts";
10
+
4
11
  export const ELISION: string = " ⋯ ";
5
12
  export const LINE_BREAK: string = "⏎";
6
13
  const ELISION_COLUMNS: number = Array.from(ELISION).length;
@@ -31,51 +38,85 @@ export function renderActionText(value: string): string {
31
38
  .trim();
32
39
  }
33
40
 
34
- /** Whether whole words of `kept` code points use at least half of `max`, so
41
+ /** Whether whole words of `kept` columns use at least half of `max`, so
35
42
  * the cut may fall between words rather than inside one. */
36
43
  const wordCut = (kept: number, max: number): boolean =>
37
44
  kept > 0 && kept * 2 >= max;
38
45
 
39
- /** The longest prefix of `text` made of whole words within `max` code
40
- * points; a hard cut at `max` when those words would use less than half of
41
- * it. Always a prefix of `text` (trailing spaces trimmed). */
42
- export function keepHead(text: string, max: number): string {
43
- const chars = Array.from(text);
44
- if (chars.length <= max) return text;
45
- let end = max;
46
- while (end > 0 && chars[end] !== " ") end -= 1;
47
- const head = wordCut(end, max)
48
- ? chars.slice(0, end)
49
- : chars.slice(0, Math.max(0, max));
50
- return head.join("").trimEnd();
46
+ const joinUnits = (units: readonly TextUnit[]): string =>
47
+ units.map((unit) => unit.text).join("");
48
+
49
+ /** The longest prefix of `text` made of whole words within `max` columns as
50
+ * `split` measures them (code points by default); a hard cut at `max` when
51
+ * those words would use less than half of it. Always a prefix of `text`
52
+ * (trailing spaces trimmed). */
53
+ export function keepHead(
54
+ text: string,
55
+ max: number,
56
+ split: UnitSplitter = codePointUnits,
57
+ ): string {
58
+ const units = split(text);
59
+ if (unitsColumns(units) <= max) return text;
60
+ let fit = 0;
61
+ let used = 0;
62
+ for (const unit of units) {
63
+ if (used + unit.columns > max) break;
64
+ used += unit.columns;
65
+ fit += 1;
66
+ }
67
+ let end = fit;
68
+ while (end > 0 && units[end]?.text !== " ") {
69
+ end -= 1;
70
+ used -= units[end]?.columns ?? 0;
71
+ }
72
+ return joinUnits(units.slice(0, wordCut(used, max) ? end : fit)).trimEnd();
51
73
  }
52
74
 
53
- /** The longest suffix of `text` made of whole words within `max` code
54
- * points; a hard cut at `max` when those words would use less than half of
55
- * it. Always a suffix of `text` (leading spaces trimmed). */
56
- export function keepTail(text: string, max: number): string {
75
+ /** The longest suffix of `text` made of whole words within `max` columns as
76
+ * `split` measures them (code points by default); a hard cut at `max` when
77
+ * those words would use less than half of it. Always a suffix of `text`
78
+ * (leading spaces trimmed). */
79
+ export function keepTail(
80
+ text: string,
81
+ max: number,
82
+ split: UnitSplitter = codePointUnits,
83
+ ): string {
57
84
  if (max <= 0) return "";
58
- const chars = Array.from(text);
59
- if (chars.length <= max) return text;
60
- let start = chars.length - max;
61
- while (start < chars.length && chars[start - 1] !== " ") start += 1;
62
- const tail = wordCut(chars.length - start, max)
63
- ? chars.slice(start)
64
- : chars.slice(chars.length - max);
65
- return tail.join("").trimStart();
85
+ const units = split(text);
86
+ if (unitsColumns(units) <= max) return text;
87
+ let fitStart = units.length;
88
+ let used = 0;
89
+ while (fitStart > 0) {
90
+ const columns = units[fitStart - 1]?.columns ?? 0;
91
+ if (used + columns > max) break;
92
+ used += columns;
93
+ fitStart -= 1;
94
+ }
95
+ let start = fitStart;
96
+ while (start < units.length && units[start - 1]?.text !== " ") {
97
+ used -= units[start]?.columns ?? 0;
98
+ start += 1;
99
+ }
100
+ return joinUnits(
101
+ units.slice(wordCut(used, max) ? start : fitStart),
102
+ ).trimStart();
66
103
  }
67
104
 
68
- /** `text` split into a head and a tail that fit `max` code points together
69
- * with " ⋯ " between them, the head taking at most half; undefined when
70
- * `text` already fits. */
105
+ /** `text` split into a head and a tail that fit `max` columns as `split`
106
+ * measures them (code points by default) together with " ⋯ " between them,
107
+ * the head taking at most half; undefined when `text` already fits. */
71
108
  export function elideMiddle(
72
109
  text: string,
73
110
  max: number,
111
+ split: UnitSplitter = codePointUnits,
74
112
  ): { head: string; tail: string } | undefined {
75
- if (Array.from(text).length <= max) return undefined;
113
+ if (unitsColumns(split(text)) <= max) return undefined;
76
114
  const budget = Math.max(0, max - ELISION_COLUMNS);
77
- const head = keepHead(text, Math.ceil(budget / 2));
78
- return { head, tail: keepTail(text, budget - Array.from(head).length) };
115
+ const head = keepHead(text, Math.ceil(budget / 2), split);
116
+ return {
117
+ head,
118
+ tail: keepTail(text, budget - unitsColumns(split(head)), split),
119
+ };
79
120
  }
80
121
 
81
122
  /** `value` on one line with escapes and line-break markers applied and at most
@@ -4,14 +4,12 @@ import type {
4
4
  ActionSegment,
5
5
  ReviewUiStatus,
6
6
  } from "../modules/status/models/ui-protocol.ts";
7
- import {
8
- ELISION,
9
- elideMiddle,
10
- keepHead,
11
- keepTail,
12
- } from "../modules/status/services/ui-text-elide.ts";
7
+ import { ELISION } from "../modules/status/services/ui-text-elide.ts";
13
8
  import {
14
9
  type FitPart,
10
+ fitHead,
11
+ fitMiddle,
12
+ fitTail,
15
13
  merged,
16
14
  partsColumns,
17
15
  shown,
@@ -25,7 +23,8 @@ export interface ActionFitPart {
25
23
  }
26
24
 
27
25
  const ELLIPSIS = "⋯";
28
- /** Narrowest width that still shows a character on each side of " ⋯ ". */
26
+ /** Narrowest width that can show a narrow character on each side of " ⋯ ";
27
+ * wide characters need 7, and below that the tail is kept. */
29
28
  const MIN_ELIDED_COLUMNS = 5;
30
29
 
31
30
  /** Collapses line breaks and tabs so a value renders on one row. */
@@ -94,11 +93,11 @@ function cutMarker(hidden: number, columns: number): string {
94
93
  }
95
94
 
96
95
  const headOf = (parts: readonly FitPart[], max: number): FitPart[] =>
97
- sliceParts(parts, 0, textColumns(keepHead(shown(parts), max)));
96
+ sliceParts(parts, 0, textColumns(fitHead(shown(parts), max)));
98
97
 
99
98
  function tailOf(parts: readonly FitPart[], max: number): FitPart[] {
100
99
  const columns = partsColumns(parts);
101
- const tail = keepTail(shown(parts), max);
100
+ const tail = fitTail(shown(parts), max);
102
101
  return sliceParts(parts, columns - textColumns(tail), columns);
103
102
  }
104
103
 
@@ -132,7 +131,7 @@ function firstAndLast(
132
131
  }
133
132
 
134
133
  function headAndTail(action: string, columns: number): ActionFitPart[] {
135
- const parts = elideMiddle(singleLine(action), columns);
134
+ const parts = fitMiddle(singleLine(action), columns);
136
135
  if (parts === undefined)
137
136
  return merged([{ text: singleLine(action), muted: false }]);
138
137
  return merged([
@@ -13,18 +13,18 @@ const AFTER: Record<
13
13
  Exclude<HandoffTrigger, "jev-failure" | "jev-uncertain-deny">,
14
14
  string
15
15
  > = {
16
- "jev-escalate": "after Jev's escalation",
17
- "jev-uncertain-allow": "after Jev's uncertain approval",
18
- "jev-gate": "after a safety gate stopped Jev's approval",
19
- "jev-invalid": "after Jev's invalid response",
16
+ "jev-escalate": "after System One's escalation",
17
+ "jev-uncertain-allow": "after System One's uncertain approval",
18
+ "jev-gate": "after a safety gate stopped System One's approval",
19
+ "jev-invalid": "after System One's invalid response",
20
20
  };
21
21
 
22
22
  const CAUSE: Record<Exclude<HandoffTrigger, "jev-failure">, string> = {
23
- "jev-escalate": "Jev escalated",
24
- "jev-uncertain-allow": "Jev's approval was uncertain",
25
- "jev-gate": "a safety gate stopped Jev's approval",
26
- "jev-invalid": "Jev's response was invalid",
27
- "jev-uncertain-deny": "Jev's denial was uncertain",
23
+ "jev-escalate": "System One escalated",
24
+ "jev-uncertain-allow": "System One's approval was uncertain",
25
+ "jev-gate": "a safety gate stopped System One's approval",
26
+ "jev-invalid": "System One's response was invalid",
27
+ "jev-uncertain-deny": "System One's denial was uncertain",
28
28
  };
29
29
 
30
30
  /** Last path segment of a provider model id: "omniroute/auto/gpt-6-luna" -> "gpt-6-luna". */
@@ -42,16 +42,16 @@ export function modelLabel(model: string): string {
42
42
  }
43
43
 
44
44
  const jevFailed = (kind: string | undefined): string =>
45
- kind === undefined ? "Jev failed" : `Jev failed (${kind})`;
45
+ kind === undefined ? "System One failed" : `System One failed (${kind})`;
46
46
 
47
47
  /** A "denied" phase with `escalationDisposition: "deny"` is a fail-closed
48
48
  * escalation, not the reasoning reviewer's own block, so it does not confirm
49
49
  * Jev's denial. */
50
50
  function denialVerdict(status: PhraseSource): string {
51
- if (status.phase === "approved") return "overturned Jev's denial";
51
+ if (status.phase === "approved") return "overturned System One's denial";
52
52
  if (status.phase === "denied" && status.escalationDisposition !== "deny")
53
- return "confirmed Jev's denial";
54
- return "after Jev's uncertain denial";
53
+ return "confirmed System One's denial";
54
+ return "after System One's uncertain denial";
55
55
  }
56
56
 
57
57
  /** Undefined on `budget-exhausted` (the reasoning reviewer never ran) and on
@@ -87,11 +87,11 @@ export function attributionText(status: ReviewUiStatus): string | undefined {
87
87
  return model === "" ? undefined : model;
88
88
  }
89
89
 
90
- /** Why Jev handed off, for the budget toast ("Jev timed out"). */
90
+ /** Why System One handed off, for the budget toast ("System One timed out"). */
91
91
  export function handoffCause(handoff: HandoffInfo): string {
92
92
  if (handoff.trigger !== "jev-failure") return CAUSE[handoff.trigger];
93
93
  return handoff.failureKind === "timeout"
94
- ? "Jev timed out"
94
+ ? "System One timed out"
95
95
  : jevFailed(handoff.failureKind);
96
96
  }
97
97
 
@@ -2,6 +2,7 @@
2
2
  // TUI session, and a one-line sidebar summary while any remain. The same
3
3
  // `status` read also names the server's reasoning reviewer.
4
4
  import { asObjectLike } from "../utils/is-record.ts";
5
+ import { modelLabel } from "./attribution.ts";
5
6
 
6
7
  interface NoticeLists {
7
8
  configWarnings?: readonly string[] | undefined;
@@ -22,14 +23,29 @@ export interface SidebarLine {
22
23
  /** Keyed by the exact text `systemOneRoutingWarnings` emits; a reworded
23
24
  * warning falls back to its full text. */
24
25
  const SHORT_WARNINGS: Readonly<Record<string, string>> = {
25
- 'systemOneEscalation "reasoning-first" is inactive: no escalationReviewer is configured; Jev escalations still go to you':
26
+ 'systemOneEscalation "reasoning-first" is inactive: no escalationReviewer is configured; System One escalations still go to you':
26
27
  "reasoning-first inactive (no escalationReviewer)",
27
- 'systemOneEscalation "reasoning-first" is inactive: the reviewer model is not Jev':
28
- "reasoning-first inactive (model is not Jev)",
29
- "systemOneDenialReview is inactive: no escalationReviewer is configured; Jev denials stay final":
28
+ 'systemOneEscalation "reasoning-first" is inactive: the reviewer model is not a System One model':
29
+ "reasoning-first inactive (model is not System One)",
30
+ "systemOneDenialReview is inactive: no escalationReviewer is configured; System One denials stay final":
30
31
  "denial review inactive (no escalationReviewer)",
31
- "systemOneDenialReview is inactive: the reviewer model is not Jev":
32
- "denial review inactive (model is not Jev)",
32
+ "systemOneDenialReview is inactive: the reviewer model is not a System One model":
33
+ "denial review inactive (model is not System One)",
34
+ };
35
+
36
+ const UNBENCHMARKED = /^(\S+) has not been benchmarked as a reviewer/;
37
+ const INCOMPATIBLE = /^(\S+) is known to reject the reviewer's request/;
38
+
39
+ const shortWarning = (warning: string): string => {
40
+ const known = SHORT_WARNINGS[warning];
41
+ if (known !== undefined) return known;
42
+ const unbenchmarked = UNBENCHMARKED.exec(warning)?.[1];
43
+ if (unbenchmarked !== undefined)
44
+ return `${modelLabel(unbenchmarked)} not benchmarked`;
45
+ const incompatible = INCOMPATIBLE.exec(warning)?.[1];
46
+ if (incompatible !== undefined)
47
+ return `${modelLabel(incompatible)} is incompatible`;
48
+ return warning;
33
49
  };
34
50
 
35
51
  const strings = (value: unknown): string[] =>
@@ -65,7 +81,7 @@ export function sidebarLine(
65
81
  ): SidebarLine | undefined {
66
82
  const items = [
67
83
  ...degraded.map((reason) => `auto-approval disabled (${reason})`),
68
- ...warnings.map((warning) => SHORT_WARNINGS[warning] ?? warning),
84
+ ...warnings.map(shortWarning),
69
85
  ];
70
86
  const first = items[0];
71
87
  if (first === undefined) return;