@noppu-labs/opencode-permission-reviewer 3.2.2 → 3.3.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 +66 -1
- package/README.md +36 -31
- package/dist/explain.d.ts +1 -3
- package/dist/explain.js +305 -314
- package/dist/index.d.ts +0 -90
- package/dist/index.js +543 -687
- package/dist/rpc.d.ts +1 -3
- package/dist/rpc.js +1 -2
- package/dist/tui/modules/config/models/openrouter-decision-models.ts +44 -0
- package/dist/tui/modules/config/models/system-one-providers.ts +154 -0
- package/dist/tui/modules/config/services/reviewer-model.ts +24 -14
- package/dist/tui/modules/config/services/system-one-routing.ts +16 -5
- package/dist/tui/ui/attribution.ts +15 -15
- package/dist/tui/ui/config-notices.ts +23 -7
- package/dist/tui/ui/manual-toast.ts +4 -4
- package/{NOTICE → docs/NOTICE} +1 -1
- package/{SECURITY.md → docs/SECURITY.md} +4 -4
- package/package.json +31 -17
- /package/{LICENSE-APACHE → docs/LICENSE-APACHE} +0 -0
- /package/{MIGRATION.md → docs/MIGRATION.md} +0 -0
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
|
-
|
|
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
|
|
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
|
|
25
|
-
|
|
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
|
|
37
|
+
return;
|
|
30
38
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 {
|
|
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
|
|
42
|
-
: 'systemOneEscalation "reasoning-first" is inactive: no escalationReviewer is configured;
|
|
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
|
|
49
|
-
: "systemOneDenialReview is inactive: no escalationReviewer is configured;
|
|
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
|
|
@@ -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
|
|
17
|
-
"jev-uncertain-allow": "after
|
|
18
|
-
"jev-gate": "after a safety gate stopped
|
|
19
|
-
"jev-invalid": "after
|
|
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": "
|
|
24
|
-
"jev-uncertain-allow": "
|
|
25
|
-
"jev-gate": "a safety gate stopped
|
|
26
|
-
"jev-invalid": "
|
|
27
|
-
"jev-uncertain-deny": "
|
|
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 ? "
|
|
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
|
|
51
|
+
if (status.phase === "approved") return "overturned System One's denial";
|
|
52
52
|
if (status.phase === "denied" && status.escalationDisposition !== "deny")
|
|
53
|
-
return "confirmed
|
|
54
|
-
return "after
|
|
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
|
|
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
|
-
? "
|
|
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;
|
|
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
|
|
28
|
-
"reasoning-first inactive (model is not
|
|
29
|
-
"systemOneDenialReview is inactive: no escalationReviewer is configured;
|
|
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
|
|
32
|
-
"denial review inactive (model is not
|
|
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(
|
|
84
|
+
...warnings.map(shortWarning),
|
|
69
85
|
];
|
|
70
86
|
const first = items[0];
|
|
71
87
|
if (first === undefined) return;
|
|
@@ -54,14 +54,14 @@ function noTimeLeft(
|
|
|
54
54
|
const parts = reason === undefined ? null : BUDGET_REASON.exec(reason);
|
|
55
55
|
if (handoff !== undefined)
|
|
56
56
|
return withReason(
|
|
57
|
-
`${NO_TIME_LEAD} ${shortModelName(handoff.to) || GENERIC_REVIEWER} after
|
|
57
|
+
`${NO_TIME_LEAD} ${shortModelName(handoff.to) || GENERIC_REVIEWER} after System One (${handoffCause(handoff)}).`,
|
|
58
58
|
parts === null ? reason : parts[2],
|
|
59
59
|
);
|
|
60
60
|
if (reason === undefined)
|
|
61
|
-
return `${NO_TIME_LEAD} ${GENERIC_REVIEWER} after
|
|
61
|
+
return `${NO_TIME_LEAD} ${GENERIC_REVIEWER} after System One.`;
|
|
62
62
|
if (parts === null) return reason;
|
|
63
63
|
const name = shortModelName(reviewer ?? "") || GENERIC_REVIEWER;
|
|
64
|
-
return `${NO_TIME_LEAD} ${name} after
|
|
64
|
+
return `${NO_TIME_LEAD} ${name} after System One (${parts[1]}). ${parts[2]}`;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/** `fallback` stands in for a missing reason on a `reasoning-escalated` or
|
|
@@ -75,7 +75,7 @@ export function manualToast(
|
|
|
75
75
|
switch (status.resolution) {
|
|
76
76
|
case "reasoning-escalated":
|
|
77
77
|
return warning(
|
|
78
|
-
`${reasoningModel(status)} reviewed this after
|
|
78
|
+
`${reasoningModel(status)} reviewed this after System One; it needs your approval: ${status.reason ?? fallback}`,
|
|
79
79
|
);
|
|
80
80
|
case "reasoning-unavailable":
|
|
81
81
|
return unavailable(status);
|
package/{NOTICE → docs/NOTICE}
RENAMED
|
@@ -5,7 +5,7 @@ This project is a fork of warc0s/opencode-permission-reviewer
|
|
|
5
5
|
(https://github.com/warc0s/opencode-permission-reviewer), Copyright 2026 Warc0s,
|
|
6
6
|
licensed under the Apache License, Version 2.0 (see ./LICENSE-APACHE). Code from
|
|
7
7
|
that project remains under the Apache License, Version 2.0. Changes made in this
|
|
8
|
-
fork are licensed under the MIT License (see
|
|
8
|
+
fork are licensed under the MIT License (see ../LICENSE).
|
|
9
9
|
|
|
10
10
|
The reviewer policy in src/modules/context/services/prompt/policy.ts is adapted
|
|
11
11
|
from the OpenAI Codex Guardian auto-review policy and policy template:
|
|
@@ -18,10 +18,10 @@ The plugin approves or denies AI-agent actions on your behalf, so most security
|
|
|
18
18
|
where it approves something it should not. In scope:
|
|
19
19
|
|
|
20
20
|
- An automatic approval that breaks one of the deterministic invariants in
|
|
21
|
-
[docs/SAFETY.md](
|
|
21
|
+
[docs/SAFETY.md](SAFETY.md), such as approving an action the reviewer classified as
|
|
22
22
|
critical, or approving after a reviewer failure.
|
|
23
23
|
- Project or inline configuration that weakens trusted global settings (see the trust rules in
|
|
24
|
-
[docs/CONFIGURATION.md](
|
|
24
|
+
[docs/CONFIGURATION.md](CONFIGURATION.md)).
|
|
25
25
|
- The reviewer session gaining tools, MCP servers, or repository instructions.
|
|
26
26
|
- Credentials leaking into reviewer evidence, the audit log, or the TUI.
|
|
27
27
|
- The release pipeline: npm publishing, provenance, checksums, and the SBOM.
|
|
@@ -29,7 +29,7 @@ where it approves something it should not. In scope:
|
|
|
29
29
|
A reviewer model that misjudges an action's risk is a known limit of the design, not a
|
|
30
30
|
vulnerability on its own. The plugin checks a decision's consistency, not its semantic
|
|
31
31
|
correctness. Other plugins loaded into the same OpenCode host can also override its decisions.
|
|
32
|
-
[docs/SAFETY.md](
|
|
32
|
+
[docs/SAFETY.md](SAFETY.md) covers the threat model.
|
|
33
33
|
|
|
34
34
|
This project is a fork of
|
|
35
35
|
[warc0s/opencode-permission-reviewer](https://github.com/warc0s/opencode-permission-reviewer).
|
|
@@ -46,5 +46,5 @@ or `npm ci` (npm 8.15.0 or later), run this in the installing project:
|
|
|
46
46
|
npm audit signatures
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
[docs/SUPPLY-CHAIN.md](
|
|
49
|
+
[docs/SUPPLY-CHAIN.md](SUPPLY-CHAIN.md) describes what the package ships and the known
|
|
50
50
|
residual exposure in its dependency tree.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noppu-labs/opencode-permission-reviewer",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Policy-aware permission reviewer for OpenCode V1 and V2",
|
|
3
|
+
"version": "3.3.0",
|
|
4
|
+
"description": "Policy-aware AI permission reviewer for OpenCode V1 and V2: auto-approves routine agent tool calls, denies risky ones with feedback, and escalates the rest to you",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"tui.tsx",
|
|
39
39
|
"dist/",
|
|
40
40
|
"README.md",
|
|
41
|
-
"MIGRATION.md",
|
|
41
|
+
"docs/MIGRATION.md",
|
|
42
42
|
"CHANGELOG.md",
|
|
43
|
-
"NOTICE",
|
|
43
|
+
"docs/NOTICE",
|
|
44
44
|
"LICENSE",
|
|
45
|
-
"LICENSE-APACHE",
|
|
46
|
-
"SECURITY.md"
|
|
45
|
+
"docs/LICENSE-APACHE",
|
|
46
|
+
"docs/SECURITY.md"
|
|
47
47
|
],
|
|
48
48
|
"license": "MIT AND Apache-2.0",
|
|
49
49
|
"author": "cris005",
|
|
@@ -61,18 +61,31 @@
|
|
|
61
61
|
"keywords": [
|
|
62
62
|
"opencode",
|
|
63
63
|
"opencode-plugin",
|
|
64
|
+
"opencode-ai",
|
|
64
65
|
"ai-agent",
|
|
66
|
+
"coding-agent",
|
|
67
|
+
"ai-coding-assistant",
|
|
65
68
|
"agent-safety",
|
|
66
|
-
"
|
|
69
|
+
"ai-safety",
|
|
70
|
+
"guardrails",
|
|
71
|
+
"llm-guardrails",
|
|
72
|
+
"permissions",
|
|
67
73
|
"permission-management",
|
|
74
|
+
"auto-approval",
|
|
75
|
+
"auto-approve",
|
|
76
|
+
"tool-approval",
|
|
77
|
+
"human-in-the-loop",
|
|
78
|
+
"command-review",
|
|
79
|
+
"shell-safety",
|
|
80
|
+
"policy-as-code",
|
|
81
|
+
"security",
|
|
68
82
|
"llm",
|
|
69
83
|
"codex-guardian",
|
|
70
|
-
"policy-as-code",
|
|
71
84
|
"typescript",
|
|
72
85
|
"bun"
|
|
73
86
|
],
|
|
74
87
|
"engines": {
|
|
75
|
-
"bun": ">=1.3.
|
|
88
|
+
"bun": ">=1.3.14",
|
|
76
89
|
"opencode": ">=1.18.29 <2 || >=2.0.22 <3"
|
|
77
90
|
},
|
|
78
91
|
"peerDependencies": {
|
|
@@ -88,21 +101,22 @@
|
|
|
88
101
|
}
|
|
89
102
|
},
|
|
90
103
|
"devDependencies": {
|
|
91
|
-
"@biomejs/biome": "2.
|
|
104
|
+
"@biomejs/biome": "2.6.3",
|
|
92
105
|
"@opencode-ai/plugin": "1.19.4",
|
|
93
106
|
"@opencode-ai/sdk": "1.19.4",
|
|
94
|
-
"@opencode/plugin": "2.
|
|
107
|
+
"@opencode/plugin": "2.2.0",
|
|
95
108
|
"@types/bun": "^1.3.0",
|
|
96
109
|
"@types/semver": "7.8.0",
|
|
97
110
|
"fta-cli": "3.1.0",
|
|
98
|
-
"knip": "6.
|
|
99
|
-
"tsdown": "0.23.
|
|
111
|
+
"knip": "6.43.0",
|
|
112
|
+
"tsdown": "0.23.3",
|
|
100
113
|
"typescript": "7.0.2"
|
|
101
114
|
},
|
|
102
115
|
"overrides": {
|
|
103
116
|
"@babel/core": "7.29.7",
|
|
104
117
|
"ip-address": "10.7.4",
|
|
105
|
-
"toml": "5.0.1"
|
|
118
|
+
"toml": "5.0.1",
|
|
119
|
+
"zod": "4.6.7"
|
|
106
120
|
},
|
|
107
121
|
"scripts": {
|
|
108
122
|
"lint": "biome check --error-on-warnings .",
|
|
@@ -122,11 +136,11 @@
|
|
|
122
136
|
},
|
|
123
137
|
"dependencies": {
|
|
124
138
|
"@typesafe-ai/sdk": "0.6.0",
|
|
125
|
-
"@opencode/client": "2.
|
|
139
|
+
"@opencode/client": "2.2.0",
|
|
126
140
|
"jsonc-parser": "3.3.1",
|
|
127
141
|
"semver": "7.8.5",
|
|
128
|
-
"@opentui/core": "0.
|
|
129
|
-
"@opentui/solid": "0.
|
|
142
|
+
"@opentui/core": "0.7.0",
|
|
143
|
+
"@opentui/solid": "0.7.0",
|
|
130
144
|
"solid-js": "1.9.12",
|
|
131
145
|
"zod": "4.6.7"
|
|
132
146
|
}
|
|
File without changes
|
|
File without changes
|