Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(pi): address integration self-review

Chrisd387ae83afbd
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/errandPrefsStore.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/errandPrefsStore.test.ts
index a5c9107a66..8669548da2 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/errandPrefsStore.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/errandPrefsStore.test.ts
@@ -57,6 +57,10 @@ describe('normalizeConfig(单插件配置清洗)', () => {
expect(__testing.normalizeConfig({ permissionMode: 'ask' })).toEqual({});
});
+ it('Pi 是合法的代办 agent', () => {
+ expect(__testing.normalizeConfig({ agentKind: 'pi' })).toEqual({ agentKind: 'pi' });
+ });
+
it('非对象入参 → 空配置', () => {
expect(__testing.normalizeConfig(null)).toEqual({});
expect(__testing.normalizeConfig('x')).toEqual({});
diff --git a/apps/desktop/src/main/cindy-brain/errandPrefsStore.ts b/apps/desktop/src/main/cindy-brain/errandPrefsStore.ts
index 62474dba56..9c479fa335 100644
--- a/apps/desktop/src/main/cindy-brain/errandPrefsStore.ts
+++ b/apps/desktop/src/main/cindy-brain/errandPrefsStore.ts
@@ -26,7 +26,7 @@ import { ownerScopedUserDataPath } from '../appSessionState.js';
const log = desktopMakerLogger.child('errand-prefs-store');
/** errand 会话可选的 agent 种类(与 sessions.agent_kind 同词汇表)。 */
-export const GHOST_ERRAND_AGENT_KINDS = ['cc', 'codex'] as const;
+export const GHOST_ERRAND_AGENT_KINDS = ['cc', 'codex', 'pi'] as const;
export type GhostErrandAgentKind = (typeof GHOST_ERRAND_AGENT_KINDS)[number];
/** errand 会话可选的思考强度(与 worker 同集合;minimal 刻意不收)。 */
diff --git a/apps/desktop/src/main/im/shared/sessionRepo.ts b/apps/desktop/src/main/im/shared/sessionRepo.ts
index f642be6386..6d27b4e636 100644
--- a/apps/desktop/src/main/im/shared/sessionRepo.ts
+++ b/apps/desktop/src/main/im/shared/sessionRepo.ts
@@ -32,7 +32,7 @@ import type { ImOrchestratorConfig, ImSessionNamespace } from './types';
const log = createLogger('im:repo');
export function toCoreAgentKind(kind: string): AgentKind {
- return kind === 'codex' ? 'codex' : 'claude-code';
+ return kind === 'codex' || kind === 'pi' ? kind : 'claude-code';
}
/** core AgentKind → sessions.agentKind 列的 legacy 存储值。 */
diff --git a/apps/desktop/src/main/learn-host/__tests__/profile.test.ts b/apps/desktop/src/main/learn-host/__tests__/profile.test.ts
index d0da4422d0..6fd16554d4 100644
--- a/apps/desktop/src/main/learn-host/__tests__/profile.test.ts
+++ b/apps/desktop/src/main/learn-host/__tests__/profile.test.ts
@@ -13,7 +13,7 @@ vi.mock('../../logger', () => ({
createLogger: () => ({ debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() }),
}));
vi.mock('../../maker-host/memory-settings-store', () => ({
- readMemorySettings: vi.fn(() => ({ maker: true, claudeCode: true, codex: true })),
+ readMemorySettings: vi.fn(() => ({ maker: true, claudeCode: true, codex: true, pi: true })),
}));
import {
@@ -36,7 +36,7 @@ const shard = (over: Partial<ProfileShard> = {}): ProfileShard => ({
beforeEach(async () => {
await fs.promises.rm(TEST_ROOT, { recursive: true, force: true });
- vi.mocked(readMemorySettings).mockReturnValue({ maker: true, claudeCode: true, codex: true });
+ vi.mocked(readMemorySettings).mockReturnValue({ maker: true, claudeCode: true, codex: true, pi: true });
});
describe('formatProfileBlock', () => {
@@ -77,7 +77,7 @@ describe('formatProfileBlock', () => {
describe('collectUserProfile', () => {
it('returns empty when Maker Memory is disabled', async () => {
- vi.mocked(readMemorySettings).mockReturnValue({ maker: false, claudeCode: true, codex: true });
+ vi.mocked(readMemorySettings).mockReturnValue({ maker: false, claudeCode: true, codex: true, pi: true });
const profile = await collectUserProfile(null);
diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionAutoTitlePersist.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionAutoTitlePersist.test.ts
index a8e3cc0ad9..1e1b9688e2 100644
--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionAutoTitlePersist.test.ts
+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionAutoTitlePersist.test.ts
@@ -256,6 +256,9 @@ describe('getOverwritableAutoTitle — 覆写目标', () => {
h.sqlite!.prepare('UPDATE sessions SET agent_kind = ? WHERE id = ?').run('codex', SESSION_ID);
expect((await getOverwritableAutoTitle(SESSION_ID))?.agentKind).toBe('codex');
+
+ h.sqlite!.prepare('UPDATE sessions SET agent_kind = ? WHERE id = ?').run('pi', SESSION_ID);
+ expect((await getOverwritableAutoTitle(SESSION_ID))?.agentKind).toBe('pi');
});
it('用它当期望值就能覆写 fork 占位(端到端条件写)', async () => {
diff --git a/apps/desktop/src/main/localDb/ipc/pluginWorkspaceSessions.ts b/apps/desktop/src/main/localDb/ipc/pluginWorkspaceSessions.ts
index 68b1aa0b37..b9a61c8c9f 100644
--- a/apps/desktop/src/main/localDb/ipc/pluginWorkspaceSessions.ts
+++ b/apps/desktop/src/main/localDb/ipc/pluginWorkspaceSessions.ts
@@ -161,7 +161,7 @@ export async function createPluginDraftSession(params: {
export async function createGhostErrandSession(params: {
ghostId: string;
title: string | null;
- agentKind?: 'cc' | 'codex';
+ agentKind?: 'cc' | 'codex' | 'pi';
model?: string;
effort?: string;
fastMode?: boolean;
diff --git a/apps/desktop/src/main/localDb/ipc/sessions.ts b/apps/desktop/src/main/localDb/ipc/sessions.ts
index c8cd7e73b3..5cb5673d20 100644
--- a/apps/desktop/src/main/localDb/ipc/sessions.ts
+++ b/apps/desktop/src/main/localDb/ipc/sessions.ts
@@ -580,7 +580,7 @@ export interface OverwritableAutoTitleTarget {
* `reconcileCreateOptsAgainstDb` 处理的正是同一类漂移),用错 agent 会让标题
* 走错供应商 —— 纯 Codex / 纯 Claude 用户会因此只拿到 fallback 标题。
*/
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
/**
* 是否仍停在建会话时的裸默认标题。合成占位(纯附件消息)只允许覆写这一种 ——
* fork 占位与上一条附件写下的合成占位都要保留到用户真正打字为止。
@@ -595,7 +595,7 @@ export async function getOverwritableAutoTitle(
const db = getDbClient().drizzle;
const row = await selectSessionWithCount(db, id);
if (!row) return null;
- const agentKind = row.agentKind === 'codex' ? 'codex' : 'claude-code';
+ const agentKind = row.agentKind === 'codex' || row.agentKind === 'pi' ? row.agentKind : 'claude-code';
const overwritable =
row.title === DEFAULT_DRAFT_SESSION_TITLE ||
(!!row.parentSessionId && row.title.startsWith(FORK_PLACEHOLDER_TITLE_PREFIX)) ||
diff --git a/apps/desktop/src/main/maker-host/__tests__/memorySettingsStore.test.ts b/apps/desktop/src/main/maker-host/__tests__/memorySettingsStore.test.ts
index 383df38abd..2fdd6802f0 100644
--- a/apps/desktop/src/main/maker-host/__tests__/memorySettingsStore.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/memorySettingsStore.test.ts
@@ -28,7 +28,7 @@ describe('memory-settings-store', () => {
const { preserveLegacyMakerMemoryDisabled, readMemorySettings, readMemorySettingsState } =
await import('../memory-settings-store.js');
- expect(readMemorySettings()).toEqual({ maker: true, claudeCode: true, codex: true });
+ expect(readMemorySettings()).toEqual({ maker: true, claudeCode: true, codex: true, pi: true });
expect(preserveLegacyMakerMemoryDisabled(null).maker).toBe(true);
expect(readMemorySettingsState().customizedKeys).toEqual([]);
});
@@ -40,7 +40,7 @@ describe('memory-settings-store', () => {
expect(preserveLegacyMakerMemoryDisabled(false).maker).toBe(false);
expect(readMemorySettingsState()).toMatchObject({
- value: { maker: false, claudeCode: true, codex: true },
+ value: { maker: false, claudeCode: true, codex: true, pi: true },
customizedKeys: ['maker'],
});
});
@@ -68,7 +68,7 @@ describe('memory-settings-store', () => {
expect(preserveLegacyMakerMemoryDisabled(null).maker).toBe(true);
expect(readMemorySettingsState()).toMatchObject({
- value: { maker: true, claudeCode: false, codex: false },
+ value: { maker: true, claudeCode: false, codex: false, pi: true },
customizedKeys: ['claudeCode', 'codex'],
});
});
@@ -85,7 +85,7 @@ describe('memory-settings-store', () => {
expect(preserveLegacyMakerMemoryDisabled(null).maker).toBe(true);
expect(readMemorySettingsState()).toMatchObject({
- value: { maker: true, claudeCode: false, codex: true },
+ value: { maker: true, claudeCode: false, codex: true, pi: true },
customizedKeys: ['claudeCode'],
});
});
@@ -111,7 +111,7 @@ describe('memory-settings-store', () => {
expect(preserveLegacyMakerMemoryDisabled(true).maker).toBe(true);
expect(readMemorySettingsState()).toMatchObject({
- value: { maker: true, claudeCode: true, codex: true },
+ value: { maker: true, claudeCode: true, codex: true, pi: true },
customizedKeys: ['maker'],
});
expect(JSON.parse(fs.readFileSync(path.join(userDataDir, 'memory-settings.json'), 'utf8'))).toEqual({
@@ -131,4 +131,12 @@ describe('memory-settings-store', () => {
expect(restored.customizedKeys).toEqual([]);
expect(fs.existsSync(path.join(userDataDir, 'memory-settings.json'))).toBe(false);
});
+
+ it('persists the Pi auto-memory override independently', async () => {
+ const { readMemorySettings, writeMemorySetting } = await import('../memory-settings-store.js');
+ expect(writeMemorySetting('pi', false).value.pi).toBe(false);
+ expect(readMemorySettings().pi).toBe(false);
+ expect(JSON.parse(fs.readFileSync(path.join(userDataDir, 'memory-settings.json'), 'utf8')))
+ .toEqual({ pi: false });
+ });
});
diff --git a/apps/desktop/src/main/maker-host/__tests__/runtimeConfigs.test.ts b/apps/desktop/src/main/maker-host/__tests__/runtimeConfigs.test.ts
index c85f64b395..37bae6407a 100644
--- a/apps/desktop/src/main/maker-host/__tests__/runtimeConfigs.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/runtimeConfigs.test.ts
@@ -4,6 +4,7 @@ let memorySettings = {
maker: true,
claudeCode: false,
codex: false,
+ pi: false,
};
vi.mock('electron', () => ({
@@ -45,6 +46,7 @@ describe('runtime-configs', () => {
maker: true,
claudeCode: false,
codex: false,
+ pi: false,
};
});
@@ -66,6 +68,7 @@ describe('runtime-configs', () => {
maker: false,
claudeCode: true,
codex: true,
+ pi: true,
};
expect(claudeConfig.memoryEnabled).toBe(true);
diff --git a/apps/desktop/src/main/maker-host/memory-settings-store.ts b/apps/desktop/src/main/maker-host/memory-settings-store.ts
index b1bdc9dab6..849ba07a6e 100644
--- a/apps/desktop/src/main/maker-host/memory-settings-store.ts
+++ b/apps/desktop/src/main/maker-host/memory-settings-store.ts
@@ -1,5 +1,5 @@
/**
- * memory-settings-store —— 三个 memory 开关的 main 端持久化 source of truth。
+ * memory-settings-store —— memory 开关的 main 端持久化 source of truth。
*
* 背景:
* - Codex 的 enable 走 app-server in-memory enablement (重启即失效)
@@ -8,7 +8,7 @@
* 三者都不持久化, 重启后用户上次设置丢失 → 这里收口落 JSON。
*
* 文件: <userData>/memory-settings.json
- * { "maker": true, "claudeCode": true, "codex": true }
+ * { "maker": true, "claudeCode": true, "codex": true, "pi": true }
*
* 默认值跟原 runtime-configs.ts / maker-memory-host.ts 的硬编码对齐:
* - maker : true (默认开启,用户可以关闭)
@@ -35,12 +35,14 @@ export interface MemorySettings {
maker: boolean;
claudeCode: boolean;
codex: boolean;
+ pi: boolean;
}
const DEFAULTS: MemorySettings = {
maker: true,
claudeCode: true,
codex: true,
+ pi: true,
};
function settingsFilePath(rootPath?: string): string {
@@ -54,6 +56,7 @@ function normalize(raw: unknown): MemorySettings {
maker: typeof r.maker === 'boolean' ? r.maker : DEFAULTS.maker,
claudeCode: typeof r.claudeCode === 'boolean' ? r.claudeCode : DEFAULTS.claudeCode,
codex: typeof r.codex === 'boolean' ? r.codex : DEFAULTS.codex,
+ pi: typeof r.pi === 'boolean' ? r.pi : DEFAULTS.pi,
};
}
diff --git a/apps/desktop/src/main/maker-host/pi-host.ts b/apps/desktop/src/main/maker-host/pi-host.ts
index 39d8ab21d6..1ac4d47966 100644
--- a/apps/desktop/src/main/maker-host/pi-host.ts
+++ b/apps/desktop/src/main/maker-host/pi-host.ts
@@ -38,6 +38,7 @@ import { hasGrokOAuthLogin } from './grok-oauth-login.js';
import hostSystemPrompt from './host-system-prompt.md?raw';
import piSystemPrompt from './pi-system-prompt.md?raw';
import { createLogger } from '../logger.js';
+import { readMemorySettings } from './memory-settings-store.js';
const log = createLogger('pi-host');
@@ -182,6 +183,16 @@ function buildDesktopPiRuntimeConfig(): AgentRuntimeConfig {
enumerable: true,
configurable: false,
});
+ Object.defineProperties(config, {
+ memoryEnabled: {
+ get: () => readMemorySettings().pi,
+ enumerable: true,
+ },
+ makerMemoryEnabled: {
+ get: () => readMemorySettings().maker,
+ enumerable: true,
+ },
+ });
return config;
}
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/ghostErrandRunner.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/ghostErrandRunner.test.ts
index a21fdb6a03..e53f934f2f 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/ghostErrandRunner.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/ghostErrandRunner.test.ts
@@ -96,6 +96,28 @@ describe('权限档钳制', () => {
});
});
+describe('Pi 代办路由', () => {
+ it('读取 Pi 草稿默认并创建 Pi 会话', async () => {
+ const createSession = vi.fn(async () => 'sess-pi');
+ const getDraftDefaults = vi.fn(() => ({ model: 'gpt-5.5' }));
+ const { deps, emitters } = makeDeps({
+ readConfig: () => ({ agentKind: 'pi' }),
+ createSession,
+ getDraftDefaults,
+ });
+ const runner = createGhostErrandRunner(deps);
+ const pending = runner(REQUEST);
+ await vi.waitFor(() => expect(emitters.has('sess-pi')).toBe(true));
+ emitters.get('sess-pi')!.emit(doneEvent());
+ await pending;
+
+ expect(getDraftDefaults).toHaveBeenCalledWith('pi');
+ expect(createSession).toHaveBeenCalledWith(
+ expect.objectContaining({ agentKind: 'pi', model: 'gpt-5.5' }),
+ );
+ });
+});
+
describe('专属会话建/复用', () => {
it('无映射时创建会话并写映射,onSession 尽早回报', async () => {
const { deps, emitters, writes } = makeDeps();
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/sessionAgentSwitchHandler.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/sessionAgentSwitchHandler.test.ts
index 85ed727a4e..b38bf67293 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/sessionAgentSwitchHandler.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/sessionAgentSwitchHandler.test.ts
@@ -116,6 +116,21 @@ describe('performSessionAgentSwitch', () => {
expect(boundary.toAgentKind).toBe('cc');
});
+ it('claude-code → pi 不会被参数校验拒绝', async () => {
+ const { deps } = makeDeps();
+ const result = await performSessionAgentSwitch(deps, {
+ sessionId: 's1',
+ targetAgentKind: 'pi',
+ model: 'gpt-5.5',
+ applyNow: true,
+ });
+ expect(result).toMatchObject({ switched: true, agentKind: 'pi' });
+ expect(deps.applyAgentSwitchToDb).toHaveBeenCalledWith(
+ 's1',
+ expect.objectContaining({ agentKind: 'pi' }),
+ );
+ });
+
it('跨引擎 DB 提交后立即覆盖旧 provider route', async () => {
const { deps } = makeDeps();
diff --git a/apps/desktop/src/main/maker-ipc/ghostErrandRunner.ts b/apps/desktop/src/main/maker-ipc/ghostErrandRunner.ts
index b5d48b32c7..9bbda36010 100644
--- a/apps/desktop/src/main/maker-ipc/ghostErrandRunner.ts
+++ b/apps/desktop/src/main/maker-ipc/ghostErrandRunner.ts
@@ -58,7 +58,7 @@ export interface GhostErrandRunnerDeps {
createSession(params: {
ghostId: string;
title: string | null;
- agentKind?: 'cc' | 'codex';
+ agentKind?: 'cc' | 'codex' | 'pi';
model?: string;
effort?: string;
fastMode?: boolean;
@@ -69,7 +69,7 @@ export interface GhostErrandRunnerDeps {
/** 该插件的展示名(errand 会话默认标题用)。 */
getGhostName(ghostId: string): string | null;
/** 缺省选型来源:New Maker 草稿偏好快照(与 Orca worker 同源)。 */
- getDraftDefaults(vendor: 'claude-code' | 'codex'): {
+ getDraftDefaults(vendor: 'claude-code' | 'codex' | 'pi'): {
model?: string;
effort?: string;
fastMode?: boolean;
@@ -184,7 +184,7 @@ export function createGhostErrandRunner(deps: GhostErrandRunnerDeps): GhostErran
if (!sessionId) {
// 缺省选型跟随 New Maker 草稿偏好(与 Orca worker / workspace 槽同源);
// 配置项逐字段覆盖。model/effort 缺省最终由 mapper 兜底,这里不硬编码。
- const vendor = cfg.agentKind === 'codex' ? 'codex' : 'claude-code';
+ const vendor = cfg.agentKind === 'codex' ? 'codex' : cfg.agentKind === 'pi' ? 'pi' : 'claude-code';
const draft = deps.getDraftDefaults(vendor);
const ghostName = deps.getGhostName(request.ghostId);
try {
diff --git a/apps/desktop/src/main/maker-ipc/messageDeleteHandler.ts b/apps/desktop/src/main/maker-ipc/messageDeleteHandler.ts
index f56115c98d..412e0eb1e2 100644
--- a/apps/desktop/src/main/maker-ipc/messageDeleteHandler.ts
+++ b/apps/desktop/src/main/maker-ipc/messageDeleteHandler.ts
@@ -64,7 +64,7 @@ export interface MessageDeleteHandlerDeps {
}
function engineLabel(agentKind: string): string {
- return agentKind === 'codex' ? 'Codex' : 'Claude Code';
+ return agentKind === 'codex' ? 'Codex' : agentKind === 'pi' ? 'Pi' : 'Claude Code';
}
export async function performMessageDeletion(
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index 0253afb3d7..d2b15c1633 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -7454,7 +7454,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
throwIpcError('INTERNAL', err instanceof Error ? err.message : 'context usage lazy create failed');
}
}
- if (sess.agentKind !== 'claude-code') {
+ if (sess.agentKind !== 'claude-code' && sess.agentKind !== 'pi') {
throwIpcError('UNSUPPORTED_CAPABILITY', `Agent ${sess.agentKind} does not support context usage`);
}
try {
@@ -8039,7 +8039,11 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
if (!msg.createOpts || typeof msg.createOpts !== 'object') {
throwIpcError('INVALID_PARAMS', 'queued.createOpts required');
}
- if (msg.createOpts.agentKind !== 'claude-code' && msg.createOpts.agentKind !== 'codex') {
+ if (
+ msg.createOpts.agentKind !== 'claude-code'
+ && msg.createOpts.agentKind !== 'codex'
+ && msg.createOpts.agentKind !== 'pi'
+ ) {
throwIpcError('INVALID_PARAMS', 'queued.createOpts.agentKind invalid');
}
const normalized: AgentInputQueuedMessage = { ...msg };
@@ -8887,15 +8891,15 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
// setMemory 后按 result.effective ('immediate' | 'next-session') 决定是否提示
// "新会话生效"; reset 前必走 confirm dialog (UI 层负责)。
ipcMain.handle(MAKER_INVOKE.MEMORY_GET, async (_e, agentKind: unknown) => {
- if (agentKind !== 'claude-code' && agentKind !== 'codex') {
- throwIpcError('INVALID_PARAMS', `agentKind required (claude-code | codex), got ${String(agentKind)}`);
+ if (agentKind !== 'claude-code' && agentKind !== 'codex' && agentKind !== 'pi') {
+ throwIpcError('INVALID_PARAMS', `agentKind required (claude-code | codex | pi), got ${String(agentKind)}`);
}
return maker.getAgentMemoryStatus(agentKind);
});
ipcMain.handle(MAKER_INVOKE.MEMORY_SET, async (_e, agentKind: unknown, enabled: unknown) => {
- if (agentKind !== 'claude-code' && agentKind !== 'codex') {
- throwIpcError('INVALID_PARAMS', `agentKind required (claude-code | codex), got ${String(agentKind)}`);
+ if (agentKind !== 'claude-code' && agentKind !== 'codex' && agentKind !== 'pi') {
+ throwIpcError('INVALID_PARAMS', `agentKind required (claude-code | codex | pi), got ${String(agentKind)}`);
}
if (typeof enabled !== 'boolean') {
throwIpcError('INVALID_PARAMS', 'enabled required (boolean)');
@@ -8906,7 +8910,8 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
// 写盘失败不阻塞 — 当前 session 已经 setMemory 成功, 只是下次重启会回默认。
let settingsState = readMemorySettingsState();
try {
- settingsState = writeMemorySetting(agentKind === 'codex' ? 'codex' : 'claudeCode', enabled);
+ const settingKey = agentKind === 'claude-code' ? 'claudeCode' : agentKind;
+ settingsState = writeMemorySetting(settingKey, enabled);
} catch (err) {
log.warn('memory:set persistence failed (in-session change still applied)', {
agentKind,
@@ -8923,8 +8928,8 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
});
ipcMain.handle(MAKER_INVOKE.MEMORY_RESET, async (_e, agentKind: unknown) => {
- if (agentKind !== 'claude-code' && agentKind !== 'codex') {
- throwIpcError('INVALID_PARAMS', `agentKind required (claude-code | codex), got ${String(agentKind)}`);
+ if (agentKind !== 'claude-code' && agentKind !== 'codex' && agentKind !== 'pi') {
+ throwIpcError('INVALID_PARAMS', `agentKind required (claude-code | codex | pi), got ${String(agentKind)}`);
}
log.info('memory:reset', { agentKind });
return maker.resetAgentMemory(agentKind);
@@ -9007,6 +9012,11 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
} else {
await maker.setAgentMemory('claude-code', settings.claudeCode);
}
+ // Pi 的自动记忆以 Cindy Memory 为存储层,不参与“启用 Cindy 时关闭原生记忆”联动;
+ // reset 仍要把存活 Pi runtime 的独立开关恢复成默认值。
+ if (maker.listAvailableAgents().includes('pi')) {
+ await maker.setAgentMemory('pi', settings.pi);
+ }
return memorySettingsWire();
},
applyRuntime: async () => {
@@ -9413,7 +9423,7 @@ async function checkWorkDirExists(
// 或者 agent 真跑起来时由远端 codex 自己报 ENOENT)。这里直接放行。
if (remoteHostId) return true;
if (!workingDir?.trim()) return true;
- const source: AgentKind = agentKind === 'codex' ? 'codex' : 'claude-code';
+ const source: AgentKind = agentKind === 'codex' || agentKind === 'pi' ? agentKind : 'claude-code';
// suppressMissingBroadcast: 调用方(SEND 事务)手里还有 DB 权威值可兜底时,
// 首检失败只记日志不广播错误横幅——兜底成功的话用户不该看到假错误。
const suppress = opts?.suppressMissingBroadcast === true;
diff --git a/apps/desktop/src/main/maker-ipc/schedule.ts b/apps/desktop/src/main/maker-ipc/schedule.ts
index e7fd757164..06205d0c7c 100644
--- a/apps/desktop/src/main/maker-ipc/schedule.ts
+++ b/apps/desktop/src/main/maker-ipc/schedule.ts
@@ -390,7 +390,9 @@ export function registerScheduleHandlers(getMaker?: () => Maker | null): void {
const maker = getMaker?.();
if (!maker) throwIpcError('INTERNAL', 'maker not ready for hook script generation');
const workingDir = await resolveHookWorkingDir(body);
- const requestedAgentKind: AgentKind | undefined = body.agentKind === 'codex' || body.agentKind === 'claude-code'
+ const requestedAgentKind: AgentKind | undefined = body.agentKind === 'codex'
+ || body.agentKind === 'claude-code'
+ || body.agentKind === 'pi'
? body.agentKind
: undefined;
const targetSessionId = typeof body.targetSessionId === 'string' && body.targetSessionId.trim()
diff --git a/apps/desktop/src/main/maker-ipc/sessionAgentSwitchHandler.ts b/apps/desktop/src/main/maker-ipc/sessionAgentSwitchHandler.ts
index 113b101d0f..77974acbac 100644
--- a/apps/desktop/src/main/maker-ipc/sessionAgentSwitchHandler.ts
+++ b/apps/desktop/src/main/maker-ipc/sessionAgentSwitchHandler.ts
@@ -327,8 +327,8 @@ export async function performSessionAgentSwitch(
if (typeof sessionId !== 'string' || sessionId.length === 0) {
throwIpcError('INVALID_PARAMS', 'sessionId required');
}
- if (targetAgentKind !== 'claude-code' && targetAgentKind !== 'codex') {
- throwIpcError('INVALID_PARAMS', 'targetAgentKind must be claude-code | codex');
+ if (targetAgentKind !== 'claude-code' && targetAgentKind !== 'codex' && targetAgentKind !== 'pi') {
+ throwIpcError('INVALID_PARAMS', 'targetAgentKind must be claude-code | codex | pi');
}
if (typeof model !== 'string' || model.length === 0) {
throwIpcError('INVALID_PARAMS', 'model required');
diff --git a/apps/desktop/src/main/scheduler-host/project-automation-loader.ts b/apps/desktop/src/main/scheduler-host/project-automation-loader.ts
index d46a41cccc..ad3634ea36 100644
--- a/apps/desktop/src/main/scheduler-host/project-automation-loader.ts
+++ b/apps/desktop/src/main/scheduler-host/project-automation-loader.ts
@@ -591,7 +591,7 @@ function optionalNumber(value: unknown): boolean {
}
function optionalAgentKind(value: unknown): boolean {
- return value === undefined || value === 'claude-code' || value === 'codex';
+ return value === undefined || value === 'claude-code' || value === 'codex' || value === 'pi';
}
function optionalNotify(value: unknown): boolean {
diff --git a/apps/desktop/src/main/scheduler-host/runner.ts b/apps/desktop/src/main/scheduler-host/runner.ts
index 37bc4ad764..60fa45c342 100644
--- a/apps/desktop/src/main/scheduler-host/runner.ts
+++ b/apps/desktop/src/main/scheduler-host/runner.ts
@@ -662,10 +662,10 @@ export class MakerScheduleRunner implements ScheduleRunner {
: undefined;
const model = rawModel?.trim() ? rawModel : defaultModelFor(effectiveAgentKind);
const permissionMode = defaultPermissionModeForSchedule();
- // fastMode 只对 codex 有意义(claude-code agent 忽略此字段);Claude 恒不传,
+ // fastMode 对 Codex / Pi 生效(claude-code agent 忽略此字段);Claude 恒不传,
// 确保「不影响 Claude」。heartbeat 沿用 session meta 里的 fast 态,非 heartbeat 取 schedule。
let fastMode =
- effectiveAgentKind === 'codex'
+ effectiveAgentKind === 'codex' || effectiveAgentKind === 'pi'
? isHeartbeat
? heartbeatFastMode
: schedule.fastMode
diff --git a/apps/desktop/src/main/session-share/__tests__/xdtshareFormat.pure.test.ts b/apps/desktop/src/main/session-share/__tests__/xdtshareFormat.pure.test.ts
index 6b6e035d5c..d1fde143f0 100644
--- a/apps/desktop/src/main/session-share/__tests__/xdtshareFormat.pure.test.ts
+++ b/apps/desktop/src/main/session-share/__tests__/xdtshareFormat.pure.test.ts
@@ -116,6 +116,10 @@ describe('validateManifest', () => {
expect('futureField' in manifest).toBe(false);
});
+ it('accepts Pi manifests without relabeling the agent', () => {
+ expect(validateManifest({ ...validManifest(), agentKind: 'pi' }).agentKind).toBe('pi');
+ });
+
it('rejects minReaderVersion above this reader', () => {
try {
validateManifest({ ...validManifest(), minReaderVersion: 999 });
diff --git a/apps/desktop/src/main/session-share/sessionShareExport.ts b/apps/desktop/src/main/session-share/sessionShareExport.ts
index 9e5944c5a9..0e2a5711c8 100644
--- a/apps/desktop/src/main/session-share/sessionShareExport.ts
+++ b/apps/desktop/src/main/session-share/sessionShareExport.ts
@@ -392,7 +392,7 @@ export async function exportSessionShare(
appVersion: safeAppVersion(),
platform: process.platform,
exportedAt: new Date().toISOString(),
- agentKind: session.agentKind as 'cc' | 'codex',
+ agentKind: session.agentKind as 'cc' | 'codex' | 'pi',
title: session.title,
workspaceKind: session.workspaceKind === 'dialogue' ? 'dialogue' : 'project',
originalWorkingDir: session.workingDir,
diff --git a/apps/desktop/src/main/session-share/sessionShareImport.ts b/apps/desktop/src/main/session-share/sessionShareImport.ts
index 3803e91f6e..fdb964c4db 100644
--- a/apps/desktop/src/main/session-share/sessionShareImport.ts
+++ b/apps/desktop/src/main/session-share/sessionShareImport.ts
@@ -81,7 +81,7 @@ function sweepExpiredDrafts(): void {
export interface SharePreview {
title: string;
- agentKind: 'cc' | 'codex';
+ agentKind: 'cc' | 'codex' | 'pi';
workspaceKind: 'project' | 'dialogue';
originalWorkingDir: string | null;
exportedAt: string;
@@ -804,9 +804,10 @@ const EFFORTS = new Set(['minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ul
const PERMISSION_MODES = new Set(['ask', 'default', 'acceptEdits', 'plan', 'auto', 'bypassPermissions']);
/** draftPrefs 缺省(旧调用方 / 测试)时按 agentKind 兜底的模型。 */
-const FALLBACK_MODEL_BY_AGENT: Record<'cc' | 'codex', string> = {
+const FALLBACK_MODEL_BY_AGENT: Record<'cc' | 'codex' | 'pi', string> = {
cc: 'claude-sonnet-4-6',
codex: 'gpt-5.4',
+ pi: 'gpt-5.4',
};
/**
diff --git a/apps/desktop/src/main/session-share/xdtshareFormat.pure.ts b/apps/desktop/src/main/session-share/xdtshareFormat.pure.ts
index c04a39d6f7..53444e4611 100644
--- a/apps/desktop/src/main/session-share/xdtshareFormat.pure.ts
+++ b/apps/desktop/src/main/session-share/xdtshareFormat.pure.ts
@@ -212,7 +212,7 @@ export interface XdtshareManifest {
appVersion: string;
platform: string;
exportedAt: string;
- agentKind: 'cc' | 'codex';
+ agentKind: 'cc' | 'codex' | 'pi';
title: string;
workspaceKind: 'project' | 'dialogue';
originalWorkingDir: string | null;
@@ -275,7 +275,7 @@ export function validateManifest(value: unknown): XdtshareManifest {
appVersion: expectString(value.appVersion, 'appVersion'),
platform: expectString(value.platform, 'platform'),
exportedAt: expectString(value.exportedAt, 'exportedAt'),
- agentKind: agentKind as 'cc' | 'codex',
+ agentKind: agentKind as 'cc' | 'codex' | 'pi',
title: expectString(value.title, 'title'),
workspaceKind: workspaceKind as 'project' | 'dialogue',
originalWorkingDir:
diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.ts
index f95b71d532..5a0b5f63e8 100644
--- a/apps/desktop/src/preload/preload.ts
+++ b/apps/desktop/src/preload/preload.ts
@@ -233,7 +233,7 @@ type VoiceInputModelSelectionPatchWire = {
type DiscordBotSessionAuthCheckWire = {
ok: boolean;
missing: 'gateway-key' | 'agent-oauth' | 'provider-key' | 'provider-disconnected' | null;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
model: string;
providerId: string | null;
providerLabel: string | null;
@@ -4026,9 +4026,9 @@ contextBridge.exposeInMainWorld('electronAPI', {
// ─── Maker Core IPC ─────────────────────────────────────────────────────
// renderer 通过统一 maker API 按 agentKind 调用 Claude Code / Codex。
maker: {
- listAvailableAgents: (): Promise<Array<'claude-code' | 'codex'>> =>
+ listAvailableAgents: (): Promise<Array<'claude-code' | 'codex' | 'pi'>> =>
ipcRenderer.invoke('maker:list-available-agents'),
- getCapabilities: (agentKind: 'claude-code' | 'codex'): Promise<unknown> =>
+ getCapabilities: (agentKind: 'claude-code' | 'codex' | 'pi'): Promise<unknown> =>
ipcRenderer.invoke('maker:get-capabilities', agentKind),
// workflow 逐 agent 进度树(只读)。读不到 / 解析失败返回 null,由 renderer 回退到
@@ -4232,7 +4232,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
ipcRenderer.invoke('maker:execute-desktop-command', name, ctx),
listAgentCommands: (
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
): Promise<{
success: boolean;
error?: string;
@@ -4240,7 +4240,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
}> => ipcRenderer.invoke('maker:list-agent-commands', agentKind),
listAgentSkills: (
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
params: { workingDir?: string; forceReload?: boolean },
): Promise<{
success: boolean;
@@ -4333,7 +4333,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
onGoalStatusChanged: fanOutGoalStatusChanged,
scanAtResources: (
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
params: { workingDir: string; cap?: number; query?: string },
): Promise<{
success: boolean;
@@ -4349,7 +4349,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
createSession: (opts: {
/** 可选: 复用外部 sessionId(本端 chat 用 local-db:sessions:create 拿到的 id) */
id?: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workingDir: string;
model: string;
title?: string;
@@ -4427,7 +4427,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
sessionId: string,
message: string | { type: 'user'; content: string | Array<{ type: string; [k: string]: unknown }> },
createOpts?: {
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workingDir: string;
model: string;
orcaRole?: 'lead' | 'worker' | null;
@@ -4471,7 +4471,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
getContextUsage: (
sessionId: string,
createOpts?: {
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workingDir: string;
model: string;
orcaRole?: 'lead' | 'worker' | null;
@@ -4508,7 +4508,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
listActive: (): Promise<Array<{
sessionId: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workDir: string;
capabilities: unknown;
isTurnRunning: boolean;
@@ -4556,12 +4556,12 @@ contextBridge.exposeInMainWorld('electronAPI', {
// switched=false 且无 deferred = 同引擎 no-op(用户选回当前引擎,意图已清)。
switchSessionAgent: (
sessionId: string,
- targetAgentKind: 'claude-code' | 'codex',
+ targetAgentKind: 'claude-code' | 'codex' | 'pi',
model: string,
providerId?: string | null,
effort?: string,
fastMode?: boolean,
- ): Promise<{ switched: boolean; agentKind: 'claude-code' | 'codex'; model: string; engineReady: boolean; deferred?: boolean }> =>
+ ): Promise<{ switched: boolean; agentKind: 'claude-code' | 'codex' | 'pi'; model: string; engineReady: boolean; deferred?: boolean }> =>
ipcRenderer.invoke('maker:switch-session-agent', sessionId, targetAgentKind, model, providerId, effort, fastMode),
// effort/mode 透传 string —— 合法值由 maker capabilities 在运行时校验,
// preload 不重复枚举 (避免 capabilities 加新值时这里也要改)。
@@ -4601,22 +4601,22 @@ contextBridge.exposeInMainWorld('electronAPI', {
// Memory 控制 (Personalization → Memory section)。
// 由 BaseAgent 子类落地; UI 层负责 Reset 前 confirm dialog。
- memoryGet: (agentKind: 'claude-code' | 'codex'): Promise<{
+ memoryGet: (agentKind: 'claude-code' | 'codex' | 'pi'): Promise<{
enabled: boolean;
source: 'agent-default' | 'host-runtime' | 'user-config';
stats?: { entryCount?: number; sizeBytes?: number; storagePath?: string };
}> => ipcRenderer.invoke('maker:memory:get', agentKind),
memorySet: (
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
enabled: boolean,
): Promise<{
effective: 'immediate' | 'next-session';
isCustomized: boolean;
customizedKeys: string[];
- defaults: { maker: boolean; claudeCode: boolean; codex: boolean };
+ defaults: { maker: boolean; claudeCode: boolean; codex: boolean; pi: boolean };
}> =>
ipcRenderer.invoke('maker:memory:set', agentKind, enabled),
- memoryReset: (agentKind: 'claude-code' | 'codex'): Promise<{
+ memoryReset: (agentKind: 'claude-code' | 'codex' | 'pi'): Promise<{
removedEntries?: number;
removedBytes?: number;
}> => ipcRenderer.invoke('maker:memory:reset', agentKind),
@@ -4632,7 +4632,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
effective: 'next-session';
isCustomized: boolean;
customizedKeys: string[];
- defaults: { maker: boolean; claudeCode: boolean; codex: boolean };
+ defaults: { maker: boolean; claudeCode: boolean; codex: boolean; pi: boolean };
codexRestartDeferred: boolean;
}> =>
ipcRenderer.invoke('maker:maker-memory:set-enabled', enabled),
@@ -4645,15 +4645,16 @@ contextBridge.exposeInMainWorld('electronAPI', {
* 启动期同步三个 memory 开关的真实持久化值 (main <userData>/memory-settings.json)。
* renderer localStorage 只是 UI 即时态镜像 — 启动时调一次, main 是 source of truth。
*/
- memoryGetSettings: (): Promise<{ maker: boolean; claudeCode: boolean; codex: boolean }> =>
+ memoryGetSettings: (): Promise<{ maker: boolean; claudeCode: boolean; codex: boolean; pi: boolean }> =>
ipcRenderer.invoke('maker:memory:get-settings'),
memoryGetSettingsState: (): Promise<{
maker: boolean;
claudeCode: boolean;
codex: boolean;
+ pi: boolean;
isCustomized: boolean;
customizedKeys: string[];
- defaults: { maker: boolean; claudeCode: boolean; codex: boolean };
+ defaults: { maker: boolean; claudeCode: boolean; codex: boolean; pi: boolean };
}> =>
ipcRenderer.invoke('maker:memory:get-settings-state'),
/** 启动期迁移旧版 renderer/native memory opt-out;null 表示 renderer marker 缺失。 */
@@ -4661,15 +4662,17 @@ contextBridge.exposeInMainWorld('electronAPI', {
maker: boolean;
claudeCode: boolean;
codex: boolean;
+ pi: boolean;
}> =>
ipcRenderer.invoke('maker:memory:preserve-legacy-maker-disabled', legacyRendererValue),
memoryResetSettings: (): Promise<{
maker: boolean;
claudeCode: boolean;
codex: boolean;
+ pi: boolean;
isCustomized: boolean;
customizedKeys: string[];
- defaults: { maker: boolean; claudeCode: boolean; codex: boolean };
+ defaults: { maker: boolean; claudeCode: boolean; codex: boolean; pi: boolean };
codexRestartDeferred: boolean;
}> =>
ipcRenderer.invoke('maker:memory:reset-settings'),
@@ -4949,7 +4952,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
},
// Stage 2 C1: chat utility (前身 cc-agent:generate-title / cc-agent:plan-file-write)
- generateTitle: (message: string, agentKind: 'claude-code' | 'codex', sessionId?: string): Promise<{ title: string | null }> =>
+ generateTitle: (message: string, agentKind: 'claude-code' | 'codex' | 'pi', sessionId?: string): Promise<{ title: string | null }> =>
ipcRenderer.invoke('maker:generate-title', { message, agentKind, sessionId }),
// 重命名输入框 Magic 按钮:按会话最新对话内容重新生成标题(素材由 main 读 DB)
regenerateSessionTitle: (sessionId: string): Promise<{ title: string | null }> =>
@@ -4958,7 +4961,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
autoTitle: (request: {
sessionId: string;
text: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
isUserText?: boolean;
}): Promise<{ applied: boolean; done: boolean }> =>
ipcRenderer.invoke('maker:auto-title', request),
@@ -5020,19 +5023,19 @@ contextBridge.exposeInMainWorld('electronAPI', {
// ── Agent 鉴权 (取代老 electronAPI.codex.auth.*) ────────────────────────
auth: {
- getState: (agentKind: 'claude-code' | 'codex'): Promise<unknown> =>
+ getState: (agentKind: 'claude-code' | 'codex' | 'pi'): Promise<unknown> =>
ipcRenderer.invoke('maker:auth:get-state', agentKind),
triggerLogin: (
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
options?: { mode?: 'browser' | 'device-code'; ownerId?: string },
): Promise<unknown> =>
ipcRenderer.invoke('maker:auth:trigger-login', agentKind, options),
cancelLogin: (
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
options?: { releaseOwner?: boolean; ownerId?: string },
): Promise<void> =>
ipcRenderer.invoke('maker:auth:cancel-login', agentKind, options),
- logout: (agentKind: 'claude-code' | 'codex'): Promise<void> =>
+ logout: (agentKind: 'claude-code' | 'codex' | 'pi'): Promise<void> =>
ipcRenderer.invoke('maker:auth:logout', agentKind),
onStateChanged: fanOutMakerAuthStateChanged,
onLoginProgress: fanOutMakerAuthLoginProgress,
@@ -5040,11 +5043,11 @@ contextBridge.exposeInMainWorld('electronAPI', {
// ── Agent 联合状态 (取代老 electronAPI.codex.binary.getStatus) ──────────
agent: {
- getStatus: (agentKind: 'claude-code' | 'codex'): Promise<unknown> =>
+ getStatus: (agentKind: 'claude-code' | 'codex' | 'pi'): Promise<unknown> =>
ipcRenderer.invoke('maker:agent:status', agentKind),
/** spawn 当前应用使用的 binary `--version`, 进程内缓存。About 面板用。 */
- getBinaryVersion: (agentKind: 'claude-code' | 'codex'): Promise<{
- kind: 'claude-code' | 'codex';
+ getBinaryVersion: (agentKind: 'claude-code' | 'codex' | 'pi'): Promise<{
+ kind: 'claude-code' | 'codex' | 'pi';
binaryPath: string | null;
version: string | null;
error?: string;
@@ -5053,9 +5056,9 @@ contextBridge.exposeInMainWorld('electronAPI', {
// ── Agent 今日累计 (取代老 electronAPI.codex.usage.* + electronAPI.onUsageTodaySpendChanged) ─
usage: {
- getToday: (agentKind: 'claude-code' | 'codex'): Promise<unknown> =>
+ getToday: (agentKind: 'claude-code' | 'codex' | 'pi'): Promise<unknown> =>
ipcRenderer.invoke('maker:usage:today', agentKind),
- getAccount: (agentKind: 'claude-code' | 'codex'): Promise<unknown> =>
+ getAccount: (agentKind: 'claude-code' | 'codex' | 'pi'): Promise<unknown> =>
ipcRenderer.invoke('maker:usage:account', agentKind),
/** Codex app-server authoritative windows and banked reset-credit metadata. */
getCodexRateLimits: (): Promise<MobileCodexRateLimitsResult> =>
diff --git a/apps/desktop/src/renderer/__tests__/deviceLinkCreateArgs.test.ts b/apps/desktop/src/renderer/__tests__/deviceLinkCreateArgs.test.ts
index 0a70fd7c80..e6ca5de70e 100644
--- a/apps/desktop/src/renderer/__tests__/deviceLinkCreateArgs.test.ts
+++ b/apps/desktop/src/renderer/__tests__/deviceLinkCreateArgs.test.ts
@@ -63,9 +63,10 @@ describe('buildDeviceLinkCreateArgs', () => {
expect(args.workingDir).toBe('/host/proj');
});
- it('agentKind 归一到 maker-core 形态:cc → claude-code,codex → codex', () => {
+ it('agentKind 归一到 maker-core 形态:cc → claude-code,codex/pi 保持原值', () => {
expect(buildDeviceLinkCreateArgs({ agentKind: 'cc', workingDir: '/p', model: 'm', effort: 'medium', permissionMode: 'acceptEdits', fastMode: false }).agentKind).toBe('claude-code');
expect(buildDeviceLinkCreateArgs({ agentKind: 'codex', workingDir: '/p', model: 'm', effort: 'high', permissionMode: 'auto', fastMode: false }).agentKind).toBe('codex');
+ expect(buildDeviceLinkCreateArgs({ agentKind: 'pi', workingDir: '/p', model: 'm', effort: 'high', permissionMode: 'auto', fastMode: false }).agentKind).toBe('pi');
});
it('其余字段原样透传(model/effort/permissionMode/fastMode)', () => {
@@ -258,6 +259,13 @@ describe('buildProvisionalRemoteSession', () => {
buildProvisionalRemoteSession({ sessionId: 's', workDir: '/w', args: dialogue, nowIso: NOW })
.agentKind,
).toBe('cc');
+ const pi = buildDeviceLinkCreateArgs({
+ agentKind: 'pi', model: 'gpt-5.4', effort: 'high', permissionMode: 'auto', fastMode: true,
+ });
+ expect(
+ buildProvisionalRemoteSession({ sessionId: 's', workDir: '/w', args: pi, nowIso: NOW })
+ .agentKind,
+ ).toBe('pi');
});
it('新会话的确定初值:active / 未置顶 / 计数为 0 / 标题与被控端 create 的默认值一致', () => {
diff --git a/apps/desktop/src/renderer/__tests__/newMakerProjectPicker.test.ts b/apps/desktop/src/renderer/__tests__/newMakerProjectPicker.test.ts
index 5e2e9b23ec..b4acee2918 100644
--- a/apps/desktop/src/renderer/__tests__/newMakerProjectPicker.test.ts
+++ b/apps/desktop/src/renderer/__tests__/newMakerProjectPicker.test.ts
@@ -198,7 +198,7 @@ describe('Shared create project picker', () => {
});
it('keeps remote project drafts out of local workspace probes', () => {
- expect(newMakerDraftRouteSource).toContain('if (wd && !isRemoteProjectDraft)');
+ expect(newMakerDraftRouteSource).toContain('if (wd && !isRemoteProjectDraft');
// device-link 草稿的 git 探测经隧道在被控端执行(本机 git 对远程路径必然误报);
// SSH(worktreeDisabled)仍不探测。
expect(worktreeChipsSource).toContain('deviceLinkReconnectEpoch,');
diff --git a/apps/desktop/src/renderer/__tests__/vendorAuthGateRemoteReadiness.test.ts b/apps/desktop/src/renderer/__tests__/vendorAuthGateRemoteReadiness.test.ts
index 309fdcd132..373b6560bc 100644
--- a/apps/desktop/src/renderer/__tests__/vendorAuthGateRemoteReadiness.test.ts
+++ b/apps/desktop/src/renderer/__tests__/vendorAuthGateRemoteReadiness.test.ts
@@ -16,6 +16,20 @@ import {
pickVoiceInputDialogCopy,
sourceReadyFromProviderList,
} from '@/hooks/useVendorAuthGate';
+import { readinessFromBinaryStatus } from '@/hooks/useVendorReadiness';
+
+describe('readinessFromBinaryStatus(本地运行时就绪推导)', () => {
+ it('Codex 与 Pi 缺少本地二进制时都返回 binary-missing', () => {
+ expect(readinessFromBinaryStatus('codex', false)).toBe('binary-missing');
+ expect(readinessFromBinaryStatus('pi', false)).toBe('binary-missing');
+ });
+
+ it('Claude 不依赖该二进制轴,已就绪时不产生覆盖状态', () => {
+ expect(readinessFromBinaryStatus('cc', false)).toBeNull();
+ expect(readinessFromBinaryStatus('codex', true)).toBeNull();
+ expect(readinessFromBinaryStatus('pi', true)).toBeNull();
+ });
+});
describe('deriveRemoteReadiness(被控端就绪推导)', () => {
it('sourceReady 可用时是唯一真相(cc / codex 同构),authReady 不参与', () => {
@@ -66,6 +80,12 @@ describe('deriveRemoteReadiness(被控端就绪推导)', () => {
).toBe('ready');
});
+ it('pi:binaryReady=false 报组件缺失,不伪装成未授权', () => {
+ expect(
+ deriveRemoteReadiness('pi', { binaryReady: false, sourceReady: true, authReady: true }),
+ ).toBe('binary-missing');
+ });
+
it('cc:binary 随包,binaryReady 不参与判定', () => {
expect(
deriveRemoteReadiness('cc', { binaryReady: false, sourceReady: true, authReady: null }),
@@ -118,6 +138,7 @@ describe('pickVoiceInputDialogCopy(语音输入缺认证文案)', () => {
'voice-direct-api-key-unauth': { title: 'direct-key', description: '', confirmText: '', cancelText: '', settingsTab: 'api-keys' },
'codex-voice-unauth': { title: 'codex', description: '', confirmText: '', cancelText: '', settingsTab: 'providers' },
'codex-binary-missing': { title: 'binary', description: '', confirmText: '', cancelText: '', settingsTab: 'providers' },
+ 'pi-binary-missing': { title: 'pi-binary', description: '', confirmText: '', cancelText: '', settingsTab: 'providers' },
};
it('api-key + providers 使用 XD Gateway 文案', () => {
diff --git a/apps/desktop/src/renderer/cindy-brain/GhostErrandPrefs.tsx b/apps/desktop/src/renderer/cindy-brain/GhostErrandPrefs.tsx
index e95ec8990a..a1def78ab3 100644
--- a/apps/desktop/src/renderer/cindy-brain/GhostErrandPrefs.tsx
+++ b/apps/desktop/src/renderer/cindy-brain/GhostErrandPrefs.tsx
@@ -4,7 +4,7 @@
*
* 选择器复用草稿页同一套组件(2026-07-31 Lizi 要求,不另搭下拉),展示与
* 交互与新建对话一致,不暴露「跟随默认 / 钉住」这层概念:
- * - Agent = VendorSegmentedSwitcher(cc/codex 分段);
+ * - Agent = VendorSegmentedSwitcher(cc/codex/pi 分段);
* - 模型/推理强度/Fast/供应商 = ModelSelector 的 field 形态,占满整行(标题在上、
* 控件 w-full 在下,与 IM 默认配置同款);面板宽度绑定 trigger(DESIGN.md §4);
* - 动手权限 = PermissionSelector(权限下拉全仓只此一份,不得私搭),
@@ -41,7 +41,7 @@ const PERMISSION_ALLOWED = new Set(['plan', 'acceptEdits', 'auto']);
const ERRAND_EFFORTS = new Set(['low', 'medium', 'high', 'xhigh', 'max', 'ultra']);
interface ErrandConfig {
- agentKind?: 'cc' | 'codex';
+ agentKind?: 'cc' | 'codex' | 'pi';
model?: string;
effort?: string;
fastMode?: boolean;
@@ -90,8 +90,9 @@ export function GhostErrandPrefs({
// 保证非空,种子默认兜底)。不能用 getPersistedVendorModel:那是调度专用的严格口径,
// 仅当用户在新建对话里显式选过该 vendor 模型才返回,否则返回 '',会让 trigger 落到
// 「选择模型」占位(2026-07-31 Lizi 反馈:应像草稿一样直接显示当前模型)。
- const followVendor = draft.vendor === 'codex' ? ('codex' as const) : ('cc' as const);
- const vendor = config.agentKind ?? followVendor;
+ const followVendor: 'cc' | 'codex' | 'pi' =
+ draft.vendor === 'pi' ? 'pi' : draft.vendor === 'codex' ? 'codex' : 'cc';
+ const vendor: 'cc' | 'codex' | 'pi' = config.agentKind ?? followVendor;
const shownModel = config.model ?? draft.lastByVendor[vendor].model;
const shownEffort = (config.effort ??
getEffortForModel(shownModel) ??
@@ -159,7 +160,7 @@ export function GhostErrandPrefs({
// 值钉进本插件配置(未选过时才实时跟随草稿)。
void save({
...config,
- agentKind: next === 'codex' ? 'codex' : 'cc',
+ agentKind: next === 'pi' ? 'pi' : next === 'codex' ? 'codex' : 'cc',
model: undefined,
effort: undefined,
fastMode: undefined,
diff --git a/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx b/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx
index ae801da12c..855f2a805c 100644
--- a/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx
+++ b/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx
@@ -228,7 +228,7 @@ export const AssistantMessage = memo(function AssistantMessage({
// fork-from-reply: 在 AI 回复上分叉 — 复制含本回复所在 turn 的全部上下文
// 到新会话(语义在 main 侧 forkSessionAtMessage 按 role 分支)。capability /
// remote gate 与 UserMessage 同款;assistant 分叉无可预填文本 → 不传 draftText。
- const makerKind: MakerAgentKind = agentKind === 'codex' ? 'codex' : 'claude-code';
+ const makerKind: MakerAgentKind = agentKind === 'codex' || agentKind === 'pi' ? agentKind : 'claude-code';
// device-link 远程会话:fork 能力按被控端读(本机会话 deviceId undefined,行为不变)。
// deviceId 取自 ChatSessionFileContext(MessageStream 顶层订阅式构造,见该文件注释)。
const sessionFileOrigin = useSessionFileOrigin();
diff --git a/apps/desktop/src/renderer/components/chat/SystemCard.tsx b/apps/desktop/src/renderer/components/chat/SystemCard.tsx
index 03795cbe17..c117a21aca 100644
--- a/apps/desktop/src/renderer/components/chat/SystemCard.tsx
+++ b/apps/desktop/src/renderer/components/chat/SystemCard.tsx
@@ -1009,7 +1009,7 @@ function AgentSwitchCard({ data }: { data?: Record<string, unknown> }) {
const { t } = useTranslation();
const [expanded, setExpanded] = useState(false);
const engineLabel = (kind: unknown): string =>
- kind === 'codex' ? 'Codex' : 'Claude Code';
+ kind === 'codex' ? 'Codex' : kind === 'pi' ? 'Pi' : 'Claude Code';
const fromLabel = engineLabel(data?.fromAgentKind);
const toLabel = engineLabel(data?.toAgentKind);
const toModel = typeof data?.toModel === 'string' ? data.toModel : '';
diff --git a/apps/desktop/src/renderer/components/chat/UserMessage.tsx b/apps/desktop/src/renderer/components/chat/UserMessage.tsx
index 4bc1d28fed..b31b35d1a6 100644
--- a/apps/desktop/src/renderer/components/chat/UserMessage.tsx
+++ b/apps/desktop/src/renderer/components/chat/UserMessage.tsx
@@ -728,7 +728,7 @@ export function UserMessage({
// Capability gate: 没传 agentKind (调用方未升级) → 默认两者都允许 (兼容旧路径)
// 传了 agentKind → 按 capabilities.fork/rewind.supported 决定 icon 显示
// renderer 'cc' ↔ maker 'claude-code' 别名映射 (DB / Session 用 'cc', maker IPC 用 'claude-code')
- const makerKind: MakerAgentKind = agentKind === 'codex' ? 'codex' : 'claude-code';
+ const makerKind: MakerAgentKind = agentKind === 'codex' || agentKind === 'pi' ? agentKind : 'claude-code';
// device-link 远程会话:fork/rewind 能力按被控端读(本机会话 deviceId undefined,行为不变)。
// 媒体来源(device/ssh)用于把附件/文件预览 URL 改写到 cindy-remote-media://(入方向媒体)。
// 取自 ChatSessionFileContext(MessageStream 顶层订阅式构造,deviceId 迟到注册时
diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
index 4e70a19f1d..17347c3d18 100644
--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
@@ -1146,7 +1146,9 @@ export function ChatInput({
// initialModel/initialEffort 缺失的瞬态(会话快照未加载)兜底:读本地草稿 lastByVendor
// (localStorage,按 agent 分槽、sanitize 恒有种子值)。默认模型/档位偏好已全量本地化,
// 不再依赖服务端 UserPreferences(登录态失效/离线时模型与档位选择必须照常工作)。
- const localVendorDefaults = getDraft().lastByVendor[vendorKey === 'codex' ? 'codex' : 'cc'];
+ const localVendorDefaults = getDraft().lastByVendor[
+ vendorKey === 'pi' ? 'pi' : vendorKey === 'codex' ? 'codex' : 'cc'
+ ];
// session-agent-switch 意图制:意图期内 chip / 选择器显示用户选择的目标
// (model/effort/provider/fast),props(镜像 DB)仍是旧引擎值——真切换在下一条
// 消息发送时刻 apply,patched 回流后意图清除、显示交回 props。意图存放在
@@ -3977,7 +3979,11 @@ export function ChatInput({
if (makerChatStore.getSnapshot(sessionId).agentStatus.isRunning) {
toast.success(
t('newChat.chatInput.agentSwitch.deferred', {
- agent: targetAgentKind === 'codex' ? 'Codex' : 'Claude Code',
+ agent: targetAgentKind === 'codex'
+ ? 'Codex'
+ : targetAgentKind === 'pi'
+ ? 'Pi'
+ : 'Claude Code',
model: newModelId,
}),
{ duration: 4000 },
diff --git a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx
index 6d8bfa2cf0..3c27b6c2cb 100644
--- a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx
@@ -1564,7 +1564,9 @@ function ModelSelectorContentView({
<>
<VendorSegmentedSwitcher
value={browseVendor}
- onChange={(next) => void handleBrowseVendorChange(next === 'codex' ? 'codex' : 'cc')}
+ onChange={(next) => {
+ if (next !== 'orca') void handleBrowseVendorChange(next);
+ }}
dense
width={304}
className="mx-auto"
diff --git a/apps/desktop/src/renderer/components/settings/HookWorkspacePrefsEditor.tsx b/apps/desktop/src/renderer/components/settings/HookWorkspacePrefsEditor.tsx
index 59c35c93a6..d801469230 100644
--- a/apps/desktop/src/renderer/components/settings/HookWorkspacePrefsEditor.tsx
+++ b/apps/desktop/src/renderer/components/settings/HookWorkspacePrefsEditor.tsx
@@ -474,9 +474,9 @@ function PrefsField({
);
}
-/** hook prefs 的 agentKind('claude-code' | 'codex')→ 选择器的 vendor key。 */
-function toVendorKey(agentKind: string | null): 'cc' | 'codex' {
- return agentKind === 'codex' ? 'codex' : 'cc';
+/** hook prefs 的 agentKind → 选择器的 vendor key。 */
+function toVendorKey(agentKind: string | null): 'cc' | 'codex' | 'pi' {
+ return agentKind === 'codex' || agentKind === 'pi' ? agentKind : 'cc';
}
/**
@@ -487,6 +487,7 @@ function toVendorKey(agentKind: string | null): 'cc' | 'codex' {
*/
function toAgentKind(vendor: MakerVendor): KnownAgent {
if (vendor === 'codex') return 'codex';
+ if (vendor === 'pi') return 'pi';
if (vendor === 'cc') return 'claude-code';
throw new Error(`WorkspacePrefsEditor: unsupported vendor '${vendor}' for hook prefs`);
}
@@ -505,13 +506,15 @@ export function WorkspacePrefsEditor({
const { t } = useTranslation();
const claudeCaps = useAgentCapabilities('claude-code');
const codexCaps = useAgentCapabilities('codex');
+ const piCaps = useAgentCapabilities('pi');
const capsByAgent = useMemo(
() =>
({
'claude-code': claudeCaps.capabilities,
codex: codexCaps.capabilities,
+ pi: piCaps.capabilities,
}) as Record<KnownAgent, AgentCapabilities | null>,
- [claudeCaps.capabilities, codexCaps.capabilities],
+ [claudeCaps.capabilities, codexCaps.capabilities, piCaps.capabilities],
);
const capsOf = useCallback(
(agentKind: string): AgentCapabilities | null =>
diff --git a/apps/desktop/src/renderer/components/settings/ImDefaultSettingsSection.tsx b/apps/desktop/src/renderer/components/settings/ImDefaultSettingsSection.tsx
index 9f419c88b0..f96d201213 100644
--- a/apps/desktop/src/renderer/components/settings/ImDefaultSettingsSection.tsx
+++ b/apps/desktop/src/renderer/components/settings/ImDefaultSettingsSection.tsx
@@ -12,6 +12,7 @@ import { useTranslation } from 'react-i18next';
import { ClaudeMark } from '@/components/icons/ClaudeMark';
import { CodexMark } from '@/components/icons/CodexMark';
+import { PiMark } from '@/components/icons/PiMark';
import { ModelSelector } from '@/components/new-chat/ModelSelector';
import { PermissionSelector } from '@/components/new-chat/PermissionSelector';
import { type ModelDescriptor, useAgentCapabilities } from '@/hooks/useAgentCapabilities';
@@ -41,10 +42,11 @@ const AGENT_OPTIONS: Array<{
}> = [
{ kind: 'claude-code', Mark: ClaudeMark },
{ kind: 'codex', Mark: CodexMark },
+ { kind: 'pi', Mark: PiMark },
];
-function vendorKeyFor(agentKind: ImDefaultAgentKind): 'cc' | 'codex' {
- return agentKind === 'codex' ? 'codex' : 'cc';
+function vendorKeyFor(agentKind: ImDefaultAgentKind): 'cc' | 'codex' | 'pi' {
+ return agentKind === 'claude-code' ? 'cc' : agentKind;
}
export interface ImDefaultSettingsSummary {
@@ -65,6 +67,7 @@ export function ImDefaultSettingsSection({
const { providers } = useProviders();
const cc = useAgentCapabilities('claude-code');
const codex = useAgentCapabilities('codex');
+ const pi = useAgentCapabilities('pi');
const [settings, setSettings] = useState<ImDefaultSettingsState | null>(null);
const [pending, setPending] = useState(false);
@@ -101,6 +104,7 @@ export function ImDefaultSettingsSection({
const fromProviders = {
'claude-code': deriveModelsFromProviders(providers, 'claude-code', { admissionFiltered: true }),
codex: deriveModelsFromProviders(providers, 'codex', { admissionFiltered: true }),
+ pi: deriveModelsFromProviders(providers, 'pi', { admissionFiltered: true }),
};
return {
'claude-code': fromProviders['claude-code'].length
@@ -109,10 +113,11 @@ export function ImDefaultSettingsSection({
codex: fromProviders.codex.length
? fromProviders.codex
: (codex.capabilities?.availableModels ?? []),
- // pi(实验性):IM 设置 UI 暂不提供 pi 选项卡,空清单仅满足满射类型。
- pi: [],
+ pi: fromProviders.pi.length
+ ? fromProviders.pi
+ : (pi.capabilities?.availableModels ?? []),
};
- }, [providers, cc.capabilities, codex.capabilities]);
+ }, [providers, cc.capabilities, codex.capabilities, pi.capabilities]);
const resolveProviderId = useCallback(
(agentKind: ImDefaultAgentKind, modelId: string, providerId: string | null): string | null => {
diff --git a/apps/desktop/src/renderer/components/settings/MemorySection.tsx b/apps/desktop/src/renderer/components/settings/MemorySection.tsx
index 6e4b18756b..3d73d3ae39 100644
--- a/apps/desktop/src/renderer/components/settings/MemorySection.tsx
+++ b/apps/desktop/src/renderer/components/settings/MemorySection.tsx
@@ -22,19 +22,22 @@ import { Switch } from '@/components/ui/switch';
import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';
import { ClaudeMark } from '@/components/icons/ClaudeMark';
import { CodexMark } from '@/components/icons/CodexMark';
+import { PiMark } from '@/components/icons/PiMark';
import { createLogger } from '@/lib/logger';
import { useMemorySettings } from '@/hooks/useMemorySettings';
import { DefaultOverrideControls } from './DefaultOverrideControls';
const log = createLogger('MemorySection');
-type AgentKind = 'claude-code' | 'codex';
+type AgentKind = 'claude-code' | 'codex' | 'pi';
interface AgentDescriptor {
kind: AgentKind;
/** 本地化展示用的稳定 key 段,与 i18n 表 settings.memory.agents.<key>.* 对齐。
品牌名 (Claude / Codex) 不翻译,由 i18n 表里的 label 字段提供。 */
Mark: () => ReactNode;
+ /** Pi 的压缩记忆写入 Cindy Memory;其开关仅在 Cindy Memory 启用时有意义。 */
+ requiresMaker?: boolean;
}
const AGENTS: readonly AgentDescriptor[] = [
@@ -46,6 +49,11 @@ const AGENTS: readonly AgentDescriptor[] = [
kind: 'codex',
Mark: () => <CodexMark size={18} className="text-[var(--settings-section-title)]" />,
},
+ {
+ kind: 'pi',
+ Mark: () => <PiMark size={18} className="text-[var(--settings-section-title)]" />,
+ requiresMaker: true,
+ },
] as const;
interface MemorySlotState {
@@ -68,6 +76,7 @@ export function MemorySection() {
const [slots, setSlots] = useState<Record<AgentKind, MemorySlotState>>({
'claude-code': INITIAL,
codex: INITIAL,
+ pi: INITIAL,
});
// pending 飞行中跳过 reload — 否则 toggle/reset 飞行期间 focus 触发 reload 会
// 把用户刚改的乐观值或回滚状态覆盖掉。任一 slot pending 都跳过整轮 reload。
@@ -336,7 +345,8 @@ export function MemorySection() {
const supported = slot.enabled !== null;
const loading = slot.enabled === undefined;
const checked = slot.enabled === true;
- const disabled = makerEnabled || !supported || slot.pending || loading;
+ const disabled = (agent.requiresMaker ? !makerEnabled : makerEnabled)
+ || !supported || slot.pending || loading;
// Agent label/description 来自 i18n 表 (品牌名 Claude / Codex 也走 i18n
// —— 各语种都保留品牌原文,只方便统一管理)。
const label = t(`settings.memory.agents.${agent.kind}.label`);
@@ -347,7 +357,7 @@ export function MemorySection() {
className={cn(
'flex items-center justify-between gap-3 px-4 py-[14px]',
'border-t border-[var(--settings-theme-card-border)]',
- makerEnabled && 'opacity-50',
+ (agent.requiresMaker ? !makerEnabled : makerEnabled) && 'opacity-50',
)}
>
<div className="flex items-center gap-3">
diff --git a/apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx b/apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx
index cee83e569b..8b734da3d1 100644
--- a/apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx
+++ b/apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx
@@ -189,7 +189,9 @@ export function SessionShareImportWizard({
// 导入语义 = 用本地草稿默认值新建会话(只有 agent 跟随分享包):把 New Maker
// 草稿里该 vendor 的偏好随 commit 传给 main,替代分享包 snapshot 的会话配置
// (导出方的模型/供应商在导入端不一定存在)。
- const vendor = preview?.agentKind === 'codex' ? 'codex' : 'cc';
+ const vendor = preview?.agentKind === 'codex' || preview?.agentKind === 'pi'
+ ? preview.agentKind
+ : 'cc';
const prefs = getDraft().lastByVendor[vendor];
const res = await window.electronAPI.localDb.sessionShare.commit({
draftId,
@@ -320,7 +322,11 @@ export function SessionShareImportWizard({
<p className="font-medium truncate">{preview.title}</p>
<p className="mt-1 text-xs text-[var(--text-tertiary)]">
{t('sessionShare.import.previewMeta', {
- agent: preview.agentKind === 'cc' ? 'Claude Code' : 'Codex',
+ agent: preview.agentKind === 'cc'
+ ? 'Claude Code'
+ : preview.agentKind === 'pi'
+ ? 'Pi'
+ : 'Codex',
count: preview.messageCount,
exportedAt: new Date(preview.exportedAt).toLocaleString(),
})}
diff --git a/apps/desktop/src/renderer/components/settings/hookWorkspacePrefsLogic.ts b/apps/desktop/src/renderer/components/settings/hookWorkspacePrefsLogic.ts
index 3e4c683d19..692c16aecb 100644
--- a/apps/desktop/src/renderer/components/settings/hookWorkspacePrefsLogic.ts
+++ b/apps/desktop/src/renderer/components/settings/hookWorkspacePrefsLogic.ts
@@ -24,7 +24,7 @@ import type { HookPrefsPatch, HookWorkspacePrefs } from '../../../shared/hookCon
* renderer 侧合法 agentKind 的单一来源(编辑器 UI 与本文件的归一化共用;与 main 侧
* 派发 defaults.ts 的 AGENT_KINDS 同口径 —— 进程边界两侧各持一份,新增 agent 时同步)。
*/
-export const AGENT_KINDS = ['claude-code', 'codex'] as const;
+export const AGENT_KINDS = ['claude-code', 'codex', 'pi'] as const;
export type KnownAgent = (typeof AGENT_KINDS)[number];
export function isKnownAgent(value: string | null): value is KnownAgent {
diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
index 6eb4eaf998..8cdb02288e 100644
--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
@@ -715,7 +715,7 @@ export function CCAgentSessionView({
const deviceId = remoteDeviceId;
const scopeKey = remoteModelMemoryScopeKey;
const agent = dbToMakerAgentKind(session?.agentKind);
- const vendorSlot = agent === 'codex' ? 'codex' : 'claudeCode';
+ const vendorSlot = agent === 'claude-code' ? 'claudeCode' : agent;
let cancelled = false;
const applySnapshot = (snapshot: RemoteModelMemorySnapshot | undefined) => {
@@ -2299,7 +2299,7 @@ export function CCAgentSessionView({
}
const createOpts = session?.workingDir
? {
- agentKind: 'claude-code' as const,
+ agentKind: session.agentKind === 'pi' ? 'pi' as const : 'claude-code' as const,
workingDir: session.workingDir,
model: session.model,
orcaRole: session.orcaRole ?? null,
@@ -2640,7 +2640,9 @@ export function CCAgentSessionView({
kind: 'usage-limit-recovery',
requestId,
sessionId,
- agentKind: session?.agentKind === 'codex' ? 'codex' : 'claude-code',
+ agentKind: session?.agentKind === 'codex' || session?.agentKind === 'pi'
+ ? session.agentKind
+ : 'claude-code',
resetAtMs: usageLimitRecovery.resetAtMs,
}),
});
diff --git a/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx b/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx
index a4bd5ffdc4..0aec6fc90c 100644
--- a/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx
@@ -1167,7 +1167,7 @@ export function NewMakerDraftRoute() {
// (驱动镜像 effect + 选中行还原)。控制端是纯显示,这里只更新显示态、不回写被控端。
useEffect(() => {
if (!isDeviceLinkDraft || !effectiveDeviceLinkDeviceId) return;
- const vendorSlot = capabilityAgentKind === 'codex' ? 'codex' : 'claudeCode';
+ const vendorSlot = capabilityAgentKind === 'claude-code' ? 'claudeCode' : capabilityAgentKind;
return window.electronAPI.deviceLink.onRemotePush((push) => {
if (push.deviceId !== effectiveDeviceLinkDeviceId) return;
if (push.channel !== 'maker:new-maker-draft:changed') return;
@@ -2449,10 +2449,10 @@ export function NewMakerDraftRoute() {
// agent 启动时看到的工作区已是迁移后的状态。fail-soft:检测错误只 warn,不阻塞 send。
try {
const wd = effectiveWorkingDir;
- if (wd && !isRemoteProjectDraft) {
+ if (wd && !isRemoteProjectDraft && persistedAgentKind !== 'pi') {
const r = await crossAgentConvertService.detect(
wd,
- persistedAgentKind === 'codex' ? 'codex' : 'claude-code',
+ persistedAgentKind === 'cc' ? 'claude-code' : persistedAgentKind,
);
if (r.items.length > 0) {
// 阻塞等弹窗关闭(用户点不要 / 完成转换 / 失败)—— 都视为流程结束
@@ -2521,7 +2521,7 @@ export function NewMakerDraftRoute() {
log.warn('[draft worktree send] touchUserSend failed', err);
});
makerChatStore.setSessionRuntime(newSession.id, {
- agentKind: persistedAgentKind === 'codex' ? 'codex' : 'claude-code',
+ agentKind: persistedAgentKind === 'cc' ? 'claude-code' : persistedAgentKind,
fastMode: effectiveFastMode,
planModeEnabled: effectivePlanMode,
});
@@ -3004,7 +3004,7 @@ export function NewMakerDraftRoute() {
// autoNameSession 对位:先立即用目标文案截断占位(Codex 式,侧边栏不停留在
// 'New Maker'),再经隧道生成智能标题窄口径覆盖。fire-and-forget;
// 覆盖前 re-read,仅在标题仍是占位/默认时落盘(用户手动改名 wins)。
- const titleAgentKind = persistedAgentKind === 'codex' ? 'codex' : 'claude-code';
+ const titleAgentKind = persistedAgentKind === 'cc' ? 'claude-code' : persistedAgentKind;
// 先折叠空白并 trim 再截断,避免前导空白吃满 40 字符得到空占位(PR #296 review)。
const placeholderTitle = objective.replace(/\s+/g, ' ').trim().slice(0, 40).trimEnd();
void (async () => {
diff --git a/apps/desktop/src/renderer/features/cc-agent/deviceLinkCreateArgs.ts b/apps/desktop/src/renderer/features/cc-agent/deviceLinkCreateArgs.ts
index 8d2c340578..755b6cbd87 100644
--- a/apps/desktop/src/renderer/features/cc-agent/deviceLinkCreateArgs.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/deviceLinkCreateArgs.ts
@@ -56,7 +56,7 @@ export interface DeviceLinkCreateParams {
}
export interface DeviceLinkCreateArgs {
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
/** 仅远程 worktree 流程出现(与 worktree:create 登记的绑定同 id)。 */
id?: string;
/** 仅项目会话出现;dialogue 不带此字段(被控端自行分配运行目录)。 */
@@ -78,7 +78,7 @@ export function buildDeviceLinkCreateArgs(p: DeviceLinkCreateParams): DeviceLink
// 免得 ' ' 这种脏值在被控端被当成一个真实路径去校验。
const dir = p.workingDir?.trim();
return {
- agentKind: p.agentKind === 'codex' ? 'codex' : 'claude-code',
+ agentKind: p.agentKind === 'cc' ? 'claude-code' : p.agentKind,
// 预生成 id 仅在远程 worktree 流程出现;不传时不放进 args,被控端自行生成。
...(p.id ? { id: p.id } : {}),
// 有目录 → 项目会话;无目录 → standalone dialogue,不带 workingDir,由被控端分配运行目录。
@@ -217,8 +217,8 @@ export function buildProvisionalRemoteSession(p: ProvisionalRemoteSessionParams)
// 侧边栏按这条时间轴排序,新会话该立刻浮到顶部。
userSendAt: p.nowIso,
status: 'active',
- // Session.agentKind 是本机形态('cc' | 'codex'),args 里是 maker-core 形态,这里转回来。
- agentKind: p.args.agentKind === 'codex' ? 'codex' : 'cc',
+ // Session.agentKind 是本机形态('cc' | 'codex' | 'pi'),args 里是 maker-core 形态,这里转回来。
+ agentKind: p.args.agentKind === 'claude-code' ? 'cc' : p.args.agentKind,
extraDirs: p.args.extraDirs ?? [],
createdAt: p.nowIso,
updatedAt: p.nowIso,
diff --git a/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx b/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx
index 45a69fc54d..57ade2beea 100644
--- a/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx
+++ b/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx
@@ -1146,7 +1146,7 @@ export function ModelEffortChip({
: t('scheduler.chips.model.default');
// railSources 仅用于 nativeDefault 归一化(下拉宽度由 ModelSelectorContent 内容自适应,见 w-auto)。
- const vendorKey = agentKind === 'codex' ? 'codex' : 'cc';
+ const vendorKey = agentKind === 'claude-code' ? 'cc' : agentKind;
const railSources = useMemo(
() => connectedProvidersForAgent(providers, agentKind),
[providers, agentKind],
@@ -1326,7 +1326,7 @@ export function ThreadPickerInline({ value, onSelect, onOpen, reference }: {
)}
{sessions.map((s) => (
<option key={s.id} value={s.id}>
- {s.title} · {s.agentKind === 'cc' ? 'Claude Code' : 'Codex'}
+ {s.title} · {s.agentKind === 'cc' ? 'Claude Code' : s.agentKind === 'pi' ? 'Pi' : 'Codex'}
</option>
))}
</select>
diff --git a/apps/desktop/src/renderer/features/scheduler/lib/usageLimitScheduleCreateIntent.ts b/apps/desktop/src/renderer/features/scheduler/lib/usageLimitScheduleCreateIntent.ts
index 14526e8e2d..d586d888ec 100644
--- a/apps/desktop/src/renderer/features/scheduler/lib/usageLimitScheduleCreateIntent.ts
+++ b/apps/desktop/src/renderer/features/scheduler/lib/usageLimitScheduleCreateIntent.ts
@@ -4,7 +4,7 @@ export interface UsageLimitScheduleCreateIntent {
kind: 'usage-limit-recovery';
requestId: string;
sessionId: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
resetAtMs: number | null;
}
@@ -32,7 +32,7 @@ export function readUsageLimitScheduleCreateIntent(
!value.requestId ||
typeof value.sessionId !== 'string' ||
!value.sessionId ||
- (value.agentKind !== 'claude-code' && value.agentKind !== 'codex') ||
+ (value.agentKind !== 'claude-code' && value.agentKind !== 'codex' && value.agentKind !== 'pi') ||
(value.resetAtMs !== null &&
(typeof value.resetAtMs !== 'number' || !Number.isFinite(value.resetAtMs)))
) {
diff --git a/apps/desktop/src/renderer/hooks/useMakerSession.ts b/apps/desktop/src/renderer/hooks/useMakerSession.ts
index bde8fa9e74..2e66605b97 100644
--- a/apps/desktop/src/renderer/hooks/useMakerSession.ts
+++ b/apps/desktop/src/renderer/hooks/useMakerSession.ts
@@ -15,13 +15,13 @@ interface MakerEvent {
interface SessionInfo {
sessionId: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workDir: string;
capabilities: unknown;
}
interface CreateSessionParams {
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workingDir: string;
model: string;
/** 与 maker-core/types/common.ts 的 Effort union 一致 */
diff --git a/apps/desktop/src/renderer/hooks/useVendorAuthGate.ts b/apps/desktop/src/renderer/hooks/useVendorAuthGate.ts
index 39550c86c8..f321c65257 100644
--- a/apps/desktop/src/renderer/hooks/useVendorAuthGate.ts
+++ b/apps/desktop/src/renderer/hooks/useVendorAuthGate.ts
@@ -50,7 +50,8 @@ type CopyKey =
| 'voice-api-key-unauth'
| 'voice-direct-api-key-unauth'
| 'codex-voice-unauth'
- | 'codex-binary-missing';
+ | 'codex-binary-missing'
+ | 'pi-binary-missing';
function buildCopy(t: (key: string) => string): Record<CopyKey, DialogCopy> {
return {
@@ -92,6 +93,13 @@ function buildCopy(t: (key: string) => string): Record<CopyKey, DialogCopy> {
cancelText: t('logic.confirm.cancel'),
settingsTab: 'providers',
},
+ 'pi-binary-missing': {
+ title: t('logic.confirm.piBinaryMissingTitle'),
+ description: t('logic.confirm.piBinaryMissingDescription'),
+ confirmText: t('logic.confirm.goToSettings'),
+ cancelText: t('logic.confirm.cancel'),
+ settingsTab: 'providers',
+ },
};
}
@@ -110,6 +118,7 @@ function pickCopy(
readiness: Readiness,
): DialogCopy | null {
if (readiness === 'binary-missing' && vendor === 'codex') return copy['codex-binary-missing'];
+ if (readiness === 'binary-missing' && vendor === 'pi') return copy['pi-binary-missing'];
if (readiness !== 'unauthenticated') return null;
// 无可用来源:cc / codex 走同一条「连接来源」文案(send 门禁,与 agent 类型无关)。
return copy['no-source'];
@@ -140,7 +149,7 @@ export function deriveRemoteReadiness(
},
): Readiness {
if (vendor !== 'cc' && input.binaryReady === false) {
- return vendor === 'codex' ? 'binary-missing' : 'unauthenticated';
+ return 'binary-missing';
}
if (input.sourceReady !== null) return input.sourceReady ? 'ready' : 'unauthenticated';
if (input.authReady !== null) return input.authReady ? 'ready' : 'unauthenticated';
@@ -262,7 +271,9 @@ export function useVendorAuthGate(): UseVendorAuthGateReturn {
let title: string;
let description: string;
if (remoteReadiness === 'binary-missing') {
- title = t('logic.confirm.remoteCodexBinaryMissingTitle');
+ title = t(vendor === 'pi'
+ ? 'logic.confirm.remotePiBinaryMissingTitle'
+ : 'logic.confirm.remoteCodexBinaryMissingTitle');
description = t('logic.confirm.remoteAuthDescription', { device });
} else if (vendor === 'codex') {
title = t('logic.confirm.remoteCodexNoSourceTitle');
diff --git a/apps/desktop/src/renderer/hooks/useVendorReadiness.ts b/apps/desktop/src/renderer/hooks/useVendorReadiness.ts
index 309fea09f6..6daac49112 100644
--- a/apps/desktop/src/renderer/hooks/useVendorReadiness.ts
+++ b/apps/desktop/src/renderer/hooks/useVendorReadiness.ts
@@ -19,6 +19,17 @@ import { connectedProvidersForAgent, type AgentKind, type ProviderView } from '@
export type Readiness = 'ready' | 'unauthenticated' | 'binary-missing' | 'loading';
+/**
+ * Codex 与 Pi 都依赖随应用分发的本地运行时。二进制缺失和模型来源未连接是
+ * 两种不同的恢复路径,不能把 Pi 的缺包状态伪装成未授权。
+ */
+export function readinessFromBinaryStatus(
+ vendorKey: 'cc' | 'codex' | 'pi',
+ binaryReady: boolean,
+): Readiness | null {
+ return vendorKey !== 'cc' && !binaryReady ? 'binary-missing' : null;
+}
+
export function useVendorReadiness(vendorKey: 'cc' | 'codex' | 'pi'): {
readiness: Readiness;
revalidate: (opts?: { includeSuspended?: boolean }) => Promise<Readiness>;
@@ -38,8 +49,8 @@ export function useVendorReadiness(vendorKey: 'cc' | 'codex' | 'pi'): {
binaryReady: boolean;
authReady: boolean;
};
- if (!status.binaryReady) {
- const missing: Readiness = vendorKey === 'codex' ? 'binary-missing' : 'unauthenticated';
+ const missing = readinessFromBinaryStatus(vendorKey, status.binaryReady);
+ if (missing) {
setReadiness(missing);
return missing;
}
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index c54e392405..50c0d00a32 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -2006,6 +2006,10 @@
"codex": {
"label": "Codex",
"description": "All models used through the Codex entry share the same memory."
+ },
+ "pi": {
+ "label": "Pi",
+ "description": "Saves long-session compression summaries to Cindy memory for future Pi sessions."
}
},
"agent": {
@@ -5862,6 +5866,8 @@
"remoteProviderUnsupported": "This provider is not supported in SSH remote sessions — pick another source",
"remoteNativeOauthUnavailable": "Claude.ai subscription is not connected — connect it first or pick a gateway model",
"deviceStillLoading": "Remote device is still loading, please wait",
+ "worktreeMissingRepo": "Unable to create worktree: the repository root for the current directory is unavailable",
+ "worktreeRepoHint": "Try selecting the working directory again and wait for the folder indicator in the lower-right corner to refresh",
"sessionInactive": "Session is no longer active",
"remoteProjectBanner": "New session in {{project}} on {{device}}",
"remoteDialogueBanner": "New chat on {{device}} (no project)"
@@ -7849,8 +7855,11 @@
"codexVoiceAuthDescription": "Voice input uses a connected ChatGPT account for GPT realtime speech recognition. The account is not connected or needs an update. Open Model Providers to connect ChatGPT?",
"codexBinaryMissingTitle": "Codex component not ready",
"codexBinaryMissingDescription": "The Codex component is not ready yet, so this feature cannot be used. Try again later or check the Codex connection in Settings → Providers.",
+ "piBinaryMissingTitle": "Pi component not ready",
+ "piBinaryMissingDescription": "The Pi component is not ready yet, so this feature cannot be used. Try again later or check the Pi connection in Settings → Providers.",
"goToSettings": "Open Settings",
"remoteCodexBinaryMissingTitle": "Codex component not ready on the remote device",
+ "remotePiBinaryMissingTitle": "Pi component not ready on the remote device",
"remoteAuthDescription": "You need to finish setup on the controlled device \"{{device}}\" before you can start a session here. Configure it on that device and try again.",
"remoteCodexNoSourceTitle": "No Codex source connected on the remote device",
"remoteCodexNoSourceDescription": "\"{{device}}\" has no model source connected for Codex, so sessions can't be started from here. Open {{appName}} on that device, sign in to OpenAI or connect another source under Settings → Providers, then try again.",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index c8b7cd25a8..a481b0cf64 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -2005,6 +2005,10 @@
"codex": {
"label": "Codex",
"description": "Codex の入口から使用するすべてのモデルで、同じメモリを共有します"
+ },
+ "pi": {
+ "label": "Pi",
+ "description": "長いセッションの圧縮要約を Cindy メモリに保存し、今後の Pi セッションで利用します"
}
},
"agent": {
@@ -5851,6 +5855,8 @@
"remoteProviderUnsupported": "このプロバイダーは SSH リモートセッションに対応していません。別のソースを選択してください",
"remoteNativeOauthUnavailable": "Claude.ai サブスクリプションが未接続です。先に接続するか、ゲートウェイモデルを選択してください",
"deviceStillLoading": "リモートデバイスの読み込み中です。しばらくお待ちください",
+ "worktreeMissingRepo": "worktree を作成できません:現在のディレクトリのリポジトリルートが見つかりません",
+ "worktreeRepoHint": "作業ディレクトリを選び直し、右下のフォルダー表示が更新されてから再試行してください",
"sessionInactive": "セッションはすでにアクティブではありません",
"remoteProjectBanner": "{{device}} の {{project}} で新しいセッションを作成",
"remoteDialogueBanner": "{{device}} で新しい対話(プロジェクトなし)"
@@ -7837,8 +7843,11 @@
"codexVoiceAuthDescription": "音声入力は、接続済みの ChatGPT アカウントで GPT リアルタイム音声認識を使用します。アカウントが未接続か、接続の更新が必要です。モデルプロバイダーを開いて ChatGPT に接続しますか?",
"codexBinaryMissingTitle": "Codex コンポーネントの準備ができていません",
"codexBinaryMissingDescription": "Codex コンポーネントの準備がまだできていないため、この機能は使用できません。しばらくしてから再試行するか、「設定 → プロバイダー」で Codex の接続状態を確認してください。",
+ "piBinaryMissingTitle": "Pi コンポーネントの準備ができていません",
+ "piBinaryMissingDescription": "Pi コンポーネントの準備がまだできていないため、この機能は使用できません。しばらくしてから再試行するか、「設定 → プロバイダー」で Pi の接続状態を確認してください。",
"goToSettings": "設定を開く",
"remoteCodexBinaryMissingTitle": "リモートデバイスの Codex コンポーネントが未準備です",
+ "remotePiBinaryMissingTitle": "リモートデバイスの Pi コンポーネントが未準備です",
"remoteAuthDescription": "操作対象のデバイス「{{device}}」で設定を完了してから、ここでセッションを開始できます。そのデバイスで設定してから再試行してください。",
"remoteCodexNoSourceTitle": "リモートデバイスに利用可能な Codex ソースがありません",
"remoteCodexNoSourceDescription": "デバイス「{{device}}」には Codex で利用可能なモデルソースが接続されていないため、ここからセッションを開始できません。そのデバイスで {{appName}} を開き、「設定 → プロバイダー」で OpenAI にログインするか他のソースを接続してから再試行してください。",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 84664d0077..c46aca37d9 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -2005,6 +2005,10 @@
"codex": {
"label": "Codex",
"description": "Codex 입구를 통해 사용하는 모든 모델이 같은 메모리를 공유합니다"
+ },
+ "pi": {
+ "label": "Pi",
+ "description": "긴 세션의 압축 요약을 Cindy 메모리에 저장해 이후 Pi 세션에서 사용합니다"
}
},
"agent": {
@@ -5851,6 +5855,8 @@
"remoteProviderUnsupported": "이 제공자는 SSH 원격 세션을 지원하지 않습니다. 다른 소스를 선택하세요",
"remoteNativeOauthUnavailable": "Claude.ai 구독이 연결되지 않았습니다. 먼저 연결하거나 게이트웨이 모델을 선택하세요",
"deviceStillLoading": "원격 기기가 아직 로딩 중입니다. 잠시 기다려 주세요",
+ "worktreeMissingRepo": "worktree를 만들 수 없습니다: 현재 디렉터리의 저장소 루트를 찾을 수 없습니다",
+ "worktreeRepoHint": "작업 디렉터리를 다시 선택하고 오른쪽 아래 폴더 표시가 새로 고쳐진 뒤 다시 시도하세요",
"sessionInactive": "세션이 더 이상 활성 상태가 아닙니다",
"remoteProjectBanner": "{{device}}의 {{project}}에서 새 세션 만들기",
"remoteDialogueBanner": "{{device}}에서 새 대화(프로젝트 없음)"
@@ -7837,8 +7843,11 @@
"codexVoiceAuthDescription": "음성 입력은 연결된 ChatGPT 계정으로 GPT 실시간 음성 인식을 사용합니다. 계정이 연결되지 않았거나 연결을 업데이트해야 합니다. 모델 제공자를 열어 ChatGPT를 연결하시겠습니까?",
"codexBinaryMissingTitle": "Codex 구성 요소가 준비되지 않음",
"codexBinaryMissingDescription": "Codex 구성 요소가 아직 준비되지 않아 이 기능을 사용할 수 없습니다. 잠시 후 다시 시도하거나 설정 → 제공자에서 Codex 연결 상태를 확인하세요.",
+ "piBinaryMissingTitle": "Pi 구성 요소가 준비되지 않음",
+ "piBinaryMissingDescription": "Pi 구성 요소가 아직 준비되지 않아 이 기능을 사용할 수 없습니다. 잠시 후 다시 시도하거나 설정 → 제공자에서 Pi 연결 상태를 확인하세요.",
"goToSettings": "설정 열기",
"remoteCodexBinaryMissingTitle": "원격 기기의 Codex 구성 요소가 준비되지 않음",
+ "remotePiBinaryMissingTitle": "원격 기기의 Pi 구성 요소가 준비되지 않음",
"remoteAuthDescription": "원격 기기 \"{{device}}\"에서 설정을 완료해야 여기에서 세션을 시작할 수 있습니다. 해당 기기에서 설정한 후 다시 시도하세요.",
"remoteCodexNoSourceTitle": "원격 기기에 연결된 Codex 소스가 없습니다",
"remoteCodexNoSourceDescription": "원격 기기 \"{{device}}\"에 Codex에서 사용할 수 있는 모델 소스가 연결되어 있지 않아 여기에서 세션을 시작할 수 없습니다. 해당 기기에서 {{appName}}를 열고 설정 → 제공자에서 OpenAI에 로그인하거나 다른 소스를 연결한 후 다시 시도하세요.",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index f4e3bffec8..43edcce27f 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -2005,6 +2005,10 @@
"codex": {
"label": "Codex",
"description": "通过 Codex 入口使用的所有模型,会共享同一份记忆"
+ },
+ "pi": {
+ "label": "Pi",
+ "description": "将长会话压缩摘要保存到 Cindy 记忆,供后续 Pi 会话继续使用"
}
},
"agent": {
@@ -7839,8 +7843,11 @@
"codexVoiceAuthDescription": "语音输入需要使用已连接的 ChatGPT 账号调用 GPT 实时语音识别。当前账号尚未连接或需要更新,是否前往「模型供应商」连接 ChatGPT?",
"codexBinaryMissingTitle": "Codex 组件未就绪",
"codexBinaryMissingDescription": "Codex 组件尚未准备好,暂时无法使用这个功能。请稍后重试,或前往「模型供应商」检查 Codex 连接状态。",
+ "piBinaryMissingTitle": "Pi 组件未就绪",
+ "piBinaryMissingDescription": "Pi 组件尚未准备好,暂时无法使用这个功能。请稍后重试,或前往「模型供应商」检查 Pi 连接状态。",
"goToSettings": "前往设置",
"remoteCodexBinaryMissingTitle": "被控端 Codex 组件未就绪",
+ "remotePiBinaryMissingTitle": "被控端 Pi 组件未就绪",
"remoteAuthDescription": "需要在被控设备「{{device}}」上完成配置后,才能在这里新建并运行任务。请在该设备上配置后重试。",
"remoteCodexNoSourceTitle": "被控端 Codex 暂无可用来源",
"remoteCodexNoSourceDescription": "被控设备「{{device}}」尚未连接 Codex 可用的模型来源,无法在这里新建并运行任务。请在该设备上打开 {{appName}},在「设置 → 模型供应商」登录 OpenAI 或连接其他来源后重试。",
diff --git a/apps/desktop/src/renderer/lib/ccAgent.types.ts b/apps/desktop/src/renderer/lib/ccAgent.types.ts
index 1c5e7f87ad..9c237e1a8a 100644
--- a/apps/desktop/src/renderer/lib/ccAgent.types.ts
+++ b/apps/desktop/src/renderer/lib/ccAgent.types.ts
@@ -311,8 +311,8 @@ export type MessageRole = 'user' | 'assistant' | 'tool_use' | 'tool_result' | 'a
* 不作为对话正文渲染,也绝不回发给 agent(注入走 main 的 wire 前缀通道)。
*/
export interface AgentSwitchContent {
- fromAgentKind: 'cc' | 'codex';
- toAgentKind: 'cc' | 'codex';
+ fromAgentKind: 'cc' | 'codex' | 'pi';
+ toAgentKind: 'cc' | 'codex' | 'pi';
fromModel: string | null;
toModel: string | null;
handoff: string;
diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.ts
index 07da46f9a4..922e782482 100644
--- a/apps/desktop/src/renderer/vite-env.d.ts
+++ b/apps/desktop/src/renderer/vite-env.d.ts
@@ -4388,7 +4388,7 @@ interface ElectronAPI {
effective: 'immediate' | 'next-session';
isCustomized: boolean;
customizedKeys: string[];
- defaults: { maker: boolean; claudeCode: boolean; codex: boolean };
+ defaults: { maker: boolean; claudeCode: boolean; codex: boolean; pi: boolean };
}>;
memoryReset: (agentKind: 'claude-code' | 'codex' | 'pi') => Promise<{
removedEntries?: number;
@@ -4403,7 +4403,7 @@ interface ElectronAPI {
effective: 'next-session';
isCustomized: boolean;
customizedKeys: string[];
- defaults: { maker: boolean; claudeCode: boolean; codex: boolean };
+ defaults: { maker: boolean; claudeCode: boolean; codex: boolean; pi: boolean };
/** true = Codex 正忙, 存活会话的软重启在任务结束后自动补做 (设置已生效) */
codexRestartDeferred: boolean;
}>;
@@ -4412,28 +4412,31 @@ interface ElectronAPI {
makerMemoryReset: () => Promise<{ removedCount: number }>;
/** 启动期拉 main 持久化的三个 memory 开关 — 见 preload memoryGetSettings 注释 */
- memoryGetSettings: () => Promise<{ maker: boolean; claudeCode: boolean; codex: boolean }>;
+ memoryGetSettings: () => Promise<{ maker: boolean; claudeCode: boolean; codex: boolean; pi: boolean }>;
memoryGetSettingsState: () => Promise<{
maker: boolean;
claudeCode: boolean;
codex: boolean;
+ pi: boolean;
isCustomized: boolean;
customizedKeys: string[];
- defaults: { maker: boolean; claudeCode: boolean; codex: boolean };
+ defaults: { maker: boolean; claudeCode: boolean; codex: boolean; pi: boolean };
}>;
/** 启动期迁移旧版 renderer/native memory opt-out;null 表示 renderer marker 缺失。 */
memoryPreserveLegacyMakerDisabled: (legacyRendererValue: boolean | null) => Promise<{
maker: boolean;
claudeCode: boolean;
codex: boolean;
+ pi: boolean;
}>;
memoryResetSettings: () => Promise<{
maker: boolean;
claudeCode: boolean;
codex: boolean;
+ pi: boolean;
isCustomized: boolean;
customizedKeys: string[];
- defaults: { maker: boolean; claudeCode: boolean; codex: boolean };
+ defaults: { maker: boolean; claudeCode: boolean; codex: boolean; pi: boolean };
/** true = Codex 正忙, 存活会话的软重启在任务结束后自动补做 (设置已生效) */
codexRestartDeferred: boolean;
}>;
diff --git a/apps/desktop/src/shared/imDefaultSettings.ts b/apps/desktop/src/shared/imDefaultSettings.ts
index 4f1f2181d1..cb6e9c5c54 100644
--- a/apps/desktop/src/shared/imDefaultSettings.ts
+++ b/apps/desktop/src/shared/imDefaultSettings.ts
@@ -48,7 +48,7 @@ export const IM_DEFAULT_SETTINGS: ImDefaultSettings = {
model: 'codex/gpt-5.5',
effort: 'high',
},
- // pi(实验性):IM 渠道设置 UI 尚未暴露 pi,此项仅满足满射类型;走网关中档模型。
+ // Pi 走网关中档模型作为 IM 新会话默认值,可在各渠道设置中覆盖。
pi: {
providerId: null,
model: 'claude-sonnet-5',
@@ -71,7 +71,7 @@ export const IM_DEFAULT_EFFORT_OVERRIDES: Readonly<Partial<Record<string, ImDefa
'codex/gpt-5.5': 'high',
};
-const AGENT_KINDS = new Set<ImDefaultAgentKind>(['claude-code', 'codex']);
+const AGENT_KINDS = new Set<ImDefaultAgentKind>(['claude-code', 'codex', 'pi']);
const EFFORTS = new Set<ImDefaultEffort>([
'minimal',
'low',
diff --git a/apps/mobile/src/__tests__/homeDesktopFirst.test.ts b/apps/mobile/src/__tests__/homeDesktopFirst.test.ts
index 91973312b5..ab00b3d239 100644
--- a/apps/mobile/src/__tests__/homeDesktopFirst.test.ts
+++ b/apps/mobile/src/__tests__/homeDesktopFirst.test.ts
@@ -144,7 +144,7 @@ describe('mobile home desktop-first surface', () => {
expect(providerMarkSource).not.toContain('CLAUDE_AGENT_PATH');
expect(providerMarkSource).not.toContain('CODEX_AGENT_FLOWER_PATH');
expect(vendorIconSource).toContain("import { MobileAgentMark } from './MobileAgentMark';");
- expect(vendorIconSource).toContain("agentKind={vendor === 'codex' ? 'codex' : 'claude-code'}");
+ expect(vendorIconSource).toContain("agentKind={vendor === 'codex' || vendor === 'pi' ? vendor : 'claude-code'}");
expect(vendorIconSource).not.toContain('viewBox="136 137 282 158"');
expect(vendorIconSource).not.toContain('transform="translate(');
expect(vendorIconSource).toContain('Easing.inOut(Easing.ease)');
diff --git a/apps/mobile/src/__tests__/sessionAgentSwitch.test.ts b/apps/mobile/src/__tests__/sessionAgentSwitch.test.ts
index f0e1d82821..7f118d6e37 100644
--- a/apps/mobile/src/__tests__/sessionAgentSwitch.test.ts
+++ b/apps/mobile/src/__tests__/sessionAgentSwitch.test.ts
@@ -42,8 +42,13 @@ describe('mobile session Agent switch contract', () => {
it('maps DB Agent kinds and labels consistently', () => {
expect(sessionAgentKind({ agentKind: 'cc' })).toBe('claude-code');
expect(sessionAgentKind({ agentKind: 'codex' })).toBe('codex');
+ expect(sessionAgentKind({ agentKind: 'pi' })).toBe('pi');
expect(mobileAgentLabel('claude-code')).toBe('Claude Code');
expect(mobileAgentLabel('codex')).toBe('Codex');
+ expect(mobileAgentLabel('pi')).toBe('Pi');
+ expect(normalizeSessionAgentSwitchIntent({
+ targetAgentKind: 'pi', model: 'gpt-5.5', providerId: 'openai',
+ })).toEqual({ targetAgentKind: 'pi', model: 'gpt-5.5', providerId: 'openai' });
});
it('requires host capability and excludes SSH / Orca sessions', () => {
diff --git a/apps/mobile/src/components/MobileAgentMark.tsx b/apps/mobile/src/components/MobileAgentMark.tsx
index 7a046ef996..565592aba9 100644
--- a/apps/mobile/src/components/MobileAgentMark.tsx
+++ b/apps/mobile/src/components/MobileAgentMark.tsx
@@ -2,7 +2,7 @@
* MobileAgentMark —— Claude Code / Codex CLI 的 Agent 身份 mark。
* 不用于 Anthropic / OpenAI provider 或模型品牌;后两者由 MobileProviderMark 负责。
*/
-import Svg, { G, Path } from 'react-native-svg';
+import Svg, { G, Path, Text as SvgText } from 'react-native-svg';
import { StyleSheet } from 'react-native';
import { iconSize, iconStroke } from '@/theme';
@@ -14,7 +14,7 @@ import {
} from './vendorIconPaths';
export interface MobileAgentMarkProps {
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
color: string;
size?: number;
}
@@ -24,7 +24,9 @@ export function MobileAgentMark({ agentKind, color, size = iconSize.sm }: Mobile
const codexStrokeWidth = size <= iconSize.sm ? iconStroke.regular : iconStroke.thin;
return (
<Svg accessible={false} height={size} viewBox="0 0 24 24" width={size}>
- {agentKind === 'codex' ? (
+ {agentKind === 'pi' ? (
+ <SvgText fill={color} fontSize="19" fontWeight="600" textAnchor="middle" x="12" y="18">π</SvgText>
+ ) : agentKind === 'codex' ? (
<G transform="translate(12 12) scale(1.1) translate(-12 -12)">
<Path
d={`${CODEX_AGENT_FLOWER_PATH}z`}
diff --git a/apps/mobile/src/components/MobileVendorIcon.tsx b/apps/mobile/src/components/MobileVendorIcon.tsx
index 6f086ea593..cf0b734b72 100644
--- a/apps/mobile/src/components/MobileVendorIcon.tsx
+++ b/apps/mobile/src/components/MobileVendorIcon.tsx
@@ -48,12 +48,12 @@ export function MobileVendorIcon({ color: colorOverride, running = false, size =
return (
<Animated.View
accessible
- accessibilityLabel={vendor === 'codex' ? 'Codex' : 'Claude Code'}
+ accessibilityLabel={vendor === 'codex' ? 'Codex' : vendor === 'pi' ? 'Pi' : 'Claude Code'}
accessibilityRole="image"
style={{ alignItems: 'center', height: size, justifyContent: 'center', opacity, width: size }}
>
<MobileAgentMark
- agentKind={vendor === 'codex' ? 'codex' : 'claude-code'}
+ agentKind={vendor === 'codex' || vendor === 'pi' ? vendor : 'claude-code'}
color={color}
size={size}
/>
diff --git a/apps/mobile/src/device-link/DeviceLinkContext.tsx b/apps/mobile/src/device-link/DeviceLinkContext.tsx
index 010334886c..86d58e9ad0 100644
--- a/apps/mobile/src/device-link/DeviceLinkContext.tsx
+++ b/apps/mobile/src/device-link/DeviceLinkContext.tsx
@@ -969,14 +969,14 @@ function routeFrame(env: Envelope, handlers: {
remoteSessionStore.applyRemotePush(env.src, push.channel, push.payload);
}
-/** provider revision 后并行重拉两种 agent 的能力;旧代或异常结果都不触碰当前页面。 */
+/** provider revision 后并行重拉所有 agent 的能力;旧代或异常结果都不触碰当前页面。 */
async function refreshDeviceCapabilities(
client: DeviceLinkClient,
deviceId: string,
): Promise<void> {
const generation = getAgentCapabilitiesGeneration(deviceId);
await Promise.allSettled(
- (['claude-code', 'codex'] as const).map(async (agentKind) => {
+ (['claude-code', 'codex', 'pi'] as const).map(async (agentKind) => {
const raw = await sendInvokeWithAccessHandling<unknown>(
client,
deviceId,
diff --git a/apps/mobile/src/device-link/mobileMakerTransport.ts b/apps/mobile/src/device-link/mobileMakerTransport.ts
index 5c8f61ea75..d7d5ea325a 100644
--- a/apps/mobile/src/device-link/mobileMakerTransport.ts
+++ b/apps/mobile/src/device-link/mobileMakerTransport.ts
@@ -58,7 +58,7 @@ export interface SendOptions {
}
export interface CreateSessionOptions {
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
/**
* 控制端预生成的 sessionId(新建会话乐观管线用):被控端 readCreateSessionOpts
* 自手机远控首版(2026-06-21)起透传 body.id,maker-core createSession 对
diff --git a/apps/mobile/src/session/MobileAgentSwitcher.tsx b/apps/mobile/src/session/MobileAgentSwitcher.tsx
index aa829c8519..c8c3bf0bbe 100644
--- a/apps/mobile/src/session/MobileAgentSwitcher.tsx
+++ b/apps/mobile/src/session/MobileAgentSwitcher.tsx
@@ -1,5 +1,5 @@
/**
- * ModelPickerSheet 顶部的 Claude / Codex 两段 Agent 浏览器。
+ * ModelPickerSheet 顶部的 Agent 浏览器。
* 切段只改变正在浏览的模型目录;选中目标模型后才登记切换意图。
*/
import { useState } from 'react';
@@ -16,6 +16,7 @@ import type { MobileSessionAgentKind } from './sessionAgentSwitch';
const AGENTS: readonly { kind: MobileSessionAgentKind; label: string }[] = [
{ kind: 'claude-code', label: 'Claude' },
{ kind: 'codex', label: 'Codex' },
+ { kind: 'pi', label: 'Pi' },
];
const makeStyles = (colors: ThemeColors) => StyleSheet.create({
diff --git a/apps/mobile/src/session/agentAuthGate.ts b/apps/mobile/src/session/agentAuthGate.ts
index efb3f4d5e3..1426e2dc36 100644
--- a/apps/mobile/src/session/agentAuthGate.ts
+++ b/apps/mobile/src/session/agentAuthGate.ts
@@ -24,7 +24,7 @@ export interface AgentAuthGateInput {
loading: boolean;
/** 目录拉取失败(典型:旧被控端不识别通道)。 */
error: string | null;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
/**
* true = 已建会话的发送门禁:计入 suspended 来源(停用是准入轴,不打断运行中
* 会话,门禁只回答「凭证还连着吗」)。缺省 false = 新建草稿:suspended 不算可
@@ -45,7 +45,7 @@ export function agentAuthGateVerdict(input: AgentAuthGateInput): AgentAuthGateVe
}
/** 未鉴权时的提示文案(与 describeAgentAuthError 的引导口径一致)。 */
-export function agentAuthGateHint(agentKind: 'claude-code' | 'codex'): string {
- const label = agentKind === 'claude-code' ? 'Claude' : 'Codex';
+export function agentAuthGateHint(agentKind: 'claude-code' | 'codex' | 'pi'): string {
+ const label = agentKind === 'claude-code' ? 'Claude' : agentKind === 'pi' ? 'Pi' : 'Codex';
return i18n.t('session.row.authGateHint', { agent: label });
}
diff --git a/apps/mobile/src/session/composerPalette.ts b/apps/mobile/src/session/composerPalette.ts
index afa3f68e7d..f45f62d595 100644
--- a/apps/mobile/src/session/composerPalette.ts
+++ b/apps/mobile/src/session/composerPalette.ts
@@ -2,6 +2,6 @@ import type { RemoteSession } from './types';
export * from '@cindy/maker-shared/composer-palette';
-export function agentKindForSession(session: Pick<RemoteSession, 'agentKind'>): 'claude-code' | 'codex' {
- return session.agentKind === 'codex' ? 'codex' : 'claude-code';
+export function agentKindForSession(session: Pick<RemoteSession, 'agentKind'>): 'claude-code' | 'codex' | 'pi' {
+ return session.agentKind === 'codex' || session.agentKind === 'pi' ? session.agentKind : 'claude-code';
}
diff --git a/apps/mobile/src/session/inputProjection.ts b/apps/mobile/src/session/inputProjection.ts
index c5345723a2..34e61e099e 100644
--- a/apps/mobile/src/session/inputProjection.ts
+++ b/apps/mobile/src/session/inputProjection.ts
@@ -102,7 +102,9 @@ export function buildQueuedTextMessage(
const workingDir = session.workingDir || '';
const effort = session.effort || '';
const permissionMode = permissionModeOrAsk(session.permissionMode);
- const agentKind = session.agentKind === 'codex' ? 'codex' : 'claude-code';
+ const agentKind = session.agentKind === 'codex' || session.agentKind === 'pi'
+ ? session.agentKind
+ : 'claude-code';
const persistedContent = stringifyUserContent(
trimmed,
persistedImageRefs,
diff --git a/apps/mobile/src/session/mobileHomeListCache.ts b/apps/mobile/src/session/mobileHomeListCache.ts
index a0335b56e1..d3a11a3aa5 100644
--- a/apps/mobile/src/session/mobileHomeListCache.ts
+++ b/apps/mobile/src/session/mobileHomeListCache.ts
@@ -208,7 +208,7 @@ function coerceCachedSession(item: unknown): RemoteSession | null {
permissionMode: typeof item.permissionMode === 'string' ? item.permissionMode : '',
fastMode: item.fastMode === true,
status,
- agentKind: item.agentKind === 'codex' ? 'codex' : 'cc',
+ agentKind: item.agentKind === 'codex' || item.agentKind === 'pi' ? item.agentKind : 'cc',
userSendAt: typeof item.userSendAt === 'string' ? item.userSendAt : null,
createdAt,
updatedAt: typeof item.updatedAt === 'string' ? item.updatedAt : createdAt,
diff --git a/apps/mobile/src/session/newSession.ts b/apps/mobile/src/session/newSession.ts
index 9392a7919e..e3a6803a24 100644
--- a/apps/mobile/src/session/newSession.ts
+++ b/apps/mobile/src/session/newSession.ts
@@ -4,7 +4,7 @@ import type { CreateSessionOptions, RemoteDirectoryEntry } from '@/device-link/m
import { reconcileEffortForModel, type ProviderModelRow } from './providerModelSections';
import type { RemoteSession } from './types';
-export type NewSessionAgentKind = 'claude-code' | 'codex';
+export type NewSessionAgentKind = 'claude-code' | 'codex' | 'pi';
export type NewSessionWorkspaceKind = 'project' | 'dialogue';
export interface NewSessionDraft {
@@ -90,7 +90,7 @@ export function parseNewSessionDeviceOptions(
}
export function normalizeNewSessionAgentKind(value: unknown): NewSessionAgentKind | null {
- return value === 'claude-code' || value === 'codex' ? value : null;
+ return value === 'claude-code' || value === 'codex' || value === 'pi' ? value : null;
}
export function pickNewSessionDefaultDevice(input: {
@@ -124,6 +124,7 @@ export const DEFAULT_NEW_SESSION_DRAFT: NewSessionDraft = {
const DEFAULT_MODELS: Record<NewSessionAgentKind, string> = {
'claude-code': 'claude-sonnet-4-6',
codex: 'gpt-5.4',
+ pi: 'gpt-5.4',
};
/** 新建交互式会话的权限种子默认;两种 agent 都保留 Auto-review。 */
@@ -180,7 +181,7 @@ export function summarizeNewSessionDraft(
content: NewSessionDraftContentState = {},
): NewSessionDraftSummary {
const validationMessage = validateNewSessionDraft(draft, content);
- const agentLabel = draft.agentKind === 'codex' ? 'Codex' : 'Claude';
+ const agentLabel = draft.agentKind === 'codex' ? 'Codex' : draft.agentKind === 'pi' ? 'Pi' : 'Claude';
const model = draft.model.trim() || i18n.t('session.new.noModelSelected');
const effort = draft.effort.trim();
const workspaceLabel = draft.workspaceKind === 'dialogue'
@@ -301,7 +302,9 @@ export function pickMostRecentSessionRuntime(
const model = session.model?.trim();
if (!model) continue;
if (options.deviceId && session.deviceLinkDeviceId && session.deviceLinkDeviceId !== options.deviceId) continue;
- const agentKind: NewSessionAgentKind = session.agentKind === 'codex' ? 'codex' : 'claude-code';
+ const agentKind: NewSessionAgentKind = session.agentKind === 'codex' || session.agentKind === 'pi'
+ ? session.agentKind
+ : 'claude-code';
if (options.agentKind && agentKind !== options.agentKind) continue;
const activityAt = session.userSendAt ?? session.updatedAt ?? session.createdAt;
if (!best || activityAt.localeCompare(best.activityAt) > 0) {
@@ -465,7 +468,7 @@ export function sessionFromCreateResult(
permissionMode: fallback.permissionMode,
fastMode: fallback.fastMode,
status: 'active',
- agentKind: fallback.agentKind === 'codex' ? 'codex' : 'cc',
+ agentKind: fallback.agentKind === 'claude-code' ? 'cc' : fallback.agentKind,
userSendAt: iso,
createdAt: iso,
updatedAt: iso,
diff --git a/apps/mobile/src/session/newSessionPreferenceStore.ts b/apps/mobile/src/session/newSessionPreferenceStore.ts
index 632731c03b..bd461241ac 100644
--- a/apps/mobile/src/session/newSessionPreferenceStore.ts
+++ b/apps/mobile/src/session/newSessionPreferenceStore.ts
@@ -62,7 +62,7 @@ function normalizePermissionModeByAgent(value: unknown): Partial<Record<NewSessi
const record = readRecord(value);
if (!record) return {};
const out: Partial<Record<NewSessionAgentKind, string>> = {};
- for (const agent of ['claude-code', 'codex'] as const) {
+ for (const agent of ['claude-code', 'codex', 'pi'] as const) {
const mode = readString(record[agent]);
if (mode && isRememberablePermissionMode(mode)) {
out[agent] = mode;
diff --git a/apps/mobile/src/session/remoteSessionStore.ts b/apps/mobile/src/session/remoteSessionStore.ts
index f771baab08..34d653a448 100644
--- a/apps/mobile/src/session/remoteSessionStore.ts
+++ b/apps/mobile/src/session/remoteSessionStore.ts
@@ -1175,7 +1175,7 @@ function sweepStaleTaskUpdates(sessionId: string): boolean {
function recallParkedTaskUpdates(
sessionId: string,
data: unknown,
- source: 'claude-code' | 'codex' | undefined,
+ source: 'claude-code' | 'codex' | 'pi' | undefined,
prevMap: ReadonlyMap<string, AgentTaskUpdate> | undefined,
): ReadonlyMap<string, AgentTaskUpdate> | undefined {
const parkedMap = sessionParkedTaskUpdates.get(sessionId);
diff --git a/apps/mobile/src/session/sessionAgentSwitch.ts b/apps/mobile/src/session/sessionAgentSwitch.ts
index 764d3cb972..b27542cbb3 100644
--- a/apps/mobile/src/session/sessionAgentSwitch.ts
+++ b/apps/mobile/src/session/sessionAgentSwitch.ts
@@ -9,7 +9,7 @@ import type {
import type { MobileAgentCapabilities } from './agentCapabilities';
import type { RemoteSession } from './types';
-export type MobileSessionAgentKind = 'claude-code' | 'codex';
+export type MobileSessionAgentKind = 'claude-code' | 'codex' | 'pi';
/** 将不可信 device-link payload 收窄为公开 intent;非法值按“无意图”处理。 */
export function normalizeSessionAgentSwitchIntent(
@@ -17,7 +17,11 @@ export function normalizeSessionAgentSwitchIntent(
): MobileSessionAgentSwitchIntent | null {
if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
const item = value as Record<string, unknown>;
- if (item.targetAgentKind !== 'claude-code' && item.targetAgentKind !== 'codex') return null;
+ if (
+ item.targetAgentKind !== 'claude-code'
+ && item.targetAgentKind !== 'codex'
+ && item.targetAgentKind !== 'pi'
+ ) return null;
if (typeof item.model !== 'string' || item.model.length === 0) return null;
// providerId 缺失(undefined)按 null 处理,与桌面 projectPendingAgentSwitchIntent 的
// `providerId ?? null` 语义对齐——只有出现非 string / 非 null / 非 undefined 的脏值才判非法,
@@ -38,7 +42,9 @@ export function normalizeSessionAgentSwitchIntent(
/** DB 会话行的 cc/codex 映射到 maker agent kind。 */
export function sessionAgentKind(session: Pick<RemoteSession, 'agentKind'>): MobileSessionAgentKind {
- return session.agentKind === 'codex' ? 'codex' : 'claude-code';
+ return session.agentKind === 'codex' || session.agentKind === 'pi'
+ ? session.agentKind
+ : 'claude-code';
}
/** 手机是否应展示 Agent 分段;远程 SSH / Orca 会话继续保持单 Agent。 */
@@ -52,5 +58,5 @@ export function supportsMobileSessionAgentSwitch(
}
export function mobileAgentLabel(agentKind: MobileSessionAgentKind): string {
- return agentKind === 'codex' ? 'Codex' : 'Claude Code';
+ return agentKind === 'codex' ? 'Codex' : agentKind === 'pi' ? 'Pi' : 'Claude Code';
}
diff --git a/apps/mobile/src/session/sessionControls.ts b/apps/mobile/src/session/sessionControls.ts
index 90749de09a..33674f0287 100644
--- a/apps/mobile/src/session/sessionControls.ts
+++ b/apps/mobile/src/session/sessionControls.ts
@@ -27,7 +27,9 @@ export function shouldFallbackToLegacyCodexUsage(error: unknown): boolean {
export function buildContextUsageCreateOpts(session: RemoteSession): Record<string, unknown> {
return {
- agentKind: session.agentKind === 'codex' ? 'codex' : 'claude-code',
+ agentKind: session.agentKind === 'codex' || session.agentKind === 'pi'
+ ? session.agentKind
+ : 'claude-code',
workingDir: session.workingDir ?? '',
model: session.model,
effort: session.effort,
diff --git a/apps/mobile/src/session/sessionMenu.ts b/apps/mobile/src/session/sessionMenu.ts
index 4bab0f9f38..1b8f270537 100644
--- a/apps/mobile/src/session/sessionMenu.ts
+++ b/apps/mobile/src/session/sessionMenu.ts
@@ -203,7 +203,7 @@ function readErrorCode(error: Error): string {
}
function buildSessionMenuMetaLine(session: RemoteSession): string {
- const agentLabel = session.agentKind === 'codex' ? 'Codex' : 'Claude';
+ const agentLabel = session.agentKind === 'codex' ? 'Codex' : session.agentKind === 'pi' ? 'Pi' : 'Claude';
const parts = [agentLabel];
const worktree = sessionWorktreeInfo(session);
const workspace = workspaceName(session);
diff --git a/apps/mobile/src/session/types.ts b/apps/mobile/src/session/types.ts
index fbc4011a1b..b34a1f538e 100644
--- a/apps/mobile/src/session/types.ts
+++ b/apps/mobile/src/session/types.ts
@@ -54,7 +54,7 @@ export interface RemoteSession {
activeTurnStartedAt?: number | null;
lastTurnEndedAt?: number | null;
status: RemoteSessionStatus;
- agentKind: 'cc' | 'codex';
+ agentKind: 'cc' | 'codex' | 'pi';
/** main 进程内的下一条消息跨 Agent 切换意图;null = 已确认没有。 */
agentSwitchIntent?: MobileSessionAgentSwitchIntent | null;
source?: string;
@@ -172,7 +172,7 @@ export interface QueuedRemoteMessage {
sessionReferencesRequireTrustedSnapshot?: boolean;
userName?: string;
createOpts: {
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workingDir: string;
model: string;
effort?: string;
diff --git a/packages/maker-core/src/agents/pi/index.ts b/packages/maker-core/src/agents/pi/index.ts
index 92dae716f1..3bb085458b 100644
--- a/packages/maker-core/src/agents/pi/index.ts
+++ b/packages/maker-core/src/agents/pi/index.ts
@@ -16,7 +16,7 @@
*
* P0 骨架已支持:流式文本/thinking/工具事件、steer、abort、set_model/set_thinking_level、
* resume(switch_session)、usage/cost 快照。
- * 尚未支持(capabilities 声明降级):文件级 rewind/后台任务/远端 host。
+ * SSH remote host 尚未支持;跨设备控制走 device-link,在目标设备本地启动 Pi。
*/
import os from 'node:os';
@@ -1054,9 +1054,7 @@ export class PiAgent extends BaseAgent {
: undefined;
const contextTokens = typeof contextUsage?.tokens === 'number' && contextUsage.tokens >= 0
? contextUsage.tokens
- : stats.success
- ? 0
- : piContextTokensFromTree(after.data, tree);
+ : piContextTokensFromTree(after.data, tree);
const contextWindow = typeof contextUsage?.contextWindow === 'number' && contextUsage.contextWindow > 0
? contextUsage.contextWindow
: ctx.contextWindow;
@@ -1070,6 +1068,42 @@ export class PiAgent extends BaseAgent {
...(draftText ? { draftText } : {}),
};
},
+
+ async getContextUsage() {
+ const stats = await proc.request({ type: 'get_session_stats' });
+ if (!stats.success) {
+ throw new Error(`pi get_session_stats failed: ${stats.error ?? 'unknown'}`);
+ }
+ const contextUsage = (stats.data as {
+ contextUsage?: { tokens?: number | null; contextWindow?: number | null };
+ } | undefined)?.contextUsage;
+ const totalTokens = typeof contextUsage?.tokens === 'number' && contextUsage.tokens >= 0
+ ? contextUsage.tokens
+ : ctx.contextTokens;
+ const maxTokens = typeof contextUsage?.contextWindow === 'number' && contextUsage.contextWindow > 0
+ ? contextUsage.contextWindow
+ : ctx.contextWindow;
+ const percentage = maxTokens > 0 ? Math.min(100, (totalTokens / maxTokens) * 100) : 0;
+ return {
+ categories: [{ name: 'Messages', tokens: totalTokens, color: '#8b8b8b' }],
+ totalTokens,
+ maxTokens,
+ rawMaxTokens: maxTokens,
+ percentage,
+ gridRows: [],
+ model: mutableModel,
+ memoryFiles: [],
+ mcpTools: [],
+ agents: [],
+ isAutoCompactEnabled: true,
+ apiUsage: {
+ input_tokens: ctx.turnInput,
+ output_tokens: ctx.turnOutput,
+ cache_creation_input_tokens: ctx.turnCacheWrite,
+ cache_read_input_tokens: ctx.turnCacheRead,
+ },
+ };
+ },
};
return handle;
diff --git a/packages/maker-shared/src/deviceLinkContract.ts b/packages/maker-shared/src/deviceLinkContract.ts
index 4b5619a6e5..0e5c47c93a 100644
--- a/packages/maker-shared/src/deviceLinkContract.ts
+++ b/packages/maker-shared/src/deviceLinkContract.ts
@@ -234,7 +234,7 @@ export interface MobileCodexRateLimitResetResult {
/** 下一条消息发送时才会应用的跨 Agent 切换意图。 */
export interface MobileSessionAgentSwitchIntent {
- targetAgentKind: 'claude-code' | 'codex';
+ targetAgentKind: 'claude-code' | 'codex' | 'pi';
model: string;
providerId: string | null;
effort?: string;
@@ -244,7 +244,7 @@ export interface MobileSessionAgentSwitchIntent {
/** desktop 登记 / 取消跨 Agent 意图后的稳定结果。 */
export interface MobileSessionAgentSwitchResult {
switched: boolean;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
model: string;
engineReady: boolean;
deferred?: boolean;
diff --git a/packages/maker-shared/src/fixtures.ts b/packages/maker-shared/src/fixtures.ts
index 984ef13e15..32c7b8e8a8 100644
--- a/packages/maker-shared/src/fixtures.ts
+++ b/packages/maker-shared/src/fixtures.ts
@@ -18,7 +18,7 @@ export interface RemoteControlSessionFixture {
workingDir: string | null;
workspaceKind: 'project' | 'dialogue';
status: 'active' | 'archived' | 'deleted';
- agentKind: 'cc' | 'codex';
+ agentKind: 'cc' | 'codex' | 'pi';
model: string;
effort: string;
permissionMode: string;
diff --git a/scripts/__tests__/ensure-agent-binaries.test.mjs b/scripts/__tests__/ensure-agent-binaries.test.mjs
index 4fe3638e6f..3e14cfccd9 100644
--- a/scripts/__tests__/ensure-agent-binaries.test.mjs
+++ b/scripts/__tests__/ensure-agent-binaries.test.mjs
@@ -15,9 +15,15 @@ import {
isValidBinary,
listSiblingWorktreeRoots,
readInstalledVersion,
+ supportsCdnFallback,
tryReuseFromSiblingWorktree,
} from '../ensure-agent-binaries.mjs';
+test('directory distributions never use the single-binary CDN fallback', () => {
+ assert.equal(supportsCdnFallback('pi'), false);
+ assert.equal(supportsCdnFallback('codex'), true);
+});
+
const LFS_POINTER = [
'version https://git-lfs.github.com/spec/v1',
'oid sha256:0000000000000000000000000000000000000000000000000000000000000000',
diff --git a/scripts/__tests__/pi-update-layout.test.mjs b/scripts/__tests__/pi-update-layout.test.mjs
index c4d86dd923..3ec5b66963 100644
--- a/scripts/__tests__/pi-update-layout.test.mjs
+++ b/scripts/__tests__/pi-update-layout.test.mjs
@@ -4,7 +4,7 @@ import os from 'node:os';
import path from 'node:path';
import test from 'node:test';
-import { flattenExtractedDir } from '../../tools/pi/update.mjs';
+import { assertPinnedRuntimeAsset, flattenExtractedDir } from '../../tools/pi/update.mjs';
function tempDir() {
return fs.mkdtempSync(path.join(os.tmpdir(), 'cindy-pi-layout-'));
@@ -43,3 +43,28 @@ test('Pi release pin covers every supported desktop architecture', () => {
'win32-x64',
]);
});
+
+test('Pi updater rejects mutable release metadata that differs from the reviewed pin', () => {
+ const cache = {
+ version: '1.2.3',
+ runtimeAssets: {
+ 'darwin-arm64': { url: 'https://example.test/pi.tgz', sha256: 'a'.repeat(64) },
+ },
+ };
+ const matching = {
+ assets: [{
+ name: 'pi-darwin-arm64.tar.gz',
+ browser_download_url: 'https://example.test/pi.tgz',
+ digest: `sha256:${'a'.repeat(64)}`,
+ }],
+ };
+ assert.doesNotThrow(() => assertPinnedRuntimeAsset(
+ cache, matching, '1.2.3', 'darwin-arm64', 'pi-darwin-arm64.tar.gz',
+ ));
+ const changed = structuredClone(matching);
+ changed.assets[0].digest = `sha256:${'b'.repeat(64)}`;
+ assert.throws(
+ () => assertPinnedRuntimeAsset(cache, changed, '1.2.3', 'darwin-arm64', 'pi-darwin-arm64.tar.gz'),
+ /does not match pin/,
+ );
+});
diff --git a/scripts/ensure-agent-binaries.mjs b/scripts/ensure-agent-binaries.mjs
index aa00f42c24..c9b5f4775f 100644
--- a/scripts/ensure-agent-binaries.mjs
+++ b/scripts/ensure-agent-binaries.mjs
@@ -37,6 +37,10 @@ const KINDS = {
const log = (msg) => console.log(`\x1b[36m[ensure-agent-binaries]\x1b[0m ${msg}`);
const warn = (msg) => console.log(`\x1b[33m[ensure-agent-binaries]\x1b[0m ${msg}`);
+export function supportsCdnFallback(kind) {
+ return KINDS[kind]?.dirDist !== true;
+}
+
export function currentPlatformKey() {
return `${process.platform}-${process.arch}`;
}
@@ -200,6 +204,12 @@ export async function ensureBinary(kind, platformKey = currentPlatformKey(), { f
try {
await mod.ensurePlatform({ version, platformKey, force });
} catch (upstreamErr) {
+ if (!supportsCdnFallback(kind)) {
+ throw new Error(
+ `Failed to download ${kind} ${platformKey}@${version} from upstream: ${upstreamErr.message}. ` +
+ 'This runtime is a directory distribution, so the single-binary CDN fallback is unsafe.',
+ );
+ }
// claude / codex / ripgrep:上游慢/失败(含 fetch-with-timeout 的 connect/stall/total/throughput 超时)→
// 回退公司 CDN(国内快,.gz gunzip 后与上游裸二进制字节一致)。
warn(`${kind} ${platformKey}: upstream failed/slow (${upstreamErr.message}); falling back to CDN...`);
diff --git a/tools/pi/update.mjs b/tools/pi/update.mjs
index 7837a7e69f..f5f31dcf75 100644
--- a/tools/pi/update.mjs
+++ b/tools/pi/update.mjs
@@ -80,6 +80,31 @@ function readCachedVersion() {
}
}
+function readCache() {
+ try {
+ return JSON.parse(fs.readFileSync(CACHE_FILE, 'utf8'));
+ } catch {
+ return null;
+ }
+}
+
+/** Fail closed when mutable GitHub release metadata no longer matches the reviewed pin. */
+export function assertPinnedRuntimeAsset(cache, meta, version, platformKey, assetName) {
+ if (!cache || cache.version !== version) {
+ throw new Error(`Pi runtime pin missing for ${platformKey}@${version}`);
+ }
+ const pin = cache.runtimeAssets?.[platformKey];
+ const asset = (meta.assets || []).find((candidate) => candidate.name === assetName);
+ const liveSha256 = normalizeExpectedSha256(asset?.digest);
+ if (!pin || !asset || !liveSha256 || liveSha256 !== pin.sha256) {
+ throw new Error(`Pi runtime asset digest does not match pin for ${platformKey}@${version}`);
+ }
+ if (asset.browser_download_url !== pin.url) {
+ throw new Error(`Pi runtime asset URL does not match pin for ${platformKey}@${version}`);
+ }
+ return asset;
+}
+
function runtimeAssetPins(meta, version) {
return Object.fromEntries(PLATFORMS.map(({ key, asset: assetName }) => {
const asset = (meta.assets || []).find((candidate) => candidate.name === assetName);
@@ -299,6 +324,7 @@ export async function ensurePlatform({ version, platformKey, force = false }) {
const entry = PLATFORMS.find((p) => p.key === platformKey);
if (!entry) throw new Error(`Unknown platform key for pi: ${platformKey}`);
const meta = await fetchReleaseMeta(`v${version}`);
+ assertPinnedRuntimeAsset(readCache(), meta, version, platformKey, entry.asset);
await downloadAsset(meta, version, platformKey, entry.asset, entry.binFile, { force, throughputGuard: true });
promoteOnePlatform(version, platformKey, entry.binFile);
}