@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/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
2
2
|
import { basename, dirname, isAbsolute, join, normalize, resolve, sep } from "node:path";
|
|
3
|
-
import { lstat, mkdir, mkdtemp, open, readlink, realpath, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { lstat, mkdir, mkdtemp, open, readlink, realpath, rm, stat, writeFile } from "node:fs/promises";
|
|
4
4
|
import { execFile } from "node:child_process";
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
6
|
import { closeSync, constants, fchmodSync, fstatSync, openSync, readSync, realpathSync, rmSync, writeSync } from "node:fs";
|
|
@@ -11,7 +11,7 @@ import { z } from "zod";
|
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
13
13
|
import { OpenCode } from "@opencode/client";
|
|
14
|
-
|
|
14
|
+
// \0rolldown/runtime.js
|
|
15
15
|
var __defProp = Object.defineProperty;
|
|
16
16
|
var __exportAll = (all, no_symbols) => {
|
|
17
17
|
let target = {};
|
|
@@ -22,8 +22,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
22
22
|
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
23
23
|
return target;
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
//#region src/utils/is-record.ts
|
|
25
|
+
// src/utils/is-record.ts
|
|
27
26
|
/** A non-null object that is not an array. */
|
|
28
27
|
function isRecord(value) {
|
|
29
28
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -32,8 +31,7 @@ function isRecord(value) {
|
|
|
32
31
|
function asObjectLike(value) {
|
|
33
32
|
return typeof value === "object" && value !== null ? value : void 0;
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
//#region src/adapters/opencode/event-normalizer.ts
|
|
34
|
+
// src/adapters/opencode/event-normalizer.ts
|
|
37
35
|
function strings(items) {
|
|
38
36
|
return items.filter((item) => typeof item === "string");
|
|
39
37
|
}
|
|
@@ -78,8 +76,7 @@ function extractPermissionRequest(event) {
|
|
|
78
76
|
...tool === void 0 ? {} : { tool }
|
|
79
77
|
};
|
|
80
78
|
}
|
|
81
|
-
|
|
82
|
-
//#region src/utils/with-timeout.ts
|
|
79
|
+
// src/utils/with-timeout.ts
|
|
83
80
|
function withTimeout(promise, timeoutMs) {
|
|
84
81
|
let timer;
|
|
85
82
|
return Promise.race([promise, new Promise((_resolve, reject) => {
|
|
@@ -88,8 +85,7 @@ function withTimeout(promise, timeoutMs) {
|
|
|
88
85
|
if (timer !== void 0) clearTimeout(timer);
|
|
89
86
|
});
|
|
90
87
|
}
|
|
91
|
-
|
|
92
|
-
//#region src/adapters/opencode/host-version.ts
|
|
88
|
+
// src/adapters/opencode/host-version.ts
|
|
93
89
|
/**
|
|
94
90
|
* Asks a V1 host for its version over the SDK client's raw HTTP client,
|
|
95
91
|
* bounded at 2 s; the promise settles to undefined on any failure. Returns
|
|
@@ -102,8 +98,7 @@ function probeHostVersion(client) {
|
|
|
102
98
|
signal: AbortSignal.timeout(2e3)
|
|
103
99
|
}), 2e3).then((response) => response.data?.version).catch(() => void 0) : void 0;
|
|
104
100
|
}
|
|
105
|
-
|
|
106
|
-
//#region src/utils/invariant.ts
|
|
101
|
+
// src/utils/invariant.ts
|
|
107
102
|
/** Assert a fact the surrounding code guarantees but the compiler cannot
|
|
108
103
|
* see, such as an index the loop bound keeps in range. A broken guarantee is
|
|
109
104
|
* a bug, so it throws.
|
|
@@ -112,12 +107,12 @@ function probeHostVersion(client) {
|
|
|
112
107
|
function invariant(condition, message) {
|
|
113
108
|
if (!condition) throw new Error(message);
|
|
114
109
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
//#endregion
|
|
119
|
-
//#region src/utils/redact.ts
|
|
110
|
+
// package.json
|
|
111
|
+
var version = "3.3.0";
|
|
112
|
+
// src/utils/redact.ts
|
|
120
113
|
const REDACT = (type) => `[REDACTED:${type}]`;
|
|
114
|
+
const OPENCODE_SESSION_KEY = /^(?:session[_-]?id|session|sid)$/i;
|
|
115
|
+
const OPENCODE_SESSION_ID = /^ses_[0-9a-f]{12}[A-Za-z0-9]{14}(?:[A-Za-z0-9]{6})?$/;
|
|
121
116
|
const RULES = [
|
|
122
117
|
{
|
|
123
118
|
re: /-----BEGIN (?:[A-Z ]*PRIVATE KEY(?: BLOCK)?)-----[\s\S]{0,8192}?-----END (?:[A-Z ]*PRIVATE KEY(?: BLOCK)?)-----/g,
|
|
@@ -139,6 +134,10 @@ const RULES = [
|
|
|
139
134
|
re: /\bgithub_pat_[A-Za-z0-9_]{22,251}\b/g,
|
|
140
135
|
replace: () => REDACT("github")
|
|
141
136
|
},
|
|
137
|
+
{
|
|
138
|
+
re: /\bsk-or-v1-[0-9a-f]{64}\b/g,
|
|
139
|
+
replace: () => REDACT("openrouter")
|
|
140
|
+
},
|
|
142
141
|
{
|
|
143
142
|
re: /\bsk-proj-[A-Za-z0-9_-]{20,}\b/g,
|
|
144
143
|
replace: () => REDACT("openai")
|
|
@@ -175,6 +174,10 @@ const RULES = [
|
|
|
175
174
|
re: /\b\d{8,12}:AA[A-Za-z0-9_-]{30,}\b/g,
|
|
176
175
|
replace: () => REDACT("telegram")
|
|
177
176
|
},
|
|
177
|
+
{
|
|
178
|
+
re: /\bliquid_[A-Za-z0-9]{32,}\b/g,
|
|
179
|
+
replace: () => REDACT("liquid")
|
|
180
|
+
},
|
|
178
181
|
{
|
|
179
182
|
re: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,
|
|
180
183
|
replace: () => REDACT("jwt")
|
|
@@ -204,7 +207,7 @@ const RULES = [
|
|
|
204
207
|
},
|
|
205
208
|
{
|
|
206
209
|
re: /(^|_|[^A-Za-z0-9_])(api[_-]?key|access[_-]?token|secret[_-]?key|client[_-]?secret|secret|password|passwd|token|cookie|csrf[_-]?token|session[_-]?id|sessionid|session|sid|private[_-]?key|passphrase|credentials?)(["']?\s*[:=]\s*["']?)(?!\[REDACTED)([^$`{}()\s"'#[\]]{8,})/gi,
|
|
207
|
-
replace: (
|
|
210
|
+
replace: (m, g) => OPENCODE_SESSION_KEY.test(g[1] ?? "") && OPENCODE_SESSION_ID.test(g[3] ?? "") ? m : `${g[0] ?? ""}${g[1] ?? ""}${g[2] ?? ""}${REDACT("credential")}`
|
|
208
211
|
}
|
|
209
212
|
];
|
|
210
213
|
function redactSecrets(input) {
|
|
@@ -218,8 +221,7 @@ function redactSecrets(input) {
|
|
|
218
221
|
}
|
|
219
222
|
return result;
|
|
220
223
|
}
|
|
221
|
-
|
|
222
|
-
//#region src/modules/decision/decision.ts
|
|
224
|
+
// src/modules/decision/decision.ts
|
|
223
225
|
const OUTCOMES$1 = /* @__PURE__ */ new Set([
|
|
224
226
|
"allow",
|
|
225
227
|
"deny",
|
|
@@ -325,8 +327,7 @@ function parseDecision(value) {
|
|
|
325
327
|
evidence_completeness: value.evidence_completeness
|
|
326
328
|
};
|
|
327
329
|
}
|
|
328
|
-
|
|
329
|
-
//#region src/modules/decision/decision-schema.ts
|
|
330
|
+
// src/modules/decision/decision-schema.ts
|
|
330
331
|
const DECISION_SCHEMA = {
|
|
331
332
|
type: "object",
|
|
332
333
|
additionalProperties: false,
|
|
@@ -412,8 +413,7 @@ const DECISION_SCHEMA = {
|
|
|
412
413
|
}
|
|
413
414
|
}
|
|
414
415
|
};
|
|
415
|
-
|
|
416
|
-
//#region src/modules/context/services/prompt/policy.ts
|
|
416
|
+
// src/modules/context/services/prompt/policy.ts
|
|
417
417
|
const DEFAULT_TENANT_POLICY = `
|
|
418
418
|
## Environment profile
|
|
419
419
|
- No third-party destination is trusted by default unless the user request or transcript clearly identifies it.
|
|
@@ -550,8 +550,7 @@ ${evidence}
|
|
|
550
550
|
${outputDirective}
|
|
551
551
|
Return only the required structured decision.`;
|
|
552
552
|
}
|
|
553
|
-
|
|
554
|
-
//#region src/modules/evidence/ssh/verified-ssh-script.ts
|
|
553
|
+
// src/modules/evidence/ssh/verified-ssh-script.ts
|
|
555
554
|
const VERIFIED_SCRIPT_LIMIT = 65536;
|
|
556
555
|
const RECEIPT_LIFETIME_MS = 36e5;
|
|
557
556
|
const RECEIPT_LIMIT = 64;
|
|
@@ -595,8 +594,7 @@ var ScriptAnalysisRegistry = class {
|
|
|
595
594
|
function configFingerprint(config) {
|
|
596
595
|
return createHash("sha256").update(JSON.stringify(config)).digest("hex");
|
|
597
596
|
}
|
|
598
|
-
|
|
599
|
-
//#region src/modules/policy/config-rule-condition.ts
|
|
597
|
+
// src/modules/policy/config-rule-condition.ts
|
|
600
598
|
const ACTOR_PROFILES = /* @__PURE__ */ new Set([
|
|
601
599
|
"read-only",
|
|
602
600
|
"validation",
|
|
@@ -691,8 +689,7 @@ function copyFlagConditions(value, out) {
|
|
|
691
689
|
function isClosedSetMemberArray(value, valid) {
|
|
692
690
|
return Array.isArray(value) && value.length > 0 && value.every((v) => typeof v === "string" && valid.has(v));
|
|
693
691
|
}
|
|
694
|
-
|
|
695
|
-
//#region src/modules/config/models/config-fields.ts
|
|
692
|
+
// src/modules/config/models/config-fields.ts
|
|
696
693
|
/** Parse a trusted name→profile mapping. Invalid entries are dropped. */
|
|
697
694
|
function resolveActorProfiles(value) {
|
|
698
695
|
if (typeof value !== "object" || value === null) return {};
|
|
@@ -732,8 +729,7 @@ function isStringArray(value) {
|
|
|
732
729
|
function optional$2(key, value) {
|
|
733
730
|
return value === void 0 ? {} : { [key]: value };
|
|
734
731
|
}
|
|
735
|
-
|
|
736
|
-
//#region src/modules/config/models/config-knobs.ts
|
|
732
|
+
// src/modules/config/models/config-knobs.ts
|
|
737
733
|
function boundedInteger(value, fallback, min, max) {
|
|
738
734
|
if (typeof value !== "number" || !Number.isInteger(value)) return fallback;
|
|
739
735
|
return Math.min(max, Math.max(min, value));
|
|
@@ -784,8 +780,7 @@ function integerKnobs(source, bounds, defaults) {
|
|
|
784
780
|
function numberKnobs(source, bounds, defaults) {
|
|
785
781
|
return clampKnobs(source, bounds, defaults, boundedNumber);
|
|
786
782
|
}
|
|
787
|
-
|
|
788
|
-
//#region src/modules/config/models/config-policy-rules.ts
|
|
783
|
+
// src/modules/config/models/config-policy-rules.ts
|
|
789
784
|
const VALID_EFFECTS = /* @__PURE__ */ new Set([
|
|
790
785
|
"review",
|
|
791
786
|
"manual",
|
|
@@ -848,8 +843,7 @@ function countInvalidPolicyRules(value) {
|
|
|
848
843
|
if (!Array.isArray(value)) return 1;
|
|
849
844
|
return value.filter((raw) => parsePolicyRule(raw) === null).length;
|
|
850
845
|
}
|
|
851
|
-
|
|
852
|
-
//#region src/modules/config/models/config-risk-policy.ts
|
|
846
|
+
// src/modules/config/models/config-risk-policy.ts
|
|
853
847
|
/** Default risk×authorization matrix. `critical` stays empty: critical risk
|
|
854
848
|
* never auto-allows. */
|
|
855
849
|
const DEFAULT_RISK_POLICY = {
|
|
@@ -913,8 +907,126 @@ function resolveMinimumConfidence(value) {
|
|
|
913
907
|
if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_RISK_POLICY.minimumConfidence;
|
|
914
908
|
return Math.min(1, Math.max(.5, value));
|
|
915
909
|
}
|
|
916
|
-
|
|
917
|
-
|
|
910
|
+
// src/modules/config/models/openrouter-decision-models.ts
|
|
911
|
+
const OPENROUTER_DECISION_MODELS = {
|
|
912
|
+
models: {
|
|
913
|
+
"cloudflare/clef": { benchmarked: false },
|
|
914
|
+
"cloudflare/clef-flash": { benchmarked: false },
|
|
915
|
+
"cloudflare/clef-omni": { benchmarked: false },
|
|
916
|
+
"inception/mercury-decide": { benchmarked: false },
|
|
917
|
+
"jaredpalmer/kev-4b": { benchmarked: false },
|
|
918
|
+
"liquid/d1": { benchmarked: true },
|
|
919
|
+
"liquid/d1-ultra": { benchmarked: true },
|
|
920
|
+
"liquid/d1.1": { benchmarked: false },
|
|
921
|
+
"microsoft/microsoft-decision-1": { benchmarked: false },
|
|
922
|
+
"nace-ai/drex-max": { benchmarked: false },
|
|
923
|
+
"nace-ai/drex-v1.5": { benchmarked: false },
|
|
924
|
+
"nace-ai/drex-v2.0": { benchmarked: false },
|
|
925
|
+
"openai/gpt-6-luna-decisions": { benchmarked: false },
|
|
926
|
+
"perplexity/pplx-decider-flash-v1.2": { benchmarked: false },
|
|
927
|
+
"perplexity/pplx-decider-v1.2": { benchmarked: false },
|
|
928
|
+
"respan/span-02": { benchmarked: false },
|
|
929
|
+
"togethercomputer/tev1-4b-experimental": { benchmarked: false },
|
|
930
|
+
"typesafe/jev-1.13": { benchmarked: true },
|
|
931
|
+
"typesafe/jev-1.14": { benchmarked: true },
|
|
932
|
+
"upstage/solar-decide": { benchmarked: false },
|
|
933
|
+
"upstage/solar-decide-flash": { benchmarked: false },
|
|
934
|
+
"~liquid/d1-latest": { benchmarked: false },
|
|
935
|
+
"~liquid/d1-ultra-latest": { benchmarked: false },
|
|
936
|
+
"~perplexity/pplx-decider-flash-latest": { benchmarked: false },
|
|
937
|
+
"~perplexity/pplx-decider-latest": { benchmarked: false },
|
|
938
|
+
"~typesafe/jev-latest": { benchmarked: false }
|
|
939
|
+
},
|
|
940
|
+
incompatible: {
|
|
941
|
+
"respan/span-01": "requires a different state shape",
|
|
942
|
+
"respan/span-01-lite": "requires a different state shape",
|
|
943
|
+
"respan/span-01-lite:free": "requires a different state shape",
|
|
944
|
+
"scaledown/classify-1": "accepts only plain-string instructions and criteria"
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
// src/modules/config/models/system-one-providers.ts
|
|
948
|
+
const JEV_MODEL = /^jev(?:-|$)/;
|
|
949
|
+
const COMMANDCODE_JEV = "typesafe/jev";
|
|
950
|
+
const LIQUID_DECISION_MODELS = /* @__PURE__ */ new Set(["d1", "d1-ultra"]);
|
|
951
|
+
const BASETEN_DECISION_MODELS = /* @__PURE__ */ new Set(["decision-models/baseten-elephant-9b-latest", "decision-models/baseten-mammoth-27b-latest"]);
|
|
952
|
+
const isJev = (modelID) => JEV_MODEL.test(modelID);
|
|
953
|
+
const returnsJev = (_modelID, returned) => isJev(returned);
|
|
954
|
+
const sameModel = (modelID, returned) => returned === modelID;
|
|
955
|
+
const OPENROUTER_FAMILIES = [/^(?:typesafe\/jev-\d[a-z0-9.-]*(?<!-latest)|~typesafe\/jev-latest)$/, /^(?:liquid\/d1(?:[-.][a-z0-9.-]*)?(?<!-latest)|~liquid\/d1(?:[-.][a-z0-9.-]*)?-latest)$/];
|
|
956
|
+
const OPENROUTER_ROUTING_SUFFIX = /:[a-z0-9-]+$/;
|
|
957
|
+
const OPENROUTER_ALIAS = /^~(.+)-latest$/;
|
|
958
|
+
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
959
|
+
const OPENROUTER_MODELS = OPENROUTER_DECISION_MODELS.models;
|
|
960
|
+
const OPENROUTER_INCOMPATIBLE = OPENROUTER_DECISION_MODELS.incompatible;
|
|
961
|
+
const withoutRoutingSuffix = (modelID) => {
|
|
962
|
+
const stripped = modelID.replace(OPENROUTER_ROUTING_SUFFIX, "");
|
|
963
|
+
return stripped === modelID ? [modelID] : [modelID, stripped];
|
|
964
|
+
};
|
|
965
|
+
const openRouterIncompatibleReason = (modelID) => {
|
|
966
|
+
for (const id of withoutRoutingSuffix(modelID)) if (Object.hasOwn(OPENROUTER_INCOMPATIBLE, id)) return OPENROUTER_INCOMPATIBLE[id];
|
|
967
|
+
};
|
|
968
|
+
const openRouterConfigWarning = (modelID) => {
|
|
969
|
+
const reason = openRouterIncompatibleReason(modelID);
|
|
970
|
+
if (reason !== void 0) return `openrouter/${modelID} is known to reject the reviewer's request (${reason}); every review will fail`;
|
|
971
|
+
const listed = withoutRoutingSuffix(modelID).find((id) => Object.hasOwn(OPENROUTER_MODELS, id));
|
|
972
|
+
if (listed !== void 0 && OPENROUTER_MODELS[listed]?.benchmarked === true) return;
|
|
973
|
+
return `openrouter/${modelID} has not been benchmarked as a reviewer; see REVIEWER-MODELS.md`;
|
|
974
|
+
};
|
|
975
|
+
const openRouterAccepts = (modelID) => openRouterIncompatibleReason(modelID) !== void 0 || withoutRoutingSuffix(modelID).some((id) => Object.hasOwn(OPENROUTER_DECISION_MODELS.models, id) || OPENROUTER_FAMILIES.some((family) => family.test(id)));
|
|
976
|
+
const openRouterAcceptsResponse = (modelID, returned) => {
|
|
977
|
+
const base = modelID.replace(OPENROUTER_ROUTING_SUFFIX, "");
|
|
978
|
+
const alias = OPENROUTER_ALIAS.exec(base)?.[1];
|
|
979
|
+
if (alias !== void 0) return new RegExp(`^${escapeRegExp(alias)}(?:$|[-.])`).test(returned);
|
|
980
|
+
return returned === base || new RegExp(`^${escapeRegExp(base)}-\\d{8}$`).test(returned);
|
|
981
|
+
};
|
|
982
|
+
const SYSTEM_ONE_PROVIDERS = {
|
|
983
|
+
opencode: {
|
|
984
|
+
keyEnv: "OPENCODE_API_KEY",
|
|
985
|
+
baseURL: "https://opencode.ai/zen",
|
|
986
|
+
accepts: isJev,
|
|
987
|
+
acceptsResponse: returnsJev
|
|
988
|
+
},
|
|
989
|
+
"typesafe-ai": {
|
|
990
|
+
keyEnv: "TYPESAFE_API_KEY",
|
|
991
|
+
accepts: isJev,
|
|
992
|
+
acceptsResponse: returnsJev
|
|
993
|
+
},
|
|
994
|
+
commandcode: {
|
|
995
|
+
keyEnv: "CMD_API_KEY",
|
|
996
|
+
baseURL: "https://api.commandcode.ai/provider",
|
|
997
|
+
accepts: (modelID) => modelID === COMMANDCODE_JEV,
|
|
998
|
+
acceptsResponse: (_modelID, returned) => returned === COMMANDCODE_JEV
|
|
999
|
+
},
|
|
1000
|
+
"liquid-ai": {
|
|
1001
|
+
keyEnv: "LIQUID_API_KEY",
|
|
1002
|
+
baseURL: "https://api.liquid.ai/decisions",
|
|
1003
|
+
keyShape: {
|
|
1004
|
+
pattern: /^liquid_[A-Za-z0-9]{32,}$/,
|
|
1005
|
+
message: "LIQUID_API_KEY is not a Liquid AI key (expected the \"liquid_\" prefix)"
|
|
1006
|
+
},
|
|
1007
|
+
accepts: (modelID) => LIQUID_DECISION_MODELS.has(modelID),
|
|
1008
|
+
acceptsResponse: sameModel
|
|
1009
|
+
},
|
|
1010
|
+
baseten: {
|
|
1011
|
+
keyEnv: "BASETEN_API_KEY",
|
|
1012
|
+
baseURL: "https://inference.baseten.co",
|
|
1013
|
+
accepts: (modelID) => BASETEN_DECISION_MODELS.has(modelID),
|
|
1014
|
+
acceptsResponse: sameModel
|
|
1015
|
+
},
|
|
1016
|
+
openrouter: {
|
|
1017
|
+
keyEnv: "OPENROUTER_API_KEY",
|
|
1018
|
+
baseURL: "https://openrouter.ai/api",
|
|
1019
|
+
keyShape: {
|
|
1020
|
+
pattern: /^sk-or-v1-[0-9a-f]{64}$/,
|
|
1021
|
+
message: "OPENROUTER_API_KEY is not an OpenRouter key (expected the \"sk-or-v1-\" prefix)"
|
|
1022
|
+
},
|
|
1023
|
+
accepts: openRouterAccepts,
|
|
1024
|
+
acceptsResponse: openRouterAcceptsResponse,
|
|
1025
|
+
incompatibleReason: openRouterIncompatibleReason,
|
|
1026
|
+
configWarning: openRouterConfigWarning
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
// src/modules/config/services/reviewer-model.ts
|
|
918
1030
|
function splitModel(model) {
|
|
919
1031
|
const slash = model.indexOf("/");
|
|
920
1032
|
if (slash <= 0 || slash === model.length - 1) throw new Error(`Invalid reviewer model "${model}"; expected provider/model`);
|
|
@@ -923,14 +1035,23 @@ function splitModel(model) {
|
|
|
923
1035
|
modelID: model.slice(slash + 1)
|
|
924
1036
|
};
|
|
925
1037
|
}
|
|
926
|
-
function
|
|
1038
|
+
function systemOneProviderFor(model) {
|
|
927
1039
|
let parsed;
|
|
928
1040
|
try {
|
|
929
1041
|
parsed = splitModel(model);
|
|
930
1042
|
} catch {
|
|
931
|
-
return
|
|
1043
|
+
return;
|
|
932
1044
|
}
|
|
933
|
-
|
|
1045
|
+
if (!Object.hasOwn(SYSTEM_ONE_PROVIDERS, parsed.providerID)) return;
|
|
1046
|
+
const provider = SYSTEM_ONE_PROVIDERS[parsed.providerID];
|
|
1047
|
+
if (!provider?.accepts(parsed.modelID)) return;
|
|
1048
|
+
return {
|
|
1049
|
+
provider,
|
|
1050
|
+
...parsed
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
function isSystemOneReviewerModel(model) {
|
|
1054
|
+
return systemOneProviderFor(model) !== void 0;
|
|
934
1055
|
}
|
|
935
1056
|
function isProviderModelId(value) {
|
|
936
1057
|
return typeof value === "string" && value.includes("/");
|
|
@@ -958,8 +1079,7 @@ function isValidEscalationReviewer(value) {
|
|
|
958
1079
|
if (source === void 0) return false;
|
|
959
1080
|
return (source.variant === void 0 || typeof source.variant === "string" && source.variant !== "") && (source.outputFormat === void 0 || source.outputFormat === "text" || source.outputFormat === "json_schema") && (source.timeoutMs === void 0 || Number.isInteger(source.timeoutMs));
|
|
960
1081
|
}
|
|
961
|
-
|
|
962
|
-
//#region src/modules/config/services/system-one-routing.ts
|
|
1082
|
+
// src/modules/config/services/system-one-routing.ts
|
|
963
1083
|
/** The least review time a hand-off needs; with less the request escalates. */
|
|
964
1084
|
const HANDOFF_BUDGET_FLOOR_MS = 15e3;
|
|
965
1085
|
/** A non-Jev model is reported first: no escalationReviewer fixes that. */
|
|
@@ -979,8 +1099,8 @@ function systemOneRoutingWarnings(config) {
|
|
|
979
1099
|
const cause = inertCause(config);
|
|
980
1100
|
if (cause === void 0) return [];
|
|
981
1101
|
const warnings = [];
|
|
982
|
-
if (config.systemOneEscalation === "reasoning-first") warnings.push(cause === "not-jev" ? "systemOneEscalation \"reasoning-first\" is inactive: the reviewer model is not
|
|
983
|
-
if (config.systemOneDenialReview) warnings.push(cause === "not-jev" ? "systemOneDenialReview is inactive: the reviewer model is not
|
|
1102
|
+
if (config.systemOneEscalation === "reasoning-first") warnings.push(cause === "not-jev" ? "systemOneEscalation \"reasoning-first\" is inactive: the reviewer model is not a System One model" : "systemOneEscalation \"reasoning-first\" is inactive: no escalationReviewer is configured; System One escalations still go to you");
|
|
1103
|
+
if (config.systemOneDenialReview) warnings.push(cause === "not-jev" ? "systemOneDenialReview is inactive: the reviewer model is not a System One model" : "systemOneDenialReview is inactive: no escalationReviewer is configured; System One denials stay final");
|
|
984
1104
|
return warnings;
|
|
985
1105
|
}
|
|
986
1106
|
/** Standard routing hands off too, so neither routing key gates this. The
|
|
@@ -991,6 +1111,12 @@ function budgetFloorWarnings(config) {
|
|
|
991
1111
|
if (budget - config.timeoutMs >= 15e3) return [];
|
|
992
1112
|
return [`reviewBudgetMs ${budget} leaves less than ${HANDOFF_BUDGET_FLOOR_MS} ms after timeoutMs; hand-offs to the reasoning reviewer will escalate to you instead`];
|
|
993
1113
|
}
|
|
1114
|
+
/** System One is never the escalation reviewer, so only `model` is checked. */
|
|
1115
|
+
function systemOneModelWarnings(config) {
|
|
1116
|
+
const target = systemOneProviderFor(config.model);
|
|
1117
|
+
const warning = target?.provider.configWarning?.(target.modelID);
|
|
1118
|
+
return warning === void 0 ? [] : [warning];
|
|
1119
|
+
}
|
|
994
1120
|
const PREVIEW_CHARS = 80;
|
|
995
1121
|
/** A warning names the value; it does not reproduce it. */
|
|
996
1122
|
function preview(value) {
|
|
@@ -1010,6 +1136,7 @@ function withSystemOneRoutingWarnings(config, source) {
|
|
|
1010
1136
|
const warnings = [
|
|
1011
1137
|
...invalidValueWarnings(config, source),
|
|
1012
1138
|
...systemOneRoutingWarnings(config),
|
|
1139
|
+
...systemOneModelWarnings(config),
|
|
1013
1140
|
...budgetFloorWarnings(config)
|
|
1014
1141
|
];
|
|
1015
1142
|
return warnings.length === 0 ? config : {
|
|
@@ -1017,8 +1144,7 @@ function withSystemOneRoutingWarnings(config, source) {
|
|
|
1017
1144
|
configWarnings: warnings
|
|
1018
1145
|
};
|
|
1019
1146
|
}
|
|
1020
|
-
|
|
1021
|
-
//#region src/modules/config/services/config.ts
|
|
1147
|
+
// src/modules/config/services/config.ts
|
|
1022
1148
|
const DEFAULT_CONFIG = {
|
|
1023
1149
|
model: "openai/gpt-6-luna",
|
|
1024
1150
|
variant: "medium",
|
|
@@ -1086,8 +1212,7 @@ function resolveConfig(options) {
|
|
|
1086
1212
|
...isStringArray(source.configDegraded) && source.configDegraded.length > 0 ? { configDegraded: source.configDegraded } : {}
|
|
1087
1213
|
}, source);
|
|
1088
1214
|
}
|
|
1089
|
-
|
|
1090
|
-
//#region src/modules/analysis/reviewed-command.ts
|
|
1215
|
+
// src/modules/analysis/reviewed-command.ts
|
|
1091
1216
|
function commandText(request, separator) {
|
|
1092
1217
|
const { command } = request.metadata;
|
|
1093
1218
|
if (typeof command === "string" && command.trim() !== "") return command;
|
|
@@ -1096,8 +1221,7 @@ function commandText(request, separator) {
|
|
|
1096
1221
|
function reviewedCommand(request) {
|
|
1097
1222
|
return commandText(request, "\n");
|
|
1098
1223
|
}
|
|
1099
|
-
|
|
1100
|
-
//#region src/modules/evidence/providers/source-command.ts
|
|
1224
|
+
// src/modules/evidence/providers/source-command.ts
|
|
1101
1225
|
/**
|
|
1102
1226
|
* Recover the shell command a permission request is about. Prefer the explicit
|
|
1103
1227
|
* `command` metadata (set by the bash tool) and fall back to the patterns
|
|
@@ -1106,8 +1230,7 @@ function reviewedCommand(request) {
|
|
|
1106
1230
|
function sourceCommand(request) {
|
|
1107
1231
|
return commandText(request, " ; ");
|
|
1108
1232
|
}
|
|
1109
|
-
|
|
1110
|
-
//#region src/utils/element-at.ts
|
|
1233
|
+
// src/utils/element-at.ts
|
|
1111
1234
|
/** `items[index]` for an index the caller's loop bound keeps in range, in an
|
|
1112
1235
|
* array that holds no `undefined` elements. A miss is a broken guarantee, so
|
|
1113
1236
|
* it throws naming the array and the index. The message is built only on
|
|
@@ -1117,8 +1240,7 @@ function elementAt(items, index, name) {
|
|
|
1117
1240
|
if (item === void 0) invariant(false, `${name}[${index}] is out of bounds (length ${items.length})`);
|
|
1118
1241
|
return item;
|
|
1119
1242
|
}
|
|
1120
|
-
|
|
1121
|
-
//#region src/modules/analysis/git/git-global-options.ts
|
|
1243
|
+
// src/modules/analysis/git/git-global-options.ts
|
|
1122
1244
|
/** Global options git reads with a separate value (`git.c` `handle_options`).
|
|
1123
1245
|
* `--super-prefix` is accepted by older Git releases.
|
|
1124
1246
|
* `--exec-path` takes a value only as `--exec-path=…`. */
|
|
@@ -1147,8 +1269,7 @@ function gitSubcommandIndex(values, gitIndex) {
|
|
|
1147
1269
|
}
|
|
1148
1270
|
return values.length;
|
|
1149
1271
|
}
|
|
1150
|
-
|
|
1151
|
-
//#region src/modules/analysis/git/git-execution-directory.ts
|
|
1272
|
+
// src/modules/analysis/git/git-execution-directory.ts
|
|
1152
1273
|
const UNRESOLVED_EXPANSION = /[$`*?{}<>]/;
|
|
1153
1274
|
function gitExecutionDirectory(tokens, gitIndex, subcommandIndex, initialDirectory, prefix) {
|
|
1154
1275
|
if (!initialDirectory) return { reason: "working directory before Git is unresolved" };
|
|
@@ -1212,8 +1333,7 @@ function settledExecutionDirectory(executionDirectories, directoryReasons) {
|
|
|
1212
1333
|
if (directoryReasons.size > 0) return { directoryReason: [...directoryReasons].join("; ") };
|
|
1213
1334
|
return {};
|
|
1214
1335
|
}
|
|
1215
|
-
|
|
1216
|
-
//#region src/modules/analysis/shell/shell-token.ts
|
|
1336
|
+
// src/modules/analysis/shell/shell-token.ts
|
|
1217
1337
|
/** Whether the character at `index` of `token.value` lies in a quoted or
|
|
1218
1338
|
* escaped span, where it cannot act as a shell operator. Tokens without
|
|
1219
1339
|
* span information fall back to whole-token conservatism. */
|
|
@@ -1327,8 +1447,7 @@ function operatorChars(token) {
|
|
|
1327
1447
|
function hasQuotedChar(token) {
|
|
1328
1448
|
return quotedChars(token).includes(true);
|
|
1329
1449
|
}
|
|
1330
|
-
|
|
1331
|
-
//#region src/modules/analysis/shell/shell-redirection-operators.ts
|
|
1450
|
+
// src/modules/analysis/shell/shell-redirection-operators.ts
|
|
1332
1451
|
/** Multi-character operators in match order: the three-character forms
|
|
1333
1452
|
* first, so `&>>` is never read as `&>`. */
|
|
1334
1453
|
const REDIRECTION_OPERATORS = [
|
|
@@ -1378,8 +1497,7 @@ function redirectionsIn(token) {
|
|
|
1378
1497
|
}
|
|
1379
1498
|
return found;
|
|
1380
1499
|
}
|
|
1381
|
-
|
|
1382
|
-
//#region src/modules/analysis/shell/shell-redirections.ts
|
|
1500
|
+
// src/modules/analysis/shell/shell-redirections.ts
|
|
1383
1501
|
/** The heredoc extractor inserts this inert marker after removing the body.
|
|
1384
1502
|
* It is evidence metadata, not another input redirection. */
|
|
1385
1503
|
const HEREDOC_MARKER = /^<HEREDOC:sha256:[a-f0-9]+>$/;
|
|
@@ -1504,8 +1622,7 @@ function splitTokens(tokens, split) {
|
|
|
1504
1622
|
tokenIndex += 1;
|
|
1505
1623
|
}
|
|
1506
1624
|
}
|
|
1507
|
-
|
|
1508
|
-
//#region src/modules/analysis/capability/heredoc/ansi-c-quoting.ts
|
|
1625
|
+
// src/modules/analysis/capability/heredoc/ansi-c-quoting.ts
|
|
1509
1626
|
/** Unescape an ANSI-C quoted region (`$'...'`), the subset bash defines for
|
|
1510
1627
|
* here-document delimiter words: standard escapes, `\xHH` hex, and up to
|
|
1511
1628
|
* three octal digits. Unknown escapes drop the backslash, like bash. A
|
|
@@ -1677,8 +1794,7 @@ function digitsAt(text, start, pattern) {
|
|
|
1677
1794
|
pattern.lastIndex = start;
|
|
1678
1795
|
return pattern.exec(text)?.[0] ?? "";
|
|
1679
1796
|
}
|
|
1680
|
-
|
|
1681
|
-
//#region src/modules/analysis/shell/shell-lex-state.ts
|
|
1797
|
+
// src/modules/analysis/shell/shell-lex-state.ts
|
|
1682
1798
|
/** Whether the reading decodes quotes the way bash does. */
|
|
1683
1799
|
function readsBashQuotes(quoting = "bash") {
|
|
1684
1800
|
return quoting === "bash" || quoting === "rescan" || quoting === "finder";
|
|
@@ -1771,8 +1887,7 @@ function flushSegment(lex, endedBy) {
|
|
|
1771
1887
|
for (const segment of lex.substitutions) lex.segments.push(segment);
|
|
1772
1888
|
lex.substitutions = [];
|
|
1773
1889
|
}
|
|
1774
|
-
|
|
1775
|
-
//#region src/modules/analysis/shell/shell-quote-scan.ts
|
|
1890
|
+
// src/modules/analysis/shell/shell-quote-scan.ts
|
|
1776
1891
|
/** Adds text of the open single quote to the value; an ANSI-C string keeps
|
|
1777
1892
|
* its text as written until it closes, unless the scan reads it undecoded. */
|
|
1778
1893
|
function appendQuoted(lex, text) {
|
|
@@ -1867,8 +1982,7 @@ function openQuote(lex, c) {
|
|
|
1867
1982
|
lex.hasToken = true;
|
|
1868
1983
|
lex.index += 1;
|
|
1869
1984
|
}
|
|
1870
|
-
|
|
1871
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-body-text.ts
|
|
1985
|
+
// src/modules/analysis/capability/heredoc/heredoc-body-text.ts
|
|
1872
1986
|
/** Maximum body bytes retained (bounded + redacted for prompt/audit safety). */
|
|
1873
1987
|
const MAX_BODY_BYTES = 4096;
|
|
1874
1988
|
/** Scan the text before a heredoc operator for a trailing `> path` target. */
|
|
@@ -1949,8 +2063,7 @@ function containsDynamic(body, expansionDisabled) {
|
|
|
1949
2063
|
if (expansionDisabled) return false;
|
|
1950
2064
|
return /\$\(?|`/.test(body);
|
|
1951
2065
|
}
|
|
1952
|
-
|
|
1953
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-body-records.ts
|
|
2066
|
+
// src/modules/analysis/capability/heredoc/heredoc-body-records.ts
|
|
1954
2067
|
/** Read one pending heredoc's body from `position`, bounded by `limit` when
|
|
1955
2068
|
* given. Returns it with the index the next text is read from: just past its
|
|
1956
2069
|
* terminator line, or the bound itself when the body is cut there. */
|
|
@@ -2010,8 +2123,7 @@ function bodyRecord(command, start, read, lineEnd, targets) {
|
|
|
2010
2123
|
...outputTarget === void 0 ? {} : { outputTarget }
|
|
2011
2124
|
};
|
|
2012
2125
|
}
|
|
2013
|
-
|
|
2014
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-body-reading.ts
|
|
2126
|
+
// src/modules/analysis/capability/heredoc/heredoc-body-reading.ts
|
|
2015
2127
|
/** The body as its expansion reads it. Its backslash-newline pairs go
|
|
2016
2128
|
* first; then, for a `<<-` body (`tabStripped`), every line loses its
|
|
2017
2129
|
* leading tabs, so a line that continues another keeps its own. */
|
|
@@ -2053,8 +2165,7 @@ function bodyTextStep(text, index) {
|
|
|
2053
2165
|
if (c === "`" || c === "$" && next === "(") return -1;
|
|
2054
2166
|
return index + 1;
|
|
2055
2167
|
}
|
|
2056
|
-
|
|
2057
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-scripts.ts
|
|
2168
|
+
// src/modules/analysis/capability/heredoc/heredoc-scripts.ts
|
|
2058
2169
|
/** What a reading that found no heredoc holds. It is shared, never written
|
|
2059
2170
|
* to. */
|
|
2060
2171
|
const NO_SCRIPTS = /* @__PURE__ */ new Map();
|
|
@@ -2137,8 +2248,7 @@ function addScript(into, placeholder, text) {
|
|
|
2137
2248
|
if (held === void 0) into.scripts.set(placeholder, [text]);
|
|
2138
2249
|
else if (!held.includes(text)) held.push(text);
|
|
2139
2250
|
}
|
|
2140
|
-
|
|
2141
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-bodies.ts
|
|
2251
|
+
// src/modules/analysis/capability/heredoc/heredoc-bodies.ts
|
|
2142
2252
|
function appendText(scan, text) {
|
|
2143
2253
|
if (text.length === 0) return;
|
|
2144
2254
|
const last = scan.pieces.at(-1);
|
|
@@ -2209,8 +2319,7 @@ function heredocRecord(start, record) {
|
|
|
2209
2319
|
dynamic: record.dynamic
|
|
2210
2320
|
};
|
|
2211
2321
|
}
|
|
2212
|
-
|
|
2213
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-word-quotes.ts
|
|
2322
|
+
// src/modules/analysis/capability/heredoc/heredoc-word-quotes.ts
|
|
2214
2323
|
function scanSingleQuoted(command, scan) {
|
|
2215
2324
|
const end = command.indexOf("'", scan.index + 1);
|
|
2216
2325
|
if (end === -1) {
|
|
@@ -2273,8 +2382,7 @@ function scanDoubleQuoted(command, scan) {
|
|
|
2273
2382
|
function doubleQuotedEscape(escaped) {
|
|
2274
2383
|
return "$`\"\\".includes(escaped) ? escaped : `\\${escaped}`;
|
|
2275
2384
|
}
|
|
2276
|
-
|
|
2277
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-delimiter.ts
|
|
2385
|
+
// src/modules/analysis/capability/heredoc/heredoc-delimiter.ts
|
|
2278
2386
|
/** Characters that cannot appear unquoted inside a heredoc delimiter word.
|
|
2279
2387
|
* `$` and backticks are NOT stops: the delimiter word undergoes no
|
|
2280
2388
|
* expansion, so they are literal terminator characters. */
|
|
@@ -2358,8 +2466,7 @@ function scanDelimiterPart(command, scan) {
|
|
|
2358
2466
|
scan.index += 1;
|
|
2359
2467
|
return true;
|
|
2360
2468
|
}
|
|
2361
|
-
|
|
2362
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-frame-bounds.ts
|
|
2469
|
+
// src/modules/analysis/capability/heredoc/heredoc-frame-bounds.ts
|
|
2363
2470
|
/** For each index `p`, the index of the `)` that closes a `(` placed just
|
|
2364
2471
|
* before `p`: scanning from `p`, the first `)` that leaves no `(` open,
|
|
2365
2472
|
* skipping quotes and backslash escapes; `-1` when the text ends first.
|
|
@@ -2451,8 +2558,7 @@ function innermostLimit(frames) {
|
|
|
2451
2558
|
function insideSubstitution(frames) {
|
|
2452
2559
|
return (frames.at(-1)?.subst ?? -1) >= 0;
|
|
2453
2560
|
}
|
|
2454
|
-
|
|
2455
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-frame-links.ts
|
|
2561
|
+
// src/modules/analysis/capability/heredoc/heredoc-frame-links.ts
|
|
2456
2562
|
/** The frame `spec` makes at stack `index`, with its links taken from the frame
|
|
2457
2563
|
* below it (already linked). */
|
|
2458
2564
|
function linkFrame(frames, index, spec) {
|
|
@@ -2468,8 +2574,7 @@ function linkFrame(frames, index, spec) {
|
|
|
2468
2574
|
function pushFrame(scan, spec) {
|
|
2469
2575
|
scan.frames.push(linkFrame(scan.frames, scan.frames.length, spec));
|
|
2470
2576
|
}
|
|
2471
|
-
|
|
2472
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-scan-context.ts
|
|
2577
|
+
// src/modules/analysis/capability/heredoc/heredoc-scan-context.ts
|
|
2473
2578
|
/** The constructs that may open, most specific first: `$((` is decided by
|
|
2474
2579
|
* `openDollarParen` (arithmetic, or a substitution ending at its matched
|
|
2475
2580
|
* `)`); `((` is arithmetic, where `<<` is a shift, and falls back to two
|
|
@@ -2638,8 +2743,7 @@ function openBacktick(scan) {
|
|
|
2638
2743
|
});
|
|
2639
2744
|
scan.i += 1;
|
|
2640
2745
|
}
|
|
2641
|
-
|
|
2642
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-frame-starts.ts
|
|
2746
|
+
// src/modules/analysis/capability/heredoc/heredoc-frame-starts.ts
|
|
2643
2747
|
/** Whether the shell reads no heredoc body at this `<<`. The nearest
|
|
2644
2748
|
* expansion, substitution or backtick open at the operator decides: an
|
|
2645
2749
|
* expansion reads `<<` as literal or shift text, while a substitution or
|
|
@@ -2707,8 +2811,7 @@ function closeFrame(scan) {
|
|
|
2707
2811
|
if (!scan.readAllOperators && (frame.kind === "substitution" || frame.kind === "backtick")) dropSubstitutedStarts(scan, frame);
|
|
2708
2812
|
return true;
|
|
2709
2813
|
}
|
|
2710
|
-
|
|
2711
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-operator-scan.ts
|
|
2814
|
+
// src/modules/analysis/capability/heredoc/heredoc-operator-scan.ts
|
|
2712
2815
|
function scanNewline(scan) {
|
|
2713
2816
|
if (scan.pending.length === 0) {
|
|
2714
2817
|
scan.lineStart = scan.i + 1;
|
|
@@ -2760,8 +2863,7 @@ function scanHeredocOperator(scan) {
|
|
|
2760
2863
|
scan.cursor = word.wordEnd;
|
|
2761
2864
|
scan.i = word.wordEnd;
|
|
2762
2865
|
}
|
|
2763
|
-
|
|
2764
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-legacy.ts
|
|
2866
|
+
// src/modules/analysis/capability/heredoc/heredoc-legacy.ts
|
|
2765
2867
|
/** The command with each heredoc body collapsed, as the previous release
|
|
2766
2868
|
* collapsed it. */
|
|
2767
2869
|
function legacySanitizedCommand(command) {
|
|
@@ -2824,8 +2926,7 @@ function scanArithmetic(scan, c) {
|
|
|
2824
2926
|
scan.i += c === "$" ? 3 : 2;
|
|
2825
2927
|
return true;
|
|
2826
2928
|
}
|
|
2827
|
-
|
|
2828
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-extractor.ts
|
|
2929
|
+
// src/modules/analysis/capability/heredoc/heredoc-extractor.ts
|
|
2829
2930
|
/**
|
|
2830
2931
|
* Extract every heredoc in `command`, replacing each body with a placeholder
|
|
2831
2932
|
* `<HEREDOC:sha256:xxxxxxxx>` so the downstream lexer never sees the content.
|
|
@@ -2913,8 +3014,7 @@ function scanCharacter(scan) {
|
|
|
2913
3014
|
}
|
|
2914
3015
|
scan.i += 1;
|
|
2915
3016
|
}
|
|
2916
|
-
|
|
2917
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-sanitized.ts
|
|
3017
|
+
// src/modules/analysis/capability/heredoc/heredoc-sanitized.ts
|
|
2918
3018
|
/** `text` with its heredoc bodies collapsed by the current extractor. */
|
|
2919
3019
|
function sanitizedText(text) {
|
|
2920
3020
|
const extraction = extractHeredocs(text);
|
|
@@ -2925,8 +3025,7 @@ function sanitizedText(text) {
|
|
|
2925
3025
|
scripts: extraction.scripts
|
|
2926
3026
|
};
|
|
2927
3027
|
}
|
|
2928
|
-
|
|
2929
|
-
//#region src/modules/analysis/shell/shell-substitution-prefix.ts
|
|
3028
|
+
// src/modules/analysis/shell/shell-substitution-prefix.ts
|
|
2930
3029
|
/** After a `coproc` name, the start of the compound command it runs. */
|
|
2931
3030
|
const COMPOUND_START = /(?:(?:case|if|while|until|for|select)(?!\w)|\{|\(|\[\[)/y;
|
|
2932
3031
|
const TIME_OPTION = /(?:-p|--)(?=[ \t\n]|$)/y;
|
|
@@ -3012,8 +3111,7 @@ function skipJoins(text, from) {
|
|
|
3012
3111
|
while (text[at] === "\\" && text[at + 1] === "\n") at += 2;
|
|
3013
3112
|
return at;
|
|
3014
3113
|
}
|
|
3015
|
-
|
|
3016
|
-
//#region src/modules/analysis/shell/shell-substitution-heredoc.ts
|
|
3114
|
+
// src/modules/analysis/shell/shell-substitution-heredoc.ts
|
|
3017
3115
|
/** The `<<` operator at `index`: the heredoc it opens (none for a `<<<`
|
|
3018
3116
|
* here-string) and the index just past its delimiter word. */
|
|
3019
3117
|
function heredocOperatorAt(text, index, reading = "default") {
|
|
@@ -3087,8 +3185,7 @@ function parenAfter(text, from) {
|
|
|
3087
3185
|
while (text[at] === " " || text[at] === " ") at += 1;
|
|
3088
3186
|
return text[at] === ")" ? at : -1;
|
|
3089
3187
|
}
|
|
3090
|
-
|
|
3091
|
-
//#region src/modules/analysis/shell/shell-substitution-words.ts
|
|
3188
|
+
// src/modules/analysis/shell/shell-substitution-words.ts
|
|
3092
3189
|
/** Words after which a command can still start. */
|
|
3093
3190
|
const COMMAND_PREFIX_WORDS = /* @__PURE__ */ new Set([
|
|
3094
3191
|
"then",
|
|
@@ -3199,8 +3296,7 @@ function endHeader(scan) {
|
|
|
3199
3296
|
function startsSubject(scan, c) {
|
|
3200
3297
|
if (scan.words === "caseSubject" && !/[\s\w]/.test(c)) scan.words = "caseIn";
|
|
3201
3298
|
}
|
|
3202
|
-
|
|
3203
|
-
//#region src/modules/analysis/shell/shell-substitution-text.ts
|
|
3299
|
+
// src/modules/analysis/shell/shell-substitution-text.ts
|
|
3204
3300
|
function stepCommandText(scan, c) {
|
|
3205
3301
|
if (c === "\n") {
|
|
3206
3302
|
skipNewline(scan);
|
|
@@ -3271,8 +3367,7 @@ function readHeredocOperator(scan) {
|
|
|
3271
3367
|
scan.index = operator.end;
|
|
3272
3368
|
scan.commandPosition = false;
|
|
3273
3369
|
}
|
|
3274
|
-
|
|
3275
|
-
//#region src/modules/analysis/shell/shell-substitution-frames.ts
|
|
3370
|
+
// src/modules/analysis/shell/shell-substitution-frames.ts
|
|
3276
3371
|
function advance(scan) {
|
|
3277
3372
|
scan.index += 1;
|
|
3278
3373
|
return false;
|
|
@@ -3349,8 +3444,7 @@ function skipSingleQuoted(scan, ansiC) {
|
|
|
3349
3444
|
scan.index = i + 1;
|
|
3350
3445
|
scan.commandPosition = false;
|
|
3351
3446
|
}
|
|
3352
|
-
|
|
3353
|
-
//#region src/modules/analysis/shell/shell-substitution-brace.ts
|
|
3447
|
+
// src/modules/analysis/shell/shell-substitution-brace.ts
|
|
3354
3448
|
function stepDouble$1(scan, c) {
|
|
3355
3449
|
return stepQuoted$1(scan, c, "\"", false);
|
|
3356
3450
|
}
|
|
@@ -3385,8 +3479,7 @@ function skip(scan, ansiC) {
|
|
|
3385
3479
|
skipSingleQuoted(scan, ansiC);
|
|
3386
3480
|
return false;
|
|
3387
3481
|
}
|
|
3388
|
-
|
|
3389
|
-
//#region src/modules/analysis/shell/shell-pair-text.ts
|
|
3482
|
+
// src/modules/analysis/shell/shell-pair-text.ts
|
|
3390
3483
|
function lineIndex(text) {
|
|
3391
3484
|
const index = {
|
|
3392
3485
|
starts: /* @__PURE__ */ new Map(),
|
|
@@ -3492,8 +3585,7 @@ function keywordAt(text, i, word) {
|
|
|
3492
3585
|
}
|
|
3493
3586
|
/** Keywords that a command follows. */
|
|
3494
3587
|
const LEADS = /(?:^|[\s;&|(])(?:then|do|else|elif|\{|!|time)$/;
|
|
3495
|
-
|
|
3496
|
-
//#region src/modules/analysis/shell/shell-substitution-pairs.ts
|
|
3588
|
+
// src/modules/analysis/shell/shell-substitution-pairs.ts
|
|
3497
3589
|
/** What the pair reading is inside: an arithmetic group `(…)`, a `$(…)`
|
|
3498
3590
|
* body, `"…"`, a backtick body, `'…'`, `$'…'`, `${…}`, `$[…]`, and a
|
|
3499
3591
|
* `case … esac` in a `$(…)` body, whose patterns end with a `)`. */
|
|
@@ -3642,8 +3734,7 @@ function commandClose(read, start) {
|
|
|
3642
3734
|
if (c === "#") return at(read, Kind.Command, read.newline);
|
|
3643
3735
|
return at(read, Kind.Command, start);
|
|
3644
3736
|
}
|
|
3645
|
-
|
|
3646
|
-
//#region src/modules/analysis/shell/shell-substitution-groups.ts
|
|
3737
|
+
// src/modules/analysis/shell/shell-substitution-groups.ts
|
|
3647
3738
|
/**
|
|
3648
3739
|
* Opens the group that the `(` or `[` at the scan starts, if it starts one:
|
|
3649
3740
|
* `x=(`, a `[[` at a command position, a `((` the shell pairs as arithmetic,
|
|
@@ -3728,8 +3819,7 @@ function endsTest(scan) {
|
|
|
3728
3819
|
const { text, index } = scan;
|
|
3729
3820
|
return text.startsWith("]]", index) && /\s/.test(text.charAt(index - 1)) && (index + 2 >= text.length || /[\s;&|)<>]/.test(text.charAt(index + 2)));
|
|
3730
3821
|
}
|
|
3731
|
-
|
|
3732
|
-
//#region src/modules/analysis/shell/shell-substitution-end.ts
|
|
3822
|
+
// src/modules/analysis/shell/shell-substitution-end.ts
|
|
3733
3823
|
/**
|
|
3734
3824
|
* Index of the character that closes the substitution whose body starts at
|
|
3735
3825
|
* `start`: the matching `)` for a `$(` body, the next unescaped backtick for
|
|
@@ -3792,8 +3882,7 @@ function stepFrame$1(scan, c, frame) {
|
|
|
3792
3882
|
function openGroupAt(scan, c, insideCase) {
|
|
3793
3883
|
return insideCase && scan.pattern ? void 0 : openGroup(scan, c);
|
|
3794
3884
|
}
|
|
3795
|
-
|
|
3796
|
-
//#region src/modules/analysis/shell/shell-substitution-expansion.ts
|
|
3885
|
+
// src/modules/analysis/shell/shell-substitution-expansion.ts
|
|
3797
3886
|
/** A `${…}` in double quotes holds quoted text and substitutions of its own,
|
|
3798
3887
|
* so a `}` or `"` inside it does not end the word. Only the shell's reading
|
|
3799
3888
|
* scans it. A `$` right after another `$` is no start: versions of the shell
|
|
@@ -3816,8 +3905,7 @@ function endsDollarPair(command, index) {
|
|
|
3816
3905
|
while (command[index - 1 - dollars - slashes] === "\\") slashes += 1;
|
|
3817
3906
|
return (dollars - slashes % 2) % 2 === 1;
|
|
3818
3907
|
}
|
|
3819
|
-
|
|
3820
|
-
//#region src/modules/analysis/shell/shell-substitution.ts
|
|
3908
|
+
// src/modules/analysis/shell/shell-substitution.ts
|
|
3821
3909
|
/**
|
|
3822
3910
|
* An unquoted `$(` is not a substitution here: the scanner already splits at
|
|
3823
3911
|
* its parentheses. `$((…))` is arithmetic, not a command. Heredoc bodies
|
|
@@ -3874,8 +3962,7 @@ function dollarParenBody(command, start, reading, scan, probes) {
|
|
|
3874
3962
|
const end = opener === "arith" ? substitutionBodyEnd(command, start, "pair", reading, scan, void 0, probes) : close;
|
|
3875
3963
|
return commandBody(command.slice(start, end), end + 1, reading, true);
|
|
3876
3964
|
}
|
|
3877
|
-
|
|
3878
|
-
//#region src/modules/analysis/shell/shell-substitution-arithmetic.ts
|
|
3965
|
+
// src/modules/analysis/shell/shell-substitution-arithmetic.ts
|
|
3879
3966
|
/** Whether the `$((` at `index` is arithmetic, by the frames the end-finder
|
|
3880
3967
|
* already closed: its subshell frame closes right before its own. */
|
|
3881
3968
|
function knownArithmetic(closes, index) {
|
|
@@ -3883,8 +3970,7 @@ function knownArithmetic(closes, index) {
|
|
|
3883
3970
|
const inner = closes.get(index + 2);
|
|
3884
3971
|
return outer !== void 0 && inner !== void 0 && outer === inner + 1;
|
|
3885
3972
|
}
|
|
3886
|
-
|
|
3887
|
-
//#region src/modules/analysis/capability/heredoc/delimited-substitution-end.ts
|
|
3973
|
+
// src/modules/analysis/capability/heredoc/delimited-substitution-end.ts
|
|
3888
3974
|
/**
|
|
3889
3975
|
* The index of the `)` that ends the `$(` whose text starts at `start`, as
|
|
3890
3976
|
* bash 3.2 finds it when it expands a heredoc body, or -1 when the text
|
|
@@ -4020,8 +4106,7 @@ function pastBacktick(text, index) {
|
|
|
4020
4106
|
function doubleQuoteEnd(text, start) {
|
|
4021
4107
|
return delimitedEnd(text, start, "double");
|
|
4022
4108
|
}
|
|
4023
|
-
|
|
4024
|
-
//#region src/modules/analysis/capability/heredoc/delimited-arithmetic.ts
|
|
4109
|
+
// src/modules/analysis/capability/heredoc/delimited-arithmetic.ts
|
|
4025
4110
|
/**
|
|
4026
4111
|
* Whether bash 3.2 reads the `$((` at `index`, whose `$(` ends at the `)` at
|
|
4027
4112
|
* `close`, as arithmetic: its text must end with `)` and balance its
|
|
@@ -4071,8 +4156,7 @@ function pastArithmeticChar(text, index, c) {
|
|
|
4071
4156
|
const end = doubleQuoteEnd(text, index + 1);
|
|
4072
4157
|
return end < 0 ? text.length : end;
|
|
4073
4158
|
}
|
|
4074
|
-
|
|
4075
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-scan-budget.ts
|
|
4159
|
+
// src/modules/analysis/capability/heredoc/heredoc-scan-budget.ts
|
|
4076
4160
|
/** Text the scans may read, per character of the input they serve, and on
|
|
4077
4161
|
* top of that. Past it every body still to scan is unresolved. */
|
|
4078
4162
|
const SCAN_CHARS_PER_CHAR = 32;
|
|
@@ -4105,8 +4189,7 @@ function chargeScan(chars) {
|
|
|
4105
4189
|
remaining -= chars;
|
|
4106
4190
|
return remaining >= 0;
|
|
4107
4191
|
}
|
|
4108
|
-
|
|
4109
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-body-early-ends.ts
|
|
4192
|
+
// src/modules/analysis/capability/heredoc/heredoc-body-early-ends.ts
|
|
4110
4193
|
/**
|
|
4111
4194
|
* The commands an expanded body `text` runs under bash 3.2 that the scan of
|
|
4112
4195
|
* later releases did not list. That scan listed a substitution for each
|
|
@@ -4280,8 +4363,7 @@ function keepCommand(scan, found, backtick) {
|
|
|
4280
4363
|
keepBodyScripts(scan, read.scripts);
|
|
4281
4364
|
scan.unresolved ||= read.bodyUnresolved;
|
|
4282
4365
|
}
|
|
4283
|
-
|
|
4284
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-body-collector.ts
|
|
4366
|
+
// src/modules/analysis/capability/heredoc/heredoc-body-collector.ts
|
|
4285
4367
|
/** Adds commands to `into`, with whether their bodies were unresolved. A
|
|
4286
4368
|
* collector that is not there is a reading that keeps none. */
|
|
4287
4369
|
function keepBodyCommands(into, commands, unresolved) {
|
|
@@ -4296,8 +4378,7 @@ function addBodyCommands(into, body, tabStripped) {
|
|
|
4296
4378
|
keepBodyCommands(into, found.commands, found.unresolved);
|
|
4297
4379
|
keepBodyScripts(into, found.scripts ?? NO_SCRIPTS);
|
|
4298
4380
|
}
|
|
4299
|
-
|
|
4300
|
-
//#region src/modules/analysis/shell/shell-substitution-trust.ts
|
|
4381
|
+
// src/modules/analysis/shell/shell-substitution-trust.ts
|
|
4301
4382
|
/** The text the heredoc extractor puts in place of a body. A user may type
|
|
4302
4383
|
* the same text, so it is never taken as proof that a body is gone. */
|
|
4303
4384
|
const PLACEHOLDER$2 = "<HEREDOC:sha256:";
|
|
@@ -4416,8 +4497,7 @@ function commentStart(text, at) {
|
|
|
4416
4497
|
if (WORD_END.test(before) || before === "<" || before === ">") return true;
|
|
4417
4498
|
return text.charAt(at - 2) === "\\" && afterContinuation(text, at);
|
|
4418
4499
|
}
|
|
4419
|
-
|
|
4420
|
-
//#region src/modules/analysis/shell/shell-substitution-lex.ts
|
|
4500
|
+
// src/modules/analysis/shell/shell-substitution-lex.ts
|
|
4421
4501
|
/** Lex the body of a command substitution into segments of its own, under
|
|
4422
4502
|
* the same budget, and keep the commands its heredocs run. */
|
|
4423
4503
|
function lexBody(lex, budget, body) {
|
|
@@ -4525,8 +4605,7 @@ function jumpPast(lex, budget, body) {
|
|
|
4525
4605
|
function lexSubstitution(lex, budget) {
|
|
4526
4606
|
while (lexOne(lex, budget) && !lex.outOfTokens);
|
|
4527
4607
|
}
|
|
4528
|
-
|
|
4529
|
-
//#region src/modules/analysis/shell/shell-scanner.ts
|
|
4608
|
+
// src/modules/analysis/shell/shell-scanner.ts
|
|
4530
4609
|
const SEPARATORS = /* @__PURE__ */ new Set([
|
|
4531
4610
|
";",
|
|
4532
4611
|
"|",
|
|
@@ -4650,8 +4729,7 @@ function lexSegments(command, state = {
|
|
|
4650
4729
|
if (!lex.outOfTokens) flushSegment(lex);
|
|
4651
4730
|
return lex.segments;
|
|
4652
4731
|
}
|
|
4653
|
-
|
|
4654
|
-
//#region src/modules/analysis/walk/command-segments.ts
|
|
4732
|
+
// src/modules/analysis/walk/command-segments.ts
|
|
4655
4733
|
function commandSegments(command) {
|
|
4656
4734
|
return lexSegments(command, {
|
|
4657
4735
|
tokensRemaining: Number.POSITIVE_INFINITY,
|
|
@@ -4664,8 +4742,7 @@ function commandSegments(command) {
|
|
|
4664
4742
|
};
|
|
4665
4743
|
});
|
|
4666
4744
|
}
|
|
4667
|
-
|
|
4668
|
-
//#region src/modules/analysis/walk/directory-tracker.ts
|
|
4745
|
+
// src/modules/analysis/walk/directory-tracker.ts
|
|
4669
4746
|
function applyPendingCd(tracker, operator) {
|
|
4670
4747
|
const pendingCd = tracker.pendingCd;
|
|
4671
4748
|
if (pendingCd === void 0) return;
|
|
@@ -4731,8 +4808,7 @@ function cdTarget(tokens, directory) {
|
|
|
4731
4808
|
if (directory === void 0) return { reason: "relative cd target follows an unresolved working directory" };
|
|
4732
4809
|
return { directory: resolve(directory, target) };
|
|
4733
4810
|
}
|
|
4734
|
-
|
|
4735
|
-
//#region src/modules/analysis/walk/working-directory-segments.ts
|
|
4811
|
+
// src/modules/analysis/walk/working-directory-segments.ts
|
|
4736
4812
|
function shellCommandSegmentsWithDirectory(command, initialDirectory) {
|
|
4737
4813
|
const tracker = {
|
|
4738
4814
|
directory: resolve(initialDirectory),
|
|
@@ -4753,8 +4829,7 @@ function shellCommandSegmentsWithDirectory(command, initialDirectory) {
|
|
|
4753
4829
|
}
|
|
4754
4830
|
return result;
|
|
4755
4831
|
}
|
|
4756
|
-
|
|
4757
|
-
//#region src/modules/analysis/shell/shell-lexer.ts
|
|
4832
|
+
// src/modules/analysis/shell/shell-lexer.ts
|
|
4758
4833
|
/** Ceiling on collected effective commands. Command strings can expand
|
|
4759
4834
|
* combinatorially (a level duplicating its script doubles the output), so
|
|
4760
4835
|
* past this bound collection stops instead of exhausting time or memory on
|
|
@@ -4807,8 +4882,7 @@ function lexSegmentsBounded(command, reading = "default", quoting = "bash") {
|
|
|
4807
4882
|
scripts: bodies.scripts ?? NO_SCRIPTS
|
|
4808
4883
|
};
|
|
4809
4884
|
}
|
|
4810
|
-
|
|
4811
|
-
//#region src/modules/analysis/brake/brake-arguments.ts
|
|
4885
|
+
// src/modules/analysis/brake/brake-arguments.ts
|
|
4812
4886
|
/** A word that reads as an option: a leading `-` with more after it. A lone
|
|
4813
4887
|
* `-` is an operand. */
|
|
4814
4888
|
function isOptionWord(value) {
|
|
@@ -4838,8 +4912,7 @@ function commandName(command) {
|
|
|
4838
4912
|
const first = command[0];
|
|
4839
4913
|
return first === void 0 ? void 0 : basename$1(first.value);
|
|
4840
4914
|
}
|
|
4841
|
-
|
|
4842
|
-
//#region src/modules/analysis/shell/shell-lexer-tables.ts
|
|
4915
|
+
// src/modules/analysis/shell/shell-lexer-tables.ts
|
|
4843
4916
|
const TRANSPARENT_WRAPPERS = /* @__PURE__ */ new Set([
|
|
4844
4917
|
"sudo",
|
|
4845
4918
|
"doas",
|
|
@@ -5084,8 +5157,7 @@ const SHELL_KEYWORDS = /* @__PURE__ */ new Set([
|
|
|
5084
5157
|
"elif",
|
|
5085
5158
|
"!"
|
|
5086
5159
|
]);
|
|
5087
|
-
|
|
5088
|
-
//#region src/modules/analysis/shell/shell-command-strings.ts
|
|
5160
|
+
// src/modules/analysis/shell/shell-command-strings.ts
|
|
5089
5161
|
/** The command string that `script`, a shell or su at `i` runs, or `null`
|
|
5090
5162
|
* when `base` is none of them or carries none. `script -c/--command '…'`
|
|
5091
5163
|
* runs a command string through a shell; without it, script just starts an
|
|
@@ -5163,8 +5235,7 @@ function shellOptionWidth(t) {
|
|
|
5163
5235
|
if (t === "-o" || t === "-O") return 2;
|
|
5164
5236
|
return (t.startsWith("-") || t.startsWith("+")) && t.length > 1 ? 1 : 0;
|
|
5165
5237
|
}
|
|
5166
|
-
|
|
5167
|
-
//#region src/modules/analysis/shell/shell-script-readers.ts
|
|
5238
|
+
// src/modules/analysis/shell/shell-script-readers.ts
|
|
5168
5239
|
/** The words `cat` may have and still pass its stdin on as it is. */
|
|
5169
5240
|
const CAT_PLAIN_WORDS = /* @__PURE__ */ new Set([
|
|
5170
5241
|
"-u",
|
|
@@ -5246,8 +5317,7 @@ function noteLetter(letter, sets, scan) {
|
|
|
5246
5317
|
else if (letter === "s") scan.stdinFlag = true;
|
|
5247
5318
|
else if (letter === "c") scan.command = true;
|
|
5248
5319
|
}
|
|
5249
|
-
|
|
5250
|
-
//#region src/modules/analysis/walk/gnu-long-option-tables.ts
|
|
5320
|
+
// src/modules/analysis/walk/gnu-long-option-tables.ts
|
|
5251
5321
|
const none = (name) => ({
|
|
5252
5322
|
name,
|
|
5253
5323
|
argument: "none"
|
|
@@ -5524,8 +5594,7 @@ const ENV_LONG_OPTIONS = [
|
|
|
5524
5594
|
none("help"),
|
|
5525
5595
|
none("version")
|
|
5526
5596
|
];
|
|
5527
|
-
|
|
5528
|
-
//#region src/modules/analysis/walk/gnu-long-options.ts
|
|
5597
|
+
// src/modules/analysis/walk/gnu-long-options.ts
|
|
5529
5598
|
/** Resolves `--name[=value]` as glibc's getopt_long does; `undefined` means
|
|
5530
5599
|
* the real tool rejects the token and runs nothing. */
|
|
5531
5600
|
function resolveGnuLongOption(token, table) {
|
|
@@ -5550,8 +5619,7 @@ function uniquePrefix(name, table) {
|
|
|
5550
5619
|
const id = first.id ?? first.name;
|
|
5551
5620
|
return candidates.some((option) => (option.id ?? option.name) !== id || option.argument !== first.argument) ? void 0 : first;
|
|
5552
5621
|
}
|
|
5553
|
-
|
|
5554
|
-
//#region src/modules/analysis/shell/shell-wrapper-options.ts
|
|
5622
|
+
// src/modules/analysis/shell/shell-wrapper-options.ts
|
|
5555
5623
|
const ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/;
|
|
5556
5624
|
const NO_VALUE_OPTIONS = /* @__PURE__ */ new Set();
|
|
5557
5625
|
/** Skip leading keywords, then leading VAR=value assignments (env-style,
|
|
@@ -5639,8 +5707,7 @@ function skipWrapperOption(opt, index, valueOpts) {
|
|
|
5639
5707
|
for (let position = 0; position < letters.length; position += 1) if (valueOpts.has(`-${letters.charAt(position)}`)) return position === letters.length - 1 ? index + 2 : index + 1;
|
|
5640
5708
|
return index + 1;
|
|
5641
5709
|
}
|
|
5642
|
-
|
|
5643
|
-
//#region src/modules/analysis/capability/bash-command-tables.ts
|
|
5710
|
+
// src/modules/analysis/capability/bash-command-tables.ts
|
|
5644
5711
|
const INTERPRETERS$1 = /* @__PURE__ */ new Set([
|
|
5645
5712
|
"sh",
|
|
5646
5713
|
"bash",
|
|
@@ -6210,8 +6277,7 @@ const CREDENTIAL_READERS = /* @__PURE__ */ new Set([
|
|
|
6210
6277
|
"source",
|
|
6211
6278
|
"."
|
|
6212
6279
|
]);
|
|
6213
|
-
|
|
6214
|
-
//#region src/modules/analysis/ssh/ssh-value-options.ts
|
|
6280
|
+
// src/modules/analysis/ssh/ssh-value-options.ts
|
|
6215
6281
|
/** The options of OpenSSH's getopt string (`ssh.c`) that take a value. */
|
|
6216
6282
|
const SSH_VALUE_LETTERS = new Set("B D E F I J L O P Q R S W b c e i l m o p w".split(" "));
|
|
6217
6283
|
const SSH_READING = {
|
|
@@ -6287,8 +6353,7 @@ function readSshArguments(words, start, reading = SSH_READING) {
|
|
|
6287
6353
|
terminated: remote.optionsEnded
|
|
6288
6354
|
};
|
|
6289
6355
|
}
|
|
6290
|
-
|
|
6291
|
-
//#region src/modules/analysis/ssh/ssh-arguments.ts
|
|
6356
|
+
// src/modules/analysis/ssh/ssh-arguments.ts
|
|
6292
6357
|
/** The options of autossh's getopt string (`autossh.c` OPTION_STRING) that
|
|
6293
6358
|
* take a value. */
|
|
6294
6359
|
const AUTOSSH_VALUE_LETTERS = new Set("M b c e i l m o p w D E F I L O Q R S W".split(" "));
|
|
@@ -6425,8 +6490,7 @@ function readMoshArguments(words, start) {
|
|
|
6425
6490
|
terminated
|
|
6426
6491
|
};
|
|
6427
6492
|
}
|
|
6428
|
-
|
|
6429
|
-
//#region src/modules/analysis/ssh/autossh-permutation.ts
|
|
6493
|
+
// src/modules/analysis/ssh/autossh-permutation.ts
|
|
6430
6494
|
/** Whether the option word ends in a letter that takes a value, so that
|
|
6431
6495
|
* its value is the next word. */
|
|
6432
6496
|
function takesNextWord(word) {
|
|
@@ -6465,8 +6529,7 @@ function permuteAutosshWords(words, start) {
|
|
|
6465
6529
|
...words.slice(index)
|
|
6466
6530
|
];
|
|
6467
6531
|
}
|
|
6468
|
-
|
|
6469
|
-
//#region src/modules/analysis/ssh/ssh-remote-command.ts
|
|
6532
|
+
// src/modules/analysis/ssh/ssh-remote-command.ts
|
|
6470
6533
|
/** The remote command of the call as one string, or `null` when nothing
|
|
6471
6534
|
* follows the options and host. */
|
|
6472
6535
|
function remoteText(values, call) {
|
|
@@ -6499,8 +6562,7 @@ function remoteCommandTexts(words, i, base, previous) {
|
|
|
6499
6562
|
const old = remoteText(values, readSshArguments(values, i + 1, PREVIOUS_SSH_READING));
|
|
6500
6563
|
return old === text ? [text] : [text, old];
|
|
6501
6564
|
}
|
|
6502
|
-
|
|
6503
|
-
//#region src/modules/analysis/walk/env-long-options.ts
|
|
6565
|
+
// src/modules/analysis/walk/env-long-options.ts
|
|
6504
6566
|
/** The abbreviated long options of the `env` at `i`, each with its index
|
|
6505
6567
|
* and the token written in full, so `--arg x` reads as `--argv0 x` and
|
|
6506
6568
|
* `--split=s` as `--split-string=s`. Option values, ambiguous prefixes and
|
|
@@ -6540,8 +6602,7 @@ function fullSpelling(value) {
|
|
|
6540
6602
|
if (!long.inlineValue) return `--${long.name}`;
|
|
6541
6603
|
return `--${long.name}${value.slice(value.indexOf("="))}`;
|
|
6542
6604
|
}
|
|
6543
|
-
|
|
6544
|
-
//#region src/modules/analysis/walk/env-split-words.ts
|
|
6605
|
+
// src/modules/analysis/walk/env-split-words.ts
|
|
6545
6606
|
const ESCAPES = {
|
|
6546
6607
|
"\"": "\"",
|
|
6547
6608
|
"#": "#",
|
|
@@ -6652,8 +6713,7 @@ function finish(state) {
|
|
|
6652
6713
|
function shellQuote(text) {
|
|
6653
6714
|
return `'${text.replaceAll("'", "'\\''")}'`;
|
|
6654
6715
|
}
|
|
6655
|
-
|
|
6656
|
-
//#region src/modules/analysis/walk/env-split-readings.ts
|
|
6716
|
+
// src/modules/analysis/walk/env-split-readings.ts
|
|
6657
6717
|
/** A first word that, with its quotes and escapes removed, starts with `-`. */
|
|
6658
6718
|
const OPTION_FIRST = /^\s*['"\\]*-/;
|
|
6659
6719
|
/** A string and operands the shell and env split into the same words. */
|
|
@@ -6682,8 +6742,7 @@ function envSplitReadings(script, operands) {
|
|
|
6682
6742
|
}
|
|
6683
6743
|
return texts;
|
|
6684
6744
|
}
|
|
6685
|
-
|
|
6686
|
-
//#region src/modules/analysis/walk/env-split-string.ts
|
|
6745
|
+
// src/modules/analysis/walk/env-split-string.ts
|
|
6687
6746
|
/** `env -S 'command string'` (or unquoted: `env -S cmd args…`) carries a
|
|
6688
6747
|
* parsed command line, and any operands after the string are appended to
|
|
6689
6748
|
* it. The texts `envSplitReadings` makes of the two are what gets
|
|
@@ -6748,8 +6807,7 @@ function splitStringOperand(tokens, index) {
|
|
|
6748
6807
|
tailIndex: index + 1
|
|
6749
6808
|
};
|
|
6750
6809
|
}
|
|
6751
|
-
|
|
6752
|
-
//#region src/modules/analysis/walk/env-readings.ts
|
|
6810
|
+
// src/modules/analysis/walk/env-readings.ts
|
|
6753
6811
|
const TABLES = [
|
|
6754
6812
|
"previous",
|
|
6755
6813
|
"exact",
|
|
@@ -6811,16 +6869,14 @@ function follow(env, words, level, walk, side = false) {
|
|
|
6811
6869
|
if (side) walk.walkTail(words, env.resume, level);
|
|
6812
6870
|
return side ? void 0 : env.resume;
|
|
6813
6871
|
}
|
|
6814
|
-
|
|
6815
|
-
//#region src/modules/analysis/walk/operand-tail-index.ts
|
|
6872
|
+
// src/modules/analysis/walk/operand-tail-index.ts
|
|
6816
6873
|
/** The index where the operand tail of `busybox` or `chroot` at `i` starts,
|
|
6817
6874
|
* or `undefined` for any other command. */
|
|
6818
6875
|
function operandTailIndex(words, i, base) {
|
|
6819
6876
|
if (base === "busybox") return i + 1;
|
|
6820
6877
|
if (base === "chroot") return chrootCommandIndex(words, i);
|
|
6821
6878
|
}
|
|
6822
|
-
|
|
6823
|
-
//#region src/modules/analysis/walk/walk-limits.ts
|
|
6879
|
+
// src/modules/analysis/walk/walk-limits.ts
|
|
6824
6880
|
/** Ceiling on command-string re-entry (`sh -c`, `env -S`, watch, ssh,
|
|
6825
6881
|
* busybox, chroot). Deeper nesting than this is not a legitimate review
|
|
6826
6882
|
* shape; the walk stops descending and the unanalyzed remainder stays the
|
|
@@ -6832,8 +6888,7 @@ const MAX_WALK_DEPTH = 32;
|
|
|
6832
6888
|
function walkLimitReached(sink, depth) {
|
|
6833
6889
|
return depth > MAX_WALK_DEPTH || sink.commands.length >= 4096 || sink.budget.remainingCommands <= 0;
|
|
6834
6890
|
}
|
|
6835
|
-
|
|
6836
|
-
//#region src/modules/analysis/capability/heredoc/heredoc-string-bodies.ts
|
|
6891
|
+
// src/modules/analysis/capability/heredoc/heredoc-string-bodies.ts
|
|
6837
6892
|
/** A shell or ssh word in a string: without one, no command in it reads a
|
|
6838
6893
|
* script from a heredoc. */
|
|
6839
6894
|
const SCRIPT_READER = /\b(?:sh|bash|zsh|dash|ksh|ash|mksh|ssh|busybox)\b/;
|
|
@@ -6847,8 +6902,7 @@ function keepStringBodies(bodies, text) {
|
|
|
6847
6902
|
keepBodyScripts(bodies, read.scripts);
|
|
6848
6903
|
if (read.scripts.size > 0 && SCRIPT_READER.test(read.text)) feedsOf(bodies).commands.push(text);
|
|
6849
6904
|
}
|
|
6850
|
-
|
|
6851
|
-
//#region src/modules/analysis/walk/walk-reanalysis.ts
|
|
6905
|
+
// src/modules/analysis/walk/walk-reanalysis.ts
|
|
6852
6906
|
/** Re-lex a command string for the walk to descend into. Its length is
|
|
6853
6907
|
* charged to the re-analysis budget first, then each substitution body as it
|
|
6854
6908
|
* is lexed. The commands its heredoc bodies run go to the budget's `bodies`,
|
|
@@ -6874,8 +6928,7 @@ function reanalysisSegments(text, sink) {
|
|
|
6874
6928
|
if (lexBudget.tokensRemaining <= 0) sink.truncated = true;
|
|
6875
6929
|
return segments;
|
|
6876
6930
|
}
|
|
6877
|
-
|
|
6878
|
-
//#region src/modules/analysis/walk/watch-command.ts
|
|
6931
|
+
// src/modules/analysis/walk/watch-command.ts
|
|
6879
6932
|
/** The letters of watch's optstring `+bCcefd::ghq:n:prs:twvx` that take a
|
|
6880
6933
|
* value: a required one in the rest of the cluster or the next token, and
|
|
6881
6934
|
* an optional one only in the rest of the cluster. */
|
|
@@ -6949,8 +7002,7 @@ function shortStep$1(opt) {
|
|
|
6949
7002
|
exec
|
|
6950
7003
|
};
|
|
6951
7004
|
}
|
|
6952
|
-
|
|
6953
|
-
//#region src/modules/analysis/walk/effective-command-walk.ts
|
|
7005
|
+
// src/modules/analysis/walk/effective-command-walk.ts
|
|
6954
7006
|
function walk(tokens, sink, inheritedRedirections, depth, remote = false, reading = "both") {
|
|
6955
7007
|
if (walkLimitReached(sink, depth)) {
|
|
6956
7008
|
sink.truncated = true;
|
|
@@ -7035,8 +7087,7 @@ function walkDeeper(tokens, level) {
|
|
|
7035
7087
|
const { sink, redirections, depth, remote, reading } = level;
|
|
7036
7088
|
walk(tokens, sink, redirections, depth + 1, remote, reading);
|
|
7037
7089
|
}
|
|
7038
|
-
|
|
7039
|
-
//#region src/modules/analysis/shell/shell-effective-commands.ts
|
|
7090
|
+
// src/modules/analysis/shell/shell-effective-commands.ts
|
|
7040
7091
|
/**
|
|
7041
7092
|
* Resolve a segment into its "effective commands" — the token lists starting
|
|
7042
7093
|
* at each real executable, after peeling wrappers and destructuring
|
|
@@ -7078,8 +7129,7 @@ function analyzeSegmentRedirections(segment, budget, heads) {
|
|
|
7078
7129
|
stdinShells: sink.stdinShells
|
|
7079
7130
|
};
|
|
7080
7131
|
}
|
|
7081
|
-
|
|
7082
|
-
//#region src/modules/evidence/providers/local-command.ts
|
|
7132
|
+
// src/modules/evidence/providers/local-command.ts
|
|
7083
7133
|
/** Resolve an executable tail only when its local filesystem scope is preserved. */
|
|
7084
7134
|
function localExecutableCommand(tokens) {
|
|
7085
7135
|
const normalized = tokens.map((value) => ({
|
|
@@ -7125,8 +7175,7 @@ function localExecutableCommand(tokens) {
|
|
|
7125
7175
|
prefix
|
|
7126
7176
|
};
|
|
7127
7177
|
}
|
|
7128
|
-
|
|
7129
|
-
//#region src/modules/evidence/git/git-invocation.ts
|
|
7178
|
+
// src/modules/evidence/git/git-invocation.ts
|
|
7130
7179
|
/** Subcommands whose first positional names (or implies) a remote. */
|
|
7131
7180
|
const GIT_REMOTE_COMMANDS = /* @__PURE__ */ new Set([
|
|
7132
7181
|
"push",
|
|
@@ -7202,8 +7251,7 @@ function rebaseBase(tokens, index) {
|
|
|
7202
7251
|
const [base] = bases;
|
|
7203
7252
|
if (!args.includes("--root") && bases.length === 1 && base !== void 0 && !UNRESOLVED_EXPANSION.test(base)) return base;
|
|
7204
7253
|
}
|
|
7205
|
-
|
|
7206
|
-
//#region src/modules/evidence/git/git-network-options.ts
|
|
7254
|
+
// src/modules/evidence/git/git-network-options.ts
|
|
7207
7255
|
/** Options of the network subcommands that consume a separate value token.
|
|
7208
7256
|
* Without skipping the value, `git fetch --depth 1 origin` would report "1"
|
|
7209
7257
|
* as the remote operand and hide the real destination. Options with an
|
|
@@ -7258,8 +7306,7 @@ const NETWORK_VALUE_OPTIONS = {
|
|
|
7258
7306
|
]),
|
|
7259
7307
|
remote: /* @__PURE__ */ new Set()
|
|
7260
7308
|
};
|
|
7261
|
-
|
|
7262
|
-
//#region src/modules/evidence/git/git-remote-operands.ts
|
|
7309
|
+
// src/modules/evidence/git/git-remote-operands.ts
|
|
7263
7310
|
/** Verbs of `git remote` that operate on a named remote as their next
|
|
7264
7311
|
* positional. `update` takes an optional group, not a remote name. */
|
|
7265
7312
|
const REMOTE_VERBS_WITH_NAME = /* @__PURE__ */ new Set([
|
|
@@ -7344,8 +7391,7 @@ function recordRemoteTargets(result, targets) {
|
|
|
7344
7391
|
for (const candidate of targets.candidates) if (result.remoteCandidates.length < MAX_REMOTE_CANDIDATES) result.remoteCandidates.push(candidate);
|
|
7345
7392
|
if (targets.defaultRemote !== void 0 && result.needsDefaultRemote.length < MAX_DEFAULT_REMOTES) result.needsDefaultRemote.push(targets.defaultRemote);
|
|
7346
7393
|
}
|
|
7347
|
-
|
|
7348
|
-
//#region src/modules/evidence/git/git-command-plan.ts
|
|
7394
|
+
// src/modules/evidence/git/git-command-plan.ts
|
|
7349
7395
|
function recordSubcommand(result, tokens, index, subcommand) {
|
|
7350
7396
|
switch (subcommand) {
|
|
7351
7397
|
case "rebase": {
|
|
@@ -7408,8 +7454,7 @@ function boundedList$1(values, max = 200) {
|
|
|
7408
7454
|
omitted: Math.max(0, values.length - max)
|
|
7409
7455
|
};
|
|
7410
7456
|
}
|
|
7411
|
-
|
|
7412
|
-
//#region src/modules/evidence/files/evidence-path-policy.ts
|
|
7457
|
+
// src/modules/evidence/files/evidence-path-policy.ts
|
|
7413
7458
|
const SENSITIVE_PATH$1 = /(?:^|\/)(?:\.env(?:\.|$)|\.ssh(?:\/|$)|\.aws(?:\/|$)|\.config\/(?:gh|gcloud)(?:\/|$)|id_(?:rsa|dsa|ecdsa|ed25519)(?:\.pub)?$|credentials(?:\.json)?$|authorized_keys$|known_hosts$|\.npmrc$|\.pypirc$|\.netrc$)/i;
|
|
7414
7459
|
/** Whether `path` equals `root` or lives somewhere below it. */
|
|
7415
7460
|
function isWithinRoot(path, root) {
|
|
@@ -7459,8 +7504,7 @@ function resolvedPathBlock(path, roots, outsideReason) {
|
|
|
7459
7504
|
if (!roots.some((root) => isWithinRoot(path, root))) return outsideReason;
|
|
7460
7505
|
if (SENSITIVE_PATH$1.test(path)) return "sensitive resolved path";
|
|
7461
7506
|
}
|
|
7462
|
-
|
|
7463
|
-
//#region src/modules/evidence/git/git-run.ts
|
|
7507
|
+
// src/modules/evidence/git/git-run.ts
|
|
7464
7508
|
const execFileAsync = promisify(execFile);
|
|
7465
7509
|
function gitInspectionEnv() {
|
|
7466
7510
|
return {
|
|
@@ -7497,8 +7541,7 @@ async function runGit(directory, args, neutralization = []) {
|
|
|
7497
7541
|
};
|
|
7498
7542
|
}
|
|
7499
7543
|
}
|
|
7500
|
-
|
|
7501
|
-
//#region src/modules/evidence/git/git-filter-neutralization.ts
|
|
7544
|
+
// src/modules/evidence/git/git-filter-neutralization.ts
|
|
7502
7545
|
/** Git inspection must never execute repository-configured extensions before
|
|
7503
7546
|
* the permission decision. Conversion filters (`clean`/`smudge`/`process`)
|
|
7504
7547
|
* and diff `textconv` drivers are shell commands from git config; disabling
|
|
@@ -7607,8 +7650,7 @@ function noMatchArgsOrRethrow(error) {
|
|
|
7607
7650
|
if (error.code === 1) return [];
|
|
7608
7651
|
throw error instanceof Error ? error : new Error(String(error));
|
|
7609
7652
|
}
|
|
7610
|
-
|
|
7611
|
-
//#region src/modules/evidence/git/git-status-porcelain.ts
|
|
7653
|
+
// src/modules/evidence/git/git-status-porcelain.ts
|
|
7612
7654
|
const UNMERGED_STATUSES = [
|
|
7613
7655
|
"DD",
|
|
7614
7656
|
"AU",
|
|
@@ -7645,8 +7687,7 @@ function recordStatusLine(status, line) {
|
|
|
7645
7687
|
if (x !== " ") status.staged.push(path);
|
|
7646
7688
|
if (y !== " ") status.unstaged.push(path);
|
|
7647
7689
|
}
|
|
7648
|
-
|
|
7649
|
-
//#region src/modules/evidence/git/git-inspection-gate.ts
|
|
7690
|
+
// src/modules/evidence/git/git-inspection-gate.ts
|
|
7650
7691
|
async function verifiedInspection(planned, directory, worktree) {
|
|
7651
7692
|
if (!planned.executionDirectory) return {
|
|
7652
7693
|
ok: false,
|
|
@@ -7706,8 +7747,7 @@ async function repositoryState(gitDirectory, roots, neutralization) {
|
|
|
7706
7747
|
status: parseStatus(status.stdout)
|
|
7707
7748
|
};
|
|
7708
7749
|
}
|
|
7709
|
-
|
|
7710
|
-
//#region src/modules/evidence/git/git-remote-identity.ts
|
|
7750
|
+
// src/modules/evidence/git/git-remote-identity.ts
|
|
7711
7751
|
/** A remote operand can be a configured remote name, a literal URL, an
|
|
7712
7752
|
* SCP-like `user@host:path` target, or a local path. Only syntactic
|
|
7713
7753
|
* classification happens here; configured names are resolved to URLs later,
|
|
@@ -7751,8 +7791,7 @@ function urlRepositoryPath(value) {
|
|
|
7751
7791
|
function isGithubTransport(url) {
|
|
7752
7792
|
return url.protocol === "https:" && (url.port === "" || url.port === "443") || url.protocol === "ssh:" && url.username === "git" && (url.port === "" || url.port === "22");
|
|
7753
7793
|
}
|
|
7754
|
-
|
|
7755
|
-
//#region src/modules/evidence/git/git-configured-remote.ts
|
|
7794
|
+
// src/modules/evidence/git/git-configured-remote.ts
|
|
7756
7795
|
const MAX_PUSH_URLS = 5;
|
|
7757
7796
|
/** Push affects every configured pushurl (or every url when no pushurl
|
|
7758
7797
|
* exists), so resolution uses `get-url --push --all`: reporting only the
|
|
@@ -7788,8 +7827,7 @@ function resolutionNote(pushUrls, fetchUrl) {
|
|
|
7788
7827
|
if (pushUrls === void 0) return "push URL resolution failed";
|
|
7789
7828
|
if (fetchUrl === void 0) return "fetch URL resolution failed";
|
|
7790
7829
|
}
|
|
7791
|
-
|
|
7792
|
-
//#region src/modules/evidence/git/git-url-rewrites.ts
|
|
7830
|
+
// src/modules/evidence/git/git-url-rewrites.ts
|
|
7793
7831
|
async function literalUrlRewrites(directory, neutralization) {
|
|
7794
7832
|
const config = await runGit(directory, [
|
|
7795
7833
|
"config",
|
|
@@ -7832,8 +7870,7 @@ function literalUrls(input, rewrites) {
|
|
|
7832
7870
|
...pushUrl === void 0 || fetchUrl === void 0 ? { note: "literal URL rewrite configuration is unavailable or ambiguous" } : {}
|
|
7833
7871
|
};
|
|
7834
7872
|
}
|
|
7835
|
-
|
|
7836
|
-
//#region src/modules/evidence/git/git-candidate-target.ts
|
|
7873
|
+
// src/modules/evidence/git/git-candidate-target.ts
|
|
7837
7874
|
async function remoteTarget(input, rewrites, configuredNames, resolveRemote) {
|
|
7838
7875
|
const bounded = sanitizeRemoteUrl(input).slice(0, 200);
|
|
7839
7876
|
if (remoteOperandKind(input) === "literal") return literalTarget(input, bounded, rewrites, configuredNames, resolveRemote);
|
|
@@ -7873,8 +7910,7 @@ function roleMatch(name, urls, pushIdentity, fetchIdentity) {
|
|
|
7873
7910
|
fetch: fetchIdentity !== void 0 && urls.fetchUrl !== void 0 && repositoryIdentity(urls.fetchUrl) === fetchIdentity
|
|
7874
7911
|
};
|
|
7875
7912
|
}
|
|
7876
|
-
|
|
7877
|
-
//#region src/modules/evidence/git/git-default-remote.ts
|
|
7913
|
+
// src/modules/evidence/git/git-default-remote.ts
|
|
7878
7914
|
async function defaultRemoteRecords(directory, annotations, configuredNames, neutralization, resolveRemote) {
|
|
7879
7915
|
const defaults = [];
|
|
7880
7916
|
for (const annotation of annotations) {
|
|
@@ -7954,8 +7990,7 @@ async function resolveDefaultRemote(directory, annotation, configuredNames, neut
|
|
|
7954
7990
|
note: `no branch.${branchName}.remote, no remote.pushDefault, and no origin remote is configured`
|
|
7955
7991
|
};
|
|
7956
7992
|
}
|
|
7957
|
-
|
|
7958
|
-
//#region src/modules/evidence/git/git-remote-targets.ts
|
|
7993
|
+
// src/modules/evidence/git/git-remote-targets.ts
|
|
7959
7994
|
/** Resolve the collected remote operands against the repository's configured
|
|
7960
7995
|
* remotes, all through the neutralized, contained git runner. Every
|
|
7961
7996
|
* resolution failure stays a visible fact, never an invention. */
|
|
@@ -7985,8 +8020,7 @@ async function resolveRemoteTargets(directory, planned, configuredNames, neutral
|
|
|
7985
8020
|
defaults
|
|
7986
8021
|
};
|
|
7987
8022
|
}
|
|
7988
|
-
|
|
7989
|
-
//#region src/modules/evidence/git/git-remote-evidence.ts
|
|
8023
|
+
// src/modules/evidence/git/git-remote-evidence.ts
|
|
7990
8024
|
/** Remote operands only resolve inside the containment envelope, after the
|
|
7991
8025
|
* repository root has been verified: `git remote`/`get-url` are plain config
|
|
7992
8026
|
* reads, but running them anywhere would inspect an arbitrary repository.
|
|
@@ -8011,8 +8045,7 @@ async function remoteRecord(gitDirectory, planned, neutralization) {
|
|
|
8011
8045
|
configuredRemotes: configuredNames
|
|
8012
8046
|
};
|
|
8013
8047
|
}
|
|
8014
|
-
|
|
8015
|
-
//#region src/modules/evidence/git/git-rewrite-evidence.ts
|
|
8048
|
+
// src/modules/evidence/git/git-rewrite-evidence.ts
|
|
8016
8049
|
async function rewriteEvidence(directory, planned, neutralization) {
|
|
8017
8050
|
if (!planned.commands.includes("rebase")) return void 0;
|
|
8018
8051
|
const base = planned.rewriteBases[0];
|
|
@@ -8079,8 +8112,7 @@ async function rewriteEvidence(directory, planned, neutralization) {
|
|
|
8079
8112
|
note: "read-only local snapshot; remote-tracking refs may be stale and absence is not proof of unpublished history"
|
|
8080
8113
|
};
|
|
8081
8114
|
}
|
|
8082
|
-
|
|
8083
|
-
//#region src/modules/evidence/git/git-state-record.ts
|
|
8115
|
+
// src/modules/evidence/git/git-state-record.ts
|
|
8084
8116
|
function unresolved(values) {
|
|
8085
8117
|
return values.filter((value) => UNRESOLVED_EXPANSION.test(value));
|
|
8086
8118
|
}
|
|
@@ -8143,8 +8175,7 @@ function numstatRecord(targetDiff) {
|
|
|
8143
8175
|
if (targetDiff === void 0) return {};
|
|
8144
8176
|
return targetDiff.ok ? { affectedTargetNumstat: targetDiff.stdout.slice(0, 8e3) || "<no unstaged diff>" } : { affectedTargetNumstat: `<unavailable: ${targetDiff.reason}>` };
|
|
8145
8177
|
}
|
|
8146
|
-
|
|
8147
|
-
//#region src/modules/evidence/git/git-evidence.ts
|
|
8178
|
+
// src/modules/evidence/git/git-evidence.ts
|
|
8148
8179
|
function unavailable(reason, planned, maxChars) {
|
|
8149
8180
|
return { text: `GIT_STATE_ANALYSIS\n${JSON.stringify({
|
|
8150
8181
|
status: "unavailable",
|
|
@@ -8165,8 +8196,7 @@ async function enrichGitEvidence(request, directory, maxChars, worktree) {
|
|
|
8165
8196
|
const serialized = JSON.stringify(await stateRecord(planned, inspection), null, 2);
|
|
8166
8197
|
return { text: `GIT_STATE_ANALYSIS\n${serialized.length <= maxChars ? serialized : `${serialized.slice(0, maxChars)}\n<git_enrichment_truncated characters="${serialized.length - maxChars}" />`}` };
|
|
8167
8198
|
}
|
|
8168
|
-
|
|
8169
|
-
//#region src/modules/evidence/providers/git-provider.ts
|
|
8199
|
+
// src/modules/evidence/providers/git-provider.ts
|
|
8170
8200
|
/**
|
|
8171
8201
|
* Wraps {@link enrichGitEvidence} behind the {@link EvidenceProvider} surface.
|
|
8172
8202
|
* Git evidence resolves the repository from the planned command's directory,
|
|
@@ -8184,8 +8214,7 @@ var GitEvidenceProvider = class {
|
|
|
8184
8214
|
};
|
|
8185
8215
|
}
|
|
8186
8216
|
};
|
|
8187
|
-
|
|
8188
|
-
//#region src/modules/analysis/walk/interpreter-options.ts
|
|
8217
|
+
// src/modules/analysis/walk/interpreter-options.ts
|
|
8189
8218
|
const INLINE_CODE_OPTIONS = /* @__PURE__ */ new Set([
|
|
8190
8219
|
"-c",
|
|
8191
8220
|
"-e",
|
|
@@ -8225,8 +8254,7 @@ function runsInlineCode(token, spec) {
|
|
|
8225
8254
|
function stopsBeforeTarget(token, interpreter, spec) {
|
|
8226
8255
|
return isInformationFlag(token, interpreter) || token === "-" || runsInlineCode(token, spec) || token.startsWith("-m") || spec?.bailOptions !== void 0 && matchesOption(token, spec.bailOptions);
|
|
8227
8256
|
}
|
|
8228
|
-
|
|
8229
|
-
//#region src/modules/analysis/walk/interpreter-specs.ts
|
|
8257
|
+
// src/modules/analysis/walk/interpreter-specs.ts
|
|
8230
8258
|
const BUN_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
8231
8259
|
"add",
|
|
8232
8260
|
"build",
|
|
@@ -8334,8 +8362,7 @@ const INTERPRETER_SPECS = {
|
|
|
8334
8362
|
])
|
|
8335
8363
|
}
|
|
8336
8364
|
};
|
|
8337
|
-
|
|
8338
|
-
//#region src/modules/analysis/walk/interpreter-script-target.ts
|
|
8365
|
+
// src/modules/analysis/walk/interpreter-script-target.ts
|
|
8339
8366
|
const STOP = {
|
|
8340
8367
|
done: true,
|
|
8341
8368
|
target: void 0
|
|
@@ -8395,16 +8422,14 @@ function scriptPath(tokens, interpreterIndex, interpreter) {
|
|
|
8395
8422
|
index += step.skip;
|
|
8396
8423
|
}
|
|
8397
8424
|
}
|
|
8398
|
-
|
|
8399
|
-
//#region src/modules/evidence/files/file-evidence.ts
|
|
8425
|
+
// src/modules/evidence/files/file-evidence.ts
|
|
8400
8426
|
function sha256(value) {
|
|
8401
8427
|
return createHash("sha256").update(value).digest("hex");
|
|
8402
8428
|
}
|
|
8403
8429
|
function isMissingFile(result) {
|
|
8404
8430
|
return result.status === "unavailable" && /\bENOENT\b|no such file or directory/i.test(result.reason ?? "");
|
|
8405
8431
|
}
|
|
8406
|
-
|
|
8407
|
-
//#region src/modules/evidence/files/evidence-content.ts
|
|
8432
|
+
// src/modules/evidence/files/evidence-content.ts
|
|
8408
8433
|
const SENSITIVE_CONTENT = /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:sk|nvapi)-[A-Za-z0-9_-]{16,}|\b(?:ghp|gho|ghs|ghr|ghu)_[A-Za-z0-9_-]{16,}|\bgithub_pat_[A-Za-z0-9_-]{16,}|\b(?:api[_-]?key|access[_-]?token|password)\s*[:=]\s*["'][^"'\n]{8,}["']/i;
|
|
8409
8434
|
async function fillBuffer(handle, buffer) {
|
|
8410
8435
|
let bytesRead = 0;
|
|
@@ -8445,8 +8470,7 @@ function contentEvidence(path, buffer, bytesRead, size, limit) {
|
|
|
8445
8470
|
content
|
|
8446
8471
|
};
|
|
8447
8472
|
}
|
|
8448
|
-
|
|
8449
|
-
//#region src/modules/evidence/files/evidence-file-reader.ts
|
|
8473
|
+
// src/modules/evidence/files/evidence-file-reader.ts
|
|
8450
8474
|
const O_RDONLY$1 = typeof constants.O_RDONLY === "number" ? constants.O_RDONLY : 0;
|
|
8451
8475
|
const O_NOFOLLOW$1 = typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
|
|
8452
8476
|
const O_NONBLOCK$1 = typeof constants.O_NONBLOCK === "number" ? constants.O_NONBLOCK : 0;
|
|
@@ -8516,8 +8540,7 @@ async function includeEvidenceFile(source, directory, rootDirectory, worktree, m
|
|
|
8516
8540
|
await new Promise((resolveDelay) => setTimeout(resolveDelay, 100));
|
|
8517
8541
|
return includeFileOnce(source, directory, rootDirectory, worktree, maxChars);
|
|
8518
8542
|
}
|
|
8519
|
-
|
|
8520
|
-
//#region src/modules/evidence/files/evidence-signals.ts
|
|
8543
|
+
// src/modules/evidence/files/evidence-signals.ts
|
|
8521
8544
|
function commandSignals(remoteCommand, hasStdin) {
|
|
8522
8545
|
return {
|
|
8523
8546
|
stagingHint: /\bstag(?:e|ing)?\b/i.test(remoteCommand),
|
|
@@ -8543,8 +8566,7 @@ function stdinSignals(stdin) {
|
|
|
8543
8566
|
if (!stdin?.content) return;
|
|
8544
8567
|
return analyzeScriptContent(stdin.content);
|
|
8545
8568
|
}
|
|
8546
|
-
|
|
8547
|
-
//#region src/modules/evidence/local-script/local-script-record.ts
|
|
8569
|
+
// src/modules/evidence/local-script/local-script-record.ts
|
|
8548
8570
|
function recordFor(interpreter, path, file) {
|
|
8549
8571
|
return {
|
|
8550
8572
|
kind: "local_script",
|
|
@@ -8566,8 +8588,7 @@ function localScriptText(records, maxChars) {
|
|
|
8566
8588
|
const serialized = JSON.stringify(records, null, 2);
|
|
8567
8589
|
return `LOCAL_SCRIPT_ANALYSIS\n${serialized.length <= maxChars ? serialized : `${serialized.slice(0, maxChars)}\n<local_script_enrichment_truncated characters="${serialized.length - maxChars}" />`}`;
|
|
8568
8590
|
}
|
|
8569
|
-
|
|
8570
|
-
//#region src/modules/evidence/local-script/local-script-evidence.ts
|
|
8591
|
+
// src/modules/evidence/local-script/local-script-evidence.ts
|
|
8571
8592
|
const INTERPRETERS = /* @__PURE__ */ new Set([
|
|
8572
8593
|
"python",
|
|
8573
8594
|
"python3",
|
|
@@ -8624,8 +8645,7 @@ async function enrichLocalScriptEvidence(request, directory, worktree, maxChars,
|
|
|
8624
8645
|
}
|
|
8625
8646
|
return { text: localScriptText(records, maxChars) };
|
|
8626
8647
|
}
|
|
8627
|
-
|
|
8628
|
-
//#region src/modules/evidence/providers/local-script-provider.ts
|
|
8648
|
+
// src/modules/evidence/providers/local-script-provider.ts
|
|
8629
8649
|
/**
|
|
8630
8650
|
* Wraps {@link enrichLocalScriptEvidence} behind the {@link EvidenceProvider}
|
|
8631
8651
|
* surface. Produces text only (no audit trail, no preflight denial).
|
|
@@ -8639,8 +8659,7 @@ var LocalScriptEvidenceProvider = class {
|
|
|
8639
8659
|
};
|
|
8640
8660
|
}
|
|
8641
8661
|
};
|
|
8642
|
-
|
|
8643
|
-
//#region src/modules/evidence/package-script/package-script-invocation.ts
|
|
8662
|
+
// src/modules/evidence/package-script/package-script-invocation.ts
|
|
8644
8663
|
const MANAGERS = /* @__PURE__ */ new Set([
|
|
8645
8664
|
"bun",
|
|
8646
8665
|
"npm",
|
|
@@ -8699,8 +8718,7 @@ function invocation(tokens) {
|
|
|
8699
8718
|
...scan.ambiguous ? { unresolved: "runtime directory or workspace selection is not resolved" } : {}
|
|
8700
8719
|
};
|
|
8701
8720
|
}
|
|
8702
|
-
|
|
8703
|
-
//#region src/modules/evidence/package-script/package-script-calls.ts
|
|
8721
|
+
// src/modules/evidence/package-script/package-script-calls.ts
|
|
8704
8722
|
const REMOTE_OR_PRIVILEGED = [
|
|
8705
8723
|
"ssh",
|
|
8706
8724
|
"chroot",
|
|
@@ -8735,8 +8753,7 @@ function scriptCalls(tokens) {
|
|
|
8735
8753
|
}] : [];
|
|
8736
8754
|
});
|
|
8737
8755
|
}
|
|
8738
|
-
|
|
8739
|
-
//#region src/modules/evidence/package-script/package-manifest-search.ts
|
|
8756
|
+
// src/modules/evidence/package-script/package-manifest-search.ts
|
|
8740
8757
|
const MAX_MANIFEST_DEPTH = 8;
|
|
8741
8758
|
function pathExists(path) {
|
|
8742
8759
|
return lstat(path).then(() => true).catch(() => false);
|
|
@@ -8799,8 +8816,7 @@ var ManifestCache = class {
|
|
|
8799
8816
|
return pending;
|
|
8800
8817
|
}
|
|
8801
8818
|
};
|
|
8802
|
-
|
|
8803
|
-
//#region src/modules/evidence/package-script/package-script-records.ts
|
|
8819
|
+
// src/modules/evidence/package-script/package-script-records.ts
|
|
8804
8820
|
function recordBase(call, phase) {
|
|
8805
8821
|
return {
|
|
8806
8822
|
manager: call.manager,
|
|
@@ -8847,8 +8863,7 @@ function includedRecord(base, directory, manifest, command) {
|
|
|
8847
8863
|
status: "included"
|
|
8848
8864
|
};
|
|
8849
8865
|
}
|
|
8850
|
-
|
|
8851
|
-
//#region src/modules/evidence/package-script/package-script-expansion.ts
|
|
8866
|
+
// src/modules/evidence/package-script/package-script-expansion.ts
|
|
8852
8867
|
const MAX_SCRIPT_DEPTH = 4;
|
|
8853
8868
|
var ScriptExpansion = class {
|
|
8854
8869
|
records = [];
|
|
@@ -8910,8 +8925,7 @@ var ScriptExpansion = class {
|
|
|
8910
8925
|
for (const segment of shellCommandSegmentsWithDirectory(command, pkgDirectory)) for (const child of scriptCalls(segment.tokens)) await this.visit(child, segment.directory, depth + 1);
|
|
8911
8926
|
}
|
|
8912
8927
|
};
|
|
8913
|
-
|
|
8914
|
-
//#region src/modules/evidence/package-script/package-script-evidence.ts
|
|
8928
|
+
// src/modules/evidence/package-script/package-script-evidence.ts
|
|
8915
8929
|
function serializeRecords(records) {
|
|
8916
8930
|
return JSON.stringify({
|
|
8917
8931
|
coverage: "manifest definitions and literal local calls only; imported code and runtime configuration may add effects",
|
|
@@ -8943,19 +8957,39 @@ function boundedText$1(records, maxChars) {
|
|
|
8943
8957
|
});
|
|
8944
8958
|
return `PACKAGE_SCRIPT_ANALYSIS\n${text}`;
|
|
8945
8959
|
}
|
|
8960
|
+
/**
|
|
8961
|
+
* Followed to its real path because package managers search parent manifests
|
|
8962
|
+
* physically. Undefined unless it is an existing directory, so another
|
|
8963
|
+
* directory's manifest is never reported as the target.
|
|
8964
|
+
*/
|
|
8965
|
+
async function shellWorkdir(request, directory) {
|
|
8966
|
+
const input = request.metadata.toolInput;
|
|
8967
|
+
if (!isRecord(input)) return directory;
|
|
8968
|
+
const workdir = input.workdir;
|
|
8969
|
+
if (workdir === void 0 || typeof workdir === "string" && workdir.trim() === "") return directory;
|
|
8970
|
+
if (typeof workdir !== "string" || workdir.includes("\0")) return void 0;
|
|
8971
|
+
const resolved = resolve(directory, workdir);
|
|
8972
|
+
if (resolved === resolve(directory)) return directory;
|
|
8973
|
+
try {
|
|
8974
|
+
const real = await realpath(resolved);
|
|
8975
|
+
return (await stat(real)).isDirectory() ? real : void 0;
|
|
8976
|
+
} catch {
|
|
8977
|
+
return;
|
|
8978
|
+
}
|
|
8979
|
+
}
|
|
8946
8980
|
/** Read manifest definitions and literal local calls; never execute package code. */
|
|
8947
8981
|
async function enrichPackageScriptEvidence(request, directory, worktree, maxChars) {
|
|
8948
8982
|
if (request.permission !== "bash") return { text: "" };
|
|
8983
|
+
const workdir = await shellWorkdir(request, directory);
|
|
8949
8984
|
const expansion = new ScriptExpansion(request, {
|
|
8950
8985
|
directory,
|
|
8951
8986
|
worktree,
|
|
8952
8987
|
maxChars
|
|
8953
8988
|
});
|
|
8954
|
-
for (const segment of shellCommandSegmentsWithDirectory(sourceCommand(request), directory)) for (const call of scriptCalls(segment.tokens)) await expansion.visit(call, segment.directory, 0);
|
|
8989
|
+
for (const segment of shellCommandSegmentsWithDirectory(sourceCommand(request), workdir ?? directory)) for (const call of scriptCalls(segment.tokens)) await expansion.visit(call, workdir === void 0 ? void 0 : segment.directory, 0);
|
|
8955
8990
|
return { text: boundedText$1(expansion.records, maxChars) };
|
|
8956
8991
|
}
|
|
8957
|
-
|
|
8958
|
-
//#region src/modules/evidence/providers/package-script-provider.ts
|
|
8992
|
+
// src/modules/evidence/providers/package-script-provider.ts
|
|
8959
8993
|
var PackageScriptEvidenceProvider = class {
|
|
8960
8994
|
id = "package_script";
|
|
8961
8995
|
async collect(input) {
|
|
@@ -8965,8 +8999,7 @@ var PackageScriptEvidenceProvider = class {
|
|
|
8965
8999
|
};
|
|
8966
9000
|
}
|
|
8967
9001
|
};
|
|
8968
|
-
|
|
8969
|
-
//#region src/modules/evidence/ssh/ssh-destination.ts
|
|
9002
|
+
// src/modules/evidence/ssh/ssh-destination.ts
|
|
8970
9003
|
/** The parts of an ssh destination word. `ssh://[user@]host[:port][/path]` is
|
|
8971
9004
|
* a URI (`parse_uri`): its user ends at the first `@` and at a `;`, and may
|
|
8972
9005
|
* be percent-encoded. A URI `ssh` rejects (a bad escape, an empty user or
|
|
@@ -9010,8 +9043,7 @@ function urlDecode(text) {
|
|
|
9010
9043
|
if (bytes.includes(0)) return;
|
|
9011
9044
|
return new TextDecoder().decode(Uint8Array.from(bytes));
|
|
9012
9045
|
}
|
|
9013
|
-
|
|
9014
|
-
//#region src/modules/evidence/ssh/ssh-option-values.ts
|
|
9046
|
+
// src/modules/evidence/ssh/ssh-option-values.ts
|
|
9015
9047
|
/** Records the value options in `tokens[start..end)`; a `--` closing the range is skipped. */
|
|
9016
9048
|
function recordSshOptions(tokens, start, end, options) {
|
|
9017
9049
|
for (let index = start; index < end;) {
|
|
@@ -9046,8 +9078,7 @@ function recordConfigOption(line, options) {
|
|
|
9046
9078
|
const field = CONFIG_OPTION_FIELDS.get(match[1]?.toLowerCase() ?? "");
|
|
9047
9079
|
if (field) options[field] ??= match[2]?.trimEnd();
|
|
9048
9080
|
}
|
|
9049
|
-
|
|
9050
|
-
//#region src/modules/evidence/ssh/ssh-login-user.ts
|
|
9081
|
+
// src/modules/evidence/ssh/ssh-login-user.ts
|
|
9051
9082
|
/** The user of ssh's arguments from `start`, the word after `ssh`: the first
|
|
9052
9083
|
* one set by `-l` or `-o User=` before the destination, the destination's
|
|
9053
9084
|
* `user@` or URI user, then `-l` or `-o User=` after the destination. A
|
|
@@ -9065,8 +9096,7 @@ function sshLoginUser(words, start) {
|
|
|
9065
9096
|
recordSshOptions(words, destination + 1, remoteCommand ?? words.length, options);
|
|
9066
9097
|
return options.user;
|
|
9067
9098
|
}
|
|
9068
|
-
|
|
9069
|
-
//#region src/modules/evidence/ssh/ssh-command-segments.ts
|
|
9099
|
+
// src/modules/evidence/ssh/ssh-command-segments.ts
|
|
9070
9100
|
function findSshIndex(tokens) {
|
|
9071
9101
|
return tokens.findIndex((token) => basename(token) === "ssh");
|
|
9072
9102
|
}
|
|
@@ -9121,8 +9151,7 @@ function catSource(tokens) {
|
|
|
9121
9151
|
if (UNRESOLVED_EXPANSION.test(source)) return;
|
|
9122
9152
|
return source;
|
|
9123
9153
|
}
|
|
9124
|
-
|
|
9125
|
-
//#region src/modules/evidence/ssh/ssh-record.ts
|
|
9154
|
+
// src/modules/evidence/ssh/ssh-record.ts
|
|
9126
9155
|
function sshRecord(parsed, preceding, stdin, remoteCommandSha256) {
|
|
9127
9156
|
const analyzedStdin = stdinSignals(stdin);
|
|
9128
9157
|
return {
|
|
@@ -9147,8 +9176,7 @@ function stdinField(stdin, preceding) {
|
|
|
9147
9176
|
reason: "pipeline producer is not one regular cat file"
|
|
9148
9177
|
} } : {};
|
|
9149
9178
|
}
|
|
9150
|
-
|
|
9151
|
-
//#region src/modules/evidence/ssh/ssh-stdin-source.ts
|
|
9179
|
+
// src/modules/evidence/ssh/ssh-stdin-source.ts
|
|
9152
9180
|
function pipelineProducer(segments, segmentIndex) {
|
|
9153
9181
|
let producerIndex = segmentIndex - 1;
|
|
9154
9182
|
let producer = segments[producerIndex];
|
|
@@ -9173,8 +9201,7 @@ function deterministicDenial(stdin) {
|
|
|
9173
9201
|
if (!stdin) return;
|
|
9174
9202
|
if (isMissingFile(stdin)) return `The file sent over stdin does not exist after a second check: ${stdin.path}. Create it and retry the command.`;
|
|
9175
9203
|
}
|
|
9176
|
-
|
|
9177
|
-
//#region src/modules/evidence/ssh/ssh-evidence.ts
|
|
9204
|
+
// src/modules/evidence/ssh/ssh-evidence.ts
|
|
9178
9205
|
async function enrichSshEvidence(request, directory, worktree, maxChars) {
|
|
9179
9206
|
if (request.permission !== "bash") return {
|
|
9180
9207
|
text: "",
|
|
@@ -9233,8 +9260,7 @@ function boundedRecords(records, maxChars) {
|
|
|
9233
9260
|
const serialized = JSON.stringify(records, null, 2);
|
|
9234
9261
|
return serialized.length <= maxChars ? serialized : `${serialized.slice(0, maxChars)}\n<ssh_enrichment_truncated characters="${serialized.length - maxChars}" />`;
|
|
9235
9262
|
}
|
|
9236
|
-
|
|
9237
|
-
//#region src/modules/evidence/providers/ssh-provider.ts
|
|
9263
|
+
// src/modules/evidence/providers/ssh-provider.ts
|
|
9238
9264
|
/**
|
|
9239
9265
|
* Wraps {@link enrichSshEvidence} behind the {@link EvidenceProvider} surface so
|
|
9240
9266
|
* the assembler can treat all evidence sources uniformly. SSH is the only
|
|
@@ -9252,8 +9278,7 @@ var SshEvidenceProvider = class {
|
|
|
9252
9278
|
};
|
|
9253
9279
|
}
|
|
9254
9280
|
};
|
|
9255
|
-
|
|
9256
|
-
//#region src/modules/evidence/ssh/verified-ssh-command.ts
|
|
9281
|
+
// src/modules/evidence/ssh/verified-ssh-command.ts
|
|
9257
9282
|
/** This exact shell form binds the locally reviewed bytes to the remote ones.
|
|
9258
9283
|
* The remote hash check runs before the interpreter, even if the file changes
|
|
9259
9284
|
* between permission review and execution. */
|
|
@@ -9295,8 +9320,7 @@ function verifiedCommandParts(command) {
|
|
|
9295
9320
|
remote
|
|
9296
9321
|
};
|
|
9297
9322
|
}
|
|
9298
|
-
|
|
9299
|
-
//#region src/modules/context/services/provenance.ts
|
|
9323
|
+
// src/modules/context/services/provenance.ts
|
|
9300
9324
|
function prov(value, source, confidence, notes) {
|
|
9301
9325
|
return notes === void 0 ? {
|
|
9302
9326
|
value,
|
|
@@ -9309,8 +9333,7 @@ function prov(value, source, confidence, notes) {
|
|
|
9309
9333
|
notes
|
|
9310
9334
|
};
|
|
9311
9335
|
}
|
|
9312
|
-
|
|
9313
|
-
//#region src/modules/context/services/actor-identity.ts
|
|
9336
|
+
// src/modules/context/services/actor-identity.ts
|
|
9314
9337
|
const UNKNOWN_STRING = prov(void 0, "unavailable", "unknown");
|
|
9315
9338
|
const UNKNOWN_PROFILE = prov("unknown", "unavailable", "unknown");
|
|
9316
9339
|
/**
|
|
@@ -9373,8 +9396,7 @@ function identityCompletenessOf(current) {
|
|
|
9373
9396
|
if (current.agentName !== void 0 || current.mode !== void 0) return "partial";
|
|
9374
9397
|
return "unknown";
|
|
9375
9398
|
}
|
|
9376
|
-
|
|
9377
|
-
//#region src/modules/context/models/unknown-resolution.ts
|
|
9399
|
+
// src/modules/context/models/unknown-resolution.ts
|
|
9378
9400
|
/** Fallback used when resolution fails outright. */
|
|
9379
9401
|
function unknownResolution(request, error) {
|
|
9380
9402
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -9421,8 +9443,7 @@ function unknownResolution(request, error) {
|
|
|
9421
9443
|
}
|
|
9422
9444
|
};
|
|
9423
9445
|
}
|
|
9424
|
-
|
|
9425
|
-
//#region src/modules/context/services/delegated-tasks.ts
|
|
9446
|
+
// src/modules/context/services/delegated-tasks.ts
|
|
9426
9447
|
function promptOrDescription(record) {
|
|
9427
9448
|
return typeof record?.prompt === "string" ? record.prompt : typeof record?.description === "string" ? record.description : void 0;
|
|
9428
9449
|
}
|
|
@@ -9476,8 +9497,7 @@ function extractDelegatedTasks(messages, sessionID, childSessionID) {
|
|
|
9476
9497
|
}
|
|
9477
9498
|
return blocks;
|
|
9478
9499
|
}
|
|
9479
|
-
|
|
9480
|
-
//#region src/modules/context/services/intent-assessment.ts
|
|
9500
|
+
// src/modules/context/services/intent-assessment.ts
|
|
9481
9501
|
/** Pick by creation time, not by array position: the intent arrays are
|
|
9482
9502
|
* concatenated local → parent → root, so the last element is the root's
|
|
9483
9503
|
* latest message even when the current session holds much newer input. When
|
|
@@ -9496,8 +9516,7 @@ function intentReasons(lineage, delegatedTask, directUserIntent, currentDelegate
|
|
|
9496
9516
|
function intentCompleteness(directUserIntent, delegatedTask, localSessionIntent, currentDelegated) {
|
|
9497
9517
|
return directUserIntent.length > 0 && (delegatedTask.length > 0 || !currentDelegated) ? "complete" : directUserIntent.length > 0 || localSessionIntent.length > 0 ? "partial" : "insufficient";
|
|
9498
9518
|
}
|
|
9499
|
-
|
|
9500
|
-
//#region src/modules/context/services/synthetic-parts.ts
|
|
9519
|
+
// src/modules/context/services/synthetic-parts.ts
|
|
9501
9520
|
const SYNTHETIC_TEXT = /^\s*(?:Magic Compact:|You have \d+ weighted tokens left)/i;
|
|
9502
9521
|
/** Host-authored text in a user-role message is never human authorization.
|
|
9503
9522
|
* The part's `synthetic`/`ignored` flags decide first; the text patterns are
|
|
@@ -9507,8 +9526,7 @@ function isSyntheticPart(part) {
|
|
|
9507
9526
|
if (part.synthetic === true || part.ignored === true) return true;
|
|
9508
9527
|
return SYNTHETIC_TEXT.test(part.text);
|
|
9509
9528
|
}
|
|
9510
|
-
|
|
9511
|
-
//#region src/modules/context/services/session-intent-blocks.ts
|
|
9529
|
+
// src/modules/context/services/session-intent-blocks.ts
|
|
9512
9530
|
function messageCreatedAt(message) {
|
|
9513
9531
|
const time = message.info.time;
|
|
9514
9532
|
return typeof time === "object" && time !== null && typeof time.created === "number" ? time.created : void 0;
|
|
@@ -9562,8 +9580,7 @@ function localIntentBlocks(request, currentMessages, lineage, currentDelegated)
|
|
|
9562
9580
|
}
|
|
9563
9581
|
return blocks;
|
|
9564
9582
|
}
|
|
9565
|
-
|
|
9566
|
-
//#region src/modules/context/services/session-metadata.ts
|
|
9583
|
+
// src/modules/context/services/session-metadata.ts
|
|
9567
9584
|
function readSession(id, raw) {
|
|
9568
9585
|
const r = raw ?? {};
|
|
9569
9586
|
return {
|
|
@@ -9602,8 +9619,7 @@ function lineageOrigin(current) {
|
|
|
9602
9619
|
if (current === void 0) return "unknown";
|
|
9603
9620
|
return current.parentID !== void 0 ? "delegated" : "human-root";
|
|
9604
9621
|
}
|
|
9605
|
-
|
|
9606
|
-
//#region src/modules/context/services/session-lineage.ts
|
|
9622
|
+
// src/modules/context/services/session-lineage.ts
|
|
9607
9623
|
/** Bound for the resolver's metadata SDK calls: a hung session.get/messages
|
|
9608
9624
|
* must degrade to "unknown" instead of leaving the review pending forever. */
|
|
9609
9625
|
const METADATA_TIMEOUT_MS = 1e4;
|
|
@@ -9676,8 +9692,7 @@ function finalize(nodes, nextUnresolved, depth, cycleDetected, truncated, missin
|
|
|
9676
9692
|
missingParents
|
|
9677
9693
|
};
|
|
9678
9694
|
}
|
|
9679
|
-
|
|
9680
|
-
//#region src/modules/context/services/intent-extraction.ts
|
|
9695
|
+
// src/modules/context/services/intent-extraction.ts
|
|
9681
9696
|
async function fetchMessagesBounded(reader, sessionID, directory, limit, intentOnly = false) {
|
|
9682
9697
|
try {
|
|
9683
9698
|
return normalizeFetched(await withTimeout(intentOnly && reader.intentMessages ? reader.intentMessages(sessionID, directory, limit) : reader.messages(sessionID, directory, limit), METADATA_TIMEOUT_MS));
|
|
@@ -9719,8 +9734,7 @@ async function resolveIntent(request, currentMessages, lineage, reader, director
|
|
|
9719
9734
|
...reasons.length === 0 ? {} : { reasons }
|
|
9720
9735
|
};
|
|
9721
9736
|
}
|
|
9722
|
-
|
|
9723
|
-
//#region src/modules/context/services/actor-resolver.ts
|
|
9737
|
+
// src/modules/context/services/actor-resolver.ts
|
|
9724
9738
|
function assessCompleteness(actor, lineage, intent) {
|
|
9725
9739
|
const reasons = [];
|
|
9726
9740
|
if (actor.identityCompleteness === "unknown") reasons.push("actor identity unavailable");
|
|
@@ -9775,8 +9789,7 @@ async function resolveActorContext(request, messages, reader, directory, config,
|
|
|
9775
9789
|
return unknownResolution(request, error);
|
|
9776
9790
|
}
|
|
9777
9791
|
}
|
|
9778
|
-
|
|
9779
|
-
//#region src/modules/analysis/capability/action-class.ts
|
|
9792
|
+
// src/modules/analysis/capability/action-class.ts
|
|
9780
9793
|
/** Pick the class when no classifier claimed one, preferring the most
|
|
9781
9794
|
* specific observed surface. */
|
|
9782
9795
|
function resolveActionClass(facts) {
|
|
@@ -9810,8 +9823,7 @@ function claimClass(facts, actionClass) {
|
|
|
9810
9823
|
function claimUnsetClass(facts, actionClass) {
|
|
9811
9824
|
if (facts.dominantClass === "unknown") claimClass(facts, actionClass);
|
|
9812
9825
|
}
|
|
9813
|
-
|
|
9814
|
-
//#region src/modules/analysis/capability/bash-mutation.ts
|
|
9826
|
+
// src/modules/analysis/capability/bash-mutation.ts
|
|
9815
9827
|
function hasWriteRedirect(redirections) {
|
|
9816
9828
|
return redirections.some(redirectionWritesPath);
|
|
9817
9829
|
}
|
|
@@ -9885,8 +9897,7 @@ function isLiteralPathValue(value) {
|
|
|
9885
9897
|
if (/[$`*?[\]{}]/.test(value)) return false;
|
|
9886
9898
|
return true;
|
|
9887
9899
|
}
|
|
9888
|
-
|
|
9889
|
-
//#region src/modules/analysis/capability/capability-facts.ts
|
|
9900
|
+
// src/modules/analysis/capability/capability-facts.ts
|
|
9890
9901
|
function newCapabilityFacts() {
|
|
9891
9902
|
return {
|
|
9892
9903
|
executesCode: false,
|
|
@@ -9922,8 +9933,7 @@ function recordWrite(facts, target, roots) {
|
|
|
9922
9933
|
if (cls.workspace) facts.workspaceWrite = true;
|
|
9923
9934
|
if (cls.external) facts.externalWrite = true;
|
|
9924
9935
|
}
|
|
9925
|
-
|
|
9926
|
-
//#region src/modules/analysis/capability/bash-facts.ts
|
|
9936
|
+
// src/modules/analysis/capability/bash-facts.ts
|
|
9927
9937
|
/** Command substitution (`$(...)` or backticks) makes analysis opaque. */
|
|
9928
9938
|
function hasCommandSubstitution(command) {
|
|
9929
9939
|
return /\$\(|`/.test(command);
|
|
@@ -9967,8 +9977,7 @@ function hasInlineCodeOption(tokens) {
|
|
|
9967
9977
|
inline: false
|
|
9968
9978
|
};
|
|
9969
9979
|
}
|
|
9970
|
-
|
|
9971
|
-
//#region src/modules/analysis/capability/capability-report.ts
|
|
9980
|
+
// src/modules/analysis/capability/capability-report.ts
|
|
9972
9981
|
function staticFlag(flag) {
|
|
9973
9982
|
return staticFact(flag ? true : "unknown");
|
|
9974
9983
|
}
|
|
@@ -10047,8 +10056,7 @@ function assessmentFrom(parsed, facts) {
|
|
|
10047
10056
|
analysisWarnings: warnings
|
|
10048
10057
|
};
|
|
10049
10058
|
}
|
|
10050
|
-
|
|
10051
|
-
//#region src/modules/analysis/capability/read-only-tool-mutations.ts
|
|
10059
|
+
// src/modules/analysis/capability/read-only-tool-mutations.ts
|
|
10052
10060
|
/** Placeholder target when a mutating form names no operand: conservatively
|
|
10053
10061
|
* treated as a workspace write (the current directory). */
|
|
10054
10062
|
const directoryFallback = ".";
|
|
@@ -10130,8 +10138,7 @@ function yqMutation(cmd) {
|
|
|
10130
10138
|
const targets = cmd.slice(1).map((token) => token.value).filter((value) => !value.startsWith("-"));
|
|
10131
10139
|
return targets.length > 0 ? { writeTargets: targets } : { writeTargets: [directoryFallback] };
|
|
10132
10140
|
}
|
|
10133
|
-
|
|
10134
|
-
//#region src/modules/analysis/capability/executable-recognition.ts
|
|
10141
|
+
// src/modules/analysis/capability/executable-recognition.ts
|
|
10135
10142
|
/** Effect families that keep a read-only or no-effect executable from
|
|
10136
10143
|
* counting as read-only. */
|
|
10137
10144
|
const READ_ONLY_DISQUALIFIERS = [
|
|
@@ -10182,8 +10189,7 @@ function classifyRecognition(base, mutatesReadOnlyTool, facts) {
|
|
|
10182
10189
|
if ((READ_ONLY_TOOLS.has(base) || NO_EFFECT_BUILTINS.has(base)) && !mutatesReadOnlyTool && !READ_ONLY_DISQUALIFIERS.some((family) => family.has(base))) facts.sawReadOnlyExecutable = true;
|
|
10183
10190
|
else if (base !== "git" && !RECOGNIZED_FAMILIES.some((family) => family.has(base))) facts.sawUnknownExecutable = true;
|
|
10184
10191
|
}
|
|
10185
|
-
|
|
10186
|
-
//#region src/modules/analysis/capability/execution-classifiers.ts
|
|
10192
|
+
// src/modules/analysis/capability/execution-classifiers.ts
|
|
10187
10193
|
const CHILD_PROCESS_INTERPRETERS = [
|
|
10188
10194
|
"bun",
|
|
10189
10195
|
"node",
|
|
@@ -10235,8 +10241,7 @@ function classifyPackageManager(cmd, base, facts) {
|
|
|
10235
10241
|
if (sub === "run") facts.executesRepositoryCode = true;
|
|
10236
10242
|
} else facts.networkObserved = true;
|
|
10237
10243
|
}
|
|
10238
|
-
|
|
10239
|
-
//#region src/modules/analysis/capability/mutation-operands.ts
|
|
10244
|
+
// src/modules/analysis/capability/mutation-operands.ts
|
|
10240
10245
|
/** A remote operand for rsync-style tools: a URL scheme, or an `host:path`
|
|
10241
10246
|
* / `user@host:path` shape whose part before the colon is a bare host (no
|
|
10242
10247
|
* slash), which is exactly how rsync decides local-with-colon vs remote. */
|
|
@@ -10316,8 +10321,7 @@ function scanShortOptions(cmd, i, v, valueOpts, scan) {
|
|
|
10316
10321
|
}
|
|
10317
10322
|
return i;
|
|
10318
10323
|
}
|
|
10319
|
-
|
|
10320
|
-
//#region src/modules/analysis/capability/file-effect-classifiers.ts
|
|
10324
|
+
// src/modules/analysis/capability/file-effect-classifiers.ts
|
|
10321
10325
|
function classifyFileWrite(cmd, base, facts, roots) {
|
|
10322
10326
|
if (!FILE_WRITE_TOOLS.has(base)) return;
|
|
10323
10327
|
for (const output of fileWriteOutputs(cmd, base)) recordWrite(facts, output, roots);
|
|
@@ -10362,8 +10366,7 @@ function classifyDeletion(cmd, base, facts, roots) {
|
|
|
10362
10366
|
}
|
|
10363
10367
|
if (!anyTarget) facts.workspaceWrite = true;
|
|
10364
10368
|
}
|
|
10365
|
-
|
|
10366
|
-
//#region src/modules/analysis/capability/git-subcommand-forms.ts
|
|
10369
|
+
// src/modules/analysis/capability/git-subcommand-forms.ts
|
|
10367
10370
|
/** Resolve a git subcommand from the token stream, skipping global git
|
|
10368
10371
|
* options and their separate values (see `src/modules/analysis/git/git-global-options.ts`), so
|
|
10369
10372
|
* `git -C /repo push` still detects the `push` mutation. */
|
|
@@ -10425,8 +10428,7 @@ const GIT_SUBCOMMAND_FORMS = /* @__PURE__ */ new Map([
|
|
|
10425
10428
|
["submodule", submoduleMutates],
|
|
10426
10429
|
["symbolic-ref", symbolicRefMutates]
|
|
10427
10430
|
]);
|
|
10428
|
-
|
|
10429
|
-
//#region src/modules/analysis/capability/network-classifiers.ts
|
|
10431
|
+
// src/modules/analysis/capability/network-classifiers.ts
|
|
10430
10432
|
function classifyNetworkClient(cmd, base, facts) {
|
|
10431
10433
|
if (!NETWORK_CLIENTS.has(base)) return;
|
|
10432
10434
|
facts.networkObserved = true;
|
|
@@ -10464,8 +10466,7 @@ function classifyGit(cmd, base, facts) {
|
|
|
10464
10466
|
else facts.workspaceWrite = true;
|
|
10465
10467
|
} else if (network) claimClass(facts, "network");
|
|
10466
10468
|
}
|
|
10467
|
-
|
|
10468
|
-
//#region src/modules/analysis/capability/process-classifiers.ts
|
|
10469
|
+
// src/modules/analysis/capability/process-classifiers.ts
|
|
10469
10470
|
function classifyServiceManager(base, facts) {
|
|
10470
10471
|
if (!SERVICE_MANAGERS.has(base)) return;
|
|
10471
10472
|
facts.persistence = true;
|
|
@@ -10478,8 +10479,7 @@ function classifyPersistenceTool(base, facts) {
|
|
|
10478
10479
|
facts.persistence = true;
|
|
10479
10480
|
facts.childProcesses = true;
|
|
10480
10481
|
}
|
|
10481
|
-
|
|
10482
|
-
//#region src/modules/analysis/capability/effective-command-classifiers.ts
|
|
10482
|
+
// src/modules/analysis/capability/effective-command-classifiers.ts
|
|
10483
10483
|
/** Every classifier runs on every command, in this order: a command can
|
|
10484
10484
|
* match several (bun is an interpreter and a package manager, rsync a
|
|
10485
10485
|
* network client and a mutation tool, shred a writer and a deleter). */
|
|
@@ -10501,8 +10501,7 @@ function classifyEffectiveCommand(cmd, facts, context) {
|
|
|
10501
10501
|
classifyServiceManager(base, facts);
|
|
10502
10502
|
classifyPersistenceTool(base, facts);
|
|
10503
10503
|
}
|
|
10504
|
-
|
|
10505
|
-
//#region src/modules/analysis/capability/segment-heads.ts
|
|
10504
|
+
// src/modules/analysis/capability/segment-heads.ts
|
|
10506
10505
|
/** Wrappers the walk peels (sudo, nohup, ssh, …) must be detected on the
|
|
10507
10506
|
* commands it resolves, because `effective` starts at the real executable
|
|
10508
10507
|
* after peeling. The walk reports each one at every level it re-enters, so
|
|
@@ -10535,8 +10534,7 @@ function classifyWrapperHead(head, facts) {
|
|
|
10535
10534
|
claimUnsetClass(facts, "remote-operation");
|
|
10536
10535
|
}
|
|
10537
10536
|
}
|
|
10538
|
-
|
|
10539
|
-
//#region src/modules/analysis/capability/sensitive-paths.ts
|
|
10537
|
+
// src/modules/analysis/capability/sensitive-paths.ts
|
|
10540
10538
|
/** Credential locations as literal path fragments (case-insensitive). */
|
|
10541
10539
|
const SENSITIVE_PATH = /(?:^|\/)(?:\.env(?:\.|$)|\.ssh(?:\/|$)|\.aws(?:\/|$)|\.config\/gcloud(?:\/|$)|\.config\/gh\/hosts\.yml$|id_(?:rsa|dsa|ecdsa|ed25519)(?:\.pub)?$|credentials(?:\.json)?$|authorized_keys$|known_hosts$|\.npmrc$|\.pypirc$|\.netrc$)/i;
|
|
10542
10540
|
/** Suffixes that mark a path as a non-secret example or public artifact. */
|
|
@@ -10550,8 +10548,7 @@ function isSensitivePathToken(path) {
|
|
|
10550
10548
|
if (NON_SECRET_SUFFIX.test(path)) return false;
|
|
10551
10549
|
return SENSITIVE_PATH.test(path);
|
|
10552
10550
|
}
|
|
10553
|
-
|
|
10554
|
-
//#region src/modules/analysis/capability/sensitive-path-reads.ts
|
|
10551
|
+
// src/modules/analysis/capability/sensitive-path-reads.ts
|
|
10555
10552
|
/** A known file reader with a literal credential path operand, or any
|
|
10556
10553
|
* command with a literal credential path as an input (`<`) redirect target.
|
|
10557
10554
|
* Wrappers are already peeled in `effective`, so `sudo cat ...` arrives here
|
|
@@ -10583,8 +10580,7 @@ function operandReadsCredential(previous, value) {
|
|
|
10583
10580
|
if (value.startsWith("<") || value.startsWith(">")) return false;
|
|
10584
10581
|
return isLiteralPathValue(value) && isSensitivePathToken(value);
|
|
10585
10582
|
}
|
|
10586
|
-
|
|
10587
|
-
//#region src/modules/analysis/capability/truncated-segment-heads.ts
|
|
10583
|
+
// src/modules/analysis/capability/truncated-segment-heads.ts
|
|
10588
10584
|
/** The walk reports no command past its depth or command limits. When one
|
|
10589
10585
|
* stopped it, each segment's own words are still read for the wrappers
|
|
10590
10586
|
* they start with, without descending into command strings, so a wrapper
|
|
@@ -10616,8 +10612,7 @@ function wrappedCommandIndex(tokens, k, head) {
|
|
|
10616
10612
|
function valueAt(tokens, k) {
|
|
10617
10613
|
return elementAt(tokens, k, "tokens").value;
|
|
10618
10614
|
}
|
|
10619
|
-
|
|
10620
|
-
//#region src/modules/analysis/capability/bash-analyzer.ts
|
|
10615
|
+
// src/modules/analysis/capability/bash-analyzer.ts
|
|
10621
10616
|
/** Analyze a parsed bash command and produce capability facts. */
|
|
10622
10617
|
function analyzeCapability(parsed, directory, worktree) {
|
|
10623
10618
|
const facts = newCapabilityFacts();
|
|
@@ -10653,8 +10648,7 @@ function recordRedirectionWrites(redirections, facts, roots) {
|
|
|
10653
10648
|
function recordHeredocWrites(heredocs, facts, roots) {
|
|
10654
10649
|
for (const h of heredocs) if (h.outputTarget !== void 0) recordWrite(facts, h.outputTarget, roots);
|
|
10655
10650
|
}
|
|
10656
|
-
|
|
10657
|
-
//#region src/modules/analysis/capability/command-walk.ts
|
|
10651
|
+
// src/modules/analysis/capability/command-walk.ts
|
|
10658
10652
|
function newWalked() {
|
|
10659
10653
|
return {
|
|
10660
10654
|
segments: [],
|
|
@@ -10690,8 +10684,7 @@ function walkSegments(segments, budget, into) {
|
|
|
10690
10684
|
}
|
|
10691
10685
|
return stopped;
|
|
10692
10686
|
}
|
|
10693
|
-
|
|
10694
|
-
//#region src/modules/analysis/shell/shell-stdin-source.ts
|
|
10687
|
+
// src/modules/analysis/shell/shell-stdin-source.ts
|
|
10695
10688
|
const PIPE = { kind: "pipe" };
|
|
10696
10689
|
const OTHER$1 = { kind: "other" };
|
|
10697
10690
|
const UNRECORDED = { kind: "unrecorded" };
|
|
@@ -10758,8 +10751,7 @@ function isDigits(text) {
|
|
|
10758
10751
|
function isDigitCode(code) {
|
|
10759
10752
|
return code >= 48 && code <= 57;
|
|
10760
10753
|
}
|
|
10761
|
-
|
|
10762
|
-
//#region src/modules/analysis/shell/shell-script-feeds.ts
|
|
10754
|
+
// src/modules/analysis/shell/shell-script-feeds.ts
|
|
10763
10755
|
/** The script readings a command's stdin carries. */
|
|
10764
10756
|
const OTHER = { kind: "other" };
|
|
10765
10757
|
/** The scripts that run, one feed per distinct reading. */
|
|
@@ -10858,8 +10850,7 @@ function readings(source, scripts) {
|
|
|
10858
10850
|
fed: true
|
|
10859
10851
|
};
|
|
10860
10852
|
}
|
|
10861
|
-
|
|
10862
|
-
//#region src/modules/analysis/shell/shell-script-feed-input.ts
|
|
10853
|
+
// src/modules/analysis/shell/shell-script-feed-input.ts
|
|
10863
10854
|
function buildFeedInput(parts, scripts) {
|
|
10864
10855
|
const producers = segmentProducers(parts.map(({ segment }) => segment), parts.map(({ effective }) => effective.length));
|
|
10865
10856
|
const effective = [];
|
|
@@ -10921,8 +10912,7 @@ function segmentProducers(segments, counts) {
|
|
|
10921
10912
|
function isPipe(separator) {
|
|
10922
10913
|
return separator === "|" || separator === "|&";
|
|
10923
10914
|
}
|
|
10924
|
-
|
|
10925
|
-
//#region src/modules/analysis/walk/interpreter-stdin.ts
|
|
10915
|
+
// src/modules/analysis/walk/interpreter-stdin.ts
|
|
10926
10916
|
/**
|
|
10927
10917
|
* Whether the interpreter that `words` start with takes its code from stdin:
|
|
10928
10918
|
* a lone `-` says so, and so does the absence of any operand, with options
|
|
@@ -10944,8 +10934,7 @@ function interpreterReadsStdin(words) {
|
|
|
10944
10934
|
}
|
|
10945
10935
|
return true;
|
|
10946
10936
|
}
|
|
10947
|
-
|
|
10948
|
-
//#region src/modules/analysis/capability/script-feed-analysis.ts
|
|
10937
|
+
// src/modules/analysis/capability/script-feed-analysis.ts
|
|
10949
10938
|
const NO_FEEDS$1 = {
|
|
10950
10939
|
feeds: [],
|
|
10951
10940
|
unresolved: false,
|
|
@@ -10976,8 +10965,7 @@ function runsStdinCode(words) {
|
|
|
10976
10965
|
if (!INTERPRETERS$1.has(head)) return false;
|
|
10977
10966
|
return STDIN_SCRIPT_SHELLS.has(head) ? shellReadsStdin(words) : interpreterReadsStdin(words);
|
|
10978
10967
|
}
|
|
10979
|
-
|
|
10980
|
-
//#region src/modules/analysis/capability/walk-feeds.ts
|
|
10968
|
+
// src/modules/analysis/capability/walk-feeds.ts
|
|
10981
10969
|
const NO_FEEDS = [];
|
|
10982
10970
|
/** The scripts the commands of the segments of `text`, walked from part
|
|
10983
10971
|
* `from` on, read: none without a `<<` in `text`. Their heredocs are read in
|
|
@@ -11045,8 +11033,7 @@ function addAll(into, scripts) {
|
|
|
11045
11033
|
into.set(placeholder, known);
|
|
11046
11034
|
}
|
|
11047
11035
|
}
|
|
11048
|
-
|
|
11049
|
-
//#region src/modules/analysis/capability/body-command-walk.ts
|
|
11036
|
+
// src/modules/analysis/capability/body-command-walk.ts
|
|
11050
11037
|
/**
|
|
11051
11038
|
* Walk the commands that heredoc bodies run, each lexed as a command line of
|
|
11052
11039
|
* its own, after the command's own. The budget's `bodies` holds those of the
|
|
@@ -11123,8 +11110,7 @@ function queueDeeper(queue, commands, feeds, from) {
|
|
|
11123
11110
|
});
|
|
11124
11111
|
return false;
|
|
11125
11112
|
}
|
|
11126
|
-
|
|
11127
|
-
//#region src/modules/analysis/capability/command-parser.ts
|
|
11113
|
+
// src/modules/analysis/capability/command-parser.ts
|
|
11128
11114
|
/** Parse a raw bash command into the reusable structure. */
|
|
11129
11115
|
function parseCommand(rawCommand) {
|
|
11130
11116
|
return withScanBudget(rawCommand.length, () => parse(rawCommand));
|
|
@@ -11177,8 +11163,7 @@ const ALL_LITERAL = /^(?:'[^']*'|\$'(?:[^'\\]|\\[\s\S])*')+$/;
|
|
|
11177
11163
|
function isAllLiteral(raw) {
|
|
11178
11164
|
return ALL_LITERAL.test(raw);
|
|
11179
11165
|
}
|
|
11180
|
-
|
|
11181
|
-
//#region src/modules/evidence/ssh/verified-script-evidence.ts
|
|
11166
|
+
// src/modules/evidence/ssh/verified-script-evidence.ts
|
|
11182
11167
|
async function collectVerifiedSshScript(command, directory, worktree, scope, configHash, registry) {
|
|
11183
11168
|
const base = {
|
|
11184
11169
|
sha256: command.sha256,
|
|
@@ -11217,8 +11202,7 @@ function unavailableReason(file, expectedSha256) {
|
|
|
11217
11202
|
const actual = file.content === void 0 ? void 0 : file.includedSha256;
|
|
11218
11203
|
if (file.status !== "included" || actual !== expectedSha256 || file.content === void 0 || redactSecrets(file.content) !== file.content) return file.status === "included" && actual !== expectedSha256 ? "script hash mismatch" : file.status === "included" ? "sensitive content" : file.status;
|
|
11219
11204
|
}
|
|
11220
|
-
|
|
11221
|
-
//#region src/modules/context/services/command-evidence.ts
|
|
11205
|
+
// src/modules/context/services/command-evidence.ts
|
|
11222
11206
|
/** The verified script's evidence, cached per root session (per request session when the lineage is unknown). */
|
|
11223
11207
|
function collectVerifiedScript(command, request, actor, ctx) {
|
|
11224
11208
|
return collectVerifiedSshScript(command, ctx.directory, ctx.worktree, actor.lineage.origin === "unknown" ? request.sessionID : actor.lineage.rootSessionID, configFingerprint({
|
|
@@ -11245,8 +11229,7 @@ function analyzeBashCommand(request, ctx) {
|
|
|
11245
11229
|
return { parsed };
|
|
11246
11230
|
}
|
|
11247
11231
|
}
|
|
11248
|
-
|
|
11249
|
-
//#region src/modules/context/services/tool-message-purpose.ts
|
|
11232
|
+
// src/modules/context/services/tool-message-purpose.ts
|
|
11250
11233
|
const MAX_PURPOSE_CHARS = 500;
|
|
11251
11234
|
/**
|
|
11252
11235
|
* Locate the assistant message that issued this tool call and recover any
|
|
@@ -11292,8 +11275,7 @@ function boundPurpose(value) {
|
|
|
11292
11275
|
if (compact.length <= MAX_PURPOSE_CHARS) return compact;
|
|
11293
11276
|
return `${compact.slice(0, 499)}…`;
|
|
11294
11277
|
}
|
|
11295
|
-
|
|
11296
|
-
//#region src/modules/context/services/action-purpose.ts
|
|
11278
|
+
// src/modules/context/services/action-purpose.ts
|
|
11297
11279
|
const PURPOSE_METADATA_KEYS = [
|
|
11298
11280
|
"purpose",
|
|
11299
11281
|
"description",
|
|
@@ -11370,8 +11352,7 @@ function latestBlockText(blocks) {
|
|
|
11370
11352
|
if (text !== void 0) return text;
|
|
11371
11353
|
}
|
|
11372
11354
|
}
|
|
11373
|
-
|
|
11374
|
-
//#region src/modules/context/services/prompt-budget.ts
|
|
11355
|
+
// src/modules/context/services/prompt-budget.ts
|
|
11375
11356
|
function truncate$1(value, max) {
|
|
11376
11357
|
const redacted = redactSecrets(value);
|
|
11377
11358
|
if (redacted.length <= max) return redacted;
|
|
@@ -11434,8 +11415,7 @@ function boundedBlock(block, budget) {
|
|
|
11434
11415
|
const bounded = redacted.length <= budget ? redacted : elideMiddle$1(redacted, budget);
|
|
11435
11416
|
return bounded.length > budget ? void 0 : bounded;
|
|
11436
11417
|
}
|
|
11437
|
-
|
|
11438
|
-
//#region src/modules/context/services/pending-permission.ts
|
|
11418
|
+
// src/modules/context/services/pending-permission.ts
|
|
11439
11419
|
/** Bound the pending command before serialization, eliding its middle rather
|
|
11440
11420
|
* than letting a head-only truncation cut the tail (where trailing
|
|
11441
11421
|
* redirections and compound command tails live). */
|
|
@@ -11479,8 +11459,7 @@ function pendingPermissionSection(request, config) {
|
|
|
11479
11459
|
actionEvidenceComplete: !elided && !truncated
|
|
11480
11460
|
};
|
|
11481
11461
|
}
|
|
11482
|
-
|
|
11483
|
-
//#region src/modules/context/services/evidence-completeness.ts
|
|
11462
|
+
// src/modules/context/services/evidence-completeness.ts
|
|
11484
11463
|
function actionCompleteness(request, config, actor, actionPurpose, verifiedScript) {
|
|
11485
11464
|
const purposeOk = actionPurpose.source !== "unavailable";
|
|
11486
11465
|
const reasons = [...actor.completeness.reasons];
|
|
@@ -11495,8 +11474,7 @@ function actionCompleteness(request, config, actor, actionPurpose, verifiedScrip
|
|
|
11495
11474
|
reasons
|
|
11496
11475
|
};
|
|
11497
11476
|
}
|
|
11498
|
-
|
|
11499
|
-
//#region src/modules/context/services/actor-sections.ts
|
|
11477
|
+
// src/modules/context/services/actor-sections.ts
|
|
11500
11478
|
function provValue(p) {
|
|
11501
11479
|
return p === void 0 ? "unavailable" : p.value;
|
|
11502
11480
|
}
|
|
@@ -11550,8 +11528,7 @@ function renderCompleteness(c, max) {
|
|
|
11550
11528
|
...c.reasons.length === 0 ? {} : { reasons: c.reasons }
|
|
11551
11529
|
}, max);
|
|
11552
11530
|
}
|
|
11553
|
-
|
|
11554
|
-
//#region src/modules/context/services/capability-section.ts
|
|
11531
|
+
// src/modules/context/services/capability-section.ts
|
|
11555
11532
|
function renderCapability(cap, max) {
|
|
11556
11533
|
return stableJson({
|
|
11557
11534
|
actionClass: cap.actionClass.value,
|
|
@@ -11585,8 +11562,7 @@ function renderCapability(cap, max) {
|
|
|
11585
11562
|
...cap.analysisWarnings.length === 0 ? {} : { warnings: cap.analysisWarnings }
|
|
11586
11563
|
}, max);
|
|
11587
11564
|
}
|
|
11588
|
-
|
|
11589
|
-
//#region src/modules/context/services/evidence-sections.ts
|
|
11565
|
+
// src/modules/context/services/evidence-sections.ts
|
|
11590
11566
|
function renderActionPurpose(purpose, max, intentReference = false) {
|
|
11591
11567
|
if (purpose === void 0) return `ACTION_PURPOSE\n${stableJson({
|
|
11592
11568
|
source: "unavailable",
|
|
@@ -11646,8 +11622,7 @@ function actorEvidenceSections(envelope, config) {
|
|
|
11646
11622
|
if (completeness !== void 0) sections.push(`EVIDENCE_COMPLETENESS\n${renderCompleteness(completeness, cap)}`);
|
|
11647
11623
|
return sections;
|
|
11648
11624
|
}
|
|
11649
|
-
|
|
11650
|
-
//#region src/modules/context/services/evidence-layout.ts
|
|
11625
|
+
// src/modules/context/services/evidence-layout.ts
|
|
11651
11626
|
/** The evidence sections in prompt order. `askDecisions` is the rendered
|
|
11652
11627
|
* USER_ASK_DECISIONS body; the section is omitted entirely when it is
|
|
11653
11628
|
* undefined: absence of ask decisions carries no signal for the reviewer (the
|
|
@@ -11676,8 +11651,7 @@ function evidenceSections(envelope, config, pendingText, askDecisions) {
|
|
|
11676
11651
|
function evidenceBudget(envelope, config) {
|
|
11677
11652
|
return config.maxContextChars + config.maxPartChars * 2 + config.maxEnrichmentChars + config.maxIntentChars + (envelope.verifiedScript?.status === "full" ? envelope.verifiedScript.text.length : 0);
|
|
11678
11653
|
}
|
|
11679
|
-
|
|
11680
|
-
//#region src/modules/context/services/intent-history.ts
|
|
11654
|
+
// src/modules/context/services/intent-history.ts
|
|
11681
11655
|
/** The trimmed, non-synthetic text parts of a message, one per line. */
|
|
11682
11656
|
function literalUserText(message) {
|
|
11683
11657
|
return message.parts.filter((part) => part.type === "text" && !isSyntheticPart(part)).map((part) => typeof part.text === "string" ? part.text.trim() : "").filter(Boolean).join("\n");
|
|
@@ -11706,8 +11680,7 @@ function distinctIntentSummaries(messages, config) {
|
|
|
11706
11680
|
return [summary];
|
|
11707
11681
|
});
|
|
11708
11682
|
}
|
|
11709
|
-
|
|
11710
|
-
//#region src/modules/context/services/message-summary.ts
|
|
11683
|
+
// src/modules/context/services/message-summary.ts
|
|
11711
11684
|
/** Part kinds that carry no reviewable content. */
|
|
11712
11685
|
const SILENT_PART_TYPES = /* @__PURE__ */ new Set([
|
|
11713
11686
|
"step-start",
|
|
@@ -11756,8 +11729,7 @@ function transcriptParts(message, options) {
|
|
|
11756
11729
|
function transcriptFingerprint(summary) {
|
|
11757
11730
|
return summary.replace(/^MESSAGE[^\n]*\n/, "").replace(/"callID": "[^"]*"/g, "\"callID\": \"<identity>\"");
|
|
11758
11731
|
}
|
|
11759
|
-
|
|
11760
|
-
//#region src/modules/context/services/prompt/context.ts
|
|
11732
|
+
// src/modules/context/services/prompt/context.ts
|
|
11761
11733
|
function buildTranscript(messages, config, options) {
|
|
11762
11734
|
const selected = messages.slice(-config.transcriptMessages);
|
|
11763
11735
|
const kept = [];
|
|
@@ -11825,8 +11797,7 @@ function normalizeMessages(value) {
|
|
|
11825
11797
|
}];
|
|
11826
11798
|
});
|
|
11827
11799
|
}
|
|
11828
|
-
|
|
11829
|
-
//#region src/modules/context/services/evidence-sources.ts
|
|
11800
|
+
// src/modules/context/services/evidence-sources.ts
|
|
11830
11801
|
/** Both transcript reads, started together; `intentMessages` is optional on the reader. */
|
|
11831
11802
|
function readTranscripts(reader, request, ctx) {
|
|
11832
11803
|
return Promise.all([reader.messages(request.sessionID, ctx.directory, Math.max(ctx.config.historyMessages, ctx.config.transcriptMessages * 2, 20)), reader.intentMessages?.(request.sessionID, ctx.directory, ctx.config.intentMessages)]);
|
|
@@ -11856,8 +11827,7 @@ function collectFragments(request, providers, verifiedScript, ctx) {
|
|
|
11856
11827
|
function scopedAskDecisions(request, actor, ctx) {
|
|
11857
11828
|
return ctx.config.askDecisions && ctx.askDecisions !== void 0 ? ctx.askDecisions.recentFor([request.sessionID, ...actor.lineage?.nodes.map((node) => node.sessionID) ?? []]) : void 0;
|
|
11858
11829
|
}
|
|
11859
|
-
|
|
11860
|
-
//#region src/modules/context/services/evidence-envelope.ts
|
|
11830
|
+
// src/modules/context/services/evidence-envelope.ts
|
|
11861
11831
|
function envelopeFrom(gathered) {
|
|
11862
11832
|
const { request, ctx, messages, actor, verifiedScript } = gathered;
|
|
11863
11833
|
const { parsed, capability, fragments } = gathered;
|
|
@@ -11908,8 +11878,7 @@ function transcriptOptions({ request, actor }) {
|
|
|
11908
11878
|
...request.tool === void 0 ? {} : { pendingTool: request.tool }
|
|
11909
11879
|
};
|
|
11910
11880
|
}
|
|
11911
|
-
|
|
11912
|
-
//#region src/modules/context/services/evidence-assembler.ts
|
|
11881
|
+
// src/modules/context/services/evidence-assembler.ts
|
|
11913
11882
|
/**
|
|
11914
11883
|
* Fetch the session transcript and run every evidence provider concurrently,
|
|
11915
11884
|
* then fold the fragments into a single {@link ReviewEnvelope}. This is the
|
|
@@ -11951,8 +11920,7 @@ function defaultEvidenceProviders() {
|
|
|
11951
11920
|
new GitEvidenceProvider()
|
|
11952
11921
|
];
|
|
11953
11922
|
}
|
|
11954
|
-
|
|
11955
|
-
//#region src/modules/review/services/attempt-evidence.ts
|
|
11923
|
+
// src/modules/review/services/attempt-evidence.ts
|
|
11956
11924
|
function rememberEvidence(attempts, requestID, evidence) {
|
|
11957
11925
|
const attempt = attempts.get(requestID);
|
|
11958
11926
|
if (attempt?.active()) Object.assign(attempt.evidence, evidence);
|
|
@@ -11966,8 +11934,7 @@ function recordReviewerMs(attempts, envelope, reviewerMs) {
|
|
|
11966
11934
|
reviewerMs
|
|
11967
11935
|
} });
|
|
11968
11936
|
}
|
|
11969
|
-
|
|
11970
|
-
//#region src/modules/review/services/review-attempt.ts
|
|
11937
|
+
// src/modules/review/services/review-attempt.ts
|
|
11971
11938
|
/** One invocation owns its deadline, identity, and terminal transition. */
|
|
11972
11939
|
var ReviewAttempt = class {
|
|
11973
11940
|
generation;
|
|
@@ -12027,8 +11994,7 @@ var ReviewAttempt = class {
|
|
|
12027
11994
|
});
|
|
12028
11995
|
}
|
|
12029
11996
|
};
|
|
12030
|
-
|
|
12031
|
-
//#region src/modules/review/services/coordinator-state.ts
|
|
11997
|
+
// src/modules/review/services/coordinator-state.ts
|
|
12032
11998
|
function coordinatorState(host, config, logger, providers, askDecisions) {
|
|
12033
11999
|
const log = logger ?? (() => {});
|
|
12034
12000
|
const state = {
|
|
@@ -12061,8 +12027,7 @@ function supersedeResult() {
|
|
|
12061
12027
|
decisionSource: "manual-superseded"
|
|
12062
12028
|
};
|
|
12063
12029
|
}
|
|
12064
|
-
|
|
12065
|
-
//#region src/modules/review/services/audit-record/review-audit-facts.ts
|
|
12030
|
+
// src/modules/review/services/audit-record/review-audit-facts.ts
|
|
12066
12031
|
function evidenceFields$1(evidence) {
|
|
12067
12032
|
const { timings, evidenceCompleteness, verifiedScript } = evidence;
|
|
12068
12033
|
return {
|
|
@@ -12140,8 +12105,7 @@ function traceAndAskFields(evidence) {
|
|
|
12140
12105
|
})) }
|
|
12141
12106
|
};
|
|
12142
12107
|
}
|
|
12143
|
-
|
|
12144
|
-
//#region src/modules/review/services/audit-record/review-audit-outcome.ts
|
|
12108
|
+
// src/modules/review/services/audit-record/review-audit-outcome.ts
|
|
12145
12109
|
function escalationFields(result) {
|
|
12146
12110
|
return {
|
|
12147
12111
|
...result.reviewerEscalatedFrom === void 0 ? {} : { reviewerEscalatedFrom: result.reviewerEscalatedFrom },
|
|
@@ -12168,8 +12132,7 @@ function configWarningsField(config) {
|
|
|
12168
12132
|
const warnings = config.configWarnings;
|
|
12169
12133
|
return warnings === void 0 || warnings.length === 0 ? {} : { configWarnings: warnings };
|
|
12170
12134
|
}
|
|
12171
|
-
|
|
12172
|
-
//#region src/modules/review/services/audit-record/review-audit-record.ts
|
|
12135
|
+
// src/modules/review/services/audit-record/review-audit-record.ts
|
|
12173
12136
|
/** Stable hash of the canonical request so audit records for the same action
|
|
12174
12137
|
* correlate across runs. Patterns are sorted so event order does not matter.
|
|
12175
12138
|
* The per-invocation tool call/message IDs are deliberately excluded: two
|
|
@@ -12230,8 +12193,7 @@ function auditWarnings(evidence) {
|
|
|
12230
12193
|
if (evidence.capability !== void 0) warnings.push(...evidence.capability.analysisWarnings);
|
|
12231
12194
|
return warnings;
|
|
12232
12195
|
}
|
|
12233
|
-
|
|
12234
|
-
//#region src/modules/review/services/audit-record/review-coordinator-support.ts
|
|
12196
|
+
// src/modules/review/services/audit-record/review-coordinator-support.ts
|
|
12235
12197
|
/** `ReviewCoordinator.process()` registers the attempt before its first await
|
|
12236
12198
|
* and deletes it only in its finally block, after closing it; `handle()`
|
|
12237
12199
|
* runs one `process()` per request ID. Every lookup asserted with this
|
|
@@ -12251,8 +12213,7 @@ async function writeReviewAudit(scope, request, result, startedAt) {
|
|
|
12251
12213
|
});
|
|
12252
12214
|
});
|
|
12253
12215
|
}
|
|
12254
|
-
|
|
12255
|
-
//#region src/modules/review/services/reply-events.ts
|
|
12216
|
+
// src/modules/review/services/reply-events.ts
|
|
12256
12217
|
/** The request ID a `permission.replied` event names, or undefined for any
|
|
12257
12218
|
* other event or one without a string session and request ID. */
|
|
12258
12219
|
function repliedRequestID(event) {
|
|
@@ -12273,8 +12234,7 @@ function supersedeOnReply(state, pending, event) {
|
|
|
12273
12234
|
state.resolvedManually.add(requestID);
|
|
12274
12235
|
attempt?.close("cancelled");
|
|
12275
12236
|
}
|
|
12276
|
-
|
|
12277
|
-
//#region src/modules/decision/escalation.ts
|
|
12237
|
+
// src/modules/decision/escalation.ts
|
|
12278
12238
|
/**
|
|
12279
12239
|
* Resolve the effective disposition for an internal escalate.
|
|
12280
12240
|
*
|
|
@@ -12345,8 +12305,7 @@ function resolveReviewerOutcome(result) {
|
|
|
12345
12305
|
if (result.reviewerOutcome !== void 0) return result.reviewerOutcome;
|
|
12346
12306
|
if (result.decision !== void 0) return result.decision.outcome;
|
|
12347
12307
|
}
|
|
12348
|
-
|
|
12349
|
-
//#region src/modules/decision/failure-reason.ts
|
|
12308
|
+
// src/modules/decision/failure-reason.ts
|
|
12350
12309
|
const MAX_FAILURE_REASON_LENGTH = 500;
|
|
12351
12310
|
const MAX_CAUSE_DEPTH = 2;
|
|
12352
12311
|
function safeName(error) {
|
|
@@ -12456,8 +12415,7 @@ function formatFailureReason(phase, error) {
|
|
|
12456
12415
|
return "review failed: unknown error";
|
|
12457
12416
|
}
|
|
12458
12417
|
}
|
|
12459
|
-
|
|
12460
|
-
//#region src/modules/review/services/review-reply.ts
|
|
12418
|
+
// src/modules/review/services/review-reply.ts
|
|
12461
12419
|
/**
|
|
12462
12420
|
* Send a permission reply. Returns `true` on success, `false` when the
|
|
12463
12421
|
* request was already resolved by another source (human TUI, a duplicate
|
|
@@ -12498,8 +12456,7 @@ async function sendPermissionReply(scope, request, reply, message) {
|
|
|
12498
12456
|
attempt.application = "reply-accepted";
|
|
12499
12457
|
return true;
|
|
12500
12458
|
}
|
|
12501
|
-
|
|
12502
|
-
//#region src/modules/status/services/ui-status-extras.ts
|
|
12459
|
+
// src/modules/status/services/ui-status-extras.ts
|
|
12503
12460
|
const MAX_LIST_ENTRIES = 5;
|
|
12504
12461
|
const MAX_ENTRY_CHARS = 200;
|
|
12505
12462
|
const MAX_MODEL_CHARS = 200;
|
|
@@ -12613,8 +12570,7 @@ function fitStatus(status) {
|
|
|
12613
12570
|
}
|
|
12614
12571
|
return fitted;
|
|
12615
12572
|
}
|
|
12616
|
-
|
|
12617
|
-
//#region src/modules/status/services/ui-status-parse.ts
|
|
12573
|
+
// src/modules/status/services/ui-status-parse.ts
|
|
12618
12574
|
const oneOf = (allowed) => (value) => allowed.includes(value);
|
|
12619
12575
|
const isString$1 = (value) => typeof value === "string";
|
|
12620
12576
|
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
@@ -12721,8 +12677,7 @@ function parseUiStatus(value) {
|
|
|
12721
12677
|
if (!(isRecord(value) && fieldsPass(value, STATUS_CHECKS))) return;
|
|
12722
12678
|
return value;
|
|
12723
12679
|
}
|
|
12724
|
-
|
|
12725
|
-
//#region src/modules/status/services/ui-text-elide.ts
|
|
12680
|
+
// src/modules/status/services/ui-text-elide.ts
|
|
12726
12681
|
const ELISION = " ⋯ ";
|
|
12727
12682
|
const ELISION_COLUMNS = Array.from(ELISION).length;
|
|
12728
12683
|
const ESCAPED = /[\u034f\u0000-\u0008\u000b-\u001f\u007f-\u00a0\u00ad\u061c\u1680\u180e\u2000-\u200f\u2028-\u202f\u205f-\u206f\u21b5\u22ef\u23ce\u3000\ud800-\udfff\ufe00-\ufe0f\ufeff\ufff9-\ufffb\u{e0000}-\u{e007f}\u{e0100}-\u{e01ef}]/gu;
|
|
@@ -12781,8 +12736,7 @@ function boundedHeadTail(value, max) {
|
|
|
12781
12736
|
const elided = elideMiddle(compact, max);
|
|
12782
12737
|
return elided === void 0 ? compact : `${elided.head}${ELISION}${elided.tail}`;
|
|
12783
12738
|
}
|
|
12784
|
-
|
|
12785
|
-
//#region src/modules/status/models/ui-protocol.ts
|
|
12739
|
+
// src/modules/status/models/ui-protocol.ts
|
|
12786
12740
|
const UI_COMMAND_PREFIX = "opencode-permission-reviewer.status.";
|
|
12787
12741
|
function permissionAction(request) {
|
|
12788
12742
|
const metadata = request.metadata;
|
|
@@ -12832,8 +12786,7 @@ function decodeUiStatus(command) {
|
|
|
12832
12786
|
return;
|
|
12833
12787
|
}
|
|
12834
12788
|
}
|
|
12835
|
-
|
|
12836
|
-
//#region src/modules/status/services/ui-heredoc-lines.ts
|
|
12789
|
+
// src/modules/status/services/ui-heredoc-lines.ts
|
|
12837
12790
|
const PLACEHOLDER$1 = /<HEREDOC:sha256:[0-9a-f]{12}>/g;
|
|
12838
12791
|
/** How the sanitized command marks a delimiter it could not resolve. */
|
|
12839
12792
|
const UNRESOLVED = "'<unresolved>' ";
|
|
@@ -12885,8 +12838,7 @@ function heredocBodies(command, extraction) {
|
|
|
12885
12838
|
}
|
|
12886
12839
|
return bodies.length === heredocs.length ? bodies : void 0;
|
|
12887
12840
|
}
|
|
12888
|
-
|
|
12889
|
-
//#region src/modules/status/services/ui-heredoc-scan.ts
|
|
12841
|
+
// src/modules/status/services/ui-heredoc-scan.ts
|
|
12890
12842
|
const PLACEHOLDER = /<HEREDOC:sha256:[0-9a-f]{12}>/g;
|
|
12891
12843
|
/** An operator as the extractor writes it: `<<` or `<<-`, the delimiter bare
|
|
12892
12844
|
* or single-quoted, then a space and the body placeholder. */
|
|
@@ -13015,8 +12967,7 @@ function heredocOperators(sanitized) {
|
|
|
13015
12967
|
const placeholders = Array.from(sanitized.matchAll(PLACEHOLDER)).length;
|
|
13016
12968
|
return scan.failed || scan.operators.length !== placeholders ? void 0 : scan.operators;
|
|
13017
12969
|
}
|
|
13018
|
-
|
|
13019
|
-
//#region src/modules/status/services/ui-heredoc-redirects.ts
|
|
12970
|
+
// src/modules/status/services/ui-heredoc-redirects.ts
|
|
13020
12971
|
/** Walks the sanitized command and the original side by side. They agree
|
|
13021
12972
|
* everywhere except the operator words and the bodies the original has
|
|
13022
12973
|
* after each start line. */
|
|
@@ -13095,8 +13046,7 @@ function heredocRedirects(command, extraction) {
|
|
|
13095
13046
|
}
|
|
13096
13047
|
return alignment.advanceTo(extraction.sanitizedCommand.length) && alignment.atEnd() ? redirects : void 0;
|
|
13097
13048
|
}
|
|
13098
|
-
|
|
13099
|
-
//#region src/modules/status/services/ui-raw-source.ts
|
|
13049
|
+
// src/modules/status/services/ui-raw-source.ts
|
|
13100
13050
|
/** The display puts a space beside a separator, which the shell ignores
|
|
13101
13051
|
* unless the neighbour is one of these. */
|
|
13102
13052
|
const OPERATOR_CHARS = /[<>|&;]/;
|
|
@@ -13153,8 +13103,7 @@ function onlySkipped(source, from, to, lineBreaks) {
|
|
|
13153
13103
|
function touchesOperator(source, span) {
|
|
13154
13104
|
return span.start < span.end && (OPERATOR_CHARS.test(source.charAt(span.start - 1)) || OPERATOR_CHARS.test(source.charAt(span.end)));
|
|
13155
13105
|
}
|
|
13156
|
-
|
|
13157
|
-
//#region src/modules/status/services/ui-segment-builder.ts
|
|
13106
|
+
// src/modules/status/services/ui-segment-builder.ts
|
|
13158
13107
|
/** Longest text one segment keeps; a longer one keeps its head and tail. */
|
|
13159
13108
|
const MAX_SEGMENT_CHARS = 200;
|
|
13160
13109
|
const SPLITTERS = /* @__PURE__ */ new Set([
|
|
@@ -13279,8 +13228,7 @@ var SegmentBuilder = class {
|
|
|
13279
13228
|
this.lines = void 0;
|
|
13280
13229
|
}
|
|
13281
13230
|
};
|
|
13282
|
-
|
|
13283
|
-
//#region src/modules/status/services/ui-action-segments.ts
|
|
13231
|
+
// src/modules/status/services/ui-action-segments.ts
|
|
13284
13232
|
/** Longest command segmented; a longer one keeps only the bounded `action`. */
|
|
13285
13233
|
const MAX_COMMAND_CHARS = 65536;
|
|
13286
13234
|
/** Tokens one lexing pass may produce; running out means no segments. */
|
|
@@ -13351,8 +13299,7 @@ function createServerUiStatus(request, phase, options) {
|
|
|
13351
13299
|
});
|
|
13352
13300
|
return keepsSegments(plain, full) ? full : plain;
|
|
13353
13301
|
}
|
|
13354
|
-
|
|
13355
|
-
//#region src/modules/status/models/failure-kind.ts
|
|
13302
|
+
// src/modules/status/models/failure-kind.ts
|
|
13356
13303
|
const FAILED_NAME = /\bfailed \(([A-Za-z]+)/;
|
|
13357
13304
|
const TIMED_OUT = /\btimed out\b/i;
|
|
13358
13305
|
/** The TypeSafe SDK errors Jev's invoker throws, as the short words the TUI shows. */
|
|
@@ -13377,8 +13324,7 @@ function failureKind(reason) {
|
|
|
13377
13324
|
if (name === "Error") return "error";
|
|
13378
13325
|
return SDK_KINDS.get(name) ?? name.replace(/Error$/, "").toLowerCase();
|
|
13379
13326
|
}
|
|
13380
|
-
|
|
13381
|
-
//#region src/modules/status/services/ui-status-routing.ts
|
|
13327
|
+
// src/modules/status/services/ui-status-routing.ts
|
|
13382
13328
|
/** The hand-off to show; a `jev-failure` one names the failure kind its
|
|
13383
13329
|
* reason records. */
|
|
13384
13330
|
function handoffInfo(from, to, trigger, reason) {
|
|
@@ -13430,8 +13376,7 @@ function configNoticeFields(config) {
|
|
|
13430
13376
|
...configDegraded.length === 0 ? {} : { configDegraded }
|
|
13431
13377
|
};
|
|
13432
13378
|
}
|
|
13433
|
-
|
|
13434
|
-
//#region src/modules/review/services/review-status.ts
|
|
13379
|
+
// src/modules/review/services/review-status.ts
|
|
13435
13380
|
/** The reviewer variant to show: the escalation reviewer's when another model
|
|
13436
13381
|
* decided, System One's label for a System One model, else the configured one. */
|
|
13437
13382
|
function statusVariant(config, reviewerModel) {
|
|
@@ -13484,8 +13429,7 @@ function publishHandoffStatus(scope, request, handoff) {
|
|
|
13484
13429
|
handoff
|
|
13485
13430
|
}).catch(() => {});
|
|
13486
13431
|
}
|
|
13487
|
-
|
|
13488
|
-
//#region src/modules/review/services/review-disposition.ts
|
|
13432
|
+
// src/modules/review/services/review-disposition.ts
|
|
13489
13433
|
/**
|
|
13490
13434
|
* Reject a request with `reject` while honoring supersede. Returns `undefined`
|
|
13491
13435
|
* when the rejection was applied, or the supersede result when the request had
|
|
@@ -13531,8 +13475,7 @@ function logReviewFailure(state, request, error) {
|
|
|
13531
13475
|
error: error instanceof Error ? error.message : String(error)
|
|
13532
13476
|
});
|
|
13533
13477
|
}
|
|
13534
|
-
|
|
13535
|
-
//#region src/modules/review/services/review-limiter.ts
|
|
13478
|
+
// src/modules/review/services/review-limiter.ts
|
|
13536
13479
|
/** Bounded FIFO admission. Queueing consumes the caller's existing deadline. */
|
|
13537
13480
|
var ReviewLimiter = class {
|
|
13538
13481
|
concurrency;
|
|
@@ -13575,8 +13518,7 @@ var ReviewLimiter = class {
|
|
|
13575
13518
|
});
|
|
13576
13519
|
}
|
|
13577
13520
|
};
|
|
13578
|
-
|
|
13579
|
-
//#region src/modules/analysis/brake/brake-rm-flags.ts
|
|
13521
|
+
// src/modules/analysis/brake/brake-rm-flags.ts
|
|
13580
13522
|
/** Long options resolve like getopt_long, abbreviations included; options
|
|
13581
13523
|
* after `--` are operands (`splitArguments`). */
|
|
13582
13524
|
function hasRmFlags(command) {
|
|
@@ -13608,8 +13550,7 @@ function applyRmShortCluster(flags, cluster) {
|
|
|
13608
13550
|
if (cluster.includes("r") || cluster.includes("R")) flags.recursive = true;
|
|
13609
13551
|
if (cluster.includes("f")) flags.force = true;
|
|
13610
13552
|
}
|
|
13611
|
-
|
|
13612
|
-
//#region src/modules/analysis/brake/brake-find-exec.ts
|
|
13553
|
+
// src/modules/analysis/brake/brake-find-exec.ts
|
|
13613
13554
|
const EXEC_ACTIONS = /* @__PURE__ */ new Set([
|
|
13614
13555
|
"-exec",
|
|
13615
13556
|
"-execdir",
|
|
@@ -13696,8 +13637,7 @@ function argvEnd(words, start) {
|
|
|
13696
13637
|
}
|
|
13697
13638
|
return words.length;
|
|
13698
13639
|
}
|
|
13699
|
-
|
|
13700
|
-
//#region src/modules/analysis/brake/brake-root-target.ts
|
|
13640
|
+
// src/modules/analysis/brake/brake-root-target.ts
|
|
13701
13641
|
/** Whether a command operand names the filesystem root, literally or as a
|
|
13702
13642
|
* live glob over its entries. */
|
|
13703
13643
|
function targetsRoot(token) {
|
|
@@ -13749,8 +13689,7 @@ function componentsReachRoot(components) {
|
|
|
13749
13689
|
}
|
|
13750
13690
|
return stack.length === 0;
|
|
13751
13691
|
}
|
|
13752
|
-
|
|
13753
|
-
//#region src/modules/analysis/brake/brake-find-root.ts
|
|
13692
|
+
// src/modules/analysis/brake/brake-find-root.ts
|
|
13754
13693
|
/** The letters of the flags find accepts before its paths, alone or
|
|
13755
13694
|
* clustered (`-H -L -P -E -X -d -s -x`, e.g. `-dx`). A cluster may end in
|
|
13756
13695
|
* `f`, which takes a path (`-D` and `-O<level>` are handled apart). */
|
|
@@ -13863,8 +13802,7 @@ function leadingCluster(value) {
|
|
|
13863
13802
|
function startsExpression(value) {
|
|
13864
13803
|
return isOptionWord(value) || EXPRESSION_STARTS.has(value);
|
|
13865
13804
|
}
|
|
13866
|
-
|
|
13867
|
-
//#region src/modules/analysis/brake/brake-find-walk.ts
|
|
13805
|
+
// src/modules/analysis/brake/brake-find-walk.ts
|
|
13868
13806
|
/** The find commands among `commands` and among the commands their exec
|
|
13869
13807
|
* actions run, at any depth, or `undefined` when any exec walk hits a limit.
|
|
13870
13808
|
* The exec walks of a nested find are charged to the shared `budget` per
|
|
@@ -13887,8 +13825,7 @@ function analyzeFinds(commands, budget) {
|
|
|
13887
13825
|
}
|
|
13888
13826
|
return finds;
|
|
13889
13827
|
}
|
|
13890
|
-
|
|
13891
|
-
//#region src/modules/analysis/brake/brake-script-feeds.ts
|
|
13828
|
+
// src/modules/analysis/brake/brake-script-feeds.ts
|
|
13892
13829
|
/** Adds the scripts the commands of `parts` read to `bodies.feeds`, which the
|
|
13893
13830
|
* brake judges after the commands heredoc bodies run. A heredoc whose script
|
|
13894
13831
|
* is not recorded makes the feeds unresolved. */
|
|
@@ -13903,8 +13840,7 @@ function keepScriptFeeds(parts, bodies) {
|
|
|
13903
13840
|
function keepFeedsUnresolved(bodies) {
|
|
13904
13841
|
feedsOf(bodies).unresolved = true;
|
|
13905
13842
|
}
|
|
13906
|
-
|
|
13907
|
-
//#region src/modules/analysis/brake/brake-analyzed-segments.ts
|
|
13843
|
+
// src/modules/analysis/brake/brake-analyzed-segments.ts
|
|
13908
13844
|
/** Lexes the command and resolves every segment's effective commands under
|
|
13909
13845
|
* one shared budget, or returns `undefined` when any limit is hit. The
|
|
13910
13846
|
* commands that heredoc bodies in its substitutions and in the command
|
|
@@ -13969,8 +13905,7 @@ function analyzeSegment(segment, budget) {
|
|
|
13969
13905
|
finds
|
|
13970
13906
|
};
|
|
13971
13907
|
}
|
|
13972
|
-
|
|
13973
|
-
//#region src/modules/analysis/brake/brake-block-device.ts
|
|
13908
|
+
// src/modules/analysis/brake/brake-block-device.ts
|
|
13974
13909
|
/**
|
|
13975
13910
|
* Whitelist of real block-device path prefixes so that pseudo-devices
|
|
13976
13911
|
* (`/dev/null`, `/dev/zero`, `/dev/shm/…`, `/dev/fd/…`, etc.) — which sit under
|
|
@@ -14032,8 +13967,7 @@ function unquotedRedirectOperators(token) {
|
|
|
14032
13967
|
}
|
|
14033
13968
|
return out;
|
|
14034
13969
|
}
|
|
14035
|
-
|
|
14036
|
-
//#region src/modules/analysis/brake/brake-device-copy.ts
|
|
13970
|
+
// src/modules/analysis/brake/brake-device-copy.ts
|
|
14037
13971
|
const CP_VALUE_OPTIONS = /* @__PURE__ */ new Set(["-S", "-t"]);
|
|
14038
13972
|
const INSTALL_VALUE_OPTIONS = /* @__PURE__ */ new Set([
|
|
14039
13973
|
"-g",
|
|
@@ -14087,8 +14021,7 @@ function applyShortCluster(parsed, cluster, valueOptions) {
|
|
|
14087
14021
|
}
|
|
14088
14022
|
return 0;
|
|
14089
14023
|
}
|
|
14090
|
-
|
|
14091
|
-
//#region src/modules/analysis/brake/brake-formatter-options.ts
|
|
14024
|
+
// src/modules/analysis/brake/brake-formatter-options.ts
|
|
14092
14025
|
/** e2fsprogs mke2fs (misc/mke2fs.c `PRS`), which has no long options. */
|
|
14093
14026
|
const MKE2FS = {
|
|
14094
14027
|
optstring: "b:cd:e:g:i:jl:m:no:qr:s:t:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:Vz:",
|
|
@@ -14186,8 +14119,7 @@ function shortTypeValue(word, next) {
|
|
|
14186
14119
|
if (letter === -1) return void 0;
|
|
14187
14120
|
return letter + 1 < word.length ? word.slice(letter + 1) : next;
|
|
14188
14121
|
}
|
|
14189
|
-
|
|
14190
|
-
//#region src/modules/analysis/brake/brake-format-tools.ts
|
|
14122
|
+
// src/modules/analysis/brake/brake-format-tools.ts
|
|
14191
14123
|
const NOT_AN_OPTION = {
|
|
14192
14124
|
dryRun: false,
|
|
14193
14125
|
takesNext: false
|
|
@@ -14255,8 +14187,7 @@ function letterArgument(optstring, letter) {
|
|
|
14255
14187
|
if (at === -1 || optstring.charAt(at + 1) !== ":") return "none";
|
|
14256
14188
|
return optstring.charAt(at + 2) === ":" ? "optional" : "required";
|
|
14257
14189
|
}
|
|
14258
|
-
|
|
14259
|
-
//#region src/modules/analysis/brake/brake-partition-tools.ts
|
|
14190
|
+
// src/modules/analysis/brake/brake-partition-tools.ts
|
|
14260
14191
|
const SGDISK_ZAP_OPTIONS = /* @__PURE__ */ new Set(["--zap-all", "--zap"]);
|
|
14261
14192
|
/** The sgdisk (popt) short options that take a value. */
|
|
14262
14193
|
const SGDISK_VALUE_LETTERS = new Set("A a b B c d h i j k l m n N r R S t T u U".split(" "));
|
|
@@ -14355,8 +14286,7 @@ function partedCommand(word) {
|
|
|
14355
14286
|
const partial = PARTED_COMMANDS.filter((names) => names.some((name) => name.startsWith(lower)));
|
|
14356
14287
|
return partial.length === 1 ? partial[0]?.[0] : void 0;
|
|
14357
14288
|
}
|
|
14358
|
-
|
|
14359
|
-
//#region src/modules/analysis/brake/brake-device-tools.ts
|
|
14289
|
+
// src/modules/analysis/brake/brake-device-tools.ts
|
|
14360
14290
|
const MKFS_FAMILY = /^mkfs(?:\.[a-z0-9]+)?$/;
|
|
14361
14291
|
const DEVICE_TOOL_CHECKS = /* @__PURE__ */ new Map([
|
|
14362
14292
|
["tee", overwritesBlockOperand],
|
|
@@ -14426,8 +14356,7 @@ function clusterErases(letters) {
|
|
|
14426
14356
|
function ddWritesBlockDevice(tool) {
|
|
14427
14357
|
return tool.args.some((t) => t.value.startsWith("of=") && isBlockDeviceTarget(t.value.slice(3)));
|
|
14428
14358
|
}
|
|
14429
|
-
|
|
14430
|
-
//#region src/modules/analysis/brake/brake-heredoc-texts.ts
|
|
14359
|
+
// src/modules/analysis/brake/brake-heredoc-texts.ts
|
|
14431
14360
|
let last;
|
|
14432
14361
|
/** The heredoc readings of `command`. The brake reads one command under
|
|
14433
14362
|
* each quote reading in turn, so the last command's readings are kept. */
|
|
@@ -14446,8 +14375,7 @@ function heredocTexts(command) {
|
|
|
14446
14375
|
};
|
|
14447
14376
|
return texts;
|
|
14448
14377
|
}
|
|
14449
|
-
|
|
14450
|
-
//#region src/modules/analysis/brake/brake-logical-lines.ts
|
|
14378
|
+
// src/modules/analysis/brake/brake-logical-lines.ts
|
|
14451
14379
|
/** The logical lines of `command`: each physical line on its own, except that
|
|
14452
14380
|
* a line ending in a backslash continuation joins the line after it. */
|
|
14453
14381
|
function logicalLines(command) {
|
|
@@ -14464,8 +14392,7 @@ function logicalLines(command) {
|
|
|
14464
14392
|
if (joined !== "") lines.push(joined);
|
|
14465
14393
|
return lines;
|
|
14466
14394
|
}
|
|
14467
|
-
|
|
14468
|
-
//#region src/modules/analysis/brake/brake-network-export.ts
|
|
14395
|
+
// src/modules/analysis/brake/brake-network-export.ts
|
|
14469
14396
|
const SECRET_EXPORT_UTILITIES = /* @__PURE__ */ new Set([
|
|
14470
14397
|
"curl",
|
|
14471
14398
|
"wget",
|
|
@@ -14488,8 +14415,7 @@ function commandExportsSecret(command, redirections) {
|
|
|
14488
14415
|
const args = [...command.slice(1).map((token) => token.value), ...redirections.filter((redirection) => redirection.operator.includes("<")).map((redirection) => redirection.target)].join(" ");
|
|
14489
14416
|
return SECRET_EXPORT_TARGETS.some((pattern) => pattern.test(args));
|
|
14490
14417
|
}
|
|
14491
|
-
|
|
14492
|
-
//#region src/modules/analysis/brake/brake-root-rm.ts
|
|
14418
|
+
// src/modules/analysis/brake/brake-root-rm.ts
|
|
14493
14419
|
function isRootRm(command) {
|
|
14494
14420
|
if (commandName(command) !== "rm") return false;
|
|
14495
14421
|
const flags = hasRmFlags(command);
|
|
@@ -14497,8 +14423,7 @@ function isRootRm(command) {
|
|
|
14497
14423
|
const rootProtectionOff = flags.force || flags.noPreserveRoot;
|
|
14498
14424
|
return splitArguments(command).operands.some((operand) => isLiveRootGlob(operand) || rootProtectionOff && resolvesToRoot(operand.value));
|
|
14499
14425
|
}
|
|
14500
|
-
|
|
14501
|
-
//#region src/modules/analysis/brake/brake-readings.ts
|
|
14426
|
+
// src/modules/analysis/brake/brake-readings.ts
|
|
14502
14427
|
const ROOT_DESTRUCTION_REGEX = [/:\s*\(\s*\)\s*\{\s*:\s*\|\s*:\s*&\s*\}\s*;\s*:/];
|
|
14503
14428
|
const ROOT_DESTRUCTION_REASON = "Emergency brake: command contains unmistakable broad system destruction.";
|
|
14504
14429
|
const SECRET_EXPORT_REASON = "Emergency brake: command appears to export credential material through a network utility.";
|
|
@@ -14560,8 +14485,7 @@ function brakeReadingsReason(command, quoting, bodies) {
|
|
|
14560
14485
|
function readsLikeDefault(text, checked) {
|
|
14561
14486
|
return checked.has(text) && !text.includes("<") && !text.includes("\\");
|
|
14562
14487
|
}
|
|
14563
|
-
|
|
14564
|
-
//#region src/modules/analysis/brake/brake-body-commands.ts
|
|
14488
|
+
// src/modules/analysis/brake/brake-body-commands.ts
|
|
14565
14489
|
/** How many distinct body commands one request may judge. Each runs every
|
|
14566
14490
|
* reading of the brake, so this bounds the time a request takes. */
|
|
14567
14491
|
const MAX_BODY_COMMANDS = 1024;
|
|
@@ -14589,8 +14513,7 @@ function bodyCommandsReason(commands, unresolved, depth, judge, budget) {
|
|
|
14589
14513
|
if (reason !== void 0) return reason;
|
|
14590
14514
|
}
|
|
14591
14515
|
}
|
|
14592
|
-
|
|
14593
|
-
//#region src/modules/analysis/brake/emergency-brake.ts
|
|
14516
|
+
// src/modules/analysis/brake/emergency-brake.ts
|
|
14594
14517
|
function emergencyBrakeReason(request) {
|
|
14595
14518
|
if (request.permission !== "bash") return;
|
|
14596
14519
|
const command = reviewedCommand(request);
|
|
@@ -14625,8 +14548,7 @@ function commandReason(command, depth, budget, scripts) {
|
|
|
14625
14548
|
function readingsReason(command, bodies) {
|
|
14626
14549
|
return brakeReadingsReason(command, "finder", bodies) ?? brakeReadingsReason(command, "rescan", bodies) ?? brakeReadingsReason(command, "undecoded", bodies) ?? brakeReadingsReason(command, "previous", bodies);
|
|
14627
14550
|
}
|
|
14628
|
-
|
|
14629
|
-
//#region src/modules/policy/policy-conditions.ts
|
|
14551
|
+
// src/modules/policy/policy-conditions.ts
|
|
14630
14552
|
/** Whether every field of a condition matches the observed facts. A missing
|
|
14631
14553
|
* condition (or `{ always: true }`) is a universal rule: it matches any
|
|
14632
14554
|
* request, which is why `validateCondition` rejects a condition that
|
|
@@ -14667,8 +14589,7 @@ const CAPABILITY_FLAG_FACTS = {
|
|
|
14667
14589
|
function capabilityFlagsHold(cond, cap) {
|
|
14668
14590
|
return CONDITION_FLAG_KEYS.every((flag) => cond[flag] !== true || CAPABILITY_FLAG_FACTS[flag](cap) === true);
|
|
14669
14591
|
}
|
|
14670
|
-
|
|
14671
|
-
//#region src/modules/policy/policy-engine.ts
|
|
14592
|
+
// src/modules/policy/policy-engine.ts
|
|
14672
14593
|
const EFFECT_SEVERITY = {
|
|
14673
14594
|
deny: 3,
|
|
14674
14595
|
manual: 2,
|
|
@@ -14738,8 +14659,7 @@ function hashEffectivePolicy(rules, config) {
|
|
|
14738
14659
|
});
|
|
14739
14660
|
return createHash("sha256").update(`${rulesCanonical}#${decisionConfig}`).digest("hex").slice(0, 16);
|
|
14740
14661
|
}
|
|
14741
|
-
|
|
14742
|
-
//#region src/modules/review/services/review-result-gates.ts
|
|
14662
|
+
// src/modules/review/services/review-result-gates.ts
|
|
14743
14663
|
function gateReviewedResult(request, config, envelope, reviewed) {
|
|
14744
14664
|
const result = reviewed.kind === "allow" ? gateAllow(reviewed, config, envelope) : reviewed;
|
|
14745
14665
|
const disposed = result.kind === "escalate" && result.escalationDisposition === void 0 ? applyEscalationDisposition(result, config, "general") : result;
|
|
@@ -14779,8 +14699,7 @@ function needsScriptGuidance(request, envelope, disposed) {
|
|
|
14779
14699
|
"unresolved"
|
|
14780
14700
|
].includes(entry.stdinStatus ?? "")) || /(?:(?:script|guion).{0,120}(?:truncat|truncad|unavailable|incomplet|not inspect|no.{0,20}inspeccion)|(?:truncat|truncad|incomplet).{0,120}(?:script|guion))/i.test(disposed.reason));
|
|
14781
14701
|
}
|
|
14782
|
-
|
|
14783
|
-
//#region src/modules/review/services/review-engine.ts
|
|
14702
|
+
// src/modules/review/services/review-engine.ts
|
|
14784
14703
|
/** Evaluate policy and evidence without applying a permission or publishing UI. */
|
|
14785
14704
|
async function evaluateReview(request, config, ports) {
|
|
14786
14705
|
const early = beforeCollect(request, ports);
|
|
@@ -14851,8 +14770,7 @@ function enforcedRoute(trace, config) {
|
|
|
14851
14770
|
if (trace.finalRoute === "deny") return deny(`Declarative policy route: deny. ${trace.matchedRules.map((m) => m.reason).join("; ")}`, false);
|
|
14852
14771
|
if (trace.finalRoute === "manual") return escalate(`Declarative policy route: manual. ${trace.matchedRules.map((m) => m.reason).join("; ")}`, config);
|
|
14853
14772
|
}
|
|
14854
|
-
|
|
14855
|
-
//#region src/modules/review/services/review-pipeline.ts
|
|
14773
|
+
// src/modules/review/services/review-pipeline.ts
|
|
14856
14774
|
async function processRequest(state, request) {
|
|
14857
14775
|
const attempt = state.attempts.get(request.id);
|
|
14858
14776
|
invariant(attempt, ATTEMPT_REGISTERED);
|
|
@@ -14895,8 +14813,7 @@ function runReviewer(state, envelope) {
|
|
|
14895
14813
|
invariant(attempt, ATTEMPT_REGISTERED);
|
|
14896
14814
|
return state.backend.review(envelope, attempt, (handoff) => publishHandoffStatus(state, envelope.request, handoff));
|
|
14897
14815
|
}
|
|
14898
|
-
|
|
14899
|
-
//#region src/modules/review/services/review-coordinator.ts
|
|
14816
|
+
// src/modules/review/services/review-coordinator.ts
|
|
14900
14817
|
/**
|
|
14901
14818
|
* Owns the review lifecycle for permission requests: orchestration, the
|
|
14902
14819
|
* supersede state machine, and the model call. The adapter (transport) and the
|
|
@@ -14973,8 +14890,7 @@ var ReviewCoordinator = class {
|
|
|
14973
14890
|
*/
|
|
14974
14891
|
annotateToolResult(callID, output) {}
|
|
14975
14892
|
};
|
|
14976
|
-
|
|
14977
|
-
//#region src/adapters/opencode/transport.ts
|
|
14893
|
+
// src/adapters/opencode/transport.ts
|
|
14978
14894
|
function responseData(response, label) {
|
|
14979
14895
|
if (response.error !== void 0) throw new Error(`${label} failed: ${JSON.stringify(response.error)}`);
|
|
14980
14896
|
if (response.data === void 0) throw new Error(`${label} returned no data`);
|
|
@@ -15016,8 +14932,7 @@ function isAlreadyResolvedError(error) {
|
|
|
15016
14932
|
const message = typeof record.message === "string" ? record.message : "";
|
|
15017
14933
|
return /PermissionNotFound|not\s*found|no\s+longer\s+(?:pending|exist)s?|already\s+(?:been\s+)?(?:resolved|answered|replied|closed)/i.test(message);
|
|
15018
14934
|
}
|
|
15019
|
-
|
|
15020
|
-
//#region src/modules/decision/decision-gates.ts
|
|
14935
|
+
// src/modules/decision/decision-gates.ts
|
|
15021
14936
|
/**
|
|
15022
14937
|
* The escalation reason for an `allow` that the risk matrix or a schema v2
|
|
15023
14938
|
* gate blocks, or `undefined` when the allow stands.
|
|
@@ -15062,8 +14977,7 @@ function enforceDecision(decision, config) {
|
|
|
15062
14977
|
reviewerOutcome
|
|
15063
14978
|
};
|
|
15064
14979
|
}
|
|
15065
|
-
|
|
15066
|
-
//#region src/kernel/review-result.ts
|
|
14980
|
+
// src/kernel/review-result.ts
|
|
15067
14981
|
const SYSTEM_ONE_BASES = [
|
|
15068
14982
|
"authorized_routine",
|
|
15069
14983
|
"authorized_reversible_change",
|
|
@@ -15077,8 +14991,7 @@ const SYSTEM_ONE_BASES = [
|
|
|
15077
14991
|
"trusted_policy_restriction",
|
|
15078
14992
|
"conflicting_evidence"
|
|
15079
14993
|
];
|
|
15080
|
-
|
|
15081
|
-
//#region src/modules/reviewer/services/system-one-choices.ts
|
|
14994
|
+
// src/modules/reviewer/services/system-one-choices.ts
|
|
15082
14995
|
/** Whether `value`'s own keys are exactly `expected`. `Object.keys` never
|
|
15083
14996
|
* repeats a key, so a duplicate in `expected` can never match. */
|
|
15084
14997
|
function exactKeys(value, expected) {
|
|
@@ -15119,8 +15032,7 @@ function parseChoice(value, options, tieTolerance = 0) {
|
|
|
15119
15032
|
probabilities
|
|
15120
15033
|
};
|
|
15121
15034
|
}
|
|
15122
|
-
|
|
15123
|
-
//#region src/modules/reviewer/services/system-one-answers.ts
|
|
15035
|
+
// src/modules/reviewer/services/system-one-answers.ts
|
|
15124
15036
|
const OUTCOMES = [
|
|
15125
15037
|
"allow",
|
|
15126
15038
|
"deny",
|
|
@@ -15191,8 +15103,7 @@ function parseAnswers(answers) {
|
|
|
15191
15103
|
signals
|
|
15192
15104
|
};
|
|
15193
15105
|
}
|
|
15194
|
-
|
|
15195
|
-
//#region src/modules/reviewer/services/system-one-questions.ts
|
|
15106
|
+
// src/modules/reviewer/services/system-one-questions.ts
|
|
15196
15107
|
const choice = (instructions, criteria) => ({
|
|
15197
15108
|
type: "choice",
|
|
15198
15109
|
instructions,
|
|
@@ -15267,8 +15178,7 @@ const SYSTEM_ONE_QUESTIONS = {
|
|
|
15267
15178
|
essential_evidence_missing: noul("Is evidence essential to judging the action missing, blocked, truncated, stale, or contradictory?", "A safe allow or deny judgment requires evidence that is not reliably available.", "The material action, intent, targets, and side effects are sufficiently visible."),
|
|
15268
15179
|
absolute_policy_deny: noul("Does `trustedPolicy` unambiguously require denying this action?", "An explicit trusted policy rule requires denial for these facts.", "No absolute trusted-policy denial applies; escalation may still be appropriate.")
|
|
15269
15180
|
};
|
|
15270
|
-
|
|
15271
|
-
//#region src/modules/reviewer/services/system-one-consistency.ts
|
|
15181
|
+
// src/modules/reviewer/services/system-one-consistency.ts
|
|
15272
15182
|
const SAFE_BASES = /* @__PURE__ */ new Set(["authorized_routine", "authorized_reversible_change"]);
|
|
15273
15183
|
const lowRiskSafetySignal = (s) => Math.max(s.unauthorizedDataLoss, s.untrustedSensitiveDisclosure, s.excessiveCredentialAccess, s.unauthorizedSecurityChange);
|
|
15274
15184
|
function dispositionChecks({ decision, basis, supportingConfidence }, config, contradictions) {
|
|
@@ -15304,8 +15214,7 @@ function systemOneContradictions(facts, config) {
|
|
|
15304
15214
|
if (facts.decision.outcome === "allow") allowChecks(facts, contradictions);
|
|
15305
15215
|
return [...new Set(contradictions)];
|
|
15306
15216
|
}
|
|
15307
|
-
|
|
15308
|
-
//#region src/modules/reviewer/services/system-one-verdict.ts
|
|
15217
|
+
// src/modules/reviewer/services/system-one-verdict.ts
|
|
15309
15218
|
function difficultReasonFor(decision, contradictions) {
|
|
15310
15219
|
if (decision.outcome === "escalate") return "System One explicitly requested a reasoning or human review.";
|
|
15311
15220
|
return contradictions.length > 0 ? `System One decision is uncertain or inconsistent: ${contradictions.join("; ")}.` : void 0;
|
|
@@ -15359,8 +15268,7 @@ function systemOneVerdict(answers, decision, returnedModel, config) {
|
|
|
15359
15268
|
}
|
|
15360
15269
|
};
|
|
15361
15270
|
}
|
|
15362
|
-
|
|
15363
|
-
//#region src/modules/reviewer/services/review.ts
|
|
15271
|
+
// src/modules/reviewer/services/review.ts
|
|
15364
15272
|
const BASIS_RATIONALE = {
|
|
15365
15273
|
authorized_routine: "The action is routine, narrow, and adequately authorized.",
|
|
15366
15274
|
authorized_reversible_change: "The action is a bounded, reversible change with sufficient authorization.",
|
|
@@ -15391,7 +15299,9 @@ function reviewDecision(answers) {
|
|
|
15391
15299
|
function responseAnswers(response, config) {
|
|
15392
15300
|
if (!isRecord(response)) return;
|
|
15393
15301
|
const raw = response;
|
|
15394
|
-
if (typeof raw.model !== "string"
|
|
15302
|
+
if (typeof raw.model !== "string") return;
|
|
15303
|
+
const resolved = systemOneProviderFor(config.model);
|
|
15304
|
+
if (!resolved?.provider.acceptsResponse(resolved.modelID, raw.model)) return;
|
|
15395
15305
|
if (!isRecord(raw.answers)) return;
|
|
15396
15306
|
const answers = raw.answers;
|
|
15397
15307
|
if (!exactKeys(answers, Object.keys(SYSTEM_ONE_QUESTIONS))) return;
|
|
@@ -15427,8 +15337,7 @@ function enforceParsedSystemOneReview(parsed, config) {
|
|
|
15427
15337
|
reviewerOutcome: parsed.decision.outcome
|
|
15428
15338
|
};
|
|
15429
15339
|
}
|
|
15430
|
-
|
|
15431
|
-
//#region src/modules/reviewer/services/system-one-invoker.ts
|
|
15340
|
+
// src/modules/reviewer/services/system-one-invoker.ts
|
|
15432
15341
|
/** The state Jev answers on. Marks the envelope's action evidence incomplete
|
|
15433
15342
|
* when the rendered evidence is. */
|
|
15434
15343
|
function systemOneState(envelope, config) {
|
|
@@ -15452,13 +15361,17 @@ const SYSTEM_ONE_RETRY = {
|
|
|
15452
15361
|
apiTimeoutError: false
|
|
15453
15362
|
};
|
|
15454
15363
|
function createSystemOneInvoker(config, fetchImpl) {
|
|
15455
|
-
const
|
|
15456
|
-
|
|
15457
|
-
const
|
|
15458
|
-
|
|
15364
|
+
const resolved = systemOneProviderFor(config.model);
|
|
15365
|
+
if (!resolved) throw new Error(`Unsupported System One reviewer model ${config.model}`);
|
|
15366
|
+
const { provider, modelID } = resolved;
|
|
15367
|
+
const reason = provider.incompatibleReason?.(modelID);
|
|
15368
|
+
if (reason) throw new Error(`${config.model} is known to reject the reviewer's request (${reason})`);
|
|
15369
|
+
const apiKey = process.env[provider.keyEnv]?.trim();
|
|
15370
|
+
if (!apiKey) throw new Error(`Missing ${provider.keyEnv} for System One reviewer ${config.model}`);
|
|
15371
|
+
if (provider.keyShape && !provider.keyShape.pattern.test(apiKey)) throw new Error(provider.keyShape.message);
|
|
15459
15372
|
const client = new TypeSafeClient({
|
|
15460
15373
|
apiKey,
|
|
15461
|
-
...
|
|
15374
|
+
...provider.baseURL ? { baseURL: provider.baseURL } : {},
|
|
15462
15375
|
defaultModel: modelID,
|
|
15463
15376
|
logLevel: "off",
|
|
15464
15377
|
timeout: config.timeoutMs,
|
|
@@ -15479,8 +15392,7 @@ function createSystemOneInvoker(config, fetchImpl) {
|
|
|
15479
15392
|
return data;
|
|
15480
15393
|
};
|
|
15481
15394
|
}
|
|
15482
|
-
|
|
15483
|
-
//#region src/modules/reviewer/services/system-one-ask.ts
|
|
15395
|
+
// src/modules/reviewer/services/system-one-ask.ts
|
|
15484
15396
|
/** Jev's answer, parsed and enforced. Never throws: a failure is an outcome
|
|
15485
15397
|
* the hand-off decision can route. */
|
|
15486
15398
|
async function askJev(config, invoke, envelope, attempt) {
|
|
@@ -15500,15 +15412,14 @@ async function askJev(config, invoke, envelope, attempt) {
|
|
|
15500
15412
|
};
|
|
15501
15413
|
}
|
|
15502
15414
|
}
|
|
15503
|
-
|
|
15504
|
-
//#region src/modules/reviewer/services/system-one-budget.ts
|
|
15415
|
+
// src/modules/reviewer/services/system-one-budget.ts
|
|
15505
15416
|
const TRIGGER_CAUSE = {
|
|
15506
|
-
"jev-escalate": "
|
|
15507
|
-
"jev-uncertain-allow": "
|
|
15508
|
-
"jev-gate": "a safety gate stopped
|
|
15509
|
-
"jev-invalid": "
|
|
15510
|
-
"jev-failure": "
|
|
15511
|
-
"jev-uncertain-deny": "
|
|
15417
|
+
"jev-escalate": "System One escalated",
|
|
15418
|
+
"jev-uncertain-allow": "System One's approval was uncertain",
|
|
15419
|
+
"jev-gate": "a safety gate stopped System One's approval",
|
|
15420
|
+
"jev-invalid": "System One's response was invalid",
|
|
15421
|
+
"jev-failure": "System One failed",
|
|
15422
|
+
"jev-uncertain-deny": "System One's denial was uncertain"
|
|
15512
15423
|
};
|
|
15513
15424
|
/** The escalation when a hand-off is due but the attempt has too little time
|
|
15514
15425
|
* left. No reasoning review ran, so Jev's own disposition applies. */
|
|
@@ -15523,8 +15434,7 @@ function budgetExhaustedResult(own, trigger, remainingMs, config) {
|
|
|
15523
15434
|
resolution: "budget-exhausted"
|
|
15524
15435
|
}, config, own.category);
|
|
15525
15436
|
}
|
|
15526
|
-
|
|
15527
|
-
//#region src/modules/reviewer/services/system-one-handoff.ts
|
|
15437
|
+
// src/modules/reviewer/services/system-one-handoff.ts
|
|
15528
15438
|
/** A denial with a strong policy or safety signal is never second-guessed. */
|
|
15529
15439
|
function denialStaysFinal(signals) {
|
|
15530
15440
|
return signals.absolutePolicyDeny >= .7 || Math.max(signals.unauthorizedDataLoss, signals.untrustedSensitiveDisclosure, signals.excessiveCredentialAccess, signals.unauthorizedSecurityChange, signals.unauthorizedExternalMutation) >= .5;
|
|
@@ -15560,8 +15470,7 @@ function handoffBlock(attempt) {
|
|
|
15560
15470
|
if (!attempt.active()) return "inactive";
|
|
15561
15471
|
return attempt.remainingMs() < 15e3 ? "budget-exhausted" : void 0;
|
|
15562
15472
|
}
|
|
15563
|
-
|
|
15564
|
-
//#region src/modules/reviewer/services/system-one-results.ts
|
|
15473
|
+
// src/modules/reviewer/services/system-one-results.ts
|
|
15565
15474
|
/** Jev's own enforced result, credited to Jev with its scores. */
|
|
15566
15475
|
function systemOneResult(enforced, config, systemOne) {
|
|
15567
15476
|
return {
|
|
@@ -15620,7 +15529,7 @@ function finalJevResult(own, config) {
|
|
|
15620
15529
|
}
|
|
15621
15530
|
/** The reason a reasoning approval stays an escalation when Jev rated the
|
|
15622
15531
|
* request critical risk. */
|
|
15623
|
-
const JEV_CRITICAL_REASON = "
|
|
15532
|
+
const JEV_CRITICAL_REASON = "System One rated this request critical risk; a reasoning approval needs manual review.";
|
|
15624
15533
|
const INSUFFICIENT_EVIDENCE_REASON = "The reasoning reviewer did not find sufficient evidence to override the System One escalation.";
|
|
15625
15534
|
/** A reasoning allow stands only on sufficient evidence, and not when Jev's
|
|
15626
15535
|
* critical rating holds; otherwise it stays an escalation. */
|
|
@@ -15659,8 +15568,7 @@ function reasoningFailureResult(config, error, handoff, systemOne) {
|
|
|
15659
15568
|
resolution: "reasoning-unavailable"
|
|
15660
15569
|
}, config, "reviewer-failure");
|
|
15661
15570
|
}
|
|
15662
|
-
|
|
15663
|
-
//#region src/modules/reviewer/services/backend.ts
|
|
15571
|
+
// src/modules/reviewer/services/backend.ts
|
|
15664
15572
|
/** Calls Jev directly and hands its result to the reasoning reviewer at most
|
|
15665
15573
|
* once, when the hand-off decision says so. */
|
|
15666
15574
|
var SystemOneReviewerBackend = class {
|
|
@@ -15732,8 +15640,7 @@ var SystemOneReviewerBackend = class {
|
|
|
15732
15640
|
}
|
|
15733
15641
|
}
|
|
15734
15642
|
};
|
|
15735
|
-
|
|
15736
|
-
//#region src/adapters/opencode/v1/v1-review-isolation.ts
|
|
15643
|
+
// src/adapters/opencode/v1/v1-review-isolation.ts
|
|
15737
15644
|
/** Refuse symlinks, hardlinks, and special files before opening anything. */
|
|
15738
15645
|
async function assertReplaceable(lstat, path) {
|
|
15739
15646
|
const existing = await lstat(path).catch((error) => {
|
|
@@ -15786,8 +15693,7 @@ async function setupIsolatedDirectory(ctx, log) {
|
|
|
15786
15693
|
return;
|
|
15787
15694
|
}
|
|
15788
15695
|
}
|
|
15789
|
-
|
|
15790
|
-
//#region src/adapters/opencode/v1/v1-isolated-directory.ts
|
|
15696
|
+
// src/adapters/opencode/v1/v1-isolated-directory.ts
|
|
15791
15697
|
/** The reviewer's isolated scratch directory, set up once and then cached. */
|
|
15792
15698
|
var IsolatedReviewerDirectory = class {
|
|
15793
15699
|
ctx;
|
|
@@ -15822,8 +15728,7 @@ var IsolatedReviewerDirectory = class {
|
|
|
15822
15728
|
return this.pending;
|
|
15823
15729
|
}
|
|
15824
15730
|
};
|
|
15825
|
-
|
|
15826
|
-
//#region src/adapters/opencode/v1/v1-review-decision.ts
|
|
15731
|
+
// src/adapters/opencode/v1/v1-review-decision.ts
|
|
15827
15732
|
/** Build the evidence prompt, folding its completeness into the envelope. */
|
|
15828
15733
|
function reviewerEvidencePrompt(envelope, config) {
|
|
15829
15734
|
const policy = config.policy ?? DEFAULT_TENANT_POLICY;
|
|
@@ -15854,8 +15759,7 @@ function reviewerFailure(error, reviewSessionID, config) {
|
|
|
15854
15759
|
decisionSource: "failure-safe"
|
|
15855
15760
|
}, config, "reviewer-failure");
|
|
15856
15761
|
}
|
|
15857
|
-
|
|
15858
|
-
//#region src/adapters/opencode/v1/v1-mcp-guard.ts
|
|
15762
|
+
// src/adapters/opencode/v1/v1-mcp-guard.ts
|
|
15859
15763
|
/** A plain object (or null-prototype) record: the shape `mcp.status` returns. */
|
|
15860
15764
|
function isPlainRecord(inventory) {
|
|
15861
15765
|
if (typeof inventory !== "object" || inventory === null) return false;
|
|
@@ -15893,8 +15797,7 @@ async function assertNoMcpServers$1(client, directory, attempt, timeoutMs) {
|
|
|
15893
15797
|
if (!isPlainRecord(inventory)) throw new Error("reviewer isolation MCP check returned invalid data");
|
|
15894
15798
|
if (Object.keys(inventory).length > 0) throw new Error("Reviewer isolation location contains MCP servers");
|
|
15895
15799
|
}
|
|
15896
|
-
|
|
15897
|
-
//#region src/adapters/opencode/v1/v1-review-session.ts
|
|
15800
|
+
// src/adapters/opencode/v1/v1-review-session.ts
|
|
15898
15801
|
/** Create an instruction-isolated session or fail into the configured error route. */
|
|
15899
15802
|
async function createReviewerSession(client, envelope, isolated, signal, timeoutMs) {
|
|
15900
15803
|
if (isolated === void 0) throw new Error("reviewer isolation unavailable");
|
|
@@ -15934,8 +15837,7 @@ async function deleteReviewerSession(client, config, reviewSessionID, directory)
|
|
|
15934
15837
|
query: { directory }
|
|
15935
15838
|
}), Math.min(config.timeoutMs, 5e3)).catch(() => {});
|
|
15936
15839
|
}
|
|
15937
|
-
|
|
15938
|
-
//#region src/adapters/opencode/v1/v1-review-lifecycle.ts
|
|
15840
|
+
// src/adapters/opencode/v1/v1-review-lifecycle.ts
|
|
15939
15841
|
/** Open a review session in the isolated, MCP-free location. */
|
|
15940
15842
|
async function openReviewSession(run, envelope, attempt) {
|
|
15941
15843
|
const isolated = await attempt.wait(run.isolatedDirectory.resolve());
|
|
@@ -15948,8 +15850,7 @@ async function releaseReviewSession(run, reviewSessionID, sessionDirectory) {
|
|
|
15948
15850
|
run.sessions.delete(reviewSessionID);
|
|
15949
15851
|
await deleteReviewerSession(run.ctx.client, run.config, reviewSessionID, sessionDirectory ?? run.ctx.directory);
|
|
15950
15852
|
}
|
|
15951
|
-
|
|
15952
|
-
//#region src/adapters/opencode/v1/v1-review-prompt.ts
|
|
15853
|
+
// src/adapters/opencode/v1/v1-review-prompt.ts
|
|
15953
15854
|
/** Corrective note for the single text-mode retry; `promptForDecision`
|
|
15954
15855
|
* (v1-review-turn.ts) says why the retry is safe. */
|
|
15955
15856
|
const TEXT_MODE_RETRY_NOTE = "Your previous response could not be parsed as a decision. Respond again with exactly one JSON object conforming to the schema and nothing else - no prose, no Markdown code fences, no commentary, and no copy of the schema.";
|
|
@@ -16015,8 +15916,7 @@ async function promptReviewer(client, config, request, attempt, retryNote) {
|
|
|
16015
15916
|
ms: performance.now() - start
|
|
16016
15917
|
};
|
|
16017
15918
|
}
|
|
16018
|
-
|
|
16019
|
-
//#region src/adapters/opencode/v1/v1-review-turn.ts
|
|
15919
|
+
// src/adapters/opencode/v1/v1-review-turn.ts
|
|
16020
15920
|
/**
|
|
16021
15921
|
* Text mode has no host-side schema retry (json_schema sets `retryCount: 2`),
|
|
16022
15922
|
* so re-prompt once with `TEXT_MODE_RETRY_NOTE`. The retry goes through the
|
|
@@ -16034,8 +15934,7 @@ async function promptForDecision(client, config, { envelope, request, attempt },
|
|
|
16034
15934
|
recordReviewerMs(envelope, first.ms + retry.ms);
|
|
16035
15935
|
return reviewerDecision(parseReviewerResponse(retry.response, outputFormat), request.sessionID, config);
|
|
16036
15936
|
}
|
|
16037
|
-
|
|
16038
|
-
//#region src/adapters/opencode/v1/v1-review-run.ts
|
|
15937
|
+
// src/adapters/opencode/v1/v1-review-run.ts
|
|
16039
15938
|
async function runV1Review(run, envelope, attempt) {
|
|
16040
15939
|
const { providerID, modelID } = splitModel(run.config.model);
|
|
16041
15940
|
const model = {
|
|
@@ -16068,8 +15967,7 @@ async function runV1Review(run, envelope, attempt) {
|
|
|
16068
15967
|
if (reviewSessionID !== void 0) await releaseReviewSession(run, reviewSessionID, sessionDirectory);
|
|
16069
15968
|
}
|
|
16070
15969
|
}
|
|
16071
|
-
|
|
16072
|
-
//#region src/adapters/opencode/v1/reviewer-backend.ts
|
|
15970
|
+
// src/adapters/opencode/v1/reviewer-backend.ts
|
|
16073
15971
|
/** Owns isolated reviewer sessions, model calls, and their bounded cleanup. */
|
|
16074
15972
|
var V1ReviewerBackend = class {
|
|
16075
15973
|
log;
|
|
@@ -16101,8 +15999,7 @@ var V1ReviewerBackend = class {
|
|
|
16101
15999
|
await Promise.allSettled([...this.jobs]);
|
|
16102
16000
|
}
|
|
16103
16001
|
};
|
|
16104
|
-
|
|
16105
|
-
//#region src/adapters/opencode/v1/backend-factory.ts
|
|
16002
|
+
// src/adapters/opencode/v1/backend-factory.ts
|
|
16106
16003
|
function escalationConfig$1(config) {
|
|
16107
16004
|
const escalation = config.escalationReviewer;
|
|
16108
16005
|
if (!escalation) return;
|
|
@@ -16126,8 +16023,7 @@ function createV1ReviewerBackend(ctx, config, log, recordReviewerMs) {
|
|
|
16126
16023
|
}
|
|
16127
16024
|
};
|
|
16128
16025
|
}
|
|
16129
|
-
|
|
16130
|
-
//#region src/adapters/opencode/v1/context-reader.ts
|
|
16026
|
+
// src/adapters/opencode/v1/context-reader.ts
|
|
16131
16027
|
const MAX_INTENT_SCAN_MESSAGES = 2e3;
|
|
16132
16028
|
/** The session's numeric creation time, when its metadata reports one. */
|
|
16133
16029
|
function sessionCreatedAt(metadata) {
|
|
@@ -16197,8 +16093,7 @@ function createV1ContextReader(client, signal) {
|
|
|
16197
16093
|
}
|
|
16198
16094
|
};
|
|
16199
16095
|
}
|
|
16200
|
-
|
|
16201
|
-
//#region src/adapters/opencode/v1/review-host.ts
|
|
16096
|
+
// src/adapters/opencode/v1/review-host.ts
|
|
16202
16097
|
function createV1ReviewHost(ctx) {
|
|
16203
16098
|
return {
|
|
16204
16099
|
context: ctx,
|
|
@@ -16213,8 +16108,7 @@ var V1ReviewCoordinator = class extends ReviewCoordinator {
|
|
|
16213
16108
|
super(createV1ReviewHost(ctx), config, logger, providers, askDecisions);
|
|
16214
16109
|
}
|
|
16215
16110
|
};
|
|
16216
|
-
|
|
16217
|
-
//#region src/adapters/opencode/capability-detection.ts
|
|
16111
|
+
// src/adapters/opencode/capability-detection.ts
|
|
16218
16112
|
/**
|
|
16219
16113
|
* Probe what the host client actually exposes. Every check is a property-type
|
|
16220
16114
|
* test on the client object; nothing is invoked, so the probe is safe to run at
|
|
@@ -16240,8 +16134,7 @@ function probeCapabilities(client) {
|
|
|
16240
16134
|
tuiPublish: typeof tui.publish === "function"
|
|
16241
16135
|
};
|
|
16242
16136
|
}
|
|
16243
|
-
|
|
16244
|
-
//#region src/adapters/opencode/host-guard.ts
|
|
16137
|
+
// src/adapters/opencode/host-guard.ts
|
|
16245
16138
|
/**
|
|
16246
16139
|
* OpenCode V2 host versions accepted at setup. A host outside this range
|
|
16247
16140
|
* fails setup loudly instead of running against an unknown contract.
|
|
@@ -16259,8 +16152,7 @@ function assertV1Host(client) {
|
|
|
16259
16152
|
const raw = record._client ?? {};
|
|
16260
16153
|
if (typeof permission.reply === "function" && typeof raw.post !== "function") throw new Error("The V1 adapter requires the authenticated legacy transport. Use the setup entrypoint for OpenCode V2; refusing this incompatible client.");
|
|
16261
16154
|
}
|
|
16262
|
-
|
|
16263
|
-
//#region src/adapters/opencode/reply-transport.ts
|
|
16155
|
+
// src/adapters/opencode/reply-transport.ts
|
|
16264
16156
|
/**
|
|
16265
16157
|
* Resolve how a permission reply is sent. The priority is: a public SDK reply
|
|
16266
16158
|
* that can carry the feedback `message`, then a public reply plus a separate
|
|
@@ -16288,8 +16180,7 @@ function createReplyTransport(deps) {
|
|
|
16288
16180
|
});
|
|
16289
16181
|
} };
|
|
16290
16182
|
}
|
|
16291
|
-
|
|
16292
|
-
//#region src/adapters/opencode/v1-adapter.ts
|
|
16183
|
+
// src/adapters/opencode/v1-adapter.ts
|
|
16293
16184
|
/**
|
|
16294
16185
|
* Build the V1 {@link RuntimeContext} against OpenCode's authenticated raw
|
|
16295
16186
|
* transport. Probes the host client's capabilities, refuses a v2-generation
|
|
@@ -16344,8 +16235,7 @@ function createV1Adapter(input, logger) {
|
|
|
16344
16235
|
worktree: input.worktree
|
|
16345
16236
|
};
|
|
16346
16237
|
}
|
|
16347
|
-
|
|
16348
|
-
//#region src/utils/descriptor-io.ts
|
|
16238
|
+
// src/utils/descriptor-io.ts
|
|
16349
16239
|
const O_RDONLY = typeof constants.O_RDONLY === "number" ? constants.O_RDONLY : 0;
|
|
16350
16240
|
const O_WRONLY = typeof constants.O_WRONLY === "number" ? constants.O_WRONLY : 0;
|
|
16351
16241
|
const O_CREAT = typeof constants.O_CREAT === "number" ? constants.O_CREAT : 0;
|
|
@@ -16369,8 +16259,7 @@ function closeQuietly(fd) {
|
|
|
16369
16259
|
closeSync(fd);
|
|
16370
16260
|
} catch {}
|
|
16371
16261
|
}
|
|
16372
|
-
|
|
16373
|
-
//#region src/modules/config/services/jsonc.ts
|
|
16262
|
+
// src/modules/config/services/jsonc.ts
|
|
16374
16263
|
/** Strict variant used by the config loader: throws on a syntax error or on a
|
|
16375
16264
|
* top-level non-object so callers can distinguish a malformed config file
|
|
16376
16265
|
* (worth warning about) from a missing one (the common case). */
|
|
@@ -16441,8 +16330,7 @@ function dropTrailingComma(state) {
|
|
|
16441
16330
|
if (j >= 0) state.out = state.out.slice(0, j);
|
|
16442
16331
|
state.lastReal = "";
|
|
16443
16332
|
}
|
|
16444
|
-
|
|
16445
|
-
//#region src/modules/config/services/layer-read.ts
|
|
16333
|
+
// src/modules/config/services/layer-read.ts
|
|
16446
16334
|
/** Cap on a single config file read: the project layer is repository-controlled
|
|
16447
16335
|
* and read at startup, so an unbounded read lets a committed symlink to an
|
|
16448
16336
|
* endless source exhaust memory. A file over the cap is treated like any
|
|
@@ -16527,8 +16415,7 @@ function readBytes(fd, length) {
|
|
|
16527
16415
|
const read = readFully(fd, buffer, length, 0);
|
|
16528
16416
|
return (read < length ? buffer.subarray(0, read) : buffer).toString("utf8");
|
|
16529
16417
|
}
|
|
16530
|
-
|
|
16531
|
-
//#region src/modules/config/services/risk-policy-clamp.ts
|
|
16418
|
+
// src/modules/config/services/risk-policy-clamp.ts
|
|
16532
16419
|
/** Ensure project riskPolicy can only tighten the trusted baseline. */
|
|
16533
16420
|
function clampRiskPolicy(project, trusted) {
|
|
16534
16421
|
const out = {
|
|
@@ -16574,8 +16461,7 @@ function raisedMinimumConfidence(projectValue, trustedValue) {
|
|
|
16574
16461
|
if (typeof projectValue === "number" && Number.isFinite(projectValue)) return Math.max(trustedMin, projectValue);
|
|
16575
16462
|
return trustedMin;
|
|
16576
16463
|
}
|
|
16577
|
-
|
|
16578
|
-
//#region src/modules/config/services/trust-boundary-keys.ts
|
|
16464
|
+
// src/modules/config/services/trust-boundary-keys.ts
|
|
16579
16465
|
/** Fields managed by the trust boundary. For these, the boundary's output is
|
|
16580
16466
|
* final: the project layer may only tighten them against the trusted
|
|
16581
16467
|
* baseline (which already includes inline), and a later inline value must not
|
|
@@ -16676,8 +16562,7 @@ const CONFIDENCE_FLOOR_KEYS = [
|
|
|
16676
16562
|
"systemOneConfidenceThreshold",
|
|
16677
16563
|
"systemOneReasoningThreshold"
|
|
16678
16564
|
];
|
|
16679
|
-
|
|
16680
|
-
//#region src/modules/config/services/trust-boundary.ts
|
|
16565
|
+
// src/modules/config/services/trust-boundary.ts
|
|
16681
16566
|
/** Whether the key is present in the layer (a `null`/wrong-type value must be
|
|
16682
16567
|
* handled as a present-but-invalid override, never silently forwarded). */
|
|
16683
16568
|
function hasKey(object, key) {
|
|
@@ -16769,8 +16654,7 @@ function combinePolicyRules(clamped, trusted) {
|
|
|
16769
16654
|
clamped.policyRules = [...Array.isArray(trusted.policyRules) ? trusted.policyRules : [], ...projectRules];
|
|
16770
16655
|
} else if (Array.isArray(trusted.policyRules)) clamped.policyRules = trusted.policyRules;
|
|
16771
16656
|
}
|
|
16772
|
-
|
|
16773
|
-
//#region src/modules/config/services/trusted-degradation.ts
|
|
16657
|
+
// src/modules/config/services/trusted-degradation.ts
|
|
16774
16658
|
/** Trusted mode fields and the values resolveConfig honors. A mistyped mode
|
|
16775
16659
|
* silently falls back to the less restrictive default in resolveConfig, so it
|
|
16776
16660
|
* gets the same fail-closed treatment as a dropped rule: visible degradation
|
|
@@ -16871,8 +16755,7 @@ function mergeLayers(globalRaw, projectRaw, inline, inlineTrust) {
|
|
|
16871
16755
|
function boundaryFields(options) {
|
|
16872
16756
|
return Object.fromEntries(Object.entries(options).filter(([key]) => TRUST_BOUNDARY_KEYS.has(key)));
|
|
16873
16757
|
}
|
|
16874
|
-
|
|
16875
|
-
//#region src/adapters/opencode/v2/v2-review-pending.ts
|
|
16758
|
+
// src/adapters/opencode/v2/v2-review-pending.ts
|
|
16876
16759
|
/** The tool a structured reviewer session returns its decision with. */
|
|
16877
16760
|
const TOOL = "permission_reviewer_result";
|
|
16878
16761
|
/** The decision tool's input: one version 2 review decision. */
|
|
@@ -16922,8 +16805,7 @@ function pendingGeneration(envelope, attempt, config) {
|
|
|
16922
16805
|
results: []
|
|
16923
16806
|
};
|
|
16924
16807
|
}
|
|
16925
|
-
|
|
16926
|
-
//#region src/adapters/opencode/v2/v2-review-hooks.ts
|
|
16808
|
+
// src/adapters/opencode/v2/v2-review-hooks.ts
|
|
16927
16809
|
function captureDecision(pending, input) {
|
|
16928
16810
|
if (!pending?.attempt.active() || pending.closing || !pending.structured) throw new Error("Not an active structured reviewer session");
|
|
16929
16811
|
const decision = parseDecision(input);
|
|
@@ -16980,8 +16862,7 @@ async function registerReviewerHooks(ctx, sessions) {
|
|
|
16980
16862
|
throw error;
|
|
16981
16863
|
}
|
|
16982
16864
|
}
|
|
16983
|
-
|
|
16984
|
-
//#region src/adapters/opencode/v2/isolated-contexts.ts
|
|
16865
|
+
// src/adapters/opencode/v2/isolated-contexts.ts
|
|
16985
16866
|
const contexts = /* @__PURE__ */ new Map();
|
|
16986
16867
|
/** Canonicalize a directory so the two spellings of a symlinked temp path agree. */
|
|
16987
16868
|
function canonical(directory) {
|
|
@@ -17003,8 +16884,7 @@ function forgetIsolatedContext(directory) {
|
|
|
17003
16884
|
function isolatedContext(directory) {
|
|
17004
16885
|
return contexts.get(canonical(directory));
|
|
17005
16886
|
}
|
|
17006
|
-
|
|
17007
|
-
//#region src/adapters/opencode/v2/isolated-location.ts
|
|
16887
|
+
// src/adapters/opencode/v2/isolated-location.ts
|
|
17008
16888
|
const KEY = "opencode-permission-reviewer.isolated-activation";
|
|
17009
16889
|
const symbol = Symbol.for(KEY);
|
|
17010
16890
|
const globals = globalThis;
|
|
@@ -17071,8 +16951,7 @@ async function createIsolatedLocation(activate) {
|
|
|
17071
16951
|
throw error;
|
|
17072
16952
|
}
|
|
17073
16953
|
}
|
|
17074
|
-
|
|
17075
|
-
//#region src/adapters/opencode/v2/with-abort.ts
|
|
16954
|
+
// src/adapters/opencode/v2/with-abort.ts
|
|
17076
16955
|
/** Race a promise against a signal, so a call the host never settles cannot
|
|
17077
16956
|
* wedge the location activation. */
|
|
17078
16957
|
function withAbort(promise, signal) {
|
|
@@ -17092,8 +16971,7 @@ function withAbort(promise, signal) {
|
|
|
17092
16971
|
});
|
|
17093
16972
|
});
|
|
17094
16973
|
}
|
|
17095
|
-
|
|
17096
|
-
//#region src/adapters/opencode/v2/v2-isolation-activation.ts
|
|
16974
|
+
// src/adapters/opencode/v2/v2-isolation-activation.ts
|
|
17097
16975
|
/** Whether a local plugin entry is this attempt's bootstrap, by ID or by its path. */
|
|
17098
16976
|
function isBootstrap(plugin, root, pluginID) {
|
|
17099
16977
|
if (plugin.source.type !== "local") return false;
|
|
@@ -17140,8 +17018,7 @@ async function waitForIsolationActive(client, directory, pluginID, signal) {
|
|
|
17140
17018
|
await pollDelay(signal);
|
|
17141
17019
|
}
|
|
17142
17020
|
}
|
|
17143
|
-
|
|
17144
|
-
//#region src/adapters/opencode/v2/v2-review-location.ts
|
|
17021
|
+
// src/adapters/opencode/v2/v2-review-location.ts
|
|
17145
17022
|
/** Create an isolated location and wait until the host activated its hooks. */
|
|
17146
17023
|
async function openReviewerLocation(client, owner) {
|
|
17147
17024
|
const registrations = /* @__PURE__ */ new Set();
|
|
@@ -17186,8 +17063,7 @@ async function openReviewerLocation(client, owner) {
|
|
|
17186
17063
|
throw error;
|
|
17187
17064
|
}
|
|
17188
17065
|
}
|
|
17189
|
-
|
|
17190
|
-
//#region src/adapters/opencode/v2/v2-review-cleanup.ts
|
|
17066
|
+
// src/adapters/opencode/v2/v2-review-cleanup.ts
|
|
17191
17067
|
/** The HTTP client and the in-process plugin adapter tag a missing session
|
|
17192
17068
|
* differently: `SessionNotFoundError` vs `Session.NotFoundError`. */
|
|
17193
17069
|
const isSessionNotFound = (error) => {
|
|
@@ -17227,26 +17103,36 @@ async function finishReviewSession(client, sessions, sessionID, { createIssued,
|
|
|
17227
17103
|
if (!cleanupConfirmed) throw new Error("Reviewer cleanup could not be confirmed; isolation guards remain active");
|
|
17228
17104
|
sessions.delete(sessionID);
|
|
17229
17105
|
}
|
|
17230
|
-
|
|
17231
|
-
//#region src/adapters/opencode/v2/v2-review-preflight.ts
|
|
17106
|
+
// src/adapters/opencode/v2/v2-review-preflight.ts
|
|
17232
17107
|
/** Fail unless the host reports this location MCP-free. */
|
|
17233
17108
|
async function assertNoMcpServers(client, directory, attempt) {
|
|
17234
17109
|
const inventory = await attempt.wait(client.mcp.list({ location: { directory } }, { signal: attempt.signal }));
|
|
17235
17110
|
if (inventory.location.directory !== directory) throw new Error("Reviewer MCP inventory belongs to another location");
|
|
17236
17111
|
if (inventory.data.length > 0) throw new Error("Reviewer isolation location contains MCP servers");
|
|
17237
17112
|
}
|
|
17113
|
+
/**
|
|
17114
|
+
* A missing `medium` falls back to the model's own default even when it was set
|
|
17115
|
+
* explicitly, because the resolved config cannot tell it apart from the built-in
|
|
17116
|
+
* default. Any other missing variant fails closed.
|
|
17117
|
+
*/
|
|
17118
|
+
function selectVariant(configured, available) {
|
|
17119
|
+
if (!configured || available.includes(configured)) return configured || void 0;
|
|
17120
|
+
if (configured === DEFAULT_CONFIG.variant) return void 0;
|
|
17121
|
+
const offered = available.length ? `model offers: ${available.join(", ")}` : "model has no variants";
|
|
17122
|
+
throw new Error(`Reviewer variant "${configured}" is unavailable (${offered})`);
|
|
17123
|
+
}
|
|
17238
17124
|
function assertReviewerModel(model, config) {
|
|
17239
17125
|
if (!model) throw new Error("Reviewer model is unavailable");
|
|
17240
|
-
|
|
17126
|
+
const variant = selectVariant(config.variant, model.variants?.map((item) => item.id) ?? []);
|
|
17241
17127
|
if (config.outputFormat === "json_schema" && !model.capabilities.tools) throw new Error("Reviewer model does not support structured tool output");
|
|
17128
|
+
return { variant };
|
|
17242
17129
|
}
|
|
17243
17130
|
/** Fail before any session exists unless the location and its model can review. */
|
|
17244
17131
|
async function assertReviewerLocation(client, directory, attempt, { providerID, modelID }, config) {
|
|
17245
17132
|
await assertNoMcpServers(client, directory, attempt);
|
|
17246
|
-
assertReviewerModel((await attempt.wait(client.model.list({ location: { directory } }, { signal: attempt.signal }))).data.find((item) => item.providerID === providerID && item.id === modelID), config);
|
|
17133
|
+
return assertReviewerModel((await attempt.wait(client.model.list({ location: { directory } }, { signal: attempt.signal }))).data.find((item) => item.providerID === providerID && item.id === modelID), config);
|
|
17247
17134
|
}
|
|
17248
|
-
|
|
17249
|
-
//#region src/adapters/opencode/v2/v2-review-response.ts
|
|
17135
|
+
// src/adapters/opencode/v2/v2-review-response.ts
|
|
17250
17136
|
/**
|
|
17251
17137
|
* Whether a captured decision is ambiguous: more than one, or one whose reply
|
|
17252
17138
|
* is not the admitted prompt's, or whose tool calls are not host schema
|
|
@@ -17273,10 +17159,9 @@ function readReviewerResponse(messages, admittedID, pending) {
|
|
|
17273
17159
|
parsed: pending.structured ? pending.results.length === 1 && !ambiguous ? pending.results[0] : void 0 : parseDecisionFromText(responseText(response))
|
|
17274
17160
|
};
|
|
17275
17161
|
}
|
|
17276
|
-
|
|
17277
|
-
//#region src/adapters/opencode/v2/v2-review-session.ts
|
|
17162
|
+
// src/adapters/opencode/v2/v2-review-session.ts
|
|
17278
17163
|
/** Create the review session denying every tool but the decision tool. */
|
|
17279
|
-
async function createReviewSession(client, { id, directory, providerID, modelID, structured },
|
|
17164
|
+
async function createReviewSession(client, { id, directory, providerID, modelID, structured, variant }, attempt) {
|
|
17280
17165
|
const created = await attempt.wait(client.session.create({
|
|
17281
17166
|
id,
|
|
17282
17167
|
title: "Permission review",
|
|
@@ -17284,7 +17169,7 @@ async function createReviewSession(client, { id, directory, providerID, modelID,
|
|
|
17284
17169
|
model: {
|
|
17285
17170
|
id: modelID,
|
|
17286
17171
|
providerID,
|
|
17287
|
-
...
|
|
17172
|
+
...variant ? { variant } : {}
|
|
17288
17173
|
},
|
|
17289
17174
|
permissions: [{
|
|
17290
17175
|
action: "*",
|
|
@@ -17331,8 +17216,7 @@ async function promptUntilDecided(client, sessionID, pending, config) {
|
|
|
17331
17216
|
decisionSource: "failure-safe"
|
|
17332
17217
|
}, config, "invalid-decision");
|
|
17333
17218
|
}
|
|
17334
|
-
|
|
17335
|
-
//#region src/adapters/opencode/v2/v2-review-run.ts
|
|
17219
|
+
// src/adapters/opencode/v2/v2-review-run.ts
|
|
17336
17220
|
async function runV2Review(run, envelope, attempt, client) {
|
|
17337
17221
|
const { config, sessions } = run;
|
|
17338
17222
|
const { providerID, modelID } = splitModel(config.model);
|
|
@@ -17340,7 +17224,7 @@ async function runV2Review(run, envelope, attempt, client) {
|
|
|
17340
17224
|
let createIssued = false;
|
|
17341
17225
|
try {
|
|
17342
17226
|
const { directory } = await attempt.wait(run.location(client));
|
|
17343
|
-
await assertReviewerLocation(client, directory, attempt, {
|
|
17227
|
+
const { variant } = await assertReviewerLocation(client, directory, attempt, {
|
|
17344
17228
|
providerID,
|
|
17345
17229
|
modelID
|
|
17346
17230
|
}, config);
|
|
@@ -17352,8 +17236,9 @@ async function runV2Review(run, envelope, attempt, client) {
|
|
|
17352
17236
|
directory,
|
|
17353
17237
|
providerID,
|
|
17354
17238
|
modelID,
|
|
17355
|
-
structured: pending.structured
|
|
17356
|
-
|
|
17239
|
+
structured: pending.structured,
|
|
17240
|
+
variant
|
|
17241
|
+
}, attempt);
|
|
17357
17242
|
return await promptUntilDecided(client, id, pending, config);
|
|
17358
17243
|
} catch (error) {
|
|
17359
17244
|
return applyEscalationDisposition({
|
|
@@ -17369,8 +17254,7 @@ async function runV2Review(run, envelope, attempt, client) {
|
|
|
17369
17254
|
});
|
|
17370
17255
|
}
|
|
17371
17256
|
}
|
|
17372
|
-
|
|
17373
|
-
//#region src/adapters/opencode/v2/reviewer-backend.ts
|
|
17257
|
+
// src/adapters/opencode/v2/reviewer-backend.ts
|
|
17374
17258
|
/** Owns auxiliary sessions and host hooks, never operational permission replies. */
|
|
17375
17259
|
var V2ReviewerBackend = class {
|
|
17376
17260
|
ctx;
|
|
@@ -17435,8 +17319,7 @@ var V2ReviewerBackend = class {
|
|
|
17435
17319
|
return location;
|
|
17436
17320
|
}
|
|
17437
17321
|
};
|
|
17438
|
-
|
|
17439
|
-
//#region src/adapters/opencode/v2/backend-factory.ts
|
|
17322
|
+
// src/adapters/opencode/v2/backend-factory.ts
|
|
17440
17323
|
function escalationConfig(config) {
|
|
17441
17324
|
const escalation = config.escalationReviewer;
|
|
17442
17325
|
if (!escalation) return;
|
|
@@ -17463,8 +17346,7 @@ function createV2ReviewerBackend(context, config) {
|
|
|
17463
17346
|
}
|
|
17464
17347
|
};
|
|
17465
17348
|
}
|
|
17466
|
-
|
|
17467
|
-
//#region src/modules/status/models/rpc.ts
|
|
17349
|
+
// src/modules/status/models/rpc.ts
|
|
17468
17350
|
/** Portable, read-only protocol. No UI message can approve a permission. */
|
|
17469
17351
|
const ReviewerRpc = {
|
|
17470
17352
|
id: "opencode-permission-reviewer",
|
|
@@ -17493,8 +17375,7 @@ const ReviewerRpc = {
|
|
|
17493
17375
|
},
|
|
17494
17376
|
events: { "review.updated": { schema: { type: "object" } } }
|
|
17495
17377
|
};
|
|
17496
|
-
|
|
17497
|
-
//#region src/adapters/opencode/v2/in-process-host.ts
|
|
17378
|
+
// src/adapters/opencode/v2/in-process-host.ts
|
|
17498
17379
|
/** A V2 host backed by this plugin's context. Model and plugin inventories
|
|
17499
17380
|
* come from the isolated location's own context, since the plugin context
|
|
17500
17381
|
* lists them only for its own location. */
|
|
@@ -17527,8 +17408,7 @@ function createInProcessHost(ctx) {
|
|
|
17527
17408
|
} }
|
|
17528
17409
|
};
|
|
17529
17410
|
}
|
|
17530
|
-
|
|
17531
|
-
//#region src/adapters/opencode/v2/connection.ts
|
|
17411
|
+
// src/adapters/opencode/v2/connection.ts
|
|
17532
17412
|
const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
|
|
17533
17413
|
"localhost",
|
|
17534
17414
|
"127.0.0.1",
|
|
@@ -17593,8 +17473,7 @@ async function resolveV2Host(ctx, directory, identity, version, signal) {
|
|
|
17593
17473
|
if (process.env.OPENCODE_PERMISSION_REVIEWER_HOST_URL !== void 0) return connectV2Host(directory, identity, version, signal);
|
|
17594
17474
|
return createInProcessHost(ctx);
|
|
17595
17475
|
}
|
|
17596
|
-
|
|
17597
|
-
//#region src/adapters/opencode/v2/server-events.ts
|
|
17476
|
+
// src/adapters/opencode/v2/server-events.ts
|
|
17598
17477
|
function toolKey(sessionID, messageID, id) {
|
|
17599
17478
|
return `${sessionID}:${messageID}:${id}`;
|
|
17600
17479
|
}
|
|
@@ -17651,8 +17530,7 @@ function watchHostEvents(state) {
|
|
|
17651
17530
|
if (!state.disposed) for (const { attempt } of state.requests.values()) attempt.close("cancelled");
|
|
17652
17531
|
});
|
|
17653
17532
|
}
|
|
17654
|
-
|
|
17655
|
-
//#region src/adapters/opencode/v2/permission-codec.ts
|
|
17533
|
+
// src/adapters/opencode/v2/permission-codec.ts
|
|
17656
17534
|
/** Host action names the reviewer's permission vocabulary spells differently. */
|
|
17657
17535
|
const REVIEW_PERMISSIONS = /* @__PURE__ */ new Map([["shell", "bash"], ["subagent", "task"]]);
|
|
17658
17536
|
function exactActionInput(actionInput) {
|
|
@@ -17702,8 +17580,7 @@ function normalizeV2Permission(input, scope, actionInput) {
|
|
|
17702
17580
|
}
|
|
17703
17581
|
};
|
|
17704
17582
|
}
|
|
17705
|
-
|
|
17706
|
-
//#region src/adapters/opencode/v2/server-audit-evidence.ts
|
|
17583
|
+
// src/adapters/opencode/v2/server-audit-evidence.ts
|
|
17707
17584
|
function verifiedScriptField(script) {
|
|
17708
17585
|
if (!script) return {};
|
|
17709
17586
|
return { verifiedScript: {
|
|
@@ -17747,8 +17624,7 @@ function evidenceFields(envelope) {
|
|
|
17747
17624
|
...actorFields(envelope?.actor)
|
|
17748
17625
|
};
|
|
17749
17626
|
}
|
|
17750
|
-
|
|
17751
|
-
//#region src/adapters/opencode/v2/server-audit.ts
|
|
17627
|
+
// src/adapters/opencode/v2/server-audit.ts
|
|
17752
17628
|
function reviewerFields(result) {
|
|
17753
17629
|
return {
|
|
17754
17630
|
...result.reviewerEscalatedFrom ? { reviewerEscalatedFrom: result.reviewerEscalatedFrom } : {},
|
|
@@ -17813,8 +17689,7 @@ function reviewAuditRecord(scope, run, result, active) {
|
|
|
17813
17689
|
...envelope?.timings ? { timings: envelope.timings } : {}
|
|
17814
17690
|
};
|
|
17815
17691
|
}
|
|
17816
|
-
|
|
17817
|
-
//#region src/adapters/opencode/v2/server-status.ts
|
|
17692
|
+
// src/adapters/opencode/v2/server-status.ts
|
|
17818
17693
|
function capabilities(systemOneReviewer) {
|
|
17819
17694
|
return systemOneReviewer ? {
|
|
17820
17695
|
structuredTool: false,
|
|
@@ -17892,8 +17767,7 @@ function notify(state, operation) {
|
|
|
17892
17767
|
const pending = Promise.resolve().then(operation).catch((error) => state.log("Review notification failed", String(error))).finally(() => state.notifications.delete(pending));
|
|
17893
17768
|
state.notifications.add(pending);
|
|
17894
17769
|
}
|
|
17895
|
-
|
|
17896
|
-
//#region src/adapters/opencode/v2/server-review-outcome.ts
|
|
17770
|
+
// src/adapters/opencode/v2/server-review-outcome.ts
|
|
17897
17771
|
/** A failure-safe denial that keeps the replaced result's System One scores. */
|
|
17898
17772
|
function failureSafeDeny(reason, result) {
|
|
17899
17773
|
return {
|
|
@@ -17954,8 +17828,7 @@ function finishReview(server, run, reviewed) {
|
|
|
17954
17828
|
run.attempt.close("finished");
|
|
17955
17829
|
queueReport(server, run, result, active);
|
|
17956
17830
|
}
|
|
17957
|
-
|
|
17958
|
-
//#region src/adapters/opencode/v2/context-messages.ts
|
|
17831
|
+
// src/adapters/opencode/v2/context-messages.ts
|
|
17959
17832
|
function omittedHistoryNotice() {
|
|
17960
17833
|
return {
|
|
17961
17834
|
info: { role: "system" },
|
|
@@ -18014,8 +17887,7 @@ function contextMessages(session, messages, limit) {
|
|
|
18014
17887
|
else if (message.type === "assistant") result.push(assistantMessage(message));
|
|
18015
17888
|
return result;
|
|
18016
17889
|
}
|
|
18017
|
-
|
|
18018
|
-
//#region src/adapters/opencode/v2/context-reader.ts
|
|
17890
|
+
// src/adapters/opencode/v2/context-reader.ts
|
|
18019
17891
|
function locatedSession(session, directory) {
|
|
18020
17892
|
if (session.location.directory !== directory) throw new Error("Session location mismatch");
|
|
18021
17893
|
return session;
|
|
@@ -18040,8 +17912,7 @@ function createV2ContextReader(ctx, signal) {
|
|
|
18040
17912
|
}
|
|
18041
17913
|
};
|
|
18042
17914
|
}
|
|
18043
|
-
|
|
18044
|
-
//#region src/adapters/opencode/v2/server-review-ports.ts
|
|
17915
|
+
// src/adapters/opencode/v2/server-review-ports.ts
|
|
18045
17916
|
async function collectEvidence(server, run, permission, client) {
|
|
18046
17917
|
const envelope = await assembleEvidence(permission.request, defaultEvidenceProviders(), {
|
|
18047
17918
|
reader: createV2ContextReader(client, run.attempt.signal),
|
|
@@ -18077,8 +17948,7 @@ function reviewPorts(server, run, permission, client) {
|
|
|
18077
17948
|
observe: () => {}
|
|
18078
17949
|
};
|
|
18079
17950
|
}
|
|
18080
|
-
|
|
18081
|
-
//#region src/adapters/opencode/v2/server-review-run.ts
|
|
17951
|
+
// src/adapters/opencode/v2/server-review-run.ts
|
|
18082
17952
|
/** Snapshots and normalises the pending action with its exact tool input. */
|
|
18083
17953
|
function beginReview(server, run) {
|
|
18084
17954
|
const { input } = run;
|
|
@@ -18123,8 +17993,7 @@ async function runReview(server, run) {
|
|
|
18123
17993
|
}
|
|
18124
17994
|
finishReview(server, run, result);
|
|
18125
17995
|
}
|
|
18126
|
-
|
|
18127
|
-
//#region src/adapters/opencode/v2/server-permission.ts
|
|
17996
|
+
// src/adapters/opencode/v2/server-permission.ts
|
|
18128
17997
|
const MAX_PENDING_REVIEWS = 32;
|
|
18129
17998
|
/** Denies the evaluation when no review can enforce it; true when denied. */
|
|
18130
17999
|
function refusedUnavailable(server, input) {
|
|
@@ -18191,8 +18060,7 @@ async function evaluatePermission(server, input) {
|
|
|
18191
18060
|
async function registerPermissionHook(server) {
|
|
18192
18061
|
server.registrations.push(await server.ctx.permission.hook("evaluate", (input) => evaluatePermission(server, input)));
|
|
18193
18062
|
}
|
|
18194
|
-
|
|
18195
|
-
//#region src/modules/audit/repositories/audit-files.ts
|
|
18063
|
+
// src/modules/audit/repositories/audit-files.ts
|
|
18196
18064
|
/** Append one JSONL line through an explicitly opened descriptor: `O_NOFOLLOW`
|
|
18197
18065
|
* rejects a symlinked audit path, `O_NONBLOCK` makes a write-open on a
|
|
18198
18066
|
* readerless FIFO fail with `ENXIO` instead of hanging the host, and the
|
|
@@ -18221,8 +18089,7 @@ function appendAuditLine(path, line) {
|
|
|
18221
18089
|
closeQuietly(fd);
|
|
18222
18090
|
}
|
|
18223
18091
|
}
|
|
18224
|
-
|
|
18225
|
-
//#region src/modules/audit/services/audit-sanitize.ts
|
|
18092
|
+
// src/modules/audit/services/audit-sanitize.ts
|
|
18226
18093
|
function boundedReason(reason) {
|
|
18227
18094
|
const normalized = reason.replace(/[\r\n]+/g, " ").trim();
|
|
18228
18095
|
return normalized.length <= 2e3 ? normalized : `${normalized.slice(0, 2e3)}…`;
|
|
@@ -18283,8 +18150,7 @@ function sanitizeAuditRecord(record) {
|
|
|
18283
18150
|
...sanitizedConfigWarnings(record)
|
|
18284
18151
|
};
|
|
18285
18152
|
}
|
|
18286
|
-
|
|
18287
|
-
//#region src/modules/audit/services/audit.ts
|
|
18153
|
+
// src/modules/audit/services/audit.ts
|
|
18288
18154
|
var audit_exports = /* @__PURE__ */ __exportAll({
|
|
18289
18155
|
DEFAULT_AUDIT_PATH: () => DEFAULT_AUDIT_PATH,
|
|
18290
18156
|
createAuditWriter: () => createAuditWriter,
|
|
@@ -18323,8 +18189,7 @@ function createAuditWriter(config, logger) {
|
|
|
18323
18189
|
}
|
|
18324
18190
|
};
|
|
18325
18191
|
}
|
|
18326
|
-
|
|
18327
|
-
//#region src/modules/context/services/ask-events.ts
|
|
18192
|
+
// src/modules/context/services/ask-events.ts
|
|
18328
18193
|
/** Word the host uses for sub-questions the user left unanswered. */
|
|
18329
18194
|
const UNANSWERED = "Unanswered";
|
|
18330
18195
|
const QUESTION_MAX_CHARS = 160;
|
|
@@ -18377,8 +18242,7 @@ function parseReplyTarget(properties) {
|
|
|
18377
18242
|
if (!isRecord(properties)) return;
|
|
18378
18243
|
return typeof properties.requestID === "string" ? { requestID: properties.requestID } : void 0;
|
|
18379
18244
|
}
|
|
18380
|
-
|
|
18381
|
-
//#region src/modules/context/services/pending-asks.ts
|
|
18245
|
+
// src/modules/context/services/pending-asks.ts
|
|
18382
18246
|
const MAX_PENDING = 128;
|
|
18383
18247
|
const PENDING_TTL_MS$1 = 18e5;
|
|
18384
18248
|
var PendingAsks = class {
|
|
@@ -18419,8 +18283,7 @@ var PendingAsks = class {
|
|
|
18419
18283
|
for (const [id, entry] of this.entries) if (entry.askedAt < cutoff) this.entries.delete(id);
|
|
18420
18284
|
}
|
|
18421
18285
|
};
|
|
18422
|
-
|
|
18423
|
-
//#region src/modules/context/services/ask-decisions.ts
|
|
18286
|
+
// src/modules/context/services/ask-decisions.ts
|
|
18424
18287
|
/**
|
|
18425
18288
|
* Captures user answers to agent ask dialogs (the `question` tool) from the
|
|
18426
18289
|
* OpenCode event stream and exposes them as compact, session-scoped
|
|
@@ -18552,8 +18415,7 @@ var AskDecisionRegistry = class {
|
|
|
18552
18415
|
}
|
|
18553
18416
|
}
|
|
18554
18417
|
};
|
|
18555
|
-
|
|
18556
|
-
//#region src/adapters/opencode/v2/form-event-shape.ts
|
|
18418
|
+
// src/adapters/opencode/v2/form-event-shape.ts
|
|
18557
18419
|
const MAX_KEPT_FIELDS = 32;
|
|
18558
18420
|
const MAX_FORM_JSON_CHARS = 64e3;
|
|
18559
18421
|
function isOptional(value, check) {
|
|
@@ -18591,8 +18453,7 @@ function formSettled(event) {
|
|
|
18591
18453
|
if (event.type === "form.replied" && !isRecord(data.answer)) return void 0;
|
|
18592
18454
|
return event;
|
|
18593
18455
|
}
|
|
18594
|
-
|
|
18595
|
-
//#region src/adapters/opencode/v2/event-codec.ts
|
|
18456
|
+
// src/adapters/opencode/v2/event-codec.ts
|
|
18596
18457
|
const PENDING_TTL_MS = 18e5;
|
|
18597
18458
|
function optionLabel(field, value) {
|
|
18598
18459
|
return "options" in field ? field.options?.find((option) => option.value === String(value))?.label : void 0;
|
|
@@ -18665,8 +18526,7 @@ var V2AskDecisions = class {
|
|
|
18665
18526
|
});
|
|
18666
18527
|
}
|
|
18667
18528
|
};
|
|
18668
|
-
|
|
18669
|
-
//#region src/adapters/opencode/v2/server-state.ts
|
|
18529
|
+
// src/adapters/opencode/v2/server-state.ts
|
|
18670
18530
|
function createServerState(ctx, services) {
|
|
18671
18531
|
const directory = ctx.location.directory;
|
|
18672
18532
|
const config = services.loadConfig(ctx.options, directory, "unknown");
|
|
@@ -18704,8 +18564,7 @@ function createServerState(ctx, services) {
|
|
|
18704
18564
|
registrations: []
|
|
18705
18565
|
};
|
|
18706
18566
|
}
|
|
18707
|
-
|
|
18708
|
-
//#region src/adapters/opencode/v2/server.ts
|
|
18567
|
+
// src/adapters/opencode/v2/server.ts
|
|
18709
18568
|
async function setup(ctx) {
|
|
18710
18569
|
return setupWithServices(ctx, {
|
|
18711
18570
|
loadConfig: loadResolvedConfig,
|
|
@@ -18736,8 +18595,7 @@ async function shutdown(state, eventTask) {
|
|
|
18736
18595
|
state.tools.clear();
|
|
18737
18596
|
state.statuses.clear();
|
|
18738
18597
|
}
|
|
18739
|
-
|
|
18740
|
-
//#region src/modules/status/services/ui-state.ts
|
|
18598
|
+
// src/modules/status/services/ui-state.ts
|
|
18741
18599
|
const RESULT_DISPLAY_MS = {
|
|
18742
18600
|
approved: 5e3,
|
|
18743
18601
|
denied: 5e3
|
|
@@ -18853,8 +18711,7 @@ var ReviewUiState = class {
|
|
|
18853
18711
|
return removed;
|
|
18854
18712
|
}
|
|
18855
18713
|
};
|
|
18856
|
-
|
|
18857
|
-
//#region src/index.ts
|
|
18714
|
+
// src/index.ts
|
|
18858
18715
|
const server = async (input, options) => {
|
|
18859
18716
|
const config = loadResolvedConfig(options, input.directory, "unknown");
|
|
18860
18717
|
const debugLogger = (message, details) => {
|
|
@@ -18893,5 +18750,4 @@ const module = {
|
|
|
18893
18750
|
server,
|
|
18894
18751
|
setup
|
|
18895
18752
|
};
|
|
18896
|
-
//#endregion
|
|
18897
18753
|
export { V1ReviewCoordinator as ApprovalReviewerRuntime, AskDecisionRegistry, DECISION_SCHEMA, DEFAULT_AUDIT_PATH, DISMISSED_ANSWER, ReviewUiState, applyEscalationDisposition, createAuditWriter, createUiStatus, decodeUiStatus, module as default, emergencyBrakeReason, encodeUiStatus, enforceDecision, enrichGitEvidence, enrichLocalScriptEvidence, enrichSshEvidence, extractPermissionRequest, loadResolvedConfig, parseDecision, permissionAction, redactSecrets, resolveConfig, resolveEscalationDisposition, server };
|