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。

refactor: AgentKind 三值化连锁 —— 类型放宽、满射补位、测试对齐

zqchris27543baa22c0
diff --git a/apps/desktop/src/main/hook-control/__tests__/defaults.test.ts b/apps/desktop/src/main/hook-control/__tests__/defaults.test.ts
index f76547e68c..2717c590d1 100644
--- a/apps/desktop/src/main/hook-control/__tests__/defaults.test.ts
+++ b/apps/desktop/src/main/hook-control/__tests__/defaults.test.ts
@@ -20,6 +20,7 @@ function deps(over?: Partial<HookDefaultsDeps>): HookDefaultsDeps {
agents: {
'claude-code': { providerId: null, model: 'claude-opus-4-8', effort: 'xhigh' },
codex: { providerId: 'xd', model: 'gpt-5.5', effort: 'high' },
+ pi: { providerId: null, model: 'claude-sonnet-5', effort: 'high' },
},
}),
getModels: (agentKind) =>
@@ -96,6 +97,7 @@ describe('resolveHookSessionConfig', () => {
agents: {
'claude-code': { providerId: null, model: 'claude-opus-4-8', effort: 'ultra-draft' },
codex: { providerId: null, model: 'gpt-5.5', effort: 'high' },
+ pi: { providerId: null, model: 'claude-sonnet-5', effort: 'high' },
},
}),
}),
@@ -117,6 +119,7 @@ describe('resolveHookSessionConfig', () => {
agents: {
'claude-code': { providerId: null, model: 'gone-model', effort: 'high' },
codex: { providerId: null, model: 'gpt-5.5', effort: 'high' },
+ pi: { providerId: null, model: 'claude-sonnet-5', effort: 'high' },
},
}),
}),
@@ -181,6 +184,7 @@ describe('resolveHookSessionConfig', () => {
agents: {
'claude-code': { providerId: null, model: 'claude-opus-4-8', effort: 'xhigh' },
codex: { providerId: ' ', model: 'gpt-5.5', effort: 'high' },
+ pi: { providerId: null, model: 'claude-sonnet-5', effort: 'high' },
},
}),
}),
diff --git a/apps/desktop/src/main/hook-control/defaults.ts b/apps/desktop/src/main/hook-control/defaults.ts
index 22e177799e..f514676fad 100644
--- a/apps/desktop/src/main/hook-control/defaults.ts
+++ b/apps/desktop/src/main/hook-control/defaults.ts
@@ -35,24 +35,24 @@ import type { Effort } from '@cindy/maker-core';
/** 依赖注入面: IM 默认值 + 各 agent 当前可用模型清单。 */
export interface HookDefaultsDeps {
readDefaults: () => {
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
agents: Record<
- 'claude-code' | 'codex',
+ 'claude-code' | 'codex' | 'pi',
{ providerId: string | null; model: string; effort: string }
>;
};
- getModels: (agentKind: 'claude-code' | 'codex') => Array<{
+ getModels: (agentKind: 'claude-code' | 'codex' | 'pi') => Array<{
id: string;
efforts: readonly string[];
defaultEffort: string | null;
}>;
/** 该 agent 支持的权限档 id 清单(capabilities.permissionModes)。 */
- getPermissionModes: (agentKind: 'claude-code' | 'codex') => readonly string[];
+ getPermissionModes: (agentKind: 'claude-code' | 'codex' | 'pi') => readonly string[];
log: { warn(msg: string): void };
}
export interface ResolvedHookSessionConfig {
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
model: string;
effort: Effort | undefined;
permissionMode: string;
@@ -82,9 +82,9 @@ export function resolveHookSessionConfig(
const defaults = deps.readDefaults();
// 1. agent: 显式合法值 > 草稿默认
- const agentKind: 'claude-code' | 'codex' =
+ const agentKind: 'claude-code' | 'codex' | 'pi' =
overrides.agentKind !== null && AGENT_KINDS.has(overrides.agentKind)
- ? (overrides.agentKind as 'claude-code' | 'codex')
+ ? (overrides.agentKind as 'claude-code' | 'codex' | 'pi')
: defaults.agentKind;
const models = deps.getModels(agentKind);
diff --git a/apps/desktop/src/main/im/__tests__/defaultSettingsStore.test.ts b/apps/desktop/src/main/im/__tests__/defaultSettingsStore.test.ts
index d2b814a222..fc067fbc9c 100644
--- a/apps/desktop/src/main/im/__tests__/defaultSettingsStore.test.ts
+++ b/apps/desktop/src/main/im/__tests__/defaultSettingsStore.test.ts
@@ -152,6 +152,12 @@ describe('im default settings store', () => {
model: 'gpt-5.5',
effort: 'high',
},
+ // legacy root mirror 是 resolved 满射快照(global 才做 diff),pi 槽为系统默认。
+ pi: {
+ providerId: null,
+ model: 'claude-sonnet-5',
+ effort: 'high',
+ },
});
});
diff --git a/apps/desktop/src/main/im/defaultSettingsStore.ts b/apps/desktop/src/main/im/defaultSettingsStore.ts
index cb59122da1..623c4e8037 100644
--- a/apps/desktop/src/main/im/defaultSettingsStore.ts
+++ b/apps/desktop/src/main/im/defaultSettingsStore.ts
@@ -72,6 +72,12 @@ function normalizeSettings(raw: unknown): ImDefaultSettings {
'codex',
rawAgentOrLegacy(rawAgents, 'codex', agentKind, legacySettings),
),
+ // 键序必须与 IM_DEFAULT_SETTINGS.agents 一致:legacy 检测(信号 4)靠
+ // JSON.stringify 与系统默认整体比对,键序漂移会让检测失灵。
+ pi: normalizeAgentSettings(
+ 'pi',
+ rawAgentOrLegacy(rawAgents, 'pi', agentKind, legacySettings),
+ ),
},
};
}
@@ -345,6 +351,7 @@ function cloneSettings(settings: ImDefaultSettings): ImDefaultSettings {
agents: {
'claude-code': { ...settings.agents['claude-code'] },
codex: { ...settings.agents.codex },
+ pi: { ...settings.agents.pi },
},
};
}
diff --git a/apps/desktop/src/main/localDb/schema.ts b/apps/desktop/src/main/localDb/schema.ts
index 9ef1420faf..8c21cfd3be 100644
--- a/apps/desktop/src/main/localDb/schema.ts
+++ b/apps/desktop/src/main/localDb/schema.ts
@@ -723,7 +723,7 @@ export const schedules = sqliteTable(
* 引擎 fireOne 优先用 intervalMs 算 nextFireAt;旧 cron 数据 0015 migration 自动回填。
*/
intervalMs: integer('interval_ms'),
- agentKind: text('agent_kind', { enum: ['claude-code', 'codex'] }).notNull(),
+ agentKind: text('agent_kind', { enum: ['claude-code', 'codex', 'pi'] }).notNull(),
model: text('model'),
/**
* 显式选定的供应商(来源)id。NULL = 回落该 agent 原生默认来源(no-break,
@@ -841,7 +841,7 @@ export const sessionGoals = sqliteTable(
/** usageLimited 时记录的限额重置时刻(unix ms);到点自动续跑。其它状态为 null。 */
usageResetAt: integer('usage_reset_at'),
lastReason: text('last_reason'),
- agentKind: text('agent_kind', { enum: ['claude-code', 'codex'] }).notNull(),
+ agentKind: text('agent_kind', { enum: ['claude-code', 'codex', 'pi'] }).notNull(),
startedAt: integer('started_at').notNull(),
updatedAt: integer('updated_at').notNull(),
},
@@ -1124,7 +1124,7 @@ export const skillUsageSources = sqliteTable(
rawFilePath: text('raw_file_path').primaryKey(),
/** 当前源文件最后一次用哪个解析器版本扫描。用于 analyzer 升级时渐进重建。 */
analyzerVersion: text('analyzer_version').notNull().default('6'),
- agentKind: text('agent_kind', { enum: ['claude-code', 'codex'] }).notNull(),
+ agentKind: text('agent_kind', { enum: ['claude-code', 'codex', 'pi'] }).notNull(),
sessionId: text('session_id').notNull(),
sdkSessionId: text('sdk_session_id').notNull(),
mtimeMs: integer('mtime_ms').notNull().default(0),
@@ -1154,7 +1154,7 @@ export const skillUsageExposures = sqliteTable(
rawLineNo: integer('raw_line_no').notNull(),
sessionId: text('session_id').notNull(),
sdkSessionId: text('sdk_session_id').notNull(),
- agentKind: text('agent_kind', { enum: ['claude-code', 'codex'] }).notNull(),
+ agentKind: text('agent_kind', { enum: ['claude-code', 'codex', 'pi'] }).notNull(),
skillName: text('skill_name').notNull(),
skillPath: text('skill_path'),
/** 规范 SKILL.md 文档 hash;拿不到规范文档时为 NULL,不参与版本聚合。 */
diff --git a/apps/desktop/src/main/maker-host/model-route-guard-live.ts b/apps/desktop/src/main/maker-host/model-route-guard-live.ts
index 1dbd8f68a9..085da246d6 100644
--- a/apps/desktop/src/main/maker-host/model-route-guard-live.ts
+++ b/apps/desktop/src/main/maker-host/model-route-guard-live.ts
@@ -194,6 +194,8 @@ export async function resolveRouteCopyCapabilities(
const DEFAULT_ONESHOT_MODEL: Record<AgentKind, string> = {
'claude-code': 'claude-haiku-4-5',
codex: 'gpt-5.4-mini',
+ // pi oneShot 未实现(BaseAgent 默认抛 NotSupported);占位与 claude 同款网关小模型。
+ pi: 'claude-haiku-4-5',
};
/**
diff --git a/apps/desktop/src/main/maker-host/newMakerDefaultsCache.ts b/apps/desktop/src/main/maker-host/newMakerDefaultsCache.ts
index e1139f8762..37a3c0a454 100644
--- a/apps/desktop/src/main/maker-host/newMakerDefaultsCache.ts
+++ b/apps/desktop/src/main/maker-host/newMakerDefaultsCache.ts
@@ -126,7 +126,7 @@ export interface RemoteNewMakerDefaults {
}
export function getRemoteNewMakerDefaults(
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
): RemoteNewMakerDefaults {
// providerModelMemory(草稿列表行真实读源)与「该 vendor 是否选过模型」无关:即便 cache 未就绪 /
// 该 vendor 无选中模型(lastByVendor 空),只要被控端有模型级预设就要全量回给控制端,
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts
index d3b6e9f032..da4355e0e3 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts
@@ -34,8 +34,13 @@ describe('providerRouteRequiresExplicitSelection', () => {
});
function providerRoutingContext(
- availability: Record<AgentKind, OrcaWorkerProviderSnapshot[]>,
+ partial: Partial<Record<AgentKind, OrcaWorkerProviderSnapshot[]>>,
): OrcaWorkerProviderRoutingContext {
+ const availability: Record<AgentKind, OrcaWorkerProviderSnapshot[]> = {
+ 'claude-code': partial['claude-code'] ?? [],
+ codex: partial.codex ?? [],
+ pi: partial.pi ?? [],
+ };
return {
availability,
resolveDefaultProviderIdForModel: (agent, model) => (
@@ -1038,6 +1043,7 @@ describe('OrcaWorkerCreationService', () => {
{ id: 'custom-codex', name: 'Custom Codex', models: ['gpt-5.5'] },
{ id: 'xd', name: 'XD Gateway', models: ['gpt-5.4'] },
],
+ pi: [],
} satisfies Record<AgentKind, OrcaWorkerProviderSnapshot[]>;
const { deps, service } = createDeps({
getWorkerDefaults: vi.fn(() => ({ model: 'gpt-5.5', providerId: 'custom-codex' })),
@@ -1309,6 +1315,7 @@ describe('buildNoProviderMessage', () => {
it('suggests the other agent when it has a connected provider', () => {
const msg = buildNoProviderMessage('codex', {
'claude-code': [{ id: 'xd', name: 'XD Gateway', models: ['claude-sonnet-4-6'] }],
+ pi: [],
codex: [],
});
expect(msg).toContain('Codex 当前没有可用的模型供应商');
@@ -1317,7 +1324,7 @@ describe('buildNoProviderMessage', () => {
});
it('omits the agent suggestion when no agent has a connected provider', () => {
- const msg = buildNoProviderMessage('claude-code', { 'claude-code': [], codex: [] });
+ const msg = buildNoProviderMessage('claude-code', { 'claude-code': [], codex: [], pi: [] });
expect(msg).toContain('Claude Code 当前没有可用的模型供应商');
expect(msg).toContain('设置 → 模型供应商');
expect(msg).not.toContain('改用');
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 a3acae4b14..85ed727a4e 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/sessionAgentSwitchHandler.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/sessionAgentSwitchHandler.test.ts
@@ -238,7 +238,7 @@ describe('deferred switch (turn running)', () => {
const store = new Map<
string,
{
- targetAgentKind: 'claude-code' | 'codex';
+ targetAgentKind: 'claude-code' | 'codex' | 'pi';
model: string;
providerId: string | null | undefined;
effort?: string;
diff --git a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
index 17536dd625..2e86d9d539 100644
--- a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
+++ b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
@@ -137,7 +137,7 @@ export interface AgentInputCoordinatorDeps {
*/
reconcileTurnIdle?: (sessionId: string) => void;
hasPendingInteraction: (sessionId: string) => boolean;
- getAgentKind: (sessionId: string) => 'claude-code' | 'codex' | null;
+ getAgentKind: (sessionId: string) => 'claude-code' | 'codex' | 'pi' | null;
getSdkSessionId: (sessionId: string) => Promise<string | undefined>;
/**
* interrupted-turn-resume:判断某条已派发 user 消息之后 agent 是否已产出内容
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index de1af65ebb..c7e7218e42 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -6683,6 +6683,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
availability: {
'claude-code': availabilityFor('claude-code'),
codex: availabilityFor('codex'),
+ pi: availabilityFor('pi'),
},
resolveDefaultProviderIdForModel: (agent, model) => (
effectiveSourceIdForModel(views, null, model, agent)
diff --git a/apps/desktop/src/main/maker-ipc/schedule.ts b/apps/desktop/src/main/maker-ipc/schedule.ts
index 16b5ef4db3..e7fd757164 100644
--- a/apps/desktop/src/main/maker-ipc/schedule.ts
+++ b/apps/desktop/src/main/maker-ipc/schedule.ts
@@ -397,7 +397,7 @@ export function registerScheduleHandlers(getMaker?: () => Maker | null): void {
? body.targetSessionId.trim()
: undefined;
let providerId = typeof body.providerId === 'string' ? body.providerId : undefined;
- let agentKind = requestedAgentKind;
+ let agentKind: AgentKind | undefined = requestedAgentKind;
let model = typeof body.model === 'string' ? body.model : undefined;
if (targetSessionId && shouldResolveBoundSessionGenerationRoute({ targetSessionId, providerId, model })) {
const session = await maker.getSessionMeta(targetSessionId).catch(() => null);
diff --git a/apps/desktop/src/renderer/__tests__/imDefaultSettingsLogic.test.ts b/apps/desktop/src/renderer/__tests__/imDefaultSettingsLogic.test.ts
index 5c82e1d7fd..125cd350e4 100644
--- a/apps/desktop/src/renderer/__tests__/imDefaultSettingsLogic.test.ts
+++ b/apps/desktop/src/renderer/__tests__/imDefaultSettingsLogic.test.ts
@@ -49,6 +49,7 @@ describe('im default settings logic', () => {
model: 'gpt-5.5',
effort: 'high',
},
+ pi: IM_DEFAULT_SETTINGS.agents.pi,
});
});
});
diff --git a/apps/desktop/src/renderer/components/settings/AddProviderWizard.tsx b/apps/desktop/src/renderer/components/settings/AddProviderWizard.tsx
index 5afc76bef1..8b4d9a7c08 100644
--- a/apps/desktop/src/renderer/components/settings/AddProviderWizard.tsx
+++ b/apps/desktop/src/renderer/components/settings/AddProviderWizard.tsx
@@ -72,6 +72,7 @@ type PresetBaseUrls = Partial<Record<AgentKind, string>>;
const AGENT_LABEL: Record<AgentKind, string> = {
'claude-code': 'Claude Code',
codex: 'Codex',
+ pi: 'Pi',
};
function presetRuntimeBaseUrl(
diff --git a/apps/desktop/src/renderer/components/settings/CustomProviderDialog.tsx b/apps/desktop/src/renderer/components/settings/CustomProviderDialog.tsx
index 3181da5fcd..c7ced17a16 100644
--- a/apps/desktop/src/renderer/components/settings/CustomProviderDialog.tsx
+++ b/apps/desktop/src/renderer/components/settings/CustomProviderDialog.tsx
@@ -62,11 +62,14 @@ import type {
ProviderWireProtocol,
} from '@cindy/model-providers';
-const AGENTS: AgentKind[] = ['claude-code', 'codex'];
+/** 本面板只配置 claude/codex 两个 runtime;pi 的模型走网关目录,不在自定义 provider 范畴。 */
+type DialogAgentKind = Extract<AgentKind, 'claude-code' | 'codex'>;
-const VISIBLE_AGENTS: AgentKind[] = AGENTS;
+const AGENTS: DialogAgentKind[] = ['claude-code', 'codex'];
-const TAB_META: Record<AgentKind, { Mark: typeof ClaudeMark; labelKey: string; helpKey: string }> =
+const VISIBLE_AGENTS: DialogAgentKind[] = AGENTS;
+
+const TAB_META: Record<DialogAgentKind, { Mark: typeof ClaudeMark; labelKey: string; helpKey: string }> =
{
'claude-code': {
Mark: ClaudeMark,
@@ -113,7 +116,7 @@ interface TestState {
}
const IDLE_TEST: TestState = { status: 'idle' };
-function emptyRuntime(agent: AgentKind): RuntimeFields {
+function emptyRuntime(agent: DialogAgentKind): RuntimeFields {
return {
baseUrl: '',
requestPath: '',
@@ -125,8 +128,8 @@ function emptyRuntime(agent: AgentKind): RuntimeFields {
};
}
-function initRuntimes(initial?: CustomProviderConfig): Record<AgentKind, RuntimeFields> {
- const out: Record<AgentKind, RuntimeFields> = {
+function initRuntimes(initial?: CustomProviderConfig): Record<DialogAgentKind, RuntimeFields> {
+ const out: Record<DialogAgentKind, RuntimeFields> = {
'claude-code': emptyRuntime('claude-code'),
codex: emptyRuntime('codex'),
};
@@ -311,12 +314,12 @@ export function CustomProviderDialog({
const initialOAuth = initial?.auth?.method === 'oauth' ? initial.auth.oauth : undefined;
const [name, setName] = useState(initial?.name ?? '');
- const [rt, setRt] = useState<Record<AgentKind, RuntimeFields>>(() => initRuntimes(initial));
- const [activeTab, setActiveTab] = useState<AgentKind>(
+ const [rt, setRt] = useState<Record<DialogAgentKind, RuntimeFields>>(() => initRuntimes(initial));
+ const [activeTab, setActiveTab] = useState<DialogAgentKind>(
() => (initial && VISIBLE_AGENTS.find((a) => initial.runtimes[a])) || 'claude-code',
);
const [showKey, setShowKey] = useState(false);
- const [hasKey, setHasKey] = useState<Record<AgentKind, boolean>>({
+ const [hasKey, setHasKey] = useState<Record<DialogAgentKind, boolean>>({
'claude-code': false,
codex: false,
});
@@ -357,18 +360,18 @@ export function CustomProviderDialog({
const [presets, setPresets] = useState<ProviderPreset[]>([]);
const [appliedPreset, setAppliedPreset] = useState<string | null>(null);
// per-runtime 测试连接状态。
- const [test, setTest] = useState<Record<AgentKind, TestState>>({
+ const [test, setTest] = useState<Record<DialogAgentKind, TestState>>({
'claude-code': IDLE_TEST,
codex: IDLE_TEST,
});
// per-runtime「获取模型列表」进行中标记(按钮瞬态 spinner)。
- const [fetchingModels, setFetchingModels] = useState<Record<AgentKind, boolean>>({
+ const [fetchingModels, setFetchingModels] = useState<Record<DialogAgentKind, boolean>>({
'claude-code': false,
codex: false,
});
// 拉取成功后的勾选弹层:行集合 = 拉取结果 ∪ 表单已填(后者默认勾选、保留用户显示名)。
const [picker, setPicker] = useState<{
- agent: AgentKind;
+ agent: DialogAgentKind;
models: ModelRow[];
selected: Set<string>;
query: string;
@@ -380,7 +383,7 @@ export function CustomProviderDialog({
const rtRef = useRef(rt);
/** 唯一的 rt 写入口:状态更新的同时同步镜像进 rtRef(updater 幂等,StrictMode 双调无害)。 */
const setRtSynced = useCallback(
- (fn: (prev: Record<AgentKind, RuntimeFields>) => Record<AgentKind, RuntimeFields>) => {
+ (fn: (prev: Record<DialogAgentKind, RuntimeFields>) => Record<DialogAgentKind, RuntimeFields>) => {
setRt((prev) => {
const next = fn(prev);
rtRef.current = next;
@@ -457,8 +460,8 @@ export function CustomProviderDialog({
if (!editing || !initial) return;
let cancelled = false;
void (async () => {
- const nextHas: Record<AgentKind, boolean> = { 'claude-code': false, codex: false };
- const fetched: Partial<Record<AgentKind, string>> = {};
+ const nextHas: Record<DialogAgentKind, boolean> = { 'claude-code': false, codex: false };
+ const fetched: Partial<Record<DialogAgentKind, string>> = {};
for (const a of AGENTS) {
if (!initial.runtimes[a]) continue;
const k = await readCustomProviderKey(initial.id, a);
@@ -483,7 +486,7 @@ export function CustomProviderDialog({
}, [editing, initial]);
const patch = useCallback(
- (agent: AgentKind, fn: (f: RuntimeFields) => RuntimeFields) => {
+ (agent: DialogAgentKind, fn: (f: RuntimeFields) => RuntimeFields) => {
setRtSynced((prev) => ({ ...prev, [agent]: fn(prev[agent]) }));
setTest((prev) => ({ ...prev, [agent]: IDLE_TEST }));
},
@@ -1589,9 +1592,9 @@ function ModelPickerOverlay({
onConfirm,
onClose,
}: {
- picker: { agent: AgentKind; models: ModelRow[]; selected: Set<string>; query: string };
+ picker: { agent: DialogAgentKind; models: ModelRow[]; selected: Set<string>; query: string };
onChange: (next: {
- agent: AgentKind;
+ agent: DialogAgentKind;
models: ModelRow[];
selected: Set<string>;
query: string;
diff --git a/apps/desktop/src/renderer/components/settings/ImDefaultSettingsSection.tsx b/apps/desktop/src/renderer/components/settings/ImDefaultSettingsSection.tsx
index 60a6cc1d4b..9f419c88b0 100644
--- a/apps/desktop/src/renderer/components/settings/ImDefaultSettingsSection.tsx
+++ b/apps/desktop/src/renderer/components/settings/ImDefaultSettingsSection.tsx
@@ -109,6 +109,8 @@ export function ImDefaultSettingsSection({
codex: fromProviders.codex.length
? fromProviders.codex
: (codex.capabilities?.availableModels ?? []),
+ // pi(实验性):IM 设置 UI 暂不提供 pi 选项卡,空清单仅满足满射类型。
+ pi: [],
};
}, [providers, cc.capabilities, codex.capabilities]);
diff --git a/apps/desktop/src/renderer/components/settings/UnifiedModelList.tsx b/apps/desktop/src/renderer/components/settings/UnifiedModelList.tsx
index 25cb8a6e5a..f6f4a0ea85 100644
--- a/apps/desktop/src/renderer/components/settings/UnifiedModelList.tsx
+++ b/apps/desktop/src/renderer/components/settings/UnifiedModelList.tsx
@@ -57,6 +57,7 @@ import type { AgentKind, CatalogModel, ProviderView } from '@cindy/model-provide
const AGENT_LABEL: Record<AgentKind, string> = {
'claude-code': 'Claude Code',
codex: 'Codex',
+ pi: 'Pi',
};
/**
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/listSessionTasks.ts b/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/listSessionTasks.ts
index 40552504fe..fe8030833b 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/listSessionTasks.ts
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/listSessionTasks.ts
@@ -28,7 +28,7 @@ export interface SessionTaskItem {
/** 标题链取不到任何来源时为 ''(UI 层负责 i18n 兜底)。 */
title: string;
status: AgentTaskStatus;
- provider: 'claude-code' | 'codex';
+ provider: 'claude-code' | 'codex' | 'pi';
update?: AgentTaskUpdate;
toolCallClientId?: string;
toolUseId?: string;
diff --git a/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx b/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx
index ffb95b54a1..45a69fc54d 100644
--- a/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx
+++ b/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx
@@ -45,7 +45,7 @@ import { PENDING_SESSION_ID } from '../lib/scheduleFormLogic';
import type { SessionReference } from '../../../../shared/sessionReference';
export type Destination = 'local' | 'worktree' | 'thread';
-export type AgentKind = 'claude-code' | 'codex';
+export type AgentKind = 'claude-code' | 'codex' | 'pi';
interface ChipButtonProps {
icon?: React.ReactNode;
@@ -160,9 +160,10 @@ export function ProjectChip({
);
}
-const AGENT_META: Record<AgentKind, { label: string; vendor: 'cc' | 'codex' }> = {
+const AGENT_META: Record<AgentKind, { label: string; vendor: 'cc' | 'codex' | 'pi' }> = {
'claude-code': { label: 'Claude Code', vendor: 'cc' },
codex: { label: 'Codex', vendor: 'codex' },
+ pi: { label: 'Pi', vendor: 'pi' },
};
export function AgentTabs({ value, onChange, disabled }: { value: AgentKind; onChange: (v: AgentKind) => void; disabled?: boolean }) {
diff --git a/apps/desktop/src/renderer/features/scheduler/hooks/useScheduleForm.ts b/apps/desktop/src/renderer/features/scheduler/hooks/useScheduleForm.ts
index ef0f6e55f6..606c4a596d 100644
--- a/apps/desktop/src/renderer/features/scheduler/hooks/useScheduleForm.ts
+++ b/apps/desktop/src/renderer/features/scheduler/hooks/useScheduleForm.ts
@@ -83,6 +83,7 @@ function defaultScheduleFormPrefs(): ScheduleFormPrefs {
lastByAgent: {
'claude-code': EMPTY_AGENT_PREFS,
codex: EMPTY_AGENT_PREFS,
+ pi: EMPTY_AGENT_PREFS,
},
};
}
@@ -104,6 +105,7 @@ function loadScheduleFormPrefs(): ScheduleFormPrefs {
lastByAgent: {
'claude-code': sanitizeAgentPrefs(parsed.lastByAgent?.['claude-code']),
codex: sanitizeAgentPrefs(parsed.lastByAgent?.codex),
+ pi: sanitizeAgentPrefs(parsed.lastByAgent?.pi),
},
};
} catch {
diff --git a/apps/desktop/src/renderer/features/scheduler/lib/projectAutomationConfig.ts b/apps/desktop/src/renderer/features/scheduler/lib/projectAutomationConfig.ts
index 9b2d3049db..76f32764ff 100644
--- a/apps/desktop/src/renderer/features/scheduler/lib/projectAutomationConfig.ts
+++ b/apps/desktop/src/renderer/features/scheduler/lib/projectAutomationConfig.ts
@@ -14,7 +14,7 @@ export interface ProjectScheduleConfig {
recurring?: boolean;
manual?: boolean;
intervalMs?: number;
- agentKind?: 'claude-code' | 'codex';
+ agentKind?: 'claude-code' | 'codex' | 'pi';
model?: string;
effort?: string;
/** Codex Fast 模式开关,仅 Codex 有意义。详见 Schedule.fastMode。 */
diff --git a/apps/desktop/src/renderer/features/scheduler/lib/scheduleFormLogic.ts b/apps/desktop/src/renderer/features/scheduler/lib/scheduleFormLogic.ts
index 434e0a16ac..2ef92c8e1a 100644
--- a/apps/desktop/src/renderer/features/scheduler/lib/scheduleFormLogic.ts
+++ b/apps/desktop/src/renderer/features/scheduler/lib/scheduleFormLogic.ts
@@ -88,7 +88,7 @@ export interface ScheduleFormState {
recurring: boolean;
/** 手动模式:true → 创建后永不自动 fire,只能 Run now。UI 上需要 recurring=false 才能勾。 */
manual: boolean;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
model: string;
/**
* 显式选定的来源(供应商)id。'' = 跟随该 agent 原生默认来源(no-break,与未升级
diff --git a/apps/desktop/src/renderer/hooks/useAgentCapabilities.ts b/apps/desktop/src/renderer/hooks/useAgentCapabilities.ts
index 6bacd7b696..8c72514183 100644
--- a/apps/desktop/src/renderer/hooks/useAgentCapabilities.ts
+++ b/apps/desktop/src/renderer/hooks/useAgentCapabilities.ts
@@ -17,7 +17,7 @@ import type { Effort, PermissionMode } from '@/lib/userPreferences.types';
const log = createLogger('useAgentCapabilities');
-export type AgentKind = 'claude-code' | 'codex';
+export type AgentKind = 'claude-code' | 'codex' | 'pi';
// renderer 视角: id 全部是不透明 string, 渲染只读 displayName。
// effort 的合法 id 集合 = capabilities.effortLevels 上每个项的 id。
diff --git a/apps/desktop/src/renderer/lib/atResourceService.ts b/apps/desktop/src/renderer/lib/atResourceService.ts
index 09b42a3a46..325faa981e 100644
--- a/apps/desktop/src/renderer/lib/atResourceService.ts
+++ b/apps/desktop/src/renderer/lib/atResourceService.ts
@@ -43,7 +43,7 @@ export interface ScanResult {
truncated: boolean;
}
-export type PaletteAgentKind = 'claude-code' | 'codex';
+export type PaletteAgentKind = 'claude-code' | 'codex' | 'pi';
/**
* Load candidate @-resources from the active agent/workspace. Returns `success:false`
diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.ts
index 02ce733f31..2ca812cf7c 100644
--- a/apps/desktop/src/renderer/lib/makerChatStore.ts
+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts
@@ -456,7 +456,7 @@ export interface ChatMessage {
export type AgentTaskStatus = 'running' | 'completed' | 'failed' | 'stopped';
export interface AgentTaskUpdate {
- provider: 'claude-code' | 'codex';
+ provider: 'claude-code' | 'codex' | 'pi';
taskId: string;
parentToolUseId?: string;
status: AgentTaskStatus;
@@ -726,7 +726,7 @@ export type MessageDeliveryMode = 'queue' | 'steer';
/** 仅影响 selector/chip 的乐观展示;agentKind 始终保留真实 reducer 路由。 */
export interface AgentSwitchIntentRecord {
- target: 'claude-code' | 'codex';
+ target: 'claude-code' | 'codex' | 'pi';
model: string;
providerId: string | null;
effort?: string;
@@ -740,7 +740,7 @@ export interface SessionChatState {
* Codex reducer。ensureInitialMessages 从 DB sessions.agent_kind 读出来灌进。
* 默认 'claude-code' 兼容老路径(老 session row 没有此字段时按 Claude 处理)。
*/
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
/** 下一条消息发送时才由 main 应用的跨引擎切换意图。 */
agentSwitchIntent: AgentSwitchIntentRecord | null;
/**
@@ -1908,7 +1908,7 @@ function isTerminalErrorData(data: unknown): boolean {
function normalizeAgentTaskUpdate(
data: unknown,
- source?: 'claude-code' | 'codex',
+ source?: 'claude-code' | 'codex' | 'pi',
): AgentTaskUpdate | null {
if (!data || typeof data !== 'object') return null;
const raw = data as Record<string, unknown>;
@@ -3250,7 +3250,7 @@ type MakerEventPayload = {
event?: {
type: string;
data: unknown;
- source?: 'claude-code' | 'codex';
+ source?: 'claude-code' | 'codex' | 'pi';
agentMeta?: Record<string, unknown>;
};
persistId?: string;
@@ -3259,7 +3259,7 @@ type MakerEventPayload = {
type PendingTextDeltaBatch = {
text: string;
- source?: 'claude-code' | 'codex';
+ source?: 'claude-code' | 'codex' | 'pi';
persistId?: string;
agentMeta?: Record<string, unknown>;
};
@@ -5041,7 +5041,7 @@ setRemoteTerminalErrorProbe(hasSessionTerminalError);
interface ActiveSessionSnapshot {
sessionId: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
isTurnRunning: boolean;
}
@@ -5254,8 +5254,8 @@ function bumpMessagesEpoch(sessionId: string): void {
*/
function dbAgentKindToMakerKind(
dbKind: string | null | undefined,
- fallback: 'claude-code' | 'codex' = 'claude-code',
-): 'claude-code' | 'codex' {
+ fallback: 'claude-code' | 'codex' | 'pi' = 'claude-code',
+): 'claude-code' | 'codex' | 'pi' {
if (dbKind === 'codex') return 'codex';
if (dbKind === 'cc') return 'claude-code';
return fallback;
@@ -7011,7 +7011,7 @@ function autoTitleFallbackLabels(): AutoTitleFallbackLabels {
function scheduleAutoName(
sessionId: string,
text: string,
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
isUserText = true,
): void {
// 与 main 共用 normalizeAutoTitle,两端算出的占位串逐字一致,回流时不跳变。
@@ -7124,7 +7124,7 @@ function clearAutoTitlePreviewSafely(sessionId: string): void {
function maybeAutoNameUnnamedSession(
sessionId: string,
seed: AutoTitleSeed | null,
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
): void {
if (!seed?.isUserText) return;
scheduleAutoName(sessionId, seed.text, agentKind, true);
@@ -7261,7 +7261,7 @@ async function sendMessageCore(
// 用会话真实 agentKind 起名 — 之前写死 'claude-code',导致 Codex 会话也
// 用 Claude haiku 起标题:纯 Codex 用户(无 Claude 鉴权)会 oneShot 失败 →
// fallback 原话,表现为"Codex 会话标题没有智能总结"。current.agentKind 已是
- // maker 格式('claude-code' | 'codex'),直接透传。起名走立即占位 + 后台覆盖。
+ // maker 格式('claude-code' | 'codex' | 'pi'),直接透传。起名走立即占位 + 后台覆盖。
if (autoTitleSeed) {
scheduleAutoName(sessionId, autoTitleSeed.text, current.agentKind, autoTitleSeed.isUserText);
}
@@ -8943,7 +8943,7 @@ function sendUiTrigger(sessionId: string, prompt: string): Promise<void> {
* sdkSessionId——否则 buildCreateOpts 会把旧引擎的原生会话 id 当 resume 目标
* (main 侧 reconcileCreateOptsWithDb 是兜底,这里是第一现场收敛)。
*/
-function noteAgentSwitched(sessionId: string, agentKind: 'claude-code' | 'codex'): void {
+function noteAgentSwitched(sessionId: string, agentKind: 'claude-code' | 'codex' | 'pi'): void {
if (!sessionId) return;
setState(sessionId, (s) =>
s.agentKind === agentKind && s.sdkSessionId === null && s.agentSwitchIntent === null
@@ -8960,7 +8960,7 @@ function noteAgentSwitched(sessionId: string, agentKind: 'claude-code' | 'codex'
*/
function noteAgentSwitchIntent(
sessionId: string,
- target: 'claude-code' | 'codex',
+ target: 'claude-code' | 'codex' | 'pi',
opts: { model: string; providerId: string | null; effort?: string; fastMode?: boolean },
): void {
if (!sessionId) return;
@@ -8990,7 +8990,7 @@ function getAgentSwitchIntent(sessionId: string): AgentSwitchIntentRecord | null
function setSessionRuntime(
sessionId: string,
- opts: { agentKind?: 'claude-code' | 'codex'; fastMode?: boolean; planModeEnabled?: boolean },
+ opts: { agentKind?: 'claude-code' | 'codex' | 'pi'; fastMode?: boolean; planModeEnabled?: boolean },
): void {
if (!sessionId) return;
setState(sessionId, (s) => {
diff --git a/apps/desktop/src/renderer/lib/providerSubtitle.ts b/apps/desktop/src/renderer/lib/providerSubtitle.ts
index b5fc52d6ee..fe183a4215 100644
--- a/apps/desktop/src/renderer/lib/providerSubtitle.ts
+++ b/apps/desktop/src/renderer/lib/providerSubtitle.ts
@@ -3,6 +3,7 @@ import type { AgentKind, ProviderView } from '@cindy/model-providers';
const AGENT_DISPLAY_LABELS: Record<AgentKind, string> = {
'claude-code': 'Claude Code',
codex: 'Codex',
+ pi: 'Pi',
};
export function providerAgentSupportLabel(provider?: Pick<ProviderView, 'agents'> | null): string {
diff --git a/apps/desktop/src/renderer/lib/providerUpstreamErrorToast.ts b/apps/desktop/src/renderer/lib/providerUpstreamErrorToast.ts
index 0e216f5c43..d72c1102fa 100644
--- a/apps/desktop/src/renderer/lib/providerUpstreamErrorToast.ts
+++ b/apps/desktop/src/renderer/lib/providerUpstreamErrorToast.ts
@@ -16,7 +16,7 @@ import { toast } from './toast';
import type { ProviderErrorCode } from '../../shared/providerErrors';
interface ProviderUpstreamErrorPayload {
- agent: 'claude-code' | 'codex';
+ agent: 'claude-code' | 'codex' | 'pi';
providerId: string;
providerName?: string;
code: ProviderErrorCode;
diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.ts
index 773bca6952..beaf777e9a 100644
--- a/apps/desktop/src/renderer/vite-env.d.ts
+++ b/apps/desktop/src/renderer/vite-env.d.ts
@@ -448,7 +448,7 @@ interface WechatChannelSettingsState {
type DiscordBotSessionAuthCheckResult = {
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;
@@ -543,7 +543,7 @@ interface OrcaWorkerRecord {
session: {
id: string;
title: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workingDir: string;
model: string;
effort: string;
@@ -603,7 +603,7 @@ interface CCAgentStreamEvent {
sessionId: string;
type: 'text' | 'tool_use' | 'tool_result' | 'tool_result_full' | 'agent_task_update' | 'status' | 'done' | 'error' | 'permission_request' | 'permission_dismissed' | 'ask_user_question' | 'plan_review' | 'thinking' | 'compact_boundary';
data: unknown;
- source?: 'claude-code' | 'codex';
+ source?: 'claude-code' | 'codex' | 'pi';
/**
* agent-meta: SDK 元信息(按 session.agentKind 解析)。当事件来自一条 SDK
* message(assistant / tool_use / thinking final / done 等)时由 main 透传过来。
@@ -1879,7 +1879,7 @@ interface ElectronAPI {
/** 被控端 renderer → 自身 main:会话「非选中模型」effort/fast 变化镜像(转发给控制端)。 */
syncSessionModelPref: (pref: {
sessionId: string;
- agent: 'claude-code' | 'codex';
+ agent: 'claude-code' | 'codex' | 'pi';
providerId: string;
model: string;
effort?: string;
@@ -1889,7 +1889,7 @@ interface ElectronAPI {
/** 被控端本地 main → 自身 renderer:控制端写穿的草稿「模型 effort/fast」pref(调本地 setter)。 */
onMakerDraftPrefApply: (
cb: (payload: {
- agent: 'claude-code' | 'codex';
+ agent: 'claude-code' | 'codex' | 'pi';
providerId: string;
modelId: string;
active: boolean;
@@ -1908,7 +1908,7 @@ interface ElectronAPI {
onMakerSessionPrefApply: (
cb: (payload: {
sessionId: string;
- agent: 'claude-code' | 'codex';
+ agent: 'claude-code' | 'codex' | 'pi';
providerId: string;
model: string;
effort?: string;
@@ -2420,7 +2420,7 @@ interface ElectronAPI {
workingDir: string;
cap?: number;
query?: string;
- agentKind?: 'claude-code' | 'codex';
+ agentKind?: 'claude-code' | 'codex' | 'pi';
}) => Promise<{
success: boolean;
error?: string;
@@ -3813,8 +3813,8 @@ interface ElectronAPI {
* apps/desktop/src/main/maker-ipc/ 的 handlers + apps/desktop/src/main/maker-host/。
*/
maker: {
- listAvailableAgents: () => Promise<Array<'claude-code' | 'codex'>>;
- getCapabilities: (agentKind: 'claude-code' | 'codex') => Promise<unknown>;
+ listAvailableAgents: () => Promise<Array<'claude-code' | 'codex' | 'pi'>>;
+ getCapabilities: (agentKind: 'claude-code' | 'codex' | 'pi') => Promise<unknown>;
/** workflow 逐 agent 进度树(只读);读不到 / 解析失败返回 null → 回退 workflow 级卡片。 */
getWorkflowProgress: (
sessionId: string,
@@ -3835,11 +3835,11 @@ interface ElectronAPI {
// 自定义供应商配置 CRUD(配置与 runtime 密钥均由 main 原子排队)。
createCustomProvider: (
config: import('@cindy/model-providers').CustomProviderConfig,
- keys: Partial<Record<'claude-code' | 'codex', string>>,
+ keys: Partial<Record<'claude-code' | 'codex' | 'pi', string>>,
) => Promise<{ ok: true }>;
updateCustomProvider: (
config: import('@cindy/model-providers').CustomProviderConfig,
- keys: Partial<Record<'claude-code' | 'codex', string>>,
+ keys: Partial<Record<'claude-code' | 'codex' | 'pi', string>>,
) => Promise<{ ok: true }>;
deleteCustomProvider: (providerId: string) => Promise<{ ok: true }>;
/** 自定义供应商创建模板(目录 presets 段,纯 UI 模板数据)。 */
@@ -3847,11 +3847,11 @@ interface ElectronAPI {
/** 供应商「测试连接」—— 与真实会话同路由口径的最小探测请求(结构化结果,code 走 providerError.* i18n)。 */
testProviderConnection: (
input:
- | { kind: 'saved'; providerId: string; agent: 'claude-code' | 'codex' }
+ | { kind: 'saved'; providerId: string; agent: 'claude-code' | 'codex' | 'pi' }
| {
kind: 'adhoc';
spec: {
- agent: 'claude-code' | 'codex';
+ agent: 'claude-code' | 'codex' | 'pi';
baseUrl: string;
modelId: string;
authMethod: 'apiKey' | 'oauth' | 'none';
@@ -3870,7 +3870,7 @@ interface ElectronAPI {
}>;
/** 供应商「获取模型列表」—— 表单值透传,结构化结果(code 走 providerError.* i18n)。 */
fetchProviderModels: (input: {
- agent: 'claude-code' | 'codex';
+ agent: 'claude-code' | 'codex' | 'pi';
baseUrl: string;
authMethod: 'apiKey' | 'oauth' | 'none';
wireProtocol?: import('@cindy/model-providers').ProviderWireProtocol;
@@ -3940,7 +3940,7 @@ interface ElectronAPI {
/** 自定义供应商上游错误订阅(返回 off);code 走 providerError.* i18n。 */
onProviderUpstreamError: (
cb: (event: {
- agent: 'claude-code' | 'codex';
+ agent: 'claude-code' | 'codex' | 'pi';
providerId: string;
providerName?: string;
code: import('../shared/providerErrors').ProviderErrorCode;
@@ -4008,7 +4008,7 @@ interface ElectronAPI {
) => Promise<{ success: boolean; error?: string }>;
listAgentCommands: (
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
) => Promise<{
success: boolean;
error?: string;
@@ -4016,7 +4016,7 @@ interface ElectronAPI {
}>;
listAgentSkills: (
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
params: { workingDir?: string; forceReload?: boolean },
) => Promise<{
success: boolean;
@@ -4077,7 +4077,7 @@ interface ElectronAPI {
) => () => void;
scanAtResources: (
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
params: { workingDir: string; cap?: number; query?: string },
) => Promise<{
success: boolean;
@@ -4093,7 +4093,7 @@ interface 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;
@@ -4131,7 +4131,7 @@ interface ElectronAPI {
enableOrca: (
leadSessionId: string,
opts: {
- workerAgent: 'claude-code' | 'codex';
+ workerAgent: 'claude-code' | 'codex' | 'pi';
delegateTask?: string;
role?: string;
label?: string;
@@ -4159,7 +4159,7 @@ interface 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?: import('@/lib/ccAgent.types').OrcaRole | null;
@@ -4204,7 +4204,7 @@ interface ElectronAPI {
getContextUsage: (
sessionId: string,
createOpts?: {
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workingDir: string;
model: string;
orcaRole?: import('@/lib/ccAgent.types').OrcaRole | null;
@@ -4232,7 +4232,7 @@ interface ElectronAPI {
) => Promise<{ sessionId: string; clientId: string; clientIds: string[] }>;
listActive: () => Promise<Array<{
sessionId: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workDir: string;
capabilities: unknown;
isTurnRunning: boolean;
@@ -4336,12 +4336,12 @@ interface ElectronAPI {
*/
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 }>;
// effort/mode 透传 string —— 合法值由 maker capabilities 决定, vite-env 不重复枚举
setEffort: (sessionId: string, effort: string) => Promise<void>;
setPermissionMode: (sessionId: string, mode: string) => Promise<void>;
@@ -4356,13 +4356,13 @@ interface ElectronAPI {
setExtraDirs: (sessionId: string, dirs: string[]) => Promise<void>;
// Memory 控制 (Settings → Personalization → Memory section)
- 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 };
}>;
memorySet: (
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
enabled: boolean,
) => Promise<{
effective: 'immediate' | 'next-session';
@@ -4370,7 +4370,7 @@ interface ElectronAPI {
customizedKeys: string[];
defaults: { maker: boolean; claudeCode: boolean; codex: boolean };
}>;
- memoryReset: (agentKind: 'claude-code' | 'codex') => Promise<{
+ memoryReset: (agentKind: 'claude-code' | 'codex' | 'pi') => Promise<{
removedEntries?: number;
removedBytes?: number;
}>;
@@ -4557,7 +4557,7 @@ interface ElectronAPI {
// Stage 2 C1: chat utility (前身 cc-agent:generate-title / cc-agent:plan-file-write)
generateTitle: (
message: string,
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
sessionId?: string,
) => Promise<{ title: string | null }>;
/** 重命名输入框 Magic 按钮:按会话最新对话内容重新生成标题(失败返 title: null)。 */
@@ -4570,7 +4570,7 @@ interface ElectronAPI {
autoTitle: (request: {
sessionId: string;
text: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
isUserText?: boolean;
}) => Promise<{ applied: boolean; done: boolean }>;
helpAsk: (
@@ -4645,22 +4645,22 @@ interface ElectronAPI {
/* ── Agent 鉴权 (取代老 codex.auth.*) ── */
auth: {
- getState: (agentKind: 'claude-code' | 'codex') => Promise<CodexAuthState>;
+ getState: (agentKind: 'claude-code' | 'codex' | 'pi') => Promise<CodexAuthState>;
triggerLogin: (
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
options?: { mode?: 'browser' | 'device-code'; ownerId?: string },
) => Promise<CodexAuthState>;
cancelLogin: (
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
options?: { releaseOwner?: boolean; ownerId?: string },
) => Promise<void>;
- logout: (agentKind: 'claude-code' | 'codex') => Promise<void>;
+ logout: (agentKind: 'claude-code' | 'codex' | 'pi') => Promise<void>;
onStateChanged: (
- cb: (s: { agentKind: 'claude-code' | 'codex' } & CodexAuthState) => void,
+ cb: (s: { agentKind: 'claude-code' | 'codex' | 'pi' } & CodexAuthState) => void,
) => () => void;
onLoginProgress: (
cb: (p: {
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
phase: string;
mode?: 'browser' | 'device-code';
detail?: string;
@@ -4672,15 +4672,15 @@ interface ElectronAPI {
/* ── Agent 联合状态 (binary + auth, 取代老 codex.binary.getStatus) ── */
agent: {
- getStatus: (agentKind: 'claude-code' | 'codex') => Promise<{
+ getStatus: (agentKind: 'claude-code' | 'codex' | 'pi') => Promise<{
binaryReady: boolean;
binaryPath: string;
authReady: boolean;
identity?: string;
}>;
/** 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;
@@ -4689,7 +4689,7 @@ interface ElectronAPI {
/* ── Agent 今日累计 (取代老 codex.usage.* + onUsageTodaySpendChanged) ── */
usage: {
- getToday: (agentKind: 'claude-code' | 'codex') => Promise<{
+ getToday: (agentKind: 'claude-code' | 'codex' | 'pi') => Promise<{
day: string;
money?: import('../shared/regionalMoney').RegionalMoney;
costUsd?: number;
@@ -4699,7 +4699,7 @@ interface ElectronAPI {
reasoningTokens?: number;
cachedTokens?: number;
}>;
- getAccount: (agentKind: 'claude-code' | 'codex') => Promise<unknown | null>;
+ getAccount: (agentKind: 'claude-code' | 'codex' | 'pi') => Promise<unknown | null>;
/** Codex app-server authoritative windows and banked reset-credit metadata. */
getCodexRateLimits: () => Promise<
import('@cindy/maker-shared/device-link-contract').MobileCodexRateLimitsResult
@@ -4776,7 +4776,7 @@ interface ElectronAPI {
crossAgent: {
detect: (
workingDir: string,
- agentKind: 'claude-code' | 'codex',
+ agentKind: 'claude-code' | 'codex' | 'pi',
) => Promise<{ items: CrossAgentMigrationItem[] }>;
convert: (
items: CrossAgentMigrationItem[],
@@ -4836,7 +4836,7 @@ interface ElectronAPI {
scheduleName?: string;
workingDir?: string;
providerId?: string;
- agentKind?: 'claude-code' | 'codex';
+ agentKind?: 'claude-code' | 'codex' | 'pi';
model?: string;
/** 绑定会话任务:workingDir 空时 main 按会话 meta.workDir 解析落盘/自测目录。 */
targetSessionId?: string;
@@ -5015,9 +5015,9 @@ interface SkillhubSkill {
/** URL 匹配键 — 不含 engine,和路由格式一致,用于侧栏选中高亮。 */
urlKey: string;
/** 来自哪个 agent 引擎。 */
- engine: 'claude-code' | 'codex';
+ engine: 'claude-code' | 'codex' | 'pi';
/** 发现该 skill 的所有引擎专属路径(去重后)。 */
- linkedEngines: Array<{ engine: 'claude-code' | 'codex'; label: string }>;
+ linkedEngines: Array<{ engine: 'claude-code' | 'codex' | 'pi'; label: string }>;
kind: SkillhubKind;
scope: SkillhubScope;
name: string;
@@ -5143,7 +5143,7 @@ interface SkillUsageEvidenceIndex {
rawLineNo: number;
sessionId: string;
sdkSessionId: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
skillName: string;
skillPath: string | null;
skillDocumentHash: string | null;
diff --git a/apps/desktop/src/shared/agentInputQueue.ts b/apps/desktop/src/shared/agentInputQueue.ts
index 54d9e61289..31a58dc5a7 100644
--- a/apps/desktop/src/shared/agentInputQueue.ts
+++ b/apps/desktop/src/shared/agentInputQueue.ts
@@ -116,7 +116,7 @@ export interface AgentInputChatMessage {
}
export interface AgentInputCreateOpts {
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workingDir: string;
model: string;
providerId?: string | null;
diff --git a/apps/desktop/src/shared/imDefaultSettings.ts b/apps/desktop/src/shared/imDefaultSettings.ts
index d773f1de80..4f1f2181d1 100644
--- a/apps/desktop/src/shared/imDefaultSettings.ts
+++ b/apps/desktop/src/shared/imDefaultSettings.ts
@@ -1,4 +1,4 @@
-export type ImDefaultAgentKind = 'claude-code' | 'codex';
+export type ImDefaultAgentKind = 'claude-code' | 'codex' | 'pi';
export type ImDefaultPermissionMode =
'ask' | 'default' | 'acceptEdits' | 'plan' | 'auto' | 'bypassPermissions';
export type ImDefaultEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'ultra';
@@ -48,6 +48,12 @@ export const IM_DEFAULT_SETTINGS: ImDefaultSettings = {
model: 'codex/gpt-5.5',
effort: 'high',
},
+ // pi(实验性):IM 渠道设置 UI 尚未暴露 pi,此项仅满足满射类型;走网关中档模型。
+ pi: {
+ providerId: null,
+ model: 'claude-sonnet-5',
+ effort: 'high',
+ },
},
};
diff --git a/apps/mobile/src/__tests__/homeDesktopFirst.test.ts b/apps/mobile/src/__tests__/homeDesktopFirst.test.ts
index 36266453d8..61beb24ee0 100644
--- a/apps/mobile/src/__tests__/homeDesktopFirst.test.ts
+++ b/apps/mobile/src/__tests__/homeDesktopFirst.test.ts
@@ -122,8 +122,10 @@ describe('mobile home desktop-first surface', () => {
// ——箭头统一后依赖图标区分 agent 类型的场景(创建自动化 chips / 侧栏混排)全部失效。
expect(desktopVendorIconSource).toContain('ClaudeMark');
expect(desktopVendorIconSource).toContain('CodexMark');
- expect(desktopVendorIconSource).toContain("vendor === 'codex' ? <CodexMark size={size} /> : <ClaudeMark size={size} />");
- expect(desktopVendorIconSource).toContain("vendor: 'cc' | 'codex'");
+ expect(desktopVendorIconSource).toContain("vendor === 'codex' ? (");
+ expect(desktopVendorIconSource).toContain('<CodexMark size={size} />');
+ expect(desktopVendorIconSource).toContain('<ClaudeMark size={size} />');
+ expect(desktopVendorIconSource).toContain("vendor: 'cc' | 'codex' | 'pi'");
expect(desktopVendorIconSource).toContain('session-status-breathing');
expect(vendorIconSource).not.toContain('XD_SYMBOL_PATHS');
expect(vendorIconSource).not.toContain('XD_INC_MARK_ASPECT_RATIO');
diff --git a/apps/mobile/src/device-link/mobileMakerTransport.ts b/apps/mobile/src/device-link/mobileMakerTransport.ts
index 3d5830fc3e..ff7bdef933 100644
--- a/apps/mobile/src/device-link/mobileMakerTransport.ts
+++ b/apps/mobile/src/device-link/mobileMakerTransport.ts
@@ -90,7 +90,7 @@ export interface CreateSessionResult {
usedProjectContext?: boolean;
}
-export type MobileAgentKind = 'claude-code' | 'codex';
+export type MobileAgentKind = 'claude-code' | 'codex' | 'pi';
export type MobileSlashCommand =
| { kind: 'agent-builtin'; name: string; description: string }
diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsx
index 1799947871..f52cb303d7 100644
--- a/apps/mobile/src/session/MessageRenderer.tsx
+++ b/apps/mobile/src/session/MessageRenderer.tsx
@@ -2391,6 +2391,7 @@ function agentTaskStatusLabel(status: AgentTaskStatus): string {
const AGENT_TASK_PROVIDER_LABEL: Record<AgentTaskCardModel['provider'], string> = {
'claude-code': 'Claude Code',
codex: 'Codex',
+ pi: 'Pi',
};
function AgentTaskStatusIcon({ status, size = iconSize.md }: { status: AgentTaskStatus; size?: number }) {
diff --git a/packages/lizi-mcps/src/scheduler/setPreRunHook.ts b/packages/lizi-mcps/src/scheduler/setPreRunHook.ts
index 942791e571..6392317198 100644
--- a/packages/lizi-mcps/src/scheduler/setPreRunHook.ts
+++ b/packages/lizi-mcps/src/scheduler/setPreRunHook.ts
@@ -88,7 +88,7 @@ export function registerScheduleSetPreRunHookTool(
let currentCommand: string | undefined;
let currentTimeoutMs: number | undefined;
let providerId: string | undefined;
- let agentKind: 'codex' | 'claude-code' | undefined;
+ let agentKind: 'codex' | 'claude-code' | 'pi' | undefined;
let model: string | undefined;
if (scheduleId) {
const schedule = await scheduler.get(scheduleId);
diff --git a/packages/lizi-mcps/src/types.ts b/packages/lizi-mcps/src/types.ts
index e241d89478..8fae5c4f61 100644
--- a/packages/lizi-mcps/src/types.ts
+++ b/packages/lizi-mcps/src/types.ts
@@ -488,7 +488,7 @@ export type ControlResult<T extends object = object, E extends string = never> =
* adding a new vendor (e.g. 'gemini') without updating this union will cause
* LLM tool calls to fail zod enum validation.
*/
-export type ControlWorkerAgent = 'claude-code' | 'codex';
+export type ControlWorkerAgent = 'claude-code' | 'codex' | 'pi';
/** Browser automation MCP host deps. Core browser execution is injected by host. */
export interface BrowserMcpDeps {
diff --git a/packages/lizi-mcps/src/xdt-helper/get_current_session_id.ts b/packages/lizi-mcps/src/xdt-helper/get_current_session_id.ts
index 49480ff464..20084b3969 100644
--- a/packages/lizi-mcps/src/xdt-helper/get_current_session_id.ts
+++ b/packages/lizi-mcps/src/xdt-helper/get_current_session_id.ts
@@ -5,7 +5,7 @@ import { errorPayload, okPayload } from './_payload.js';
export interface GetCurrentSessionIdDeps {
getSessionContext: () => {
sessionId?: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workingDir: string;
};
}
diff --git a/packages/lizi-mcps/src/xdt-helper/list_available_models.ts b/packages/lizi-mcps/src/xdt-helper/list_available_models.ts
index dffdea0e7a..7ceeb4deb7 100644
--- a/packages/lizi-mcps/src/xdt-helper/list_available_models.ts
+++ b/packages/lizi-mcps/src/xdt-helper/list_available_models.ts
@@ -41,7 +41,7 @@ function tagTier(models: ModelDescriptor[] | undefined): TaggedModel[] | undefin
export interface ListAvailableModelsDeps {
listAvailableModels: (params: {
- agent?: 'claude-code' | 'codex';
+ agent?: 'claude-code' | 'codex' | 'pi';
}) => Promise<ControlResult<{
codex?: ModelDescriptor[];
claude_code?: ModelDescriptor[];
diff --git a/packages/lizi-mcps/src/xdt-helper/send_to_worker.ts b/packages/lizi-mcps/src/xdt-helper/send_to_worker.ts
index 89b1d5134c..9dc2c75dac 100644
--- a/packages/lizi-mcps/src/xdt-helper/send_to_worker.ts
+++ b/packages/lizi-mcps/src/xdt-helper/send_to_worker.ts
@@ -22,7 +22,7 @@ export interface SendToWorkerDeps {
}) => Promise<
ControlResult<
{
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
wakeKind: 'resumed' | 'already-active' | 'queued';
targetTitle: string | null;
targetLastUserSendAt: string | null;
diff --git a/packages/lizi-mcps/src/xdt-helper/set_current_session_title.ts b/packages/lizi-mcps/src/xdt-helper/set_current_session_title.ts
index f6f46a791f..2ab8b06613 100644
--- a/packages/lizi-mcps/src/xdt-helper/set_current_session_title.ts
+++ b/packages/lizi-mcps/src/xdt-helper/set_current_session_title.ts
@@ -16,7 +16,7 @@ export type SetCurrentSessionTitleResult = ControlResult<
export interface SetCurrentSessionTitleDeps {
getSessionContext: () => {
sessionId?: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workingDir: string;
};
setCurrentSessionTitle(params: {
diff --git a/packages/lizi-mcps/src/xdt-helper/submit_github_issue.ts b/packages/lizi-mcps/src/xdt-helper/submit_github_issue.ts
index 85b4aea509..9ffd068524 100644
--- a/packages/lizi-mcps/src/xdt-helper/submit_github_issue.ts
+++ b/packages/lizi-mcps/src/xdt-helper/submit_github_issue.ts
@@ -48,7 +48,7 @@ export type SubmitGithubIssueHostResult =
export interface SubmitGithubIssueDeps {
getSessionContext: () => {
sessionId?: string;
- agentKind: 'claude-code' | 'codex';
+ agentKind: 'claude-code' | 'codex' | 'pi';
workingDir: string;
};
/** host 回调:弹确认卡片 → 用户确认后提交到 server。 */
diff --git a/packages/maker-core/src/types/events.ts b/packages/maker-core/src/types/events.ts
index 33eb895780..1c9272a70b 100644
--- a/packages/maker-core/src/types/events.ts
+++ b/packages/maker-core/src/types/events.ts
@@ -57,7 +57,7 @@ export interface AgentTaskUsage {
}
export interface AgentTaskUpdateEventData {
- provider: 'claude-code' | 'codex';
+ provider: 'claude-code' | 'codex' | 'pi';
/** Provider task id when available; falls back to the parent tool call id. */
taskId: string;
/** The tool_use id that launched or controls this subagent task. */
diff --git a/packages/maker-scheduler/src/types.ts b/packages/maker-scheduler/src/types.ts
index 603299b871..930fd42817 100644
--- a/packages/maker-scheduler/src/types.ts
+++ b/packages/maker-scheduler/src/types.ts
@@ -1,5 +1,5 @@
export type ScheduleKind = 'cron';
-export type AgentKind = 'claude-code' | 'codex';
+export type AgentKind = 'claude-code' | 'codex' | 'pi';
export type ScheduleStatus = 'active' | 'paused' | 'expired';
export type ScheduleWorkspaceKind = 'project' | 'dialogue';
export type ScheduleExecutionMode = 'agent' | 'script';
diff --git a/packages/maker-shared/src/agentTask.ts b/packages/maker-shared/src/agentTask.ts
index 8d877c8dce..5d57261d1e 100644
--- a/packages/maker-shared/src/agentTask.ts
+++ b/packages/maker-shared/src/agentTask.ts
@@ -128,7 +128,7 @@ export function normalizeWorkflowProgressEntries(
}
export interface AgentTaskUpdate {
- provider: 'claude-code' | 'codex';
+ provider: 'claude-code' | 'codex' | 'pi';
taskId: string;
parentToolUseId?: string;
status: AgentTaskStatus;
@@ -163,7 +163,7 @@ export function isAgentTaskToolName(toolName: string): boolean {
*/
export function normalizeAgentTaskUpdate(
data: unknown,
- source?: 'claude-code' | 'codex',
+ source?: 'claude-code' | 'codex' | 'pi',
): AgentTaskUpdate | null {
if (!data || typeof data !== 'object') return null;
const raw = data as Record<string, unknown>;
@@ -254,7 +254,7 @@ export function isSameAgentTaskAlias(left: AgentTaskUpdate, right: AgentTaskUpda
export function applyAgentTaskUpdateEvent(
prevMap: ReadonlyMap<string, AgentTaskUpdate> | undefined,
data: unknown,
- source: 'claude-code' | 'codex' | undefined,
+ source: 'claude-code' | 'codex' | 'pi' | undefined,
nowIso: string,
): Map<string, AgentTaskUpdate> | null {
const update = normalizeAgentTaskUpdate(data, source);
@@ -309,7 +309,7 @@ export function findAgentTaskUpdate(
*/
export interface AgentTaskCardModel {
status: AgentTaskStatus;
- provider: 'claude-code' | 'codex';
+ provider: 'claude-code' | 'codex' | 'pi';
/** Best title, or null when nothing usable was found (caller supplies its own fallback). */
title: string | null;
description?: string;
@@ -329,7 +329,7 @@ export function buildAgentTaskCardModel(input: {
}): AgentTaskCardModel {
const { toolName, toolInput, update, result } = input;
const status: AgentTaskStatus = update?.status ?? (result ? 'completed' : 'running');
- const provider: 'claude-code' | 'codex' =
+ const provider: 'claude-code' | 'codex' | 'pi' =
update?.provider ?? (toolName?.startsWith('collab:') ? 'codex' : 'claude-code');
const title = compactText(
update?.title
diff --git a/packages/model-providers/src/types.ts b/packages/model-providers/src/types.ts
index 13dbe687a0..1c6f834a99 100644
--- a/packages/model-providers/src/types.ts
+++ b/packages/model-providers/src/types.ts
@@ -19,7 +19,7 @@
*/
/** 承载模型的 agent runtime —— 与 maker-core AgentKind 对齐。 */
-export type AgentKind = 'claude-code' | 'codex';
+export type AgentKind = 'claude-code' | 'codex' | 'pi';
/** 推理强度档位 —— 与 maker-core Effort 对齐。 */
export type Effort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'ultra';