Open-source, local-first AI agent team for your desktop: multi-agent group chats, computer use, browser, MCP, routines and approvals. macOS, Windows, Linux + Android. Built on pi.
TypeScript agentai-agentai-agentsai-assistantandroidautomationchatgptcoding-agentcomputer-usedesktop-appelectronllmlocal-firstmcpmulti-agentollamaopenaiprivacyself-hostedtypescript
feat(desktop): Windows explains YOLO once before commands run without a sandbox
leen.zhoub068cf7b8eef
diff --git a/apps/desktop/src/renderer/features/chat/status/YoloConfirmation.tsx b/apps/desktop/src/renderer/features/chat/status/YoloConfirmation.tsxnew file mode 100644index 0000000..a7b731c--- /dev/null+++ b/apps/desktop/src/renderer/features/chat/status/YoloConfirmation.tsx@@ -0,0 +1,168 @@+// Keep the Windows disclosure and explicit consent with the existing YOLO confirmation.+import { isolationReasonText } from "@pibot/client-core";+import type { ConversationYolo } from "@pibot/protocol";+import { useAction, useNavigation, useSettings } from "@pibot/renderer-kit";+import { Button } from "@pibot/ui";+import { useState } from "react";+import { Overlay } from "../../workspace/Overlay.tsx";+import workspaceStyles from "../../workspace/workspace.module.css";+import styles from "./yolo.module.css";++export function YoloConfirmation({+ isolation,+ group,+ close,+ enable,+}: {+ isolation: ConversationYolo["isolation"];+ group: boolean;+ close(): void;+ enable(signal: AbortSignal, acknowledged: boolean): Promise<ConversationYolo | undefined>;+}) {+ const { t, settings } = useSettings();+ const action = useAction();+ const [acknowledged, setAcknowledged] = useState(false);+ const windows = window.pibot.platform === "win32";+ const consented = settings?.yoloUnisolatedCommands === true;+ const needsConsent = windows && !consented;+ return (+ <Overlay+ icon="bolt"+ tone="orange"+ title={t("yolo.confirmTitle")}+ close={close}+ busy={action.busy}+ >+ <div className={styles.confirm}>+ <p>{t("yolo.confirmIntro")}</p>+ {group && <p>{t("yolo.confirmGroup")}</p>}+ {!isolation.available && (!windows || isolation.reason !== "windows_unisolated") && (+ <p className={styles.risk} role="alert">+ {t("yolo.unisolated", {+ reason: isolationReasonText(isolation.reason, t) || t("yolo.unisolatedUnknown"),+ })}+ </p>+ )}+ <YoloScopes windows={windows} isolated={isolation.available} />+ {windows && (+ <WindowsYoloDisclosure+ consented={consented}+ ready={settings !== undefined}+ acknowledged={acknowledged}+ setAcknowledged={setAcknowledged}+ busy={action.busy}+ close={close}+ />+ )}+ <p className={styles.note}>+ {t(windows ? "yolo.nothingRemembered.windows" : "yolo.nothingRemembered")}+ </p>+ </div>+ <div className={workspaceStyles.actions}>+ <Button variant="secondary" disabled={action.busy} onClick={close}>+ {t("common.cancel")}+ </Button>+ <Button+ className={styles.turnOn}+ loading={action.busy}+ disabled={windows && (!settings || (needsConsent && !acknowledged))}+ onClick={() =>+ void action+ .run(+ (signal) => enable(signal, needsConsent && acknowledged),+ () => "yolo.failed",+ )+ .then((value) => {+ if (value?.enabled) close();+ })+ }+ >+ {t("yolo.confirm")}+ </Button>+ </div>+ {action.error && (+ <p role="alert" className={workspaceStyles.error}>+ {t(action.error)}+ </p>+ )}+ </Overlay>+ );+}++function YoloScopes({ windows, isolated }: { windows: boolean; isolated: boolean }) {+ const { t } = useSettings();+ return (+ <div className={styles.scopes}>+ <section className={styles.scope} data-tone="ok">+ <h2>{t("yolo.skips")}</h2>+ <p>{t(windows ? "yolo.skipsList.windows" : "yolo.skipsList")}</p>+ </section>+ <section className={styles.scope} data-tone="danger">+ <h2>{t("yolo.keeps")}</h2>+ <p>{t(windows ? "yolo.keepsList.windows" : "yolo.keepsList")}</p>+ <p>+ {t(+ windows+ ? "yolo.readOnly.windows"+ : isolated+ ? "yolo.keepsSafety"+ : "yolo.keepsSafetyUnisolated",+ )}+ </p>+ </section>+ </div>+ );+}++function WindowsYoloDisclosure({+ consented,+ ready,+ acknowledged,+ setAcknowledged,+ busy,+ close,+}: {+ consented: boolean;+ ready: boolean;+ acknowledged: boolean;+ setAcknowledged(value: boolean): void;+ busy: boolean;+ close(): void;+}) {+ const { t } = useSettings();+ const { openSettings } = useNavigation();+ if (!ready) return <p role="status">{t("common.loading")}</p>;+ if (consented)+ return (+ <p className={styles.note}>+ {t("yolo.windowsReminder")}{" "}+ <button+ type="button"+ className={styles.consentLink}+ disabled={busy}+ onClick={() => {+ close();+ openSettings("permissions");+ }}+ >+ {t("yolo.windowsConsentSettings")}+ </button>+ </p>+ );+ return (+ <div className={styles.consentBanner}>+ <p>+ <strong>{t("yolo.windowsDisclosureTitle")}</strong> {t("yolo.windowsDisclosure")}+ </p>+ <label className={styles.consentCheck}>+ <input+ type="checkbox"+ checked={acknowledged}+ disabled={busy}+ onChange={(event) => setAcknowledged(event.currentTarget.checked)}+ />+ {t("yolo.windowsAcknowledge")}+ </label>+ </div>+ );+}diff --git a/apps/desktop/src/renderer/features/chat/status/YoloControl.tsx b/apps/desktop/src/renderer/features/chat/status/YoloControl.tsxindex 56ddaea..6147fee 100644--- a/apps/desktop/src/renderer/features/chat/status/YoloControl.tsx+++ b/apps/desktop/src/renderer/features/chat/status/YoloControl.tsx@@ -1,13 +1,12 @@+// Show the conversation's YOLO switch and its confirmation.import type { ChatPeer } from "@pibot/client-core";-import { isolationReasonText } from "@pibot/client-core";-import { useAction, useSettings, useT } from "@pibot/renderer-kit";+import { useAction, useT } from "@pibot/renderer-kit";import { Button, Icon, IconButton, IconTile } from "@pibot/ui";import { useRef, useState } from "react";-import { Overlay } from "../../workspace/Overlay.tsx";import { menuKeys, useMenuPopover } from "../../workspace/profile/use-menu-popover.ts";-import workspaceStyles from "../../workspace/workspace.module.css";import { useGroupTopicArchive, useTopicArchive } from "../topics/use-topic-archive.ts";import { useConversationYolo } from "./use-conversation-yolo.ts";+import { YoloConfirmation } from "./YoloConfirmation.tsx";import styles from "./yolo.module.css";/**@@ -29,19 +28,19 @@ export function YoloControl({topicBotId?: string;topicGroupId?: string;}) {- const { t, settings } = useSettings();- const windows = window.pibot.platform === "win32";+ const t = useT();const { state, set } = useConversationYolo(peer, conversationId);const dmArchive = useTopicArchive(peer, topicBotId, conversationId);const groupArchive = useGroupTopicArchive(peer, topicGroupId, conversationId);const archive = topicGroupId ? groupArchive : dmArchive;const action = useAction();const [menu, setMenu] = useState<{ opener: HTMLElement; x: number; y: number }>();- const [confirming, setConfirming] = useState(false);+ const [confirmingId, setConfirmingId] = useState<string>();+ const confirming = !!state && confirmingId === state.conversationId;if (!state && !archive.available) return null;const change = (enabled: boolean) =>action.run(- () => set(enabled),+ (signal) => set(enabled, signal),() => "yolo.failed",);return (@@ -85,7 +84,7 @@ export function YoloControl({toggle={() => {setMenu(undefined);if (state?.enabled) void change(false);- else setConfirming(true);+ else setConfirmingId(state?.conversationId);}}archive={archive.available@@ -104,69 +103,13 @@ export function YoloControl({</span>)}{confirming && state && (- <Overlay- icon="bolt"- tone="orange"- title={t("yolo.confirmTitle")}- close={() => setConfirming(false)}- busy={action.busy}- >- <div className={styles.confirm}>- <p>{t("yolo.confirmIntro")}</p>- {group && <p>{t("yolo.confirmGroup")}</p>}- {!state.isolation.available && (- <p className={styles.risk} role="alert">- {t(- windows- ? settings?.yoloUnisolatedCommands- ? "yolo.unisolatedEnabled"- : "yolo.unisolatedDisabled"- : "yolo.unisolated",- {- reason:- isolationReasonText(state.isolation.reason, t) || t("yolo.unisolatedUnknown"),- },- )}- </p>- )}- {/* What YOLO allows and what still asks sit side by side. */}- <div className={styles.scopes}>- <section className={styles.scope} data-tone="ok">- <h2>{t("yolo.skips")}</h2>- <p>{t(windows ? "yolo.skipsList.windows" : "yolo.skipsList")}</p>- </section>- <section className={styles.scope} data-tone="danger">- <h2>{t("yolo.keeps")}</h2>- <p>{t("yolo.keepsList")}</p>- <p>- {t(state.isolation.available ? "yolo.keepsSafety" : "yolo.keepsSafetyUnisolated")}- </p>- </section>- </div>- <p className={styles.note}>{t("yolo.nothingRemembered")}</p>- </div>- <div className={workspaceStyles.actions}>- <Button variant="secondary" disabled={action.busy} onClick={() => setConfirming(false)}>- {t("common.cancel")}- </Button>- <Button- className={styles.turnOn}- loading={action.busy}- onClick={() =>- void change(true).then((value) => {- if (value) setConfirming(false);- })- }- >- {t("yolo.confirm")}- </Button>- </div>- {action.error && (- <p role="alert" className={workspaceStyles.error}>- {t(action.error)}- </p>- )}- </Overlay>+ <YoloConfirmation+ key={state.conversationId}+ isolation={state.isolation}+ group={group}+ close={() => setConfirmingId(undefined)}+ enable={(signal, acknowledged) => set(true, signal, acknowledged)}+ />)}</span>);diff --git a/apps/desktop/src/renderer/features/chat/status/use-conversation-yolo.ts b/apps/desktop/src/renderer/features/chat/status/use-conversation-yolo.tsindex fa1cd61..451767a 100644--- a/apps/desktop/src/renderer/features/chat/status/use-conversation-yolo.ts+++ b/apps/desktop/src/renderer/features/chat/status/use-conversation-yolo.ts@@ -1,3 +1,4 @@+// Keep the conversation switch in sync with the brain and other windows.import type { ChatPeer } from "@pibot/client-core";import type { ConversationYolo } from "@pibot/protocol";import { useCallback, useEffect, useState } from "react";@@ -40,13 +41,21 @@ export function useConversationYolo(peer: ChatPeer | null | undefined, conversat};}, [peer, conversationId]);const set = useCallback(- async (enabled: boolean) => {+ async (enabled: boolean, signal: AbortSignal, acknowledged = false) => {if (!peer || !conversationId) return undefined;- const value = await peer.call("conversations.yolo.set", { conversationId, enabled });- setState(value);+ const value =+ enabled && window.pibot.platform === "win32"+ ? await peer.call(+ "conversations.yolo.enableOnWindows",+ { conversationId, ...(acknowledged ? { acknowledged: true } : {}) },+ { signal },+ )+ : await peer.call("conversations.yolo.set", { conversationId, enabled }, { signal });+ if (!signal.aborted)+ setState((current) => (current?.conversationId === conversationId ? value : current));return value;},[peer, conversationId],);- return { state, set };+ return { state: state?.conversationId === conversationId ? state : null, set };}diff --git a/apps/desktop/src/renderer/features/chat/status/yolo.module.css b/apps/desktop/src/renderer/features/chat/status/yolo.module.cssindex 0e9748b..86b4cbf 100644--- a/apps/desktop/src/renderer/features/chat/status/yolo.module.css+++ b/apps/desktop/src/renderer/features/chat/status/yolo.module.css@@ -273,3 +273,33 @@display: block;}}++.consentBanner {+ display: grid;+ gap: 8px;+ margin-top: 8px;+ padding: 10px 12px;+ border-radius: 12px;+ background: var(--warnBg);+ color: var(--warn);+}+.consentCheck {+ display: flex;+ align-items: flex-start;+ gap: 8px;+ color: var(--text);+}+.consentCheck input {+ flex: none;+ margin: 3px 0 0;+ accent-color: var(--prim);+}+.consentLink {+ border: 0;+ padding: 0;+ background: none;+ color: var(--accent);+ cursor: pointer;+ font: inherit;+ text-decoration: underline;+}diff --git a/apps/desktop/src/renderer/features/settings/permissions/permission-operations.tsx b/apps/desktop/src/renderer/features/settings/permissions/permission-operations.tsxindex 9521a9e..3360d65 100644--- a/apps/desktop/src/renderer/features/settings/permissions/permission-operations.tsx+++ b/apps/desktop/src/renderer/features/settings/permissions/permission-operations.tsx@@ -1,3 +1,4 @@+// Keep global permission controls and their explanations consistent.import type { TranslationKey } from "@pibot/i18n";import type { Category, Level, PermissionLevels } from "@pibot/protocol";import { SettingsRow, useT } from "@pibot/renderer-kit";@@ -60,7 +61,9 @@ export function LevelRow({const t = useT();const windowsCommand = category === "run_command" && window.pibot.platform === "win32";const short = info ? SHORT[category] : undefined;- const long = t(`permissions.note.${category}`);+ const long = t(+ windowsCommand ? "permissions.info.run_command.windows" : `permissions.note.${category}`,+ );return (<SettingsRowicon={CATEGORY_LOOK[category][0]}diff --git a/apps/desktop/src/renderer/features/settings/permissions/permissions.tsx b/apps/desktop/src/renderer/features/settings/permissions/permissions.tsxindex 10be613..2fa7094 100644--- a/apps/desktop/src/renderer/features/settings/permissions/permissions.tsx+++ b/apps/desktop/src/renderer/features/settings/permissions/permissions.tsx@@ -1,3 +1,4 @@+// Arrange the global permissions and command environment settings.import { isolationReasonText } from "@pibot/client-core";import { PasswordSettings, useCredentialList } from "@pibot/credentials/ui";import type { Category, Level } from "@pibot/protocol";@@ -128,7 +129,7 @@ export function PermissionsSettings({ target }: { target?: "passwords" }) {levels={data.levels}disabled={disabled}info- unisolated={category === "run_command" && !data.isolation.available}+ unisolated={sandboxed && category === "run_command" && !data.isolation.available}note={category === "run_command"? window.pibot.platform === "win32"@@ -141,10 +142,13 @@ export function PermissionsSettings({ target }: { target?: "passwords" }) {change={change}/>))}- <UnisolatedYoloRow disabled={disabled} /></SettingsSection><SettingsSection title={t("permissions.commandEnv")}>- <SandboxRemembered disabled={disabled} open={() => setSub("sandbox")} />+ {sandboxed ? (+ <SandboxRemembered disabled={disabled} open={() => setSub("sandbox")} />+ ) : (+ <UnisolatedYoloRow disabled={disabled} />+ )}<PathPermissions data={data} disabled={disabled} save={settings.save} /><DockerPermissions data={data} disabled={disabled} save={settings.save} /><SettingsLinkRowdiff --git a/apps/desktop/src/renderer/features/settings/permissions/unisolated-yolo.tsx b/apps/desktop/src/renderer/features/settings/permissions/unisolated-yolo.tsxindex af7f67e..6e739e6 100644--- a/apps/desktop/src/renderer/features/settings/permissions/unisolated-yolo.tsx+++ b/apps/desktop/src/renderer/features/settings/permissions/unisolated-yolo.tsx@@ -1,64 +1,45 @@-import { layoutStyles, SettingsRow, useSettings } from "@pibot/renderer-kit";-import { Button, Switch } from "@pibot/ui";-import { useState } from "react";+// Show and withdraw the Windows consent that was recorded in the YOLO confirmation.+import { SettingsLine, SettingsRow, useAction, useSettings } from "@pibot/renderer-kit";+import { Button } from "@pibot/ui";-/**- * Windows only: commands there run without a sandbox, so YOLO approves them- * only after the user turns this on and confirms the risk. Other platforms never run commands- * unisolated, so the row is not shown there.- */export function UnisolatedYoloRow({ disabled }: { disabled: boolean }) {- const { t, settings, update } = useSettings();- const [confirming, setConfirming] = useState(false);- if (window.pibot.platform !== "win32" || !settings) return null;- const on = settings.yoloUnisolatedCommands === true;+ const { t, settings, update, language } = useSettings();+ const action = useAction();+ if (window.pibot.platform !== "win32") return null;+ const consented = settings?.yoloUnisolatedCommands === true;+ const at = settings?.yoloUnisolatedCommandsAt;+ const date = at ? new Date(at).toLocaleDateString(language === "zh" ? "zh-CN" : "en") : null;+ const status = !settings+ ? t("common.loading")+ : consented+ ? date+ ? t("permissions.yoloWindowsConsentedAt", { date })+ : t("permissions.yoloWindowsConsented")+ : t("permissions.yoloWindowsNotConsented");return (<><SettingsRow- icon="warning"- tone="red"+ icon="shield"+ tone="orange"label={t("permissions.yoloUnisolated")}- note={t("permissions.short.yoloUnisolated")}- info={t("permissions.yoloUnisolatedNote")}+ note={status}>- <Switch- label={t("permissions.yoloUnisolated")}- checked={on}- disabled={disabled || confirming}- onCheckedChange={(next) => {- if (next) setConfirming(true);- else void update({ yoloUnisolatedCommands: false });- }}- />- </SettingsRow>- {confirming && (- <div- role="alertdialog"- aria-label={t("permissions.yoloUnisolated")}- className={layoutStyles.banner}- data-tone="danger"- >- <span>{t("permissions.yoloUnisolatedConfirm")}</span>+ {consented && (<Buttonvariant="ghost"- className={layoutStyles.small}- disabled={disabled}- onClick={() => setConfirming(false)}+ disabled={disabled || action.busy}+ onClick={() =>+ void action.run(+ () => update({ yoloUnisolatedCommands: false }),+ () => "permissions.yoloWindowsWithdrawFailed",+ )+ }>- {t("common.cancel")}+ {t("permissions.yoloWindowsWithdraw")}</Button>- <Button- className={layoutStyles.small}- disabled={disabled}- onClick={() => {- setConfirming(false);- void update({ yoloUnisolatedCommands: true });- }}- >- {t("permissions.yoloUnisolatedEnable")}- </Button>- </div>- )}+ )}+ </SettingsRow>+ {action.error && <SettingsLine tone="danger">{t(action.error)}</SettingsLine>}</>);}diff --git a/packages/brain/src/core/yolo.ts b/packages/brain/src/core/yolo.tsindex 4bb91d0..aa19d5f 100644--- a/packages/brain/src/core/yolo.ts+++ b/packages/brain/src/core/yolo.ts@@ -1,3 +1,4 @@+// Own conversation YOLO, Windows consent, and the release of waiting approvals.import type { LocalToolCall } from "@pibot/agent";import { type PolicyResult, YOLO_REASON } from "@pibot/policy";import { type ConversationYolo, RpcError, RpcErrorCodes } from "@pibot/protocol-base";@@ -6,6 +7,7 @@ import {ConversationsRepo,ConversationYoloRepo,GroupsRepo,+ SettingsRepo,transaction,} from "@pibot/storage";import { ZodError } from "zod";@@ -76,48 +78,110 @@ export class YoloService {return { ...this.state(conversationId), isolation: await this.isolation(conversationId) };}- async set(conversationId: string, enabled: boolean): Promise<ConversationYolo> {+ set(conversationId: string, enabled: boolean): Promise<ConversationYolo> {+ return this.change(conversationId, enabled);+ }++ async enableOnWindows(+ conversationId: string,+ acknowledged: boolean,+ signal: AbortSignal,+ ): Promise<ConversationYolo> {+ this.requireWindows();+ signal.throwIfAborted();+ return this.change(conversationId, true, { acknowledged });+ }++ revokeWindowsConsent() {+ this.requireWindows();+ const { db, peer } = this.local.deps;+ const settings = new SettingsRepo(db);+ const current = settings.get();+ if (current.yoloUnisolatedCommands !== true) return current;+ const value = transaction(db, () => this.writeWindowsConsent(settings, false));+ peer.emit("settings.changed", value);+ return value;+ }++ private requireWindows() {+ if (this.local.deps.platform !== "win32")+ throw new RpcError(RpcErrorCodes.unsupported, "windows_yolo_unavailable");+ }++ private writeWindowsConsent(settings: SettingsRepo, consented: boolean) {+ const botId = new BotsRepo(this.local.deps.db).getMain()?.id;+ if (!botId) throw new RpcError(RpcErrorCodes.internal, "main_bot_unavailable");+ const audit = this.local.approvals.audit.append({+ botId,+ kind: "yolo.changed",+ summary: consented ? "YOLO unisolated commands on" : "YOLO unisolated commands off",+ detail: {+ actor: "user",+ reasonCode: consented ? "yolo_unisolated_commands_on" : "yolo_unisolated_commands_off",+ },+ });+ return settings.set({+ yoloUnisolatedCommands: consented,+ yoloUnisolatedCommandsAt: consented ? audit.at : null,+ });+ }++ private async change(+ conversationId: string,+ enabled: boolean,+ windows?: { acknowledged: boolean },+ ): Promise<ConversationYolo> {const before = this.state(conversationId);const conversation = this.repo.switchable(conversationId);- if (!conversation) throw new RpcError(-32602, "yolo_unavailable");- const state =- before.enabled === enabled- ? before- : transaction(this.local.deps.db, () => {- const value = this.repo.set(conversationId, enabled);+ if (!conversation) throw new RpcError(RpcErrorCodes.invalidParams, "yolo_unavailable");+ const { db, peer } = this.local.deps;+ const settings = new SettingsRepo(db);+ const needsConsent = windows !== undefined && settings.get().yoloUnisolatedCommands !== true;+ if (needsConsent && !windows?.acknowledged)+ throw new RpcError(RpcErrorCodes.invalidParams, "windows_yolo_consent_required");+ const committed =+ needsConsent || before.enabled !== enabled+ ? transaction(db, () => {+ const updatedSettings = needsConsent+ ? this.writeWindowsConsent(settings, true)+ : undefined;+ if (before.enabled === enabled) return { state: before, updatedSettings };+ const state = this.repo.set(conversationId, enabled);this.audit(conversation, enabled);- return value;- });- if (state !== before) this.local.deps.peer.emit("conversations.yolo.changed", state);- // Recommended: cards already waiting in this conversation go through as allowed.- if (enabled) {- await this.releasePending(conversation.id, conversation.groupId ?? undefined);- for (const listener of [...(this.listeners.get(conversation.id) ?? [])]) listener();- for (const entry of [...this.runListeners.values()]) {- try {- const source = entry.context.executionTaskId- ? this.local.taskAuthority.source(entry.context)- : entry.context;- if (source.conversationId !== conversation.id || !runYolo(this.local, entry.context))- continue;- const actions = [...entry.actions];- entry.actions.clear();- for (const action of actions) {- try {- await action();- } catch {- // Each card is independent; one stale proposal must not strand other live waiters.- this.local.deps.logger.warn(- "YOLO pending business confirmation could not be applied",- );- }+ return { state, updatedSettings };+ })+ : { state: before, updatedSettings: undefined };+ const { state, updatedSettings } = committed;+ if (updatedSettings) peer.emit("settings.changed", updatedSettings);+ if (state !== before) peer.emit("conversations.yolo.changed", state);+ if (enabled) await this.releaseOnEnable(conversation.id, conversation.groupId ?? undefined);+ return { ...state, isolation: await this.isolation(conversationId) };+ }++ private async releaseOnEnable(conversationId: string, groupId?: string) {+ await this.releasePending(conversationId, groupId);+ for (const listener of [...(this.listeners.get(conversationId) ?? [])]) listener();+ for (const entry of [...this.runListeners.values()]) {+ try {+ const source = entry.context.executionTaskId+ ? this.local.taskAuthority.source(entry.context)+ : entry.context;+ if (source.conversationId !== conversationId || !runYolo(this.local, entry.context))+ continue;+ const actions = [...entry.actions];+ entry.actions.clear();+ for (const action of actions) {+ try {+ await action();+ } catch {+ // Each card is independent; one stale proposal must not strand other live waiters.+ this.local.deps.logger.warn("YOLO pending business confirmation could not be applied");}- } catch {- this.local.deps.logger.warn("YOLO pending business confirmation could not be applied");}+ } catch {+ this.local.deps.logger.warn("YOLO pending business confirmation could not be applied");}}- return { ...state, isolation: await this.isolation(conversationId) };}/** Only live run waiters subscribe; their abort/settlement always removes the listener. */diff --git a/packages/brain/src/runtime/startup/register-app-rpc.ts b/packages/brain/src/runtime/startup/register-app-rpc.tsindex c172104..f5832f0 100644--- a/packages/brain/src/runtime/startup/register-app-rpc.ts+++ b/packages/brain/src/runtime/startup/register-app-rpc.ts@@ -1,3 +1,4 @@+// Register application settings and other shared brain RPCs at startup.import { readFile as readDependencyManifest } from "node:fs/promises";import { PI_VERSION } from "@pibot/agent";import {@@ -130,7 +131,16 @@ export function registerAppRpc(ctx: StartupContext) {);ctx.handle("network.test", async () => ctx.network.test(ctx.providerTests.signal));ctx.handle("settings.get", async () => ctx.settings.get());- ctx.handle("settings.set", async (patch) => {+ ctx.handle("settings.set", async (patch, { signal }) => {+ if (patch.yoloUnisolatedCommandsAt !== undefined || patch.yoloUnisolatedCommands === true)+ throw new RpcError(RpcErrorCodes.invalidParams, "windows_yolo_consent_required");+ if (patch.yoloUnisolatedCommands === false) {+ // Keep the original withdrawal request. Its settings write and audit must commit together.+ if (Object.keys(patch).length !== 1)+ throw new RpcError(RpcErrorCodes.invalidParams, "windows_yolo_withdrawal_is_separate");+ signal.throwIfAborted();+ return ctx.capabilities.yolo.revokeWindowsConsent();+ }const value = await ctx.models().settings.setSettings(@@ -140,19 +150,6 @@ export function registerAppRpc(ctx: StartupContext) {ctx.peer.emit("settings.changed", value.settings);if (patch.backgroundCommandLimitMinutes !== undefined)ctx.capabilities.background.refreshLimits();- // Turning command auto-approval without isolation on or off is a security decision (rule 6).- if (patch.yoloUnisolatedCommands !== undefined)- ctx.audit.append({- botId: ctx.bots.getMain()?.id ?? "",- kind: "yolo.changed",- summary: `YOLO unisolated commands ${patch.yoloUnisolatedCommands ? "on" : "off"}`,- detail: {- actor: "user",- reasonCode: patch.yoloUnisolatedCommands- ? "yolo_unisolated_commands_on"- : "yolo_unisolated_commands_off",- },- });// Whether and which commands may leave the sandbox is a security decision too.if (patch.strictSandbox !== undefined)ctx.audit.append({diff --git a/packages/brain/src/runtime/tools/local-rpc.ts b/packages/brain/src/runtime/tools/local-rpc.tsindex c0573eb..81de51f 100644--- a/packages/brain/src/runtime/tools/local-rpc.ts+++ b/packages/brain/src/runtime/tools/local-rpc.ts@@ -1,3 +1,4 @@+// Expose local operations through the validated brain RPC dispatcher.import { join } from "node:path";import { discoverCommandPaths, listHostSshAliases } from "@pibot/execution";import { RpcError } from "@pibot/protocol-base";@@ -91,6 +92,9 @@ export function registerLocalRpc(handle: KernelRegisterRpc, local: LocalService)local.openLog(runId, toolCallId, signal),);handle("conversations.yolo.get", ({ conversationId }) => local.yolo.get(conversationId));+ handle("conversations.yolo.enableOnWindows", ({ conversationId, acknowledged }, { signal }) =>+ local.yolo.enableOnWindows(conversationId, acknowledged === true, signal),+ );handle("conversations.yolo.set", ({ conversationId, enabled }) =>local.yolo.set(conversationId, enabled),);diff --git a/packages/i18n/src/sections/permissions.ts b/packages/i18n/src/sections/permissions.tsindex 6134e84..6991cb8 100644--- a/packages/i18n/src/sections/permissions.ts+++ b/packages/i18n/src/sections/permissions.ts@@ -1,3 +1,4 @@+// Translate permission settings, approvals, and policy warnings.import { linuxIsolationRemedies } from "@pibot/execution/isolation-remedy";export const permissionsZh = {@@ -100,12 +101,14 @@ export const permissionsZh = {"permissions.topicGrantScope": "话题 {topic} · 当前可写根:{roots}(随话题变更)","permissions.topicGrantUnavailable": "工作范围不可用,执行前重新校验","permissions.topicGrantNoRoots": "无可写根",- "permissions.yoloUnisolated": "YOLO 自动批准命令(无隔离)",- "permissions.yoloUnisolatedNote":- "Windows 上的命令没有系统隔离。关闭时,即使开了 YOLO,每条命令仍要你确认。",- "permissions.yoloUnisolatedConfirm":- "开了 YOLO 的对话会自动运行命令。这些命令能读写你的所有文件、访问网络,没有任何隔离。",- "permissions.yoloUnisolatedEnable": "确认开启",+ "permissions.yoloUnisolated": "Windows 上 YOLO 自动运行命令",+ "permissions.yoloWindowsConsentedAt":+ "已同意({date})。开了 YOLO 的对话里普通命令直接运行,危险命令仍需确认。撤回后下次开启 YOLO 会再次说明。",+ "permissions.yoloWindowsConsented":+ "已同意。开了 YOLO 的对话里普通命令直接运行,危险命令仍需确认。撤回后下次开启 YOLO 会再次说明。",+ "permissions.yoloWindowsNotConsented": "尚未同意。开启 YOLO 时可以确认。",+ "permissions.yoloWindowsWithdraw": "撤回",+ "permissions.yoloWindowsWithdrawFailed": "未能撤回同意,请重试。","permissions.strictSandbox": "严格沙箱","permissions.strictSandboxNote":"打开后,命令被沙箱拦截时只说明原因,不提供「在沙箱外运行一次」,下面的清单也不生效。",@@ -118,7 +121,10 @@ export const permissionsZh = {"permissions.sandboxOutsideCommandsInvalid":"格式不对:每行一条,程序名加参数,* 只能放在最后,最多 32 条。","permissions.unisolated": "未隔离",- "permissions.note.run_command.windows": "每条命令都要你确认后才运行",+ "permissions.note.run_command.windows":+ "Windows 没有命令沙箱。受支持的只读命令(如 dir、type)经权限检查后直接运行。",+ "permissions.info.run_command.windows":+ "设为「不允许」时命令不会运行。经权限检查的受支持只读命令可直接运行。普通命令逐次确认,除非这个对话开了 YOLO 且你同意无隔离执行。","permissions.windowsAlwaysUnavailable":"Windows 命令没有系统隔离,不能设为总是允许;YOLO 自动批准需单独开启","permissions.connectionsAndSending": "连接与发送",@@ -579,12 +585,14 @@ export const permissionsEn: { [K in keyof typeof permissionsZh]: string } = {"Topic {topic} · Current writable roots: {roots} (follows topic changes)","permissions.topicGrantUnavailable": "Working folders unavailable; rechecked before execution","permissions.topicGrantNoRoots": "No writable roots",- "permissions.yoloUnisolated": "YOLO auto-approves commands (no isolation)",- "permissions.yoloUnisolatedNote":- "Commands on Windows run without system isolation. While this is off, every command still needs your confirmation, even with YOLO on.",- "permissions.yoloUnisolatedConfirm":- "Conversations with YOLO on will run commands automatically. These commands can read and write all your files and access the network, without any isolation.",- "permissions.yoloUnisolatedEnable": "Turn on",+ "permissions.yoloUnisolated": "YOLO runs commands automatically on Windows",+ "permissions.yoloWindowsConsentedAt":+ "Consented on {date}. Ordinary commands run directly in conversations with YOLO on. Dangerous commands still ask. Withdraw to see the explanation next time you turn on YOLO.",+ "permissions.yoloWindowsConsented":+ "Consented. Ordinary commands run directly in conversations with YOLO on. Dangerous commands still ask. Withdraw to see the explanation next time you turn on YOLO.",+ "permissions.yoloWindowsNotConsented": "Consent not given. You can confirm when turning on YOLO.",+ "permissions.yoloWindowsWithdraw": "Withdraw",+ "permissions.yoloWindowsWithdrawFailed": "Couldn't withdraw consent. Try again.","permissions.strictSandbox": "Strict sandbox","permissions.strictSandboxNote":"When on, a command the sandbox blocks only explains why; running it once outside the sandbox is not offered, and the list below is ignored.",@@ -597,7 +605,10 @@ export const permissionsEn: { [K in keyof typeof permissionsZh]: string } = {"permissions.sandboxOutsideCommandsInvalid":"Invalid entry: one per line, a program and its arguments, * only at the end, at most 32 entries.","permissions.unisolated": "Unisolated",- "permissions.note.run_command.windows": "Every command runs only after your confirmation",+ "permissions.note.run_command.windows":+ "Windows has no command sandbox. Supported read-only commands, such as dir and type, run directly when permissions allow.",+ "permissions.info.run_command.windows":+ "Don't allow blocks commands. Supported read-only commands run directly when permissions allow. Ordinary commands ask each time unless YOLO is on in the conversation and you consented to unisolated execution.","permissions.windowsAlwaysUnavailable":"Windows commands have no system isolation and cannot be set to Always; YOLO auto-approval must be enabled separately","permissions.connectionsAndSending": "Connections and sending",diff --git a/packages/i18n/src/sections/yolo.ts b/packages/i18n/src/sections/yolo.tsindex bbc1490..df5e154 100644--- a/packages/i18n/src/sections/yolo.ts+++ b/packages/i18n/src/sections/yolo.ts@@ -25,11 +25,20 @@ export const yoloZh = {"命令隔离当前不可用({reason})。YOLO 不提供隔离保护;命令是否能执行仍按执行设备的确认和权限规则判定。","yolo.unisolatedUnknown": "原因未知","yolo.skipsList.windows":- "读写工作位置内的文件、访问网站和提交表单、搜索服务的首次询问、操作电脑、对外发送、用唯一已保存账号登录。运行命令是否自动批准取决于「YOLO 自动批准命令(无隔离)」;危险命令仍要逐次确认,提权命令始终拒绝。",- "yolo.unisolatedEnabled":- "Windows 命令没有系统隔离。「YOLO 自动批准命令(无隔离)」已开启:普通命令会以你的身份自动运行,可读写你的文件、访问网络;危险命令仍需确认。",- "yolo.unisolatedDisabled":- "Windows 命令没有系统隔离。「YOLO 自动批准命令(无隔离)」尚未开启:即使这个对话开了 YOLO,每条命令仍要你确认。",+ "普通命令、读写工作位置内的文件、访问网站和提交表单、搜索服务的首次询问、操作电脑、允许自动批准的对外发送、用唯一已保存账号登录。正在等待的审批会重新检查。",+ "yolo.keepsList.windows":+ "危险命令(如删除磁盘根目录或系统文件夹)、网络共享路径、规则判定无法安全分析的命令、写入受保护位置(如 .git、Pi Bot 数据和凭据目录)仍需逐次确认。提权命令(如 runas)始终拒绝。付费生成图片、设为「不允许」的权限和不能操作的应用仍遵循原有规则。",+ "yolo.readOnly.windows":+ "通过读取权限检查的受支持只读命令(如 dir、Get-ChildItem、type)无需开启 YOLO。",+ "yolo.windowsDisclosureTitle": "Windows 没有命令沙箱。",+ "yolo.windowsDisclosure":+ "开启 YOLO 后,普通 Windows 命令会以你的身份直接运行,可以读写你能访问的文件和访问网络。危险命令仍需确认。",+ "yolo.windowsAcknowledge":+ "我知道 Windows 上的命令会直接运行。以后开启 YOLO 时只显示简短提醒,我可以在设置 › 权限撤回同意。",+ "yolo.windowsReminder": "普通 Windows 命令会以你的身份直接运行,危险命令仍需确认。",+ "yolo.windowsConsentSettings": "前往权限设置撤回",+ "yolo.nothingRemembered.windows":+ "关闭 YOLO 后恢复正常询问,开启期间不会留下「一直允许」。每个自动允许的操作都会写进操作记录。","yolo.keepsSafetyUnisolated":"命令没有系统隔离保护。操作电脑时顶部提示、前台锁、移动鼠标暂停和全局停止快捷键都还在。","yolo.audit.unisolatedOn": "开启了全局 YOLO 无隔离命令自动批准",@@ -70,11 +79,21 @@ export const yoloEn = {"Command isolation is unavailable ({reason}). YOLO provides no isolation; commands remain subject to the execution device’s confirmation and permission rules.","yolo.unisolatedUnknown": "reason unknown","yolo.skipsList.windows":- "Reading and writing files in working folders, visiting sites and submitting forms, first-use search prompts, operating the computer, sending things out, and logging in with a single saved account. Command auto-approval depends on “YOLO auto-approves commands (no isolation)”. Dangerous commands still ask each time; privilege escalation is always refused.",- "yolo.unisolatedEnabled":- "Windows commands have no system isolation. “YOLO auto-approves commands (no isolation)” is on: ordinary commands run automatically as you and can read and write your files and access the network. Dangerous commands still need confirmation.",- "yolo.unisolatedDisabled":- "Windows commands have no system isolation. “YOLO auto-approves commands (no isolation)” is off: every command still needs your confirmation, even with YOLO on in this conversation.",+ "Ordinary commands, reading and writing files in working folders, visiting sites and submitting forms, first-use search prompts, operating the computer, eligible outgoing actions, and signing in with a single saved account. Pending approvals are checked again.",+ "yolo.keepsList.windows":+ "Dangerous commands (such as deleting a drive root or system folder), network share paths, commands the policy flags as unparseable, and writes to protected locations (such as .git, Pi Bot data, and credential folders) still ask each time. Elevation (such as runas) is always refused. Paid images, permissions set to Don't allow, and blocked apps still follow their existing rules.",+ "yolo.readOnly.windows":+ "Supported read-only commands (such as dir, Get-ChildItem, and type) can run with YOLO off when their read permissions allow it.",+ "yolo.windowsDisclosureTitle": "Windows has no command sandbox.",+ "yolo.windowsDisclosure":+ "With YOLO on, ordinary Windows commands run directly as you. They can read and write files you can access and use the network. Dangerous commands still ask.",+ "yolo.windowsAcknowledge":+ "I understand that Windows commands run directly. Next time I turn on YOLO, I’ll see a short reminder. I can withdraw consent in Settings › Permissions.",+ "yolo.windowsReminder":+ "Ordinary Windows commands run directly as you. Dangerous commands still ask.",+ "yolo.windowsConsentSettings": "Withdraw in Permissions",+ "yolo.nothingRemembered.windows":+ "Turning off YOLO restores normal prompts. YOLO leaves no Always allow grants. Every automatically allowed action is logged.","yolo.keepsSafetyUnisolated":"Commands have no system isolation. When operating the computer, the top indicator, foreground lock, pause on mouse movement and global stop shortcut remain in place.","yolo.audit.unisolatedOn": "Turned on global YOLO auto-approval for unisolated commands",diff --git a/packages/protocol-base/src/app/settings.ts b/packages/protocol-base/src/app/settings.tsindex c0b7682..cf1323f 100644--- a/packages/protocol-base/src/app/settings.ts+++ b/packages/protocol-base/src/app/settings.ts@@ -1,3 +1,4 @@+// Share persisted settings and desktop bootstrap contracts across processes.import { z } from "zod";import { AvatarImageSchema } from "../bots/app-profile.ts";import { IdSchema } from "../core/ids.ts";@@ -49,11 +50,12 @@ export const SettingsSchema = z.strictObject({/** Prefer the user's connected browser over the isolated Bot browser. */browserExtensionPreference: z.enum(["user", "bot"]).optional(),/**- * Windows only: commands there have no sandbox, so YOLO auto-approves them- * only after the user explicitly turns this on. Ignored on other platforms, which never run- * commands unisolated.+ * Consent to YOLO auto-approval of eligible Windows commands, which run without isolation.+ * Both the active conversation's YOLO and this consent are required.*/yoloUnisolatedCommands: z.boolean().optional(),+ /** Recorded by the Windows consent flow; legacy consent has no reliable timestamp. */+ yoloUnisolatedCommandsAt: z.iso.datetime().nullable().optional(),/*** When on, a command the sandbox blocked is never offered a run outside it; the* user only sees why it was blocked. macOS / Linux only.diff --git a/packages/protocol-base/src/permissions/yolo.ts b/packages/protocol-base/src/permissions/yolo.tsindex 9e909c8..3689b8d 100644--- a/packages/protocol-base/src/permissions/yolo.ts+++ b/packages/protocol-base/src/permissions/yolo.ts@@ -1,3 +1,4 @@+// Share YOLO requests, results, and events between the brain and its clients.import { z } from "zod";import { IdSchema } from "../core/ids.ts";import { RiskSchema } from "./approvals.ts";@@ -24,7 +25,12 @@ export const YoloStepSchema = z.strictObject({ risk: RiskSchema });const conversationId = z.strictObject({ conversationId: IdSchema });export const YoloMethods = {"conversations.yolo.get": { params: conversationId, result: ConversationYoloSchema },- /** Turning it on also lets pending cards of that conversation through. */+ // This desktop-only confirmation can persist the device-wide Windows consent.+ "conversations.yolo.enableOnWindows": {+ params: conversationId.extend({ acknowledged: z.literal(true).optional() }),+ result: ConversationYoloSchema,+ },+ /** Turning it on also lets eligible pending cards of that conversation through. */"conversations.yolo.set": {params: conversationId.extend({ enabled: z.boolean() }),result: ConversationYoloSchema,diff --git a/packages/protocol/test/schemas.test.ts b/packages/protocol/test/schemas.test.tsindex 929a21d..321fe79 100644--- a/packages/protocol/test/schemas.test.ts+++ b/packages/protocol/test/schemas.test.ts@@ -1,3 +1,4 @@+// Keep the published RPC schemas covered by the existing contract fixtures.import { DEFAULT_EXECUTION_LIMITS } from "@pibot/protocol-base";import { describe, expect, it } from "vitest";import type { z } from "zod";@@ -2990,6 +2991,12 @@ const methodCases = {updatedAt: date,},},+ "conversations.yolo.enableOnWindows": {+ params: { conversationId: id, acknowledged: true },+ result: { conversationId: id, enabled: true, enabledAt: date, isolation: { available: false } },+ badParams: { conversationId: id, acknowledged: false },+ badResult: { conversationId: id, enabled: true, enabledAt: date },+ },"conversations.yolo.set": {params: { conversationId: id, enabled: true },result: { conversationId: id, enabled: true, enabledAt: date, isolation: { available: false } },diff --git a/packages/storage/src/workspace/repositories.ts b/packages/storage/src/workspace/repositories.tsindex 1a61f51..3e23ae8 100644--- a/packages/storage/src/workspace/repositories.ts+++ b/packages/storage/src/workspace/repositories.ts@@ -1,3 +1,4 @@+// Persist application settings and shared workspace records in SQLite.import { randomUUID } from "node:crypto";import type { DatabaseSync } from "node:sqlite";import {@@ -44,7 +45,12 @@ export const DEFAULT_SETTINGS: Readonly<Settings> = Object.freeze({sandboxAutoSystemServices: [],});/** Optional keys without a default: read back only once written. */-const OPTIONAL_KEYS = ["userAvatar", "personalTodoView", "personalTodoStatuses"] as const;+const OPTIONAL_KEYS = [+ "userAvatar",+ "personalTodoView",+ "personalTodoStatuses",+ "yoloUnisolatedCommandsAt",+] as const;export class SettingsRepo {constructor(private readonly db: DatabaseSync) {}