pi-advisor-flow 0.15.1-dev.2 → 0.15.2-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +16 -1
- package/dist/index.js +1157 -502
- package/docs/README.md +9 -0
- package/docs/benchmark.md +22 -0
- package/docs/configuration.md +194 -0
- package/docs/development.md +38 -0
- package/docs/herdr.md +169 -0
- package/docs/privacy.md +102 -0
- package/extensions/index.ts +23 -0
- package/locales/de.json +330 -0
- package/locales/en.json +331 -0
- package/locales/es.json +3 -0
- package/locales/fr.json +330 -0
- package/locales/pt-BR.json +3 -0
- package/locales/pt.json +3 -0
- package/locales/ru.json +3 -0
- package/locales/uk.json +3 -0
- package/locales/zh.json +3 -0
- package/package.json +15 -2
- package/skills/pi-advisor-flow/SKILL.md +62 -0
- package/src/commands/activation-preparation.ts +9 -2
- package/src/commands/activation.ts +28 -8
- package/src/commands/configuration-tool-models.ts +143 -0
- package/src/commands/configuration-tool-policy.ts +177 -0
- package/src/commands/configuration-tool-preview.ts +228 -0
- package/src/commands/configuration-tool-runtime.ts +40 -0
- package/src/commands/configuration-tool-transaction.ts +120 -0
- package/src/commands/configuration-tool-update.ts +230 -0
- package/src/commands/configuration-tool.ts +89 -0
- package/src/commands/lifecycle.ts +6 -1
- package/src/commands/manual-consultation.ts +6 -1
- package/src/commands/manual-progress.ts +4 -3
- package/src/commands/model-commands.ts +2 -1
- package/src/commands/model-options.ts +4 -6
- package/src/commands/model-picker.ts +16 -6
- package/src/commands/registration.ts +2 -0
- package/src/commands/runtime.ts +17 -4
- package/src/commands/settings-commands.ts +30 -7
- package/src/config/schema-validators.ts +104 -0
- package/src/config/schema.ts +35 -102
- package/src/config/storage.ts +160 -7
- package/src/i18n.ts +31 -0
- package/src/scout-group-serialization.ts +66 -0
- package/src/scout-groups.ts +3 -66
- package/src/scout-selection.ts +99 -0
- package/src/scout.ts +6 -93
- package/src/session-state.ts +27 -137
- package/src/tool-input-normalization.ts +119 -0
- package/src/tools/gate-policy.ts +13 -5
- package/src/tools/jev-filter.ts +2 -1
- package/src/tools/jev-turn-gate.ts +2 -1
- package/src/tools/register-lifecycle.ts +5 -1
- package/src/tools/register-outcome.ts +5 -1
- package/src/tools/register-renderers.ts +5 -2
- package/src/tools/render-advisor-result.ts +20 -8
- package/src/tools/render-common.ts +16 -4
- package/src/tools/scout-status.ts +10 -2
- package/src/ui/jev-classifier-submenu.ts +143 -38
- package/src/ui/jev-filter-submenu.ts +52 -14
- package/src/ui/jev-provider-submenu-view.ts +72 -20
- package/src/ui/jev-provider-submenu.ts +40 -12
- package/src/ui/jev-setup-support.ts +48 -19
- package/src/ui/manual-dialog-render.ts +71 -25
- package/src/ui/searchable-model-list.ts +18 -4
- package/src/ui/settings-formatting.ts +5 -2
- package/src/ui/settings-items-jev.ts +216 -0
- package/src/ui/settings-items.ts +216 -259
- package/src/ui/settings-selector.ts +9 -2
- package/src/ui/text-setting-submenu.ts +8 -1
- package/src/usage.ts +9 -3
package/dist/index.js
CHANGED
|
@@ -518,8 +518,7 @@ var normalizeJevBaseUrl = (input) => {
|
|
|
518
518
|
return { baseUrl: `${parsed.origin}${stripContractPath(parsed.pathname)}` };
|
|
519
519
|
};
|
|
520
520
|
|
|
521
|
-
// src/config/schema.ts
|
|
522
|
-
var configuredModelRef = (value) => value?.trim() || undefined;
|
|
521
|
+
// src/config/schema-validators.ts
|
|
523
522
|
var isNonEmptyModel = (model) => typeof model === "string" && model.trim().length > 0;
|
|
524
523
|
var isValidAdvisorModelWhitelist = (value) => Array.isArray(value) && value.every(isNonEmptyModel);
|
|
525
524
|
var ADVISOR_TOOL_POLICY_NAMES = new Set(ADVISOR_TOOL_POLICIES);
|
|
@@ -529,17 +528,17 @@ var isValidAdvisorToolPolicies = (value) => {
|
|
|
529
528
|
}
|
|
530
529
|
return Object.entries(value).every(([toolName, policy]) => toolName.trim().length > 0 && isString(policy) && ADVISOR_TOOL_POLICY_NAMES.has(policy));
|
|
531
530
|
};
|
|
532
|
-
var
|
|
531
|
+
var isValidNonNegativeSafeInteger = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
533
532
|
var isValidContextMaxChars = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= MAX_CONTEXT_MAX_CHARS;
|
|
534
533
|
var isValidLoopThreshold = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 2;
|
|
535
|
-
var isValidMaxCallsPerSession = (value) =>
|
|
534
|
+
var isValidMaxCallsPerSession = (value) => isValidNonNegativeSafeInteger(value);
|
|
536
535
|
var GATE_FAILURE_MODE_NAMES = new Set(GATE_FAILURE_MODES);
|
|
537
536
|
var isValidGateFailureMode = (value) => isString(value) && GATE_FAILURE_MODE_NAMES.has(value);
|
|
538
|
-
var isValidToolResultMaxLines = (value) =>
|
|
539
|
-
var isValidToolResultMaxBytes = (value) =>
|
|
537
|
+
var isValidToolResultMaxLines = (value) => isValidNonNegativeSafeInteger(value);
|
|
538
|
+
var isValidToolResultMaxBytes = (value) => isValidNonNegativeSafeInteger(value);
|
|
540
539
|
var isValidJevTimeoutMs = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
|
|
541
540
|
var isValidScoutTimeoutMs = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1 && value <= MAX_SCOUT_TIMEOUT_MS;
|
|
542
|
-
var isValidJevDigestMaxChars = (value) =>
|
|
541
|
+
var isValidJevDigestMaxChars = (value) => isValidNonNegativeSafeInteger(value);
|
|
543
542
|
var isValidJevPricePerMtok = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
544
543
|
var isValidJevSkipConfidence = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0.5 && value <= 1;
|
|
545
544
|
var isValidJevNoulMargin = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 0.5;
|
|
@@ -547,6 +546,9 @@ var JEV_TRANSPORT_NAMES = new Set(JEV_TRANSPORTS);
|
|
|
547
546
|
var isValidJevTransport = (value) => isString(value) && JEV_TRANSPORT_NAMES.has(value);
|
|
548
547
|
var isValidJevBaseUrl = (value) => isString(value) && (value.trim() === "" || normalizeJevBaseUrl(value).baseUrl !== undefined);
|
|
549
548
|
var isValidJevKeyProvider = (value) => isString(value) && (value.trim() === "" || !/\s/u.test(value.trim()));
|
|
549
|
+
|
|
550
|
+
// src/config/schema.ts
|
|
551
|
+
var configuredModelRef = (value) => value?.trim() || undefined;
|
|
550
552
|
var CONFIG_SCHEMA = {
|
|
551
553
|
advisor: {
|
|
552
554
|
accepted: "a provider/model string",
|
|
@@ -626,7 +628,7 @@ var CONFIG_SCHEMA = {
|
|
|
626
628
|
current: () => advisorGitContextMaxCharsRef,
|
|
627
629
|
persisted: true,
|
|
628
630
|
type: "number",
|
|
629
|
-
validate:
|
|
631
|
+
validate: isValidNonNegativeSafeInteger
|
|
630
632
|
},
|
|
631
633
|
advisorHerdrIntegration: {
|
|
632
634
|
accepted: "true or false",
|
|
@@ -673,7 +675,7 @@ var CONFIG_SCHEMA = {
|
|
|
673
675
|
current: () => advisorJevFilterOverrideWindowRef,
|
|
674
676
|
persisted: true,
|
|
675
677
|
type: "number",
|
|
676
|
-
validate:
|
|
678
|
+
validate: isValidNonNegativeSafeInteger
|
|
677
679
|
},
|
|
678
680
|
advisorJevFilterSkipConfidence: {
|
|
679
681
|
accepted: "a number between 0.5 and 1 inclusive",
|
|
@@ -721,7 +723,7 @@ var CONFIG_SCHEMA = {
|
|
|
721
723
|
current: () => advisorJevTurnGateEveryTurnsRef,
|
|
722
724
|
persisted: true,
|
|
723
725
|
type: "number",
|
|
724
|
-
validate:
|
|
726
|
+
validate: isValidNonNegativeSafeInteger
|
|
725
727
|
},
|
|
726
728
|
advisorJevTurnGateNoulThreshold: {
|
|
727
729
|
accepted: "a number between 0.5 and 1 inclusive",
|
|
@@ -956,10 +958,32 @@ var parseArgs = (args) => {
|
|
|
956
958
|
};
|
|
957
959
|
|
|
958
960
|
// src/config/storage.ts
|
|
959
|
-
import {
|
|
961
|
+
import { randomUUID } from "node:crypto";
|
|
962
|
+
import {
|
|
963
|
+
closeSync,
|
|
964
|
+
existsSync,
|
|
965
|
+
fsyncSync,
|
|
966
|
+
openSync,
|
|
967
|
+
readFileSync,
|
|
968
|
+
renameSync,
|
|
969
|
+
statSync,
|
|
970
|
+
unlinkSync,
|
|
971
|
+
writeFileSync
|
|
972
|
+
} from "node:fs";
|
|
960
973
|
import { join } from "node:path";
|
|
961
974
|
import { CONFIG_DIR_NAME, getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
962
975
|
|
|
976
|
+
// src/i18n.ts
|
|
977
|
+
var I18N_NAMESPACE = "pi-advisor-flow";
|
|
978
|
+
var scopeImpl;
|
|
979
|
+
try {
|
|
980
|
+
const sdk = await import("@juicesharp/rpiv-i18n");
|
|
981
|
+
scopeImpl = sdk.scope(I18N_NAMESPACE);
|
|
982
|
+
} catch {
|
|
983
|
+
scopeImpl = (_key, fallback) => fallback;
|
|
984
|
+
}
|
|
985
|
+
var t = scopeImpl;
|
|
986
|
+
|
|
963
987
|
// src/config/defaults.ts
|
|
964
988
|
var resetDefaults = () => {
|
|
965
989
|
setExecutorRef("");
|
|
@@ -1083,8 +1107,13 @@ var applyConfig = (config) => {
|
|
|
1083
1107
|
};
|
|
1084
1108
|
|
|
1085
1109
|
// src/config/storage.ts
|
|
1110
|
+
var configPaths = (ctx) => [
|
|
1111
|
+
ctx.isProjectTrusted() ? join(ctx.cwd, CONFIG_DIR_NAME, "advisor.json") : null,
|
|
1112
|
+
join(getAgentDir(), "advisor.json")
|
|
1113
|
+
];
|
|
1086
1114
|
var currentConfigState = () => Object.fromEntries(SAVED_CONFIG_KEYS.map((key) => [key, CONFIG_SCHEMA[key].current()]));
|
|
1087
1115
|
var sameConfigValue = (left, right) => JSON.stringify(left) === JSON.stringify(right);
|
|
1116
|
+
var CONFIG_KEY_SET = new Set(Object.keys(CONFIG_SCHEMA));
|
|
1088
1117
|
var RESERVED_ADVISOR_JSON_KEYS = new Set(["typesafe_api_key"]);
|
|
1089
1118
|
var readConfigForSave = (path) => {
|
|
1090
1119
|
if (!existsSync(path)) {
|
|
@@ -1151,6 +1180,7 @@ var configIdentity = (path) => {
|
|
|
1151
1180
|
return `unstattable:${process.hrtime.bigint()}`;
|
|
1152
1181
|
}
|
|
1153
1182
|
};
|
|
1183
|
+
var configFileIdentity = (path) => existsSync(path) ? configIdentity(path) : null;
|
|
1154
1184
|
var readConfigCached = (path) => {
|
|
1155
1185
|
const identity = configIdentity(path);
|
|
1156
1186
|
const cached = configCache.get(path);
|
|
@@ -1171,11 +1201,11 @@ var loadConfig = (_ctx) => {
|
|
|
1171
1201
|
const warningIdentity = `${global}:${configIdentity(global)}`;
|
|
1172
1202
|
if (advisorJevFilterEnabledRef && !advisorJevClassifierRef && _ctx.hasUI && !warnedFilterWithoutClassifierIdentities.has(warningIdentity)) {
|
|
1173
1203
|
warnedFilterWithoutClassifierIdentities.add(warningIdentity);
|
|
1174
|
-
_ctx.ui.notify("The Jev consultation filter is enabled but no Jev classifier is selected; consultations are not screened until you pick one in /advisor-settings.", "warning");
|
|
1204
|
+
_ctx.ui.notify(t("notify.jevFilterNoClassifier.message", "The Jev consultation filter is enabled but no Jev classifier is selected; consultations are not screened until you pick one in /advisor-settings."), "warning");
|
|
1175
1205
|
}
|
|
1176
1206
|
const unknownKeys = unknownConfigKeys(globalConfig).filter((key) => !RESERVED_ADVISOR_JSON_KEYS.has(key));
|
|
1177
1207
|
if (unknownKeys.length > 0 && _ctx.hasUI && !warnedUnknownConfigIdentities.has(warningIdentity)) {
|
|
1178
|
-
_ctx.ui.notify(
|
|
1208
|
+
_ctx.ui.notify(`${t("notify.unknownConfigKeys.at", "Advisor configuration at")} ${global} ${t("notify.unknownConfigKeys.contains", "contains unrecognized key(s)")} ${unknownKeys.map((key) => JSON.stringify(key)).join(", ")}. ${t("notify.unknownConfigKeys.preserved", "They were preserved but ignored; check for typos or upgrade pi-advisor.")}`, "warning");
|
|
1179
1209
|
warnedUnknownConfigIdentities.add(warningIdentity);
|
|
1180
1210
|
}
|
|
1181
1211
|
}
|
|
@@ -1184,6 +1214,10 @@ var loadConfig = (_ctx) => {
|
|
|
1184
1214
|
loadedConfigPath = global;
|
|
1185
1215
|
return existsSync(global) ? global : null;
|
|
1186
1216
|
};
|
|
1217
|
+
var rebaseConfigBaseline = () => {
|
|
1218
|
+
loadedConfigState = currentConfigState();
|
|
1219
|
+
loadedConfigPath = join(getAgentDir(), "advisor.json");
|
|
1220
|
+
};
|
|
1187
1221
|
var saveConfig = (_ctx, options = {}) => {
|
|
1188
1222
|
const path = join(getAgentDir(), "advisor.json");
|
|
1189
1223
|
const persistAdvisor = options.persistAdvisor ?? true;
|
|
@@ -1211,11 +1245,75 @@ var saveConfig = (_ctx, options = {}) => {
|
|
|
1211
1245
|
setPersistedModelRefs(configuredModelRef(nextLoadedState.advisor), configuredModelRef(nextLoadedState.executor));
|
|
1212
1246
|
return path;
|
|
1213
1247
|
};
|
|
1214
|
-
var
|
|
1248
|
+
var writeConfigAtomically = (path, contents, expectedIdentity) => {
|
|
1249
|
+
const mode = existsSync(path) ? statSync(path).mode % 512 : 384;
|
|
1250
|
+
const temporaryPath = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
1251
|
+
let fileDescriptor;
|
|
1252
|
+
try {
|
|
1253
|
+
fileDescriptor = openSync(temporaryPath, "wx", mode);
|
|
1254
|
+
writeFileSync(fileDescriptor, contents, "utf-8");
|
|
1255
|
+
fsyncSync(fileDescriptor);
|
|
1256
|
+
closeSync(fileDescriptor);
|
|
1257
|
+
fileDescriptor = undefined;
|
|
1258
|
+
if (expectedIdentity !== undefined && configFileIdentity(path) !== expectedIdentity) {
|
|
1259
|
+
throw new Error("Advisor configuration changed during the update; retry so unrelated edits are preserved.");
|
|
1260
|
+
}
|
|
1261
|
+
renameSync(temporaryPath, path);
|
|
1262
|
+
} catch (error) {
|
|
1263
|
+
if (fileDescriptor !== undefined) {
|
|
1264
|
+
closeSync(fileDescriptor);
|
|
1265
|
+
}
|
|
1266
|
+
try {
|
|
1267
|
+
unlinkSync(temporaryPath);
|
|
1268
|
+
} catch {}
|
|
1269
|
+
throw error;
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
var saveGlobalOutcomeLogging = (enabled, expected, expectedKeys = ["advisorOutcomeLogging"]) => {
|
|
1215
1273
|
const path = join(getAgentDir(), "advisor.json");
|
|
1274
|
+
const identity = configFileIdentity(path);
|
|
1216
1275
|
const existing = readConfigForSave(path);
|
|
1217
|
-
|
|
1218
|
-
|
|
1276
|
+
if (expected && expectedKeys.some((key) => Object.hasOwn(existing, key) !== Object.hasOwn(expected, key) || !sameConfigValue(existing[key], expected[key]))) {
|
|
1277
|
+
throw new Error("Advisor settings changed during confirmation; read the settings again and retry.");
|
|
1278
|
+
}
|
|
1279
|
+
if (enabled === null) {
|
|
1280
|
+
Reflect.deleteProperty(existing, "advisorOutcomeLogging");
|
|
1281
|
+
} else {
|
|
1282
|
+
existing.advisorOutcomeLogging = enabled;
|
|
1283
|
+
}
|
|
1284
|
+
writeConfigAtomically(path, `${JSON.stringify(existing, null, 2)}
|
|
1285
|
+
`, identity);
|
|
1286
|
+
resetConfigCache();
|
|
1287
|
+
return path;
|
|
1288
|
+
};
|
|
1289
|
+
var readGlobalAdvisorConfig = () => {
|
|
1290
|
+
const path = join(getAgentDir(), "advisor.json");
|
|
1291
|
+
const config = readConfigForSave(path);
|
|
1292
|
+
validateConfig(config, path);
|
|
1293
|
+
return config;
|
|
1294
|
+
};
|
|
1295
|
+
var saveGlobalAdvisorConfigPatch = (patch, expected, expectedKeys) => {
|
|
1296
|
+
const path = join(getAgentDir(), "advisor.json");
|
|
1297
|
+
const unknownKeys = Object.keys(patch).filter((key) => !CONFIG_KEY_SET.has(key));
|
|
1298
|
+
if (unknownKeys.length > 0) {
|
|
1299
|
+
throw new Error(`Cannot update Advisor configuration: unsupported key(s) ${unknownKeys.map((key) => JSON.stringify(key)).join(", ")}.`);
|
|
1300
|
+
}
|
|
1301
|
+
const identity = configFileIdentity(path);
|
|
1302
|
+
const next = readConfigForSave(path);
|
|
1303
|
+
const checkedKeys = expectedKeys ?? Object.keys(patch);
|
|
1304
|
+
if (expected && checkedKeys.some((key) => Object.hasOwn(next, key) !== Object.hasOwn(expected, key) || !sameConfigValue(next[key], expected[key]))) {
|
|
1305
|
+
throw new Error("Advisor settings changed during confirmation; read the settings again and retry.");
|
|
1306
|
+
}
|
|
1307
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
1308
|
+
if (value === null) {
|
|
1309
|
+
Reflect.deleteProperty(next, key);
|
|
1310
|
+
} else {
|
|
1311
|
+
next[key] = value;
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
validateConfig(next, path);
|
|
1315
|
+
writeConfigAtomically(path, `${JSON.stringify(next, null, 2)}
|
|
1316
|
+
`, identity);
|
|
1219
1317
|
resetConfigCache();
|
|
1220
1318
|
return path;
|
|
1221
1319
|
};
|
|
@@ -1286,7 +1384,6 @@ var selectedEffort = (choice) => {
|
|
|
1286
1384
|
const effort = choice.startsWith(SELECTED_PREFIX) ? choice.slice(SELECTED_PREFIX.length) : choice;
|
|
1287
1385
|
return effort === DEFAULT_EFFORT_LEVEL ? undefined : effort;
|
|
1288
1386
|
};
|
|
1289
|
-
var ADVISOR_ACTIVATION_EXPLANATION = "The Advisor is a second-opinion model that reviews the Executor's context and returns risks, alternatives, and verification steps without changing files or running tools.";
|
|
1290
1387
|
var ARGUMENT_WHITESPACE2 = /\s+/u;
|
|
1291
1388
|
var hasModelOverride = (args, key) => args.trim().split(ARGUMENT_WHITESPACE2).some((token) => {
|
|
1292
1389
|
const [tokenKey, value] = token.split("=");
|
|
@@ -1359,13 +1456,13 @@ var isSelectableModel = (ctx, ref, availableRefs) => {
|
|
|
1359
1456
|
var getExplicitModelError = (ctx, ref, label, overridden, availableRefs) => {
|
|
1360
1457
|
if (overridden) {
|
|
1361
1458
|
if (!ref) {
|
|
1362
|
-
return `${label} model not configured`;
|
|
1459
|
+
return `${label} ${t("activation.modelNotConfigured", "model not configured")}`;
|
|
1363
1460
|
}
|
|
1364
1461
|
if (!findConfiguredModel(ctx, ref)) {
|
|
1365
|
-
return `${label} model not found: ${ref}`;
|
|
1462
|
+
return `${label} ${t("activation.modelNotFound.prefix", "model not found:")} ${ref}`;
|
|
1366
1463
|
}
|
|
1367
1464
|
if (availableRefs && !isSelectableModel(ctx, ref, availableRefs)) {
|
|
1368
|
-
return `${label} model unavailable: ${ref}`;
|
|
1465
|
+
return `${label} ${t("activation.modelUnavailable.prefix", "model unavailable:")} ${ref}`;
|
|
1369
1466
|
}
|
|
1370
1467
|
}
|
|
1371
1468
|
};
|
|
@@ -1405,7 +1502,6 @@ class ModelSelectorAdapter {
|
|
|
1405
1502
|
|
|
1406
1503
|
// src/ui/searchable-model-list.ts
|
|
1407
1504
|
import { fuzzyFilter, Input, truncateToWidth } from "@earendil-works/pi-tui";
|
|
1408
|
-
|
|
1409
1505
|
class SearchableModelList {
|
|
1410
1506
|
tui;
|
|
1411
1507
|
searchInput;
|
|
@@ -1467,14 +1563,14 @@ class SearchableModelList {
|
|
|
1467
1563
|
const lines = [this.theme.fg("border", "─".repeat(width))];
|
|
1468
1564
|
lines.push(` ${this.theme.fg("accent", this.theme.bold(this.title))}`);
|
|
1469
1565
|
const inputLines = this.searchInput.render(Math.max(1, width - 10));
|
|
1470
|
-
lines.push(` ${this.theme.fg("accent", "Search:
|
|
1566
|
+
lines.push(` ${this.theme.fg("accent", t("modelPicker.searchLabel", "Search:"))} ${inputLines[0] || ""}`, "");
|
|
1471
1567
|
const query = this.searchInput.getValue().trim();
|
|
1472
1568
|
this.filteredOptions = query ? fuzzyFilter(this.allOptions, query, (item) => item) : this.allOptions;
|
|
1473
1569
|
this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredOptions.length - 1));
|
|
1474
1570
|
const maxVisible = 10;
|
|
1475
1571
|
const total = this.filteredOptions.length;
|
|
1476
1572
|
if (total === 0) {
|
|
1477
|
-
lines.push(` ${this.theme.fg("muted", "No matching models found.")}`);
|
|
1573
|
+
lines.push(` ${this.theme.fg("muted", t("modelPicker.noMatches", "No matching models found."))}`);
|
|
1478
1574
|
} else {
|
|
1479
1575
|
const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(maxVisible / 2), total - maxVisible));
|
|
1480
1576
|
const endIndex = Math.min(startIndex + maxVisible, total);
|
|
@@ -1530,7 +1626,7 @@ class SearchableModelList {
|
|
|
1530
1626
|
this.tui.requestRender();
|
|
1531
1627
|
}
|
|
1532
1628
|
interactionHint() {
|
|
1533
|
-
return this.multiSelect ? "Type to search · ↑↓: navigate · Space: toggle · Enter: apply · Esc: cancel" : "Type to search · ↑↓: navigate · Enter: select · Esc: cancel";
|
|
1629
|
+
return this.multiSelect ? t("modelPicker.hintMulti", "Type to search · ↑↓: navigate · Space: toggle · Enter: apply · Esc: cancel") : t("modelPicker.hintSingle", "Type to search · ↑↓: navigate · Enter: select · Esc: cancel");
|
|
1534
1630
|
}
|
|
1535
1631
|
renderOption(item, index) {
|
|
1536
1632
|
let tick = " ";
|
|
@@ -1588,7 +1684,7 @@ var selectAdvisorModels = async (ctx, options) => {
|
|
|
1588
1684
|
}
|
|
1589
1685
|
const refs = getAvailableModelRefs(ctx);
|
|
1590
1686
|
if (refs && refs.length === 0) {
|
|
1591
|
-
ctx.ui.notify("No selectable models are available. Configure a provider with /login or models.json, then retry.", "error");
|
|
1687
|
+
ctx.ui.notify(t("notify.noSelectableModels.message", "No selectable models are available. Configure a provider with /login or models.json, then retry."), "error");
|
|
1592
1688
|
return;
|
|
1593
1689
|
}
|
|
1594
1690
|
const allOptions = [
|
|
@@ -1609,13 +1705,13 @@ var selectAdvisorModels = async (ctx, options) => {
|
|
|
1609
1705
|
onCancel: () => done(undefined),
|
|
1610
1706
|
onSelect: done,
|
|
1611
1707
|
theme,
|
|
1612
|
-
title: "Select Executor Model",
|
|
1708
|
+
title: t("modelPicker.selectExecutor", "Select Executor Model"),
|
|
1613
1709
|
tui
|
|
1614
1710
|
}));
|
|
1615
1711
|
if (!selectedExecutor) {
|
|
1616
1712
|
return;
|
|
1617
1713
|
}
|
|
1618
|
-
const selectedExecutorEffort = await ctx.ui.select("Select Executor Reasoning/Thinking Level", effortChoices(executorEffort));
|
|
1714
|
+
const selectedExecutorEffort = await ctx.ui.select(t("modelPicker.executorEffort", "Select Executor Reasoning/Thinking Level"), effortChoices(executorEffort));
|
|
1619
1715
|
if (!selectedExecutorEffort) {
|
|
1620
1716
|
return;
|
|
1621
1717
|
}
|
|
@@ -1630,13 +1726,13 @@ var selectAdvisorModels = async (ctx, options) => {
|
|
|
1630
1726
|
onCancel: () => done(undefined),
|
|
1631
1727
|
onSelect: done,
|
|
1632
1728
|
theme,
|
|
1633
|
-
title: "Select Advisor Model",
|
|
1729
|
+
title: t("modelPicker.selectAdvisor", "Select Advisor Model"),
|
|
1634
1730
|
tui
|
|
1635
1731
|
}));
|
|
1636
1732
|
if (!selectedAdvisor) {
|
|
1637
1733
|
return;
|
|
1638
1734
|
}
|
|
1639
|
-
const selectedAdvisorEffort = await ctx.ui.select("Select Advisor Reasoning/Thinking Level", effortChoices(advisorEffort));
|
|
1735
|
+
const selectedAdvisorEffort = await ctx.ui.select(t("modelPicker.advisorEffort", "Select Advisor Reasoning/Thinking Level"), effortChoices(advisorEffort));
|
|
1640
1736
|
if (!selectedAdvisorEffort) {
|
|
1641
1737
|
return;
|
|
1642
1738
|
}
|
|
@@ -1656,7 +1752,7 @@ var selectAdvisorModels = async (ctx, options) => {
|
|
|
1656
1752
|
onCancel: () => done(undefined),
|
|
1657
1753
|
onSelect: done,
|
|
1658
1754
|
theme,
|
|
1659
|
-
title: "Select Fallback Advisor Model (optional)",
|
|
1755
|
+
title: t("modelPicker.selectFallbackAdvisor", "Select Fallback Advisor Model (optional)"),
|
|
1660
1756
|
tui
|
|
1661
1757
|
}));
|
|
1662
1758
|
if (selectedFallback === undefined) {
|
|
@@ -2036,7 +2132,7 @@ var herdrAdvisorActivity = new HerdrAdvisorActivity(sendToHerdr, () => getAdviso
|
|
|
2036
2132
|
var herdrAdvisorBlock = new HerdrAdvisorBlock(sendToHerdr, () => getAdvisorSettings().herdrIntegration);
|
|
2037
2133
|
|
|
2038
2134
|
// src/tools/consultation.ts
|
|
2039
|
-
import { randomUUID as
|
|
2135
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
2040
2136
|
|
|
2041
2137
|
// src/model-stream.ts
|
|
2042
2138
|
import { stream } from "@earendil-works/pi-ai/compat";
|
|
@@ -2253,7 +2349,7 @@ var sessionContextEntries = (ctx) => {
|
|
|
2253
2349
|
};
|
|
2254
2350
|
|
|
2255
2351
|
// src/tools/consult-context.ts
|
|
2256
|
-
import { randomUUID } from "node:crypto";
|
|
2352
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
2257
2353
|
|
|
2258
2354
|
// src/attachments.ts
|
|
2259
2355
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
@@ -2874,9 +2970,6 @@ var readProjectRules = async (ctx, maxBytes = PREFERENCES_MAX_BYTES, redact = tr
|
|
|
2874
2970
|
};
|
|
2875
2971
|
};
|
|
2876
2972
|
|
|
2877
|
-
// src/scout-groups.ts
|
|
2878
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
2879
|
-
|
|
2880
2973
|
// src/tool-result-cap.ts
|
|
2881
2974
|
var OMITTED_MARKER = "[... omitted tool-result section ...]";
|
|
2882
2975
|
var collect = (candidates, maxEntries, maxContentBytes) => {
|
|
@@ -3067,6 +3160,52 @@ var recentConversation = (ctx, maxChars = 15000, toolResultMaxLines = advisorToo
|
|
|
3067
3160
|
return selectRecentEntries(entries, maxChars);
|
|
3068
3161
|
};
|
|
3069
3162
|
|
|
3163
|
+
// src/scout-group-serialization.ts
|
|
3164
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
3165
|
+
|
|
3166
|
+
// src/scout-types.ts
|
|
3167
|
+
var SCOUT_MANIFEST_MAX_BYTES = 64 * 1024;
|
|
3168
|
+
var SCOUT_MANIFEST_MAX_GROUPS = 64;
|
|
3169
|
+
var SCOUT_GROUP_MAX_BYTES = 24 * 1024;
|
|
3170
|
+
var SCOUT_LABEL_MAX_CHARS = 160;
|
|
3171
|
+
var SCOUT_SELECTION_MAX_IDS = 32;
|
|
3172
|
+
var SCOUT_SYNTHESIS_MAX_BYTES = 4 * 1024;
|
|
3173
|
+
|
|
3174
|
+
// src/scout-group-serialization.ts
|
|
3175
|
+
var SPEAKER_PREFIX = /^(?<speaker>User|Executor):\s*/u;
|
|
3176
|
+
var boundedLabel = (value) => [...value.replaceAll(/\s+/gu, " ").trim()].slice(0, SCOUT_LABEL_MAX_CHARS).join("");
|
|
3177
|
+
var labelFor = (kind, content) => {
|
|
3178
|
+
const preview = boundedLabel(content.replace(SPEAKER_PREFIX, ""));
|
|
3179
|
+
const prefix = {
|
|
3180
|
+
assistant: "Executor",
|
|
3181
|
+
compaction: "Compaction summary",
|
|
3182
|
+
"pending-invocation": "Current Advisor invocation",
|
|
3183
|
+
"tool-exchange": "Tool exchange",
|
|
3184
|
+
user: "User request"
|
|
3185
|
+
};
|
|
3186
|
+
return boundedLabel(`${prefix[kind]}: ${preview || "(no text)"}`);
|
|
3187
|
+
};
|
|
3188
|
+
var stableId = (index, entryIds, kind, content) => `g_${createHash2("sha256").update(JSON.stringify([index, entryIds, kind, content])).digest("hex").slice(0, 16)}`;
|
|
3189
|
+
var createScoutContextGroup = (originalIndex, entryIds, kind, content, required) => ({
|
|
3190
|
+
bytes: byteLength(content),
|
|
3191
|
+
content,
|
|
3192
|
+
entryIds,
|
|
3193
|
+
id: stableId(originalIndex, entryIds, kind, content),
|
|
3194
|
+
kind,
|
|
3195
|
+
label: labelFor(kind, content),
|
|
3196
|
+
originalIndex,
|
|
3197
|
+
required
|
|
3198
|
+
});
|
|
3199
|
+
var groupWire = (group) => ({
|
|
3200
|
+
bytes: group.bytes,
|
|
3201
|
+
content: group.content,
|
|
3202
|
+
id: group.id,
|
|
3203
|
+
kind: group.kind,
|
|
3204
|
+
label: group.label,
|
|
3205
|
+
required: group.required
|
|
3206
|
+
});
|
|
3207
|
+
var groupWireBytes = (group) => byteLength(JSON.stringify(groupWire(group)));
|
|
3208
|
+
|
|
3070
3209
|
// src/scout-protocol.ts
|
|
3071
3210
|
var invalid = (message) => ({
|
|
3072
3211
|
message,
|
|
@@ -3141,48 +3280,7 @@ var indexToolCalls = (entries) => {
|
|
|
3141
3280
|
};
|
|
3142
3281
|
};
|
|
3143
3282
|
|
|
3144
|
-
// src/scout-types.ts
|
|
3145
|
-
var SCOUT_MANIFEST_MAX_BYTES = 64 * 1024;
|
|
3146
|
-
var SCOUT_MANIFEST_MAX_GROUPS = 64;
|
|
3147
|
-
var SCOUT_GROUP_MAX_BYTES = 24 * 1024;
|
|
3148
|
-
var SCOUT_LABEL_MAX_CHARS = 160;
|
|
3149
|
-
var SCOUT_SELECTION_MAX_IDS = 32;
|
|
3150
|
-
var SCOUT_SYNTHESIS_MAX_BYTES = 4 * 1024;
|
|
3151
|
-
|
|
3152
3283
|
// src/scout-groups.ts
|
|
3153
|
-
var SPEAKER_PREFIX = /^(?<speaker>User|Executor):\s*/u;
|
|
3154
|
-
var boundedLabel = (value) => [...value.replaceAll(/\s+/gu, " ").trim()].slice(0, SCOUT_LABEL_MAX_CHARS).join("");
|
|
3155
|
-
var labelFor = (kind, content) => {
|
|
3156
|
-
const preview = boundedLabel(content.replace(SPEAKER_PREFIX, ""));
|
|
3157
|
-
const prefix = {
|
|
3158
|
-
assistant: "Executor",
|
|
3159
|
-
compaction: "Compaction summary",
|
|
3160
|
-
"pending-invocation": "Current Advisor invocation",
|
|
3161
|
-
"tool-exchange": "Tool exchange",
|
|
3162
|
-
user: "User request"
|
|
3163
|
-
};
|
|
3164
|
-
return boundedLabel(`${prefix[kind]}: ${preview || "(no text)"}`);
|
|
3165
|
-
};
|
|
3166
|
-
var stableId = (index, entryIds, kind, content) => `g_${createHash2("sha256").update(JSON.stringify([index, entryIds, kind, content])).digest("hex").slice(0, 16)}`;
|
|
3167
|
-
var groupWire = (group) => ({
|
|
3168
|
-
bytes: group.bytes,
|
|
3169
|
-
content: group.content,
|
|
3170
|
-
id: group.id,
|
|
3171
|
-
kind: group.kind,
|
|
3172
|
-
label: group.label,
|
|
3173
|
-
required: group.required
|
|
3174
|
-
});
|
|
3175
|
-
var groupWireBytes = (group) => byteLength(JSON.stringify(groupWire(group)));
|
|
3176
|
-
var createGroup = (originalIndex, entryIds, kind, content, required) => ({
|
|
3177
|
-
bytes: byteLength(content),
|
|
3178
|
-
content,
|
|
3179
|
-
entryIds,
|
|
3180
|
-
id: stableId(originalIndex, entryIds, kind, content),
|
|
3181
|
-
kind,
|
|
3182
|
-
label: labelFor(kind, content),
|
|
3183
|
-
originalIndex,
|
|
3184
|
-
required
|
|
3185
|
-
});
|
|
3186
3284
|
var pendingAdvisorArguments = (part) => {
|
|
3187
3285
|
const value = isRecord(part.arguments) ? part.arguments : {};
|
|
3188
3286
|
const allowed = {};
|
|
@@ -3250,7 +3348,7 @@ var missingOutcome = (entry, index, entryId, disclosed, callIds, missing, result
|
|
|
3250
3348
|
}
|
|
3251
3349
|
const pendingDisclosed = pendingInvocationDisclosure(entry, currentInvocationId, caps.toolResultMaxLines, caps.toolResultMaxBytes, caps.policies, caps.redact, caps.imageNonce, disclosed);
|
|
3252
3350
|
return {
|
|
3253
|
-
group:
|
|
3351
|
+
group: createScoutContextGroup(index, [entryId, ...resultEntryIds], "pending-invocation", [pendingDisclosed ?? disclosed, ...resultParts].join(`
|
|
3254
3352
|
|
|
3255
3353
|
`), true),
|
|
3256
3354
|
kind: "group"
|
|
@@ -3274,7 +3372,7 @@ var toolExchangeGroup = (entry, message, index, entryId, disclosed, immediate, i
|
|
|
3274
3372
|
return missingOutcome(entry, index, entryId, disclosed, callIds, missing, resultParts, resultEntryIds, caps);
|
|
3275
3373
|
}
|
|
3276
3374
|
return {
|
|
3277
|
-
group:
|
|
3375
|
+
group: createScoutContextGroup(index, [entryId, ...resultEntryIds], "tool-exchange", [disclosed, ...resultParts].join(`
|
|
3278
3376
|
|
|
3279
3377
|
`), false),
|
|
3280
3378
|
kind: "group"
|
|
@@ -3299,14 +3397,14 @@ var groupForEntry = (entry, index, disclosed, immediate, indexed, consumedResult
|
|
|
3299
3397
|
const entryId = isString(entry.id) ? entry.id : String(index);
|
|
3300
3398
|
if (entry.type !== "message" || !isRecord(entry.message)) {
|
|
3301
3399
|
return {
|
|
3302
|
-
group:
|
|
3400
|
+
group: createScoutContextGroup(index, [entryId], "compaction", disclosed, false),
|
|
3303
3401
|
kind: "group"
|
|
3304
3402
|
};
|
|
3305
3403
|
}
|
|
3306
3404
|
const { message } = entry;
|
|
3307
3405
|
if (message.role === "user") {
|
|
3308
3406
|
return {
|
|
3309
|
-
group:
|
|
3407
|
+
group: createScoutContextGroup(index, [entryId], "user", disclosed, index === indexed.latestUserIndex),
|
|
3310
3408
|
kind: "group"
|
|
3311
3409
|
};
|
|
3312
3410
|
}
|
|
@@ -3318,7 +3416,7 @@ var groupForEntry = (entry, index, disclosed, immediate, indexed, consumedResult
|
|
|
3318
3416
|
}
|
|
3319
3417
|
if (!hasCalls(message)) {
|
|
3320
3418
|
return {
|
|
3321
|
-
group:
|
|
3419
|
+
group: createScoutContextGroup(index, [entryId], "assistant", disclosed, false),
|
|
3322
3420
|
kind: "group"
|
|
3323
3421
|
};
|
|
3324
3422
|
}
|
|
@@ -3489,6 +3587,55 @@ var buildScoutManifest = (ctx, options = {}) => {
|
|
|
3489
3587
|
return fitToBudget(built, caps);
|
|
3490
3588
|
};
|
|
3491
3589
|
|
|
3590
|
+
// src/scout-selection.ts
|
|
3591
|
+
var byteLength2 = (value) => Buffer.byteLength(value, "utf-8");
|
|
3592
|
+
var isStringArray = (value) => Array.isArray(value) && value.every(isString);
|
|
3593
|
+
var parseScoutSelection = (text, manifest) => {
|
|
3594
|
+
if (!text.trim()) {
|
|
3595
|
+
throw new Error("Scout returned an empty response.");
|
|
3596
|
+
}
|
|
3597
|
+
let value;
|
|
3598
|
+
try {
|
|
3599
|
+
value = JSON.parse(text);
|
|
3600
|
+
} catch (error) {
|
|
3601
|
+
throw new Error("Scout response is not a JSON object.", { cause: error });
|
|
3602
|
+
}
|
|
3603
|
+
if (!isRecord(value)) {
|
|
3604
|
+
throw new Error("Scout response must be a JSON object.");
|
|
3605
|
+
}
|
|
3606
|
+
const keys = Object.keys(value).toSorted();
|
|
3607
|
+
if (keys.length !== 2 || keys[0] !== "selectedIds" || keys[1] !== "synthesis") {
|
|
3608
|
+
throw new Error("Scout response must contain only selectedIds and synthesis.");
|
|
3609
|
+
}
|
|
3610
|
+
if (!isStringArray(value.selectedIds)) {
|
|
3611
|
+
throw new Error("Scout selectedIds must be an array of strings.");
|
|
3612
|
+
}
|
|
3613
|
+
const { selectedIds } = value;
|
|
3614
|
+
if (new Set(selectedIds).size !== selectedIds.length) {
|
|
3615
|
+
throw new Error("Scout selected duplicate group IDs.");
|
|
3616
|
+
}
|
|
3617
|
+
const known = new Set(manifest.groups.map((group) => group.id));
|
|
3618
|
+
const knownSelectedIds = selectedIds.filter((id) => known.has(id));
|
|
3619
|
+
const requiredIds = manifest.groups.filter((group) => group.required).map((group) => group.id);
|
|
3620
|
+
if (requiredIds.length > SCOUT_SELECTION_MAX_IDS) {
|
|
3621
|
+
throw new Error(`Manifest contains more than ${SCOUT_SELECTION_MAX_IDS} required groups.`);
|
|
3622
|
+
}
|
|
3623
|
+
const required = new Set(requiredIds);
|
|
3624
|
+
const optionalIds = knownSelectedIds.filter((id) => !required.has(id)).slice(0, SCOUT_SELECTION_MAX_IDS - requiredIds.length);
|
|
3625
|
+
const retained = new Set([...requiredIds, ...optionalIds]);
|
|
3626
|
+
const normalizedIds = manifest.groups.filter((group) => retained.has(group.id)).map((group) => group.id);
|
|
3627
|
+
if (!isString(value.synthesis)) {
|
|
3628
|
+
throw new TypeError("Scout synthesis must be a string.");
|
|
3629
|
+
}
|
|
3630
|
+
if (byteLength2(value.synthesis) > SCOUT_SYNTHESIS_MAX_BYTES) {
|
|
3631
|
+
throw new Error(`Scout synthesis exceeds ${SCOUT_SYNTHESIS_MAX_BYTES} UTF-8 bytes.`);
|
|
3632
|
+
}
|
|
3633
|
+
return {
|
|
3634
|
+
selectedIds: normalizedIds,
|
|
3635
|
+
synthesis: knownSelectedIds.length > 0 ? value.synthesis : ""
|
|
3636
|
+
};
|
|
3637
|
+
};
|
|
3638
|
+
|
|
3492
3639
|
// src/usage.ts
|
|
3493
3640
|
var finite = (value) => isNumber(value) && Number.isFinite(value) && value >= 0 ? value : undefined;
|
|
3494
3641
|
var add = (left, right) => left === undefined || right === undefined ? left ?? right : left + right;
|
|
@@ -3664,13 +3811,16 @@ var formatAdvisorUsage = (usage) => {
|
|
|
3664
3811
|
var formatAdvisorUsageTotals = (totals) => {
|
|
3665
3812
|
const usage = formatUsageFields(totals);
|
|
3666
3813
|
const missing = totals.calls - totals.knownCalls;
|
|
3667
|
-
return [
|
|
3814
|
+
return [
|
|
3815
|
+
usage,
|
|
3816
|
+
missing > 0 ? `${missing} ${t("usage.withoutData", "without usage data")}` : undefined
|
|
3817
|
+
].filter((value) => value !== undefined).join(" · ") || t("usage.unavailable", "unavailable");
|
|
3668
3818
|
};
|
|
3669
3819
|
var formatAdvisorUsageStatus = (totals) => {
|
|
3670
3820
|
if (totals.calls === 0) {
|
|
3671
3821
|
return;
|
|
3672
3822
|
}
|
|
3673
|
-
return
|
|
3823
|
+
return `${t("usage.advisorPrefix", "Advisor:")} ${totals.calls} ${totals.calls === 1 ? t("usage.call", "call") : t("usage.calls", "calls")} · ${formatAdvisorUsageTotals(totals)}`;
|
|
3674
3824
|
};
|
|
3675
3825
|
|
|
3676
3826
|
// src/scout.ts
|
|
@@ -3690,7 +3840,6 @@ var defaultDependencies = {
|
|
|
3690
3840
|
collect: collectTextStream,
|
|
3691
3841
|
resolve: resolveConfiguredModel
|
|
3692
3842
|
};
|
|
3693
|
-
var byteLength2 = (value) => Buffer.byteLength(value, "utf-8");
|
|
3694
3843
|
var AUTH_ERROR_PATTERN = /api key|auth|login|credential/iu;
|
|
3695
3844
|
var manifestMessage = (manifest) => ({
|
|
3696
3845
|
content: [
|
|
@@ -3708,52 +3857,6 @@ var manifestMessage = (manifest) => ({
|
|
|
3708
3857
|
role: "user",
|
|
3709
3858
|
timestamp: Date.now()
|
|
3710
3859
|
});
|
|
3711
|
-
var isStringArray = (value) => Array.isArray(value) && value.every(isString);
|
|
3712
|
-
var parseScoutSelection = (text, manifest) => {
|
|
3713
|
-
if (!text.trim()) {
|
|
3714
|
-
throw new Error("Scout returned an empty response.");
|
|
3715
|
-
}
|
|
3716
|
-
let value;
|
|
3717
|
-
try {
|
|
3718
|
-
value = JSON.parse(text);
|
|
3719
|
-
} catch (error) {
|
|
3720
|
-
throw new Error("Scout response is not a JSON object.", { cause: error });
|
|
3721
|
-
}
|
|
3722
|
-
if (!isRecord(value)) {
|
|
3723
|
-
throw new Error("Scout response must be a JSON object.");
|
|
3724
|
-
}
|
|
3725
|
-
const keys = Object.keys(value).toSorted();
|
|
3726
|
-
if (keys.length !== 2 || keys[0] !== "selectedIds" || keys[1] !== "synthesis") {
|
|
3727
|
-
throw new Error("Scout response must contain only selectedIds and synthesis.");
|
|
3728
|
-
}
|
|
3729
|
-
if (!isStringArray(value.selectedIds)) {
|
|
3730
|
-
throw new Error("Scout selectedIds must be an array of strings.");
|
|
3731
|
-
}
|
|
3732
|
-
const { selectedIds } = value;
|
|
3733
|
-
if (new Set(selectedIds).size !== selectedIds.length) {
|
|
3734
|
-
throw new Error("Scout selected duplicate group IDs.");
|
|
3735
|
-
}
|
|
3736
|
-
const known = new Set(manifest.groups.map((group) => group.id));
|
|
3737
|
-
const knownSelectedIds = selectedIds.filter((id) => known.has(id));
|
|
3738
|
-
const requiredIds = manifest.groups.filter((group) => group.required).map((group) => group.id);
|
|
3739
|
-
if (requiredIds.length > SCOUT_SELECTION_MAX_IDS) {
|
|
3740
|
-
throw new Error(`Manifest contains more than ${SCOUT_SELECTION_MAX_IDS} required groups.`);
|
|
3741
|
-
}
|
|
3742
|
-
const required = new Set(requiredIds);
|
|
3743
|
-
const optionalIds = knownSelectedIds.filter((id) => !required.has(id)).slice(0, SCOUT_SELECTION_MAX_IDS - requiredIds.length);
|
|
3744
|
-
const retained = new Set([...requiredIds, ...optionalIds]);
|
|
3745
|
-
const normalizedIds = manifest.groups.filter((group) => retained.has(group.id)).map((group) => group.id);
|
|
3746
|
-
if (!isString(value.synthesis)) {
|
|
3747
|
-
throw new TypeError("Scout synthesis must be a string.");
|
|
3748
|
-
}
|
|
3749
|
-
if (byteLength2(value.synthesis) > SCOUT_SYNTHESIS_MAX_BYTES) {
|
|
3750
|
-
throw new Error(`Scout synthesis exceeds ${SCOUT_SYNTHESIS_MAX_BYTES} UTF-8 bytes.`);
|
|
3751
|
-
}
|
|
3752
|
-
return {
|
|
3753
|
-
selectedIds: normalizedIds,
|
|
3754
|
-
synthesis: knownSelectedIds.length > 0 ? value.synthesis : ""
|
|
3755
|
-
};
|
|
3756
|
-
};
|
|
3757
3860
|
var baseMetrics = (manifest, startedAt) => ({
|
|
3758
3861
|
availableCount: manifest.availableCount,
|
|
3759
3862
|
inputBytes: manifest.availableBytes,
|
|
@@ -4080,7 +4183,7 @@ var assembleConsultationContext = async (options) => {
|
|
|
4080
4183
|
const changes = collectGitContext(ctx.cwd, level, gitBudget, advisorRedactSecretsRef ? redactSecrets : undefined);
|
|
4081
4184
|
const changeText = advisorRepositoryContext(changes, options.gitContext ?? allowed, level, gitBudget);
|
|
4082
4185
|
const conversationBudget = Math.max(0, contextMaxCharsRef - changeText.length);
|
|
4083
|
-
const imageNonce =
|
|
4186
|
+
const imageNonce = randomUUID2();
|
|
4084
4187
|
const legacyConversation = advisorRequestConversation(ctx, conversationBudget, true, imageNonce);
|
|
4085
4188
|
const curated = await curateAdvisorConversation(ctx, legacyConversation, options.signal, options.onScout, advisorScoutEnabledRef, runAdvisorScout, options.currentInvocationId, conversationBudget, imageNonce);
|
|
4086
4189
|
const preferences = await readProjectPreferences(ctx, ATTACHMENT_TEXT_MAX_BYTES, advisorRedactSecretsRef);
|
|
@@ -4461,7 +4564,7 @@ var consultAdvisor = async (ctx, question, signal, onChunk, trigger = "executor-
|
|
|
4461
4564
|
signal,
|
|
4462
4565
|
systemPrompt: ADVISOR_SYSTEM
|
|
4463
4566
|
});
|
|
4464
|
-
const adviceId =
|
|
4567
|
+
const adviceId = randomUUID3();
|
|
4465
4568
|
const { followUpPayload, ...publicResult } = result;
|
|
4466
4569
|
onFollowUpPayload?.(adviceId, followUpPayload, followUp?.adviceId);
|
|
4467
4570
|
return { ...publicResult, adviceId, trigger };
|
|
@@ -4617,7 +4720,7 @@ class ThinkingMarkdown {
|
|
|
4617
4720
|
}
|
|
4618
4721
|
}
|
|
4619
4722
|
var hiddenThinkingLabel = (theme) => {
|
|
4620
|
-
const label = theme.fg("thinkingText", `${THINKING_PREFIX}Thinking
|
|
4723
|
+
const label = theme.fg("thinkingText", `${THINKING_PREFIX}${t("render.thinking", "Thinking…")}`);
|
|
4621
4724
|
return {
|
|
4622
4725
|
invalidate: noop,
|
|
4623
4726
|
render: () => [label]
|
|
@@ -4628,7 +4731,7 @@ var resolveAdvisorRequest = (question) => question?.trim() || undefined;
|
|
|
4628
4731
|
var renderAdvisorCallBox = (question, theme, followUp = false) => {
|
|
4629
4732
|
const box = new Box(1, 1, (text) => theme.bg("customMessageBg", text));
|
|
4630
4733
|
const label = theme.fg("customMessageLabel", theme.bold("[advisor]"));
|
|
4631
|
-
const title = theme.fg("customMessageText", followUp ? "Executor → Advisor · Follow-up" : "Executor → Advisor");
|
|
4734
|
+
const title = theme.fg("customMessageText", followUp ? `${t("render.executorToAdvisor", "Executor → Advisor")} · ${t("render.followUp", "Follow-up")}` : t("render.executorToAdvisor", "Executor → Advisor"));
|
|
4632
4735
|
box.addChild(new Text(question ? `${label} ${title}
|
|
4633
4736
|
${theme.fg("dim", ` ${question}`)}` : `${label} ${title}`, 0, 0));
|
|
4634
4737
|
return box;
|
|
@@ -4637,7 +4740,7 @@ var COLLAPSED_ADVICE_LINES = 12;
|
|
|
4637
4740
|
var SOUND_VERDICT = /^Verdict:\s*sound$/u;
|
|
4638
4741
|
var hasSoundVerdict = (advice) => SOUND_VERDICT.test((advice.split(`
|
|
4639
4742
|
`).find((line) => line.trim()) ?? "").trim());
|
|
4640
|
-
var renderAdvisorResponseHeader = (sound, theme) => sound ? theme.fg("accent", theme.bold(
|
|
4743
|
+
var renderAdvisorResponseHeader = (sound, theme) => sound ? theme.fg("accent", theme.bold(`◆ ADVISOR · ${t("render.sound", "SOUND")}`)) : theme.fg("warning", theme.bold(`◆ ADVISOR ${t("render.response", "RESPONSE")}`));
|
|
4641
4744
|
var adviceForDisplay = (advice, expanded) => {
|
|
4642
4745
|
if (!advisorCollapseResponsesRef || expanded) {
|
|
4643
4746
|
return advice;
|
|
@@ -4723,7 +4826,7 @@ class ScoutStatusManager {
|
|
|
4723
4826
|
if (event.type === "call" || event.type === "chunk") {
|
|
4724
4827
|
this.#active.add(token);
|
|
4725
4828
|
if (this.showStatus) {
|
|
4726
|
-
uiAction(ctx, (ui) => ui.setStatus("advisor-scout", "Scout curating…"));
|
|
4829
|
+
uiAction(ctx, (ui) => ui.setStatus("advisor-scout", t("status.scoutCurating", "Scout curating…")));
|
|
4727
4830
|
}
|
|
4728
4831
|
return;
|
|
4729
4832
|
}
|
|
@@ -4736,7 +4839,7 @@ class ScoutStatusManager {
|
|
|
4736
4839
|
if (!(uiAvailable(ctx) && this.showStatus)) {
|
|
4737
4840
|
return;
|
|
4738
4841
|
}
|
|
4739
|
-
uiAction(ctx, (ui) => ui.setStatus("advisor-scout", this.#active.size > 0 ? "Scout curating…" : undefined));
|
|
4842
|
+
uiAction(ctx, (ui) => ui.setStatus("advisor-scout", this.#active.size > 0 ? t("status.scoutCurating", "Scout curating…") : undefined));
|
|
4740
4843
|
}
|
|
4741
4844
|
clear(ctx) {
|
|
4742
4845
|
for (const token of this.#known) {
|
|
@@ -5010,7 +5113,7 @@ class AdvisorJevLedgerState {
|
|
|
5010
5113
|
}
|
|
5011
5114
|
}
|
|
5012
5115
|
|
|
5013
|
-
// src/
|
|
5116
|
+
// src/tool-input-normalization.ts
|
|
5014
5117
|
var WHITESPACE = /\s/u;
|
|
5015
5118
|
var TIMESTAMP_KEYS = new Set([
|
|
5016
5119
|
"createdat",
|
|
@@ -5078,6 +5181,8 @@ var normalizeToolInput = (toolName, input) => {
|
|
|
5078
5181
|
return visit(input);
|
|
5079
5182
|
};
|
|
5080
5183
|
var normalizedToolSignature = (toolName, input) => `${toolName}:${JSON.stringify(normalizeToolInput(toolName, input))}`;
|
|
5184
|
+
|
|
5185
|
+
// src/session-state.ts
|
|
5081
5186
|
var freshRepetition = () => ({
|
|
5082
5187
|
count: 0,
|
|
5083
5188
|
interventions: 0
|
|
@@ -5293,7 +5398,7 @@ class AdvisorSessionState {
|
|
|
5293
5398
|
parts.push(`${count} ${decision}`);
|
|
5294
5399
|
}
|
|
5295
5400
|
}
|
|
5296
|
-
return parts.join(", ") || "none";
|
|
5401
|
+
return parts.join(", ") || t("sessionSummary.none", "none");
|
|
5297
5402
|
}
|
|
5298
5403
|
#countTrigger(trigger) {
|
|
5299
5404
|
return this.#usage.invocations.filter((item) => item.trigger === trigger).length;
|
|
@@ -5306,7 +5411,7 @@ class AdvisorSessionState {
|
|
|
5306
5411
|
"repeated-tool-call",
|
|
5307
5412
|
"completion-review",
|
|
5308
5413
|
"custom-rule"
|
|
5309
|
-
].filter((trigger) => this.#countTrigger(trigger) > 0).join(", ") || "none";
|
|
5414
|
+
].filter((trigger) => this.#countTrigger(trigger) > 0).join(", ") || t("sessionSummary.none", "none");
|
|
5310
5415
|
}
|
|
5311
5416
|
recordJevFilterAllowed() {
|
|
5312
5417
|
this.#jev.recordFilterAllowed();
|
|
@@ -5345,22 +5450,22 @@ class AdvisorSessionState {
|
|
|
5345
5450
|
const gates = invocations.filter((item) => item.kind === "gate");
|
|
5346
5451
|
const effects = (effect) => invocations.filter((item) => item.executionEffect === effect).length;
|
|
5347
5452
|
const failures = invocations.filter((item) => item.failure).map((item) => item.failure);
|
|
5348
|
-
const models = [...new Set(invocations.map((item) => item.model).filter(Boolean))].join(", ") || "unknown";
|
|
5349
|
-
const budget = limit === undefined ? `${this.#consumedCalls} used; unlimited remaining` : `${this.#consumedCalls} / ${limit} used; ${Math.max(0, limit - this.#consumedCalls)} remaining`;
|
|
5453
|
+
const models = [...new Set(invocations.map((item) => item.model).filter(Boolean))].join(", ") || t("sessionSummary.models.unknown", "unknown");
|
|
5454
|
+
const budget = limit === undefined ? `${this.#consumedCalls} ${t("sessionSummary.budget.used", "used")}; ${t("sessionSummary.budget.unlimitedRemaining", "unlimited remaining")}` : `${this.#consumedCalls} / ${limit} ${t("sessionSummary.budget.used", "used")}; ${Math.max(0, limit - this.#consumedCalls)} ${t("sessionSummary.budget.remaining", "remaining")}`;
|
|
5350
5455
|
return [
|
|
5351
|
-
"[Session Advisor Summary]",
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5456
|
+
t("sessionSummary.title", "[Session Advisor Summary]"),
|
|
5457
|
+
`${t("sessionSummary.consultations.label", "Consultations:")} ${markdown.length} ${t("sessionSummary.consultations.markdown", "Markdown")} (${this.#countTrigger("manual")} ${t("sessionSummary.consultations.manual", "manual")}, ${this.#countTrigger("executor-requested")} ${t("sessionSummary.consultations.executorRequested", "executor-requested")}), ${t("sessionSummary.consultations.automaticGates", "automatic gates:")} ${gates.length}`,
|
|
5458
|
+
`${t("sessionSummary.triggers.label", "Triggers:")} ${this.#triggersLine()}`,
|
|
5459
|
+
`${t("sessionSummary.models.label", "Models:")} ${models}`,
|
|
5460
|
+
`${t("sessionSummary.budget.label", "Budget:")} ${budget}`,
|
|
5461
|
+
`${t("sessionSummary.usage.label", "Usage:")} ${formatAdvisorUsageTotals(totals)}`,
|
|
5462
|
+
`${t("sessionSummary.markdownAdvice.label", "Markdown advice:")} ${markdown.length} ${t("sessionSummary.markdownAdvice.responses", "responses")} (${this.#ledger.draftConsultations} ${t("sessionSummary.markdownAdvice.withDrafts", "with drafts")})`,
|
|
5463
|
+
`${t("sessionSummary.followUps.label", "Follow-ups:")} ${markdown.filter((item) => item.followUp).length}`,
|
|
5464
|
+
`${t("sessionSummary.outcomeReports.label", "Outcome reports:")} ${this.#ledger.outcomes}`,
|
|
5465
|
+
`${t("sessionSummary.gateDecisions.label", "Gate decisions:")} ${this.#decisionsLine()}`,
|
|
5466
|
+
`${t("sessionSummary.loopMatching.label", "Loop matching: normalized tool signatures;")} ${this.#repetition.interventions} ${t("sessionSummary.loopMatching.gateIntervention", "gate intervention")}${this.#repetition.interventions === 1 ? "" : "s"}`,
|
|
5467
|
+
`${t("sessionSummary.executionEffects.label", "Execution effects:")} ${effects("tool-blocked")} ${t("sessionSummary.executionEffects.toolBlocked", "tool blocked")}, ${effects("session-blocked")} ${t("sessionSummary.executionEffects.sessionsBlocked", "sessions blocked")}, ${effects("continued")} ${t("sessionSummary.executionEffects.continued", "continued")}`,
|
|
5468
|
+
`${t("sessionSummary.failures.label", "Failures:")} ${failures.length ? failures.join(", ") : t("sessionSummary.none", "none")}`,
|
|
5364
5469
|
...jevLines
|
|
5365
5470
|
].join(`
|
|
5366
5471
|
`);
|
|
@@ -5385,9 +5490,8 @@ var notify = (ctx, message, level) => {
|
|
|
5385
5490
|
uiAction(ctx, (ui) => ui.notify(message, level));
|
|
5386
5491
|
};
|
|
5387
5492
|
var reportManualBudgetExhausted = (ctx) => {
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
notifyHerdrAdvisorFailure("Advisor budget exhausted", message);
|
|
5493
|
+
notify(ctx, t("notify.budgetExhausted.message", "Advisor call budget exhausted for this session."), "warning");
|
|
5494
|
+
notifyHerdrAdvisorFailure("Advisor budget exhausted", "Advisor call budget exhausted for this session.");
|
|
5391
5495
|
};
|
|
5392
5496
|
var requestManualRender = (ctx) => {
|
|
5393
5497
|
uiAction(ctx, (ui) => ui.setStatus("advisor-manual", undefined));
|
|
@@ -5433,7 +5537,7 @@ class CommandRuntime {
|
|
|
5433
5537
|
if (disabled && this.lastSameModelDisabled !== true) {
|
|
5434
5538
|
notify(ctx, sameModelAdvisorNotice, "info");
|
|
5435
5539
|
} else if (!disabled && this.lastSameModelDisabled === true) {
|
|
5436
|
-
notify(ctx, "Advisor re-enabled: executor and advisor models differ.", "info");
|
|
5540
|
+
notify(ctx, t("notify.sameModelReenabled.message", "Advisor re-enabled: executor and advisor models differ."), "info");
|
|
5437
5541
|
}
|
|
5438
5542
|
this.lastSameModelDisabled = disabled;
|
|
5439
5543
|
}
|
|
@@ -5462,7 +5566,7 @@ var loadCommandConfig = (ctx) => {
|
|
|
5462
5566
|
return true;
|
|
5463
5567
|
} catch (error) {
|
|
5464
5568
|
const message = error instanceof Error ? error.message : String(error);
|
|
5465
|
-
notify(ctx,
|
|
5569
|
+
notify(ctx, `${t("notify.configLoadFailed.prefix", "Advisor command could not load configuration:")} ${message} ${t("notify.configLoadFailed.suffix", "Fix advisor.json and retry.")}`, "error");
|
|
5466
5570
|
return false;
|
|
5467
5571
|
}
|
|
5468
5572
|
};
|
|
@@ -5481,7 +5585,7 @@ var prepareActivationModels = async (runtime, ctx, announce, executorOverride, a
|
|
|
5481
5585
|
return { pendingExecutor: plan.pendingExecutor, pickedModels: false };
|
|
5482
5586
|
}
|
|
5483
5587
|
if (!announce) {
|
|
5484
|
-
notify(ctx, "Advisor models are not configured or available. Run /advisor to choose them.", "error");
|
|
5588
|
+
notify(ctx, t("notify.modelsNotConfigured.message", "Advisor models are not configured or available. Run /advisor to choose them."), "error");
|
|
5485
5589
|
return;
|
|
5486
5590
|
}
|
|
5487
5591
|
const selection = await selectAdvisorModels(ctx, {
|
|
@@ -5528,12 +5632,14 @@ var resolveActivationModels = async (runtime, ctx, canContinue) => {
|
|
|
5528
5632
|
}
|
|
5529
5633
|
const executor = executorRef ? findConfiguredModel(ctx, executorRef) : undefined;
|
|
5530
5634
|
if (executorRef && !executor) {
|
|
5531
|
-
return {
|
|
5635
|
+
return {
|
|
5636
|
+
error: `${t("activation.executorNotFound.prefix", "Executor model not found:")} ${executorRef}`
|
|
5637
|
+
};
|
|
5532
5638
|
}
|
|
5533
5639
|
const advisor = findConfiguredModel(ctx, advisorRef);
|
|
5534
5640
|
if (!advisor) {
|
|
5535
5641
|
return {
|
|
5536
|
-
error: advisorRef ?
|
|
5642
|
+
error: advisorRef ? `${t("activation.advisorNotFound.prefix", "Advisor model not found:")} ${advisorRef}` : t("activation.advisorNotConfigured", "Advisor model not configured")
|
|
5537
5643
|
};
|
|
5538
5644
|
}
|
|
5539
5645
|
if (advisor.api !== "pi-virtual") {
|
|
@@ -5542,11 +5648,15 @@ var resolveActivationModels = async (runtime, ctx, canContinue) => {
|
|
|
5542
5648
|
return { cancelled: true };
|
|
5543
5649
|
}
|
|
5544
5650
|
if (!(advisorAuth.ok && hasUsableModelAuth(advisorAuth))) {
|
|
5545
|
-
return {
|
|
5651
|
+
return {
|
|
5652
|
+
error: `${t("activation.noAdvisorApiKey.prefix", "No API key for Advisor")} ${advisorRef}`
|
|
5653
|
+
};
|
|
5546
5654
|
}
|
|
5547
5655
|
}
|
|
5548
5656
|
if (executor && !isMarkedSubagent() && !await runtime.setExecutorModel(executor)) {
|
|
5549
|
-
return {
|
|
5657
|
+
return {
|
|
5658
|
+
error: `${t("activation.noExecutorApiKey.prefix", "No API key for Executor")} ${executorRef}`
|
|
5659
|
+
};
|
|
5550
5660
|
}
|
|
5551
5661
|
return {};
|
|
5552
5662
|
};
|
|
@@ -5575,7 +5685,7 @@ var persistSuccessfulActivation = (ctx, shouldSave, reenableTools, restoreRefs)
|
|
|
5575
5685
|
setAdvisorToolsEnabledRef(false);
|
|
5576
5686
|
restoreRefs();
|
|
5577
5687
|
const message = saveError instanceof Error ? saveError.message : String(saveError);
|
|
5578
|
-
notify(ctx,
|
|
5688
|
+
notify(ctx, `${t("activation.saveFailed.prefix", "Could not save Advisor activation:")} ${message}`, "error");
|
|
5579
5689
|
return false;
|
|
5580
5690
|
}
|
|
5581
5691
|
return true;
|
|
@@ -5654,39 +5764,545 @@ var activateAdvisor = async (runtime, args, ctx, announce = true) => {
|
|
|
5654
5764
|
if (announce) {
|
|
5655
5765
|
const activeExecutorRef = effectiveExecutorRef(ctx);
|
|
5656
5766
|
const activeExecutorEffort = effectiveExecutorEffort(ctx);
|
|
5657
|
-
notify(ctx, `${
|
|
5767
|
+
notify(ctx, `${t("activation.explanation", "The Advisor is a second-opinion model that reviews the Executor's context and returns risks, alternatives, and verification steps without changing files or running tools.")}
|
|
5658
5768
|
|
|
5659
|
-
Advisor flow ${sameModelAdvisorDisabled(ctx, activeModel) ? "configured" : "ready"} — Executor: ${activeExecutorRef} (thinking: ${activeExecutorEffort || "default"}) · Advisor: ${advisorRef} (thinking: ${advisorEffortRef || "default"})`, "info");
|
|
5769
|
+
${t("activation.flow", "Advisor flow")} ${sameModelAdvisorDisabled(ctx, activeModel) ? t("activation.flowConfigured", "configured") : t("activation.flowReady", "ready")} — Executor: ${activeExecutorRef} (thinking: ${activeExecutorEffort || "default"}) · Advisor: ${advisorRef} (thinking: ${advisorEffortRef || "default"})`, "info");
|
|
5660
5770
|
}
|
|
5661
5771
|
};
|
|
5662
5772
|
|
|
5663
|
-
// src/commands/
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5773
|
+
// src/commands/configuration-tool.ts
|
|
5774
|
+
import { Text as Text3 } from "@earendil-works/pi-tui";
|
|
5775
|
+
import { Type } from "typebox";
|
|
5776
|
+
|
|
5777
|
+
// src/commands/configuration-tool-policy.ts
|
|
5778
|
+
var UI_ONLY_KEYS = new Set([
|
|
5779
|
+
"advisorJevBaseUrl",
|
|
5780
|
+
"advisorJevClassifier",
|
|
5781
|
+
"advisorJevKeyProvider",
|
|
5782
|
+
"advisorJevModel",
|
|
5783
|
+
"advisorJevPricePerMtok",
|
|
5784
|
+
"advisorJevTransport"
|
|
5785
|
+
]);
|
|
5786
|
+
var WRITABLE_KEYS = new Set(configKeys.filter((key) => !UI_ONLY_KEYS.has(key)));
|
|
5787
|
+
var ADVISOR_CONFIG_EFFORT_LEVELS = [
|
|
5788
|
+
"off",
|
|
5789
|
+
"minimal",
|
|
5790
|
+
"low",
|
|
5791
|
+
"medium",
|
|
5792
|
+
"high",
|
|
5793
|
+
"xhigh",
|
|
5794
|
+
"max"
|
|
5795
|
+
];
|
|
5796
|
+
var ADVISOR_CONFIG_WRITABLE_KEYS = configKeys.filter((key) => !UI_ONLY_KEYS.has(key));
|
|
5797
|
+
var getAdvisorConfigSnapshot = () => {
|
|
5798
|
+
const snapshot = Object.fromEntries(configKeys.map((key) => [key, CONFIG_SCHEMA[key].current()]));
|
|
5799
|
+
return snapshot;
|
|
5800
|
+
};
|
|
5801
|
+
var getAdvisorConfigForAgent = (persisted) => {
|
|
5802
|
+
const snapshot = getAdvisorConfigSnapshot();
|
|
5803
|
+
const keys = configKeys.filter((key) => !UI_ONLY_KEYS.has(key));
|
|
5804
|
+
const effectiveSettings = Object.fromEntries(keys.map((key) => [key, snapshot[key] ?? null]));
|
|
5805
|
+
const globalOverrides = Object.fromEntries(keys.filter((key) => Object.hasOwn(persisted, key)).map((key) => [key, persisted[key]]));
|
|
5806
|
+
return {
|
|
5807
|
+
effectiveSettings,
|
|
5808
|
+
globalOverrides,
|
|
5809
|
+
jevClassifierConfigured: Boolean(persisted.advisorJevClassifier),
|
|
5810
|
+
readOnlyKeys: [...UI_ONLY_KEYS].toSorted(),
|
|
5811
|
+
writableKeys: [...ADVISOR_CONFIG_WRITABLE_KEYS].toSorted()
|
|
5812
|
+
};
|
|
5813
|
+
};
|
|
5814
|
+
var validateAdvisorConfigPatch = (value, jevClassifierConfigured) => {
|
|
5815
|
+
if (!isRecord(value)) {
|
|
5816
|
+
return false;
|
|
5817
|
+
}
|
|
5818
|
+
const keys = Object.keys(value);
|
|
5819
|
+
if (keys.length === 0) {
|
|
5820
|
+
throw new TypeError("Provide at least one Advisor setting to update.");
|
|
5821
|
+
}
|
|
5822
|
+
if (keys.length > 16) {
|
|
5823
|
+
throw new TypeError("Update at most 16 Advisor settings at a time.");
|
|
5824
|
+
}
|
|
5825
|
+
const unsupported = keys.filter((key) => !WRITABLE_KEYS.has(key));
|
|
5826
|
+
if (unsupported.length > 0) {
|
|
5827
|
+
throw new TypeError(`These Advisor settings require their dedicated UI flow: ${unsupported.map((key) => JSON.stringify(key)).join(", ")}. Use /advisor-settings for classifier and credential setup.`);
|
|
5828
|
+
}
|
|
5829
|
+
const setValues = {};
|
|
5830
|
+
for (const [key, setting] of Object.entries(value)) {
|
|
5831
|
+
if (setting !== null) {
|
|
5832
|
+
setValues[key] = setting;
|
|
5833
|
+
}
|
|
5834
|
+
}
|
|
5835
|
+
if (!validateConfig(setValues, "advisor_config changes")) {
|
|
5836
|
+
return false;
|
|
5837
|
+
}
|
|
5838
|
+
const effortLevels = ADVISOR_CONFIG_EFFORT_LEVELS;
|
|
5839
|
+
for (const key of ["advisorEffort", "executorEffort"]) {
|
|
5840
|
+
const effort = setValues[key];
|
|
5841
|
+
if (isString(effort) && !effortLevels.includes(effort)) {
|
|
5842
|
+
throw new TypeError(`${key} must be one of ${ADVISOR_CONFIG_EFFORT_LEVELS.join(", ")}; use null for the model default.`);
|
|
5843
|
+
}
|
|
5844
|
+
}
|
|
5845
|
+
if (value.advisor === null) {
|
|
5846
|
+
throw new TypeError("The Advisor model cannot be cleared from chat. Choose another model with the picker or use /advisor-models.");
|
|
5847
|
+
}
|
|
5848
|
+
const turnGateEveryTurns = isNumber(setValues.advisorJevTurnGateEveryTurns) ? setValues.advisorJevTurnGateEveryTurns : 0;
|
|
5849
|
+
if ((setValues.advisorJevFilterEnabled === true || turnGateEveryTurns > 0) && !jevClassifierConfigured) {
|
|
5850
|
+
throw new TypeError("Select and verify a Jev classifier in /advisor-settings before enabling Jev screening or the turn gate. No settings were changed.");
|
|
5851
|
+
}
|
|
5852
|
+
return true;
|
|
5853
|
+
};
|
|
5854
|
+
var addAdvisorConfigDependencies = (changes) => {
|
|
5855
|
+
const normalized = { ...changes };
|
|
5856
|
+
if (changes.advisorToolsEnabled === false) {
|
|
5857
|
+
if (changes.alwaysOn === true) {
|
|
5858
|
+
throw new TypeError("Advisor tools cannot be disabled while Always on is enabled in the same update. Set both to false.");
|
|
5859
|
+
}
|
|
5860
|
+
normalized.alwaysOn = false;
|
|
5861
|
+
}
|
|
5862
|
+
if (changes.alwaysOn === true) {
|
|
5863
|
+
if (changes.advisorToolsEnabled === false) {
|
|
5864
|
+
throw new TypeError("Always on requires Advisor tools. Enable both or keep Always on off.");
|
|
5865
|
+
}
|
|
5866
|
+
normalized.advisorToolsEnabled = true;
|
|
5867
|
+
}
|
|
5868
|
+
return normalized;
|
|
5869
|
+
};
|
|
5870
|
+
|
|
5871
|
+
// src/commands/configuration-tool-preview.ts
|
|
5872
|
+
var sameConfigValue2 = (left, right) => JSON.stringify(left) === JSON.stringify(right);
|
|
5873
|
+
var orderedPatchEntries = (patch) => configKeys.filter((key) => Object.hasOwn(patch, key)).map((key) => [key, patch[key]]);
|
|
5874
|
+
var sameConfigPatch = (left, right) => JSON.stringify(orderedPatchEntries(left)) === JSON.stringify(orderedPatchEntries(right));
|
|
5875
|
+
var effectiveChanges = (changes, persisted) => {
|
|
5876
|
+
const entries = [];
|
|
5877
|
+
for (const key of configKeys) {
|
|
5878
|
+
const value = changes[key];
|
|
5879
|
+
if (value === undefined) {
|
|
5880
|
+
continue;
|
|
5881
|
+
}
|
|
5882
|
+
if (value === null) {
|
|
5883
|
+
if (Object.hasOwn(persisted, key)) {
|
|
5884
|
+
entries.push([key, null]);
|
|
5885
|
+
}
|
|
5886
|
+
continue;
|
|
5887
|
+
}
|
|
5888
|
+
if (!sameConfigValue2(value, persisted[key] ?? null)) {
|
|
5889
|
+
entries.push([key, value]);
|
|
5890
|
+
}
|
|
5891
|
+
}
|
|
5892
|
+
return Object.fromEntries(entries);
|
|
5893
|
+
};
|
|
5894
|
+
var staleCheckKeys = (changes) => {
|
|
5895
|
+
const keys = new Set(configKeys.filter((key) => Object.hasOwn(changes, key)));
|
|
5896
|
+
if (keys.has("advisorToolsEnabled") || keys.has("alwaysOn")) {
|
|
5897
|
+
keys.add("advisorToolsEnabled");
|
|
5898
|
+
keys.add("alwaysOn");
|
|
5899
|
+
}
|
|
5900
|
+
if (keys.has("advisorJevFilterEnabled") || keys.has("advisorJevTurnGateEveryTurns")) {
|
|
5901
|
+
keys.add("advisorJevClassifier");
|
|
5902
|
+
}
|
|
5903
|
+
return [...keys];
|
|
5904
|
+
};
|
|
5905
|
+
var summarizeAdvisorConfigPatch = (changes, before, persisted) => configKeys.filter((key) => Object.hasOwn(changes, key)).map((key) => {
|
|
5906
|
+
const value = changes[key];
|
|
5907
|
+
const previous = Object.hasOwn(persisted, key) ? JSON.stringify(persisted[key]) : `unset (extension default; current session ${JSON.stringify(before[key] ?? null)})`;
|
|
5908
|
+
const next = value === null ? "reset to extension default" : JSON.stringify(value);
|
|
5909
|
+
return `- ${key}: ${previous} → ${next}`;
|
|
5910
|
+
}).join(`
|
|
5911
|
+
`);
|
|
5912
|
+
var automationRiskNotes = (changes, before) => {
|
|
5913
|
+
const notes = [];
|
|
5914
|
+
if (changes.simpleMode === true) {
|
|
5915
|
+
notes.push("Simple mode disables automatic gates, gate blocking, and configured call budgets; voluntary Advisor calls remain available.");
|
|
5916
|
+
}
|
|
5917
|
+
if (changes.advisorToolsEnabled === false) {
|
|
5918
|
+
notes.push("Advisor tools will be disabled immediately. advisor_config remains available to re-enable them.");
|
|
5919
|
+
}
|
|
5920
|
+
if (changes.alwaysOn === true) {
|
|
5921
|
+
notes.push("Always on enables automatic activation for future sessions.");
|
|
5922
|
+
}
|
|
5923
|
+
if (changes.advisorPlanGate === true || changes.advisorFailureGate === true || changes.advisorCompletionGate === true || changes.advisorAutoLoopGate === true) {
|
|
5924
|
+
notes.push("Automatic gates may request extra Advisor calls; loop-gate failures can block a tool or session under the selected failure policy.");
|
|
5925
|
+
}
|
|
5926
|
+
if (changes.gateFailureMode === "block-session" || changes.advisorBlockOnBlocked === true) {
|
|
5927
|
+
notes.push("A blocked gate may stop the current session.");
|
|
5928
|
+
}
|
|
5929
|
+
if (changes.advisorToolsEnabled === true) {
|
|
5930
|
+
notes.push(before.alwaysOn === true || changes.alwaysOn === true ? "Advisor tools become available, and saved Always on will activate the flow in future sessions." : "Advisor tools become available; this does not activate Always on.");
|
|
5931
|
+
}
|
|
5932
|
+
return notes;
|
|
5933
|
+
};
|
|
5934
|
+
var disclosureRiskNotes = (changes) => {
|
|
5935
|
+
const notes = [];
|
|
5936
|
+
if (changes.advisorGitContext === "full") {
|
|
5937
|
+
notes.push("Future Advisor requests may include repository patch contents.");
|
|
5938
|
+
}
|
|
5939
|
+
if (changes.advisorTrackedFileContent === true) {
|
|
5940
|
+
notes.push("This enables explicitly requested tracked file contents to be sent to the Advisor.");
|
|
5941
|
+
}
|
|
5942
|
+
if (changes.advisorUntrackedContent === true) {
|
|
5943
|
+
notes.push("This enables explicitly requested untracked file contents to be sent to the Advisor.");
|
|
5944
|
+
}
|
|
5945
|
+
if (changes.advisorAgentsMdContext === true) {
|
|
5946
|
+
notes.push("Trusted AGENTS.md instructions may be included in Advisor requests.");
|
|
5947
|
+
}
|
|
5948
|
+
if (changes.advisorToolPolicies && Object.values(changes.advisorToolPolicies).includes("full")) {
|
|
5949
|
+
notes.push("Tools set to full may send their arguments and result content to the Advisor.");
|
|
5950
|
+
}
|
|
5951
|
+
if (changes.advisorRedactSecrets === false) {
|
|
5952
|
+
notes.push("Credential-pattern redaction will be off for Advisor requests.");
|
|
5953
|
+
}
|
|
5954
|
+
return notes;
|
|
5955
|
+
};
|
|
5956
|
+
var costRiskNotes = (changes) => {
|
|
5957
|
+
const notes = [];
|
|
5958
|
+
if (changes.advisorOutcomeLogging === true) {
|
|
5959
|
+
notes.push("Outcome logging stores bounded adoption and validation metadata in the local ledger.");
|
|
5960
|
+
}
|
|
5961
|
+
if (changes.advisorMaxCallsPerSession === null) {
|
|
5962
|
+
notes.push("This removes the per-session Advisor call limit; calls may be unlimited.");
|
|
5963
|
+
}
|
|
5964
|
+
if ((changes.advisorJevTurnGateEveryTurns ?? 0) > 0) {
|
|
5965
|
+
notes.push("The Jev turn gate can initiate proactive Advisor calls and add cost.");
|
|
5966
|
+
}
|
|
5967
|
+
return notes;
|
|
5968
|
+
};
|
|
5969
|
+
var advisorConfigRiskNotes = (changes, before, persisted) => [
|
|
5970
|
+
...automationRiskNotes(changes, {
|
|
5971
|
+
...before,
|
|
5972
|
+
alwaysOn: Object.hasOwn(persisted, "alwaysOn") ? persisted.alwaysOn === true : before.alwaysOn
|
|
5973
|
+
}),
|
|
5974
|
+
...disclosureRiskNotes(changes),
|
|
5975
|
+
...costRiskNotes(changes)
|
|
5976
|
+
];
|
|
5977
|
+
|
|
5978
|
+
// src/commands/configuration-tool-models.ts
|
|
5979
|
+
var MODEL_KEYS = [
|
|
5980
|
+
"advisor",
|
|
5981
|
+
"advisorEffort",
|
|
5982
|
+
"advisorFallbackModel",
|
|
5983
|
+
"executor",
|
|
5984
|
+
"executorEffort"
|
|
5985
|
+
];
|
|
5986
|
+
var MODEL_REF_KEYS = [
|
|
5987
|
+
"advisor",
|
|
5988
|
+
"advisorFallbackModel",
|
|
5989
|
+
"executor"
|
|
5990
|
+
];
|
|
5991
|
+
var isModelChange = (changes) => MODEL_KEYS.some((key) => Object.hasOwn(changes, key));
|
|
5992
|
+
var validateRequestedModels = (changes, modelRefs) => {
|
|
5993
|
+
for (const key of MODEL_REF_KEYS) {
|
|
5994
|
+
const requested = changes[key];
|
|
5995
|
+
if (requested !== null && requested !== undefined && !modelRefs.includes(requested)) {
|
|
5996
|
+
throw new Error(`${key} must name an available provider/model. Choose it from /advisor-models or use the model picker opened by advisor_config.`);
|
|
5997
|
+
}
|
|
5998
|
+
}
|
|
5999
|
+
};
|
|
6000
|
+
var pickerOptions = (changes, before) => ({
|
|
6001
|
+
advisor: changes.advisor ?? before.advisor,
|
|
6002
|
+
advisorEffort: changes.advisorEffort === null ? undefined : changes.advisorEffort ?? before.advisorEffort,
|
|
6003
|
+
advisorFallbackModel: changes.advisorFallbackModel === null ? undefined : changes.advisorFallbackModel ?? before.advisorFallbackModel,
|
|
6004
|
+
executor: changes.executor === null ? "" : changes.executor ?? before.executor,
|
|
6005
|
+
executorEffort: changes.executorEffort === null ? undefined : changes.executorEffort ?? before.executorEffort,
|
|
6006
|
+
selectAdvisor: Object.hasOwn(changes, "advisor") || Object.hasOwn(changes, "advisorEffort") || !before.advisor,
|
|
6007
|
+
selectExecutor: Object.hasOwn(changes, "executor") || Object.hasOwn(changes, "executorEffort")
|
|
6008
|
+
});
|
|
6009
|
+
var selectedModelChanges = (changes, selection, persisted) => {
|
|
6010
|
+
const selected = {
|
|
6011
|
+
advisor: selection.advisor,
|
|
6012
|
+
advisorEffort: selection.advisorEffort ?? null,
|
|
6013
|
+
advisorFallbackModel: selection.advisorFallbackModel ?? null,
|
|
6014
|
+
executor: selection.executor || null,
|
|
6015
|
+
executorEffort: selection.executorEffort ?? null
|
|
6016
|
+
};
|
|
6017
|
+
const resolved = {};
|
|
6018
|
+
for (const key of MODEL_KEYS) {
|
|
6019
|
+
const persistedValue = persisted[key] ?? null;
|
|
6020
|
+
if (!sameConfigValue2(selected[key], persistedValue)) {
|
|
6021
|
+
resolved[key] = selected[key];
|
|
6022
|
+
}
|
|
6023
|
+
}
|
|
6024
|
+
const {
|
|
6025
|
+
advisor: _requestedAdvisor,
|
|
6026
|
+
advisorEffort: _requestedAdvisorEffort,
|
|
6027
|
+
advisorFallbackModel: _requestedFallback,
|
|
6028
|
+
executor: _requestedExecutor,
|
|
6029
|
+
executorEffort: _requestedExecutorEffort,
|
|
6030
|
+
...otherChanges
|
|
6031
|
+
} = changes;
|
|
6032
|
+
return { ...otherChanges, ...resolved };
|
|
6033
|
+
};
|
|
6034
|
+
var resolveModelChanges = async (ctx, changes, before, persisted, selectModels = selectAdvisorModels) => {
|
|
6035
|
+
if (!isModelChange(changes)) {
|
|
6036
|
+
return changes;
|
|
6037
|
+
}
|
|
6038
|
+
if (ctx.mode !== "tui") {
|
|
6039
|
+
throw new Error("Model changes require Pi's interactive TUI so you can choose from the existing model picker. No settings were changed.");
|
|
6040
|
+
}
|
|
6041
|
+
validateRequestedModels(changes, getConfiguredModelRefs(ctx));
|
|
6042
|
+
const selection = await selectModels(ctx, pickerOptions(changes, before));
|
|
6043
|
+
if (!selection) {
|
|
6044
|
+
return;
|
|
6045
|
+
}
|
|
6046
|
+
return selectedModelChanges(changes, selection, persisted);
|
|
6047
|
+
};
|
|
6048
|
+
|
|
6049
|
+
// src/commands/configuration-tool-runtime.ts
|
|
6050
|
+
var applyAdvisorConfigRuntimeSettings = (runtime, ctx, previous) => {
|
|
6051
|
+
const next = getAdvisorSettings();
|
|
6052
|
+
const shouldEnable = next.advisorToolsEnabled ?? true;
|
|
6053
|
+
const toolsAreActive = runtime.pi.getActiveTools().includes("ask_advisor");
|
|
6054
|
+
if (previous.advisorToolsEnabled !== next.advisorToolsEnabled || toolsAreActive !== shouldEnable) {
|
|
6055
|
+
runtime.noteAdvisorToolsStateChange();
|
|
6056
|
+
setAdvisorToolsActive(runtime.pi, shouldEnable);
|
|
6057
|
+
if (!shouldEnable) {
|
|
6058
|
+
runtime.resetSameModelNotice();
|
|
6059
|
+
}
|
|
6060
|
+
}
|
|
6061
|
+
runtime.updateSameModelNotice(ctx);
|
|
6062
|
+
runtime.updateAdvisorUsageStatus(ctx);
|
|
6063
|
+
};
|
|
6064
|
+
var cancelledAdvisorConfigResult = (message) => ({
|
|
6065
|
+
content: [{ text: message, type: "text" }],
|
|
6066
|
+
details: { action: "update", applied: false, cancelled: true }
|
|
6067
|
+
});
|
|
6068
|
+
var unchangedAdvisorConfigResult = (message) => ({
|
|
6069
|
+
content: [{ text: message, type: "text" }],
|
|
6070
|
+
details: { action: "update", applied: false, unchanged: true }
|
|
6071
|
+
});
|
|
6072
|
+
|
|
6073
|
+
// src/commands/configuration-tool-transaction.ts
|
|
6074
|
+
import { withFileMutationQueue } from "@earendil-works/pi-coding-agent";
|
|
6075
|
+
var confirmAdvisorConfigUpdate = async (ctx, prepared, signal) => {
|
|
6076
|
+
const preview = summarizeAdvisorConfigPatch(prepared.proposed, prepared.before, prepared.existing);
|
|
6077
|
+
const risks = advisorConfigRiskNotes(prepared.proposed, prepared.before, prepared.existing);
|
|
6078
|
+
const confirmation = [
|
|
6079
|
+
"These changes apply to global Advisor settings, not a project config:",
|
|
6080
|
+
preview,
|
|
6081
|
+
...risks.map((risk) => `
|
|
6082
|
+
Risk: ${risk}`)
|
|
6083
|
+
].join(`
|
|
6084
|
+
`);
|
|
6085
|
+
const confirmed = await ctx.ui.confirm("Apply Advisor settings?", confirmation, { signal });
|
|
6086
|
+
return confirmed && !signal?.aborted;
|
|
6087
|
+
};
|
|
6088
|
+
var persistAdvisorConfigUpdate = (prepared, signal) => {
|
|
6089
|
+
const touched = staleCheckKeys(prepared.proposed);
|
|
6090
|
+
return withFileMutationQueue(prepared.configPath, () => Promise.resolve().then(() => {
|
|
6091
|
+
if (signal?.aborted) {
|
|
6092
|
+
throw new Error("Update cancelled before writing; no settings changed.");
|
|
6093
|
+
}
|
|
6094
|
+
const latest = readGlobalAdvisorConfig();
|
|
6095
|
+
const stale = touched.filter((key) => Object.hasOwn(latest, key) !== Object.hasOwn(prepared.existing, key) || !sameConfigValue2(latest[key] ?? null, prepared.existing[key] ?? null));
|
|
6096
|
+
if (stale.length > 0) {
|
|
6097
|
+
throw new Error(`Advisor settings changed while confirmation was open (${stale.join(", ")}). Read the settings again and retry; nothing was written.`);
|
|
6098
|
+
}
|
|
6099
|
+
const refreshed = effectiveChanges(addAdvisorConfigDependencies(prepared.proposed), latest);
|
|
6100
|
+
if (!sameConfigPatch(refreshed, prepared.proposed)) {
|
|
6101
|
+
throw new Error("Advisor setting dependencies changed while confirmation was open. Read the settings again and retry; nothing was written.");
|
|
6102
|
+
}
|
|
6103
|
+
if (Object.hasOwn(refreshed, "advisorOutcomeLogging")) {
|
|
6104
|
+
saveGlobalOutcomeLogging(refreshed.advisorOutcomeLogging === null ? null : refreshed.advisorOutcomeLogging === true, prepared.existing, touched);
|
|
6105
|
+
} else {
|
|
6106
|
+
saveGlobalAdvisorConfigPatch(refreshed, prepared.existing, touched);
|
|
6107
|
+
}
|
|
6108
|
+
return prepared.configPath;
|
|
6109
|
+
}));
|
|
6110
|
+
};
|
|
6111
|
+
|
|
6112
|
+
// src/commands/configuration-tool-update.ts
|
|
6113
|
+
var prepareAdvisorConfigUpdate = async (ctx, input, selectModels) => {
|
|
6114
|
+
const existing = readGlobalAdvisorConfig();
|
|
6115
|
+
const before = getAdvisorConfigSnapshot();
|
|
6116
|
+
const beforeSettings = getAdvisorSettings();
|
|
6117
|
+
const [, configPath] = configPaths(ctx);
|
|
6118
|
+
if (!configPath) {
|
|
6119
|
+
throw new Error("Could not resolve the global Advisor configuration path.");
|
|
6120
|
+
}
|
|
6121
|
+
if (input === undefined) {
|
|
6122
|
+
throw new TypeError("Provide Advisor settings changes for action=update.");
|
|
6123
|
+
}
|
|
6124
|
+
if (!validateAdvisorConfigPatch(input, Boolean(existing.advisorJevClassifier))) {
|
|
6125
|
+
throw new TypeError("Advisor settings changes must be a JSON object.");
|
|
6126
|
+
}
|
|
6127
|
+
const initialChanges = input;
|
|
6128
|
+
if (Object.hasOwn(initialChanges, "advisorOutcomeLogging") && Object.keys(initialChanges).length > 1) {
|
|
6129
|
+
throw new Error("Update advisorOutcomeLogging by itself so its separate consent path remains clear.");
|
|
6130
|
+
}
|
|
6131
|
+
const changesWithModels = await resolveModelChanges(ctx, initialChanges, before, existing, selectModels);
|
|
6132
|
+
if (!changesWithModels) {
|
|
6133
|
+
return;
|
|
6134
|
+
}
|
|
6135
|
+
const changes = addAdvisorConfigDependencies(changesWithModels);
|
|
6136
|
+
return {
|
|
6137
|
+
before,
|
|
6138
|
+
beforeSettings,
|
|
6139
|
+
configPath,
|
|
6140
|
+
existing,
|
|
6141
|
+
proposed: effectiveChanges(changes, existing)
|
|
6142
|
+
};
|
|
6143
|
+
};
|
|
6144
|
+
var appliedAdvisorConfigResult = (prepared, savedPath) => {
|
|
6145
|
+
const notices = [];
|
|
6146
|
+
if (Object.hasOwn(prepared.proposed, "alwaysOn") && prepared.proposed.alwaysOn === true) {
|
|
6147
|
+
notices.push("Always on applies to future sessions; this did not start an Advisor call.");
|
|
6148
|
+
}
|
|
6149
|
+
if (Object.hasOwn(prepared.proposed, "executor")) {
|
|
6150
|
+
notices.push(prepared.proposed.executor === null ? "The Executor pin was removed; it now follows the current Pi session model." : "Executor model selection is saved; run /advisor to activate it in this session.");
|
|
6151
|
+
}
|
|
6152
|
+
return {
|
|
6153
|
+
content: [
|
|
6154
|
+
{
|
|
6155
|
+
text: [
|
|
6156
|
+
`Saved Advisor settings to ${savedPath}.`,
|
|
6157
|
+
summarizeAdvisorConfigPatch(prepared.proposed, prepared.before, prepared.existing),
|
|
6158
|
+
...notices
|
|
6159
|
+
].join(`
|
|
6160
|
+
`),
|
|
6161
|
+
type: "text"
|
|
6162
|
+
}
|
|
6163
|
+
],
|
|
6164
|
+
details: {
|
|
6165
|
+
action: "update",
|
|
6166
|
+
applied: true,
|
|
6167
|
+
changes: prepared.proposed,
|
|
6168
|
+
saved: true
|
|
6169
|
+
}
|
|
6170
|
+
};
|
|
6171
|
+
};
|
|
6172
|
+
var savedButNotAppliedResult = (prepared, savedPath, message) => ({
|
|
6173
|
+
content: [
|
|
6174
|
+
{
|
|
6175
|
+
text: `Advisor settings were saved to ${savedPath}, but could not be fully applied to the current session: ${message}`,
|
|
6176
|
+
type: "text"
|
|
6177
|
+
}
|
|
6178
|
+
],
|
|
6179
|
+
details: {
|
|
6180
|
+
action: "update",
|
|
6181
|
+
applied: false,
|
|
6182
|
+
changes: prepared.proposed,
|
|
6183
|
+
saved: true
|
|
6184
|
+
}
|
|
6185
|
+
});
|
|
6186
|
+
var applyAdvisorConfigUpdate = (runtime, ctx, prepared, savedPath) => {
|
|
6187
|
+
try {
|
|
6188
|
+
loadConfig(ctx);
|
|
6189
|
+
if (!Object.hasOwn(prepared.proposed, "contextMaxChars") && prepared.before.contextMaxChars !== undefined) {
|
|
6190
|
+
setContextMaxCharsRef(prepared.before.contextMaxChars);
|
|
6191
|
+
rebaseConfigBaseline();
|
|
6192
|
+
}
|
|
6193
|
+
applyAdvisorConfigRuntimeSettings(runtime, ctx, prepared.beforeSettings);
|
|
6194
|
+
} catch (error) {
|
|
6195
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6196
|
+
return savedButNotAppliedResult(prepared, savedPath, message);
|
|
6197
|
+
}
|
|
6198
|
+
return appliedAdvisorConfigResult(prepared, savedPath);
|
|
6199
|
+
};
|
|
6200
|
+
var executeAdvisorConfigUpdate = async (runtime, ctx, input, signal, selectModels) => {
|
|
6201
|
+
if (!ctx.hasUI) {
|
|
6202
|
+
throw new Error("Advisor setting updates require an interactive confirmation. Use Pi's TUI or RPC UI; no settings were changed.");
|
|
6203
|
+
}
|
|
6204
|
+
const prepared = await prepareAdvisorConfigUpdate(ctx, input, selectModels);
|
|
6205
|
+
if (!prepared) {
|
|
6206
|
+
return cancelledAdvisorConfigResult("Model selection cancelled; no settings changed.");
|
|
6207
|
+
}
|
|
6208
|
+
if (Object.keys(prepared.proposed).length === 0) {
|
|
6209
|
+
return unchangedAdvisorConfigResult("Advisor settings already match the request.");
|
|
6210
|
+
}
|
|
6211
|
+
if (!await confirmAdvisorConfigUpdate(ctx, prepared, signal)) {
|
|
6212
|
+
return cancelledAdvisorConfigResult("Update cancelled; no settings changed.");
|
|
6213
|
+
}
|
|
6214
|
+
let savedPath;
|
|
6215
|
+
try {
|
|
6216
|
+
savedPath = await persistAdvisorConfigUpdate(prepared, signal);
|
|
6217
|
+
} catch (error) {
|
|
6218
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6219
|
+
throw new Error(`Advisor settings were not saved: ${message}`, {
|
|
6220
|
+
cause: error
|
|
6221
|
+
});
|
|
6222
|
+
}
|
|
6223
|
+
return applyAdvisorConfigUpdate(runtime, ctx, prepared, savedPath);
|
|
6224
|
+
};
|
|
6225
|
+
|
|
6226
|
+
// src/commands/configuration-tool.ts
|
|
6227
|
+
var CONFIGURATION_VALUE = Type.Union([
|
|
6228
|
+
Type.String(),
|
|
6229
|
+
Type.Number(),
|
|
6230
|
+
Type.Boolean(),
|
|
6231
|
+
Type.Null(),
|
|
6232
|
+
Type.Array(Type.String()),
|
|
6233
|
+
Type.Record(Type.String(), Type.String())
|
|
6234
|
+
]);
|
|
6235
|
+
var CONFIGURATION_TOOL_PARAMETERS = Type.Object({
|
|
6236
|
+
action: Type.String({ enum: ["read", "update"] }),
|
|
6237
|
+
changes: Type.Optional(Type.Record(Type.String(), CONFIGURATION_VALUE))
|
|
6238
|
+
}, { additionalProperties: false });
|
|
6239
|
+
var readCurrentConfig = (ctx) => {
|
|
6240
|
+
const config = getAdvisorConfigForAgent(readGlobalAdvisorConfig());
|
|
6241
|
+
const currentSessionModel = ctx.model ? `${ctx.model.provider}/${ctx.model.id}` : null;
|
|
6242
|
+
return {
|
|
6243
|
+
...config,
|
|
6244
|
+
currentSessionModel,
|
|
6245
|
+
scope: "global"
|
|
6246
|
+
};
|
|
6247
|
+
};
|
|
6248
|
+
var registerAdvisorConfigurationTool = (runtime, dependencies = {}) => {
|
|
6249
|
+
runtime.pi.registerTool({
|
|
6250
|
+
description: "Read or update pi-advisor settings at the user's request. Start with action=read to inspect current effective settings, persisted global overrides, and writable keys. For action=update, pass a sparse changes object using exact keys from writableKeys; use null to remove a saved override and restore the extension default. Every changing update previews global old-to-new values and requires user confirmation. Model settings open the existing interactive model picker; supplied model strings are proposed selections, not approval. Jev classifier/credential setup must use /advisor-settings, and outcome logging must be changed by itself through its dedicated consent path.",
|
|
6251
|
+
async execute(_id, params, signal, _onUpdate, ctx) {
|
|
6252
|
+
if (params.action === "read") {
|
|
6253
|
+
if (params.changes) {
|
|
6254
|
+
throw new Error("Do not pass changes with action=read.");
|
|
6255
|
+
}
|
|
6256
|
+
const settings = readCurrentConfig(ctx);
|
|
6257
|
+
return {
|
|
6258
|
+
content: [{ text: JSON.stringify(settings, null, 2), type: "text" }],
|
|
6259
|
+
details: { action: "read", applied: false, settings }
|
|
6260
|
+
};
|
|
6261
|
+
}
|
|
6262
|
+
return await executeAdvisorConfigUpdate(runtime, ctx, params.changes, signal, dependencies.selectModels);
|
|
6263
|
+
},
|
|
6264
|
+
executionMode: "sequential",
|
|
6265
|
+
label: "Configure Advisor",
|
|
6266
|
+
name: "advisor_config",
|
|
6267
|
+
parameters: CONFIGURATION_TOOL_PARAMETERS,
|
|
6268
|
+
promptGuidelines: [
|
|
6269
|
+
"Use advisor_config when the user asks to inspect or change pi-advisor settings. Read before updates when the current value affects the requested outcome.",
|
|
6270
|
+
"Send only settings the user asked to change. advisor_config asks for confirmation before writing and preserves unrelated settings; do not edit advisor.json directly.",
|
|
6271
|
+
"Wait for advisor_config to report a successful update before saying a setting changed. Use /advisor-settings for Jev classifier/credential setup."
|
|
6272
|
+
],
|
|
6273
|
+
promptSnippet: "Read or change the user's pi-advisor configuration",
|
|
6274
|
+
renderCall: () => new Text3("[advisor] Configure settings", 0, 0),
|
|
6275
|
+
renderResult: (result) => new Text3(textFrom(result.content), 0, 0)
|
|
6276
|
+
});
|
|
6277
|
+
};
|
|
6278
|
+
|
|
6279
|
+
// src/commands/lifecycle.ts
|
|
6280
|
+
var registerCommandLifecycle = (runtime, activateAdvisor) => {
|
|
6281
|
+
runtime.pi.on("session_start", async (_event, ctx) => {
|
|
6282
|
+
runtime.pendingExecutorModelRef = undefined;
|
|
6283
|
+
runtime.resetSameModelNotice();
|
|
6284
|
+
try {
|
|
6285
|
+
loadConfig(ctx);
|
|
6286
|
+
if (!advisorToolsEnabledRef) {
|
|
6287
|
+
setAdvisorToolsActive(runtime.pi, false);
|
|
6288
|
+
runtime.updateSameModelNotice(ctx);
|
|
6289
|
+
return;
|
|
6290
|
+
}
|
|
6291
|
+
if (alwaysOnRef) {
|
|
6292
|
+
setAdvisorToolsActive(runtime.pi, false);
|
|
6293
|
+
await activateAdvisor("", ctx, false);
|
|
6294
|
+
} else {
|
|
6295
|
+
runtime.updateSameModelNotice(ctx);
|
|
6296
|
+
}
|
|
6297
|
+
} catch (error) {
|
|
6298
|
+
setAdvisorToolsActive(runtime.pi, false);
|
|
6299
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6300
|
+
notify(ctx, `${t("notify.activationFailed.prefix", "Advisor activation failed:")} ${message}`, "error");
|
|
6301
|
+
}
|
|
6302
|
+
});
|
|
6303
|
+
runtime.pi.on("model_select", (event, ctx) => {
|
|
6304
|
+
if (!runtime.suppressModelSelectionSync) {
|
|
6305
|
+
runtime.updateSameModelNotice(ctx, event.model);
|
|
5690
6306
|
}
|
|
5691
6307
|
if (event.source !== "set" || runtime.suppressModelSelectionSync || isMarkedSubagent()) {
|
|
5692
6308
|
return;
|
|
@@ -5740,10 +6356,27 @@ import {
|
|
|
5740
6356
|
visibleWidth as visibleWidth2,
|
|
5741
6357
|
wrapTextWithAnsi
|
|
5742
6358
|
} from "@earendil-works/pi-tui";
|
|
5743
|
-
var
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
6359
|
+
var gitContextCopy = (level) => {
|
|
6360
|
+
switch (level) {
|
|
6361
|
+
case "full": {
|
|
6362
|
+
return {
|
|
6363
|
+
description: t("manualDialog.git.full.desc", "summary plus patch"),
|
|
6364
|
+
label: t("manualDialog.git.full.label", "Full")
|
|
6365
|
+
};
|
|
6366
|
+
}
|
|
6367
|
+
case "off": {
|
|
6368
|
+
return {
|
|
6369
|
+
description: t("manualDialog.git.off.desc", "no Git data"),
|
|
6370
|
+
label: t("manualDialog.git.off.label", "None")
|
|
6371
|
+
};
|
|
6372
|
+
}
|
|
6373
|
+
default: {
|
|
6374
|
+
return {
|
|
6375
|
+
description: t("manualDialog.git.summary.desc", "changed paths and status"),
|
|
6376
|
+
label: t("manualDialog.git.summary.label", "Summary")
|
|
6377
|
+
};
|
|
6378
|
+
}
|
|
6379
|
+
}
|
|
5747
6380
|
};
|
|
5748
6381
|
var renderManualAdvisorDialog = (view) => {
|
|
5749
6382
|
const {
|
|
@@ -5776,7 +6409,7 @@ var renderManualAdvisorDialog = (view) => {
|
|
|
5776
6409
|
}
|
|
5777
6410
|
};
|
|
5778
6411
|
if (renderWidth >= 2) {
|
|
5779
|
-
const title = truncateToWidth3(" Ask Advisor
|
|
6412
|
+
const title = truncateToWidth3(` ${t("manualDialog.title", "Ask Advisor")} `, Math.max(0, innerWidth), "", false);
|
|
5780
6413
|
const titleWidth = visibleWidth2(title);
|
|
5781
6414
|
const remaining = Math.max(0, innerWidth - titleWidth);
|
|
5782
6415
|
const left = Math.floor(remaining / 2);
|
|
@@ -5784,20 +6417,20 @@ var renderManualAdvisorDialog = (view) => {
|
|
|
5784
6417
|
lines.push(theme.fg("border", `╭${"─".repeat(left)}`) + theme.fg("accent", title) + theme.fg("border", `${"─".repeat(right)}╮`));
|
|
5785
6418
|
addLine("");
|
|
5786
6419
|
}
|
|
5787
|
-
addLine(`${focusMarker("editor")}${theme.bold("Message for Advisor (optional)")}`);
|
|
6420
|
+
addLine(`${focusMarker("editor")}${theme.bold(t("manualDialog.messageLabel", "Message for Advisor (optional)"))}`);
|
|
5788
6421
|
for (const editorLine of editorLines) {
|
|
5789
6422
|
addLine(editorLine);
|
|
5790
6423
|
}
|
|
5791
6424
|
addLine("");
|
|
5792
|
-
addWrapped("Automatic context follows your settings: conversation history, tool disclosure, project preferences, redaction, and configured limits remain unchanged.", "muted");
|
|
5793
|
-
addWrapped("This dialog does not expose drafts or explicit file handoff controls.", "dim");
|
|
5794
|
-
addWrapped("Git None only withholds repository data; it does not remove configured conversation history.", "dim");
|
|
6425
|
+
addWrapped(t("manualDialog.contextNote", "Automatic context follows your settings: conversation history, tool disclosure, project preferences, redaction, and configured limits remain unchanged."), "muted");
|
|
6426
|
+
addWrapped(t("manualDialog.noDraftsNote", "This dialog does not expose drafts or explicit file handoff controls."), "dim");
|
|
6427
|
+
addWrapped(t("manualDialog.gitNoneNote", "Git None only withholds repository data; it does not remove configured conversation history."), "dim");
|
|
5795
6428
|
addLine("");
|
|
5796
|
-
const gitCeiling =
|
|
5797
|
-
addLine(`${focusMarker("git")}${theme.bold(
|
|
6429
|
+
const gitCeiling = gitContextCopy(gitContext).label;
|
|
6430
|
+
addLine(`${focusMarker("git")}${theme.bold(`${t("manualDialog.gitTitle", "Git repository context (max:")} ${gitCeiling}; ${t("manualDialog.gitChoose", "↑/↓ or Space to choose)")}`)}`);
|
|
5798
6431
|
for (let index = 0;index < gitLevels.length; index += 1) {
|
|
5799
6432
|
const level = gitLevels[index];
|
|
5800
|
-
const copy =
|
|
6433
|
+
const copy = gitContextCopy(level);
|
|
5801
6434
|
const selected = index === gitIndex;
|
|
5802
6435
|
const marker = selected ? "●" : "○";
|
|
5803
6436
|
const optionFocus = focusTarget === "git" && selected ? "▸ " : " ";
|
|
@@ -5805,16 +6438,16 @@ var renderManualAdvisorDialog = (view) => {
|
|
|
5805
6438
|
addWrapped(`${optionFocus}${marker} ${copy.label} — ${copy.description}`, color);
|
|
5806
6439
|
}
|
|
5807
6440
|
addLine("");
|
|
5808
|
-
let interactionHint = "Enter submit · Shift+Enter newline · Tab/Shift+Tab focus · Esc cancel";
|
|
6441
|
+
let interactionHint = t("manualDialog.hint.editor", "Enter submit · Shift+Enter newline · Tab/Shift+Tab focus · Esc cancel");
|
|
5809
6442
|
if (focusTarget === "git") {
|
|
5810
|
-
interactionHint = "↑/↓ or Space choose · Enter next · Tab/Shift+Tab focus · Esc cancel";
|
|
6443
|
+
interactionHint = t("manualDialog.hint.git", "↑/↓ or Space choose · Enter next · Tab/Shift+Tab focus · Esc cancel");
|
|
5811
6444
|
} else if (focusTarget === "actions") {
|
|
5812
|
-
interactionHint = "←/→ choose · Enter/Space activate · Tab/Shift+Tab focus · Esc cancel";
|
|
6445
|
+
interactionHint = t("manualDialog.hint.actions", "←/→ choose · Enter/Space activate · Tab/Shift+Tab focus · Esc cancel");
|
|
5813
6446
|
}
|
|
5814
6447
|
const submit = focusTarget === "actions" && actionIndex === 0;
|
|
5815
|
-
const submitLabel = submit ? theme.fg("accent", "[Submit]") : theme.fg("text", "[Submit]");
|
|
6448
|
+
const submitLabel = submit ? theme.fg("accent", t("manualDialog.submit", "[Submit]")) : theme.fg("text", t("manualDialog.submit", "[Submit]"));
|
|
5816
6449
|
const cancel = focusTarget === "actions" && actionIndex === 1;
|
|
5817
|
-
const cancelLabel = cancel ? theme.fg("accent", "[Cancel]") : theme.fg("text", "[Cancel]");
|
|
6450
|
+
const cancelLabel = cancel ? theme.fg("accent", t("manualDialog.cancel", "[Cancel]")) : theme.fg("text", t("manualDialog.cancel", "[Cancel]"));
|
|
5818
6451
|
const actionButtons = `${submitLabel} ${cancelLabel}`;
|
|
5819
6452
|
const buttonOffset = Math.max(0, Math.floor((contentWidth - visibleWidth2(actionButtons)) / 2) - 2);
|
|
5820
6453
|
addLine(`${focusMarker("actions")}${" ".repeat(buttonOffset)}${actionButtons}`);
|
|
@@ -6482,7 +7115,7 @@ var SCREENED_SKIP_TEXT = "Advisor consultation skipped (screened out): the stake
|
|
|
6482
7115
|
var repeatSkipText = (advice) => `Advisor consultation skipped (already answered): this question was answered earlier in this session; the earlier advice is reattached below. Consult again only if the situation has materially changed.
|
|
6483
7116
|
|
|
6484
7117
|
${advice}`;
|
|
6485
|
-
var outageNotifier = createOutageNotifier((category, message) =>
|
|
7118
|
+
var outageNotifier = createOutageNotifier((category, message) => `${t("notify.jevFilterOutage.prefix", "Advisor Jev classifier failed")} (${category}); ${t("notify.jevFilterOutage.allowing", "allowing consultations.")} ${message}`);
|
|
6486
7119
|
var notifyOutageOnce = outageNotifier.notify;
|
|
6487
7120
|
var resetJevOutageNotification = outageNotifier.reset;
|
|
6488
7121
|
var allow = () => ({ decision: "allow" });
|
|
@@ -6686,7 +7319,7 @@ ${markdown}`,
|
|
|
6686
7319
|
},
|
|
6687
7320
|
display: true
|
|
6688
7321
|
}, { deliverAs: "steer", triggerTurn: !isPrintMode });
|
|
6689
|
-
notify(ctx,
|
|
7322
|
+
notify(ctx, `${t("manualCmd.consultFailed.prefix", "Advisor consultation failed:")} ${message}`, "error");
|
|
6690
7323
|
notifyHerdrAdvisorFailure("Advisor consultation failed", message);
|
|
6691
7324
|
} finally {
|
|
6692
7325
|
finishHerdrActivity();
|
|
@@ -6828,7 +7461,7 @@ var registerModelCommands = (runtime) => {
|
|
|
6828
7461
|
});
|
|
6829
7462
|
runtime.pendingExecutorModelRef = undefined;
|
|
6830
7463
|
runtime.updateSameModelNotice(ctx);
|
|
6831
|
-
ctx.ui.notify(
|
|
7464
|
+
ctx.ui.notify(`${t("notify.modelsSaved.prefix", "Saved Executor + Advisor configurations to")} ${path}`, "info");
|
|
6832
7465
|
}
|
|
6833
7466
|
});
|
|
6834
7467
|
};
|
|
@@ -7142,11 +7775,11 @@ var registerOutcomeStatsCommand = (runtime) => {
|
|
|
7142
7775
|
|
|
7143
7776
|
// src/commands/renderers.ts
|
|
7144
7777
|
import { getMarkdownTheme as getMarkdownTheme3 } from "@earendil-works/pi-coding-agent";
|
|
7145
|
-
import { Box as Box2, Markdown as Markdown3, Text as
|
|
7778
|
+
import { Box as Box2, Markdown as Markdown3, Text as Text5 } from "@earendil-works/pi-tui";
|
|
7146
7779
|
|
|
7147
7780
|
// src/commands/manual-progress.ts
|
|
7148
7781
|
import { getMarkdownTheme as getMarkdownTheme2 } from "@earendil-works/pi-coding-agent";
|
|
7149
|
-
import { Markdown as Markdown2, Text as
|
|
7782
|
+
import { Markdown as Markdown2, Text as Text4 } from "@earendil-works/pi-tui";
|
|
7150
7783
|
class ManualAdvisorProgressComponent {
|
|
7151
7784
|
question;
|
|
7152
7785
|
state;
|
|
@@ -7173,17 +7806,17 @@ class ManualAdvisorProgressComponent {
|
|
|
7173
7806
|
return box.render(width);
|
|
7174
7807
|
}
|
|
7175
7808
|
if (this.state.phase === "error") {
|
|
7176
|
-
box.addChild(new
|
|
7809
|
+
box.addChild(new Text4(this.theme.fg("error", this.theme.bold("◆ ADVISOR · FAILED")), 0, 0));
|
|
7177
7810
|
return box.render(width);
|
|
7178
7811
|
}
|
|
7179
7812
|
const frame = SPINNER_FRAMES[Math.floor(Date.now() / 80) % SPINNER_FRAMES.length];
|
|
7180
|
-
let status = "Working…";
|
|
7813
|
+
let status = t("manualProgress.working", "Working…");
|
|
7181
7814
|
if (this.state.phase === "preparing") {
|
|
7182
|
-
status = "Preparing…";
|
|
7815
|
+
status = t("manualProgress.preparing", "Preparing…");
|
|
7183
7816
|
} else if (this.state.text?.trim()) {
|
|
7184
|
-
status = "Responding…";
|
|
7817
|
+
status = t("manualProgress.responding", "Responding…");
|
|
7185
7818
|
}
|
|
7186
|
-
box.addChild(new
|
|
7819
|
+
box.addChild(new Text4(`${this.theme.fg("warning", this.theme.bold(`◆ ADVISOR ${frame}`))} ${this.theme.fg("dim", `· ${status}`)}`, 0, 0));
|
|
7187
7820
|
if (this.state.thinking?.trim()) {
|
|
7188
7821
|
box.addChild(renderThinkingMarkdown(this.state.thinking.slice(-200), this.theme));
|
|
7189
7822
|
}
|
|
@@ -7214,14 +7847,14 @@ var manualResultRenderer = (message, { expanded }, theme) => {
|
|
|
7214
7847
|
const { details } = message;
|
|
7215
7848
|
const box = new Box2(1, 1, (text) => theme.bg("customMessageBg", text));
|
|
7216
7849
|
const advice = details?.text ?? (isString(message.content) ? message.content : "(Advisor returned no advice.)");
|
|
7217
|
-
box.addChild(new
|
|
7850
|
+
box.addChild(new Text5(renderAdvisorResponseHeader(hasSoundVerdict(advice), theme), 0, 0));
|
|
7218
7851
|
if (details?.advisor) {
|
|
7219
|
-
box.addChild(new
|
|
7852
|
+
box.addChild(new Text5(theme.fg("dim", ` ${details.advisor}`), 0, 0));
|
|
7220
7853
|
}
|
|
7221
7854
|
if (getAdvisorSettings().showUsageDetails) {
|
|
7222
7855
|
const usage = formatAdvisorUsage(details?.usage);
|
|
7223
7856
|
if (usage) {
|
|
7224
|
-
box.addChild(new
|
|
7857
|
+
box.addChild(new Text5(theme.fg("dim", ` Usage: ${usage}`), 0, 0));
|
|
7225
7858
|
}
|
|
7226
7859
|
}
|
|
7227
7860
|
const attachments = [
|
|
@@ -7229,14 +7862,14 @@ var manualResultRenderer = (message, { expanded }, theme) => {
|
|
|
7229
7862
|
details?.preferenceBytes ? `Project preferences attached · ${formatByteSize(details.preferenceBytes)}` : undefined
|
|
7230
7863
|
].filter((value) => value !== undefined);
|
|
7231
7864
|
if (attachments.length) {
|
|
7232
|
-
box.addChild(new
|
|
7865
|
+
box.addChild(new Text5(theme.fg("dim", ` ${attachments.join(" · ")}`), 0, 0));
|
|
7233
7866
|
}
|
|
7234
7867
|
box.addChild(new Markdown3(adviceForDisplay(advice, expanded), 0, 0, getMarkdownTheme3()));
|
|
7235
7868
|
return box;
|
|
7236
7869
|
};
|
|
7237
7870
|
var outcomeStatsRenderer = (message, _options, theme) => {
|
|
7238
7871
|
const box = new Box2(1, 1, (text) => theme.bg("customMessageBg", text));
|
|
7239
|
-
box.addChild(new
|
|
7872
|
+
box.addChild(new Text5(theme.fg("accent", theme.bold("◆ ADVISOR · OUTCOME STATS")), 0, 0));
|
|
7240
7873
|
box.addChild(new Markdown3(formatAdvisorStats(message.details ?? { malformedLines: 0 }), 0, 0, getMarkdownTheme3()));
|
|
7241
7874
|
return box;
|
|
7242
7875
|
};
|
|
@@ -7312,8 +7945,8 @@ var contextDescription = (presets, contextMaxChars) => {
|
|
|
7312
7945
|
const markerColumn = meterPrefix.length + marker;
|
|
7313
7946
|
const labelStart = Math.max(0, Math.min(meterPrefix.length + meter.length + 2 - labelWidth, markerColumn - Math.floor((labelWidth - 1) / 2)));
|
|
7314
7947
|
const markerLabel = `${" ".repeat(labelStart)}${label}`;
|
|
7315
|
-
const description = exactIndex === -1 ? "Custom context limit." : selectedPreset?.description;
|
|
7316
|
-
return `${description ?? "Custom context limit."}
|
|
7948
|
+
const description = exactIndex === -1 ? t("settings.context.customLimit", "Custom context limit.") : selectedPreset?.description;
|
|
7949
|
+
return `${description ?? t("settings.context.customLimit", "Custom context limit.")}
|
|
7317
7950
|
${meterPrefix}${meter} full
|
|
7318
7951
|
${markerLabel}`;
|
|
7319
7952
|
};
|
|
@@ -7338,6 +7971,16 @@ var rainbowGradient = (text, startedAt) => {
|
|
|
7338
7971
|
};
|
|
7339
7972
|
|
|
7340
7973
|
// src/ui/settings-items.ts
|
|
7974
|
+
import { getKeybindings as getKeybindings2 } from "@earendil-works/pi-tui";
|
|
7975
|
+
|
|
7976
|
+
// src/ui/model-multi-selector.ts
|
|
7977
|
+
class SearchableModelMultiSelector extends ModelSelectorAdapter {
|
|
7978
|
+
constructor(options) {
|
|
7979
|
+
super(new SearchableModelList(options));
|
|
7980
|
+
}
|
|
7981
|
+
}
|
|
7982
|
+
|
|
7983
|
+
// src/ui/settings-items-jev.ts
|
|
7341
7984
|
import { getKeybindings } from "@earendil-works/pi-tui";
|
|
7342
7985
|
|
|
7343
7986
|
// src/ui/jev-classifier-submenu.ts
|
|
@@ -7419,12 +8062,12 @@ class JevClassifierSubmenu {
|
|
|
7419
8062
|
if (this.mode === "key") {
|
|
7420
8063
|
return [
|
|
7421
8064
|
border,
|
|
7422
|
-
theme.fg("accent", theme.bold("Jev API Key")),
|
|
8065
|
+
theme.fg("accent", theme.bold(t("jevSubmenu.apiKeyTitle", "Jev API Key"))),
|
|
7423
8066
|
"",
|
|
7424
|
-
this.notice ?? "Enter a new TypeSafe Jev API key:",
|
|
8067
|
+
this.notice ?? t("jevSubmenu.enterNewKey", "Enter a new TypeSafe Jev API key:"),
|
|
7425
8068
|
` ${this.keyInput?.render(Math.max(1, width - 4))[0] ?? ""}`,
|
|
7426
8069
|
"",
|
|
7427
|
-
this.failClosedKeyMode ? "Key restore failed. Re-enter and verify a valid Jev key." : "Enter to verify · Esc to cancel",
|
|
8070
|
+
this.failClosedKeyMode ? t("jevSubmenu.keyRestoreFailed", "Key restore failed. Re-enter and verify a valid Jev key.") : t("jevSubmenu.keyEntryHint", "Enter to verify · Esc to cancel"),
|
|
7428
8071
|
border
|
|
7429
8072
|
];
|
|
7430
8073
|
}
|
|
@@ -7434,13 +8077,13 @@ class JevClassifierSubmenu {
|
|
|
7434
8077
|
const rows = this.filtered.map((choice, index) => `${index === this.selectedIndex ? "›" : " "} ${choice.label}`);
|
|
7435
8078
|
return [
|
|
7436
8079
|
border,
|
|
7437
|
-
theme.fg("accent", theme.bold("Jev classifier")),
|
|
8080
|
+
theme.fg("accent", theme.bold(t("jevSubmenu.classifierTitle", "Jev classifier"))),
|
|
7438
8081
|
"",
|
|
7439
|
-
this.mode === "loading" ? "Loading Pi classifier catalog…" :
|
|
8082
|
+
this.mode === "loading" ? t("jevSubmenu.loading", "Loading Pi classifier catalog…") : `${t("jevSubmenu.searchLabel", "Search:")} ${this.search.render(Math.max(1, width - 10))[0]}`,
|
|
7440
8083
|
...this.notice ? [this.notice] : [],
|
|
7441
8084
|
...rows.slice(0, 10),
|
|
7442
8085
|
"",
|
|
7443
|
-
"↑/↓ move · Enter select · Esc cancel",
|
|
8086
|
+
t("jevSubmenu.listHint", "↑/↓ move · Enter select · Esc cancel"),
|
|
7444
8087
|
border
|
|
7445
8088
|
];
|
|
7446
8089
|
}
|
|
@@ -7476,7 +8119,7 @@ class JevClassifierSubmenu {
|
|
|
7476
8119
|
async loadChoices() {
|
|
7477
8120
|
try {
|
|
7478
8121
|
if (!this.options.modelRegistry) {
|
|
7479
|
-
throw new Error("Pi classifier registry is unavailable.");
|
|
8122
|
+
throw new Error(t("jevSubmenu.registryUnavailable", "Pi classifier registry is unavailable."));
|
|
7480
8123
|
}
|
|
7481
8124
|
const models = await this.options.modelRegistry.getAvailableOfType("classifier");
|
|
7482
8125
|
this.choices = (models ?? []).map((model) => ({
|
|
@@ -7489,27 +8132,27 @@ class JevClassifierSubmenu {
|
|
|
7489
8132
|
if (stored.key) {
|
|
7490
8133
|
this.choices.push({
|
|
7491
8134
|
action: "use-key",
|
|
7492
|
-
label: "Jev API Key (use stored key)",
|
|
8135
|
+
label: t("jevSubmenu.useStoredKey", "Jev API Key (use stored key)"),
|
|
7493
8136
|
ref: JEV_API_KEY_CLASSIFIER
|
|
7494
8137
|
}, {
|
|
7495
8138
|
action: "replace-key",
|
|
7496
|
-
label: "Replace Jev API Key…",
|
|
8139
|
+
label: t("jevSubmenu.replaceKey", "Replace Jev API Key…"),
|
|
7497
8140
|
ref: JEV_API_KEY_CLASSIFIER
|
|
7498
8141
|
});
|
|
7499
8142
|
} else {
|
|
7500
8143
|
this.choices.push({
|
|
7501
8144
|
action: "replace-key",
|
|
7502
|
-
label: "Jev API Key… (enter TypeSafe key)",
|
|
8145
|
+
label: t("jevSubmenu.enterKeyChoice", "Jev API Key… (enter TypeSafe key)"),
|
|
7503
8146
|
ref: JEV_API_KEY_CLASSIFIER
|
|
7504
8147
|
});
|
|
7505
8148
|
}
|
|
7506
8149
|
this.mode = "list";
|
|
7507
8150
|
this.loaded.resolve(true);
|
|
7508
|
-
this.notice = this.options.currentValue && this.options.currentValue !== "Choose classifier" ?
|
|
8151
|
+
this.notice = this.options.currentValue && this.options.currentValue !== "Choose classifier" ? `${t("jevSubmenu.currentPrefix", "Current:")} ${this.options.currentValue}` : undefined;
|
|
7509
8152
|
} catch (error) {
|
|
7510
8153
|
this.mode = "list";
|
|
7511
8154
|
this.loaded.resolve(false);
|
|
7512
|
-
this.notice =
|
|
8155
|
+
this.notice = `${t("jevSubmenu.loadFailedPrefix", "Could not load classifiers:")} ${error instanceof Error ? error.message : t("jevSetup.unknownError", "unknown error")}${t("jevSubmenu.loadFailedSuffix", ". Retry /advisor-settings.")}`;
|
|
7513
8156
|
}
|
|
7514
8157
|
this.options.tui.requestRender();
|
|
7515
8158
|
}
|
|
@@ -7518,7 +8161,7 @@ class JevClassifierSubmenu {
|
|
|
7518
8161
|
}
|
|
7519
8162
|
static rates(model) {
|
|
7520
8163
|
const rates = model.cost;
|
|
7521
|
-
return rates.input === 0 && rates.output === 0 ? "$0/M tokens" : `$${rates.input}/$${rates.output} per Mtok`;
|
|
8164
|
+
return rates.input === 0 && rates.output === 0 ? t("jevSubmenu.ratesFree", "$0/M tokens") : `$${rates.input}/$${rates.output} ${t("jevSubmenu.perMtok", "per Mtok")}`;
|
|
7522
8165
|
}
|
|
7523
8166
|
async choose(choice) {
|
|
7524
8167
|
if (choice.action === "use-key") {
|
|
@@ -7538,24 +8181,24 @@ class JevClassifierSubmenu {
|
|
|
7538
8181
|
return;
|
|
7539
8182
|
}
|
|
7540
8183
|
this.mode = "verifying";
|
|
7541
|
-
this.notice =
|
|
8184
|
+
this.notice = `${t("jevSubmenu.verifying", "Verifying")} ${choice.ref}…`;
|
|
7542
8185
|
this.options.tui.requestRender();
|
|
7543
8186
|
try {
|
|
7544
8187
|
await this.verify(choice.model);
|
|
7545
8188
|
const saved = this.save({ classifier: choice.ref, transport: "auto" });
|
|
7546
8189
|
if (!saved) {
|
|
7547
8190
|
this.mode = "list";
|
|
7548
|
-
this.notice = "Verified, but settings could not be saved.";
|
|
8191
|
+
this.notice = t("jevSubmenu.verifiedNotSaved", "Verified, but settings could not be saved.");
|
|
7549
8192
|
}
|
|
7550
8193
|
} catch (error) {
|
|
7551
|
-
this.notice =
|
|
8194
|
+
this.notice = `${t("jevSubmenu.verifyFailedFor", "Verification failed for")} ${choice.ref}: ${error instanceof Error ? error.message : t("jevSubmenu.providerError", "provider error")}`;
|
|
7552
8195
|
this.mode = "list";
|
|
7553
8196
|
}
|
|
7554
8197
|
this.options.tui.requestRender();
|
|
7555
8198
|
}
|
|
7556
8199
|
async verify(model, apiKey) {
|
|
7557
8200
|
if (!this.options.modelRegistry) {
|
|
7558
|
-
throw new Error("Pi classifier registry is unavailable.");
|
|
8201
|
+
throw new Error(t("jevSubmenu.registryUnavailable", "Pi classifier registry is unavailable."));
|
|
7559
8202
|
}
|
|
7560
8203
|
const state = {
|
|
7561
8204
|
recent_conversation: "Classifier verification check.",
|
|
@@ -7563,32 +8206,32 @@ class JevClassifierSubmenu {
|
|
|
7563
8206
|
};
|
|
7564
8207
|
const result = await classifyWithJev({ modelRegistry: this.options.modelRegistry, signal: undefined }, `${model.provider}/${model.id}`, state, nativeScreeningQuestions, { apiKey });
|
|
7565
8208
|
if (!result.answers.self_answerable || !result.answers.stakes) {
|
|
7566
|
-
throw new Error("Classifier returned an incomplete verification result.");
|
|
8209
|
+
throw new Error(t("jevSubmenu.incompleteResult", "Classifier returned an incomplete verification result."));
|
|
7567
8210
|
}
|
|
7568
8211
|
}
|
|
7569
8212
|
async verifyKey() {
|
|
7570
8213
|
const candidate = this.keyInput?.getValue().trim() ?? "";
|
|
7571
8214
|
this.keyInput?.setValue("");
|
|
7572
8215
|
if (!candidate) {
|
|
7573
|
-
this.notice = "Enter a non-empty Jev API key.";
|
|
8216
|
+
this.notice = t("jevSubmenu.emptyKey", "Enter a non-empty Jev API key.");
|
|
7574
8217
|
this.options.tui.requestRender();
|
|
7575
8218
|
return;
|
|
7576
8219
|
}
|
|
7577
8220
|
const model = this.options.modelRegistry?.findOfType("classifier", "typesafe", "jev-latest");
|
|
7578
8221
|
if (!model) {
|
|
7579
|
-
this.notice = "TypeSafe Jev classifier is not present in Pi's catalog.";
|
|
8222
|
+
this.notice = t("jevSubmenu.classifierMissing", "TypeSafe Jev classifier is not present in Pi's catalog.");
|
|
7580
8223
|
this.options.tui.requestRender();
|
|
7581
8224
|
return;
|
|
7582
8225
|
}
|
|
7583
8226
|
const previous = await (this.options.resolveStoredKey ?? readJevClassifierKey)();
|
|
7584
8227
|
if (previous.failed) {
|
|
7585
8228
|
this.mode = "list";
|
|
7586
|
-
this.notice = "Could not read the stored Jev API Key state; nothing was changed. Try again later.";
|
|
8229
|
+
this.notice = t("jevSubmenu.keyStateUnreadable", "Could not read the stored Jev API Key state; nothing was changed. Try again later.");
|
|
7587
8230
|
this.options.tui.requestRender();
|
|
7588
8231
|
return;
|
|
7589
8232
|
}
|
|
7590
8233
|
this.mode = "verifying";
|
|
7591
|
-
this.notice = "Verifying Jev API Key…";
|
|
8234
|
+
this.notice = t("jevSubmenu.verifyingKey", "Verifying Jev API Key…");
|
|
7592
8235
|
this.options.tui.requestRender();
|
|
7593
8236
|
try {
|
|
7594
8237
|
await this.verify(model, candidate);
|
|
@@ -7601,15 +8244,15 @@ class JevClassifierSubmenu {
|
|
|
7601
8244
|
if (!await this.restorePreviousKey(previous)) {
|
|
7602
8245
|
this.failClosedKeyMode = true;
|
|
7603
8246
|
disableJevClassifierKeyForRuntime();
|
|
7604
|
-
throw new Error("Settings save failed and the previous key could not be restored. Re-enter and verify a valid Jev key before continuing.");
|
|
8247
|
+
throw new Error(t("jevSubmenu.saveFailedNoRestore", "Settings save failed and the previous key could not be restored. Re-enter and verify a valid Jev key before continuing."));
|
|
7605
8248
|
}
|
|
7606
|
-
throw new Error("Could not save Jev classifier settings; existing key was restored.");
|
|
8249
|
+
throw new Error(t("jevSubmenu.saveFailedRestored", "Could not save Jev classifier settings; existing key was restored."));
|
|
7607
8250
|
}
|
|
7608
8251
|
this.mode = "list";
|
|
7609
|
-
this.notice = "Jev API Key verified and saved securely.";
|
|
8252
|
+
this.notice = t("jevSubmenu.keyVerifiedSaved", "Jev API Key verified and saved securely.");
|
|
7610
8253
|
} catch (error) {
|
|
7611
8254
|
this.mode = "key";
|
|
7612
|
-
this.notice =
|
|
8255
|
+
this.notice = `${t("jevSubmenu.verificationFailedPrefix", "Verification failed:")} ${error instanceof Error ? error.message : t("jevSubmenu.providerError", "provider error")}`;
|
|
7613
8256
|
}
|
|
7614
8257
|
this.options.tui.requestRender();
|
|
7615
8258
|
}
|
|
@@ -7622,7 +8265,7 @@ class JevClassifierSubmenu {
|
|
|
7622
8265
|
this.options.tui.requestRender();
|
|
7623
8266
|
},
|
|
7624
8267
|
onSubmit: () => this.handleKeySubmit(),
|
|
7625
|
-
placeholder: "TypeSafe Jev API key"
|
|
8268
|
+
placeholder: t("jevSubmenu.keyPlaceholder", "TypeSafe Jev API key")
|
|
7626
8269
|
});
|
|
7627
8270
|
}
|
|
7628
8271
|
restorePreviousKey(previous) {
|
|
@@ -7634,22 +8277,22 @@ class JevClassifierSubmenu {
|
|
|
7634
8277
|
async verifyStoredKey(key) {
|
|
7635
8278
|
const model = this.options.modelRegistry?.findOfType("classifier", "typesafe", "jev-latest");
|
|
7636
8279
|
if (!model) {
|
|
7637
|
-
this.notice = "TypeSafe Jev classifier is not present in Pi's catalog.";
|
|
8280
|
+
this.notice = t("jevSubmenu.classifierMissing", "TypeSafe Jev classifier is not present in Pi's catalog.");
|
|
7638
8281
|
this.options.tui.requestRender();
|
|
7639
8282
|
return;
|
|
7640
8283
|
}
|
|
7641
8284
|
this.mode = "verifying";
|
|
7642
|
-
this.notice = "Verifying stored Jev API Key…";
|
|
8285
|
+
this.notice = t("jevSubmenu.verifyingStoredKey", "Verifying stored Jev API Key…");
|
|
7643
8286
|
this.options.tui.requestRender();
|
|
7644
8287
|
try {
|
|
7645
8288
|
await this.verify(model, key);
|
|
7646
8289
|
if (!this.save({ classifier: JEV_API_KEY_CLASSIFIER, transport: "auto" })) {
|
|
7647
|
-
throw new Error("Could not save the Jev classifier selection.");
|
|
8290
|
+
throw new Error(t("jevSubmenu.selectionNotSaved", "Could not save the Jev classifier selection."));
|
|
7648
8291
|
}
|
|
7649
|
-
this.notice = "Stored Jev API Key verified.";
|
|
8292
|
+
this.notice = t("jevSubmenu.storedKeyVerified", "Stored Jev API Key verified.");
|
|
7650
8293
|
} catch (error) {
|
|
7651
8294
|
this.mode = "list";
|
|
7652
|
-
this.notice =
|
|
8295
|
+
this.notice = `${t("jevSubmenu.verificationFailedPrefix", "Verification failed:")} ${error instanceof Error ? error.message : t("jevSubmenu.providerError", "provider error")}`;
|
|
7653
8296
|
}
|
|
7654
8297
|
this.options.tui.requestRender();
|
|
7655
8298
|
}
|
|
@@ -7657,7 +8300,7 @@ class JevClassifierSubmenu {
|
|
|
7657
8300
|
try {
|
|
7658
8301
|
await this.verifyKey();
|
|
7659
8302
|
} catch (error) {
|
|
7660
|
-
this.notice =
|
|
8303
|
+
this.notice = `${t("jevSubmenu.verificationFailedPrefix", "Verification failed:")} ${error instanceof Error ? error.message : t("jevSubmenu.providerError", "provider error")}`;
|
|
7661
8304
|
this.mode = "key";
|
|
7662
8305
|
this.options.tui.requestRender();
|
|
7663
8306
|
}
|
|
@@ -7668,7 +8311,7 @@ class JevClassifierSubmenu {
|
|
|
7668
8311
|
this.options.done(selection.classifier);
|
|
7669
8312
|
} else {
|
|
7670
8313
|
this.mode = "list";
|
|
7671
|
-
this.notice = "Verified, but settings could not be saved.";
|
|
8314
|
+
this.notice = t("jevSubmenu.verifiedNotSaved", "Verified, but settings could not be saved.");
|
|
7672
8315
|
}
|
|
7673
8316
|
return saved;
|
|
7674
8317
|
}
|
|
@@ -7679,9 +8322,9 @@ import { Key as Key3, matchesKey as matchesKey3, truncateToWidth as truncateToWi
|
|
|
7679
8322
|
var actionsFor = (enabled) => enabled ? ["disable", "done"] : ["enable", "done"];
|
|
7680
8323
|
var labelFor2 = (action) => {
|
|
7681
8324
|
if (action === "enable") {
|
|
7682
|
-
return "Enable the filter";
|
|
8325
|
+
return t("jevSubmenu.filter.enable", "Enable the filter");
|
|
7683
8326
|
}
|
|
7684
|
-
return action === "disable" ? "Disable the filter" : "Done";
|
|
8327
|
+
return action === "disable" ? t("jevSubmenu.filter.disable", "Disable the filter") : t("jevSubmenu.filter.done", "Done");
|
|
7685
8328
|
};
|
|
7686
8329
|
|
|
7687
8330
|
class JevFilterSubmenu {
|
|
@@ -7711,13 +8354,13 @@ class JevFilterSubmenu {
|
|
|
7711
8354
|
render(width) {
|
|
7712
8355
|
const { theme } = this.options;
|
|
7713
8356
|
const lines = [
|
|
7714
|
-
theme.fg("accent", theme.bold("
|
|
8357
|
+
theme.fg("accent", theme.bold(` ${t("jevSubmenu.filter.title", "Jev classifier consultation filter")}`)),
|
|
7715
8358
|
"",
|
|
7716
|
-
` Filter: ${this.enabled ? "On" : "Off"}`,
|
|
7717
|
-
` Classifier: ${this.options.currentClassifier ?? "not selected"}`
|
|
8359
|
+
` ${t("jevSubmenu.filter.filterLabel", "Filter:")} ${this.enabled ? "On" : "Off"}`,
|
|
8360
|
+
` ${t("jevSubmenu.filter.classifierLabel", "Classifier:")} ${this.options.currentClassifier ?? t("jevSubmenu.filter.notSelected", "not selected")}`
|
|
7718
8361
|
];
|
|
7719
8362
|
if (this.mode === "resolving") {
|
|
7720
|
-
lines.push("", "
|
|
8363
|
+
lines.push("", ` ${t("jevSubmenu.filter.checking", "Checking selected classifier availability…")}`);
|
|
7721
8364
|
} else if (this.notice) {
|
|
7722
8365
|
lines.push("", theme.fg("warning", ` ${this.notice}`));
|
|
7723
8366
|
}
|
|
@@ -7752,9 +8395,9 @@ class JevFilterSubmenu {
|
|
|
7752
8395
|
const stored = await (this.resolveClassifierKey ?? readJevClassifierKey)();
|
|
7753
8396
|
this.classifierAvailable = Boolean(stored.key);
|
|
7754
8397
|
if (stored.failed) {
|
|
7755
|
-
this.notice = "Could not read the stored Jev API Key state; try again later.";
|
|
8398
|
+
this.notice = t("jevSubmenu.filter.keyStateUnreadable", "Could not read the stored Jev API Key state; try again later.");
|
|
7756
8399
|
} else if (!this.classifierAvailable) {
|
|
7757
|
-
this.notice = "No Jev API Key is stored. Choose Jev API Key in Jev classifier settings.";
|
|
8400
|
+
this.notice = t("jevSubmenu.filter.noStoredKey", "No Jev API Key is stored. Choose Jev API Key in Jev classifier settings.");
|
|
7758
8401
|
}
|
|
7759
8402
|
} else {
|
|
7760
8403
|
const parsed = selected ? parseJevClassifierRef(selected) : undefined;
|
|
@@ -7764,11 +8407,11 @@ class JevFilterSubmenu {
|
|
|
7764
8407
|
this.classifierAvailable = available.some((model) => model.id === parsed.modelId);
|
|
7765
8408
|
}
|
|
7766
8409
|
if (!this.classifierAvailable) {
|
|
7767
|
-
this.notice = "Select an available authenticated classifier in Jev classifier settings first.";
|
|
8410
|
+
this.notice = t("jevSubmenu.filter.selectClassifierFirst", "Select an available authenticated classifier in Jev classifier settings first.");
|
|
7768
8411
|
}
|
|
7769
8412
|
}
|
|
7770
8413
|
} catch (error) {
|
|
7771
|
-
this.notice =
|
|
8414
|
+
this.notice = `${t("jevSubmenu.filter.lookupFailedPrefix", "Classifier lookup failed:")} ${error instanceof Error ? error.message : t("jevSubmenu.filter.piError", "Pi error")}`;
|
|
7772
8415
|
}
|
|
7773
8416
|
this.mode = "menu";
|
|
7774
8417
|
this.options.tui.requestRender();
|
|
@@ -7784,7 +8427,7 @@ class JevFilterSubmenu {
|
|
|
7784
8427
|
return;
|
|
7785
8428
|
}
|
|
7786
8429
|
if (this.options.onSelection?.({ enabled }) === false) {
|
|
7787
|
-
this.notice = "The filter state could not be saved.";
|
|
8430
|
+
this.notice = t("jevSubmenu.filter.stateNotSaved", "The filter state could not be saved.");
|
|
7788
8431
|
this.options.tui.requestRender();
|
|
7789
8432
|
return;
|
|
7790
8433
|
}
|
|
@@ -7794,16 +8437,112 @@ class JevFilterSubmenu {
|
|
|
7794
8437
|
}
|
|
7795
8438
|
}
|
|
7796
8439
|
|
|
7797
|
-
// src/ui/
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
8440
|
+
// src/ui/settings-items-jev.ts
|
|
8441
|
+
var jevFilterRowValue = (settings) => {
|
|
8442
|
+
if (!settings.jevFilterEnabled) {
|
|
8443
|
+
return "Off";
|
|
7801
8444
|
}
|
|
7802
|
-
|
|
8445
|
+
return settings.jevClassifier ? "On" : t("settings.jevFilter.onUnavailable", "On (unavailable: no classifier)");
|
|
8446
|
+
};
|
|
8447
|
+
var jevItems = (settings, theme, tui, {
|
|
8448
|
+
jevClassifierRegistry,
|
|
8449
|
+
jevKeyDeps,
|
|
8450
|
+
onJevFilter,
|
|
8451
|
+
onJevProvider
|
|
8452
|
+
}) => [
|
|
8453
|
+
{
|
|
8454
|
+
currentValue: settings.jevClassifier ?? t("settings.jevProvider.choose", "Choose classifier"),
|
|
8455
|
+
description: t("settings.jevProvider.desc", "Select a Pi-authenticated classifier or explicitly configure the separate Jev API Key option."),
|
|
8456
|
+
id: "jevProvider",
|
|
8457
|
+
label: t("settings.jevProvider.label", "Jev classifier"),
|
|
8458
|
+
submenu: (currentValue, done) => new JevClassifierSubmenu({
|
|
8459
|
+
currentValue,
|
|
8460
|
+
done,
|
|
8461
|
+
keybindings: getKeybindings(),
|
|
8462
|
+
modelRegistry: jevClassifierRegistry,
|
|
8463
|
+
onSelection: onJevProvider,
|
|
8464
|
+
persistKey: jevKeyDeps?.persistClassifierKey,
|
|
8465
|
+
resolveStoredKey: jevKeyDeps?.resolveClassifierKey,
|
|
8466
|
+
restoreKey: jevKeyDeps?.restoreClassifierKey,
|
|
8467
|
+
theme,
|
|
8468
|
+
tui
|
|
8469
|
+
})
|
|
8470
|
+
},
|
|
8471
|
+
{
|
|
8472
|
+
currentValue: jevFilterRowValue(settings),
|
|
8473
|
+
description: t("settings.jevFilter.desc", "Screen low-stakes ask_advisor consultations with the selected Jev provider."),
|
|
8474
|
+
id: "jevFilter",
|
|
8475
|
+
label: t("settings.jevFilter.label", "Jev/Decisions consultation filter"),
|
|
8476
|
+
submenu: (currentValue, done) => new JevFilterSubmenu({
|
|
8477
|
+
currentClassifier: settings.jevClassifier,
|
|
8478
|
+
currentValue,
|
|
8479
|
+
done,
|
|
8480
|
+
modelRegistry: jevClassifierRegistry,
|
|
8481
|
+
onSelection: onJevFilter,
|
|
8482
|
+
resolveClassifierKey: jevKeyDeps?.resolveClassifierKey,
|
|
8483
|
+
theme,
|
|
8484
|
+
tui
|
|
8485
|
+
})
|
|
8486
|
+
},
|
|
8487
|
+
{
|
|
8488
|
+
currentValue: String(settings.jevFilterSkipConfidence ?? DEFAULT_JEV_FILTER_SKIP_CONFIDENCE),
|
|
8489
|
+
description: t("settings.jevFilterSkipConfidence.desc", "Required probability on negligible stakes before a consultation is skipped."),
|
|
8490
|
+
id: "jevFilterSkipConfidence",
|
|
8491
|
+
label: t("settings.jevFilterSkipConfidence.label", "Jev skip confidence"),
|
|
8492
|
+
values: numericValues(settings.jevFilterSkipConfidence ?? DEFAULT_JEV_FILTER_SKIP_CONFIDENCE, [0.6, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95])
|
|
8493
|
+
},
|
|
8494
|
+
{
|
|
8495
|
+
currentValue: String(settings.jevFilterNoulMargin ?? DEFAULT_JEV_FILTER_NOUL_MARGIN),
|
|
8496
|
+
description: t("settings.jevFilterNoulMargin.desc", "Extra margin over a coin flip required on self-answerability before skipping."),
|
|
8497
|
+
id: "jevFilterNoulMargin",
|
|
8498
|
+
label: t("settings.jevFilterNoulMargin.label", "Jev Noul margin"),
|
|
8499
|
+
values: numericValues(settings.jevFilterNoulMargin ?? DEFAULT_JEV_FILTER_NOUL_MARGIN, [0.1, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45])
|
|
8500
|
+
},
|
|
8501
|
+
{
|
|
8502
|
+
currentValue: `${settings.jevFilterOverrideWindow ?? DEFAULT_JEV_FILTER_OVERRIDE_WINDOW} ${t("settings.jev.turnsUnit", "turns")}`,
|
|
8503
|
+
description: t("settings.jevFilterOverrideWindow.desc", "Turns after a skip during which the same question passes automatically."),
|
|
8504
|
+
id: "jevFilterOverrideWindow",
|
|
8505
|
+
label: t("settings.jevFilterOverrideWindow.label", "Jev override window"),
|
|
8506
|
+
values: numericValues(settings.jevFilterOverrideWindow ?? DEFAULT_JEV_FILTER_OVERRIDE_WINDOW, [0, 3, 5, 10, 20, 50]).map((value) => `${value} ${t("settings.jev.turnsUnit", "turns")}`)
|
|
8507
|
+
},
|
|
8508
|
+
{
|
|
8509
|
+
currentValue: String(settings.jevTimeoutMs ?? DEFAULT_JEV_TIMEOUT_MS),
|
|
8510
|
+
description: t("settings.jevTimeoutMs.desc", "Total wall-time budget for one Jev call, including retries."),
|
|
8511
|
+
id: "jevTimeoutMs",
|
|
8512
|
+
label: t("settings.jevTimeoutMs.label", "Jev timeout ms"),
|
|
8513
|
+
values: numericValues(settings.jevTimeoutMs ?? DEFAULT_JEV_TIMEOUT_MS, [1000, 2000, 5000, 8000, 15000, 30000])
|
|
8514
|
+
},
|
|
8515
|
+
{
|
|
8516
|
+
currentValue: String(settings.jevDigestMaxChars ?? DEFAULT_JEV_DIGEST_MAX_CHARS),
|
|
8517
|
+
description: t("settings.jevDigestMaxChars.desc", "Conversation characters sent to Jev as screening evidence."),
|
|
8518
|
+
id: "jevDigestMaxChars",
|
|
8519
|
+
label: t("settings.jevDigestMaxChars.label", "Jev digest chars"),
|
|
8520
|
+
values: numericValues(settings.jevDigestMaxChars ?? DEFAULT_JEV_DIGEST_MAX_CHARS, [0, 1000, 2000, 4000, 8000, 15000])
|
|
8521
|
+
},
|
|
8522
|
+
{
|
|
8523
|
+
currentValue: settings.jevTurnGateEveryTurns === 0 || settings.jevTurnGateEveryTurns === undefined ? "Off" : `every ${settings.jevTurnGateEveryTurns} turns`,
|
|
8524
|
+
description: t("settings.jevTurnGateEveryTurns.desc", "Proactively consult the Advisor every N turns without a consultation (0 = off)."),
|
|
8525
|
+
id: "jevTurnGateEveryTurns",
|
|
8526
|
+
label: t("settings.jevTurnGateEveryTurns.label", "Jev/Decisions turn gate"),
|
|
8527
|
+
values: [
|
|
8528
|
+
"Off",
|
|
8529
|
+
"every 3 turns",
|
|
8530
|
+
"every 5 turns",
|
|
8531
|
+
"every 10 turns",
|
|
8532
|
+
"every 20 turns"
|
|
8533
|
+
]
|
|
8534
|
+
},
|
|
8535
|
+
{
|
|
8536
|
+
currentValue: String(settings.jevTurnGateNoulThreshold ?? DEFAULT_JEV_TURN_GATE_NOUL_THRESHOLD),
|
|
8537
|
+
description: t("settings.jevTurnGateNoulThreshold.desc", "Jev confidence required before the turn gate interrupts with advice."),
|
|
8538
|
+
id: "jevTurnGateNoulThreshold",
|
|
8539
|
+
label: t("settings.jevTurnGateNoulThreshold.label", "Jev/Decisions turn-gate threshold"),
|
|
8540
|
+
values: numericValues(settings.jevTurnGateNoulThreshold ?? DEFAULT_JEV_TURN_GATE_NOUL_THRESHOLD, [0.6, 0.7, 0.8, 0.85, 0.9, 0.95])
|
|
8541
|
+
}
|
|
8542
|
+
];
|
|
7803
8543
|
|
|
7804
8544
|
// src/ui/text-setting-submenu.ts
|
|
7805
8545
|
import { Input as Input4, truncateToWidth as truncateToWidth6 } from "@earendil-works/pi-tui";
|
|
7806
|
-
|
|
7807
8546
|
class TextSettingSubmenu {
|
|
7808
8547
|
input = new Input4;
|
|
7809
8548
|
options;
|
|
@@ -7848,7 +8587,7 @@ class TextSettingSubmenu {
|
|
|
7848
8587
|
if (this.error) {
|
|
7849
8588
|
lines.push(theme.fg("error", ` ${this.error}`));
|
|
7850
8589
|
}
|
|
7851
|
-
lines.push("", theme.fg("dim", "
|
|
8590
|
+
lines.push("", theme.fg("dim", ` ${t("textSetting.hint", "Enter: apply · Esc: cancel")}`));
|
|
7852
8591
|
return lines.map((line) => truncateToWidth6(line, width));
|
|
7853
8592
|
}
|
|
7854
8593
|
handleInput(keyData) {
|
|
@@ -7872,144 +8611,47 @@ var scoutTimeoutItem = (settings) => {
|
|
|
7872
8611
|
const timeoutMs = settings.scoutTimeoutMs ?? DEFAULT_SCOUT_TIMEOUT_MS;
|
|
7873
8612
|
return {
|
|
7874
8613
|
currentValue: String(timeoutMs),
|
|
7875
|
-
description: "Maximum time for Scout's response stream; model and auth resolution happen before this timeout starts.",
|
|
8614
|
+
description: t("settings.scoutTimeoutMs.desc", "Maximum time for Scout's response stream; model and auth resolution happen before this timeout starts."),
|
|
7876
8615
|
id: "scoutTimeoutMs",
|
|
7877
|
-
label: "Scout timeout ms",
|
|
8616
|
+
label: t("settings.scoutTimeoutMs.label", "Scout timeout ms"),
|
|
7878
8617
|
values: numericValues(timeoutMs, [5000, 1e4, 15000, 30000, 45000, 60000, 90000, 120000])
|
|
7879
8618
|
};
|
|
7880
8619
|
};
|
|
7881
|
-
var jevFilterRowValue = (settings) => {
|
|
7882
|
-
if (!settings.jevFilterEnabled) {
|
|
7883
|
-
return "Off";
|
|
7884
|
-
}
|
|
7885
|
-
return settings.jevClassifier ? "On" : "On (unavailable: no classifier)";
|
|
7886
|
-
};
|
|
7887
|
-
var jevItems = (settings, theme, tui, jevClassifierRegistry, jevKeyDeps, onJevFilter, onJevProvider) => [
|
|
7888
|
-
{
|
|
7889
|
-
currentValue: settings.jevClassifier ?? "Choose classifier",
|
|
7890
|
-
description: "Select a Pi-authenticated classifier or explicitly configure the separate Jev API Key option.",
|
|
7891
|
-
id: "jevProvider",
|
|
7892
|
-
label: "Jev classifier",
|
|
7893
|
-
submenu: (currentValue, done) => new JevClassifierSubmenu({
|
|
7894
|
-
currentValue,
|
|
7895
|
-
done,
|
|
7896
|
-
keybindings: getKeybindings(),
|
|
7897
|
-
modelRegistry: jevClassifierRegistry,
|
|
7898
|
-
onSelection: onJevProvider,
|
|
7899
|
-
persistKey: jevKeyDeps?.persistClassifierKey,
|
|
7900
|
-
resolveStoredKey: jevKeyDeps?.resolveClassifierKey,
|
|
7901
|
-
restoreKey: jevKeyDeps?.restoreClassifierKey,
|
|
7902
|
-
theme,
|
|
7903
|
-
tui
|
|
7904
|
-
})
|
|
7905
|
-
},
|
|
7906
|
-
{
|
|
7907
|
-
currentValue: jevFilterRowValue(settings),
|
|
7908
|
-
description: "Screen low-stakes ask_advisor consultations with the selected Jev provider.",
|
|
7909
|
-
id: "jevFilter",
|
|
7910
|
-
label: "Jev/Decisions consultation filter",
|
|
7911
|
-
submenu: (currentValue, done) => new JevFilterSubmenu({
|
|
7912
|
-
currentClassifier: settings.jevClassifier,
|
|
7913
|
-
currentValue,
|
|
7914
|
-
done,
|
|
7915
|
-
modelRegistry: jevClassifierRegistry,
|
|
7916
|
-
onSelection: onJevFilter,
|
|
7917
|
-
resolveClassifierKey: jevKeyDeps?.resolveClassifierKey,
|
|
7918
|
-
theme,
|
|
7919
|
-
tui
|
|
7920
|
-
})
|
|
7921
|
-
},
|
|
7922
|
-
{
|
|
7923
|
-
currentValue: String(settings.jevFilterSkipConfidence ?? DEFAULT_JEV_FILTER_SKIP_CONFIDENCE),
|
|
7924
|
-
description: "Required probability on negligible stakes before a consultation is skipped.",
|
|
7925
|
-
id: "jevFilterSkipConfidence",
|
|
7926
|
-
label: "Jev skip confidence",
|
|
7927
|
-
values: numericValues(settings.jevFilterSkipConfidence ?? DEFAULT_JEV_FILTER_SKIP_CONFIDENCE, [0.6, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95])
|
|
7928
|
-
},
|
|
7929
|
-
{
|
|
7930
|
-
currentValue: String(settings.jevFilterNoulMargin ?? DEFAULT_JEV_FILTER_NOUL_MARGIN),
|
|
7931
|
-
description: "Extra margin over a coin flip required on self-answerability before skipping.",
|
|
7932
|
-
id: "jevFilterNoulMargin",
|
|
7933
|
-
label: "Jev Noul margin",
|
|
7934
|
-
values: numericValues(settings.jevFilterNoulMargin ?? DEFAULT_JEV_FILTER_NOUL_MARGIN, [0.1, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45])
|
|
7935
|
-
},
|
|
7936
|
-
{
|
|
7937
|
-
currentValue: `${settings.jevFilterOverrideWindow ?? DEFAULT_JEV_FILTER_OVERRIDE_WINDOW} turns`,
|
|
7938
|
-
description: "Turns after a skip during which the same question passes automatically.",
|
|
7939
|
-
id: "jevFilterOverrideWindow",
|
|
7940
|
-
label: "Jev override window",
|
|
7941
|
-
values: numericValues(settings.jevFilterOverrideWindow ?? DEFAULT_JEV_FILTER_OVERRIDE_WINDOW, [0, 3, 5, 10, 20, 50]).map((value) => `${value} turns`)
|
|
7942
|
-
},
|
|
7943
|
-
{
|
|
7944
|
-
currentValue: String(settings.jevTimeoutMs ?? DEFAULT_JEV_TIMEOUT_MS),
|
|
7945
|
-
description: "Total wall-time budget for one Jev call, including retries.",
|
|
7946
|
-
id: "jevTimeoutMs",
|
|
7947
|
-
label: "Jev timeout ms",
|
|
7948
|
-
values: numericValues(settings.jevTimeoutMs ?? DEFAULT_JEV_TIMEOUT_MS, [1000, 2000, 5000, 8000, 15000, 30000])
|
|
7949
|
-
},
|
|
7950
|
-
{
|
|
7951
|
-
currentValue: String(settings.jevDigestMaxChars ?? DEFAULT_JEV_DIGEST_MAX_CHARS),
|
|
7952
|
-
description: "Conversation characters sent to Jev as screening evidence.",
|
|
7953
|
-
id: "jevDigestMaxChars",
|
|
7954
|
-
label: "Jev digest chars",
|
|
7955
|
-
values: numericValues(settings.jevDigestMaxChars ?? DEFAULT_JEV_DIGEST_MAX_CHARS, [0, 1000, 2000, 4000, 8000, 15000])
|
|
7956
|
-
},
|
|
7957
|
-
{
|
|
7958
|
-
currentValue: settings.jevTurnGateEveryTurns === 0 || settings.jevTurnGateEveryTurns === undefined ? "Off" : `every ${settings.jevTurnGateEveryTurns} turns`,
|
|
7959
|
-
description: "Proactively consult the Advisor every N turns without a consultation (0 = off).",
|
|
7960
|
-
id: "jevTurnGateEveryTurns",
|
|
7961
|
-
label: "Jev/Decisions turn gate",
|
|
7962
|
-
values: [
|
|
7963
|
-
"Off",
|
|
7964
|
-
"every 3 turns",
|
|
7965
|
-
"every 5 turns",
|
|
7966
|
-
"every 10 turns",
|
|
7967
|
-
"every 20 turns"
|
|
7968
|
-
]
|
|
7969
|
-
},
|
|
7970
|
-
{
|
|
7971
|
-
currentValue: String(settings.jevTurnGateNoulThreshold ?? DEFAULT_JEV_TURN_GATE_NOUL_THRESHOLD),
|
|
7972
|
-
description: "Jev confidence required before the turn gate interrupts with advice.",
|
|
7973
|
-
id: "jevTurnGateNoulThreshold",
|
|
7974
|
-
label: "Jev/Decisions turn-gate threshold",
|
|
7975
|
-
values: numericValues(settings.jevTurnGateNoulThreshold ?? DEFAULT_JEV_TURN_GATE_NOUL_THRESHOLD, [0.6, 0.7, 0.8, 0.85, 0.9, 0.95])
|
|
7976
|
-
}
|
|
7977
|
-
];
|
|
7978
8620
|
var advisorFallbackModelItem = (settings, modelRefs, keybindings, theme, tui) => ({
|
|
7979
8621
|
currentValue: settings.fallbackModel ?? FALLBACK_ADVISOR_MODEL_DISABLED,
|
|
7980
|
-
description: "Retry a failed Advisor request once with this optional model; the primary model remains unchanged.",
|
|
8622
|
+
description: t("settings.fallbackModel.desc", "Retry a failed Advisor request once with this optional model; the primary model remains unchanged."),
|
|
7981
8623
|
id: "fallbackModel",
|
|
7982
|
-
label: "Fallback Advisor model",
|
|
8624
|
+
label: t("settings.fallbackModel.label", "Fallback Advisor model"),
|
|
7983
8625
|
submenu: (_currentValue, done) => new SearchableModelSelector({
|
|
7984
8626
|
allOptions: [
|
|
7985
8627
|
FALLBACK_ADVISOR_MODEL_DISABLED,
|
|
7986
8628
|
...new Set(modelRefs ?? (settings.fallbackModel ? [settings.fallbackModel] : []))
|
|
7987
8629
|
],
|
|
7988
8630
|
currentOption: settings.fallbackModel ?? FALLBACK_ADVISOR_MODEL_DISABLED,
|
|
7989
|
-
keybindings: keybindings ??
|
|
8631
|
+
keybindings: keybindings ?? getKeybindings2(),
|
|
7990
8632
|
onCancel: done,
|
|
7991
8633
|
onSelect: (value) => done(value === FALLBACK_ADVISOR_MODEL_DISABLED ? "" : value),
|
|
7992
8634
|
theme,
|
|
7993
|
-
title: "Fallback Advisor model",
|
|
8635
|
+
title: t("settings.fallbackModel.label", "Fallback Advisor model"),
|
|
7994
8636
|
tui
|
|
7995
8637
|
})
|
|
7996
8638
|
});
|
|
7997
8639
|
var advisorModelWhitelistItem = (settings, modelRefs, keybindings, theme, tui) => ({
|
|
7998
|
-
currentValue: settings.modelWhitelist?.length ? settings.modelWhitelist.join(", ") : "Any model",
|
|
7999
|
-
description: "Only the exact provider/model references listed here may call the Advisor; an empty list allows every model.",
|
|
8640
|
+
currentValue: settings.modelWhitelist?.length ? settings.modelWhitelist.join(", ") : t("settings.modelWhitelist.any", "Any model"),
|
|
8641
|
+
description: t("settings.modelWhitelist.desc", "Only the exact provider/model references listed here may call the Advisor; an empty list allows every model."),
|
|
8000
8642
|
id: "modelWhitelist",
|
|
8001
|
-
label: "Advisor model whitelist",
|
|
8643
|
+
label: t("settings.modelWhitelist.label", "Advisor model whitelist"),
|
|
8002
8644
|
submenu: (_currentValue, done) => new SearchableModelMultiSelector({
|
|
8003
8645
|
allOptions: [
|
|
8004
8646
|
...new Set([...modelRefs ?? [], ...settings.modelWhitelist ?? []])
|
|
8005
8647
|
],
|
|
8006
8648
|
currentOptions: settings.modelWhitelist ?? [],
|
|
8007
|
-
keybindings: keybindings ??
|
|
8649
|
+
keybindings: keybindings ?? getKeybindings2(),
|
|
8008
8650
|
multiSelect: true,
|
|
8009
8651
|
onCancel: done,
|
|
8010
8652
|
onSelect: (values) => done(values.join(",")),
|
|
8011
8653
|
theme,
|
|
8012
|
-
title: "Advisor model whitelist",
|
|
8654
|
+
title: t("settings.modelWhitelist.label", "Advisor model whitelist"),
|
|
8013
8655
|
tui
|
|
8014
8656
|
})
|
|
8015
8657
|
});
|
|
@@ -8031,89 +8673,89 @@ var createSettingsItems = ({
|
|
|
8031
8673
|
currentValue: currentContextLabel(presets, settings.contextMaxChars),
|
|
8032
8674
|
description: contextDescription(presets, settings.contextMaxChars),
|
|
8033
8675
|
id: "context",
|
|
8034
|
-
label: "Context window",
|
|
8676
|
+
label: t("settings.context.label", "Context window"),
|
|
8035
8677
|
values: presets.map((preset) => preset.label)
|
|
8036
8678
|
},
|
|
8037
8679
|
{
|
|
8038
8680
|
currentValue: settingValue(settings.advisorToolsEnabled, true),
|
|
8039
|
-
description: "Allow the model to call the Advisor tools; /advisor-off disables them across sessions.",
|
|
8681
|
+
description: t("settings.advisorToolsEnabled.desc", "Allow the model to call the Advisor tools; /advisor-off disables them across sessions."),
|
|
8040
8682
|
id: "advisorToolsEnabled",
|
|
8041
|
-
label: "Advisor tools",
|
|
8683
|
+
label: t("settings.advisorToolsEnabled.label", "Advisor tools"),
|
|
8042
8684
|
values: TOGGLE_VALUES
|
|
8043
8685
|
},
|
|
8044
8686
|
{
|
|
8045
8687
|
currentValue: settingValue(settings.simpleMode, false),
|
|
8046
|
-
description: "Keep enabled Advisor tools available on demand without automatic gates or blocks.",
|
|
8688
|
+
description: t("settings.simpleMode.desc", "Keep enabled Advisor tools available on demand without automatic gates or blocks."),
|
|
8047
8689
|
id: "simpleMode",
|
|
8048
|
-
label: "Simple mode",
|
|
8690
|
+
label: t("settings.simpleMode.label", "Simple mode"),
|
|
8049
8691
|
values: TOGGLE_VALUES
|
|
8050
8692
|
},
|
|
8051
8693
|
{
|
|
8052
8694
|
currentValue: settingValue(settings.alwaysOn, false),
|
|
8053
|
-
description: "Run the Advisor flow automatically for supported agent turns.",
|
|
8695
|
+
description: t("settings.alwaysOn.desc", "Run the Advisor flow automatically for supported agent turns."),
|
|
8054
8696
|
id: "alwaysOn",
|
|
8055
|
-
label: "Always on",
|
|
8697
|
+
label: t("settings.alwaysOn.label", "Always on"),
|
|
8056
8698
|
values: TOGGLE_VALUES
|
|
8057
8699
|
},
|
|
8058
8700
|
fallbackModel
|
|
8059
8701
|
];
|
|
8060
8702
|
if (settings.simpleMode) {
|
|
8061
|
-
items.push(modelWhitelist, toggle("disableSameModel", "Disable same-model Advisor", "Skip advice when the active Executor and Advisor use the same provider/model; turn off to allow higher-effort same-model reviews.", settings.disableSameModel, true));
|
|
8703
|
+
items.push(modelWhitelist, toggle("disableSameModel", t("settings.disableSameModel.label", "Disable same-model Advisor"), t("settings.disableSameModel.desc", "Skip advice when the active Executor and Advisor use the same provider/model; turn off to allow higher-effort same-model reviews."), settings.disableSameModel, true));
|
|
8062
8704
|
return items;
|
|
8063
8705
|
}
|
|
8064
8706
|
items.push({
|
|
8065
8707
|
currentValue: currentEffort(settings.effort),
|
|
8066
|
-
description: "Reasoning level used for Advisor calls.",
|
|
8708
|
+
description: t("settings.effort.desc", "Reasoning level used for Advisor calls."),
|
|
8067
8709
|
id: "effort",
|
|
8068
|
-
label: "Advisor reasoning",
|
|
8710
|
+
label: t("settings.effort.label", "Advisor reasoning"),
|
|
8069
8711
|
values: withCurrentValue(currentEffort(settings.effort), effortLevels)
|
|
8070
|
-
}, modelWhitelist, toggle("disableSameModel", "Disable same-model Advisor", "Skip advice when the active Executor and Advisor use the same provider/model; turn off to allow higher-effort same-model reviews.", settings.disableSameModel, true), toggle("scoutEnabled", "Experimental Advisor Scout", "Enable the experimental Scout before Advisor calls.", settings.scoutEnabled, false), scoutTimeoutItem(settings), toggle("showUsageDetails", "Show usage and cost details", "Show token usage and cost details in Advisor responses.", settings.showUsageDetails, true), toggle("showUsageFooter", "Show usage in footer", "Show the current Advisor usage summary in the footer.", settings.showUsageFooter, false), toggle("planGate", "Plan gate", "Ask the Advisor to review implementation plans.", settings.planGate, true), toggle("failureGate", "Failure gate", "Ask the Advisor to review repeated failures.", settings.failureGate, true), toggle("completionGate", "Completion gate", "Ask the Advisor to review work before declaring success.", settings.completionGate, true), toggle("collapseResponses", "Collapse long responses", "Collapse long Advisor responses in the transcript.", settings.collapseResponses, false), {
|
|
8071
|
-
currentValue: settings.customRule || "None",
|
|
8072
|
-
description: "Add a rule that triggers Advisor involvement.",
|
|
8712
|
+
}, modelWhitelist, toggle("disableSameModel", t("settings.disableSameModel.label", "Disable same-model Advisor"), t("settings.disableSameModel.desc", "Skip advice when the active Executor and Advisor use the same provider/model; turn off to allow higher-effort same-model reviews."), settings.disableSameModel, true), toggle("scoutEnabled", t("settings.scoutEnabled.label", "Experimental Advisor Scout"), t("settings.scoutEnabled.desc", "Enable the experimental Scout before Advisor calls."), settings.scoutEnabled, false), scoutTimeoutItem(settings), toggle("showUsageDetails", t("settings.showUsageDetails.label", "Show usage and cost details"), t("settings.showUsageDetails.desc", "Show token usage and cost details in Advisor responses."), settings.showUsageDetails, true), toggle("showUsageFooter", t("settings.showUsageFooter.label", "Show usage in footer"), t("settings.showUsageFooter.desc", "Show the current Advisor usage summary in the footer."), settings.showUsageFooter, false), toggle("planGate", t("settings.planGate.label", "Plan gate"), t("settings.planGate.desc", "Ask the Advisor to review implementation plans."), settings.planGate, true), toggle("failureGate", t("settings.failureGate.label", "Failure gate"), t("settings.failureGate.desc", "Ask the Advisor to review repeated failures."), settings.failureGate, true), toggle("completionGate", t("settings.completionGate.label", "Completion gate"), t("settings.completionGate.desc", "Ask the Advisor to review work before declaring success."), settings.completionGate, true), toggle("collapseResponses", t("settings.collapseResponses.label", "Collapse long responses"), t("settings.collapseResponses.desc", "Collapse long Advisor responses in the transcript."), settings.collapseResponses, false), {
|
|
8713
|
+
currentValue: settings.customRule || t("settings.none", "None"),
|
|
8714
|
+
description: t("settings.customRule.desc", "Add a rule that triggers Advisor involvement."),
|
|
8073
8715
|
id: "customRule",
|
|
8074
|
-
label: "Custom invocation",
|
|
8716
|
+
label: t("settings.customRule.label", "Custom invocation"),
|
|
8075
8717
|
submenu: (_currentValue, done) => new TextSettingSubmenu({
|
|
8076
|
-
description: "Enter a custom invocation rule.",
|
|
8718
|
+
description: t("settings.customRule.submenuDesc", "Enter a custom invocation rule."),
|
|
8077
8719
|
initial: settings.customRule || "",
|
|
8078
8720
|
onCancel: done,
|
|
8079
8721
|
onSubmit: (value) => ({ value: value.trim() }),
|
|
8080
8722
|
theme,
|
|
8081
|
-
title: "Custom invocation",
|
|
8723
|
+
title: t("settings.customRule.label", "Custom invocation"),
|
|
8082
8724
|
tui
|
|
8083
8725
|
})
|
|
8084
|
-
}, toggle("blockOnBlocked", "Block on critical advice", "Block the agent when the Advisor returns a critical decision.", settings.blockOnBlocked, true), toggle("autoLoopGate", "Automatic loop gate", "Ask the Advisor to review repeated equivalent attempts.", settings.autoLoopGate, true), {
|
|
8085
|
-
currentValue:
|
|
8086
|
-
description: "Number of equivalent attempts before automatic review.",
|
|
8726
|
+
}, toggle("blockOnBlocked", t("settings.blockOnBlocked.label", "Block on critical advice"), t("settings.blockOnBlocked.desc", "Block the agent when the Advisor returns a critical decision."), settings.blockOnBlocked, true), toggle("autoLoopGate", t("settings.autoLoopGate.label", "Automatic loop gate"), t("settings.autoLoopGate.desc", "Ask the Advisor to review repeated equivalent attempts."), settings.autoLoopGate, true), {
|
|
8727
|
+
currentValue: `${t("settings.loopThreshold.after", "After")} ${settings.loopThreshold ?? 3} ${t("settings.loopThreshold.repeats", "repeats")}`,
|
|
8728
|
+
description: t("settings.loopThreshold.desc", "Number of equivalent attempts before automatic review."),
|
|
8087
8729
|
id: "loopThreshold",
|
|
8088
|
-
label: "Loop threshold",
|
|
8089
|
-
values: numericValues(settings.loopThreshold ?? 3, Array.from({ length: 99 }, (_, index) => index + 2)).map((value) =>
|
|
8730
|
+
label: t("settings.loopThreshold.label", "Loop threshold"),
|
|
8731
|
+
values: numericValues(settings.loopThreshold ?? 3, Array.from({ length: 99 }, (_, index) => index + 2)).map((value) => `${t("settings.loopThreshold.after", "After")} ${value} ${t("settings.loopThreshold.repeats", "repeats")}`)
|
|
8090
8732
|
}, {
|
|
8091
8733
|
currentValue: settings.maxCallsPerSession === undefined ? "∞" : String(settings.maxCallsPerSession),
|
|
8092
|
-
description: "Limit automatic Advisor calls in one session.",
|
|
8734
|
+
description: t("settings.maxCallsPerSession.desc", "Limit automatic Advisor calls in one session."),
|
|
8093
8735
|
id: "maxCallsPerSession",
|
|
8094
|
-
label: "Max Advisor calls/session",
|
|
8736
|
+
label: t("settings.maxCallsPerSession.label", "Max Advisor calls/session"),
|
|
8095
8737
|
values: maxCallValues(settings.maxCallsPerSession === undefined ? "∞" : String(settings.maxCallsPerSession))
|
|
8096
|
-
}, toggle("sessionSummary", "Session Advisor Summary", "Show a local summary when the session ends.", settings.sessionSummary, false), toggle("logFeedback", "Advisor log feedback", "Include budget and Scout status messages in session logs. Actual Advisor calls and results remain visible either way.", settings.logFeedback, false), {
|
|
8738
|
+
}, toggle("sessionSummary", t("settings.sessionSummary.label", "Session Advisor Summary"), t("settings.sessionSummary.desc", "Show a local summary when the session ends."), settings.sessionSummary, false), toggle("logFeedback", t("settings.logFeedback.label", "Advisor log feedback"), t("settings.logFeedback.desc", "Include budget and Scout status messages in session logs. Actual Advisor calls and results remain visible either way."), settings.logFeedback, false), {
|
|
8097
8739
|
currentValue: settings.failureMode ?? "block-session",
|
|
8098
|
-
description: "Choose what happens when an Advisor gate fails.",
|
|
8740
|
+
description: t("settings.failureMode.desc", "Choose what happens when an Advisor gate fails."),
|
|
8099
8741
|
id: "failureMode",
|
|
8100
|
-
label: "Gate failure mode",
|
|
8742
|
+
label: t("settings.failureMode.label", "Gate failure mode"),
|
|
8101
8743
|
values: withCurrentValue(settings.failureMode ?? "block-session", [
|
|
8102
8744
|
"block-session",
|
|
8103
8745
|
"block-tool",
|
|
8104
8746
|
"warn-and-continue"
|
|
8105
8747
|
])
|
|
8106
|
-
}, toggle("herdrIntegration", "Herdr integration", "Send Advisor activity to the optional Herdr integration.", settings.herdrIntegration, true), {
|
|
8748
|
+
}, toggle("herdrIntegration", t("settings.herdrIntegration.label", "Herdr integration"), t("settings.herdrIntegration.desc", "Send Advisor activity to the optional Herdr integration."), settings.herdrIntegration, true), {
|
|
8107
8749
|
currentValue: String(settings.toolResultMaxLines ?? 2000),
|
|
8108
|
-
description: "Maximum lines included from a tool result.",
|
|
8750
|
+
description: t("settings.toolResultMaxLines.desc", "Maximum lines included from a tool result."),
|
|
8109
8751
|
id: "toolResultMaxLines",
|
|
8110
|
-
label: "Tool result lines",
|
|
8752
|
+
label: t("settings.toolResultMaxLines.label", "Tool result lines"),
|
|
8111
8753
|
values: numericValues(settings.toolResultMaxLines ?? 2000, [0, 500, 1000, 2000, 5000, 1e4])
|
|
8112
8754
|
}, {
|
|
8113
8755
|
currentValue: String(settings.toolResultMaxBytes ?? 50 * 1024),
|
|
8114
|
-
description: "Maximum bytes included from a tool result.",
|
|
8756
|
+
description: t("settings.toolResultMaxBytes.desc", "Maximum bytes included from a tool result."),
|
|
8115
8757
|
id: "toolResultMaxBytes",
|
|
8116
|
-
label: "Tool result bytes",
|
|
8758
|
+
label: t("settings.toolResultMaxBytes.label", "Tool result bytes"),
|
|
8117
8759
|
values: numericValues(settings.toolResultMaxBytes ?? 50 * 1024, [
|
|
8118
8760
|
0,
|
|
8119
8761
|
10 * 1024,
|
|
@@ -8121,11 +8763,11 @@ var createSettingsItems = ({
|
|
|
8121
8763
|
100 * 1024,
|
|
8122
8764
|
500 * 1024
|
|
8123
8765
|
])
|
|
8124
|
-
}, toggle("redactSecrets", "Redact common secrets", "Redact common credential patterns before Advisor calls.", settings.redactSecrets, false), toggle("agentsMdContext", "AGENTS.md context", "Include trusted project and global AGENTS.md rules in Advisor calls.", settings.agentsMdContext, true), {
|
|
8766
|
+
}, toggle("redactSecrets", t("settings.redactSecrets.label", "Redact common secrets"), t("settings.redactSecrets.desc", "Redact common credential patterns before Advisor calls."), settings.redactSecrets, false), toggle("agentsMdContext", t("settings.agentsMdContext.label", "AGENTS.md context"), t("settings.agentsMdContext.desc", "Include trusted project and global AGENTS.md rules in Advisor calls."), settings.agentsMdContext, true), {
|
|
8125
8767
|
currentValue: settings.gitContext ?? "summary",
|
|
8126
|
-
description: "How much repository context is shared with the Advisor.",
|
|
8768
|
+
description: t("settings.gitContext.desc", "How much repository context is shared with the Advisor."),
|
|
8127
8769
|
id: "gitContext",
|
|
8128
|
-
label: "Repository context",
|
|
8770
|
+
label: t("settings.gitContext.label", "Repository context"),
|
|
8129
8771
|
values: withCurrentValue(settings.gitContext ?? "summary", [
|
|
8130
8772
|
"off",
|
|
8131
8773
|
"summary",
|
|
@@ -8133,17 +8775,17 @@ var createSettingsItems = ({
|
|
|
8133
8775
|
])
|
|
8134
8776
|
}, {
|
|
8135
8777
|
currentValue: String(settings.gitContextMaxChars ?? 20000),
|
|
8136
|
-
description: "Maximum repository context characters included.",
|
|
8778
|
+
description: t("settings.gitContextMaxChars.desc", "Maximum repository context characters included."),
|
|
8137
8779
|
id: "gitContextMaxChars",
|
|
8138
|
-
label: "Repository context chars",
|
|
8780
|
+
label: t("settings.gitContextMaxChars.label", "Repository context chars"),
|
|
8139
8781
|
values: numericValues(settings.gitContextMaxChars ?? 20000, [0, 5000, 1e4, 20000, 50000, 1e5])
|
|
8140
8782
|
}, {
|
|
8141
|
-
currentValue: Object.keys(settings.toolPolicies ?? {}).length ? "Configured" : "All tools: full",
|
|
8142
|
-
description: "Choose which tools are shared in full, summarized, or excluded.",
|
|
8783
|
+
currentValue: Object.keys(settings.toolPolicies ?? {}).length ? t("settings.toolPolicies.configured", "Configured") : t("settings.toolPolicies.allToolsFull", "All tools: full"),
|
|
8784
|
+
description: t("settings.toolPolicies.desc", "Choose which tools are shared in full, summarized, or excluded."),
|
|
8143
8785
|
id: "toolPolicies",
|
|
8144
|
-
label: "Tool disclosure policies",
|
|
8786
|
+
label: t("settings.toolPolicies.label", "Tool disclosure policies"),
|
|
8145
8787
|
submenu: (_currentValue, done) => new TextSettingSubmenu({
|
|
8146
|
-
description: 'Enter a JSON object with "full", "summary", or "exclude" values.',
|
|
8788
|
+
description: t("settings.toolPolicies.submenuDesc", 'Enter a JSON object with "full", "summary", or "exclude" values.'),
|
|
8147
8789
|
initial: JSON.stringify(settings.toolPolicies ?? {}),
|
|
8148
8790
|
onCancel: done,
|
|
8149
8791
|
onSubmit: (value) => {
|
|
@@ -8151,20 +8793,27 @@ var createSettingsItems = ({
|
|
|
8151
8793
|
try {
|
|
8152
8794
|
parsed = JSON.parse(value || "{}");
|
|
8153
8795
|
} catch {
|
|
8154
|
-
return {
|
|
8796
|
+
return {
|
|
8797
|
+
error: t("settings.toolPolicies.invalidJson", "Enter a valid JSON object.")
|
|
8798
|
+
};
|
|
8155
8799
|
}
|
|
8156
8800
|
if (!isValidAdvisorToolPolicies(parsed)) {
|
|
8157
8801
|
return {
|
|
8158
|
-
error: "Use non-empty tool names with full, summary, or exclude values."
|
|
8802
|
+
error: t("settings.toolPolicies.invalidPolicies", "Use non-empty tool names with full, summary, or exclude values.")
|
|
8159
8803
|
};
|
|
8160
8804
|
}
|
|
8161
8805
|
return { value: JSON.stringify(parsed) };
|
|
8162
8806
|
},
|
|
8163
8807
|
theme,
|
|
8164
|
-
title: "Tool disclosure policies",
|
|
8808
|
+
title: t("settings.toolPolicies.label", "Tool disclosure policies"),
|
|
8165
8809
|
tui
|
|
8166
8810
|
})
|
|
8167
|
-
}, toggle("trackedFileContent", "Tracked file content", "Allow tracked file contents to be sent with Advisor context.", settings.trackedFileContent, false), toggle("untrackedContent", "Untracked file content", "Allow untracked file contents to be sent with Advisor context.", settings.untrackedContent, false), toggle("outcomeLogging", "Outcome logging (global)", "Allow anonymized Advisor outcomes to be logged globally.", settings.outcomeLogging, false), ...jevItems(settings, theme, tui,
|
|
8811
|
+
}, toggle("trackedFileContent", t("settings.trackedFileContent.label", "Tracked file content"), t("settings.trackedFileContent.desc", "Allow tracked file contents to be sent with Advisor context."), settings.trackedFileContent, false), toggle("untrackedContent", t("settings.untrackedContent.label", "Untracked file content"), t("settings.untrackedContent.desc", "Allow untracked file contents to be sent with Advisor context."), settings.untrackedContent, false), toggle("outcomeLogging", t("settings.outcomeLogging.label", "Outcome logging (global)"), t("settings.outcomeLogging.desc", "Allow anonymized Advisor outcomes to be logged globally."), settings.outcomeLogging, false), ...jevItems(settings, theme, tui, {
|
|
8812
|
+
jevClassifierRegistry,
|
|
8813
|
+
jevKeyDeps,
|
|
8814
|
+
onJevFilter,
|
|
8815
|
+
onJevProvider
|
|
8816
|
+
}));
|
|
8168
8817
|
return items;
|
|
8169
8818
|
};
|
|
8170
8819
|
|
|
@@ -8439,7 +9088,7 @@ class AdvisorSettingsSelector {
|
|
|
8439
9088
|
this.presets = options.presets.some((preset) => preset.value === configuredContext) ? [...options.presets] : [
|
|
8440
9089
|
...options.presets,
|
|
8441
9090
|
{
|
|
8442
|
-
description: "Current custom context limit",
|
|
9091
|
+
description: t("settingsSubmenu.customContextLimit", "Current custom context limit"),
|
|
8443
9092
|
label: String(configuredContext),
|
|
8444
9093
|
value: configuredContext
|
|
8445
9094
|
}
|
|
@@ -8470,7 +9119,7 @@ class AdvisorSettingsSelector {
|
|
|
8470
9119
|
const defaultLabel = listTheme.label;
|
|
8471
9120
|
listTheme.label = (text, selected) => {
|
|
8472
9121
|
if (this.settings.simpleMode && text.startsWith("Simple mode")) {
|
|
8473
|
-
return `${rainbowGradient("Simple mode", this.simpleModeGradientStartedAt ?? 0)}${text.slice("Simple mode".length)}`;
|
|
9122
|
+
return `${rainbowGradient(t("settings.simpleMode.label", "Simple mode"), this.simpleModeGradientStartedAt ?? 0)}${text.slice("Simple mode".length)}`;
|
|
8474
9123
|
}
|
|
8475
9124
|
return defaultLabel(text, selected);
|
|
8476
9125
|
};
|
|
@@ -8674,7 +9323,7 @@ var persistJevSettings = (ctx, settings, runtime) => {
|
|
|
8674
9323
|
saveAdvisorSettings(ctx, settings, { skipOutcomeLogging: true });
|
|
8675
9324
|
} catch (error) {
|
|
8676
9325
|
const message = error instanceof Error ? error.message : String(error);
|
|
8677
|
-
ctx.ui.notify(
|
|
9326
|
+
ctx.ui.notify(`${t("settingsCmd.saveFailed.prefix", "Could not save Advisor settings:")} ${message}`, "error");
|
|
8678
9327
|
return false;
|
|
8679
9328
|
}
|
|
8680
9329
|
try {
|
|
@@ -8683,7 +9332,7 @@ var persistJevSettings = (ctx, settings, runtime) => {
|
|
|
8683
9332
|
runtime.updateAdvisorUsageStatus(ctx);
|
|
8684
9333
|
} catch (error) {
|
|
8685
9334
|
const message = error instanceof Error ? error.message : String(error);
|
|
8686
|
-
ctx.ui.notify(
|
|
9335
|
+
ctx.ui.notify(`${t("settingsCmd.refreshFailed.prefix", "Advisor settings were saved, but the status refresh failed:")} ${message}`, "warning");
|
|
8687
9336
|
}
|
|
8688
9337
|
return true;
|
|
8689
9338
|
};
|
|
@@ -8728,7 +9377,7 @@ var registerSettingsCommands = (runtime) => {
|
|
|
8728
9377
|
runtime.resetSameModelNotice();
|
|
8729
9378
|
}
|
|
8730
9379
|
const message = error instanceof Error ? error.message : String(error);
|
|
8731
|
-
ctx.ui.notify(toolsDisabled ?
|
|
9380
|
+
ctx.ui.notify(toolsDisabled ? `${t("settingsCmd.saveFailedToolsDisabled.prefix", "Could not save Advisor settings; tools remain disabled for this session.")} ${message}` : `${t("settingsCmd.saveFailed.prefix", "Could not save Advisor settings:")} ${message}`, "error");
|
|
8732
9381
|
}
|
|
8733
9382
|
},
|
|
8734
9383
|
onJevFilter: (_selection, settings) => persistJevSettings(ctx, settings, runtime),
|
|
@@ -8751,7 +9400,7 @@ var registerSettingsCommands = (runtime) => {
|
|
|
8751
9400
|
setAdvisorToolsEnabledRef(false);
|
|
8752
9401
|
setAlwaysOnRef(false);
|
|
8753
9402
|
const message = error instanceof Error ? error.message : String(error);
|
|
8754
|
-
notify(ctx,
|
|
9403
|
+
notify(ctx, `${t("settingsCmd.offReloadFailed.prefix", "Advisor tools disabled for this session, but configuration could not be reloaded:")} ${message}`, "error");
|
|
8755
9404
|
return Promise.resolve();
|
|
8756
9405
|
}
|
|
8757
9406
|
const wasAlwaysOn = alwaysOnRef;
|
|
@@ -8767,10 +9416,10 @@ var registerSettingsCommands = (runtime) => {
|
|
|
8767
9416
|
});
|
|
8768
9417
|
} catch (error) {
|
|
8769
9418
|
const message = error instanceof Error ? error.message : String(error);
|
|
8770
|
-
notify(ctx,
|
|
9419
|
+
notify(ctx, `${t("settingsCmd.offSaveFailed.prefix", "Advisor tools disabled for this session, but the setting could not be saved:")} ${message}`, "error");
|
|
8771
9420
|
return Promise.resolve();
|
|
8772
9421
|
}
|
|
8773
|
-
notify(ctx,
|
|
9422
|
+
notify(ctx, `${t("settingsCmd.off.message", "Advisor tools disabled. Current model unchanged.")}${wasAlwaysOn ? ` ${t("settingsCmd.off.alwaysOnTurnedOff", "Always on turned off.")}` : ""}`, "info");
|
|
8774
9423
|
return Promise.resolve();
|
|
8775
9424
|
}
|
|
8776
9425
|
});
|
|
@@ -8786,6 +9435,7 @@ var registerCommands = (pi, dependencies = {}) => {
|
|
|
8786
9435
|
registerModelCommands(runtime);
|
|
8787
9436
|
registerOutcomeStatsCommand(runtime);
|
|
8788
9437
|
registerSettingsCommands(runtime);
|
|
9438
|
+
registerAdvisorConfigurationTool(runtime);
|
|
8789
9439
|
};
|
|
8790
9440
|
|
|
8791
9441
|
// src/tools/budget-feedback.ts
|
|
@@ -8833,7 +9483,8 @@ var updateAdvisorUsageStatus = (ctx, session) => {
|
|
|
8833
9483
|
};
|
|
8834
9484
|
var notifyLocalFailure = (ctx, message, sessionBlocked = false) => {
|
|
8835
9485
|
if (ctx.hasUI) {
|
|
8836
|
-
|
|
9486
|
+
const prefix = sessionBlocked ? t("notify.localFailure.blockedPrefix", "Advisor gate failure; session blocked:") : t("notify.localFailure.failedPrefix", "Advisor consultation failed:");
|
|
9487
|
+
ctx.ui.notify(`${prefix} ${message}`, "error");
|
|
8837
9488
|
}
|
|
8838
9489
|
};
|
|
8839
9490
|
var gateFailureEffectForMode = (mode) => {
|
|
@@ -8868,7 +9519,7 @@ var failureEffect = (category, message, ctx, session, failureMode, herdrBlock =
|
|
|
8868
9519
|
var blockedDecisionEffect = (reason, ctx, session, failureMode, herdrBlock = herdrAdvisorBlock) => {
|
|
8869
9520
|
if (failureMode === "warn-and-continue") {
|
|
8870
9521
|
if (ctx.hasUI) {
|
|
8871
|
-
ctx.ui.notify("Advisor gate returned blocked; continuing by configuration.", "warning");
|
|
9522
|
+
ctx.ui.notify(t("notify.gateBlockedContinued.message", "Advisor gate returned blocked; continuing by configuration."), "warning");
|
|
8872
9523
|
}
|
|
8873
9524
|
return { block: false, effect: "continued", reason };
|
|
8874
9525
|
}
|
|
@@ -8899,7 +9550,7 @@ var reserveAdvisorCall = (event, ctx, session, reservedCalls) => {
|
|
|
8899
9550
|
};
|
|
8900
9551
|
|
|
8901
9552
|
// src/tools/jev-turn-gate.ts
|
|
8902
|
-
var outageNotifier2 = createOutageNotifier((category, message) =>
|
|
9553
|
+
var outageNotifier2 = createOutageNotifier((category, message) => `${t("notify.jevTurnGateOutage.prefix", "Advisor Jev classifier turn gate failed")} (${category}); ${t("notify.jevTurnGateOutage.continuing", "continuing without a proactive consultation.")} ${message}`);
|
|
8903
9554
|
var notifyFailureOnce = outageNotifier2.notify;
|
|
8904
9555
|
var shouldRunTurnGate = (registration, ctx, session) => {
|
|
8905
9556
|
const interval = advisorJevTurnGateEveryTurnsRef;
|
|
@@ -9000,36 +9651,36 @@ var registerJevTurnGate = (on, registration) => {
|
|
|
9000
9651
|
};
|
|
9001
9652
|
|
|
9002
9653
|
// src/tools/register-ask-advisor.ts
|
|
9003
|
-
import { Type as
|
|
9654
|
+
import { Type as Type3 } from "typebox";
|
|
9004
9655
|
|
|
9005
9656
|
// src/tools/advisor-output.ts
|
|
9006
|
-
import { Type } from "typebox";
|
|
9007
|
-
var advisorOutputSchema =
|
|
9008
|
-
adviceId:
|
|
9009
|
-
advisor:
|
|
9010
|
-
followUp:
|
|
9011
|
-
jev:
|
|
9012
|
-
kind:
|
|
9013
|
-
reason:
|
|
9014
|
-
skipped:
|
|
9657
|
+
import { Type as Type2 } from "typebox";
|
|
9658
|
+
var advisorOutputSchema = Type2.Object({
|
|
9659
|
+
adviceId: Type2.Optional(Type2.String()),
|
|
9660
|
+
advisor: Type2.Optional(Type2.String()),
|
|
9661
|
+
followUp: Type2.Optional(Type2.Boolean()),
|
|
9662
|
+
jev: Type2.Optional(Type2.Object({
|
|
9663
|
+
kind: Type2.Union([Type2.Literal("screened"), Type2.Literal("repeat")]),
|
|
9664
|
+
reason: Type2.String(),
|
|
9665
|
+
skipped: Type2.Boolean()
|
|
9015
9666
|
})),
|
|
9016
|
-
skipReason:
|
|
9017
|
-
text:
|
|
9667
|
+
skipReason: Type2.Optional(Type2.String()),
|
|
9668
|
+
text: Type2.String({
|
|
9018
9669
|
description: "Advisor Markdown or consultation skip notice."
|
|
9019
9670
|
}),
|
|
9020
|
-
usage:
|
|
9021
|
-
cacheRead:
|
|
9022
|
-
cacheWrite:
|
|
9023
|
-
cost:
|
|
9024
|
-
input:
|
|
9025
|
-
output:
|
|
9026
|
-
totalTokens:
|
|
9671
|
+
usage: Type2.Optional(Type2.Object({
|
|
9672
|
+
cacheRead: Type2.Optional(Type2.Number()),
|
|
9673
|
+
cacheWrite: Type2.Optional(Type2.Number()),
|
|
9674
|
+
cost: Type2.Optional(Type2.Number()),
|
|
9675
|
+
input: Type2.Optional(Type2.Number()),
|
|
9676
|
+
output: Type2.Optional(Type2.Number()),
|
|
9677
|
+
totalTokens: Type2.Optional(Type2.Number())
|
|
9027
9678
|
}))
|
|
9028
9679
|
});
|
|
9029
9680
|
|
|
9030
9681
|
// src/tools/render-advisor-result.ts
|
|
9031
9682
|
import { getMarkdownTheme as getMarkdownTheme4 } from "@earendil-works/pi-coding-agent";
|
|
9032
|
-
import { Box as Box3, Markdown as Markdown4, Spacer, Text as
|
|
9683
|
+
import { Box as Box3, Markdown as Markdown4, Spacer, Text as Text6 } from "@earendil-works/pi-tui";
|
|
9033
9684
|
var advisorResultDetails = (result) => result.details;
|
|
9034
9685
|
var syncRenderPhase = (context, phase) => {
|
|
9035
9686
|
if (context.state.phase !== phase && context.state.timerId) {
|
|
@@ -9066,17 +9717,17 @@ var attachmentLabels = (details) => [
|
|
|
9066
9717
|
details?.agentRulesBytes ? `AGENTS.md rules attached · ${formatByteSize2(details.agentRulesBytes)}` : undefined,
|
|
9067
9718
|
details?.draftBytes ? `Draft attached · ${formatByteSize2(details.draftBytes)}` : undefined,
|
|
9068
9719
|
details?.preferenceBytes ? `Project preferences attached · ${formatByteSize2(details.preferenceBytes)}` : undefined,
|
|
9069
|
-
details?.trackedBytes ?
|
|
9070
|
-
details?.untrackedBytes ?
|
|
9071
|
-
details?.imageCount ? `${details.imageCount}
|
|
9720
|
+
details?.trackedBytes ? `${t("render.trackedAttached", "Tracked files attached")} · ${formatByteSize2(details.trackedBytes)}` : undefined,
|
|
9721
|
+
details?.untrackedBytes ? `${t("render.untrackedAttached", "Untracked files attached")} · ${formatByteSize2(details.untrackedBytes)}` : undefined,
|
|
9722
|
+
details?.imageCount ? `${details.imageCount} ${details.imageCount === 1 ? t("render.image", "image") : t("render.images", "images")} ${t("render.attached", "attached")}${details.imageBytes ? ` · ${formatByteSize2(details.imageBytes)}` : ""}${details.imageOmissions ? ` · ${details.imageOmissions} ${t("render.withheld", "withheld")}` : ""}` : undefined
|
|
9072
9723
|
].filter((label) => label !== undefined);
|
|
9073
9724
|
var renderSkipBox = (box, result, expanded, theme) => {
|
|
9074
9725
|
const details = advisorResultDetails(result);
|
|
9075
9726
|
const lines = [
|
|
9076
|
-
theme.fg("dim", theme.bold(
|
|
9727
|
+
theme.fg("dim", theme.bold(`◆ ADVISOR · ${t("render.skipped", "SKIPPED")}`)),
|
|
9077
9728
|
theme.fg("dim", ` ${details?.skipReason ?? details?.jev?.reason ?? ""}`)
|
|
9078
9729
|
];
|
|
9079
|
-
box.addChild(new
|
|
9730
|
+
box.addChild(new Text6(lines.join(`
|
|
9080
9731
|
`), 0, 0));
|
|
9081
9732
|
box.addChild(new Markdown4(adviceForDisplay(textFrom(result.content), expanded), 0, 0, getMarkdownTheme4()));
|
|
9082
9733
|
};
|
|
@@ -9099,9 +9750,9 @@ var renderPartialAdvisorResult = (box, result, expanded, theme, context) => {
|
|
|
9099
9750
|
}
|
|
9100
9751
|
const frame = SPINNER_FRAMES[Math.floor(Date.now() / 80) % SPINNER_FRAMES.length];
|
|
9101
9752
|
const lines = [
|
|
9102
|
-
`${theme.fg("warning", theme.bold(`◆ ADVISOR ${frame}`))} ${theme.fg("dim", "
|
|
9753
|
+
`${theme.fg("warning", theme.bold(`◆ ADVISOR ${frame}`))} ${theme.fg("dim", `· ${t("render.working", "Working…")}`)}`
|
|
9103
9754
|
];
|
|
9104
|
-
box.addChild(new
|
|
9755
|
+
box.addChild(new Text6(lines.join(`
|
|
9105
9756
|
`), 0, 0));
|
|
9106
9757
|
if (details?.thinking?.trim()) {
|
|
9107
9758
|
const thought = details.thinking.length > 200 ? details.thinking.slice(-200) : details.thinking;
|
|
@@ -9115,7 +9766,7 @@ var thinkingPreview = (details) => details?.thinking?.trim() ? `${details.thinki
|
|
|
9115
9766
|
var finalResultLines = (details, advice, theme) => {
|
|
9116
9767
|
const lines = [renderAdvisorResponseHeader(hasSoundVerdict(advice), theme)];
|
|
9117
9768
|
if (details?.followUp) {
|
|
9118
|
-
lines.push(theme.fg("dim", "
|
|
9769
|
+
lines.push(theme.fg("dim", ` ${t("render.followUpConsultation", "Follow-up consultation")}`));
|
|
9119
9770
|
}
|
|
9120
9771
|
if (details?.advisor) {
|
|
9121
9772
|
lines.push(theme.fg("dim", ` ${details.advisor}`));
|
|
@@ -9123,7 +9774,7 @@ var finalResultLines = (details, advice, theme) => {
|
|
|
9123
9774
|
if (getAdvisorSettings().showUsageDetails) {
|
|
9124
9775
|
const usage = formatAdvisorUsage(details?.usage);
|
|
9125
9776
|
if (usage) {
|
|
9126
|
-
lines.push(theme.fg("dim", ` Usage: ${usage}`));
|
|
9777
|
+
lines.push(theme.fg("dim", ` ${t("render.usage", "Usage:")} ${usage}`));
|
|
9127
9778
|
}
|
|
9128
9779
|
}
|
|
9129
9780
|
const attachments = attachmentLabels(details);
|
|
@@ -9156,8 +9807,8 @@ var renderFinalAdvisorResult = (box, result, expanded, theme, context) => {
|
|
|
9156
9807
|
const advice = details?.text || textFrom(result.content);
|
|
9157
9808
|
const thinking = thinkingPreview(details);
|
|
9158
9809
|
const lines = finalResultLines(details, advice, theme);
|
|
9159
|
-
const displayAdvice = advice || "(Advisor returned no advice.)";
|
|
9160
|
-
box.addChild(new
|
|
9810
|
+
const displayAdvice = advice || t("render.noAdvice", "(Advisor returned no advice.)");
|
|
9811
|
+
box.addChild(new Text6(lines.join(`
|
|
9161
9812
|
`), 0, 0));
|
|
9162
9813
|
if (thinking) {
|
|
9163
9814
|
box.addChild(renderThinkingMarkdown(thinking, theme));
|
|
@@ -9430,26 +10081,26 @@ ${result.markdown}`,
|
|
|
9430
10081
|
label: "Ask Advisor",
|
|
9431
10082
|
name: "ask_advisor",
|
|
9432
10083
|
outputSchema: advisorOutputSchema,
|
|
9433
|
-
parameters:
|
|
9434
|
-
draft:
|
|
10084
|
+
parameters: Type3.Object({
|
|
10085
|
+
draft: Type3.Optional(Type3.String({
|
|
9435
10086
|
description: "Concise untrusted draft for plan or completion review; claims are not verification evidence."
|
|
9436
10087
|
})),
|
|
9437
|
-
followUpTo:
|
|
10088
|
+
followUpTo: Type3.Optional(Type3.String({
|
|
9438
10089
|
description: "Opaque adviceId from a prior successful consultation. Requires a new non-empty question and reuses that consultation's redacted payload; do not combine with draft, Git context, or file attachments."
|
|
9439
10090
|
})),
|
|
9440
|
-
force:
|
|
10091
|
+
force: Type3.Optional(Type3.Boolean({
|
|
9441
10092
|
description: "Set true only when you judge a decision genuinely material after a consultation was screened out; bypasses screening."
|
|
9442
10093
|
})),
|
|
9443
|
-
gitContext:
|
|
10094
|
+
gitContext: Type3.Optional(Type3.Union([Type3.Literal("none"), Type3.Literal("summary"), Type3.Literal("full")], {
|
|
9444
10095
|
description: "How much of the working tree to include. Use full when the review depends on the exact code changes, such as a completion review. Use summary for changed file names only, or none when the question is not about the current changes. The user's configured allowance is the ceiling and a larger request is narrowed to it."
|
|
9445
10096
|
})),
|
|
9446
|
-
includeTrackedFiles:
|
|
10097
|
+
includeTrackedFiles: Type3.Optional(Type3.Array(Type3.String({
|
|
9447
10098
|
description: "Exact tracked repository-relative files to attach after the Advisor explicitly names a file it cannot review. Requires global advisorTrackedFileContent consent; current working-tree contents are sent as untrusted data."
|
|
9448
10099
|
}))),
|
|
9449
|
-
includeUntracked:
|
|
10100
|
+
includeUntracked: Type3.Optional(Type3.Array(Type3.String({
|
|
9450
10101
|
description: "Exact new repository-relative files to include only when user configuration allows it."
|
|
9451
10102
|
}))),
|
|
9452
|
-
question:
|
|
10103
|
+
question: Type3.Optional(Type3.String({
|
|
9453
10104
|
description: "The specific question or decision to get advice on. Omit this for normal reviews: the Advisor already has the conversation context."
|
|
9454
10105
|
}))
|
|
9455
10106
|
}),
|
|
@@ -9619,7 +10270,7 @@ var registerToolLifecycle = ({
|
|
|
9619
10270
|
if (message !== lastConfigErrorNotified) {
|
|
9620
10271
|
lastConfigErrorNotified = message;
|
|
9621
10272
|
if (ctx.hasUI) {
|
|
9622
|
-
ctx.ui.notify(
|
|
10273
|
+
ctx.ui.notify(`${t("notify.gatingSkipped.prefix", "Advisor gating skipped; configuration is invalid.")} ${message} ${t("notify.gatingSkipped.suffix", "Fix advisor.json.")}`, "error");
|
|
9623
10274
|
}
|
|
9624
10275
|
}
|
|
9625
10276
|
return false;
|
|
@@ -9733,8 +10384,8 @@ ${guidelines.map((rule) => `- ${rule}`).join(`
|
|
|
9733
10384
|
};
|
|
9734
10385
|
|
|
9735
10386
|
// src/tools/register-outcome.ts
|
|
9736
|
-
import { Text as
|
|
9737
|
-
import { Type as
|
|
10387
|
+
import { Text as Text7 } from "@earendil-works/pi-tui";
|
|
10388
|
+
import { Type as Type4 } from "typebox";
|
|
9738
10389
|
var registerOutcomeTool = ({
|
|
9739
10390
|
appendOutcome: appendAdvisorOutcome,
|
|
9740
10391
|
pi,
|
|
@@ -9773,7 +10424,7 @@ var registerOutcomeTool = ({
|
|
|
9773
10424
|
} catch {
|
|
9774
10425
|
session.releaseAdvice(params.adviceId);
|
|
9775
10426
|
if (ctx.hasUI) {
|
|
9776
|
-
ctx.ui.notify("Advisor outcome could not be recorded locally.", "warning");
|
|
10427
|
+
ctx.ui.notify(t("notify.outcomeRecordFailed.message", "Advisor outcome could not be recorded locally."), "warning");
|
|
9777
10428
|
}
|
|
9778
10429
|
return {
|
|
9779
10430
|
content: [
|
|
@@ -9788,19 +10439,19 @@ var registerOutcomeTool = ({
|
|
|
9788
10439
|
},
|
|
9789
10440
|
label: "Record Advisor Outcome",
|
|
9790
10441
|
name: "record_advisor_outcome",
|
|
9791
|
-
parameters:
|
|
9792
|
-
adoption:
|
|
9793
|
-
adviceId:
|
|
9794
|
-
validationStatus:
|
|
10442
|
+
parameters: Type4.Object({
|
|
10443
|
+
adoption: Type4.String({ enum: ADOPTIONS }),
|
|
10444
|
+
adviceId: Type4.String(),
|
|
10445
|
+
validationStatus: Type4.String({ enum: VALIDATIONS })
|
|
9795
10446
|
}),
|
|
9796
|
-
renderCall: () => new
|
|
9797
|
-
renderResult: (result) => new
|
|
10447
|
+
renderCall: () => new Text7("[advisor] Record outcome", 0, 0),
|
|
10448
|
+
renderResult: (result) => new Text7(textFrom(result.content), 0, 0)
|
|
9798
10449
|
});
|
|
9799
10450
|
};
|
|
9800
10451
|
|
|
9801
10452
|
// src/tools/register-renderers.ts
|
|
9802
10453
|
import { getMarkdownTheme as getMarkdownTheme5 } from "@earendil-works/pi-coding-agent";
|
|
9803
|
-
import { Box as Box4, Markdown as Markdown5, Text as
|
|
10454
|
+
import { Box as Box4, Markdown as Markdown5, Text as Text8 } from "@earendil-works/pi-tui";
|
|
9804
10455
|
var formatByteSize3 = (bytes) => {
|
|
9805
10456
|
if (bytes >= 1024 ** 3) {
|
|
9806
10457
|
return `${(bytes / 1024 ** 3).toFixed(1)} GiB`;
|
|
@@ -9815,14 +10466,14 @@ var formatByteSize3 = (bytes) => {
|
|
|
9815
10466
|
};
|
|
9816
10467
|
var addAttachmentLine = (box, details, theme) => {
|
|
9817
10468
|
if (details?.agentRulesBytes) {
|
|
9818
|
-
box.addChild(new
|
|
10469
|
+
box.addChild(new Text8(theme.fg("dim", ` AGENTS.md rules attached · ${formatByteSize3(details.agentRulesBytes)}`), 0, 0));
|
|
9819
10470
|
}
|
|
9820
10471
|
};
|
|
9821
10472
|
var addUsageLine = (box, details, theme) => {
|
|
9822
10473
|
if (getAdvisorSettings().showUsageDetails) {
|
|
9823
10474
|
const usageText = formatAdvisorUsage(details?.usage);
|
|
9824
10475
|
if (usageText) {
|
|
9825
|
-
box.addChild(new
|
|
10476
|
+
box.addChild(new Text8(theme.fg("dim", ` Usage: ${usageText}`), 0, 0));
|
|
9826
10477
|
}
|
|
9827
10478
|
}
|
|
9828
10479
|
addAttachmentLine(box, details, theme);
|
|
@@ -9836,30 +10487,30 @@ var scoutResultRenderer = (entry, { expanded }, theme) => {
|
|
|
9836
10487
|
var turnGateResultRenderer = (message, { expanded }, theme) => {
|
|
9837
10488
|
const { details } = message;
|
|
9838
10489
|
const box = new Box4(1, 1, (text) => theme.bg("customMessageBg", text));
|
|
9839
|
-
box.addChild(new
|
|
10490
|
+
box.addChild(new Text8(theme.fg("warning", theme.bold("◆ ADVISOR · TURN REVIEW")), 0, 0));
|
|
9840
10491
|
if (details?.advisor) {
|
|
9841
|
-
box.addChild(new
|
|
10492
|
+
box.addChild(new Text8(theme.fg("dim", ` ${details.advisor}`), 0, 0));
|
|
9842
10493
|
}
|
|
9843
10494
|
addUsageLine(box, details, theme);
|
|
9844
10495
|
if (details?.text) {
|
|
9845
10496
|
box.addChild(new Markdown5(adviceForDisplay(details.text, Boolean(expanded)), 0, 0, getMarkdownTheme5()));
|
|
9846
10497
|
} else {
|
|
9847
|
-
box.addChild(new
|
|
10498
|
+
box.addChild(new Text8(theme.fg("error", isString(message.content) ? message.content : t("render.turnReviewFailed", "Advisor turn review failed.")), 0, 0));
|
|
9848
10499
|
}
|
|
9849
10500
|
return box;
|
|
9850
10501
|
};
|
|
9851
10502
|
var loopResultRenderer = (message, { expanded }, theme) => {
|
|
9852
10503
|
const { details } = message;
|
|
9853
10504
|
const box = new Box4(1, 1, (text) => theme.bg("customMessageBg", text));
|
|
9854
|
-
box.addChild(new
|
|
10505
|
+
box.addChild(new Text8(theme.fg("warning", theme.bold(`◆ ADVISOR GATE: ${details?.decision ?? "failure"}`)), 0, 0));
|
|
9855
10506
|
if (details?.advisor) {
|
|
9856
|
-
box.addChild(new
|
|
10507
|
+
box.addChild(new Text8(theme.fg("dim", ` ${details.advisor}`), 0, 0));
|
|
9857
10508
|
}
|
|
9858
10509
|
addUsageLine(box, details, theme);
|
|
9859
10510
|
if (details?.text) {
|
|
9860
10511
|
box.addChild(new Markdown5(adviceForDisplay(details.text, Boolean(expanded)), 0, 0, getMarkdownTheme5()));
|
|
9861
10512
|
} else {
|
|
9862
|
-
box.addChild(new
|
|
10513
|
+
box.addChild(new Text8(theme.fg("error", isString(message.content) ? message.content : t("render.gateFailed", "Advisor gate failed.")), 0, 0));
|
|
9863
10514
|
}
|
|
9864
10515
|
return box;
|
|
9865
10516
|
};
|
|
@@ -9909,6 +10560,10 @@ var registerAdvisorTool = (pi, session = sessionStateFor(pi), dependencies = {})
|
|
|
9909
10560
|
var consultAdvisor2 = (...args) => consultAdvisor(...args);
|
|
9910
10561
|
var parseAutomaticDecision2 = (...args) => parseAutomaticDecision(...args);
|
|
9911
10562
|
var runAdvisorGate2 = (...args) => runAdvisorGate(...args);
|
|
10563
|
+
try {
|
|
10564
|
+
const loader = await import("@juicesharp/rpiv-i18n/loader");
|
|
10565
|
+
loader.registerLocalesFromDir(I18N_NAMESPACE, new URL("../", import.meta.url).href, { label: "pi-advisor" });
|
|
10566
|
+
} catch {}
|
|
9912
10567
|
function registerPiAdvisor(pi) {
|
|
9913
10568
|
const sessionState = new AdvisorSessionState;
|
|
9914
10569
|
const scoutStatus = new ScoutStatusManager;
|