gentle-pi 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -6
- package/assets/agents/gentle-ai-verify.md +4 -0
- package/assets/agents/gentle-ai-worker.md +1 -0
- package/assets/migrations/agent-body-history.json +147 -0
- package/assets/orchestrator-delegation-reference.md +3 -3
- package/assets/orchestrator-delegation.md +2 -2
- package/assets/orchestrator-verification.md +10 -6
- package/assets/orchestrator.md +8 -8
- package/bin/gentle-shell.mjs +61 -26
- package/docs/ci-performance.md +11 -0
- package/docs/delegated-verification.md +6 -0
- package/docs/fast-mode.md +15 -0
- package/docs/gentle-agents-activity.md +8 -0
- package/docs/gentle-music.md +6 -3
- package/docs/gentle-shell.md +70 -20
- package/docs/install-wizard.md +1 -1
- package/docs/mcp-status.md +52 -0
- package/docs/prompt-budget.md +28 -0
- package/docs/readme-reference.md +82 -21
- package/docs/session-profile-format.md +20 -5
- package/docs/sound-notifications.md +1 -1
- package/docs/star-prompt.md +32 -0
- package/docs/work-continuity.md +46 -0
- package/extensions/ask-user-question.ts +1 -0
- package/extensions/codegraph-tools.ts +38 -4
- package/extensions/gentle-agents.ts +477 -50
- package/extensions/gentle-ai.ts +1046 -191
- package/extensions/gentle-fast.ts +61 -0
- package/extensions/gentle-guide.ts +174 -0
- package/extensions/gentle-herdr-activity.ts +21 -1
- package/extensions/gentle-herdr-agent.ts +144 -0
- package/extensions/gentle-music.ts +10 -0
- package/extensions/gentle-program-identity.ts +61 -0
- package/extensions/gentle-shell.ts +642 -97
- package/extensions/gentle-star-prompt.ts +334 -0
- package/extensions/gentle-stats.ts +5 -5
- package/extensions/gentle-todo.ts +42 -22
- package/extensions/history/store.ts +18 -12
- package/extensions/skill-registry.ts +35 -3
- package/extensions/startup-banner.ts +39 -7
- package/lib/agent-assets.ts +74 -17
- package/lib/agent-profiles.ts +1 -1
- package/lib/agents-config.ts +12 -3
- package/lib/agents-keys.ts +8 -16
- package/lib/agents-protocol.ts +80 -4
- package/lib/agents-runner.ts +105 -4
- package/lib/agents-view.ts +6 -1
- package/lib/agents-widget.ts +132 -9
- package/lib/bridge-cost.ts +28 -0
- package/lib/codemode-renderer.ts +16 -0
- package/lib/command-palette-catalog.ts +1 -0
- package/lib/command-palette.ts +21 -8
- package/lib/exploration-budget.ts +62 -0
- package/lib/gentle-guide.ts +201 -0
- package/lib/gentle-shell-launcher.ts +4 -0
- package/lib/herdr-activity.ts +9 -3
- package/lib/herdr-task-summary-policy.ts +85 -0
- package/lib/inprocess-reviewer.ts +33 -13
- package/lib/jobs-sidebar-state.ts +5 -6
- package/lib/jobs-widget.ts +16 -52
- package/lib/keymaps-customize.ts +81 -0
- package/lib/keymaps.ts +291 -0
- package/lib/model-fallback-notice.ts +61 -0
- package/lib/model-fallback-policy.ts +141 -0
- package/lib/model-fallback-store.ts +143 -0
- package/lib/model-routing-authority.ts +10 -2
- package/lib/nan-provider.ts +3 -2
- package/lib/native-review-cli.ts +7 -2
- package/lib/notification-customize.ts +48 -51
- package/lib/openai-fast-tier.ts +22 -0
- package/lib/orchestrator-discovery.ts +5 -1
- package/lib/orchestrator-fallback.ts +75 -0
- package/lib/pasted-image-paths.ts +113 -0
- package/lib/questionnaire/questionnaire-view.ts +121 -7
- package/lib/review-candidate-view-owner.ts +4 -0
- package/lib/review-candidate-view.ts +10 -7
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +22 -7
- package/lib/review-repository.ts +5 -0
- package/lib/session-profile-append-controller.ts +21 -6
- package/lib/session-profile-authority.ts +119 -0
- package/lib/session-profile-binding.ts +54 -5
- package/lib/session-profile-freeze.ts +105 -9
- package/lib/session-profile-integration.ts +313 -0
- package/lib/session-profile-persistence.ts +63 -9
- package/lib/shell-bar.ts +171 -56
- package/lib/shell-card.ts +26 -6
- package/lib/shell-page.ts +120 -0
- package/lib/shell-panel.ts +149 -0
- package/lib/shell-prompt.ts +53 -1
- package/lib/shell-sidebar-layout.ts +98 -25
- package/lib/shell-sidebar.ts +54 -1
- package/lib/shell-stats.ts +123 -0
- package/lib/shell-todo.ts +71 -0
- package/lib/shell-usage.ts +12 -2
- package/lib/star-prompt.ts +197 -0
- package/lib/verifier-admission.ts +18 -8
- package/lib/verifier-settle-reminder.ts +64 -0
- package/lib/vim-editor-adapter.ts +6 -1
- package/lib/visual-customization-policy.ts +41 -6
- package/lib/visual-customize-view.ts +164 -26
- package/lib/visual-layout-preview.ts +43 -0
- package/lib/yolo-session-policy.ts +28 -1
- package/package.json +1 -1
- package/runtime/gentle-shell-launcher.mjs +4 -0
- package/runtime/native-review-cli.mjs +7 -2
- package/runtime/review-integration-v2.mjs +22 -7
- package/runtime/windows-session-transport.ps1 +60 -3
- package/scripts/bootstrap.sh +4 -1
- package/scripts/installer-preflight.mjs +1 -1
- package/scripts/pi-update.mjs +113 -3
- package/scripts/run-test-suite.mjs +17 -1
- package/scripts/shell-snapshot.mjs +340 -0
- package/scripts/test-packed-runner.mjs +1 -1
- package/scripts/update-agent-body-history.mjs +41 -0
- package/scripts/verify-installer-tap.mjs +45 -0
- package/scripts/verify-package-files.mjs +2 -0
- package/skills/gentle-ai/SKILL.md +2 -2
- package/skills/tui-design/NOTICE.md +5 -0
- package/skills/tui-design/SKILL.md +56 -0
- package/skills/tui-design/references/commands.md +75 -0
- package/skills/tui-design/references/critique.md +48 -0
- package/skills/tui-design/references/design-doc.md +44 -0
- package/skills/tui-design/references/terminal-craft.md +64 -0
- package/skills/tui-design/references/visual-loop.md +32 -0
- package/tests/agents-protocol.test.ts +53 -1
- package/tests/agents-runner.test.ts +168 -3
- package/tests/agents-view.test.ts +27 -0
- package/tests/agents-widget.test.ts +312 -10
- package/tests/bounded-scan-contract.test.ts +39 -0
- package/tests/bridge-cost.test.ts +32 -0
- package/tests/bundled-install.test.ts +6 -4
- package/tests/ci-concurrency.test.ts +11 -0
- package/tests/ci-merge-base-identity.test.ts +114 -0
- package/tests/codegraph-tools.test.ts +69 -0
- package/tests/codemode-rendering.test.ts +22 -2
- package/tests/command-palette.test.ts +16 -2
- package/tests/commit-slice-signal.test.ts +11 -9
- package/tests/delegate-for-reason-contract.test.ts +5 -4
- package/tests/design-canvas-server.test.ts +6 -2
- package/tests/exploration-budget.test.ts +128 -0
- package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
- package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +18 -10
- package/tests/fixtures/session-profile-v1/replay.ts +125 -0
- package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
- package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
- package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
- package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
- package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
- package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
- package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
- package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
- package/tests/gentle-agents.test.ts +416 -21
- package/tests/gentle-ai-exploration-budget.test.ts +135 -0
- package/tests/gentle-ai.test.ts +1011 -37
- package/tests/gentle-fast.test.ts +73 -0
- package/tests/gentle-guide.test.ts +208 -0
- package/tests/gentle-herdr-activity.test.ts +76 -2
- package/tests/gentle-herdr-agent.test.ts +111 -0
- package/tests/gentle-music.test.ts +36 -1
- package/tests/gentle-program-identity.test.ts +197 -0
- package/tests/gentle-shell-bin.test.ts +49 -26
- package/tests/gentle-shell-launcher.test.ts +18 -2
- package/tests/gentle-shell.test.ts +1068 -37
- package/tests/gentle-stats.test.ts +15 -2
- package/tests/gentle-todo.test.ts +50 -4
- package/tests/herdr-task-summary-policy.test.ts +128 -0
- package/tests/history-store-private-mode.test.ts +40 -0
- package/tests/image-paste-chips.test.ts +42 -0
- package/tests/inprocess-reviewer.test.ts +122 -0
- package/tests/installer-posix-bootstrap.test.ts +67 -5
- package/tests/installer-server.test.ts +2 -2
- package/tests/installer-windows-diagnostics.test.ts +4 -5
- package/tests/isolated-config-home.ts +28 -0
- package/tests/jobs-widget.test.ts +25 -37
- package/tests/keymaps-customize.test.ts +114 -0
- package/tests/keymaps.test.ts +103 -0
- package/tests/maintainer/mcp-status.maintest.ts +88 -0
- package/tests/maintainer/pi-update-source.maintest.ts +116 -0
- package/tests/model-fallback-notice.test.ts +45 -0
- package/tests/model-fallback-policy.test.ts +83 -0
- package/tests/model-fallback-store.test.ts +111 -0
- package/tests/nan-provider.test.ts +4 -4
- package/tests/no-self-pause-contract.test.ts +19 -0
- package/tests/notification-customize.test.ts +58 -34
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/odd-routing-contract.test.ts +1 -1
- package/tests/orchestrator-fallback.test.ts +82 -0
- package/tests/orchestrator-prompt-budget.test.ts +131 -0
- package/tests/package-manifest.test.ts +160 -7
- package/tests/pasted-image-paths.test.ts +118 -0
- package/tests/persona-reply-language.test.ts +61 -0
- package/tests/pi-update-launcher.test.ts +32 -8
- package/tests/pi-update-source.test.ts +162 -0
- package/tests/profile-fast-tier.test.ts +311 -0
- package/tests/profile-tier-footer.test.ts +79 -0
- package/tests/questionnaire-view.test.ts +150 -0
- package/tests/review-candidate-owner-sweep.test.ts +93 -0
- package/tests/review-candidate-view.test.ts +51 -0
- package/tests/review-controller-native-routing.test.ts +120 -6
- package/tests/review-gate.test.ts +24 -0
- package/tests/review-inspect-preflight.test.ts +197 -0
- package/tests/review-integration-v2-forward.test.ts +59 -0
- package/tests/review-repository.test.ts +52 -1
- package/tests/review-sidebar-state.test.ts +5 -5
- package/tests/run-test-suite.test.ts +61 -5
- package/tests/sensitive-path-tools.test.ts +74 -0
- package/tests/session-profile-append-controller.test.ts +63 -0
- package/tests/session-profile-authority.test.ts +259 -0
- package/tests/session-profile-binding.test.ts +15 -0
- package/tests/session-profile-extension.test.ts +615 -0
- package/tests/session-profile-freeze.test.ts +110 -2
- package/tests/session-profile-integration.test.ts +857 -0
- package/tests/session-profile-persistence.test.ts +57 -0
- package/tests/session-profile-v1-compat.test.ts +221 -0
- package/tests/shell-bar.test.ts +113 -55
- package/tests/shell-card.test.ts +13 -1
- package/tests/shell-page.test.ts +108 -0
- package/tests/shell-panel.test.ts +332 -0
- package/tests/shell-prompt.test.ts +54 -0
- package/tests/shell-render-cache.test.ts +5 -0
- package/tests/shell-sidebar-fullscreen.test.ts +12 -0
- package/tests/shell-sidebar-layout.test.ts +159 -27
- package/tests/shell-stats.test.ts +90 -0
- package/tests/shell-usage.test.ts +14 -0
- package/tests/skill-registry.test.ts +68 -1
- package/tests/star-prompt.test.ts +470 -0
- package/tests/startup-banner.test.ts +57 -1
- package/tests/task-size-routing-contract.test.ts +45 -1
- package/tests/verifier-settle-reminder.test.ts +281 -0
- package/tests/verify-first-launch-contract.test.ts +56 -5
- package/tests/verify-installer-tap.test.ts +57 -0
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/visual-customization-policy.test.ts +61 -7
- package/tests/visual-customize-view.test.ts +253 -8
- package/tests/visual-layout-preview.test.ts +28 -0
- package/tests/windows-session-bootstrap.test.ts +105 -2
- package/tests/work-continuity-contract.test.ts +86 -0
- package/tests/writer-surfaces.test.ts +12 -10
- package/tests/yolo-customize.test.ts +30 -11
- package/tests/yolo-mode-runtime.test.ts +4 -2
- package/tests/yolo-mode.test.ts +16 -2
package/lib/nan-provider.ts
CHANGED
|
@@ -20,7 +20,8 @@ const ZERO_COST = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
|
20
20
|
// Decimal bounds conservatively interpret the documented 1M/262K/131K labels.
|
|
21
21
|
// Pi models text/image inputs only; documented audio/video inputs are not advertised.
|
|
22
22
|
// Reasoning shares max_tokens with the answer: 65,536 leaves answer room after a
|
|
23
|
-
// 32,768 reasoning budget; DeepSeek
|
|
23
|
+
// 32,768 reasoning budget; DeepSeek gets a generous 131,072 output budget: NaN counts reasoning
|
|
24
|
+
// against max_tokens and dense review prompts exceed 16K reasoning tokens (gentle-shell#2840). Qwen 3.8 retains its
|
|
24
25
|
// published 131K output maximum. The remaining 32,768 caps are configured, not NaN-published limits.
|
|
25
26
|
// Pi requires explicit max mappings to offer that level; a null hides a level Pi would otherwise
|
|
26
27
|
// offer, and missing ordinary levels pass through. Each map exposes exactly the efforts NaN's
|
|
@@ -56,7 +57,7 @@ const CHAT_MODELS: NanChatModelConfig[] = ([
|
|
|
56
57
|
},
|
|
57
58
|
{
|
|
58
59
|
id: "deepseek-v4-flash", name: "DeepSeek V4 Flash", input: ["text", "image"], contextWindow: 1_000_000,
|
|
59
|
-
thinkingLevelMap: EXTENDED_THINKING_LEVEL_MAP, maxTokens:
|
|
60
|
+
thinkingLevelMap: EXTENDED_THINKING_LEVEL_MAP, maxTokens: 131_072,
|
|
60
61
|
// NaN's DeepSeek route enforces this field, not max_completion_tokens.
|
|
61
62
|
compat: { maxTokensField: "max_tokens" },
|
|
62
63
|
},
|
package/lib/native-review-cli.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
decodeReviewStartV3,
|
|
19
19
|
decodeReviewStartV4,
|
|
20
20
|
decodeReviewStatusV3,
|
|
21
|
+
intendedUntrackedSubmissionCarriesTarget,
|
|
21
22
|
type ReviewAcknowledgedExpectationV1,
|
|
22
23
|
type ReviewAcknowledgedV1,
|
|
23
24
|
type ReviewConsentEnvelope,
|
|
@@ -2399,7 +2400,11 @@ export class NativeReviewCliV216 implements NativeReviewCli {
|
|
|
2399
2400
|
// value for the same flag. providerFlagValue also fails closed on a
|
|
2400
2401
|
// dangling `--flag` (last token, no value) or an empty `--flag=`.
|
|
2401
2402
|
const submittedBaseRefValue = submittedTokens === undefined ? undefined : providerFlagValue(submittedTokens, "base-ref");
|
|
2402
|
-
|
|
2403
|
+
// A provider-issued base-diff selector (base tree plus scope) already binds
|
|
2404
|
+
// the target the request named; the tree is not textually comparable to
|
|
2405
|
+
// the request's ref, so it runs as issued and nothing is re-forwarded.
|
|
2406
|
+
const providerOwnsTarget = submitted !== undefined && intendedUntrackedSubmissionCarriesTarget(submitted.argumentTokens);
|
|
2407
|
+
if (!providerOwnsTarget && request.baseRef !== undefined && submittedBaseRefValue !== undefined && submittedBaseRefValue !== request.baseRef) throw new TypeError("Native intended-untracked selection already carries a conflicting base-ref");
|
|
2403
2408
|
const submittedLineageValue = submittedTokens === undefined ? undefined : providerFlagValue(submittedTokens, "lineage");
|
|
2404
2409
|
if (request.lineageId !== undefined && submittedLineageValue !== undefined && submittedLineageValue !== request.lineageId) throw new TypeError("Native intended-untracked selection already carries a conflicting lineage");
|
|
2405
2410
|
let submittedHasCommittedOnly = false;
|
|
@@ -2412,7 +2417,7 @@ export class NativeReviewCliV216 implements NativeReviewCli {
|
|
|
2412
2417
|
// Append only the half of the base-ref/committed-only pair the provider
|
|
2413
2418
|
// did not already carry (a present base-ref already equals
|
|
2414
2419
|
// request.baseRef; the throw above ruled out the conflicting case).
|
|
2415
|
-
const forwardedBaseRef = request.baseRef === undefined ? [] : [
|
|
2420
|
+
const forwardedBaseRef = request.baseRef === undefined || providerOwnsTarget ? [] : [
|
|
2416
2421
|
...(submittedBaseRefValue === undefined ? ["--base-ref", request.baseRef] : []),
|
|
2417
2422
|
...(submittedHasCommittedOnly ? [] : ["--committed-only"]),
|
|
2418
2423
|
];
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { getNotificationService, type NotificationService } from "./notification-service.ts";
|
|
8
8
|
import type { CustomizeInline, CustomizeRow } from "./visual-customize-view.ts";
|
|
9
9
|
|
|
10
|
-
/**
|
|
10
|
+
/** Inline sound options: silence, builtins, then custom. Priority belongs to the event. */
|
|
11
11
|
const SOUND_CYCLE: readonly NotificationSound[] = [null, ...BUILTIN_NOTIFICATION_IDS.map(id => `builtin:${id}` as const)];
|
|
12
12
|
/** Human labels for the builtin tones; the basic card never prints a `builtin:` id. */
|
|
13
13
|
const HUMAN_TONES: Readonly<Record<string, string>> = Object.freeze({
|
|
@@ -15,19 +15,19 @@ const HUMAN_TONES: Readonly<Record<string, string>> = Object.freeze({
|
|
|
15
15
|
"builtin:error": "error tone",
|
|
16
16
|
"builtin:attention": "attention tone",
|
|
17
17
|
});
|
|
18
|
+
const CUSTOM_SOUND = "custom";
|
|
18
19
|
/** Footer hint shared by every row that can assign its own sound (basic groups and per-event exceptions). */
|
|
19
|
-
const SOUND_ROW_HINT = "
|
|
20
|
+
const SOUND_ROW_HINT = "←/→ choose · Enter apply · f sound · p test · Esc close";
|
|
20
21
|
|
|
21
22
|
interface GroupPlan {
|
|
22
23
|
name: string;
|
|
23
|
-
recommended: `builtin:${typeof BUILTIN_NOTIFICATION_IDS[number]}`;
|
|
24
24
|
targets: readonly NotificationEvent[];
|
|
25
25
|
}
|
|
26
26
|
/** Fixed, verified targets per basic type. Attention never intersects `subagent.waiting`. */
|
|
27
27
|
const GROUP_PLANS: readonly GroupPlan[] = [
|
|
28
|
-
{ name: "Success",
|
|
29
|
-
{ name: "Error",
|
|
30
|
-
{ name: "Attention",
|
|
28
|
+
{ name: "Success", targets: ["agent.completed", "subagent.completed"] },
|
|
29
|
+
{ name: "Error", targets: ["agent.failed", "subagent.failed", "subagent.timed_out"] },
|
|
30
|
+
{ name: "Attention", targets: ["agent.attention"] },
|
|
31
31
|
];
|
|
32
32
|
|
|
33
33
|
/** Human basename for a local audio reference; never leaks the absolute path or the `file:` prefix. */
|
|
@@ -135,7 +135,20 @@ export function buildNotificationRows(ctx: ExtensionContext): CustomizeRow[] {
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
const rows: CustomizeRow[] = [];
|
|
138
|
-
|
|
138
|
+
const choices = <T>(row: Omit<CustomizeRow, "action" | "choice">, setting: string,
|
|
139
|
+
options: readonly { value: T; label: string }[], read: () => T | undefined,
|
|
140
|
+
apply: (value: T, inline: CustomizeInline) => unknown): void => {
|
|
141
|
+
for (const option of options) rows.push({ ...row,
|
|
142
|
+
choice: { setting, value: option.label, current: () => read() === option.value, applyOnMove: false },
|
|
143
|
+
action: async inline => { await apply(option.value, inline); },
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
const onOff = [{ value: false, label: "off" }, { value: true, label: "on" }];
|
|
147
|
+
const sounds: { value: NotificationSound | typeof CUSTOM_SOUND; label: string }[] = [
|
|
148
|
+
...SOUND_CYCLE.map(value => ({ value, label: selectionLabel(value) })), { value: CUSTOM_SOUND, label: "custom" },
|
|
149
|
+
];
|
|
150
|
+
const soundValue = (sound: NotificationSound): NotificationSound | typeof CUSTOM_SOUND => sound?.startsWith("file:") ? CUSTOM_SOUND : sound;
|
|
151
|
+
choices({
|
|
139
152
|
category,
|
|
140
153
|
label: () => { const current = state(); return `Audio notifications: ${current ? (current.settings.enabled ? "on" : "off") : "unavailable"}`; },
|
|
141
154
|
preview: () => {
|
|
@@ -143,25 +156,18 @@ export function buildNotificationRows(ctx: ExtensionContext): CustomizeRow[] {
|
|
|
143
156
|
return { title: "Audio notifications · global switch",
|
|
144
157
|
sample: current ? `opt-in audio · ${current.settings.enabled ? "enabled" : "disabled"} · mute: ${current.muted ? "on" : "off"} · separate from visual settings` : "Unavailable in this session" };
|
|
145
158
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const enabled = !service.getState().settings.enabled;
|
|
150
|
-
await mutate(inline, settings => { settings.enabled = enabled; });
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
rows.push({
|
|
159
|
+
}, "Enabled", onOff, () => state()?.settings.enabled,
|
|
160
|
+
(enabled, inline) => mutate(inline, settings => { settings.enabled = enabled; }));
|
|
161
|
+
choices({
|
|
154
162
|
category,
|
|
155
163
|
label: () => { const current = state(); return `Audio: ${current ? (current.muted ? "muted" : "unmuted") : "unavailable"}`; },
|
|
156
164
|
preview: () => ({ title: "Audio · process mute", sample: "mute survives reload and session replacement; restarting Pi clears it; muted or disabled events are never replayed" }),
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (!service.setMuted(ctx, !service.getState().muted)) notify("Audio mute could not be changed.", true);
|
|
161
|
-
},
|
|
165
|
+
}, "Mute", onOff, () => state()?.muted, muted => {
|
|
166
|
+
const service = serviceOrNotify();
|
|
167
|
+
if (service && !service.setMuted(ctx, muted)) notify("Audio mute could not be changed.", true);
|
|
162
168
|
});
|
|
163
169
|
for (const group of GROUP_PLANS) {
|
|
164
|
-
|
|
170
|
+
choices({
|
|
165
171
|
category,
|
|
166
172
|
keyhint: SOUND_ROW_HINT,
|
|
167
173
|
label: () => { const current = state(); return current ? `${group.name}: ${groupSelectionLabel(current.settings, group)}` : `${group.name}: unavailable`; },
|
|
@@ -170,18 +176,10 @@ export function buildNotificationRows(ctx: ExtensionContext): CustomizeRow[] {
|
|
|
170
176
|
if (!current) return { title: `${group.name} sounds`, sample: "Unavailable in this session" };
|
|
171
177
|
const selection = groupSelection(current.settings, group);
|
|
172
178
|
const detail = selection.kind === "mixed" ? `mixes several sounds across ${group.targets.length} events · expand Advanced for per-event exceptions`
|
|
173
|
-
: selection.sound === null ? "silence ·
|
|
179
|
+
: selection.sound === null ? "silence · choose a tone or assign your own sound with f"
|
|
174
180
|
: selection.sound.startsWith("builtin:") ? `${selectionLabel(selection.sound)} · builtin tone · f assigns your own sound`
|
|
175
181
|
: `${selectionLabel(selection.sound)} (own group file) · f replaces it`;
|
|
176
|
-
return { title: `${group.name} sounds · applies to ${group.targets.length} event${group.targets.length === 1 ? "" : "s"}`, sample: `${detail} · p tests the
|
|
177
|
-
},
|
|
178
|
-
action: async inline => {
|
|
179
|
-
const service = serviceOrNotify();
|
|
180
|
-
if (!service) return;
|
|
181
|
-
const selection = groupSelection(service.getState().settings, group);
|
|
182
|
-
const next = selection.kind === "mixed" ? group.recommended
|
|
183
|
-
: SOUND_CYCLE[(SOUND_CYCLE.indexOf(selection.sound) + 1) % SOUND_CYCLE.length]!;
|
|
184
|
-
await setTargets(inline, group.targets, next);
|
|
182
|
+
return { title: `${group.name} sounds · applies to ${group.targets.length} event${group.targets.length === 1 ? "" : "s"}`, sample: `${group.name}: ${groupSelectionLabel(current.settings, group)} · ${detail} · p tests the configured sound` };
|
|
185
183
|
},
|
|
186
184
|
key: (data, inline) => {
|
|
187
185
|
if (matchesKey(data, "p")) {
|
|
@@ -193,49 +191,48 @@ export function buildNotificationRows(ctx: ExtensionContext): CustomizeRow[] {
|
|
|
193
191
|
return true;
|
|
194
192
|
}
|
|
195
193
|
if (matchesKey(data, "f")) {
|
|
196
|
-
const
|
|
197
|
-
const selection =
|
|
198
|
-
|
|
199
|
-
? selection.sound.slice(5) : "";
|
|
200
|
-
return chooseFileFor(inline, group.targets, prefill);
|
|
194
|
+
const current = state();
|
|
195
|
+
const selection = current ? groupSelection(current.settings, group) : undefined;
|
|
196
|
+
return chooseFileFor(inline, group.targets, selection?.kind === "uniform" && selection.sound?.startsWith("file:") ? selection.sound.slice(5) : "");
|
|
201
197
|
}
|
|
202
198
|
return false;
|
|
203
199
|
},
|
|
200
|
+
}, group.name, sounds, () => {
|
|
201
|
+
const current = state();
|
|
202
|
+
if (!current) return undefined;
|
|
203
|
+
const selection = groupSelection(current.settings, group);
|
|
204
|
+
return selection.kind === "mixed" ? CUSTOM_SOUND : soundValue(selection.sound);
|
|
205
|
+
}, (sound, inline) => {
|
|
206
|
+
if (sound !== CUSTOM_SOUND) return setTargets(inline, group.targets, sound);
|
|
207
|
+
const current = state();
|
|
208
|
+
const selection = current ? groupSelection(current.settings, group) : undefined;
|
|
209
|
+
return chooseFileFor(inline, group.targets, selection?.kind === "uniform" && selection.sound?.startsWith("file:") ? selection.sound.slice(5) : "");
|
|
204
210
|
});
|
|
205
211
|
}
|
|
206
|
-
|
|
212
|
+
choices({
|
|
207
213
|
category,
|
|
208
214
|
label: () => `Advanced: ${advanced ? "hide" : "show"} per-event exceptions`,
|
|
209
215
|
preview: () => ({ title: "Advanced · per-event exceptions", sample: advanced ? "hiding folds the per-event rows again; the basic type choices are unaffected" : "reveals one-off per-event overrides; the basic type choices stay independent" }),
|
|
210
|
-
|
|
211
|
-
});
|
|
216
|
+
}, "Advanced", [{ value: false, label: "hidden" }, { value: true, label: "shown" }], () => advanced, value => { advanced = value; });
|
|
212
217
|
const events = getNotificationService()?.getState().supportedEvents
|
|
213
218
|
?? NOTIFICATION_EVENTS.filter(event => event !== "session.shutdown");
|
|
214
219
|
for (const event of events) {
|
|
215
|
-
|
|
220
|
+
choices({
|
|
216
221
|
category,
|
|
217
222
|
visible: () => advanced,
|
|
218
223
|
keyhint: SOUND_ROW_HINT,
|
|
219
224
|
label: () => { const current = state(); const sound = current?.settings.audio.events[event] ?? null; return `${event}: ${sound === null ? "silence" : sound}`; },
|
|
220
225
|
preview: () => {
|
|
221
226
|
const sound = state()?.settings.audio.events[event] ?? null;
|
|
222
|
-
return { title: `${event} · audio event`, sample:
|
|
223
|
-
},
|
|
224
|
-
action: async inline => {
|
|
225
|
-
const service = serviceOrNotify();
|
|
226
|
-
if (!service) return;
|
|
227
|
-
const current = service.getState().settings.audio.events[event] ?? null;
|
|
228
|
-
const index = SOUND_CYCLE.findIndex(candidate => candidate === current);
|
|
229
|
-
const next = SOUND_CYCLE[(index + 1) % SOUND_CYCLE.length]!;
|
|
230
|
-
await mutate(inline, settings => { settings.audio.events[event] = next; });
|
|
227
|
+
return { title: `${event} · audio event`, sample: `${event}: ${sound === null ? "silence" : sound} · ${soundDescription(sound)} · Enter applies the chosen option · f local sound · p test sound` };
|
|
231
228
|
},
|
|
232
229
|
key: (data, inline) => {
|
|
233
230
|
if (matchesKey(data, "p")) { previewSound(getNotificationService()?.getState().settings.audio.events[event] ?? null); return true; }
|
|
234
|
-
// Return the field/validation promise so the view keeps the card busy until it settles.
|
|
235
231
|
if (matchesKey(data, "f")) return chooseFileFor(inline, [event], "");
|
|
236
232
|
return false;
|
|
237
233
|
},
|
|
238
|
-
});
|
|
234
|
+
}, event, sounds, () => { const current = state(); return current ? soundValue(current.settings.audio.events[event] ?? null) : undefined; },
|
|
235
|
+
(sound, inline) => sound === CUSTOM_SOUND ? chooseFileFor(inline, [event], "") : setTargets(inline, [event], sound));
|
|
239
236
|
}
|
|
240
237
|
return rows;
|
|
241
238
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ServiceTier } from "./model-routing-authority.ts";
|
|
2
|
+
|
|
3
|
+
// Conservative intersection of the installed catalog and OpenAI's Fast list.
|
|
4
|
+
const FAST_MODELS = new Set([
|
|
5
|
+
"gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra",
|
|
6
|
+
"gpt-6-astra", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-sol", "gpt-6.1-terra",
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
export const PROFILE_TIER_EVENT = "gentle-pi:profile-tier";
|
|
10
|
+
export const CHILD_TIER_ENV = "GENTLE_PI_AGENT_SERVICE_TIER";
|
|
11
|
+
|
|
12
|
+
export function supportsOpenAIFast(model: { provider?: string; api?: string; id?: string } | null | undefined): boolean {
|
|
13
|
+
return !!model && typeof model.id === "string" && FAST_MODELS.has(model.id) && (
|
|
14
|
+
(model.provider === "openai" && model.api === "openai-responses") ||
|
|
15
|
+
(model.provider === "openai-codex" && model.api === "openai-codex-responses")
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function applyOpenAITier(payload: unknown, tier: ServiceTier | undefined, model: { provider?: string; api?: string; id?: string } | null | undefined): unknown {
|
|
20
|
+
if (!tier || !supportsOpenAIFast(model) || !payload || typeof payload !== "object" || Array.isArray(payload)) return undefined;
|
|
21
|
+
return { ...payload, service_tier: tier === "fast" ? "priority" : "default" };
|
|
22
|
+
}
|
|
@@ -12,6 +12,9 @@ export interface OrchestratorCandidate {
|
|
|
12
12
|
* its schema-1 header heartbeats, but it never writes a discovery sidecar. */
|
|
13
13
|
legacyLabel?: string;
|
|
14
14
|
aliases?: DiscoveryMetadata["aliases"];
|
|
15
|
+
/** stateOnly selection: whether this peer published owner-curated state. Boolean
|
|
16
|
+
* only — curated state prose stays out of the default session list. */
|
|
17
|
+
statePublished?: boolean;
|
|
15
18
|
workspace?: string;
|
|
16
19
|
tasks?: DiscoveryMetadata["tasks"];
|
|
17
20
|
omitted?: number;
|
|
@@ -27,7 +30,7 @@ export interface OrchestratorCandidate {
|
|
|
27
30
|
/** One bounded metadata page, no thread reads or transport probes. The registry
|
|
28
31
|
* selects a canonical routing activation; metadata must bind to that exact one.
|
|
29
32
|
* Incomplete scans and duplicate presence headers fail closed. */
|
|
30
|
-
export function discoverOrchestrators(profile: string, peers: readonly PresenceRecord[], now = Date.now(), selection?: { recipientSessionId?: string; cursor?: string; consultation?: boolean; includeWork?: boolean }): OrchestratorCandidate[] {
|
|
33
|
+
export function discoverOrchestrators(profile: string, peers: readonly PresenceRecord[], now = Date.now(), selection?: { recipientSessionId?: string; cursor?: string; consultation?: boolean; includeWork?: boolean; stateOnly?: boolean }): OrchestratorCandidate[] {
|
|
31
34
|
const page = listPresence(profile, now);
|
|
32
35
|
const ids = [...new Set(peers.map(peer => peer.sessionId))];
|
|
33
36
|
return ids.filter(id => selection?.recipientSessionId === undefined || selection.recipientSessionId === id).map(sessionId => {
|
|
@@ -48,6 +51,7 @@ export function discoverOrchestrators(profile: string, peers: readonly PresenceR
|
|
|
48
51
|
...(selection?.consultation ? { publication: { incarnation: header.incarnation, activation: metadata.activation, heartbeat: header.heartbeat } } : {}),
|
|
49
52
|
...(selection?.includeWork && metadata.state?.sessionId === sessionId
|
|
50
53
|
? { workRecord: { work: metadata.state.state?.work ?? null, recordedAt: metadata.state.recordedAt } } : {}),
|
|
54
|
+
...(selection?.stateOnly ? { statePublished: metadata.state?.sessionId === sessionId } : {}),
|
|
51
55
|
...(!selection?.includeWork && selection?.recipientSessionId === sessionId && metadata.state?.sessionId === sessionId ? { state: metadata.state } : {}) };
|
|
52
56
|
});
|
|
53
57
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { assistantErrorCategory } from "./agents-protocol.ts";
|
|
2
|
+
import { fallbackContinuePrompt, type FallbackChange } from "./model-fallback-notice.ts";
|
|
3
|
+
import { pickModel, shouldFallBack, type ModelCooldown } from "./model-fallback-policy.ts";
|
|
4
|
+
import type { FallbackChain } from "./model-fallback-store.ts";
|
|
5
|
+
import type { ThinkingLevel } from "./model-routing-authority.ts";
|
|
6
|
+
|
|
7
|
+
// The main session's fallback. Pi fires agent_end on every failed attempt and
|
|
8
|
+
// only then decides to retry, so the decision waits for agent_settled: the
|
|
9
|
+
// run's last attempt failed after Pi's own retries. Then the `orchestrator`
|
|
10
|
+
// chain of the session's profile picks the next model, the session switches
|
|
11
|
+
// to it and a message resumes the work. An episode lasts until a turn
|
|
12
|
+
// succeeds or the user aborts, so a chain is walked at most once.
|
|
13
|
+
|
|
14
|
+
export interface OrchestratorFallbackDeps {
|
|
15
|
+
chain(): FallbackChain;
|
|
16
|
+
/** `provider/id` of the session model, undefined when unknown. */
|
|
17
|
+
current(): string | undefined;
|
|
18
|
+
/** The model is in Pi's catalog and can be selected. */
|
|
19
|
+
available(model: string): boolean;
|
|
20
|
+
setModel(model: string): Promise<boolean>;
|
|
21
|
+
setThinking(level: ThinkingLevel): void;
|
|
22
|
+
/** The session's effort when the episode began: a step without its own effort runs at it. */
|
|
23
|
+
thinking(): ThinkingLevel | undefined;
|
|
24
|
+
announce(change: FallbackChange): void;
|
|
25
|
+
resume(message: string): void;
|
|
26
|
+
cooldown: ModelCooldown;
|
|
27
|
+
now(): number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type AssistantLike = { role?: unknown; stopReason?: unknown; errorMessage?: unknown };
|
|
31
|
+
|
|
32
|
+
export function createOrchestratorFallback(deps: OrchestratorFallbackDeps) {
|
|
33
|
+
const tried = new Set<string>();
|
|
34
|
+
let episodeThinking: ThinkingLevel | undefined;
|
|
35
|
+
return {
|
|
36
|
+
/** Handles a settled run (its last attempt's messages); true when the session moved to a fallback and resumed. */
|
|
37
|
+
async onSettled(messages: readonly unknown[], settled: { aborted?: boolean } = {}): Promise<boolean> {
|
|
38
|
+
if (settled.aborted) {
|
|
39
|
+
// The user stopped the run: never resume it on another model.
|
|
40
|
+
tried.clear();
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const last = [...messages].reverse().find((message) => (message as AssistantLike)?.role === "assistant") as AssistantLike | undefined;
|
|
44
|
+
const category = assistantErrorCategory(last);
|
|
45
|
+
if (category === undefined) {
|
|
46
|
+
// Success or an abort ends the episode.
|
|
47
|
+
tried.clear();
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const chain = deps.chain();
|
|
51
|
+
if (!chain.length || !shouldFallBack(category)) return false;
|
|
52
|
+
const now = deps.now();
|
|
53
|
+
const current = deps.current();
|
|
54
|
+
if (tried.size === 0) episodeThinking = deps.thinking();
|
|
55
|
+
if (current) {
|
|
56
|
+
tried.add(current);
|
|
57
|
+
deps.cooldown.mark(current, category, now);
|
|
58
|
+
}
|
|
59
|
+
for (;;) {
|
|
60
|
+
const pick = pickModel(current, chain, { cooldown: deps.cooldown, now, tried });
|
|
61
|
+
if (!pick?.fallback || !pick.model) return false;
|
|
62
|
+
tried.add(pick.model);
|
|
63
|
+
if (!deps.available(pick.model)) continue;
|
|
64
|
+
// Pi may refuse or throw (an expired login): the next step gets its turn.
|
|
65
|
+
const switched = await deps.setModel(pick.model).catch(() => false);
|
|
66
|
+
if (!switched) continue;
|
|
67
|
+
const level = pick.thinking ?? episodeThinking;
|
|
68
|
+
if (level) deps.setThinking(level);
|
|
69
|
+
deps.announce({ agent: "orchestrator", from: current ?? "default", to: pick.model, category });
|
|
70
|
+
deps.resume(fallbackContinuePrompt(current, pick.model, category));
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { isAbsolute } from "node:path";
|
|
4
|
+
import { sniffImageMimeType, type ClipboardImage } from "./clipboard-image.ts";
|
|
5
|
+
|
|
6
|
+
// Some terminals hand an image over as a path instead of clipboard bytes.
|
|
7
|
+
// Herdr does this for a terminal on another machine: the desktop app and
|
|
8
|
+
// `herdr --remote` write the clipboard image to a temp file there and paste
|
|
9
|
+
// its path (`herdr-paste-*.png`, `client-N-clipboard-*.png`). Dropping an image
|
|
10
|
+
// on a Herdr pane, or copying files in a file manager, arrives the same way:
|
|
11
|
+
// quoted paths. A paste made only of image paths becomes chips like a
|
|
12
|
+
// clipboard image, so the model sees the picture instead of a path string.
|
|
13
|
+
|
|
14
|
+
const MAX_PASTED_PATHS = 8;
|
|
15
|
+
const MAX_PASTED_BYTES = 64 * 1024 * 1024;
|
|
16
|
+
const IMAGE_PATH_EXTENSIONS = [".png", ".jpg", ".jpeg", ".webp", ".gif"];
|
|
17
|
+
|
|
18
|
+
export interface PastedImagePathOptions {
|
|
19
|
+
/** Test seam: read a file's bytes. */
|
|
20
|
+
readFile?(path: string): Uint8Array;
|
|
21
|
+
/** Test seam: does a regular file exist at this path? */
|
|
22
|
+
isFile?(path: string): boolean;
|
|
23
|
+
/** Test seam: the home directory `~/` expands to. */
|
|
24
|
+
home?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whitespace-separated shell-like tokens. Herdr quotes each dropped file with
|
|
29
|
+
* single quotes and escapes an embedded quote as `'\''`; terminals that paste
|
|
30
|
+
* several files quote them the same way. Newlines separate tokens too.
|
|
31
|
+
*/
|
|
32
|
+
export function parsePathTokens(text: string): string[] {
|
|
33
|
+
const tokens: string[] = [];
|
|
34
|
+
let current = "";
|
|
35
|
+
let started = false;
|
|
36
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
37
|
+
const char = text[index];
|
|
38
|
+
if (/\s/.test(char)) {
|
|
39
|
+
if (started) { tokens.push(current); current = ""; started = false; }
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
started = true;
|
|
43
|
+
if (char === "'") {
|
|
44
|
+
// Close, escaped quote, reopen (`'\''`) is one literal quote.
|
|
45
|
+
for (index += 1; index < text.length; index += 1) {
|
|
46
|
+
if (text[index] !== "'") { current += text[index]; continue; }
|
|
47
|
+
if (text[index + 1] === "\\" && text[index + 2] === "'" && text[index + 3] === "'") {
|
|
48
|
+
current += "'";
|
|
49
|
+
index += 3;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (char === '"') {
|
|
57
|
+
for (index += 1; index < text.length; index += 1) {
|
|
58
|
+
if (text[index] === "\\" && (text[index + 1] === '"' || text[index + 1] === "\\")) { current += text[index + 1]; index += 1; continue; }
|
|
59
|
+
if (text[index] === '"') break;
|
|
60
|
+
current += text[index];
|
|
61
|
+
}
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (char === "\\" && index + 1 < text.length) { current += text[index + 1]; index += 1; continue; }
|
|
65
|
+
current += char;
|
|
66
|
+
}
|
|
67
|
+
if (started) tokens.push(current);
|
|
68
|
+
return tokens;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Absolute path for one token, or undefined when it cannot name a local file. */
|
|
72
|
+
function resolveToken(token: string, home: string): string | undefined {
|
|
73
|
+
if (/[\u0000-\u001f\u007f]/.test(token)) return undefined;
|
|
74
|
+
let path = token;
|
|
75
|
+
if (path.startsWith("file://")) {
|
|
76
|
+
try { path = decodeURIComponent(path.slice("file://".length)); } catch { return undefined; }
|
|
77
|
+
}
|
|
78
|
+
if (path === "~") path = home;
|
|
79
|
+
else if (path.startsWith("~/")) path = `${home}${path.slice(1)}`;
|
|
80
|
+
return isAbsolute(path) ? path : undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Images from a paste whose entire text is image paths, in paste order.
|
|
85
|
+
* Anything else — text, a sentence that mentions a path, a missing or
|
|
86
|
+
* unsupported file — returns [] so Pi's own paste handler runs unchanged.
|
|
87
|
+
*/
|
|
88
|
+
export function readPastedImagePaths(text: string, options: PastedImagePathOptions = {}): ClipboardImage[] {
|
|
89
|
+
const tokens = parsePathTokens(text);
|
|
90
|
+
if (tokens.length === 0 || tokens.length > MAX_PASTED_PATHS) return [];
|
|
91
|
+
const home = options.home ?? homedir();
|
|
92
|
+
const readFile = options.readFile ?? ((path: string) => readFileSync(path));
|
|
93
|
+
const isFile = options.isFile ?? ((path: string) => {
|
|
94
|
+
try {
|
|
95
|
+
const stat = statSync(path);
|
|
96
|
+
return stat.isFile() && stat.size > 0 && stat.size <= MAX_PASTED_BYTES;
|
|
97
|
+
} catch { return false; }
|
|
98
|
+
});
|
|
99
|
+
const images: ClipboardImage[] = [];
|
|
100
|
+
for (const token of tokens) {
|
|
101
|
+
const path = resolveToken(token, home);
|
|
102
|
+
if (!path || !IMAGE_PATH_EXTENSIONS.some((extension) => path.toLowerCase().endsWith(extension))) return [];
|
|
103
|
+
if (!isFile(path)) return [];
|
|
104
|
+
let bytes: Uint8Array;
|
|
105
|
+
try { bytes = readFile(path); } catch { return []; }
|
|
106
|
+
if (bytes.length === 0 || bytes.length > MAX_PASTED_BYTES) return [];
|
|
107
|
+
// The extension only narrows the candidates; the bytes decide the type.
|
|
108
|
+
const mimeType = sniffImageMimeType(bytes);
|
|
109
|
+
if (!mimeType) return [];
|
|
110
|
+
images.push({ bytes, mimeType });
|
|
111
|
+
}
|
|
112
|
+
return images;
|
|
113
|
+
}
|