pi-advisor-flow 0.16.1-dev.2 → 0.17.1-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 +14 -0
- package/README.md +17 -9
- package/dist/index.js +396 -106
- package/docs/configuration.md +21 -10
- package/docs/privacy.md +2 -2
- package/locales/de.json +8 -1
- package/locales/en.json +8 -1
- package/locales/fr.json +8 -1
- package/package.json +11 -11
- package/src/commands/activation-preparation.ts +30 -3
- package/src/commands/activation-settings.ts +73 -0
- package/src/commands/activation.ts +75 -56
- package/src/commands/advisor-tools.ts +27 -6
- package/src/commands/configuration-tool-preview.ts +107 -15
- package/src/commands/configuration-tool-runtime.ts +3 -20
- package/src/commands/configuration-tool-update.ts +23 -1
- package/src/commands/lifecycle.ts +30 -1
- package/src/commands/manual-progress.ts +5 -5
- package/src/commands/model-commands.ts +17 -0
- package/src/commands/model-picker.ts +14 -6
- package/src/commands/settings-commands.ts +36 -20
- package/src/commands/settings-persistence.ts +37 -1
- package/src/config/defaults.ts +10 -0
- package/src/config/schema-validators.ts +10 -0
- package/src/config/schema.ts +24 -1
- package/src/config/session-overrides.ts +109 -0
- package/src/config/state.ts +19 -0
- package/src/config/storage.ts +15 -1
- package/src/config/types.ts +11 -0
- package/src/session-state.ts +2 -0
- package/src/tools/budget-feedback.ts +2 -2
- package/src/tools/prompts.ts +18 -0
- package/src/tools/register-ask-advisor.ts +10 -4
- package/src/tools/register-lifecycle.ts +12 -6
- package/src/tools/registration.ts +8 -1
- package/src/tools/session-availability.ts +10 -0
- package/src/ui/settings-items.ts +43 -6
- package/src/ui/settings-list-adapter.ts +1 -1
- package/src/ui/settings-mutations.ts +14 -0
- package/src/ui/settings-selector.ts +1 -0
- package/src/ui/types.ts +8 -1
package/dist/index.js
CHANGED
|
@@ -38,6 +38,10 @@ var GATE_FAILURE_MODES = [
|
|
|
38
38
|
"block-tool",
|
|
39
39
|
"warn-and-continue"
|
|
40
40
|
];
|
|
41
|
+
var TRACKED_FILE_HANDOFF_MODES = [
|
|
42
|
+
"advisor-named",
|
|
43
|
+
"executor"
|
|
44
|
+
];
|
|
41
45
|
|
|
42
46
|
// src/config/state.ts
|
|
43
47
|
var executorRef = "";
|
|
@@ -64,6 +68,7 @@ var advisorSessionSummaryRef = false;
|
|
|
64
68
|
var advisorLogFeedbackRef = false;
|
|
65
69
|
var simpleModeRef = false;
|
|
66
70
|
var advisorToolsEnabledRef = true;
|
|
71
|
+
var advisorActivationRef = "persistent";
|
|
67
72
|
var alwaysOnRef = false;
|
|
68
73
|
var advisorFailureModeRef = "block-session";
|
|
69
74
|
var advisorHerdrIntegrationRef = true;
|
|
@@ -91,6 +96,7 @@ var advisorToolPoliciesRef = {};
|
|
|
91
96
|
var advisorOutcomeLoggingRef = false;
|
|
92
97
|
var advisorUntrackedContentRef = false;
|
|
93
98
|
var advisorTrackedFileContentRef = false;
|
|
99
|
+
var advisorTrackedFileHandoffRef = "advisor-named";
|
|
94
100
|
var advisorScoutEnabledRef = false;
|
|
95
101
|
var advisorScoutTimeoutMsRef = DEFAULT_SCOUT_TIMEOUT_MS;
|
|
96
102
|
var showUsageDetailsRef = true;
|
|
@@ -174,6 +180,9 @@ var setSimpleModeRef = (enabled) => {
|
|
|
174
180
|
var setAdvisorToolsEnabledRef = (enabled) => {
|
|
175
181
|
advisorToolsEnabledRef = enabled;
|
|
176
182
|
};
|
|
183
|
+
var setAdvisorActivationRef = (activation) => {
|
|
184
|
+
advisorActivationRef = activation;
|
|
185
|
+
};
|
|
177
186
|
var setAlwaysOnRef = (enabled) => {
|
|
178
187
|
alwaysOnRef = enabled;
|
|
179
188
|
};
|
|
@@ -254,6 +263,9 @@ var setAdvisorUntrackedContentRef = (enabled) => {
|
|
|
254
263
|
var setAdvisorTrackedFileContentRef = (enabled) => {
|
|
255
264
|
advisorTrackedFileContentRef = enabled;
|
|
256
265
|
};
|
|
266
|
+
var setAdvisorTrackedFileHandoffRef = (mode) => {
|
|
267
|
+
advisorTrackedFileHandoffRef = mode;
|
|
268
|
+
};
|
|
257
269
|
var setAdvisorScoutEnabledRef = (enabled) => {
|
|
258
270
|
advisorScoutEnabledRef = enabled;
|
|
259
271
|
};
|
|
@@ -267,6 +279,7 @@ var setShowUsageFooterRef = (enabled) => {
|
|
|
267
279
|
showUsageFooterRef = enabled;
|
|
268
280
|
};
|
|
269
281
|
var getAdvisorSettings = () => ({
|
|
282
|
+
advisorActivation: advisorActivationRef,
|
|
270
283
|
advisorToolsEnabled: advisorToolsEnabledRef,
|
|
271
284
|
agentsMdContext: advisorAgentsMdContextRef,
|
|
272
285
|
alwaysOn: alwaysOnRef,
|
|
@@ -315,6 +328,7 @@ var getAdvisorSettings = () => ({
|
|
|
315
328
|
toolResultMaxBytes: advisorToolResultMaxBytesRef,
|
|
316
329
|
toolResultMaxLines: advisorToolResultMaxLinesRef,
|
|
317
330
|
trackedFileContent: advisorTrackedFileContentRef,
|
|
331
|
+
trackedFileHandoff: advisorTrackedFileHandoffRef,
|
|
318
332
|
untrackedContent: advisorUntrackedContentRef
|
|
319
333
|
});
|
|
320
334
|
var getAdvisorMaxCallsPerSession = () => getAdvisorSettings().maxCallsPerSession;
|
|
@@ -534,6 +548,8 @@ var isValidLoopThreshold = (value) => typeof value === "number" && Number.isSafe
|
|
|
534
548
|
var isValidMaxCallsPerSession = (value) => isValidNonNegativeSafeInteger(value);
|
|
535
549
|
var GATE_FAILURE_MODE_NAMES = new Set(GATE_FAILURE_MODES);
|
|
536
550
|
var isValidGateFailureMode = (value) => isString(value) && GATE_FAILURE_MODE_NAMES.has(value);
|
|
551
|
+
var TRACKED_FILE_HANDOFF_MODE_NAMES = new Set(TRACKED_FILE_HANDOFF_MODES);
|
|
552
|
+
var isValidTrackedFileHandoffMode = (value) => isString(value) && TRACKED_FILE_HANDOFF_MODE_NAMES.has(value);
|
|
537
553
|
var isValidToolResultMaxLines = (value) => isValidNonNegativeSafeInteger(value);
|
|
538
554
|
var isValidToolResultMaxBytes = (value) => isValidNonNegativeSafeInteger(value);
|
|
539
555
|
var isValidJevTimeoutMs = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
|
|
@@ -556,6 +572,13 @@ var CONFIG_SCHEMA = {
|
|
|
556
572
|
persisted: true,
|
|
557
573
|
type: "string"
|
|
558
574
|
},
|
|
575
|
+
advisorActivation: {
|
|
576
|
+
accepted: "persistent or session",
|
|
577
|
+
current: () => advisorActivationRef,
|
|
578
|
+
persisted: true,
|
|
579
|
+
type: "enum",
|
|
580
|
+
validate: (value) => value === "persistent" || value === "session"
|
|
581
|
+
},
|
|
559
582
|
advisorAgentsMdContext: {
|
|
560
583
|
accepted: "true or false",
|
|
561
584
|
current: () => advisorAgentsMdContextRef,
|
|
@@ -829,6 +852,13 @@ var CONFIG_SCHEMA = {
|
|
|
829
852
|
persisted: true,
|
|
830
853
|
type: "boolean"
|
|
831
854
|
},
|
|
855
|
+
advisorTrackedFileHandoff: {
|
|
856
|
+
accepted: TRACKED_FILE_HANDOFF_MODES.join(", "),
|
|
857
|
+
current: () => advisorTrackedFileHandoffRef,
|
|
858
|
+
persisted: true,
|
|
859
|
+
type: "enum",
|
|
860
|
+
validate: isValidTrackedFileHandoffMode
|
|
861
|
+
},
|
|
832
862
|
advisorUntrackedContent: {
|
|
833
863
|
accepted: "true or false",
|
|
834
864
|
current: () => advisorUntrackedContentRef,
|
|
@@ -957,6 +987,70 @@ var parseArgs = (args) => {
|
|
|
957
987
|
setContextMaxCharsRef(nextContextMaxChars);
|
|
958
988
|
};
|
|
959
989
|
|
|
990
|
+
// src/config/session-overrides.ts
|
|
991
|
+
var SESSION_ACTIVATION_KEYS = [
|
|
992
|
+
"advisor",
|
|
993
|
+
"advisorEffort",
|
|
994
|
+
"advisorFallbackModel",
|
|
995
|
+
"contextMaxChars",
|
|
996
|
+
"executor",
|
|
997
|
+
"executorEffort"
|
|
998
|
+
];
|
|
999
|
+
var overrides = new WeakMap;
|
|
1000
|
+
var sessionKey = (ctx) => ctx.sessionManager ?? ctx;
|
|
1001
|
+
var getSessionActivationOverrides = (ctx) => overrides.get(sessionKey(ctx));
|
|
1002
|
+
var applySessionActivationOverrides = (ctx) => {
|
|
1003
|
+
const values = getSessionActivationOverrides(ctx);
|
|
1004
|
+
if (!values) {
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
if (Object.hasOwn(values, "advisor")) {
|
|
1008
|
+
setAdvisorRef(values.advisor ?? "");
|
|
1009
|
+
}
|
|
1010
|
+
if (Object.hasOwn(values, "advisorEffort")) {
|
|
1011
|
+
setAdvisorEffortRef(values.advisorEffort);
|
|
1012
|
+
}
|
|
1013
|
+
if (Object.hasOwn(values, "advisorFallbackModel")) {
|
|
1014
|
+
setAdvisorFallbackModelRef(values.advisorFallbackModel);
|
|
1015
|
+
}
|
|
1016
|
+
if (values.contextMaxChars !== undefined) {
|
|
1017
|
+
setContextMaxCharsRef(values.contextMaxChars);
|
|
1018
|
+
}
|
|
1019
|
+
if (Object.hasOwn(values, "executor")) {
|
|
1020
|
+
setExecutorRef(values.executor ?? "");
|
|
1021
|
+
}
|
|
1022
|
+
if (Object.hasOwn(values, "executorEffort")) {
|
|
1023
|
+
setExecutorEffortRef(values.executorEffort);
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
var rememberSessionActivationOverrides = (ctx, previous, current) => {
|
|
1027
|
+
const next = { ...getSessionActivationOverrides(ctx) };
|
|
1028
|
+
for (const key of SESSION_ACTIVATION_KEYS) {
|
|
1029
|
+
if (previous[key] !== current[key]) {
|
|
1030
|
+
Object.assign(next, { [key]: current[key] });
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
if (Object.keys(next).length > 0) {
|
|
1034
|
+
overrides.set(sessionKey(ctx), next);
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
var clearSessionActivationOverrides = (ctx, keys = SESSION_ACTIVATION_KEYS) => {
|
|
1038
|
+
const key = sessionKey(ctx);
|
|
1039
|
+
const existing = overrides.get(key);
|
|
1040
|
+
if (!existing) {
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
const remaining = { ...existing };
|
|
1044
|
+
for (const name of keys) {
|
|
1045
|
+
Reflect.deleteProperty(remaining, name);
|
|
1046
|
+
}
|
|
1047
|
+
if (Object.keys(remaining).length === 0) {
|
|
1048
|
+
overrides.delete(key);
|
|
1049
|
+
} else {
|
|
1050
|
+
overrides.set(key, remaining);
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
|
|
960
1054
|
// src/config/storage.ts
|
|
961
1055
|
import { randomUUID } from "node:crypto";
|
|
962
1056
|
import {
|
|
@@ -1008,6 +1102,7 @@ var resetDefaults = () => {
|
|
|
1008
1102
|
setAdvisorSessionSummaryRef(false);
|
|
1009
1103
|
setAdvisorLogFeedbackRef(false);
|
|
1010
1104
|
setSimpleModeRef(false);
|
|
1105
|
+
setAdvisorActivationRef("persistent");
|
|
1011
1106
|
setAdvisorToolsEnabledRef(true);
|
|
1012
1107
|
setAlwaysOnRef(false);
|
|
1013
1108
|
setAdvisorFailureModeRef("block-session");
|
|
@@ -1035,6 +1130,7 @@ var resetDefaults = () => {
|
|
|
1035
1130
|
setAdvisorOutcomeLoggingRef(false);
|
|
1036
1131
|
setAdvisorUntrackedContentRef(false);
|
|
1037
1132
|
setAdvisorTrackedFileContentRef(false);
|
|
1133
|
+
setAdvisorTrackedFileHandoffRef("advisor-named");
|
|
1038
1134
|
setAdvisorScoutEnabledRef(false);
|
|
1039
1135
|
setAdvisorScoutTimeoutMsRef(DEFAULT_SCOUT_TIMEOUT_MS);
|
|
1040
1136
|
setShowUsageDetailsRef(true);
|
|
@@ -1077,6 +1173,7 @@ var applyConfig = (config) => {
|
|
|
1077
1173
|
applyOptionalConfig(config, "showUsageDetails", setShowUsageDetailsRef);
|
|
1078
1174
|
applyOptionalConfig(config, "showUsageFooter", setShowUsageFooterRef);
|
|
1079
1175
|
applyOptionalConfig(config, "simpleMode", setSimpleModeRef);
|
|
1176
|
+
applyOptionalConfig(config, "advisorActivation", setAdvisorActivationRef);
|
|
1080
1177
|
applyOptionalConfig(config, "advisorToolsEnabled", setAdvisorToolsEnabledRef);
|
|
1081
1178
|
applyOptionalConfig(config, "alwaysOn", setAlwaysOnRef);
|
|
1082
1179
|
applyOptionalConfig(config, "gateFailureMode", setAdvisorFailureModeRef);
|
|
@@ -1103,6 +1200,7 @@ var applyConfig = (config) => {
|
|
|
1103
1200
|
applyOptionalConfig(config, "advisorToolPolicies", setAdvisorToolPoliciesRef);
|
|
1104
1201
|
applyOptionalConfig(config, "advisorUntrackedContent", setAdvisorUntrackedContentRef);
|
|
1105
1202
|
applyOptionalConfig(config, "advisorTrackedFileContent", setAdvisorTrackedFileContentRef);
|
|
1203
|
+
applyOptionalConfig(config, "advisorTrackedFileHandoff", setAdvisorTrackedFileHandoffRef);
|
|
1106
1204
|
applyOptionalConfig(config, "advisorOutcomeLogging", setAdvisorOutcomeLoggingRef);
|
|
1107
1205
|
};
|
|
1108
1206
|
|
|
@@ -1209,6 +1307,11 @@ var loadConfig = (_ctx) => {
|
|
|
1209
1307
|
warnedUnknownConfigIdentities.add(warningIdentity);
|
|
1210
1308
|
}
|
|
1211
1309
|
}
|
|
1310
|
+
if (advisorActivationRef === "session") {
|
|
1311
|
+
applySessionActivationOverrides(_ctx);
|
|
1312
|
+
} else {
|
|
1313
|
+
clearSessionActivationOverrides(_ctx);
|
|
1314
|
+
}
|
|
1212
1315
|
setAdvisorOutcomeLoggingRef(globalConfig?.advisorOutcomeLogging === true);
|
|
1213
1316
|
loadedConfigState = currentConfigState();
|
|
1214
1317
|
loadedConfigPath = global;
|
|
@@ -1224,7 +1327,8 @@ var saveConfig = (_ctx, options = {}) => {
|
|
|
1224
1327
|
const persistExecutor = options.persistExecutor ?? true;
|
|
1225
1328
|
const current = currentConfigState();
|
|
1226
1329
|
const baseline = loadedConfigPath === path ? loadedConfigState : undefined;
|
|
1227
|
-
const
|
|
1330
|
+
const forcedKeys = new Set(options.forceKeys);
|
|
1331
|
+
const changedKeys = baseline ? SAVED_CONFIG_KEYS.filter((key) => forcedKeys.has(key) || !sameConfigValue(current[key], baseline[key])) : [...SAVED_CONFIG_KEYS];
|
|
1228
1332
|
if (changedKeys.length === 0) {
|
|
1229
1333
|
return path;
|
|
1230
1334
|
}
|
|
@@ -1676,8 +1780,10 @@ var FALLBACK_ADVISOR_MODEL_DISABLED = "Disabled (no fallback)";
|
|
|
1676
1780
|
var EXECUTOR_FOLLOWS_SESSION_MODEL = "Current session model (no override)";
|
|
1677
1781
|
|
|
1678
1782
|
// src/commands/model-picker.ts
|
|
1783
|
+
var isCurrentChoice = (choice, canContinue) => Boolean(choice) && canContinue();
|
|
1679
1784
|
var selectAdvisorModels = async (ctx, options) => {
|
|
1680
|
-
|
|
1785
|
+
const canContinue = () => options.canContinue?.() ?? true;
|
|
1786
|
+
if (!canContinue() || !ctx.hasUI) {
|
|
1681
1787
|
return;
|
|
1682
1788
|
}
|
|
1683
1789
|
const refs = getAvailableModelRefs(ctx);
|
|
@@ -1706,11 +1812,11 @@ var selectAdvisorModels = async (ctx, options) => {
|
|
|
1706
1812
|
title: t("modelPicker.selectExecutor", "Select Executor Model"),
|
|
1707
1813
|
tui
|
|
1708
1814
|
}));
|
|
1709
|
-
if (!selectedExecutor) {
|
|
1815
|
+
if (!isCurrentChoice(selectedExecutor, canContinue)) {
|
|
1710
1816
|
return;
|
|
1711
1817
|
}
|
|
1712
1818
|
const selectedExecutorEffort = await ctx.ui.select(t("modelPicker.executorEffort", "Select Executor Reasoning/Thinking Level"), effortChoices(executorEffort));
|
|
1713
|
-
if (!selectedExecutorEffort) {
|
|
1819
|
+
if (!isCurrentChoice(selectedExecutorEffort, canContinue)) {
|
|
1714
1820
|
return;
|
|
1715
1821
|
}
|
|
1716
1822
|
executor = selectedExecutor === EXECUTOR_FOLLOWS_SESSION_MODEL ? "" : selectedExecutor;
|
|
@@ -1727,11 +1833,11 @@ var selectAdvisorModels = async (ctx, options) => {
|
|
|
1727
1833
|
title: t("modelPicker.selectAdvisor", "Select Advisor Model"),
|
|
1728
1834
|
tui
|
|
1729
1835
|
}));
|
|
1730
|
-
if (!selectedAdvisor) {
|
|
1836
|
+
if (!isCurrentChoice(selectedAdvisor, canContinue)) {
|
|
1731
1837
|
return;
|
|
1732
1838
|
}
|
|
1733
1839
|
const selectedAdvisorEffort = await ctx.ui.select(t("modelPicker.advisorEffort", "Select Advisor Reasoning/Thinking Level"), effortChoices(advisorEffort));
|
|
1734
|
-
if (!selectedAdvisorEffort) {
|
|
1840
|
+
if (!isCurrentChoice(selectedAdvisorEffort, canContinue)) {
|
|
1735
1841
|
return;
|
|
1736
1842
|
}
|
|
1737
1843
|
advisor = selectedAdvisor;
|
|
@@ -1753,7 +1859,7 @@ var selectAdvisorModels = async (ctx, options) => {
|
|
|
1753
1859
|
title: t("modelPicker.selectFallbackAdvisor", "Select Fallback Advisor Model (optional)"),
|
|
1754
1860
|
tui
|
|
1755
1861
|
}));
|
|
1756
|
-
if (selectedFallback === undefined) {
|
|
1862
|
+
if (selectedFallback === undefined || !canContinue()) {
|
|
1757
1863
|
return;
|
|
1758
1864
|
}
|
|
1759
1865
|
advisorFallbackModel = selectedFallback === FALLBACK_ADVISOR_MODEL_DISABLED ? undefined : selectedFallback;
|
|
@@ -4163,10 +4269,19 @@ var advisorRepositoryContext = (result, requested, allowed, budget) => {
|
|
|
4163
4269
|
`);
|
|
4164
4270
|
};
|
|
4165
4271
|
var advisorRequestConversation = (ctx, maxChars = contextMaxCharsRef, describeImages = false, imageNonce = "") => recentConversation(ctx, maxChars, undefined, undefined, undefined, undefined, describeImages, imageNonce);
|
|
4272
|
+
var trackedFileHandoffGuidelines = () => {
|
|
4273
|
+
if (!advisorTrackedFileContentRef) {
|
|
4274
|
+
return [];
|
|
4275
|
+
}
|
|
4276
|
+
return [
|
|
4277
|
+
advisorTrackedFileHandoffRef === "executor" ? "Tracked files may be attached before the Advisor names them. When your question or draft depends on specific repository documents, attach them with `includeTrackedFiles` on the first consultation. Prefer a few key files within the size limits." : "Attach tracked files with `includeTrackedFiles` only after the Advisor names them."
|
|
4278
|
+
];
|
|
4279
|
+
};
|
|
4166
4280
|
var advisorInvocationGuidelines = () => {
|
|
4167
4281
|
if (isSimpleMode()) {
|
|
4168
4282
|
return [
|
|
4169
|
-
"When uncertain and normal available tools cannot resolve it, call ask_advisor for a second opinion."
|
|
4283
|
+
"When uncertain and normal available tools cannot resolve it, call ask_advisor for a second opinion.",
|
|
4284
|
+
...trackedFileHandoffGuidelines()
|
|
4170
4285
|
];
|
|
4171
4286
|
}
|
|
4172
4287
|
const guidelines = [];
|
|
@@ -4185,6 +4300,7 @@ var advisorInvocationGuidelines = () => {
|
|
|
4185
4300
|
if (guidelines.length > 0) {
|
|
4186
4301
|
guidelines.push("Call ask_advisor with an empty object by default. Do not invent a question merely to request a review: the Advisor already receives context. Include question only for a genuinely specific assumption or trade-off.");
|
|
4187
4302
|
}
|
|
4303
|
+
guidelines.push(...trackedFileHandoffGuidelines());
|
|
4188
4304
|
return guidelines;
|
|
4189
4305
|
};
|
|
4190
4306
|
var ADVISOR_SYSTEM = [
|
|
@@ -5241,10 +5357,12 @@ class AdvisorSessionState {
|
|
|
5241
5357
|
#followUps;
|
|
5242
5358
|
#sessionTurnOrdinal = 0;
|
|
5243
5359
|
#turnsSinceConsultation = 0;
|
|
5360
|
+
sessionToolsEnabled = false;
|
|
5244
5361
|
constructor(now) {
|
|
5245
5362
|
this.#followUps = new AdvisorFollowUpCache(now);
|
|
5246
5363
|
}
|
|
5247
5364
|
resetTask() {
|
|
5365
|
+
this.sessionToolsEnabled = false;
|
|
5248
5366
|
this.#repetition = freshRepetition();
|
|
5249
5367
|
this.#blockedReason = undefined;
|
|
5250
5368
|
this.#ledger = freshAdviceLedger();
|
|
@@ -5600,8 +5718,13 @@ var loadCommandConfig = (ctx) => {
|
|
|
5600
5718
|
return false;
|
|
5601
5719
|
}
|
|
5602
5720
|
};
|
|
5603
|
-
var prepareActivationModels = async (runtime, ctx, announce, executorOverride, advisorOverride) => {
|
|
5604
|
-
const
|
|
5721
|
+
var prepareActivationModels = async (runtime, ctx, announce, executorOverride, advisorOverride, canContinue) => {
|
|
5722
|
+
const saved = getPersistedModelRefs();
|
|
5723
|
+
const overrides = advisorActivationRef === "session" ? getSessionActivationOverrides(ctx) : undefined;
|
|
5724
|
+
const persisted = {
|
|
5725
|
+
advisor: overrides && Object.hasOwn(overrides, "advisor") ? advisorRef || undefined : saved.advisor,
|
|
5726
|
+
executor: overrides && Object.hasOwn(overrides, "executor") ? executorRef || undefined : saved.executor
|
|
5727
|
+
};
|
|
5605
5728
|
const availableRefs = getAvailableModelRefs(ctx);
|
|
5606
5729
|
const availableRefSet = availableRefs ? new Set(availableRefs) : undefined;
|
|
5607
5730
|
const explicitError = getExplicitModelError(ctx, executorRef, "Executor", executorOverride, availableRefSet) ?? getExplicitModelError(ctx, advisorRef, "Advisor", advisorOverride, availableRefSet);
|
|
@@ -5618,6 +5741,7 @@ var prepareActivationModels = async (runtime, ctx, announce, executorOverride, a
|
|
|
5618
5741
|
return;
|
|
5619
5742
|
}
|
|
5620
5743
|
const selection = await selectAdvisorModels(ctx, {
|
|
5744
|
+
canContinue,
|
|
5621
5745
|
advisor: advisorOverride || persisted.advisor ? advisorRef : "",
|
|
5622
5746
|
advisorEffort: advisorEffortRef,
|
|
5623
5747
|
advisorFallbackModel: advisorFallbackModelRef,
|
|
@@ -5625,8 +5749,13 @@ var prepareActivationModels = async (runtime, ctx, announce, executorOverride, a
|
|
|
5625
5749
|
executorEffort: executorEffortRef,
|
|
5626
5750
|
selectAdvisor: plan.selectAdvisor,
|
|
5627
5751
|
selectExecutor: plan.selectExecutor
|
|
5752
|
+
}).catch((error) => {
|
|
5753
|
+
if (!canContinue()) {
|
|
5754
|
+
return;
|
|
5755
|
+
}
|
|
5756
|
+
throw error;
|
|
5628
5757
|
});
|
|
5629
|
-
if (!selection) {
|
|
5758
|
+
if (!selection || !canContinue()) {
|
|
5630
5759
|
return;
|
|
5631
5760
|
}
|
|
5632
5761
|
setAdvisorRef(selection.advisor);
|
|
@@ -5639,11 +5768,16 @@ var prepareActivationModels = async (runtime, ctx, announce, executorOverride, a
|
|
|
5639
5768
|
|
|
5640
5769
|
// src/commands/advisor-tools.ts
|
|
5641
5770
|
var ADVISOR_TOOL_NAMES = new Set(["ask_advisor", "record_advisor_outcome"]);
|
|
5642
|
-
var
|
|
5771
|
+
var ALL_ADVISOR_TOOL_NAMES = new Set([
|
|
5772
|
+
...ADVISOR_TOOL_NAMES,
|
|
5773
|
+
"advisor_config"
|
|
5774
|
+
]);
|
|
5775
|
+
var CONFIGURATION_TOOL_NAME = new Set(["advisor_config"]);
|
|
5776
|
+
var setToolsActive = (pi, enabled, names) => {
|
|
5643
5777
|
const current = pi.getActiveTools();
|
|
5644
|
-
const next = current.filter((name) => enabled || !
|
|
5778
|
+
const next = current.filter((name) => enabled || !names.has(name));
|
|
5645
5779
|
if (enabled) {
|
|
5646
|
-
for (const name of
|
|
5780
|
+
for (const name of names) {
|
|
5647
5781
|
if (!next.includes(name)) {
|
|
5648
5782
|
next.push(name);
|
|
5649
5783
|
}
|
|
@@ -5653,6 +5787,8 @@ var setAdvisorToolsActive = (pi, enabled) => {
|
|
|
5653
5787
|
pi.setActiveTools(next);
|
|
5654
5788
|
}
|
|
5655
5789
|
};
|
|
5790
|
+
var setAdvisorToolsActive = (pi, enabled, includeConfiguration = false) => setToolsActive(pi, enabled, includeConfiguration ? ALL_ADVISOR_TOOL_NAMES : ADVISOR_TOOL_NAMES);
|
|
5791
|
+
var enableAdvisorConfigurationTool = (pi) => setToolsActive(pi, true, CONFIGURATION_TOOL_NAME);
|
|
5656
5792
|
|
|
5657
5793
|
// src/commands/activation.ts
|
|
5658
5794
|
var resolveActivationModels = async (runtime, ctx, canContinue) => {
|
|
@@ -5697,10 +5833,31 @@ var restoreActivationRefsIfCurrent = (canContinue, restoreRefs) => {
|
|
|
5697
5833
|
var liveRefSnapshot = () => ({
|
|
5698
5834
|
advisor: advisorRef,
|
|
5699
5835
|
advisorEffort: advisorEffortRef,
|
|
5836
|
+
advisorFallbackModel: advisorFallbackModelRef,
|
|
5700
5837
|
contextMaxChars: contextMaxCharsRef,
|
|
5701
5838
|
executor: executorRef,
|
|
5702
5839
|
executorEffort: executorEffortRef
|
|
5703
5840
|
});
|
|
5841
|
+
var restoreActivationRefs = (previous, attempted) => {
|
|
5842
|
+
if (advisorRef === attempted.advisor) {
|
|
5843
|
+
setAdvisorRef(previous.advisor);
|
|
5844
|
+
}
|
|
5845
|
+
if (advisorEffortRef === attempted.advisorEffort) {
|
|
5846
|
+
setAdvisorEffortRef(previous.advisorEffort);
|
|
5847
|
+
}
|
|
5848
|
+
if (advisorFallbackModelRef === attempted.advisorFallbackModel) {
|
|
5849
|
+
setAdvisorFallbackModelRef(previous.advisorFallbackModel);
|
|
5850
|
+
}
|
|
5851
|
+
if (contextMaxCharsRef === attempted.contextMaxChars) {
|
|
5852
|
+
setContextMaxCharsRef(previous.contextMaxChars);
|
|
5853
|
+
}
|
|
5854
|
+
if (executorRef === attempted.executor) {
|
|
5855
|
+
setExecutorRef(previous.executor);
|
|
5856
|
+
}
|
|
5857
|
+
if (executorEffortRef === attempted.executorEffort) {
|
|
5858
|
+
setExecutorEffortRef(previous.executorEffort);
|
|
5859
|
+
}
|
|
5860
|
+
};
|
|
5704
5861
|
var persistSuccessfulActivation = (ctx, shouldSave, reenableTools, restoreRefs) => {
|
|
5705
5862
|
if (!shouldSave) {
|
|
5706
5863
|
return true;
|
|
@@ -5719,37 +5876,21 @@ var persistSuccessfulActivation = (ctx, shouldSave, reenableTools, restoreRefs)
|
|
|
5719
5876
|
}
|
|
5720
5877
|
return true;
|
|
5721
5878
|
};
|
|
5879
|
+
var announceActivation = (ctx, activeModel) => {
|
|
5880
|
+
const activeExecutorRef = effectiveExecutorRef(ctx);
|
|
5881
|
+
const activeExecutorEffort = effectiveExecutorEffort(ctx);
|
|
5882
|
+
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.")}
|
|
5883
|
+
|
|
5884
|
+
${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");
|
|
5885
|
+
};
|
|
5722
5886
|
var activateAdvisor = async (runtime, args, ctx, announce = true) => {
|
|
5723
5887
|
if (!loadCommandConfig(ctx)) {
|
|
5724
5888
|
return;
|
|
5725
5889
|
}
|
|
5726
5890
|
const { toolAvailabilityRevision } = runtime;
|
|
5727
5891
|
const canContinue = () => runtime.toolAvailabilityRevision === toolAvailabilityRevision;
|
|
5728
|
-
const previous =
|
|
5729
|
-
|
|
5730
|
-
advisorEffort: advisorEffortRef,
|
|
5731
|
-
contextMaxChars: contextMaxCharsRef,
|
|
5732
|
-
executor: executorRef,
|
|
5733
|
-
executorEffort: executorEffortRef
|
|
5734
|
-
};
|
|
5735
|
-
const liveSnapshot = liveRefSnapshot;
|
|
5736
|
-
const restoreRefs = (attempted) => {
|
|
5737
|
-
if (advisorRef === attempted.advisor) {
|
|
5738
|
-
setAdvisorRef(previous.advisor);
|
|
5739
|
-
}
|
|
5740
|
-
if (advisorEffortRef === attempted.advisorEffort) {
|
|
5741
|
-
setAdvisorEffortRef(previous.advisorEffort);
|
|
5742
|
-
}
|
|
5743
|
-
if (contextMaxCharsRef === attempted.contextMaxChars) {
|
|
5744
|
-
setContextMaxCharsRef(previous.contextMaxChars);
|
|
5745
|
-
}
|
|
5746
|
-
if (executorRef === attempted.executor) {
|
|
5747
|
-
setExecutorRef(previous.executor);
|
|
5748
|
-
}
|
|
5749
|
-
if (executorEffortRef === attempted.executorEffort) {
|
|
5750
|
-
setExecutorEffortRef(previous.executorEffort);
|
|
5751
|
-
}
|
|
5752
|
-
};
|
|
5892
|
+
const previous = liveRefSnapshot();
|
|
5893
|
+
const restoreRefs = (attempted) => restoreActivationRefs(previous, attempted);
|
|
5753
5894
|
let attempted = liveRefSnapshot();
|
|
5754
5895
|
const executorOverride = hasExecutorOverride(args);
|
|
5755
5896
|
const advisorOverride = hasAdvisorOverride(args);
|
|
@@ -5760,7 +5901,7 @@ var activateAdvisor = async (runtime, args, ctx, announce = true) => {
|
|
|
5760
5901
|
notify(ctx, argumentError, "error");
|
|
5761
5902
|
return;
|
|
5762
5903
|
}
|
|
5763
|
-
const prepared = await prepareActivationModels(runtime, ctx, announce, executorOverride, advisorOverride);
|
|
5904
|
+
const prepared = await prepareActivationModels(runtime, ctx, announce, executorOverride, advisorOverride, canContinue);
|
|
5764
5905
|
if (!prepared) {
|
|
5765
5906
|
attempted = liveRefSnapshot();
|
|
5766
5907
|
restoreActivationRefsIfCurrent(canContinue, () => restoreRefs(attempted));
|
|
@@ -5775,26 +5916,28 @@ var activateAdvisor = async (runtime, args, ctx, announce = true) => {
|
|
|
5775
5916
|
notify(ctx, error, "error");
|
|
5776
5917
|
return;
|
|
5777
5918
|
}
|
|
5778
|
-
const
|
|
5919
|
+
const sessionScoped = advisorActivationRef === "session";
|
|
5920
|
+
const reenableTools = !sessionScoped && !advisorToolsEnabledRef;
|
|
5779
5921
|
if (reenableTools) {
|
|
5780
5922
|
setAdvisorToolsEnabledRef(true);
|
|
5781
5923
|
}
|
|
5782
|
-
const shouldSave = Boolean(args.trim() || prepared.pickedModels || reenableTools);
|
|
5924
|
+
const shouldSave = !sessionScoped && Boolean(args.trim() || prepared.pickedModels || reenableTools);
|
|
5783
5925
|
if (!persistSuccessfulActivation(ctx, shouldSave, reenableTools, () => restoreRefs(liveRefSnapshot()))) {
|
|
5784
5926
|
return;
|
|
5785
5927
|
}
|
|
5786
5928
|
if (executorEffortRef && !isMarkedSubagent()) {
|
|
5787
5929
|
runtime.pi.setThinkingLevel(executorEffortRef);
|
|
5788
5930
|
}
|
|
5789
|
-
|
|
5931
|
+
if (sessionScoped) {
|
|
5932
|
+
rememberSessionActivationOverrides(ctx, previous, liveRefSnapshot());
|
|
5933
|
+
rebaseConfigBaseline();
|
|
5934
|
+
runtime.advisorSessionState.sessionToolsEnabled = true;
|
|
5935
|
+
}
|
|
5936
|
+
setAdvisorToolsActive(runtime.pi, true, sessionScoped);
|
|
5790
5937
|
const activeModel = followsSessionExecutor() ? ctx.model : findConfiguredModel(ctx, executorRef);
|
|
5791
5938
|
runtime.updateSameModelNotice(ctx, activeModel);
|
|
5792
5939
|
if (announce) {
|
|
5793
|
-
|
|
5794
|
-
const activeExecutorEffort = effectiveExecutorEffort(ctx);
|
|
5795
|
-
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.")}
|
|
5796
|
-
|
|
5797
|
-
${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");
|
|
5940
|
+
announceActivation(ctx, activeModel);
|
|
5798
5941
|
}
|
|
5799
5942
|
};
|
|
5800
5943
|
|
|
@@ -5937,16 +6080,42 @@ var summarizeAdvisorConfigPatch = (changes, before, persisted) => configKeys.fil
|
|
|
5937
6080
|
return `- ${key}: ${previous} → ${next}`;
|
|
5938
6081
|
}).join(`
|
|
5939
6082
|
`);
|
|
5940
|
-
var
|
|
6083
|
+
var enabledToolsRiskNote = (sessionScoped, alwaysOn, enabledByAlwaysOn) => {
|
|
6084
|
+
if (sessionScoped && enabledByAlwaysOn) {
|
|
6085
|
+
return "The saved tool preference changes; enabling Always on does not activate this session.";
|
|
6086
|
+
}
|
|
6087
|
+
if (sessionScoped) {
|
|
6088
|
+
return "Advisor tools become available in this session; later session starts remain inactive.";
|
|
6089
|
+
}
|
|
6090
|
+
if (alwaysOn) {
|
|
6091
|
+
return "Advisor tools become available, and saved Always on will activate the flow in future sessions.";
|
|
6092
|
+
}
|
|
6093
|
+
return "Advisor tools become available; this does not activate Always on.";
|
|
6094
|
+
};
|
|
6095
|
+
var activationRiskNotes = (changes, before) => {
|
|
5941
6096
|
const notes = [];
|
|
5942
|
-
|
|
5943
|
-
|
|
6097
|
+
const sessionScoped = changes.advisorActivation === "session" || changes.advisorActivation === undefined && before.advisorActivation === "session";
|
|
6098
|
+
if (changes.advisorActivation === "session") {
|
|
6099
|
+
notes.push("The current Advisor on/off state is kept; advisor_config follows it. Every session start, including /reload, starts inactive even when Always on is saved.");
|
|
6100
|
+
}
|
|
6101
|
+
if (changes.advisorActivation === "persistent" || changes.advisorActivation === null) {
|
|
6102
|
+
notes.push("Persistent mode applies the saved Advisor tools preference immediately and makes advisor_config available.");
|
|
5944
6103
|
}
|
|
5945
6104
|
if (changes.advisorToolsEnabled === false) {
|
|
5946
|
-
notes.push("Advisor tools will be disabled immediately. advisor_config remains available to re-enable them.");
|
|
6105
|
+
notes.push(sessionScoped ? "Advisor tools, including advisor_config, will be disabled immediately; use /advisor to enable them for this session." : "Advisor tools will be disabled immediately. advisor_config remains available to re-enable them.");
|
|
5947
6106
|
}
|
|
5948
6107
|
if (changes.alwaysOn === true) {
|
|
5949
|
-
notes.push("Always on enables automatic activation for future sessions.");
|
|
6108
|
+
notes.push(sessionScoped ? "Always on is saved, but session activation starts inactive." : "Always on enables automatic activation for future sessions.");
|
|
6109
|
+
}
|
|
6110
|
+
if (changes.advisorToolsEnabled === true) {
|
|
6111
|
+
notes.push(enabledToolsRiskNote(sessionScoped, before.alwaysOn === true || changes.alwaysOn === true, changes.alwaysOn === true && before.advisorToolsEnabled === false));
|
|
6112
|
+
}
|
|
6113
|
+
return notes;
|
|
6114
|
+
};
|
|
6115
|
+
var automationRiskNotes = (changes, before) => {
|
|
6116
|
+
const notes = activationRiskNotes(changes, before);
|
|
6117
|
+
if (changes.simpleMode === true) {
|
|
6118
|
+
notes.push("Simple mode disables automatic gates, gate blocking, and configured call budgets; voluntary Advisor calls remain available.");
|
|
5950
6119
|
}
|
|
5951
6120
|
if (changes.advisorPlanGate === true || changes.advisorFailureGate === true || changes.advisorCompletionGate === true || changes.advisorAutoLoopGate === true) {
|
|
5952
6121
|
notes.push("Automatic gates may request extra Advisor calls; loop-gate failures can block a tool or session under the selected failure policy.");
|
|
@@ -5954,12 +6123,9 @@ var automationRiskNotes = (changes, before) => {
|
|
|
5954
6123
|
if (changes.gateFailureMode === "block-session" || changes.advisorBlockOnBlocked === true) {
|
|
5955
6124
|
notes.push("A blocked gate may stop the current session.");
|
|
5956
6125
|
}
|
|
5957
|
-
if (changes.advisorToolsEnabled === true) {
|
|
5958
|
-
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.");
|
|
5959
|
-
}
|
|
5960
6126
|
return notes;
|
|
5961
6127
|
};
|
|
5962
|
-
var disclosureRiskNotes = (changes) => {
|
|
6128
|
+
var disclosureRiskNotes = (changes, before) => {
|
|
5963
6129
|
const notes = [];
|
|
5964
6130
|
if (changes.advisorGitContext === "full") {
|
|
5965
6131
|
notes.push("Future Advisor requests may include repository patch contents.");
|
|
@@ -5967,6 +6133,15 @@ var disclosureRiskNotes = (changes) => {
|
|
|
5967
6133
|
if (changes.advisorTrackedFileContent === true) {
|
|
5968
6134
|
notes.push("This enables explicitly requested tracked file contents to be sent to the Advisor.");
|
|
5969
6135
|
}
|
|
6136
|
+
if (changes.advisorTrackedFileHandoff === "executor") {
|
|
6137
|
+
notes.push("The Executor will choose which tracked files to attach, and their contents may be sent to the Advisor on any consultation without the Advisor naming them first. Tracked file content consent is still required.");
|
|
6138
|
+
}
|
|
6139
|
+
const trackedFileContent = changes.advisorTrackedFileContent === undefined ? before.advisorTrackedFileContent : changes.advisorTrackedFileContent;
|
|
6140
|
+
const trackedFileHandoff = changes.advisorTrackedFileHandoff === undefined ? before.advisorTrackedFileHandoff : changes.advisorTrackedFileHandoff;
|
|
6141
|
+
const touchesTrackedFiles = changes.advisorTrackedFileContent !== undefined || changes.advisorTrackedFileHandoff !== undefined;
|
|
6142
|
+
if (touchesTrackedFiles && trackedFileHandoff === "executor" && trackedFileContent !== true) {
|
|
6143
|
+
notes.push("Executor tracked file handoff has no effect until Tracked file content is enabled.");
|
|
6144
|
+
}
|
|
5970
6145
|
if (changes.advisorUntrackedContent === true) {
|
|
5971
6146
|
notes.push("This enables explicitly requested untracked file contents to be sent to the Advisor.");
|
|
5972
6147
|
}
|
|
@@ -5999,7 +6174,7 @@ var advisorConfigRiskNotes = (changes, before, persisted) => [
|
|
|
5999
6174
|
...before,
|
|
6000
6175
|
alwaysOn: Object.hasOwn(persisted, "alwaysOn") ? persisted.alwaysOn === true : before.alwaysOn
|
|
6001
6176
|
}),
|
|
6002
|
-
...disclosureRiskNotes(changes),
|
|
6177
|
+
...disclosureRiskNotes(changes, before),
|
|
6003
6178
|
...costRiskNotes(changes)
|
|
6004
6179
|
];
|
|
6005
6180
|
|
|
@@ -6074,21 +6249,45 @@ var resolveModelChanges = async (ctx, changes, before, persisted, selectModels =
|
|
|
6074
6249
|
return selectedModelChanges(changes, selection, persisted);
|
|
6075
6250
|
};
|
|
6076
6251
|
|
|
6077
|
-
// src/commands/
|
|
6078
|
-
var
|
|
6252
|
+
// src/commands/activation-settings.ts
|
|
6253
|
+
var reconcileAdvisorToolsAfterSettings = (runtime, ctx, previous, refreshPersistentTools = true) => {
|
|
6079
6254
|
const next = getAdvisorSettings();
|
|
6080
|
-
const
|
|
6081
|
-
const
|
|
6082
|
-
|
|
6255
|
+
const modeChanged = previous.advisorActivation !== next.advisorActivation;
|
|
6256
|
+
const preferenceChanged = previous.advisorToolsEnabled !== next.advisorToolsEnabled;
|
|
6257
|
+
const sessionScoped = next.advisorActivation === "session";
|
|
6258
|
+
const enabledByAlwaysOn = !previous.alwaysOn && next.alwaysOn && !previous.advisorToolsEnabled && next.advisorToolsEnabled;
|
|
6259
|
+
const persistentOutOfSync = !sessionScoped && runtime.flowEnabled() !== next.advisorToolsEnabled;
|
|
6260
|
+
if (modeChanged || preferenceChanged || !refreshPersistentTools && persistentOutOfSync) {
|
|
6083
6261
|
runtime.noteAdvisorToolsStateChange();
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6262
|
+
}
|
|
6263
|
+
let enabled = next.advisorToolsEnabled;
|
|
6264
|
+
if (sessionScoped) {
|
|
6265
|
+
if (modeChanged) {
|
|
6266
|
+
runtime.advisorSessionState.sessionToolsEnabled = runtime.flowEnabled();
|
|
6267
|
+
} else if (preferenceChanged && !enabledByAlwaysOn) {
|
|
6268
|
+
runtime.advisorSessionState.sessionToolsEnabled = enabled;
|
|
6087
6269
|
}
|
|
6270
|
+
enabled = runtime.advisorSessionState.sessionToolsEnabled;
|
|
6271
|
+
setAdvisorToolsActive(runtime.pi, enabled, true);
|
|
6272
|
+
} else {
|
|
6273
|
+
if (modeChanged) {
|
|
6274
|
+
enableAdvisorConfigurationTool(runtime.pi);
|
|
6275
|
+
}
|
|
6276
|
+
if (refreshPersistentTools || modeChanged || preferenceChanged || persistentOutOfSync) {
|
|
6277
|
+
setAdvisorToolsActive(runtime.pi, enabled);
|
|
6278
|
+
}
|
|
6279
|
+
}
|
|
6280
|
+
if (!enabled) {
|
|
6281
|
+
runtime.resetSameModelNotice();
|
|
6088
6282
|
}
|
|
6089
6283
|
runtime.updateSameModelNotice(ctx);
|
|
6090
6284
|
runtime.updateAdvisorUsageStatus(ctx);
|
|
6091
6285
|
};
|
|
6286
|
+
|
|
6287
|
+
// src/commands/configuration-tool-runtime.ts
|
|
6288
|
+
var applyAdvisorConfigRuntimeSettings = (runtime, ctx, previous) => {
|
|
6289
|
+
reconcileAdvisorToolsAfterSettings(runtime, ctx, previous, false);
|
|
6290
|
+
};
|
|
6092
6291
|
var cancelledAdvisorConfigResult = (message) => ({
|
|
6093
6292
|
content: [{ text: message, type: "text" }],
|
|
6094
6293
|
details: { action: "update", applied: false, cancelled: true }
|
|
@@ -6171,8 +6370,9 @@ var prepareAdvisorConfigUpdate = async (ctx, input, selectModels) => {
|
|
|
6171
6370
|
};
|
|
6172
6371
|
var appliedAdvisorConfigResult = (prepared, savedPath) => {
|
|
6173
6372
|
const notices = [];
|
|
6373
|
+
const sessionScoped = prepared.proposed.advisorActivation === "session" || prepared.proposed.advisorActivation === undefined && prepared.beforeSettings.advisorActivation === "session";
|
|
6174
6374
|
if (Object.hasOwn(prepared.proposed, "alwaysOn") && prepared.proposed.alwaysOn === true) {
|
|
6175
|
-
notices.push("Always on applies to future sessions; this did not start an Advisor call.");
|
|
6375
|
+
notices.push(sessionScoped ? "Always on is saved but session activation starts inactive; this did not start an Advisor call." : "Always on applies to future sessions; this did not start an Advisor call.");
|
|
6176
6376
|
}
|
|
6177
6377
|
if (Object.hasOwn(prepared.proposed, "executor")) {
|
|
6178
6378
|
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.");
|
|
@@ -6213,6 +6413,11 @@ var savedButNotAppliedResult = (prepared, savedPath, message) => ({
|
|
|
6213
6413
|
});
|
|
6214
6414
|
var applyAdvisorConfigUpdate = (runtime, ctx, prepared, savedPath) => {
|
|
6215
6415
|
try {
|
|
6416
|
+
if (Object.hasOwn(prepared.proposed, "advisorActivation")) {
|
|
6417
|
+
clearSessionActivationOverrides(ctx);
|
|
6418
|
+
} else {
|
|
6419
|
+
clearSessionActivationOverrides(ctx, SESSION_ACTIVATION_KEYS.filter((key) => Object.hasOwn(prepared.proposed, key)));
|
|
6420
|
+
}
|
|
6216
6421
|
loadConfig(ctx);
|
|
6217
6422
|
if (!Object.hasOwn(prepared.proposed, "contextMaxChars") && prepared.before.contextMaxChars !== undefined) {
|
|
6218
6423
|
setContextMaxCharsRef(prepared.before.contextMaxChars);
|
|
@@ -6307,9 +6512,16 @@ var registerAdvisorConfigurationTool = (runtime, dependencies = {}) => {
|
|
|
6307
6512
|
// src/commands/lifecycle.ts
|
|
6308
6513
|
var registerCommandLifecycle = (runtime, activateAdvisor) => {
|
|
6309
6514
|
runtime.pi.on("session_start", async (_event, ctx) => {
|
|
6515
|
+
runtime.noteAdvisorToolsStateChange();
|
|
6516
|
+
runtime.advisorSessionState.sessionToolsEnabled = false;
|
|
6517
|
+
clearSessionActivationOverrides(ctx);
|
|
6310
6518
|
runtime.resetSameModelNotice();
|
|
6311
6519
|
try {
|
|
6312
6520
|
loadConfig(ctx);
|
|
6521
|
+
if (advisorActivationRef === "session") {
|
|
6522
|
+
setAdvisorToolsActive(runtime.pi, false, true);
|
|
6523
|
+
return;
|
|
6524
|
+
}
|
|
6313
6525
|
if (!advisorToolsEnabledRef) {
|
|
6314
6526
|
setAdvisorToolsActive(runtime.pi, false);
|
|
6315
6527
|
runtime.updateSameModelNotice(ctx);
|
|
@@ -6327,12 +6539,21 @@ var registerCommandLifecycle = (runtime, activateAdvisor) => {
|
|
|
6327
6539
|
notify(ctx, `${t("notify.activationFailed.prefix", "Advisor activation failed:")} ${message}`, "error");
|
|
6328
6540
|
}
|
|
6329
6541
|
});
|
|
6542
|
+
runtime.pi.on("session_tree", (_event, ctx) => {
|
|
6543
|
+
if (advisorActivationRef === "session") {
|
|
6544
|
+
runtime.noteAdvisorToolsStateChange();
|
|
6545
|
+
setAdvisorToolsActive(runtime.pi, runtime.advisorSessionState.sessionToolsEnabled, true);
|
|
6546
|
+
runtime.updateSameModelNotice(ctx);
|
|
6547
|
+
}
|
|
6548
|
+
});
|
|
6330
6549
|
runtime.pi.on("model_select", (event, ctx) => {
|
|
6331
6550
|
if (!runtime.suppressModelSelectionSync) {
|
|
6332
6551
|
runtime.updateSameModelNotice(ctx, event.model);
|
|
6333
6552
|
}
|
|
6334
6553
|
});
|
|
6335
6554
|
runtime.pi.on("session_shutdown", (_event, ctx) => {
|
|
6555
|
+
runtime.noteAdvisorToolsStateChange();
|
|
6556
|
+
clearSessionActivationOverrides(ctx);
|
|
6336
6557
|
if (ctx.hasUI) {
|
|
6337
6558
|
ctx.ui.setStatus("advisor-usage", undefined);
|
|
6338
6559
|
}
|
|
@@ -7432,6 +7653,13 @@ var registerManualCommand = (runtime) => {
|
|
|
7432
7653
|
};
|
|
7433
7654
|
|
|
7434
7655
|
// src/commands/model-commands.ts
|
|
7656
|
+
var MODEL_SETTINGS = [
|
|
7657
|
+
"advisor",
|
|
7658
|
+
"advisorEffort",
|
|
7659
|
+
"advisorFallbackModel",
|
|
7660
|
+
"executor",
|
|
7661
|
+
"executorEffort"
|
|
7662
|
+
];
|
|
7435
7663
|
var registerModelCommands = (runtime) => {
|
|
7436
7664
|
runtime.pi.registerCommand("advisor", {
|
|
7437
7665
|
description: "Enable the Executor/Advisor flow and switch to the configured or explicitly selected Executor model; accepts contextMaxChars=N",
|
|
@@ -7461,10 +7689,15 @@ var registerModelCommands = (runtime) => {
|
|
|
7461
7689
|
setAdvisorFallbackModelRef(selection.advisorFallbackModel);
|
|
7462
7690
|
setExecutorEffortRef(selection.executorEffort);
|
|
7463
7691
|
setAdvisorEffortRef(selection.advisorEffort);
|
|
7692
|
+
const sessionScoped = advisorActivationRef === "session";
|
|
7464
7693
|
const path = saveConfig(ctx, {
|
|
7694
|
+
forceKeys: sessionScoped ? MODEL_SETTINGS : undefined,
|
|
7465
7695
|
persistAdvisor: true,
|
|
7466
7696
|
persistExecutor: true
|
|
7467
7697
|
});
|
|
7698
|
+
if (sessionScoped) {
|
|
7699
|
+
clearSessionActivationOverrides(ctx, MODEL_SETTINGS);
|
|
7700
|
+
}
|
|
7468
7701
|
runtime.updateSameModelNotice(ctx);
|
|
7469
7702
|
ctx.ui.notify(`${t("notify.modelsSaved.prefix", "Saved Executor + Advisor configurations to")} ${path}`, "info");
|
|
7470
7703
|
}
|
|
@@ -7799,20 +8032,20 @@ class ManualAdvisorProgressComponent {
|
|
|
7799
8032
|
render(width) {
|
|
7800
8033
|
const box = renderAdvisorCallBox(this.question, this.theme);
|
|
7801
8034
|
if (this.state.phase === "complete" || this.state.phase === "cancelled") {
|
|
7802
|
-
return box.render(width);
|
|
8035
|
+
return [...box.render(width)];
|
|
7803
8036
|
}
|
|
7804
8037
|
const { scout } = this.state;
|
|
7805
8038
|
const scoutActive = scout?.status === "calling" || scout?.status === "streaming";
|
|
7806
8039
|
if (scoutActive) {
|
|
7807
8040
|
renderScoutDetails(box, scout, this.expanded, this.theme);
|
|
7808
|
-
return box.render(width);
|
|
8041
|
+
return [...box.render(width)];
|
|
7809
8042
|
}
|
|
7810
8043
|
if (scout?.status === "cancelled") {
|
|
7811
|
-
return box.render(width);
|
|
8044
|
+
return [...box.render(width)];
|
|
7812
8045
|
}
|
|
7813
8046
|
if (this.state.phase === "error") {
|
|
7814
8047
|
box.addChild(new Text4(this.theme.fg("error", this.theme.bold("◆ ADVISOR · FAILED")), 0, 0));
|
|
7815
|
-
return box.render(width);
|
|
8048
|
+
return [...box.render(width)];
|
|
7816
8049
|
}
|
|
7817
8050
|
const frame = SPINNER_FRAMES[Math.floor(Date.now() / 80) % SPINNER_FRAMES.length];
|
|
7818
8051
|
let status = t("manualProgress.working", "Working…");
|
|
@@ -7828,7 +8061,7 @@ class ManualAdvisorProgressComponent {
|
|
|
7828
8061
|
if (this.state.text) {
|
|
7829
8062
|
box.addChild(new Markdown2(adviceForDisplay(this.state.text, this.expanded), 0, 0, getMarkdownTheme2()));
|
|
7830
8063
|
}
|
|
7831
|
-
return box.render(width);
|
|
8064
|
+
return [...box.render(width)];
|
|
7832
8065
|
}
|
|
7833
8066
|
invalidate = noop;
|
|
7834
8067
|
}
|
|
@@ -8660,6 +8893,23 @@ var advisorModelWhitelistItem = (settings, modelRefs, keybindings, theme, tui) =
|
|
|
8660
8893
|
tui
|
|
8661
8894
|
})
|
|
8662
8895
|
});
|
|
8896
|
+
var advisorToolsItem = (settings) => ({
|
|
8897
|
+
currentValue: settingValue(settings.advisorToolsEnabled, true),
|
|
8898
|
+
description: settings.advisorActivation === "session" ? t("settings.advisorToolsEnabled.sessionDesc", "Saved preference for persistent mode. Changing it also toggles this session’s Advisor tools.") : t("settings.advisorToolsEnabled.desc", "Allow the model to call the Advisor tools; activation scope determines how long they stay enabled."),
|
|
8899
|
+
id: "advisorToolsEnabled",
|
|
8900
|
+
label: settings.advisorActivation === "session" ? t("settings.advisorToolsEnabled.savedLabel", "Advisor tools (saved)") : t("settings.advisorToolsEnabled.label", "Advisor tools"),
|
|
8901
|
+
values: TOGGLE_VALUES
|
|
8902
|
+
});
|
|
8903
|
+
var trackedFileHandoffItem = (settings) => {
|
|
8904
|
+
const mode = settings.trackedFileHandoff ?? "advisor-named";
|
|
8905
|
+
return {
|
|
8906
|
+
currentValue: mode,
|
|
8907
|
+
description: t("settings.trackedFileHandoff.desc", "When the Executor may attach tracked files: only after the Advisor names them, or on any consultation. Requires Tracked file content."),
|
|
8908
|
+
id: "trackedFileHandoff",
|
|
8909
|
+
label: t("settings.trackedFileHandoff.label", "Tracked file handoff"),
|
|
8910
|
+
values: withCurrentValue(mode, ["advisor-named", "executor"])
|
|
8911
|
+
};
|
|
8912
|
+
};
|
|
8663
8913
|
var createSettingsItems = ({
|
|
8664
8914
|
effortLevels,
|
|
8665
8915
|
fallbackModel,
|
|
@@ -8682,12 +8932,13 @@ var createSettingsItems = ({
|
|
|
8682
8932
|
values: presets.map((preset) => preset.label)
|
|
8683
8933
|
},
|
|
8684
8934
|
{
|
|
8685
|
-
currentValue:
|
|
8686
|
-
description: t("settings.
|
|
8687
|
-
id: "
|
|
8688
|
-
label: t("settings.
|
|
8689
|
-
values:
|
|
8935
|
+
currentValue: settings.advisorActivation ?? "persistent",
|
|
8936
|
+
description: t("settings.advisorActivation.desc", "Choose persistent activation or start inactive at each session start, including /reload."),
|
|
8937
|
+
id: "advisorActivation",
|
|
8938
|
+
label: t("settings.advisorActivation.label", "Advisor activation"),
|
|
8939
|
+
values: ["persistent", "session"]
|
|
8690
8940
|
},
|
|
8941
|
+
advisorToolsItem(settings),
|
|
8691
8942
|
{
|
|
8692
8943
|
currentValue: settingValue(settings.simpleMode, false),
|
|
8693
8944
|
description: t("settings.simpleMode.desc", "Keep enabled Advisor tools available on demand without automatic gates or blocks."),
|
|
@@ -8813,7 +9064,7 @@ var createSettingsItems = ({
|
|
|
8813
9064
|
title: t("settings.toolPolicies.label", "Tool disclosure policies"),
|
|
8814
9065
|
tui
|
|
8815
9066
|
})
|
|
8816
|
-
}, 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, {
|
|
9067
|
+
}, 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), trackedFileHandoffItem(settings), 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, {
|
|
8817
9068
|
jevClassifierRegistry,
|
|
8818
9069
|
jevKeyDeps,
|
|
8819
9070
|
onJevFilter,
|
|
@@ -8834,7 +9085,7 @@ class SettingsListAdapter {
|
|
|
8834
9085
|
this.list.invalidate();
|
|
8835
9086
|
}
|
|
8836
9087
|
render(width) {
|
|
8837
|
-
return this.list.render(width);
|
|
9088
|
+
return [...this.list.render(width)];
|
|
8838
9089
|
}
|
|
8839
9090
|
handleInput(keyData) {
|
|
8840
9091
|
this.list.handleInput(keyData);
|
|
@@ -8920,6 +9171,10 @@ var parseModelWhitelist = (value) => [
|
|
|
8920
9171
|
];
|
|
8921
9172
|
var applyModeMutation = (settings, id, value) => {
|
|
8922
9173
|
switch (id) {
|
|
9174
|
+
case "advisorActivation": {
|
|
9175
|
+
settings.advisorActivation = value === "session" ? "session" : "persistent";
|
|
9176
|
+
return true;
|
|
9177
|
+
}
|
|
8923
9178
|
case "advisorToolsEnabled": {
|
|
8924
9179
|
settings.advisorToolsEnabled = value === "On";
|
|
8925
9180
|
if (!settings.advisorToolsEnabled) {
|
|
@@ -8985,6 +9240,10 @@ var applyCoreMutation = (settings, id, value, presets) => {
|
|
|
8985
9240
|
settings.gitContext = value;
|
|
8986
9241
|
return true;
|
|
8987
9242
|
}
|
|
9243
|
+
case "trackedFileHandoff": {
|
|
9244
|
+
settings.trackedFileHandoff = value === "executor" ? "executor" : "advisor-named";
|
|
9245
|
+
return true;
|
|
9246
|
+
}
|
|
8988
9247
|
default: {
|
|
8989
9248
|
return false;
|
|
8990
9249
|
}
|
|
@@ -9242,7 +9501,7 @@ class AdvisorSettingsSelector {
|
|
|
9242
9501
|
showUsageDetails: this.settings.showUsageDetails ?? true,
|
|
9243
9502
|
toolPolicies: { ...this.settings.toolPolicies }
|
|
9244
9503
|
});
|
|
9245
|
-
if (id === "context" || id === "simpleMode" || id === "customRule" || id === "modelWhitelist" || id === "toolPolicies") {
|
|
9504
|
+
if (id === "context" || id === "advisorActivation" || id === "simpleMode" || id === "customRule" || id === "modelWhitelist" || id === "toolPolicies") {
|
|
9246
9505
|
this.settingsList = this.createSettingsList(id);
|
|
9247
9506
|
}
|
|
9248
9507
|
}
|
|
@@ -9271,6 +9530,7 @@ var applySessionSettings = (settings) => {
|
|
|
9271
9530
|
setShowUsageDetailsRef(settings.showUsageDetails ?? true);
|
|
9272
9531
|
setShowUsageFooterRef(settings.showUsageFooter ?? false);
|
|
9273
9532
|
setSimpleModeRef(settings.simpleMode ?? false);
|
|
9533
|
+
setAdvisorActivationRef(settings.advisorActivation ?? "persistent");
|
|
9274
9534
|
setAdvisorToolsEnabledRef(settings.advisorToolsEnabled ?? true);
|
|
9275
9535
|
setAlwaysOnRef(settings.alwaysOn ?? false);
|
|
9276
9536
|
setAdvisorFailureModeRef(settings.failureMode ?? "block-session");
|
|
@@ -9296,6 +9556,7 @@ var applyDisclosureSettings = (settings) => {
|
|
|
9296
9556
|
setAdvisorToolPoliciesRef(settings.toolPolicies ?? {});
|
|
9297
9557
|
setAdvisorAgentsMdContextRef(settings.agentsMdContext ?? true);
|
|
9298
9558
|
setAdvisorTrackedFileContentRef(settings.trackedFileContent ?? false);
|
|
9559
|
+
setAdvisorTrackedFileHandoffRef(settings.trackedFileHandoff ?? "advisor-named");
|
|
9299
9560
|
setAdvisorUntrackedContentRef(settings.untrackedContent ?? false);
|
|
9300
9561
|
setAdvisorOutcomeLoggingRef(settings.outcomeLogging ?? false);
|
|
9301
9562
|
};
|
|
@@ -9316,6 +9577,25 @@ var saveAdvisorSettings = (ctx, settings, options = {}) => {
|
|
|
9316
9577
|
if (!options.skipOutcomeLogging) {
|
|
9317
9578
|
saveGlobalOutcomeLogging(settings.outcomeLogging ?? false);
|
|
9318
9579
|
}
|
|
9580
|
+
if (previous.advisorActivation === "session") {
|
|
9581
|
+
const next = getAdvisorSettings();
|
|
9582
|
+
const changed = [];
|
|
9583
|
+
if (previous.contextMaxChars !== next.contextMaxChars) {
|
|
9584
|
+
changed.push("contextMaxChars");
|
|
9585
|
+
}
|
|
9586
|
+
if (previous.effort !== next.effort) {
|
|
9587
|
+
changed.push("advisorEffort");
|
|
9588
|
+
}
|
|
9589
|
+
if (previous.fallbackModel !== next.fallbackModel) {
|
|
9590
|
+
changed.push("advisorFallbackModel");
|
|
9591
|
+
}
|
|
9592
|
+
if (next.advisorActivation === "persistent") {
|
|
9593
|
+
clearSessionActivationOverrides(ctx);
|
|
9594
|
+
loadConfig(ctx);
|
|
9595
|
+
} else {
|
|
9596
|
+
clearSessionActivationOverrides(ctx, changed);
|
|
9597
|
+
}
|
|
9598
|
+
}
|
|
9319
9599
|
} catch (error) {
|
|
9320
9600
|
applyAdvisorSettings(previous);
|
|
9321
9601
|
throw error;
|
|
@@ -9324,6 +9604,7 @@ var saveAdvisorSettings = (ctx, settings, options = {}) => {
|
|
|
9324
9604
|
|
|
9325
9605
|
// src/commands/settings-commands.ts
|
|
9326
9606
|
var persistJevSettings = (ctx, settings, runtime) => {
|
|
9607
|
+
const previous = getAdvisorSettings();
|
|
9327
9608
|
try {
|
|
9328
9609
|
saveAdvisorSettings(ctx, settings, { skipOutcomeLogging: true });
|
|
9329
9610
|
} catch (error) {
|
|
@@ -9332,9 +9613,7 @@ var persistJevSettings = (ctx, settings, runtime) => {
|
|
|
9332
9613
|
return false;
|
|
9333
9614
|
}
|
|
9334
9615
|
try {
|
|
9335
|
-
|
|
9336
|
-
runtime.updateSameModelNotice(ctx);
|
|
9337
|
-
runtime.updateAdvisorUsageStatus(ctx);
|
|
9616
|
+
reconcileAdvisorToolsAfterSettings(runtime, ctx, previous);
|
|
9338
9617
|
} catch (error) {
|
|
9339
9618
|
const message = error instanceof Error ? error.message : String(error);
|
|
9340
9619
|
ctx.ui.notify(`${t("settingsCmd.refreshFailed.prefix", "Advisor settings were saved, but the status refresh failed:")} ${message}`, "warning");
|
|
@@ -9362,23 +9641,18 @@ var registerSettingsCommands = (runtime) => {
|
|
|
9362
9641
|
modelRefs: getConfiguredModelRefs(ctx),
|
|
9363
9642
|
onCancel: () => done(undefined),
|
|
9364
9643
|
onChange: (settings) => {
|
|
9365
|
-
const
|
|
9366
|
-
const toolsEnabled = settings.advisorToolsEnabled ?? true;
|
|
9644
|
+
const previous = getAdvisorSettings();
|
|
9367
9645
|
try {
|
|
9368
9646
|
saveAdvisorSettings(ctx, settings);
|
|
9369
|
-
|
|
9370
|
-
runtime.noteAdvisorToolsStateChange();
|
|
9371
|
-
}
|
|
9372
|
-
setAdvisorToolsActive(runtime.pi, toolsEnabled);
|
|
9373
|
-
runtime.updateSameModelNotice(ctx);
|
|
9374
|
-
runtime.updateAdvisorUsageStatus(ctx);
|
|
9647
|
+
reconcileAdvisorToolsAfterSettings(runtime, ctx, previous);
|
|
9375
9648
|
} catch (error) {
|
|
9376
|
-
const toolsDisabled =
|
|
9649
|
+
const toolsDisabled = previous.advisorToolsEnabled && settings.advisorToolsEnabled === false;
|
|
9377
9650
|
if (toolsDisabled) {
|
|
9378
9651
|
runtime.noteAdvisorToolsStateChange();
|
|
9379
9652
|
setAdvisorToolsEnabledRef(false);
|
|
9380
9653
|
setAlwaysOnRef(false);
|
|
9381
|
-
|
|
9654
|
+
runtime.advisorSessionState.sessionToolsEnabled = false;
|
|
9655
|
+
setAdvisorToolsActive(runtime.pi, false, previous.advisorActivation === "session");
|
|
9382
9656
|
runtime.resetSameModelNotice();
|
|
9383
9657
|
}
|
|
9384
9658
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -9394,10 +9668,11 @@ var registerSettingsCommands = (runtime) => {
|
|
|
9394
9668
|
}
|
|
9395
9669
|
});
|
|
9396
9670
|
runtime.pi.registerCommand("advisor-off", {
|
|
9397
|
-
description: "Disable
|
|
9671
|
+
description: "Disable Advisor tools; keep the current model",
|
|
9398
9672
|
handler: (_args, ctx) => {
|
|
9399
9673
|
runtime.noteAdvisorToolsStateChange();
|
|
9400
|
-
|
|
9674
|
+
runtime.advisorSessionState.sessionToolsEnabled = false;
|
|
9675
|
+
setAdvisorToolsActive(runtime.pi, false, advisorActivationRef === "session");
|
|
9401
9676
|
runtime.resetSameModelNotice();
|
|
9402
9677
|
try {
|
|
9403
9678
|
loadConfig(ctx);
|
|
@@ -9408,6 +9683,11 @@ var registerSettingsCommands = (runtime) => {
|
|
|
9408
9683
|
notify(ctx, `${t("settingsCmd.offReloadFailed.prefix", "Advisor tools disabled for this session, but configuration could not be reloaded:")} ${message}`, "error");
|
|
9409
9684
|
return Promise.resolve();
|
|
9410
9685
|
}
|
|
9686
|
+
if (advisorActivationRef === "session") {
|
|
9687
|
+
setAdvisorToolsActive(runtime.pi, false, true);
|
|
9688
|
+
notify(ctx, t("settingsCmd.off.session", "Advisor tools disabled for this session. Current model unchanged."), "info");
|
|
9689
|
+
return Promise.resolve();
|
|
9690
|
+
}
|
|
9411
9691
|
const wasAlwaysOn = alwaysOnRef;
|
|
9412
9692
|
const persisted = getPersistedModelRefs();
|
|
9413
9693
|
setAdvisorToolsEnabledRef(false);
|
|
@@ -9443,6 +9723,9 @@ var registerCommands = (pi, dependencies = {}) => {
|
|
|
9443
9723
|
registerAdvisorConfigurationTool(runtime);
|
|
9444
9724
|
};
|
|
9445
9725
|
|
|
9726
|
+
// src/tools/session-availability.ts
|
|
9727
|
+
var advisorToolsAllowed = (session) => advisorActivationRef === "session" ? session.sessionToolsEnabled : advisorToolsEnabledRef;
|
|
9728
|
+
|
|
9446
9729
|
// src/tools/budget-feedback.ts
|
|
9447
9730
|
var advisorBudgetMessage = (session) => {
|
|
9448
9731
|
const simple = isSimpleMode();
|
|
@@ -9467,7 +9750,7 @@ var advisorBudgetUpdate = (event, ctx, pi, session) => {
|
|
|
9467
9750
|
} catch {
|
|
9468
9751
|
return;
|
|
9469
9752
|
}
|
|
9470
|
-
if (!
|
|
9753
|
+
if (!advisorToolsAllowed(session) || !advisorModelIsAllowed(ctx)) {
|
|
9471
9754
|
return;
|
|
9472
9755
|
}
|
|
9473
9756
|
const message = advisorBudgetMessage(session);
|
|
@@ -9870,9 +10153,13 @@ var claimTrackedHandoff = (session, includeTrackedFiles) => {
|
|
|
9870
10153
|
if (!includeTrackedFiles?.length) {
|
|
9871
10154
|
return;
|
|
9872
10155
|
}
|
|
9873
|
-
|
|
10156
|
+
const settings = getAdvisorSettings();
|
|
10157
|
+
if (!settings.trackedFileContent) {
|
|
9874
10158
|
throw new Error("Tracked file attachments are disabled: enable the global advisorTrackedFileContent setting (Tracked file content in /advisor-settings) and retry.");
|
|
9875
10159
|
}
|
|
10160
|
+
if (settings.trackedFileHandoff === "executor") {
|
|
10161
|
+
return;
|
|
10162
|
+
}
|
|
9876
10163
|
if (!session.claimTrackedFiles(includeTrackedFiles)) {
|
|
9877
10164
|
throw new Error("Tracked file handoff requires a prior Advisor response that explicitly names every requested path and is consumed once.");
|
|
9878
10165
|
}
|
|
@@ -9886,7 +10173,7 @@ var registerAskAdvisorTool = ({
|
|
|
9886
10173
|
session
|
|
9887
10174
|
}) => {
|
|
9888
10175
|
pi.registerTool({
|
|
9889
|
-
description: "Consult the on-demand Advisor model for strategic guidance. Call with an empty object for a contextual review; attach an optional draft for concrete plan or completion review. Use followUpTo with a new question to continue one cached consultation without rebuilding its redacted context.
|
|
10176
|
+
description: "Consult the on-demand Advisor model for strategic guidance. Call with an empty object for a contextual review; attach an optional draft for concrete plan or completion review. Use followUpTo with a new question to continue one cached consultation without rebuilding its redacted context. Attach tracked files with includeTrackedFiles only after the Advisor names them, unless the Advisor invocation settings explicitly allow attaching them earlier; it requires global advisorTrackedFileContent consent and sends file contents as untrusted data. In Pi Codemode, gather and filter deterministic tool results first, then call tools.ask_advisor. Nested results are not automatically reconstructed: pass only permitted, concise summaries in draft (untrusted, capped at 8 KiB, not independently verified). Draft does not inherit source-tool disclosure policies; use gitContext for patches within the user's allowance.",
|
|
9890
10177
|
async execute(_id, params, signal, onUpdate, ctx) {
|
|
9891
10178
|
let followUp;
|
|
9892
10179
|
try {
|
|
@@ -10100,7 +10387,7 @@ ${result.markdown}`,
|
|
|
10100
10387
|
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."
|
|
10101
10388
|
})),
|
|
10102
10389
|
includeTrackedFiles: Type3.Optional(Type3.Array(Type3.String({
|
|
10103
|
-
description: "Exact tracked repository-relative files to attach
|
|
10390
|
+
description: "Exact tracked repository-relative files to attach. By default only files the latest Advisor answer names are accepted, unless the Advisor invocation settings explicitly allow earlier attachment. Requires global advisorTrackedFileContent consent; current working-tree contents are sent as untrusted data."
|
|
10104
10391
|
}))),
|
|
10105
10392
|
includeUntracked: Type3.Optional(Type3.Array(Type3.String({
|
|
10106
10393
|
description: "Exact new repository-relative files to include only when user configuration allows it."
|
|
@@ -10110,7 +10397,7 @@ ${result.markdown}`,
|
|
|
10110
10397
|
}))
|
|
10111
10398
|
}),
|
|
10112
10399
|
promptGuidelines: [
|
|
10113
|
-
"Call ask_advisor with an empty object for general consultation. For a plan or completion review, include a concise draft naming work, validation, and remaining risks; its claims are not evidence. To drill into an existing answer, pass its adviceId as followUpTo with a new question and no draft, Git context, or attachments.
|
|
10400
|
+
"Call ask_advisor with an empty object for general consultation. For a plan or completion review, include a concise draft naming work, validation, and remaining risks; its claims are not evidence. To drill into an existing answer, pass its adviceId as followUpTo with a new question and no draft, Git context, or attachments. Attach tracked files with includeTrackedFiles only after the Advisor names them, unless the Advisor invocation settings explicitly allow attaching them earlier; use exact repository-relative paths that are relevant and permitted, and do not guess paths."
|
|
10114
10401
|
],
|
|
10115
10402
|
promptSnippet: "Consult the Advisor using its existing context; attach a draft for plan or completion review",
|
|
10116
10403
|
renderCall(args, theme) {
|
|
@@ -10299,7 +10586,7 @@ var registerToolLifecycle = ({
|
|
|
10299
10586
|
return;
|
|
10300
10587
|
}
|
|
10301
10588
|
loadConfig(ctx);
|
|
10302
|
-
if (!
|
|
10589
|
+
if (!advisorToolsAllowed(session) || !advisorModelAccess(ctx).allowed || sameModelAdvisorDisabled(ctx)) {
|
|
10303
10590
|
return;
|
|
10304
10591
|
}
|
|
10305
10592
|
const guidelines = advisorInvocationGuidelines();
|
|
@@ -10333,20 +10620,20 @@ ${guidelines.map((rule) => `- ${rule}`).join(`
|
|
|
10333
10620
|
reason: session.blockedReason ?? "Advisor session is blocked."
|
|
10334
10621
|
};
|
|
10335
10622
|
}
|
|
10336
|
-
const isAdvisorTool = event.toolName === "ask_advisor" || event.toolName === "record_advisor_outcome";
|
|
10337
|
-
if (isAdvisorTool && !
|
|
10623
|
+
const isAdvisorTool = event.toolName === "ask_advisor" || event.toolName === "record_advisor_outcome" || event.toolName === "advisor_config" && advisorActivationRef === "session";
|
|
10624
|
+
if (isAdvisorTool && !advisorToolsAllowed(session)) {
|
|
10338
10625
|
return {
|
|
10339
10626
|
block: true,
|
|
10340
10627
|
reason: "Advisor tools are disabled. Enable them in /advisor-settings or run /advisor."
|
|
10341
10628
|
};
|
|
10342
10629
|
}
|
|
10343
|
-
if (!pi.getActiveTools().includes("ask_advisor")) {
|
|
10630
|
+
if (!pi.getActiveTools().includes("ask_advisor") || advisorActivationRef === "session" && !session.sessionToolsEnabled) {
|
|
10344
10631
|
return;
|
|
10345
10632
|
}
|
|
10346
10633
|
if (!loadConfigOrSkipGating(ctx)) {
|
|
10347
10634
|
return;
|
|
10348
10635
|
}
|
|
10349
|
-
if (isAdvisorTool && !
|
|
10636
|
+
if (isAdvisorTool && !advisorToolsAllowed(session)) {
|
|
10350
10637
|
return {
|
|
10351
10638
|
block: true,
|
|
10352
10639
|
reason: "Advisor tools are disabled. Enable them in /advisor-settings or run /advisor."
|
|
@@ -10546,7 +10833,10 @@ var registerAdvisorTool = (pi, session = sessionStateFor(pi), dependencies = {})
|
|
|
10546
10833
|
registerAskAdvisorTool(registration);
|
|
10547
10834
|
registerOutcomeTool(registration);
|
|
10548
10835
|
const turnGate = {
|
|
10549
|
-
activeTools: () =>
|
|
10836
|
+
activeTools: () => {
|
|
10837
|
+
const active = pi.getActiveTools();
|
|
10838
|
+
return advisorActivationRef === "session" && !session.sessionToolsEnabled ? active.filter((name) => name !== "ask_advisor") : active;
|
|
10839
|
+
},
|
|
10550
10840
|
consult: registration.consult,
|
|
10551
10841
|
herdrActivity: registration.herdrActivity,
|
|
10552
10842
|
send: (message) => pi.sendMessage(message, { deliverAs: "steer" }),
|