Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(agent): improve tool and notification feedback

vastsa233d6f85d368
diff --git a/apps/desktop/electron/main/ipc/notification-ipc.ts b/apps/desktop/electron/main/ipc/notification-ipc.ts
index f9deb3676..073e8017e 100644
--- a/apps/desktop/electron/main/ipc/notification-ipc.ts
+++ b/apps/desktop/electron/main/ipc/notification-ipc.ts
@@ -203,7 +203,7 @@ export function registerNotificationIpc({
return { shown: false };
}
- const notification = new SystemNotification({ title, body });
+ const notification = new SystemNotification({ title, body, silent: true });
if (kind === "task") {
taskNativeNotifications.set(id, { notification, dismissed: false });
} else {
diff --git a/apps/desktop/electron/main/services/desktop-services.ts b/apps/desktop/electron/main/services/desktop-services.ts
index 26e4d52c8..02b01dee7 100644
--- a/apps/desktop/electron/main/services/desktop-services.ts
+++ b/apps/desktop/electron/main/services/desktop-services.ts
@@ -50,7 +50,7 @@ export function createDesktopServices({
const body = String(input.body ?? "").trim().slice(0, 240);
return new Promise((resolve) => {
- const notification = new SystemNotification({ title, body });
+ const notification = new SystemNotification({ title, body, silent: true });
pluginNativeNotifications.add(notification);
let settled = false;
let timer: NodeJS.Timeout | undefined;
diff --git a/apps/desktop/electron/main/services/plugin-services.ts b/apps/desktop/electron/main/services/plugin-services.ts
index 112ccdcd3..ed8998e06 100644
--- a/apps/desktop/electron/main/services/plugin-services.ts
+++ b/apps/desktop/electron/main/services/plugin-services.ts
@@ -212,8 +212,18 @@ export function createPluginServices({
message: `${input.title}${input.body ? `: ${input.body}` : ""}`,
}),
getNotificationPermission: getPluginNotificationPermission,
- requestNotificationPermission: requestPluginNotificationPermission,
- showNativeNotification: showPluginNativeNotification,
+ requestNotificationPermission: async () => {
+ const permission = await requestPluginNotificationPermission();
+ if (permission === "granted") {
+ sendToRenderer(IPC.event.notificationSound, {});
+ }
+ return permission;
+ },
+ showNativeNotification: async (input) => {
+ const result = await showPluginNativeNotification(input);
+ if (result.shown) sendToRenderer(IPC.event.notificationSound, {});
+ return result;
+ },
openExternal: async (url) => {
await safeOpenExternal(url);
},
diff --git a/apps/desktop/src/components/AskToolCard.tsx b/apps/desktop/src/components/AskToolCard.tsx
index 42a9a8c18..9628a2830 100644
--- a/apps/desktop/src/components/AskToolCard.tsx
+++ b/apps/desktop/src/components/AskToolCard.tsx
@@ -1,6 +1,10 @@
import { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
-import type { AskToolQuestion } from "@pi-desktop/shared";
+import {
+ askToolOptionDescription,
+ askToolOptionLabel,
+ type AskToolQuestion,
+} from "@pi-desktop/shared";
import type { PendingAsk } from "../lib/pending-asks";
import { useAppStore } from "../stores/app-store";
import { Button } from "./ui";
@@ -162,20 +166,27 @@ export function AskToolCard({ request, queued = 0 }: { request: PendingAsk; queu
</div>
<h3 className="asktool-question">{current.question}</h3>
<div className="asktool-options" role={current.multiSelect ? "group" : "radiogroup"}>
- {current.options.map((option) => {
- const selected = currentDraft.values.includes(option);
+ {current.options.map((option, optionIndex) => {
+ const label = askToolOptionLabel(option);
+ const description = askToolOptionDescription(option);
+ const selected = currentDraft.values.includes(label);
return (
<button
- key={option}
+ key={`${label}-${optionIndex}`}
type="button"
className={`asktool-option ${selected ? "selected" : ""}`}
aria-pressed={current.multiSelect ? selected : undefined}
aria-checked={!current.multiSelect ? selected : undefined}
role={current.multiSelect ? "checkbox" : "radio"}
- onClick={() => selectOption(option)}
+ onClick={() => selectOption(label)}
>
<span className="asktool-option-mark" aria-hidden>{selected ? "✓" : ""}</span>
- <span>{option}</span>
+ <span className="asktool-option-copy">
+ <span>{label}</span>
+ {description ? (
+ <span className="asktool-option-description">{description}</span>
+ ) : null}
+ </span>
</button>
);
})}
diff --git a/apps/desktop/src/components/Toast.tsx b/apps/desktop/src/components/Toast.tsx
index 1465b029c..86438554e 100644
--- a/apps/desktop/src/components/Toast.tsx
+++ b/apps/desktop/src/components/Toast.tsx
@@ -9,6 +9,10 @@ import {
IconTriangleAlert,
} from "./icons";
import { TooltipButton } from "./ui";
+import {
+ playNotificationChime,
+ shouldPlayToastSound,
+} from "../lib/notification-sound";
const VARIANT_ICON: Record<ToastVariant, typeof IconInfo> = {
info: IconInfo,
@@ -79,6 +83,19 @@ function ToastCard({ item }: { item: ToastItem }) {
/** Global toast stack — mount once per shell, above dialogs (z-toast). */
export function ToastHost() {
const toasts = useAppStore((s) => s.toasts);
+ const visibleToastIds = useRef<Set<number>>(new Set());
+
+ useEffect(() => {
+ const nextVisibleIds = new Set<number>();
+ let shouldPlay = false;
+ for (const toast of toasts) {
+ nextVisibleIds.add(toast.id);
+ if (shouldPlayToastSound(toast, visibleToastIds.current)) shouldPlay = true;
+ }
+ visibleToastIds.current = nextVisibleIds;
+ if (shouldPlay) playNotificationChime();
+ }, [toasts]);
+
return (
<div className="toast-viewport" aria-live="polite">
{toasts.map((item) => (
diff --git a/apps/desktop/src/features/app/useAppShellRuntime.tsx b/apps/desktop/src/features/app/useAppShellRuntime.tsx
index 1df208ddf..ad7bff035 100644
--- a/apps/desktop/src/features/app/useAppShellRuntime.tsx
+++ b/apps/desktop/src/features/app/useAppShellRuntime.tsx
@@ -15,6 +15,7 @@ import { useTranslation } from "react-i18next";
import { installRendererApi } from "../../capture/renderer-api";
import { StartupSplash } from "../../components/StartupSplash";
import { api } from "../../lib/api";
+import { playNotificationChime } from "../../lib/notification-sound";
import {
clampSidebarWidth,
loadSidebarWidth,
@@ -573,6 +574,7 @@ export function useAppShellRuntime() {
const offPlansChanged = api.onPlansChanged(handlePlansChanged);
// Host-pushed toasts (plugin runtime etc.) are informational.
const offToast = api.onToast((message) => showToast(message));
+ const offNotificationSound = api.onNotificationSound(playNotificationChime);
// The first plaintext hop to an endpoint the user typed. The shell owns the
// wording, and recording `insecureNoticeAcknowledged` keeps it to once; a
// failed write only means the notice shows again.
@@ -629,6 +631,7 @@ export function useAppShellRuntime() {
// to a row that is already present/acknowledged. Do not surface a native
// banner for an event the store intentionally rejected.
if (!accepted) return;
+ playNotificationChime();
const failed = notification.kind === "task.failed";
const title = t(
failed ? "notifications.failedTitle" : "notifications.completedTitle",
@@ -796,6 +799,7 @@ export function useAppShellRuntime() {
offQueueChanged();
offPlansChanged();
offToast();
+ offNotificationSound();
offInsecureEndpoint();
offBrowserPreview();
offBrowserState();
diff --git a/apps/desktop/src/lib/api.ts b/apps/desktop/src/lib/api.ts
index 2c30bb6a9..2ce0a40b7 100644
--- a/apps/desktop/src/lib/api.ts
+++ b/apps/desktop/src/lib/api.ts
@@ -1537,6 +1537,10 @@ export const api = {
listener((payload as { notification: AppNotification }).notification),
);
},
+ onNotificationSound: (listener: () => void) => {
+ if (!window.piDesktop?.on) return () => undefined;
+ return window.piDesktop.on(IPC.event.notificationSound, () => listener());
+ },
// --- Remote hosts (R2b pairing UX) -----------------------------------------
/** Paired remote `pi-host` list, redacted so no device token reaches here. */
diff --git a/apps/desktop/src/lib/notification-sound.ts b/apps/desktop/src/lib/notification-sound.ts
new file mode 100644
index 000000000..15e72de7d
--- /dev/null
+++ b/apps/desktop/src/lib/notification-sound.ts
@@ -0,0 +1,88 @@
+/** Soft, best-effort in-app chime for notification and toast surfaces. */
+export type NotificationAudioContext = Pick<
+ AudioContext,
+ | "state"
+ | "currentTime"
+ | "destination"
+ | "createOscillator"
+ | "createGain"
+ | "resume"
+ | "close"
+>;
+
+export type NotificationAudioContextFactory =
+ () => NotificationAudioContext | undefined;
+
+const CHIME_FREQUENCY_HZ = 660;
+const CHIME_PEAK_GAIN = 0.022;
+const CHIME_DURATION_SECONDS = 0.16;
+const MIN_CHIME_INTERVAL_MS = 140;
+
+function browserAudioContext(): NotificationAudioContext | undefined {
+ if (typeof window === "undefined" || typeof window.AudioContext !== "function") {
+ return undefined;
+ }
+ try {
+ return new window.AudioContext();
+ } catch {
+ return undefined;
+ }
+}
+
+export function createNotificationChime(
+ createContext: NotificationAudioContextFactory = browserAudioContext,
+ now: () => number = Date.now,
+): () => void {
+ let lastPlayedAt = Number.NEGATIVE_INFINITY;
+
+ return () => {
+ const playedAt = now();
+ if (playedAt - lastPlayedAt < MIN_CHIME_INTERVAL_MS) return;
+ const context = createContext();
+ if (!context) return;
+ lastPlayedAt = playedAt;
+
+ const closeQuietly = () => {
+ try {
+ void context.close().catch(() => undefined);
+ } catch {
+ // Audio is optional feedback; a platform teardown failure is non-fatal.
+ }
+ };
+
+ const startTone = () => {
+ try {
+ const startAt = context.currentTime;
+ const oscillator = context.createOscillator();
+ const gain = context.createGain();
+ oscillator.type = "sine";
+ oscillator.frequency.setValueAtTime(CHIME_FREQUENCY_HZ, startAt);
+ gain.gain.setValueAtTime(0.0001, startAt);
+ gain.gain.linearRampToValueAtTime(CHIME_PEAK_GAIN, startAt + 0.012);
+ gain.gain.exponentialRampToValueAtTime(
+ 0.0001,
+ startAt + CHIME_DURATION_SECONDS,
+ );
+ oscillator.connect(gain);
+ gain.connect(context.destination);
+ oscillator.onended = closeQuietly;
+ oscillator.start(startAt);
+ oscillator.stop(startAt + CHIME_DURATION_SECONDS + 0.01);
+ } catch {
+ closeQuietly();
+ }
+ };
+
+ if (context.state === "running") startTone();
+ else void context.resume().then(startTone).catch(closeQuietly);
+ };
+}
+
+export const playNotificationChime = createNotificationChime();
+
+export function shouldPlayToastSound(
+ toast: { id: number; sound?: boolean },
+ visibleToastIds: ReadonlySet<number>,
+): boolean {
+ return toast.sound !== false && !visibleToastIds.has(toast.id);
+}
diff --git a/apps/desktop/src/stores/app-state.ts b/apps/desktop/src/stores/app-state.ts
index bc238da1c..1e70dfc1d 100644
--- a/apps/desktop/src/stores/app-state.ts
+++ b/apps/desktop/src/stores/app-state.ts
@@ -58,12 +58,16 @@ export type ToastItem = {
variant: ToastVariant;
/** Auto-dismiss delay in ms; 0 keeps the toast until dismissed. */
duration: number;
+ /** Notification chime is enabled by default. */
+ sound: boolean;
};
export type ToastOptions = {
variant?: ToastVariant;
/** Override the variant default (4s, error 8s); 0 disables auto-dismiss. */
duration?: number;
+ /** Suppress the default soft chime when another notification surface already played it. */
+ sound?: boolean;
};
export type AgentTurnResult = {
diff --git a/apps/desktop/src/stores/runtime/notification-runtime.ts b/apps/desktop/src/stores/runtime/notification-runtime.ts
index 61863354b..451bae323 100644
--- a/apps/desktop/src/stores/runtime/notification-runtime.ts
+++ b/apps/desktop/src/stores/runtime/notification-runtime.ts
@@ -1,5 +1,6 @@
import i18n from "i18next";
import { api } from "../../lib/api";
+import { playNotificationChime } from "../../lib/notification-sound";
import type { StoreGet } from "../slices/types";
export type InteractivePromptNotifier = (
@@ -28,6 +29,14 @@ export function createInteractivePromptNotifier(
title = i18n.t("notifications.planApprovalTitle", { sessionTitle });
body = i18n.t("notifications.planApprovalBody");
}
+ playNotificationChime();
+ if (kind === "ask") {
+ get().showToast(`${title}: ${body}`, {
+ variant: "info",
+ duration: 8_000,
+ sound: false,
+ });
+ }
void api
.showNativeNotification({
id: crypto.randomUUID(),
diff --git a/apps/desktop/src/stores/slices/interaction-slice.ts b/apps/desktop/src/stores/slices/interaction-slice.ts
index 8ed8f6388..29406b838 100644
--- a/apps/desktop/src/stores/slices/interaction-slice.ts
+++ b/apps/desktop/src/stores/slices/interaction-slice.ts
@@ -220,6 +220,7 @@ export function createInteractionSlice({
message,
variant,
duration,
+ sound: options?.sound !== false,
},
];
return { toasts: next.slice(-TOAST_STACK_LIMIT) };
diff --git a/apps/desktop/src/styles/messages.css b/apps/desktop/src/styles/messages.css
index 8323949b6..3cfce77bd 100644
--- a/apps/desktop/src/styles/messages.css
+++ b/apps/desktop/src/styles/messages.css
@@ -179,7 +179,7 @@
.asktool-option {
display: flex;
width: 100%;
- align-items: center;
+ align-items: flex-start;
gap: 8px;
min-height: 30px;
padding: 4px 8px;
@@ -193,6 +193,19 @@
transition: background-color var(--motion-duration-fast) var(--motion-ease-out);
}
+.asktool-option-copy {
+ display: grid;
+ min-width: 0;
+ gap: 2px;
+}
+
+.asktool-option-description {
+ color: var(--ds-text-muted);
+ font-size: var(--text-xs);
+ line-height: var(--leading-normal);
+ overflow-wrap: anywhere;
+}
+
.asktool-option:hover,
.asktool-option.selected {
background: color-mix(in oklab, var(--ds-accent) 10%, var(--ds-tile-deep));
@@ -210,6 +223,7 @@
color: var(--ds-accent);
font-size: var(--text-xs);
line-height: var(--leading-none);
+ margin-top: 2px;
}
.asktool-option[role="radio"] .asktool-option-mark {
diff --git a/apps/desktop/test/asktool-rich-options.test.mjs b/apps/desktop/test/asktool-rich-options.test.mjs
new file mode 100644
index 000000000..590174108
--- /dev/null
+++ b/apps/desktop/test/asktool-rich-options.test.mjs
@@ -0,0 +1,42 @@
+import assert from "node:assert/strict";
+import { readFile } from "node:fs/promises";
+import test from "node:test";
+import {
+ askToolOptionDescription,
+ askToolOptionLabel,
+ normalizeAskToolOption,
+} from "../../../packages/shared/src/types/agent.ts";
+
+const cardSource = await readFile(
+ new URL("../src/components/AskToolCard.tsx", import.meta.url),
+ "utf8",
+);
+const styleSource = await readFile(
+ new URL("../src/styles/messages.css", import.meta.url),
+ "utf8",
+);
+
+test("asktool keeps legacy strings and normalizes rich labels and descriptions", () => {
+ const legacy = normalizeAskToolOption(" Web ");
+ const rich = normalizeAskToolOption({
+ label: " Desktop ",
+ description: " Installed on your computer. ",
+ });
+ assert.equal(legacy, "Web");
+ assert.deepEqual(rich, {
+ label: "Desktop",
+ description: "Installed on your computer.",
+ });
+ assert.equal(normalizeAskToolOption({ label: " " }), undefined);
+ assert.equal(askToolOptionLabel(rich), "Desktop");
+ assert.equal(askToolOptionDescription(rich), "Installed on your computer.");
+ assert.equal(askToolOptionDescription(legacy), undefined);
+});
+
+test("asktool card presents descriptions without changing the selected answer", () => {
+ assert.match(cardSource, /askToolOptionLabel\(option\)/);
+ assert.match(cardSource, /askToolOptionDescription\(option\)/);
+ assert.match(cardSource, /onClick=\{\(\) => selectOption\(label\)\}/);
+ assert.match(cardSource, /className="asktool-option-description"/);
+ assert.match(styleSource, /\.asktool-option-description\s*\{/);
+});
diff --git a/apps/desktop/test/notification-contract.test.mjs b/apps/desktop/test/notification-contract.test.mjs
index 4084c680f..441daf4b4 100644
--- a/apps/desktop/test/notification-contract.test.mjs
+++ b/apps/desktop/test/notification-contract.test.mjs
@@ -49,6 +49,7 @@ test("notification IPC stays behind the shared preload allowlist", () => {
"notificationSetViewingSession",
"notificationChanged",
"notificationActivated",
+ "notificationSound",
]) {
assert.match(protocolSource, new RegExp(`${channel}:`), channel);
}
@@ -56,6 +57,7 @@ test("notification IPC stays behind the shared preload allowlist", () => {
assert.match(apiSource, /setNotificationViewingSession:/);
assert.match(apiSource, /onNotificationChanged:/);
assert.match(apiSource, /onNotificationActivated:/);
+ assert.match(apiSource, /onNotificationSound:/);
});
test("terminal notifications flow from host completion to the renderer", () => {
diff --git a/apps/desktop/test/notification-sound.test.mjs b/apps/desktop/test/notification-sound.test.mjs
new file mode 100644
index 000000000..d16592dd7
--- /dev/null
+++ b/apps/desktop/test/notification-sound.test.mjs
@@ -0,0 +1,121 @@
+import assert from "node:assert/strict";
+import { readFile } from "node:fs/promises";
+import test from "node:test";
+import {
+ createNotificationChime,
+ shouldPlayToastSound,
+} from "../src/lib/notification-sound.ts";
+
+const toastSource = await readFile(
+ new URL("../src/components/Toast.tsx", import.meta.url),
+ "utf8",
+);
+const promptNotificationSource = await readFile(
+ new URL("../src/stores/runtime/notification-runtime.ts", import.meta.url),
+ "utf8",
+);
+const shellNotificationSource = await readFile(
+ new URL("../src/features/app/useAppShellRuntime.tsx", import.meta.url),
+ "utf8",
+);
+const nativeNotificationSource = await readFile(
+ new URL("../electron/main/ipc/notification-ipc.ts", import.meta.url),
+ "utf8",
+);
+const pluginNotificationSource = await readFile(
+ new URL("../electron/main/services/plugin-services.ts", import.meta.url),
+ "utf8",
+);
+const pluginNativeSource = await readFile(
+ new URL("../electron/main/services/desktop-services.ts", import.meta.url),
+ "utf8",
+);
+
+function audioFixture() {
+ const calls = { frequency: [], gain: [], start: [], stop: [], closes: 0 };
+ const oscillator = {
+ type: "",
+ frequency: { setValueAtTime: (...args) => calls.frequency.push(args) },
+ connect() {},
+ start: (...args) => calls.start.push(args),
+ stop: (...args) => calls.stop.push(args),
+ onended: undefined,
+ };
+ const gain = {
+ gain: {
+ setValueAtTime: (...args) => calls.gain.push(["set", ...args]),
+ linearRampToValueAtTime: (...args) => calls.gain.push(["linear", ...args]),
+ exponentialRampToValueAtTime: (...args) => calls.gain.push(["exponential", ...args]),
+ },
+ connect() {},
+ };
+ const context = {
+ state: "running",
+ currentTime: 4,
+ destination: {},
+ createOscillator: () => oscillator,
+ createGain: () => gain,
+ resume: async () => undefined,
+ close: async () => { calls.closes += 1; },
+ };
+ return { calls, context, oscillator };
+}
+
+test("notification chime is a brief, low-gain sine tone and releases audio resources", () => {
+ const fixture = audioFixture();
+ const play = createNotificationChime(() => fixture.context, () => 1_000);
+
+ play();
+
+ assert.equal(fixture.oscillator.type, "sine");
+ assert.deepEqual(fixture.calls.frequency, [[660, 4]]);
+ assert.deepEqual(fixture.calls.gain, [
+ ["set", 0.0001, 4],
+ ["linear", 0.022, 4.012],
+ ["exponential", 0.0001, 4.16],
+ ]);
+ assert.deepEqual(fixture.calls.start, [[4]]);
+ assert.deepEqual(fixture.calls.stop, [[4.17]]);
+ fixture.oscillator.onended();
+ assert.equal(fixture.calls.closes, 1);
+});
+
+test("notification chime coalesces rapid events and skips unavailable audio", () => {
+ let now = 1_000;
+ let created = 0;
+ const play = createNotificationChime(() => {
+ created += 1;
+ return audioFixture().context;
+ }, () => now);
+
+ play();
+ play();
+ assert.equal(created, 1);
+ now += 200;
+ play();
+ assert.equal(created, 2);
+ assert.doesNotThrow(() => createNotificationChime(() => undefined, () => 1_000)());
+});
+
+test("toast chimes only for newly visible toasts that have not opted out", () => {
+ const visible = new Set([2]);
+ assert.equal(shouldPlayToastSound({ id: 1 }, visible), true);
+ assert.equal(shouldPlayToastSound({ id: 2 }, visible), false);
+ assert.equal(shouldPlayToastSound({ id: 3, sound: false }, visible), false);
+});
+
+test("app and plugin notification surfaces share one chime without native double-sounds", () => {
+ assert.match(toastSource, /shouldPlayToastSound\(toast, visibleToastIds\.current\)/);
+ assert.match(toastSource, /if \(shouldPlay\) playNotificationChime\(\)/);
+ assert.match(promptNotificationSource, /playNotificationChime\(\)/);
+ assert.match(promptNotificationSource, /get\(\)\.showToast\([\s\S]*sound: false/);
+ assert.match(
+ shellNotificationSource,
+ /if \(!accepted\) return;\s*playNotificationChime\(\)/,
+ );
+ assert.match(nativeNotificationSource, /new SystemNotification\(\{ title, body, silent: true \}\)/);
+ assert.match(shellNotificationSource, /api\.onNotificationSound\(playNotificationChime\)/);
+ assert.match(pluginNotificationSource, /if \(result\.shown\) sendToRenderer\(IPC\.event\.notificationSound/);
+ assert.match(pluginNotificationSource, /permission === "granted"[\s\S]*IPC\.event\.notificationSound/);
+ assert.match(pluginNativeSource, /new SystemNotification\(\{ title, body, silent: true \}\)/);
+});
diff --git a/docs/adr/0048-lazy-per-turn-tool-activation.md b/docs/adr/0048-lazy-per-turn-tool-activation.md
index 76b2280a8..ce205c553 100644
--- a/docs/adr/0048-lazy-per-turn-tool-activation.md
+++ b/docs/adr/0048-lazy-per-turn-tool-activation.md
@@ -94,3 +94,16 @@ optimization.
- `docs/spec/06-delivery/04-e2e-test-plan.md` (E2E-008a)
- `https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/src/core/system-prompt.ts`
- `https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/docs/extensions.md`
+
+## Amendment — 2026-09-27: keep workspace search in Agent's initial schema
+
+Routine file discovery should not require a separate `ToolSearch` turn. Agent
+now includes `Glob` and `Grep` alongside `Read`, `Bash`, `Edit`, and `Write` in
+its initial provider request. `BrowserPreview`, plugin tools, and plugin
+development helpers remain deferred, so the bounded catalog and activation
+mechanism continue to control optional schemas. Chat, Plan, and Goal tool sets
+are unchanged.
+
+This supersedes only ADR 0048's initial-set and Glob/Grep-deferral bullets and
+the corresponding first-turn consequences; successful activation restoration,
+provider compatibility, permissions, and host policy are unchanged.
diff --git a/docs/adr/0069-recoverable-native-tool-path-errors.md b/docs/adr/0069-recoverable-native-tool-path-errors.md
index c7260a2e4..f383a9684 100644
--- a/docs/adr/0069-recoverable-native-tool-path-errors.md
+++ b/docs/adr/0069-recoverable-native-tool-path-errors.md
@@ -82,3 +82,12 @@ and common across coding-agent tool conventions.
Rejected. Settlement does not mean every intermediate tool call succeeded;
the dedicated terminal outcome surfaces already own turn failure.
+
+## Amendment — 2026-09-27: Agent search tools start active
+
+`Glob` and `Grep` now ship in the first Agent request alongside `Read`,
+`Bash`, `Edit`, and `Write`, as recorded in the amendment to ADR 0048. This
+supersedes Decision 1's deferral instruction and the deferred-search
+consequences above. ADR 0069's path shapes, structured Read recovery, and
+transcript outcome ownership remain unchanged; other optional capabilities
+remain available through `ToolSearch`.
diff --git a/docs/adr/0230-skill-ships-with-the-agent-core-tool-set.md b/docs/adr/0230-skill-ships-with-the-agent-core-tool-set.md
index 7ac960c96..e3c7fccbb 100644
--- a/docs/adr/0230-skill-ships-with-the-agent-core-tool-set.md
+++ b/docs/adr/0230-skill-ships-with-the-agent-core-tool-set.md
@@ -7,11 +7,11 @@
## Context
-ADR 0048 keeps the first Agent request on a small core set and defers every
-other capability behind the local `ToolSearch` tool, so a large plugin surface
-cannot recreate the original prompt bloat. `Skill` was registered into that
-deferred set: it only appears in the provider schema after the model searches
-for it.
+As originally accepted, ADR 0048 kept the first Agent request on a small
+core set and deferred optional capabilities behind the local `ToolSearch`
+tool, so a large plugin surface could not recreate the original prompt bloat.
+`Skill` was registered into that deferred set: it only appeared in the
+provider schema after the model searched for it.
Two later decisions assume a `Skill` tool the model can call immediately:
@@ -61,3 +61,10 @@ for a skill pays one or two extra round trips before the body is ever loaded.
reload semantics D174 and ADR 0039 already settled.
- **Make every on-demand tool core:** rejected because it recreates the prompt
bloat ADR 0048 exists to prevent. Only `Skill` is admitted here.
+
+## Amendment — 2026-09-27: Agent search tools start active
+
+The amendment to ADR 0048 also places `Glob` and `Grep` in the first Agent
+request to remove the discovery round trip for routine workspace exploration.
+This does not change ADR 0230: `Skill` remains core when its catalog exists,
+and plugin, preview, and development tools remain deferred.
diff --git a/docs/spec/03-runtime/01-ipc-protocol.md b/docs/spec/03-runtime/01-ipc-protocol.md
index 4fe147193..cd7b15617 100644
--- a/docs/spec/03-runtime/01-ipc-protocol.md
+++ b/docs/spec/03-runtime/01-ipc-protocol.md
@@ -33,7 +33,7 @@ Principles:
| `fs` | Work panel workspace file listing/reading/reveal, chat file-reference completion against the project, session scratch, and attachment roots, plus user-initiated open with the OS default handler (read-only) |
| `window` | Frameless window state, controls, and compatibility work-panel geometry channels |
| `menu` | Allowlisted application-menu commands and native editing/window actions |
-| `notification` | Durable inbox list/read/clear and new/activated events |
+| `notification` | Durable inbox list/read/clear, new/activated events, and native-notification sound cues |
| `stats` | Completed-turn token history (host RPC; dashboard is plugin-owned) |
## 3. Channel Conventions
@@ -845,6 +845,11 @@ Main sends two events:
- `pi-desktop/notification/event/activated` after the user clicks Electron's
native system notification. Renderer follows its existing session-selection
path, including project activation for a project-bound session.
+- `pi-desktop/notification/event/sound` is a payload-free, one-way cue for a
+ plugin-native notification that Electron successfully showed. Renderer plays
+ the shared soft chime; the event carries no notification content and creates
+ no inbox row. Native task, interactive, and plugin banners are silent so the
+ in-app chime is not doubled by a platform-specific sound.
Plugin-owned session mutations additionally emit
`pi-desktop/session/event/changed` after a successful write. The renderer
diff --git a/docs/spec/03-runtime/03-tools-and-permissions.md b/docs/spec/03-runtime/03-tools-and-permissions.md
index 924aa21cf..4a94b8b83 100644
--- a/docs/spec/03-runtime/03-tools-and-permissions.md
+++ b/docs/spec/03-runtime/03-tools-and-permissions.md
@@ -45,15 +45,16 @@ Let the agent get things done, but stay under control by default.
### 2.1 Deferred ancillary tools (D185, ADR 0048)
-Following pi's coding-agent default, the first Agent request activates only
-`Read`, `Bash`, `Edit`, and `Write`; `Glob` and `Grep` are loaded on demand.
-Plan and Goal keep their read/inspection core. `Skill` is deliberately not
-deferred: a `/skill-id` invocation instructs the model to call it, and a tool
-absent from the schema cannot be called at all, so it ships with the first
-request whenever the skill catalog is non-empty (D404, ADR 0230). The runtime
-also registers capabilities without sending their full schemas up front:
-
-- `Glob` and `Grep` in Agent mode
+The first Agent request includes `Read`, `Bash`, `Edit`, `Write`, `Glob`, and
+`Grep`. Keeping workspace listing and content search in the initial schema
+avoids a discovery round trip for routine project exploration (the amendment
+to ADR 0048 records this change). Plan and Goal keep their read/inspection core.
+`Skill` is deliberately not deferred: a `/skill-id` invocation instructs the
+model to call it, and a tool absent from the schema cannot be called at all, so
+it ships with the first request whenever the skill catalog is non-empty (D404,
+ADR 0230). The runtime still registers optional capabilities without sending
+their full schemas up front:
+
- `BrowserPreview`
- `PluginCheck`, `PluginScaffold`, and `PluginPack`
- plugin-declared agent tools
@@ -86,7 +87,9 @@ Every non-interactive execution tool must have:
`asktool` is the interactive exception: it has a typed request event, waits for
the renderer response without an expiry, and returns a bounded structured tool
-result. Stopping the turn resolves outstanding questions as skipped.
+result. Options may be plain strings or `{ label, description? }` objects; the
+selected label remains the answer value. Stopping the turn resolves outstanding
+questions as skipped.
## 4. Path Rules
@@ -108,11 +111,10 @@ On POSIX, a literal backslash in a filename remains a backslash so the result
can be passed back to `Read` or `Edit`; Windows path separators are normalized
to `/`.
-Agent mode keeps `Glob`/`Grep` deferred under D185. Each new user prompt clears
-their live activation and restores only eligible successful markers still in
-context; when no such marker exists, directory discovery activates `Glob`
-through `ToolSearch` for that prompt instead of guessing a file name or calling
-`Read` on a directory.
+Agent mode keeps `Glob`/`Grep` available from the first request. Other deferred
+tools still follow the per-prompt activation and successful-context restoration
+rules above; directory discovery can call `Glob` directly without a
+`ToolSearch` round trip.
The runtime accepts one alias per canonical argument name and folds it away
before the host sees the call (D273):
diff --git a/docs/spec/03-runtime/17-asktool-questions.md b/docs/spec/03-runtime/17-asktool-questions.md
index 3d614760c..f574325a7 100644
--- a/docs/spec/03-runtime/17-asktool-questions.md
+++ b/docs/spec/03-runtime/17-asktool-questions.md
@@ -12,12 +12,15 @@ deadline.
The tool accepts a non-empty `questions` array. Each question contains:
- `question`: the prompt text;
-- `options`: one or more selectable answer labels;
+- `options`: one or more selectable answer labels, each either a string or an
+ object with a required `label` and optional `description`;
- `multiSelect`: optional; when true, more than one selectable answer is allowed.
-The desktop card always adds one extra `Enter another answer` option with a text
-field. The model does not need to add a special free-text choice to the tool
-arguments.
+Plain string options remain supported. The card shows an object's description
+as secondary text, while selection and the model-facing answer continue to use
+only its label. The desktop card always adds one extra `Enter another answer`
+option with a text field. The model does not need to add a special free-text
+choice to the tool arguments.
## 3. Card interaction
@@ -31,13 +34,18 @@ There is no timer, countdown, or automatic expiration. The card remains pending
until the user submits or the turn is stopped. If the turn is stopped while a
card is open, the runtime resolves every remaining question as skipped.
+When an ask arrives, the app shows an in-app toast containing the session and
+first question, in addition to the existing native notification policy for
+background sessions. The ask event plays one soft in-app chime; its toast does
+not play a second one.
+
## 4. Tool output
The response is the normal tool result returned to the model and persisted with
the tool row. For each question, the content is serialized as:
```text
-question text:answer 1、answer 2
+question text:answer label 1、answer label 2
```
Multiple questions are separated by `\n---\n`. A skipped or unanswered
diff --git a/docs/spec/04-ux/11-asktool-question-card.md b/docs/spec/04-ux/11-asktool-question-card.md
index 6fa429028..e1441a904 100644
--- a/docs/spec/04-ux/11-asktool-question-card.md
+++ b/docs/spec/04-ux/11-asktool-question-card.md
@@ -29,6 +29,14 @@ The card has no countdown or expiration copy. On narrow screens options remain
full-width and actions may share the row; question text and custom input may
wrap naturally without clipping.
+## Rich options
+
+A selectable option may remain a plain string or use `{ label, description? }`.
+The label keeps the existing option typography and selection behavior; the
+optional description appears beneath it in muted supporting text and wraps
+within the row. Clicking either line selects the same label, which is the only
+value returned to the model. The custom-answer option remains unchanged.
+
## Typography hierarchy
The card uses a compact two-tier type scale — quiet labels, then content at
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 798ed8b8e..df404773a 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -2096,9 +2096,9 @@ identify the platform validation still needed.
- **Preconditions**: Project directory open.
- **Steps**: 1) Ask agent to read a file in the project. 2) Observe result.
- **Expected**: `Read` returns immediately within project scope. In Agent mode,
- the agent activates `Glob` or `Grep` through `ToolSearch` before using it;
- Plan keeps its read/search core available from the first request. All results
- remain within project scope.
+ `Glob` and `Grep` are available in the first Agent request without
+ `ToolSearch`; Plan keeps its read/search core available from the first
+ request. All results remain within project scope.
- **Specs linked**: `03-runtime/03-tools-and-permissions.md`
- **Acceptance**: E (Read/Glob/Grep work), D (tools based on project)
- **Milestone**: M3
@@ -2188,7 +2188,8 @@ identify the platform validation still needed.
- **Preconditions**: Agent or Plan mode; project open; the host tool catalog is
available on macOS, Linux, or Windows.
-- **Steps**: 1) Activate `Glob`/`Grep` when deferred and inspect their schemas.
+- **Steps**: 1) In Agent mode, inspect `Glob`/`Grep` in the first request
+ without `ToolSearch`; confirm Plan also exposes both from its first request.
2) Search with workspace-relative `path`, `include`, `headLimit`, and
`outputMode: "filesWithMatches"` or `"count"`, first with a directory and
then one explicit file. 3) Call `Read` with a directory and follow its
@@ -4348,8 +4349,9 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
outstanding task-native object, a repeated durable id produces no second
banner or row, and a delayed pre-clear event cannot resurrect the cleared
item; a genuinely new post-clear turn still produces exactly one row and
- banner. On Windows, the taskbar overlay is a smooth black circular badge
- with a centered white system-font numeral. Its visual weight matches common
+ banner. Each newly accepted task notification plays one soft in-app chime;
+ duplicate, delayed, and historical rows do not replay it. On Windows, the
+ taskbar overlay is a smooth black circular badge with a centered white system-font numeral. Its visual weight matches common
Windows taskbar badges for both single- and two-digit counts. A success-only
outcome increments the taskbar badge without adding a bell row or bell
count; both toolbar actions remain enabled when relevant and clear the
@@ -4382,10 +4384,10 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
- **Expected**: Focused-current A creates neither inbox row, terminal sidebar mark, nor native banner.
Focused-background B creates an inbox row without a native banner. Unfocused
current A and the minimized failure each create one durable row and one
- localized native notification. Clicking restores, shows, and focuses the
- main window before activating the matching session, including after the
- notification has moved to Windows Action Center; no event opens the wrong
- currently selected session. Abort shows neither surface. OS suppression does
+ localized, silent native notification plus one soft in-app chime. Clicking
+ restores, shows, and focuses the main window before activating the matching
+ session, including after the notification has moved to Windows Action Center;
+ no event opens the wrong currently selected session. Abort shows neither surface. OS suppression does
not lose the durable row or surface a misleading app error. Every inspected
Windows system surface identifies `PI-Desktop`; no stock Electron application
name or identity is exposed. Duplicate delivery is idempotent: one durable
@@ -4399,6 +4401,24 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
- **Status**: Source-contract covered (`notification-contract.test.mjs`); packaged
Windows Action Center activation remains runner validation; full UI scenario Draft
+#### E2E-065A: App notifications use one soft chime
+
+- **Preconditions**: A running desktop app with audio output; a second session
+ for background notification delivery.
+- **Steps**: 1) Trigger info, success, warning, and error toasts. 2) Complete or
+ fail a background task. 3) Trigger an asktool request and a permission or plan
+ approval request. 4) Replay a durable notification id and refresh the inbox.
+- **Expected**: Each newly presented app toast, task notification, interactive
+ prompt, and successfully shown plugin-native notification plays one short,
+ low-volume chime. Rapid events coalesce; duplicate or historical notification
+ rows do not replay it. Asktool's toast does not add a second chime, and native
+ banners stay silent to prevent a second, platform-dependent sound. If Web
+ Audio is unavailable or blocked, visual notifications still work and no app
+ action fails.
+- **Specs linked**: `03-runtime/17-asktool-questions.md`
+- **Acceptance**: C (notification feedback), Accessibility
+- **Status**: Unit/source-contract covered; audible desktop check Draft
+
#### E2E-066: Provider model catalog survives restart and offline refresh
- **Preconditions**: A saved provider matches a models.dev provider/API URL and
@@ -9702,14 +9722,15 @@ This test plan spec is accepted when:
- Focusing the textarea paints an inset 2px accent ring inside the plate;
Escape or Cancel restores the bubble.
-#### E2E-123: asktool collects multiple answers and returns skipped placeholders
+#### E2E-123: asktool renders rich options, reminds the user, and returns answers
- **Preconditions**: Agent, Plan, or Goal mode; a configured provider; a
session with an active transcript.
- **Steps**: 1) Ask the agent to call `asktool` with a single-select question,
- a multi-select question, and an option list for each. 2) Confirm each card
- shows the fixed custom-input choice. 3) Answer the first question, click
- Next, and select two answers on the multi-select question. 4) Skip the final
+ a multi-select question, and option lists containing both strings and
+ `{ label, description }` objects. 2) Confirm each card shows the fixed
+ custom-input choice and rich option descriptions. 3) Answer the first question,
+ click Next, and select two answers on the multi-select question. 4) Skip the final
question without entering text. 5) Inspect the completed tool row and the
next model response.
- **Expected**: One question is visible at a time; the small indicators show
@@ -9729,13 +9750,17 @@ This test plan spec is accepted when:
action row. The tool output is ordered as
`question:answer`, uses `、` between multiple answers and `\n---\n`
between questions, and
- keeps `question:` for the skipped question. Decline all produces empty
- placeholders for every question and still completes the tool call.
+ keeps `question:` for the skipped question, and selecting a rich option
+ returns only its label. Decline all produces empty placeholders for every
+ question and still completes the tool call. A pending ask shows a localized
+ in-app toast with its session and first question, while background sessions
+ retain the existing native notification policy. Exactly one soft chime plays
+ for the ask; the toast and native banner do not double it.
- **Specs linked**: `03-runtime/17-asktool-questions.md`,
`04-ux/11-asktool-question-card.md`, ADR 0077
- **Acceptance**: E (interactive tool output), C (inline card)
- **Milestone**: M5
-- **Status**: Draft (unit coverage active; desktop journey pending)
+- **Status**: Draft (runtime/unit coverage active; desktop journey pending)
- **Request transition regression**: Keep a one-question request pending in chat
B. In chat A, advance a two-question request to question two, then select B.
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index f86bf1070..c0e0cb841 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -7208,3 +7208,15 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
IDs, provider identity, or host capability ownership. See
`03-runtime/13-model-catalog-and-selection.md` §11.3 and
`04-ux/08-component-spec.md` §11.
+
+## 2026-09-27 — Agent workspace search is available from turn one (D631)
+
+- Amend D185 / D208 and ADR 0069's Agent activation boundary: `Glob` and
+ `Grep` are included with `Read`, `Bash`, `Edit`, and `Write` in the first
+ Agent request. Routine workspace discovery no longer needs a `ToolSearch`
+ round trip.
+- `BrowserPreview`, plugin tools, and plugin-development helpers remain
+ deferred; ToolSearch, successful-activation restoration, host permissions,
+ and the Plan/Goal tool sets are unchanged.
+- See the 2026-09-27 amendments to ADR 0048, ADR 0069, and ADR 0230, plus
+ `03-runtime/03-tools-and-permissions.md` and E2E-013/E2E-019e.
diff --git a/packages/agent-host/src/agent-host.test.ts b/packages/agent-host/src/agent-host.test.ts
index 1040b2db7..ae05d8cbd 100644
--- a/packages/agent-host/src/agent-host.test.ts
+++ b/packages/agent-host/src/agent-host.test.ts
@@ -572,11 +572,29 @@ describe("AgentHost approvals and inputs", () => {
host.ingest(
envelope("s1", "rt_1", {
type: "asktool_request",
- request: { requestId: "ask_1", sessionId: "s1", toolCallId: "c9", questions: [{ question: "Which?", options: ["a", "b"], multiSelect: true }, { question: "Why?", options: [] }] },
+ request: {
+ requestId: "ask_1",
+ sessionId: "s1",
+ toolCallId: "c9",
+ questions: [
+ {
+ question: "Which?",
+ options: [
+ { label: "a", description: "First choice" },
+ { label: "b", description: "Second choice" },
+ ],
+ multiSelect: true,
+ },
+ { question: "Why?", options: [] },
+ ],
+ },
}),
);
const raised = received.find((event) => event.kind === "input.requested")!;
expect((raised.payload as { questions: unknown[] }).questions).toHaveLength(2);
+ expect(
+ (raised.payload as { questions: Array<{ options: string[] }> }).questions[0]?.options,
+ ).toEqual(["a", "b"]);
expect(host.getTurn("rt_1").status).toBe("waiting_input");
await expect(host.respondInput(controller, { inputId: "ask_1", answers: [["a"]], context: { requestId: "r" } })).rejects.toMatchObject({
code: "INVALID_ARGUMENT",
diff --git a/packages/agent-host/src/agent-host.ts b/packages/agent-host/src/agent-host.ts
index 8901bf8d8..d62701831 100644
--- a/packages/agent-host/src/agent-host.ts
+++ b/packages/agent-host/src/agent-host.ts
@@ -32,6 +32,7 @@ import {
RACP_DEFAULT_LIMITS,
RACP_DEFAULT_POLICY,
applyMessageUpdate,
+ askToolOptionLabel,
deltaStreamPayloadFits,
effectiveRemotePermissionMode,
racpKindForAgentEvent,
@@ -1166,7 +1167,9 @@ export class AgentHost {
questions: request.questions.map((question, index) => ({
id: `${request.requestId}:${index}`,
question: question.question,
- options: question.options,
+ // RACP v1 keeps answer choices as labels; the desktop-only description
+ // remains local to the inline asktool card.
+ options: question.options.map(askToolOptionLabel),
multiSelect: question.multiSelect ?? false,
})),
};
diff --git a/packages/agent-runtime/src/runtime.test.ts b/packages/agent-runtime/src/runtime.test.ts
index 12a4fb769..029e11bad 100644
--- a/packages/agent-runtime/src/runtime.test.ts
+++ b/packages/agent-runtime/src/runtime.test.ts
@@ -1296,8 +1296,8 @@ describe("DesktopAgentRuntime configuration matching", () => {
),
};
const runtime = createRuntime({ host });
- // Read the catalog, not the active set: Glob and Grep are deferred tools
- // and are only activated on demand.
+ // Read the full registry so aliases can be exercised independently of the
+ // active set selected for a particular session mode.
const tool = (name: string) => (runtime as any).toolCatalog.get(name);
for (const name of ["Read", "Write", "Edit"]) {
@@ -1910,7 +1910,7 @@ describe("DesktopAgentRuntime live activity", () => {
});
describe("DesktopAgentRuntime deferred tool catalog", () => {
- it("keeps the first agent request on core tools plus discovery", async () => {
+ it("starts Agent with core tools plus workspace search and discovery", async () => {
const runtime = createRuntime({
pluginTools: [
{
@@ -1935,6 +1935,8 @@ describe("DesktopAgentRuntime deferred tool catalog", () => {
"Bash",
"Edit",
"Write",
+ "Glob",
+ "Grep",
"asktool",
"Skill",
"EnterPlanMode",
@@ -1942,6 +1944,8 @@ describe("DesktopAgentRuntime deferred tool catalog", () => {
"new_context",
"ToolSearch",
]);
+ expect((runtime as any).deferredToolNames.has("Glob")).toBe(false);
+ expect((runtime as any).deferredToolNames.has("Grep")).toBe(false);
expect(names).not.toContain("A2A");
expect(names).not.toContain("Peer");
expect(names).not.toContain("BrowserPreview");
@@ -1965,9 +1969,29 @@ describe("DesktopAgentRuntime deferred tool catalog", () => {
const askTool = (runtime as any).agent.state.tools.find(
(tool: any) => tool.name === "asktool",
);
+ const optionVariants =
+ (askTool.parameters as any).properties.questions.items.properties.options.items.anyOf;
+ expect(optionVariants).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({ type: "string" }),
+ expect.objectContaining({
+ type: "object",
+ properties: expect.objectContaining({
+ label: expect.objectContaining({ type: "string" }),
+ description: expect.objectContaining({ type: "string" }),
+ }),
+ }),
+ ]),
+ );
const pending = askTool.execute("ask-call-1", {
questions: [
- { question: "Color?", options: ["Blue", "Green"] },
+ {
+ question: "Color?",
+ options: [
+ { label: "Blue", description: "A calm, cool color." },
+ "Green",
+ ],
+ },
{ question: "Targets?", options: ["Web", "Desktop"], multiSelect: true },
],
});
@@ -1980,7 +2004,13 @@ describe("DesktopAgentRuntime deferred tool catalog", () => {
sessionId: "session-1",
toolCallId: "ask-call-1",
questions: [
- { question: "Color?", options: ["Blue", "Green"] },
+ {
+ question: "Color?",
+ options: [
+ { label: "Blue", description: "A calm, cool color." },
+ "Green",
+ ],
+ },
{ question: "Targets?", options: ["Web", "Desktop"], multiSelect: true },
],
});
@@ -2170,6 +2200,8 @@ describe("DesktopAgentRuntime mode and tool composition", () => {
expect(agentTools).toEqual(
expect.arrayContaining([
"Read",
+ "Glob",
+ "Grep",
"Write",
"Edit",
"Bash",
@@ -8709,9 +8741,9 @@ describe("DesktopAgentRuntime deferred tool restore (#225)", () => {
assistantRow,
searchRow({
toolResult: {
- content: [{ type: "text", text: "Activated on-demand tools: BrowserPreview, Glob." }],
+ content: [{ type: "text", text: "Activated on-demand tools: BrowserPreview, PluginCheck." }],
details: {
- addedToolNames: ["BrowserPreview", "Glob"],
+ addedToolNames: ["BrowserPreview", "PluginCheck"],
},
},
}),
@@ -8732,7 +8764,7 @@ describe("DesktopAgentRuntime deferred tool restore (#225)", () => {
(runtime as any).resetDeferredToolsForPrompt();
expect(hasTool(runtime, "BrowserPreview")).toBe(true);
- expect(hasTool(runtime, "Glob")).toBe(true);
+ expect(hasTool(runtime, "PluginCheck")).toBe(true);
await runtime.dispose();
});
diff --git a/packages/agent-runtime/src/runtime.ts b/packages/agent-runtime/src/runtime.ts
index ea5d6c3b8..53ac0c021 100644
--- a/packages/agent-runtime/src/runtime.ts
+++ b/packages/agent-runtime/src/runtime.ts
@@ -99,12 +99,14 @@ import {
contextCompactionMark,
cumulativeDelta,
DEFAULT_SUBAGENT_PERMISSION,
+ askToolOptionLabel,
formatAskToolOutput,
formatSessionMessage,
hostedSearchFromMessage,
isCommandShellOption,
isToolsOutputParams,
MAX_SUBAGENT_CONCURRENCY,
+ normalizeAskToolOption,
normalizeSubagentName,
proposalKindForMode,
resolveSubagentToolNames,
@@ -672,6 +674,8 @@ const PATH_MUTATING_TOOLS = new Set(["Write", "Edit"]);
const CHAT_CORE_TOOL_NAMES = new Set(["Read", "Glob", "Grep", ASK_TOOL_NAME]);
const AGENT_CORE_TOOL_NAMES = new Set([
"Read",
+ "Glob",
+ "Grep",
"Write",
"Edit",
"Bash",
@@ -2915,7 +2919,7 @@ Do not invent objections or turn speculative risks into blockers. Stop when the
case "Bash":
return `${commandShellToolDescription(this.commandShell, this.scratchDir)} Use Edit or Write instead of apply_patch, git apply, or patch; do not retry a failed shell patch command repeatedly.`;
case ASK_TOOL_NAME:
- return "Ask the user one or more questions. Each question has selectable options and the desktop card always provides a custom user-input option; unanswered questions are returned as empty answers.";
+ return "Ask the user one or more questions. Options may be plain labels or objects with a `label` and optional `description`; the desktop card always provides a custom user-input option. Unanswered questions are returned as empty answers.";
case "PluginScaffold":
return "Create a PI-Desktop plugin from a template and load it for development. `directory` is workspace-relative and must be empty or new; `template` is one of panel-basic, agent-tool-basic, skill-pack, full-demo. Use this instead of hand-writing plugin files.";
case "PluginCheck":
@@ -3336,7 +3340,15 @@ Do not invent objections or turn speculative risks into blockers. Stop when the
questions: Type.Array(
Type.Object({
question: Type.String(),
- options: Type.Array(Type.String()),
+ options: Type.Array(
+ Type.Union([
+ Type.String(),
+ Type.Object({
+ label: Type.String(),
+ description: Type.Optional(Type.String()),
+ }),
+ ]),
+ ),
multiSelect: Type.Optional(Type.Boolean()),
}),
),
@@ -5353,17 +5365,22 @@ Do not invent objections or turn speculative risks into blockers. Stop when the
for (const raw of params.questions) {
if (!isRecord(raw)) return undefined;
const question = typeof raw.question === "string" ? raw.question.trim() : "";
- const options = Array.isArray(raw.options)
- ? raw.options
- .filter((option): option is string => typeof option === "string")
- .map((option) => option.trim())
- .filter(Boolean)
- : [];
+ const options: AskToolQuestion["options"] = [];
+ const seenLabels = new Set<string>();
+ if (Array.isArray(raw.options)) {
+ for (const rawOption of raw.options) {
+ const option = normalizeAskToolOption(rawOption);
+ if (!option) continue;
+ const label = askToolOptionLabel(option);
+ if (seenLabels.has(label)) continue;
+ seenLabels.add(label);
+ options.push(option);
+ }
+ }
if (!question || options.length === 0) return undefined;
- const uniqueOptions = [...new Set(options)];
questions.push({
question,
- options: uniqueOptions,
+ options,
...(raw.multiSelect === true ? { multiSelect: true } : {}),
});
}
diff --git a/packages/shared/src/asktool.test.ts b/packages/shared/src/asktool.test.ts
index c3e687d62..6cf7068a6 100644
--- a/packages/shared/src/asktool.test.ts
+++ b/packages/shared/src/asktool.test.ts
@@ -4,7 +4,14 @@ import { formatAskToolOutput, type AskToolQuestion } from "./types.js";
describe("asktool output", () => {
const questions: AskToolQuestion[] = [
{ question: "Preferred color?", options: ["Blue", "Green"] },
- { question: "Which platforms?", options: ["Web", "Desktop"], multiSelect: true },
+ {
+ question: "Which platforms?",
+ options: [
+ { label: "Web", description: "Runs in a browser." },
+ { label: "Desktop", description: "Installs on the user's computer." },
+ ],
+ multiSelect: true,
+ },
];
it("serializes each question with selected answers and a stable separator", () => {
diff --git a/packages/shared/src/protocol.ts b/packages/shared/src/protocol.ts
index 7313e9f1b..1e489047e 100644
--- a/packages/shared/src/protocol.ts
+++ b/packages/shared/src/protocol.ts
@@ -380,6 +380,7 @@ export const IPC = {
notificationChanged: "pi-desktop/notification/event/changed",
sessionsChanged: "pi-desktop/session/event/changed",
notificationActivated: "pi-desktop/notification/event/activated",
+ notificationSound: "pi-desktop/notification/event/sound",
plansChanged: "pi-desktop/plans/event/changed",
providersOauth: "pi-desktop/providers/oauth/event",
mcpOauth: "pi-desktop/mcp/oauth/event",
diff --git a/packages/shared/src/types/agent.ts b/packages/shared/src/types/agent.ts
index 548730a15..da9d8d171 100644
--- a/packages/shared/src/types/agent.ts
+++ b/packages/shared/src/types/agent.ts
@@ -184,10 +184,45 @@ export type ToolPermissionResolution = {
decision: PermissionDecision;
};
+/** A selectable asktool answer: a plain label or a label with supporting copy. */
+export type AskToolOption =
+ | string
+ | {
+ label: string;
+ description?: string;
+ };
+
+/** Normalize a model-provided asktool option and discard malformed/empty values. */
+export function normalizeAskToolOption(value: unknown): AskToolOption | undefined {
+ if (typeof value === "string") {
+ const label = value.trim();
+ return label || undefined;
+ }
+ if (!value || typeof value !== "object" || Array.isArray(value)) return undefined;
+ const option = value as Record<string, unknown>;
+ const label = typeof option.label === "string" ? option.label.trim() : "";
+ if (!label) return undefined;
+ const description =
+ typeof option.description === "string" ? option.description.trim() : "";
+ return description ? { label, description } : { label };
+}
+
+export function askToolOptionLabel(option: AskToolOption): string {
+ return typeof option === "string" ? option : option.label;
+}
+
+export function askToolOptionDescription(
+ option: AskToolOption,
+): string | undefined {
+ if (typeof option === "string") return undefined;
+ const description = option.description?.trim();
+ return description || undefined;
+}
+
/** A model-created question shown in the inline asktool card. */
export type AskToolQuestion = {
question: string;
- options: string[];
+ options: AskToolOption[];
multiSelect?: boolean;
};