pi-advisor-flow 0.15.1 → 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 +5 -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
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { getKeybindings } from "@earendil-works/pi-tui";
|
|
3
|
+
import type { SettingItem } from "@earendil-works/pi-tui";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_JEV_DIGEST_MAX_CHARS,
|
|
7
|
+
DEFAULT_JEV_FILTER_NOUL_MARGIN,
|
|
8
|
+
DEFAULT_JEV_FILTER_OVERRIDE_WINDOW,
|
|
9
|
+
DEFAULT_JEV_FILTER_SKIP_CONFIDENCE,
|
|
10
|
+
DEFAULT_JEV_TIMEOUT_MS,
|
|
11
|
+
DEFAULT_JEV_TURN_GATE_NOUL_THRESHOLD,
|
|
12
|
+
} from "../config/types.ts";
|
|
13
|
+
import { t } from "../i18n.ts";
|
|
14
|
+
import type { JevClassifierKeySnapshot } from "../jev/classifier-key-store.ts";
|
|
15
|
+
import { JevClassifierSubmenu } from "./jev-classifier-submenu.ts";
|
|
16
|
+
import { JevFilterSubmenu } from "./jev-filter-submenu.ts";
|
|
17
|
+
import { numericValues } from "./settings-formatting.ts";
|
|
18
|
+
import type {
|
|
19
|
+
AdvisorSettings,
|
|
20
|
+
JevClassifierRegistryAccess,
|
|
21
|
+
JevFilterSelection,
|
|
22
|
+
JevProviderSelection,
|
|
23
|
+
RenderRequester,
|
|
24
|
+
} from "./types.ts";
|
|
25
|
+
|
|
26
|
+
export interface JevItemsDependencies {
|
|
27
|
+
jevClassifierRegistry?: JevClassifierRegistryAccess;
|
|
28
|
+
jevKeyDeps?: {
|
|
29
|
+
resolveClassifierKey?: () => Promise<JevClassifierKeySnapshot>;
|
|
30
|
+
persistClassifierKey?: (
|
|
31
|
+
key: string
|
|
32
|
+
) => Promise<{ ok: boolean; message: string }>;
|
|
33
|
+
restoreClassifierKey?: (
|
|
34
|
+
previous: JevClassifierKeySnapshot
|
|
35
|
+
) => Promise<boolean>;
|
|
36
|
+
};
|
|
37
|
+
onJevFilter?: (selection: JevFilterSelection) => boolean;
|
|
38
|
+
onJevProvider?: (selection: JevProviderSelection) => boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const jevFilterRowValue = (settings: AdvisorSettings) => {
|
|
42
|
+
if (!settings.jevFilterEnabled) {
|
|
43
|
+
return "Off";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return settings.jevClassifier
|
|
47
|
+
? "On"
|
|
48
|
+
: t("settings.jevFilter.onUnavailable", "On (unavailable: no classifier)");
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const jevItems = (
|
|
52
|
+
settings: AdvisorSettings,
|
|
53
|
+
theme: Theme,
|
|
54
|
+
tui: RenderRequester,
|
|
55
|
+
{
|
|
56
|
+
jevClassifierRegistry,
|
|
57
|
+
jevKeyDeps,
|
|
58
|
+
onJevFilter,
|
|
59
|
+
onJevProvider,
|
|
60
|
+
}: JevItemsDependencies
|
|
61
|
+
): SettingItem[] => [
|
|
62
|
+
{
|
|
63
|
+
currentValue:
|
|
64
|
+
settings.jevClassifier ??
|
|
65
|
+
t("settings.jevProvider.choose", "Choose classifier"),
|
|
66
|
+
description: t(
|
|
67
|
+
"settings.jevProvider.desc",
|
|
68
|
+
"Select a Pi-authenticated classifier or explicitly configure the separate Jev API Key option."
|
|
69
|
+
),
|
|
70
|
+
id: "jevProvider",
|
|
71
|
+
label: t("settings.jevProvider.label", "Jev classifier"),
|
|
72
|
+
submenu: (currentValue, done) =>
|
|
73
|
+
new JevClassifierSubmenu({
|
|
74
|
+
currentValue,
|
|
75
|
+
done,
|
|
76
|
+
keybindings: getKeybindings(),
|
|
77
|
+
modelRegistry: jevClassifierRegistry,
|
|
78
|
+
onSelection: onJevProvider,
|
|
79
|
+
persistKey: jevKeyDeps?.persistClassifierKey,
|
|
80
|
+
resolveStoredKey: jevKeyDeps?.resolveClassifierKey,
|
|
81
|
+
restoreKey: jevKeyDeps?.restoreClassifierKey,
|
|
82
|
+
theme,
|
|
83
|
+
tui,
|
|
84
|
+
}),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
currentValue: jevFilterRowValue(settings),
|
|
88
|
+
description: t(
|
|
89
|
+
"settings.jevFilter.desc",
|
|
90
|
+
"Screen low-stakes ask_advisor consultations with the selected Jev provider."
|
|
91
|
+
),
|
|
92
|
+
id: "jevFilter",
|
|
93
|
+
label: t("settings.jevFilter.label", "Jev/Decisions consultation filter"),
|
|
94
|
+
submenu: (currentValue, done) =>
|
|
95
|
+
new JevFilterSubmenu({
|
|
96
|
+
currentClassifier: settings.jevClassifier,
|
|
97
|
+
currentValue,
|
|
98
|
+
done,
|
|
99
|
+
modelRegistry: jevClassifierRegistry,
|
|
100
|
+
onSelection: onJevFilter,
|
|
101
|
+
resolveClassifierKey: jevKeyDeps?.resolveClassifierKey,
|
|
102
|
+
theme,
|
|
103
|
+
tui,
|
|
104
|
+
}),
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
currentValue: String(
|
|
108
|
+
settings.jevFilterSkipConfidence ?? DEFAULT_JEV_FILTER_SKIP_CONFIDENCE
|
|
109
|
+
),
|
|
110
|
+
description: t(
|
|
111
|
+
"settings.jevFilterSkipConfidence.desc",
|
|
112
|
+
"Required probability on negligible stakes before a consultation is skipped."
|
|
113
|
+
),
|
|
114
|
+
id: "jevFilterSkipConfidence",
|
|
115
|
+
label: t("settings.jevFilterSkipConfidence.label", "Jev skip confidence"),
|
|
116
|
+
values: numericValues(
|
|
117
|
+
settings.jevFilterSkipConfidence ?? DEFAULT_JEV_FILTER_SKIP_CONFIDENCE,
|
|
118
|
+
[0.6, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95]
|
|
119
|
+
),
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
currentValue: String(
|
|
123
|
+
settings.jevFilterNoulMargin ?? DEFAULT_JEV_FILTER_NOUL_MARGIN
|
|
124
|
+
),
|
|
125
|
+
description: t(
|
|
126
|
+
"settings.jevFilterNoulMargin.desc",
|
|
127
|
+
"Extra margin over a coin flip required on self-answerability before skipping."
|
|
128
|
+
),
|
|
129
|
+
id: "jevFilterNoulMargin",
|
|
130
|
+
label: t("settings.jevFilterNoulMargin.label", "Jev Noul margin"),
|
|
131
|
+
values: numericValues(
|
|
132
|
+
settings.jevFilterNoulMargin ?? DEFAULT_JEV_FILTER_NOUL_MARGIN,
|
|
133
|
+
[0.1, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45]
|
|
134
|
+
),
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
currentValue: `${settings.jevFilterOverrideWindow ?? DEFAULT_JEV_FILTER_OVERRIDE_WINDOW} ${t("settings.jev.turnsUnit", "turns")}`,
|
|
138
|
+
description: t(
|
|
139
|
+
"settings.jevFilterOverrideWindow.desc",
|
|
140
|
+
"Turns after a skip during which the same question passes automatically."
|
|
141
|
+
),
|
|
142
|
+
id: "jevFilterOverrideWindow",
|
|
143
|
+
label: t("settings.jevFilterOverrideWindow.label", "Jev override window"),
|
|
144
|
+
values: numericValues(
|
|
145
|
+
settings.jevFilterOverrideWindow ?? DEFAULT_JEV_FILTER_OVERRIDE_WINDOW,
|
|
146
|
+
[0, 3, 5, 10, 20, 50]
|
|
147
|
+
).map((value) => `${value} ${t("settings.jev.turnsUnit", "turns")}`),
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
currentValue: String(settings.jevTimeoutMs ?? DEFAULT_JEV_TIMEOUT_MS),
|
|
151
|
+
description: t(
|
|
152
|
+
"settings.jevTimeoutMs.desc",
|
|
153
|
+
"Total wall-time budget for one Jev call, including retries."
|
|
154
|
+
),
|
|
155
|
+
id: "jevTimeoutMs",
|
|
156
|
+
label: t("settings.jevTimeoutMs.label", "Jev timeout ms"),
|
|
157
|
+
values: numericValues(
|
|
158
|
+
settings.jevTimeoutMs ?? DEFAULT_JEV_TIMEOUT_MS,
|
|
159
|
+
[1000, 2000, 5000, 8000, 15_000, 30_000]
|
|
160
|
+
),
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
currentValue: String(
|
|
164
|
+
settings.jevDigestMaxChars ?? DEFAULT_JEV_DIGEST_MAX_CHARS
|
|
165
|
+
),
|
|
166
|
+
description: t(
|
|
167
|
+
"settings.jevDigestMaxChars.desc",
|
|
168
|
+
"Conversation characters sent to Jev as screening evidence."
|
|
169
|
+
),
|
|
170
|
+
id: "jevDigestMaxChars",
|
|
171
|
+
label: t("settings.jevDigestMaxChars.label", "Jev digest chars"),
|
|
172
|
+
values: numericValues(
|
|
173
|
+
settings.jevDigestMaxChars ?? DEFAULT_JEV_DIGEST_MAX_CHARS,
|
|
174
|
+
[0, 1000, 2000, 4000, 8000, 15_000]
|
|
175
|
+
),
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
{
|
|
179
|
+
currentValue:
|
|
180
|
+
settings.jevTurnGateEveryTurns === 0 ||
|
|
181
|
+
settings.jevTurnGateEveryTurns === undefined
|
|
182
|
+
? "Off"
|
|
183
|
+
: `every ${settings.jevTurnGateEveryTurns} turns`,
|
|
184
|
+
description: t(
|
|
185
|
+
"settings.jevTurnGateEveryTurns.desc",
|
|
186
|
+
"Proactively consult the Advisor every N turns without a consultation (0 = off)."
|
|
187
|
+
),
|
|
188
|
+
id: "jevTurnGateEveryTurns",
|
|
189
|
+
label: t("settings.jevTurnGateEveryTurns.label", "Jev/Decisions turn gate"),
|
|
190
|
+
values: [
|
|
191
|
+
"Off",
|
|
192
|
+
"every 3 turns",
|
|
193
|
+
"every 5 turns",
|
|
194
|
+
"every 10 turns",
|
|
195
|
+
"every 20 turns",
|
|
196
|
+
],
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
currentValue: String(
|
|
200
|
+
settings.jevTurnGateNoulThreshold ?? DEFAULT_JEV_TURN_GATE_NOUL_THRESHOLD
|
|
201
|
+
),
|
|
202
|
+
description: t(
|
|
203
|
+
"settings.jevTurnGateNoulThreshold.desc",
|
|
204
|
+
"Jev confidence required before the turn gate interrupts with advice."
|
|
205
|
+
),
|
|
206
|
+
id: "jevTurnGateNoulThreshold",
|
|
207
|
+
label: t(
|
|
208
|
+
"settings.jevTurnGateNoulThreshold.label",
|
|
209
|
+
"Jev/Decisions turn-gate threshold"
|
|
210
|
+
),
|
|
211
|
+
values: numericValues(
|
|
212
|
+
settings.jevTurnGateNoulThreshold ?? DEFAULT_JEV_TURN_GATE_NOUL_THRESHOLD,
|
|
213
|
+
[0.6, 0.7, 0.8, 0.85, 0.9, 0.95]
|
|
214
|
+
),
|
|
215
|
+
},
|
|
216
|
+
];
|