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.
Files changed (71) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +16 -1
  3. package/dist/index.js +1157 -502
  4. package/docs/README.md +9 -0
  5. package/docs/benchmark.md +22 -0
  6. package/docs/configuration.md +194 -0
  7. package/docs/development.md +38 -0
  8. package/docs/herdr.md +169 -0
  9. package/docs/privacy.md +102 -0
  10. package/extensions/index.ts +23 -0
  11. package/locales/de.json +330 -0
  12. package/locales/en.json +331 -0
  13. package/locales/es.json +3 -0
  14. package/locales/fr.json +330 -0
  15. package/locales/pt-BR.json +3 -0
  16. package/locales/pt.json +3 -0
  17. package/locales/ru.json +3 -0
  18. package/locales/uk.json +3 -0
  19. package/locales/zh.json +3 -0
  20. package/package.json +15 -2
  21. package/skills/pi-advisor-flow/SKILL.md +62 -0
  22. package/src/commands/activation-preparation.ts +9 -2
  23. package/src/commands/activation.ts +28 -8
  24. package/src/commands/configuration-tool-models.ts +143 -0
  25. package/src/commands/configuration-tool-policy.ts +177 -0
  26. package/src/commands/configuration-tool-preview.ts +228 -0
  27. package/src/commands/configuration-tool-runtime.ts +40 -0
  28. package/src/commands/configuration-tool-transaction.ts +120 -0
  29. package/src/commands/configuration-tool-update.ts +230 -0
  30. package/src/commands/configuration-tool.ts +89 -0
  31. package/src/commands/lifecycle.ts +6 -1
  32. package/src/commands/manual-consultation.ts +6 -1
  33. package/src/commands/manual-progress.ts +4 -3
  34. package/src/commands/model-commands.ts +2 -1
  35. package/src/commands/model-options.ts +4 -6
  36. package/src/commands/model-picker.ts +16 -6
  37. package/src/commands/registration.ts +2 -0
  38. package/src/commands/runtime.ts +17 -4
  39. package/src/commands/settings-commands.ts +30 -7
  40. package/src/config/schema-validators.ts +104 -0
  41. package/src/config/schema.ts +35 -102
  42. package/src/config/storage.ts +160 -7
  43. package/src/i18n.ts +31 -0
  44. package/src/scout-group-serialization.ts +66 -0
  45. package/src/scout-groups.ts +3 -66
  46. package/src/scout-selection.ts +99 -0
  47. package/src/scout.ts +6 -93
  48. package/src/session-state.ts +27 -137
  49. package/src/tool-input-normalization.ts +119 -0
  50. package/src/tools/gate-policy.ts +13 -5
  51. package/src/tools/jev-filter.ts +2 -1
  52. package/src/tools/jev-turn-gate.ts +2 -1
  53. package/src/tools/register-lifecycle.ts +5 -1
  54. package/src/tools/register-outcome.ts +5 -1
  55. package/src/tools/register-renderers.ts +5 -2
  56. package/src/tools/render-advisor-result.ts +20 -8
  57. package/src/tools/render-common.ts +16 -4
  58. package/src/tools/scout-status.ts +10 -2
  59. package/src/ui/jev-classifier-submenu.ts +143 -38
  60. package/src/ui/jev-filter-submenu.ts +52 -14
  61. package/src/ui/jev-provider-submenu-view.ts +72 -20
  62. package/src/ui/jev-provider-submenu.ts +40 -12
  63. package/src/ui/jev-setup-support.ts +48 -19
  64. package/src/ui/manual-dialog-render.ts +71 -25
  65. package/src/ui/searchable-model-list.ts +18 -4
  66. package/src/ui/settings-formatting.ts +5 -2
  67. package/src/ui/settings-items-jev.ts +216 -0
  68. package/src/ui/settings-items.ts +216 -259
  69. package/src/ui/settings-selector.ts +9 -2
  70. package/src/ui/text-setting-submenu.ts +8 -1
  71. 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
+ ];