mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-25 05:07:05 +00:00
feat(opencode): add plan mode, reasoning effort, and status telemetry (#688)
* feat(opencode): support plan mode * feat(opencode): support reasoning effort * feat(opencode): surface context usage in web Bridge OpenCode ACP usage updates into the existing token-count pipeline so the web status bar can show live context and cache information without a separate UI path. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(opencode): restrict plan mode to remote, rollback reasoning effort on failure - Block local OpenCode plan startup (tools not enforced in local path) - Allow remote OpenCode plan only (ACP permission handler denies tools) - Guard web /permission-mode endpoint for local OpenCode plan sessions - Rollback session reasoning effort when OpenCode rejects set_config_option - Wire rollback callback through opencodeLoop to runOpencode closure - Add tests: local plan rejected, remote plan allowed, web guard, effort rollback * fix(web): auto-retry OpenCode models query to populate model selector without refresh - Retry early failures (RPC may still be registering on new sessions) - Poll briefly until availableModels is non-empty - Stop polling once model options are discovered - Add tests for retry/poll/stop policy * fix(opencode): cap model discovery polling --------- Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,12 +7,14 @@ import type { RpcHandlerManager } from '@/api/rpc/RpcHandlerManager'
|
||||
type SessionConfigState<TPermissionMode extends PermissionMode = PermissionMode> = {
|
||||
permissionMode?: TPermissionMode
|
||||
model?: string | null
|
||||
modelReasoningEffort?: string | null
|
||||
}
|
||||
|
||||
type RegisterSessionConfigRpcOptions<TPermissionMode extends PermissionMode = PermissionMode> = {
|
||||
rpcHandlerManager: RpcHandlerManager
|
||||
flavor: AgentFlavor
|
||||
modelMode?: 'nullable' | 'ignore' | 'reject'
|
||||
modelReasoningEffortMode?: 'nullable' | 'ignore' | 'reject'
|
||||
appliedFallback?: () => Record<string, unknown>
|
||||
onApply: (config: SessionConfigState<TPermissionMode>) => void
|
||||
onAfterApply?: () => void
|
||||
@@ -43,6 +45,7 @@ export function registerSessionConfigRpc<TPermissionMode extends PermissionMode>
|
||||
rpcHandlerManager,
|
||||
flavor,
|
||||
modelMode = 'reject',
|
||||
modelReasoningEffortMode = 'reject',
|
||||
appliedFallback,
|
||||
onApply,
|
||||
onAfterApply
|
||||
@@ -52,7 +55,7 @@ export function registerSessionConfigRpc<TPermissionMode extends PermissionMode>
|
||||
throw new Error('Invalid session config payload')
|
||||
}
|
||||
|
||||
const config = payload as { permissionMode?: unknown; model?: unknown }
|
||||
const config = payload as { permissionMode?: unknown; model?: unknown; modelReasoningEffort?: unknown }
|
||||
const applied: Record<string, unknown> = {}
|
||||
const next: SessionConfigState<TPermissionMode> = {}
|
||||
|
||||
@@ -71,6 +74,17 @@ export function registerSessionConfigRpc<TPermissionMode extends PermissionMode>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (config.modelReasoningEffort !== undefined) {
|
||||
if (modelReasoningEffortMode === 'reject') {
|
||||
throw new Error('Invalid model reasoning effort')
|
||||
}
|
||||
if (modelReasoningEffortMode === 'nullable') {
|
||||
next.modelReasoningEffort = resolveNullableSessionModel(config.modelReasoningEffort)
|
||||
applied.modelReasoningEffort = next.modelReasoningEffort
|
||||
}
|
||||
}
|
||||
|
||||
onApply(next)
|
||||
onAfterApply?.()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user