mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-25 05:07:05 +00:00
Effort looked and behaved differently per harness. Codex and OpenCode had no toolbar button and called it "Reasoning effort", Claude called the unset choice "Auto" while others said "Default", Chinese used both 思考强度 and 推理强度, and the status bar and header showed effort only for Codex, OpenCode and Pi. - Codex/OpenCode get the same toolbar effort button as Claude; it opens the same anchored Effort section. - Every effort picker is titled Effort (推理强度), and the unset choice is Default everywhere. An unset toolbar button reads "Default effort". - The status bar, header, shared-turn metadata and Codex agent tool cards use one "effort <level>" label. Claude and Grok now show their effort, with "default" when unset; Pi and AGY show it only when set, since their models may not take one. via [HAPI](https://hapi.run) Co-authored-by: HAPI <noreply@hapi.run> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { CLAUDE_EFFORT_LABELS, CLAUDE_EFFORT_LEVELS, type ClaudeEffortLevel } from '@hapi/protocol'
|
|
|
|
export type ClaudeComposerEffortOption = {
|
|
value: string | null
|
|
label: string
|
|
}
|
|
|
|
function normalizeClaudeComposerEffort(effort?: string | null): string | null {
|
|
const trimmedEffort = effort?.trim().toLowerCase()
|
|
if (!trimmedEffort || trimmedEffort === 'auto' || trimmedEffort === 'default') {
|
|
return null
|
|
}
|
|
|
|
return trimmedEffort
|
|
}
|
|
|
|
function formatEffortLabel(effort: string): string {
|
|
return CLAUDE_EFFORT_LABELS[effort as keyof typeof CLAUDE_EFFORT_LABELS]
|
|
?? `${effort.charAt(0).toUpperCase()}${effort.slice(1)}`
|
|
}
|
|
|
|
/**
|
|
* `supportedLevels` narrows the list to what the current model accepts
|
|
* (`[]` = no effort control); undefined offers every level.
|
|
*/
|
|
export function getClaudeComposerEffortOptions(
|
|
currentEffort?: string | null,
|
|
supportedLevels?: readonly string[]
|
|
): ClaudeComposerEffortOption[] {
|
|
const normalizedCurrentEffort = normalizeClaudeComposerEffort(currentEffort)
|
|
const levels: readonly ClaudeEffortLevel[] = supportedLevels
|
|
? CLAUDE_EFFORT_LEVELS.filter((effort) => supportedLevels.includes(effort))
|
|
: CLAUDE_EFFORT_LEVELS
|
|
const options: ClaudeComposerEffortOption[] = [
|
|
{ value: null, label: 'Default' }
|
|
]
|
|
|
|
if (
|
|
normalizedCurrentEffort
|
|
&& !levels.includes(normalizedCurrentEffort as ClaudeEffortLevel)
|
|
) {
|
|
options.push({
|
|
value: normalizedCurrentEffort,
|
|
label: formatEffortLabel(normalizedCurrentEffort)
|
|
})
|
|
}
|
|
|
|
options.push(...levels.map((effort) => ({
|
|
value: effort,
|
|
label: CLAUDE_EFFORT_LABELS[effort]
|
|
})))
|
|
|
|
return options
|
|
}
|