Files
hapi/web/src/lib/codexFamilyPermissionAgents.ts
T
ffd950a220 fix(codex): drop safe-yolo from Codex permission modes (#2183)
* fix(codex): drop safe-yolo from Codex permission modes

Every Codex session runs on the native shared runtime (runCodex is
runSharedCodex), which rejects safe-yolo. The mode stayed in
CODEX_PERMISSION_MODES and six filters hid it again in the web picker,
composer, hub permission-mode route, hapi set-mode and both native
apps. API callers that validate against the flavor catalog (e.g. a
spawn with permissionMode: 'safe-yolo') still passed it through and
only failed inside the runner.

Remove it from the Codex catalog (shared, iOS, Android, fixture) and
delete the filters. autoReview is the native replacement. Safe Yolo
stays for Gemini, Kimi and Copilot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(ios): Codex option list now has four modes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 12:12:55 +08:00

51 lines
2.1 KiB
TypeScript

import type { AgentFlavor } from '@hapi/protocol'
/** Agents that share codex-family permission modes (default / read-only / yolo). */
export const CODEX_FAMILY_PERMISSION_AGENTS = [
'codex',
'gemini',
'kimi',
'copilot',
'opencode'
] as const satisfies readonly AgentFlavor[]
export type CodexFamilyPermissionAgent = typeof CODEX_FAMILY_PERMISSION_AGENTS[number]
export function usesCodexFamilyPermissionModes(
flavor: string | null | undefined
): flavor is CodexFamilyPermissionAgent {
return typeof flavor === 'string'
&& (CODEX_FAMILY_PERMISSION_AGENTS as readonly string[]).includes(flavor)
}
/**
* Flavors whose create-form permission control is the native-mode select.
* Ports: `NewSessionLogic.usesNativePermissionSelect`
* (`ios/Packages/HapiKit/Sources/HapiClient/NewSession/NewSessionForm.swift`,
* `android/app/src/main/kotlin/app/hapi/companion/feature/newsession/NewSessionForm.kt`).
* claude and grok do not share the codex-family mode set, but they render
* through the same native select.
*/
export function usesNativePermissionSelect(flavor: string | null | undefined): boolean {
return flavor === 'claude' || flavor === 'grok' || usesCodexFamilyPermissionModes(flavor)
}
/**
* Flavors that keep their create-form permission choice in the single shared
* `nativePermissionMode` state. Grok is a native-select flavor but is
* excluded: its Auto option depends on a machine capability
* (`autoPermissionModeSupported`) that the other native-select flavors do
* not gate on, so it keeps its own state (`grokPermissionMode`) instead.
*/
export function usesSharedPermissionModeState(flavor: string | null | undefined): boolean {
return usesNativePermissionSelect(flavor) && flavor !== 'grok'
}
/**
* Flavors whose create surface carried the HAPI YOLO toggle before it moved
* to the native permission select. Their stored toggle preference migrates
* once into the native mode it mapped to; flavors that moved earlier already
* settled on 'default' and are intentionally left alone.
*/
export const LEGACY_YOLO_BRIDGE_AGENTS: readonly AgentFlavor[] = ['codex', 'claude']