novacode-cli 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- novacode_cli/__init__.py +29 -0
- novacode_cli/__main__.py +6 -0
- novacode_cli/_lazy_heavy.py +99 -0
- novacode_cli/_version.py +3 -0
- novacode_cli/agent_stream.py +178 -0
- novacode_cli/agents/agent_file.py +250 -0
- novacode_cli/agents/agent_mailbox.py +120 -0
- novacode_cli/agents/approval_decisions.py +146 -0
- novacode_cli/agents/arg_repair.py +196 -0
- novacode_cli/agents/async_agents/__init__.py +6 -0
- novacode_cli/agents/async_agents/_config.py +213 -0
- novacode_cli/agents/async_agents/_mcp_tools.py +192 -0
- novacode_cli/agents/async_agents/_specialist.py +84 -0
- novacode_cli/agents/async_agents/_test_commands.py +89 -0
- novacode_cli/agents/async_agents/_tools.py +432 -0
- novacode_cli/agents/async_agents/general_purpose.py +42 -0
- novacode_cli/agents/async_agents/langgraph.json +9 -0
- novacode_cli/agents/async_agents/research.py +22 -0
- novacode_cli/agents/async_context.py +303 -0
- novacode_cli/agents/async_on_demand.py +52 -0
- novacode_cli/agents/async_task_errors.py +75 -0
- novacode_cli/agents/async_workspace.py +27 -0
- novacode_cli/agents/attribution.py +165 -0
- novacode_cli/agents/browser_mode.py +119 -0
- novacode_cli/agents/btw_agent.py +71 -0
- novacode_cli/agents/caveman.py +352 -0
- novacode_cli/agents/caveman_support.py +370 -0
- novacode_cli/agents/code_mode.py +774 -0
- novacode_cli/agents/code_runtime.py +160 -0
- novacode_cli/agents/context_compaction.py +1339 -0
- novacode_cli/agents/core_agent.py +2710 -0
- novacode_cli/agents/default_subagents/__init__.py +24 -0
- novacode_cli/agents/default_subagents/async_subagents.py +296 -0
- novacode_cli/agents/default_subagents/builtin/browser-automation-agent.md +110 -0
- novacode_cli/agents/default_subagents/builtin/bug-fix-agent.md +22 -0
- novacode_cli/agents/default_subagents/builtin/bug-investigation-agent.md +42 -0
- novacode_cli/agents/default_subagents/builtin/code-explorer.md +37 -0
- novacode_cli/agents/default_subagents/builtin/code-review-agent.md +33 -0
- novacode_cli/agents/default_subagents/builtin/dependency-audit-agent.md +34 -0
- novacode_cli/agents/default_subagents/builtin/documentation-update-agent.md +46 -0
- novacode_cli/agents/default_subagents/builtin/performance-audit-agent.md +41 -0
- novacode_cli/agents/default_subagents/builtin/plan-scout-agent.md +64 -0
- novacode_cli/agents/default_subagents/builtin/refactoring-agent.md +35 -0
- novacode_cli/agents/default_subagents/builtin/refactoring-specialist-agent.md +175 -0
- novacode_cli/agents/default_subagents/builtin/security-audit-agent.md +96 -0
- novacode_cli/agents/default_subagents/builtin/test-generation-agent.md +33 -0
- novacode_cli/agents/default_subagents/builtin/test-runner-agent.md +55 -0
- novacode_cli/agents/default_subagents/prompt.py +88 -0
- novacode_cli/agents/default_subagents/subagents.py +138 -0
- novacode_cli/agents/dream_agent.py +93 -0
- novacode_cli/agents/edit_diagnostics.py +362 -0
- novacode_cli/agents/edit_fallback.py +62 -0
- novacode_cli/agents/handoff.py +166 -0
- novacode_cli/agents/invocation.py +152 -0
- novacode_cli/agents/model_budget.py +42 -0
- novacode_cli/agents/model_retry.py +113 -0
- novacode_cli/agents/model_router.py +420 -0
- novacode_cli/agents/openai_decisions.py +186 -0
- novacode_cli/agents/plan_agent/__init__.py +12 -0
- novacode_cli/agents/plan_agent/plan_agent.py +357 -0
- novacode_cli/agents/plan_agent/plan_mode_middleware.py +64 -0
- novacode_cli/agents/plan_execution.py +237 -0
- novacode_cli/agents/ponytail.py +66 -0
- novacode_cli/agents/prime.py +274 -0
- novacode_cli/agents/provider_caching.py +99 -0
- novacode_cli/agents/server_launcher.py +904 -0
- novacode_cli/agents/strict_tools.py +384 -0
- novacode_cli/agents/task_discipline.py +294 -0
- novacode_cli/agents/tool_call_repair.py +290 -0
- novacode_cli/agents/tool_offload.py +291 -0
- novacode_cli/agents/tool_search.py +806 -0
- novacode_cli/agents/tool_search_variants.py +106 -0
- novacode_cli/agents/tool_verdicts.py +1194 -0
- novacode_cli/agents/user_async_agents.py +312 -0
- novacode_cli/artifacts/__init__.py +10 -0
- novacode_cli/artifacts/registry.py +278 -0
- novacode_cli/artifacts/server.py +426 -0
- novacode_cli/assets/Nova.png +0 -0
- novacode_cli/assets/nova-avatar.png +0 -0
- novacode_cli/audio/__init__.py +301 -0
- novacode_cli/audio/capture.py +137 -0
- novacode_cli/audio/downloads.py +273 -0
- novacode_cli/audio/pipeline.py +391 -0
- novacode_cli/audio/playback.py +87 -0
- novacode_cli/audio/providers.py +208 -0
- novacode_cli/audio/speakable.py +78 -0
- novacode_cli/audio/stt.py +132 -0
- novacode_cli/audio/stt_deepgram.py +69 -0
- novacode_cli/audio/stt_elevenlabs.py +89 -0
- novacode_cli/audio/stt_parakeet.py +94 -0
- novacode_cli/audio/stt_whistle.py +61 -0
- novacode_cli/audio/summarize.py +92 -0
- novacode_cli/audio/tts.py +85 -0
- novacode_cli/audio/tts_kokoro.py +73 -0
- novacode_cli/audio/tts_orpheus.py +180 -0
- novacode_cli/audio/tts_pocket.py +131 -0
- novacode_cli/audio/tts_sano.py +69 -0
- novacode_cli/audio/vad.py +145 -0
- novacode_cli/backends/__init__.py +17 -0
- novacode_cli/backends/filesystem.py +894 -0
- novacode_cli/backends/native_search.py +92 -0
- novacode_cli/bootstrap/__init__.py +9 -0
- novacode_cli/bootstrap/env_snapshot.py +240 -0
- novacode_cli/bootstrap/steering.py +464 -0
- novacode_cli/bootstrap/vision_router.py +604 -0
- novacode_cli/brand.py +362 -0
- novacode_cli/cli_args.py +718 -0
- novacode_cli/commands/__init__.py +237 -0
- novacode_cli/commands/agents_commands.py +231 -0
- novacode_cli/commands/auth_handler.py +40 -0
- novacode_cli/commands/browser_use_handler.py +75 -0
- novacode_cli/commands/cache_handler.py +32 -0
- novacode_cli/commands/chat_handler.py +1357 -0
- novacode_cli/commands/ci_fix.py +171 -0
- novacode_cli/commands/claude_plan.py +331 -0
- novacode_cli/commands/codex_plan.py +195 -0
- novacode_cli/commands/commands.py +1113 -0
- novacode_cli/commands/create_handler.py +124 -0
- novacode_cli/commands/create_server.py +1887 -0
- novacode_cli/commands/cron_handler.py +119 -0
- novacode_cli/commands/dream_handler.py +203 -0
- novacode_cli/commands/effort_handler.py +65 -0
- novacode_cli/commands/evolution_handler.py +214 -0
- novacode_cli/commands/file_commands.py +381 -0
- novacode_cli/commands/handoff_handler.py +68 -0
- novacode_cli/commands/hooks_handler.py +269 -0
- novacode_cli/commands/init_handler.py +146 -0
- novacode_cli/commands/learning_handler.py +160 -0
- novacode_cli/commands/lite_mode_handler.py +76 -0
- novacode_cli/commands/log_commands.py +363 -0
- novacode_cli/commands/mcp_handler.py +29 -0
- novacode_cli/commands/model_handler.py +29 -0
- novacode_cli/commands/notifications_handler.py +158 -0
- novacode_cli/commands/onboard_handler.py +121 -0
- novacode_cli/commands/plan_handler.py +440 -0
- novacode_cli/commands/planner_usage.py +250 -0
- novacode_cli/commands/plugin_install_handler.py +38 -0
- novacode_cli/commands/plugins_handler.py +35 -0
- novacode_cli/commands/prime_handler.py +455 -0
- novacode_cli/commands/prompt_handler.py +149 -0
- novacode_cli/commands/provider_usage.py +160 -0
- novacode_cli/commands/ralph_events.py +106 -0
- novacode_cli/commands/ralph_handler.py +1293 -0
- novacode_cli/commands/refine_handler.py +213 -0
- novacode_cli/commands/research_handler.py +202 -0
- novacode_cli/commands/rootapp_remote.py +83 -0
- novacode_cli/commands/router_handler.py +36 -0
- novacode_cli/commands/server_commands.py +249 -0
- novacode_cli/commands/session_commands.py +203 -0
- novacode_cli/commands/share_handler.py +450 -0
- novacode_cli/commands/side_commands.py +366 -0
- novacode_cli/commands/skill_invoke.py +420 -0
- novacode_cli/commands/skills_commands.py +48 -0
- novacode_cli/commands/trace_handler.py +322 -0
- novacode_cli/commands/trello_handler.py +226 -0
- novacode_cli/commands/trello_remote.py +177 -0
- novacode_cli/commands/trello_server.py +1214 -0
- novacode_cli/commands/vision_handler.py +127 -0
- novacode_cli/commands/voice_handler.py +447 -0
- novacode_cli/commands/webhook_handler.py +134 -0
- novacode_cli/commands/wiki_commands.py +227 -0
- novacode_cli/compaction.py +753 -0
- novacode_cli/computation_cache.py +159 -0
- novacode_cli/computer/__init__.py +1 -0
- novacode_cli/computer/persistent.py +234 -0
- novacode_cli/computer/preview.py +253 -0
- novacode_cli/computer/runtime.py +474 -0
- novacode_cli/computer/windows_console.py +152 -0
- novacode_cli/computer/windows_qemu.py +211 -0
- novacode_cli/config/browser_mode.py +159 -0
- novacode_cli/config/catalog_models.py +95 -0
- novacode_cli/config/config.py +1388 -0
- novacode_cli/config/credentials.py +540 -0
- novacode_cli/config/google_oauth_auth.py +281 -0
- novacode_cli/config/model_capabilities.py +343 -0
- novacode_cli/config/model_catalog.py +275 -0
- novacode_cli/config/model_create.py +1325 -0
- novacode_cli/config/model_manager.py +695 -0
- novacode_cli/config/nova_config.py +1283 -0
- novacode_cli/config/openai_chatgpt_auth.py +384 -0
- novacode_cli/config/opencode_gateway.py +25 -0
- novacode_cli/config/plan_mode.py +188 -0
- novacode_cli/config/provider_auth.py +438 -0
- novacode_cli/config/provider_catalog.json +5127 -0
- novacode_cli/config/provider_registry.py +38 -0
- novacode_cli/config/provider_transports.py +258 -0
- novacode_cli/config/role_models.py +175 -0
- novacode_cli/context/__init__.py +50 -0
- novacode_cli/context/_analysis.py +799 -0
- novacode_cli/context/_budget.py +116 -0
- novacode_cli/context/_conversation.py +73 -0
- novacode_cli/context/_dynamic.py +264 -0
- novacode_cli/context/_model_config.py +380 -0
- novacode_cli/context/_models_dev.py +99 -0
- novacode_cli/context/archives.py +248 -0
- novacode_cli/context/estimates.py +65 -0
- novacode_cli/context/history.py +17 -0
- novacode_cli/context/knowledge_cache.py +292 -0
- novacode_cli/context/manager.py +101 -0
- novacode_cli/context/observations.py +65 -0
- novacode_cli/context/pressure.py +168 -0
- novacode_cli/context/provider_accounting.py +109 -0
- novacode_cli/context/snapshot.py +493 -0
- novacode_cli/context/strategies.py +279 -0
- novacode_cli/context/task_progress.py +122 -0
- novacode_cli/core/__init__.py +0 -0
- novacode_cli/core/agent_loop.py +1821 -0
- novacode_cli/core/autonomous_loop.py +277 -0
- novacode_cli/core/code_approvals.py +57 -0
- novacode_cli/core/input_preparation.py +276 -0
- novacode_cli/core/reasoning.py +67 -0
- novacode_cli/core/streaming.py +326 -0
- novacode_cli/core/subagent_tasks.py +696 -0
- novacode_cli/core/subagent_tracking.py +235 -0
- novacode_cli/core/tool_results.py +116 -0
- novacode_cli/core/verification_loop.py +272 -0
- novacode_cli/council.py +595 -0
- novacode_cli/council_consensus.py +115 -0
- novacode_cli/council_decision.py +157 -0
- novacode_cli/council_planner.py +1421 -0
- novacode_cli/council_settings.py +208 -0
- novacode_cli/council_web_settings.py +41 -0
- novacode_cli/council_workspace.py +56 -0
- novacode_cli/cowork/__init__.py +10 -0
- novacode_cli/cowork/broker_middleware.py +162 -0
- novacode_cli/cowork/launcher.py +102 -0
- novacode_cli/cowork/policy.py +284 -0
- novacode_cli/cowork/ui.py +826 -0
- novacode_cli/daemons/__init__.py +1 -0
- novacode_cli/daemons/registry.py +342 -0
- novacode_cli/desktop_notifications.py +302 -0
- novacode_cli/doctor.py +251 -0
- novacode_cli/embeddings.py +109 -0
- novacode_cli/entrypoint.py +56 -0
- novacode_cli/errors/__init__.py +19 -0
- novacode_cli/errors/handlers.py +648 -0
- novacode_cli/errors/provider_errors.py +249 -0
- novacode_cli/errors/taxonomy.py +80 -0
- novacode_cli/events.py +179 -0
- novacode_cli/file_ops.py +714 -0
- novacode_cli/git_safety.py +281 -0
- novacode_cli/handoff.py +383 -0
- novacode_cli/headless/__init__.py +18 -0
- novacode_cli/headless/input.py +58 -0
- novacode_cli/headless/output.py +224 -0
- novacode_cli/headless/pipe.py +532 -0
- novacode_cli/headless/runner.py +461 -0
- novacode_cli/hermes/__init__.py +39 -0
- novacode_cli/hermes/activation.py +297 -0
- novacode_cli/hermes/config.py +129 -0
- novacode_cli/hermes/curator.py +199 -0
- novacode_cli/hermes/evolution.py +374 -0
- novacode_cli/hermes/ledger.py +364 -0
- novacode_cli/hermes/memory_tiers.py +969 -0
- novacode_cli/hermes/middleware.py +678 -0
- novacode_cli/hermes/overview.py +174 -0
- novacode_cli/hermes/prompt_evolution.py +503 -0
- novacode_cli/hermes/refine_loop.py +643 -0
- novacode_cli/hermes/refinement_log.py +190 -0
- novacode_cli/hermes/review.py +674 -0
- novacode_cli/hermes/skill_debate.py +135 -0
- novacode_cli/hermes/skill_discovery.py +450 -0
- novacode_cli/hermes/skill_manager.py +335 -0
- novacode_cli/hermes/skill_proposals.py +43 -0
- novacode_cli/hermes/test_gaming.py +119 -0
- novacode_cli/hermes/tracker.py +435 -0
- novacode_cli/hermes/tuner.py +206 -0
- novacode_cli/hermes/verification_memory.py +134 -0
- novacode_cli/hermes/verifier.py +277 -0
- novacode_cli/hitl/__init__.py +22 -0
- novacode_cli/hitl/interrupts.py +493 -0
- novacode_cli/hooks.py +359 -0
- novacode_cli/image_utils.py +517 -0
- novacode_cli/init/__init__.py +7 -0
- novacode_cli/init/events.py +43 -0
- novacode_cli/input_utils.py +526 -0
- novacode_cli/install_commands.py +87 -0
- novacode_cli/integrations/__init__.py +82 -0
- novacode_cli/integrations/daytona.py +122 -0
- novacode_cli/integrations/docker.py +309 -0
- novacode_cli/integrations/host_path.py +111 -0
- novacode_cli/integrations/langsmith.py +151 -0
- novacode_cli/integrations/modal.py +134 -0
- novacode_cli/integrations/runloop.py +130 -0
- novacode_cli/integrations/sandbox_factory.py +1388 -0
- novacode_cli/integrations/sandbox_registry.py +312 -0
- novacode_cli/integrations/workdir_backend.py +589 -0
- novacode_cli/main.py +2078 -0
- novacode_cli/mcp/__init__.py +73 -0
- novacode_cli/mcp/auth.py +189 -0
- novacode_cli/mcp/client.py +571 -0
- novacode_cli/mcp/code_mode.py +5 -0
- novacode_cli/mcp/code_runtime.py +5 -0
- novacode_cli/mcp/commands.py +902 -0
- novacode_cli/mcp/config.py +406 -0
- novacode_cli/mcp/generic.py +128 -0
- novacode_cli/mcp/middleware.py +993 -0
- novacode_cli/mcp/presets.py +367 -0
- novacode_cli/memory/__init__.py +1 -0
- novacode_cli/memory/agent_memory.py +1312 -0
- novacode_cli/memory/builtin_lessons.py +60 -0
- novacode_cli/memory/dream_gates.py +192 -0
- novacode_cli/memory/limits.py +59 -0
- novacode_cli/memory/parsed_cache.py +106 -0
- novacode_cli/memory/recall_stats.py +97 -0
- novacode_cli/memory/semantic.py +116 -0
- novacode_cli/memory/store.py +335 -0
- novacode_cli/memory/wiki.py +274 -0
- novacode_cli/migrate.py +185 -0
- novacode_cli/onboarding.py +649 -0
- novacode_cli/onboarding_check.py +119 -0
- novacode_cli/path_approval.py +297 -0
- novacode_cli/plan_archive.py +148 -0
- novacode_cli/plugins/__init__.py +121 -0
- novacode_cli/plugins/claude_plugins.py +538 -0
- novacode_cli/plugins/cli.py +168 -0
- novacode_cli/plugins/components.py +413 -0
- novacode_cli/plugins/hooks.py +356 -0
- novacode_cli/plugins/loader.py +317 -0
- novacode_cli/plugins/marketplaces.py +199 -0
- novacode_cli/plugins/storage.py +70 -0
- novacode_cli/prime.py +759 -0
- novacode_cli/prime_factory/__init__.py +15 -0
- novacode_cli/prime_factory/container.py +198 -0
- novacode_cli/prime_factory/controller.py +565 -0
- novacode_cli/prime_factory/knowledge.py +261 -0
- novacode_cli/prime_factory/publication.py +218 -0
- novacode_cli/prime_factory/recovery.py +50 -0
- novacode_cli/prime_factory/research.py +370 -0
- novacode_cli/prime_factory/runner.py +608 -0
- novacode_cli/prime_factory/runtime.py +261 -0
- novacode_cli/prime_factory/state.py +201 -0
- novacode_cli/prime_factory/store.py +128 -0
- novacode_cli/prime_factory/worker.py +129 -0
- novacode_cli/prime_factory/workflow.py +899 -0
- novacode_cli/prime_factory/workspace.py +317 -0
- novacode_cli/prime_memory.py +290 -0
- novacode_cli/process_manager.py +585 -0
- novacode_cli/project_onboard.py +537 -0
- novacode_cli/prompts/System_Prompt_Nova.jinja +23 -0
- novacode_cli/prompts/__init__.py +168 -0
- novacode_cli/prompts/agent_definitions.jinja +11 -0
- novacode_cli/prompts/agent_generation.jinja +125 -0
- novacode_cli/prompts/async_agents/general_purpose.jinja +22 -0
- novacode_cli/prompts/claude_plan_mode.jinja +12 -0
- novacode_cli/prompts/coding_workflow.jinja +18 -0
- novacode_cli/prompts/computer_use.jinja +17 -0
- novacode_cli/prompts/core_agent_system.jinja +81 -0
- novacode_cli/prompts/delegation.jinja +15 -0
- novacode_cli/prompts/desktop_power.jinja +4 -0
- novacode_cli/prompts/file_paths.jinja +15 -0
- novacode_cli/prompts/file_tracker.jinja +23 -0
- novacode_cli/prompts/init_agents_md.jinja +56 -0
- novacode_cli/prompts/init_exploration.jinja +174 -0
- novacode_cli/prompts/init_semantic_orchestrate.jinja +37 -0
- novacode_cli/prompts/instruction_scope.jinja +5 -0
- novacode_cli/prompts/learnings_extraction.jinja +45 -0
- novacode_cli/prompts/longterm_memory.jinja +54 -0
- novacode_cli/prompts/mcp.jinja +84 -0
- novacode_cli/prompts/memory_consolidation.jinja +40 -0
- novacode_cli/prompts/nova_evolution.jinja +73 -0
- novacode_cli/prompts/nova_review.jinja +158 -0
- novacode_cli/prompts/nova_skill_debate.jinja +36 -0
- novacode_cli/prompts/nova_standing_instructions.jinja +26 -0
- novacode_cli/prompts/nova_verify.jinja +100 -0
- novacode_cli/prompts/onboard_dashboard.jinja +378 -0
- novacode_cli/prompts/plan_agent.jinja +87 -0
- novacode_cli/prompts/plan_scouts.jinja +5 -0
- novacode_cli/prompts/plan_storage.jinja +8 -0
- novacode_cli/prompts/planning.jinja +82 -0
- novacode_cli/prompts/ponytail/LICENSE +21 -0
- novacode_cli/prompts/ponytail/UPSTREAM.json +15 -0
- novacode_cli/prompts/ponytail/hooks/ponytail-config.js +175 -0
- novacode_cli/prompts/ponytail/hooks/ponytail-instructions.js +98 -0
- novacode_cli/prompts/ponytail/skills/ponytail/SKILL.md +52 -0
- novacode_cli/prompts/ponytail/skills/ponytail-audit/SKILL.md +103 -0
- novacode_cli/prompts/ponytail/skills/ponytail-debt/SKILL.md +44 -0
- novacode_cli/prompts/ponytail/skills/ponytail-gain/SKILL.md +52 -0
- novacode_cli/prompts/ponytail/skills/ponytail-help/SKILL.md +76 -0
- novacode_cli/prompts/ponytail/skills/ponytail-review/SKILL.md +101 -0
- novacode_cli/prompts/prompt_evolution.jinja +27 -0
- novacode_cli/prompts/ralph_iteration.jinja +75 -0
- novacode_cli/prompts/refine_gate.jinja +31 -0
- novacode_cli/prompts/refine_plan.jinja +64 -0
- novacode_cli/prompts/refine_review.jinja +34 -0
- novacode_cli/prompts/research_delivery.jinja +9 -0
- novacode_cli/prompts/research_swarm.jinja +130 -0
- novacode_cli/prompts/response_style.jinja +5 -0
- novacode_cli/prompts/session_summarization.jinja +86 -0
- novacode_cli/prompts/skill_creation.jinja +85 -0
- novacode_cli/prompts/subagents/fact_checker.jinja +48 -0
- novacode_cli/prompts/subagents/financial_analyst.jinja +50 -0
- novacode_cli/prompts/subagents/literature_reviewer.jinja +52 -0
- novacode_cli/prompts/subagents/market_analyst.jinja +48 -0
- novacode_cli/prompts/subagents/research_synthesizer.jinja +57 -0
- novacode_cli/prompts/subagents/technical_researcher.jinja +56 -0
- novacode_cli/prompts/subagents/web_researcher.jinja +46 -0
- novacode_cli/prompts/summarization.jinja +107 -0
- novacode_cli/prompts/summarization_answers.jinja +23 -0
- novacode_cli/prompts/summarization_questions.jinja +32 -0
- novacode_cli/prompts/vision_caption.jinja +21 -0
- novacode_cli/prompts/voice_summary.jinja +65 -0
- novacode_cli/prompts/wiki_file.jinja +57 -0
- novacode_cli/prompts/wiki_ingest.jinja +87 -0
- novacode_cli/recovery.py +383 -0
- novacode_cli/remote/__init__.py +45 -0
- novacode_cli/remote/approvals.py +282 -0
- novacode_cli/remote/async_task_clients.py +97 -0
- novacode_cli/remote/async_task_watcher.py +240 -0
- novacode_cli/remote/bridge.py +905 -0
- novacode_cli/remote/command_menu.py +26 -0
- novacode_cli/remote/command_ui.py +243 -0
- novacode_cli/remote/config.py +199 -0
- novacode_cli/remote/discord_bridge.py +530 -0
- novacode_cli/remote/discord_format.py +31 -0
- novacode_cli/remote/discord_threads.py +225 -0
- novacode_cli/remote/images.py +97 -0
- novacode_cli/remote/processor.py +601 -0
- novacode_cli/remote/rootapp_bot/bot.cjs +16 -0
- novacode_cli/remote/rootapp_bot/package-lock.json +2683 -0
- novacode_cli/remote/rootapp_bot/package.json +18 -0
- novacode_cli/remote/rootapp_bot/transport.cjs +80 -0
- novacode_cli/remote/rootapp_bridge.py +370 -0
- novacode_cli/remote/rootapp_setup.py +89 -0
- novacode_cli/remote/routing.py +103 -0
- novacode_cli/remote/scheduler.py +302 -0
- novacode_cli/remote/session.py +164 -0
- novacode_cli/remote/status.py +411 -0
- novacode_cli/remote/streaming.py +188 -0
- novacode_cli/remote/telegram_bridge.py +1118 -0
- novacode_cli/remote/telegram_format.py +215 -0
- novacode_cli/remote/telegram_hub.py +256 -0
- novacode_cli/remote/voice_notes.py +120 -0
- novacode_cli/remote/webhook_adapters.py +167 -0
- novacode_cli/remote/webhook_server.py +154 -0
- novacode_cli/rewind.py +150 -0
- novacode_cli/rooms/__init__.py +1 -0
- novacode_cli/rooms/bridge.py +86 -0
- novacode_cli/rooms/cli.py +231 -0
- novacode_cli/rooms/nova.py +227 -0
- novacode_cli/rooms/runtime.py +299 -0
- novacode_cli/rooms/store.py +538 -0
- novacode_cli/rooms/workspace.py +94 -0
- novacode_cli/security/__init__.py +29 -0
- novacode_cli/security/approval_context.py +45 -0
- novacode_cli/security/delegated_approval.py +68 -0
- novacode_cli/security/local_http.py +85 -0
- novacode_cli/security/middleware.py +87 -0
- novacode_cli/security/paths.py +35 -0
- novacode_cli/security/policy.py +535 -0
- novacode_cli/security/policy_writer.py +90 -0
- novacode_cli/security/prompt_injection.py +203 -0
- novacode_cli/security/remember.py +81 -0
- novacode_cli/security/rule_synthesis.py +116 -0
- novacode_cli/security/secret_files.py +61 -0
- novacode_cli/security/session_allow.py +114 -0
- novacode_cli/security/unicode_security.py +516 -0
- novacode_cli/security/validator.py +173 -0
- novacode_cli/server/__init__.py +9 -0
- novacode_cli/server/app.py +632 -0
- novacode_cli/server/event_adapter.py +189 -0
- novacode_cli/server/session_manager.py +90 -0
- novacode_cli/server_main.py +64 -0
- novacode_cli/server_runner/dev_server.py +530 -0
- novacode_cli/server_runner/test_runner.py +470 -0
- novacode_cli/session/__init__.py +1 -0
- novacode_cli/session/adapters/__init__.py +240 -0
- novacode_cli/session/adapters/claude_code.py +102 -0
- novacode_cli/session/adapters/codex.py +77 -0
- novacode_cli/session/adapters/harness_native.py +75 -0
- novacode_cli/session/checkpoint_coordinator.py +448 -0
- novacode_cli/session/context_restore.py +25 -0
- novacode_cli/session/history_export.py +228 -0
- novacode_cli/session/history_tree.py +174 -0
- novacode_cli/session/imported_context.py +267 -0
- novacode_cli/session/runtime_identity.py +32 -0
- novacode_cli/session/session_persistence.py +1168 -0
- novacode_cli/session/session_prompt_builder.py +279 -0
- novacode_cli/session/session_restore.py +351 -0
- novacode_cli/session/session_summarization.py +20 -0
- novacode_cli/session/transcript_journal.py +153 -0
- novacode_cli/sessions/__init__.py +11 -0
- novacode_cli/sessions/gateway.py +84 -0
- novacode_cli/sessions/launch.py +51 -0
- novacode_cli/sessions/lease.py +213 -0
- novacode_cli/sessions/messaging.py +255 -0
- novacode_cli/sessions/protocol.py +216 -0
- novacode_cli/sessions/resume.py +31 -0
- novacode_cli/sessions/supervisor.py +498 -0
- novacode_cli/sessions/tasks.py +73 -0
- novacode_cli/sessions/tui_messaging.py +413 -0
- novacode_cli/sessions/worker.py +652 -0
- novacode_cli/sessions/worktree.py +262 -0
- novacode_cli/shell/__init__.py +27 -0
- novacode_cli/shell/jobs.py +475 -0
- novacode_cli/shell/middleware.py +1568 -0
- novacode_cli/shell/os_sandbox.py +205 -0
- novacode_cli/shell/output.py +181 -0
- novacode_cli/shell/patterns.py +275 -0
- novacode_cli/shell/processes.py +87 -0
- novacode_cli/shell/utils.py +236 -0
- novacode_cli/skills/__init__.py +26 -0
- novacode_cli/skills/builtin/handoff/SKILL.md +15 -0
- novacode_cli/skills/curation_middleware.py +69 -0
- novacode_cli/skills/executable.py +161 -0
- novacode_cli/skills/libraries.py +102 -0
- novacode_cli/skills/load.py +248 -0
- novacode_cli/skills/prune.py +215 -0
- novacode_cli/skills/refreshing_middleware.py +896 -0
- novacode_cli/skills/retrieval.py +248 -0
- novacode_cli/skills/runtime.py +118 -0
- novacode_cli/skills/schema.py +254 -0
- novacode_cli/skills/skill_creation.py +1549 -0
- novacode_cli/skills/skill_lock.py +75 -0
- novacode_cli/skills/skill_system_prompt.py +16 -0
- novacode_cli/skills/skills_prefs.py +126 -0
- novacode_cli/skills/tool_resolver.py +31 -0
- novacode_cli/skills/upstream.py +50 -0
- novacode_cli/skills/versioning.py +291 -0
- novacode_cli/states/Session.py +847 -0
- novacode_cli/states/__init__.py +31 -0
- novacode_cli/states/slices/__init__.py +17 -0
- novacode_cli/states/slices/agent_runtime.py +249 -0
- novacode_cli/states/slices/background_tasks.py +21 -0
- novacode_cli/states/slices/notifications.py +74 -0
- novacode_cli/states/slices/remote_bridge.py +56 -0
- novacode_cli/states/slices/ui_settings.py +49 -0
- novacode_cli/states/slices/wiki.py +25 -0
- novacode_cli/teammates/__init__.py +1 -0
- novacode_cli/teammates/controller.py +557 -0
- novacode_cli/teammates/graph.py +104 -0
- novacode_cli/teammates/registry.py +175 -0
- novacode_cli/teammates/service.py +254 -0
- novacode_cli/teammates/worker.py +19 -0
- novacode_cli/teams/__init__.py +1 -0
- novacode_cli/teams/adapters/__init__.py +1 -0
- novacode_cli/teams/adapters/container.py +316 -0
- novacode_cli/teams/adapters/inprocess.py +206 -0
- novacode_cli/teams/adapters/process.py +364 -0
- novacode_cli/teams/bootstrap.py +246 -0
- novacode_cli/teams/container_git.py +67 -0
- novacode_cli/teams/context.py +34 -0
- novacode_cli/teams/coordinator.py +815 -0
- novacode_cli/teams/gateway.py +200 -0
- novacode_cli/teams/host.py +64 -0
- novacode_cli/teams/legacy.py +52 -0
- novacode_cli/teams/middleware.py +176 -0
- novacode_cli/teams/models.py +104 -0
- novacode_cli/teams/output.py +47 -0
- novacode_cli/teams/protocol.py +50 -0
- novacode_cli/teams/recovery.py +80 -0
- novacode_cli/teams/scheduler.py +44 -0
- novacode_cli/teams/store.py +631 -0
- novacode_cli/teams/worker.py +251 -0
- novacode_cli/teams/workspace.py +100 -0
- novacode_cli/token_utils.py +256 -0
- novacode_cli/tools/__init__.py +104 -0
- novacode_cli/tools/_shared.py +97 -0
- novacode_cli/tools/_types.py +24 -0
- novacode_cli/tools/artifact_tools.py +137 -0
- novacode_cli/tools/code_search_tools.py +330 -0
- novacode_cli/tools/computer_tools.py +77 -0
- novacode_cli/tools/cron_tools.py +65 -0
- novacode_cli/tools/daemon_tool.py +290 -0
- novacode_cli/tools/desktop_tools.py +161 -0
- novacode_cli/tools/fetch_tools.py +530 -0
- novacode_cli/tools/http_tools.py +279 -0
- novacode_cli/tools/inspection_tools.py +107 -0
- novacode_cli/tools/job_tools.py +143 -0
- novacode_cli/tools/knowledge_tools.py +427 -0
- novacode_cli/tools/memory_tools.py +461 -0
- novacode_cli/tools/memory_wiki_tools.py +40 -0
- novacode_cli/tools/notebook_tools.py +238 -0
- novacode_cli/tools/oracle_tool.py +83 -0
- novacode_cli/tools/plan_archive_tools.py +80 -0
- novacode_cli/tools/plan_mode_tools.py +315 -0
- novacode_cli/tools/python_kernel_loop.py +165 -0
- novacode_cli/tools/python_kernel_tool.py +222 -0
- novacode_cli/tools/reflection_tools.py +34 -0
- novacode_cli/tools/scraper_tools.py +377 -0
- novacode_cli/tools/skill_tools.py +275 -0
- novacode_cli/tools/speak_tool.py +51 -0
- novacode_cli/tools/store_memory_tools.py +227 -0
- novacode_cli/tools/ui_tools.py +62 -0
- novacode_cli/tools/waiter_tools.py +408 -0
- novacode_cli/tools/web_tools.py +349 -0
- novacode_cli/tools/wiki_tools.py +152 -0
- novacode_cli/tools/worktree_tools.py +219 -0
- novacode_cli/tracking/__init__.py +10 -0
- novacode_cli/tracking/file_tracker.py +826 -0
- novacode_cli/tracking/local_metrics.py +170 -0
- novacode_cli/tracking/loop_guard.py +507 -0
- novacode_cli/tracking/request_metrics.py +60 -0
- novacode_cli/tracking/tracing.py +692 -0
- novacode_cli/tracking/usage_tree.py +677 -0
- novacode_cli/tracking/workspace_anchoring.py +231 -0
- novacode_cli/tui/__init__.py +11 -0
- novacode_cli/tui/animation_rate.py +9 -0
- novacode_cli/tui/animations.py +332 -0
- novacode_cli/tui/app.py +19315 -0
- novacode_cli/tui/auth_display.py +87 -0
- novacode_cli/tui/auth_screens.py +826 -0
- novacode_cli/tui/avatar.py +294 -0
- novacode_cli/tui/avatar_frames.py +21 -0
- novacode_cli/tui/background_tasks.py +35 -0
- novacode_cli/tui/browser_settings_screen.py +70 -0
- novacode_cli/tui/caveman_screen.py +185 -0
- novacode_cli/tui/council_settings_screen.py +182 -0
- novacode_cli/tui/council_view.py +535 -0
- novacode_cli/tui/decision_settings.py +268 -0
- novacode_cli/tui/diff_preview.py +199 -0
- novacode_cli/tui/gc_tuning.py +63 -0
- novacode_cli/tui/handoff_screen.py +206 -0
- novacode_cli/tui/harness.py +244 -0
- novacode_cli/tui/history_tree_screen.py +179 -0
- novacode_cli/tui/home.py +328 -0
- novacode_cli/tui/home_scene.py +94 -0
- novacode_cli/tui/icons.py +81 -0
- novacode_cli/tui/interface_styles.tcss +327 -0
- novacode_cli/tui/matrix3.py +108 -0
- novacode_cli/tui/mcp_tools_screen.py +131 -0
- novacode_cli/tui/motion.py +178 -0
- novacode_cli/tui/output_body.py +136 -0
- novacode_cli/tui/output_buffer.py +59 -0
- novacode_cli/tui/palette.py +334 -0
- novacode_cli/tui/pickers.py +237 -0
- novacode_cli/tui/prime_panel.py +506 -0
- novacode_cli/tui/provider_signin.py +213 -0
- novacode_cli/tui/pty_shell.py +159 -0
- novacode_cli/tui/reference_screens.py +444 -0
- novacode_cli/tui/resume_picker.py +346 -0
- novacode_cli/tui/rooms.py +597 -0
- novacode_cli/tui/screens.py +7088 -0
- novacode_cli/tui/session_import.py +333 -0
- novacode_cli/tui/session_pane.py +242 -0
- novacode_cli/tui/session_tab.py +42 -0
- novacode_cli/tui/session_transcript.py +118 -0
- novacode_cli/tui/shell_output.py +7 -0
- novacode_cli/tui/stall_watch.py +174 -0
- novacode_cli/tui/statusline.py +40 -0
- novacode_cli/tui/statusline_screen.py +91 -0
- novacode_cli/tui/teammate_updates.py +162 -0
- novacode_cli/tui/teammates.py +548 -0
- novacode_cli/tui/terminal.py +289 -0
- novacode_cli/tui/terminal_view.py +235 -0
- novacode_cli/tui/themes.py +118 -0
- novacode_cli/tui/update_notice.py +84 -0
- novacode_cli/tui/voice_downloads.py +113 -0
- novacode_cli/tui/widgets.py +2038 -0
- novacode_cli/tui/windows_input.py +38 -0
- novacode_cli/tui/workspace_approval.py +165 -0
- novacode_cli/ui/council_web.py +113 -0
- novacode_cli/ui/council_workspace.py +72 -0
- novacode_cli/ui/cowork_web.py +41 -0
- novacode_cli/ui/diff_highlight.py +160 -0
- novacode_cli/ui/execution.py +1396 -0
- novacode_cli/ui/exit_summary.py +65 -0
- novacode_cli/ui/hitl_approval.py +196 -0
- novacode_cli/ui/input_preparation.py +2 -0
- novacode_cli/ui/interrupt_handlers.py +215 -0
- novacode_cli/ui/question_prompt.py +151 -0
- novacode_cli/ui/status_phrases.py +157 -0
- novacode_cli/ui/stream_preview.py +66 -0
- novacode_cli/ui/streaming.py +2 -0
- novacode_cli/ui/subagent_tracking.py +2 -0
- novacode_cli/ui/ui_elements.py +1585 -0
- novacode_cli/ui/web_workspace.py +244 -0
- novacode_cli/ui_events.py +299 -0
- novacode_cli/update_ui.py +243 -0
- novacode_cli/updates.py +489 -0
- novacode_cli/utils/backend_patches.py +399 -0
- novacode_cli/utils/backend_paths.py +467 -0
- novacode_cli/utils/lazy_providers.py +51 -0
- novacode_cli/utils/model_info.py +223 -0
- novacode_cli/utils/pdf_extraction.py +183 -0
- novacode_cli/utils/startup.py +29 -0
- novacode_cli/utils/tasks.py +42 -0
- novacode_cli/utils/windows.py +9 -0
- novacode_cli/vixie/hook_adapter.py +127 -0
- novacode_cli/vixie/server.py +375 -0
- novacode_cli/wiki/__init__.py +15 -0
- novacode_cli/wiki/ask.py +56 -0
- novacode_cli/wiki/file.py +71 -0
- novacode_cli/wiki/ingest.py +184 -0
- novacode_cli/wiki/manager.py +261 -0
- novacode_cli-1.2.0.dist-info/METADATA +271 -0
- novacode_cli-1.2.0.dist-info/RECORD +691 -0
- novacode_cli-1.2.0.dist-info/WHEEL +5 -0
- novacode_cli-1.2.0.dist-info/entry_points.txt +2 -0
- novacode_cli-1.2.0.dist-info/licenses/LICENSE +21 -0
- novacode_cli-1.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1283 @@
|
|
|
1
|
+
"""Configuration management for Nova CLI.
|
|
2
|
+
|
|
3
|
+
Manages persistent settings stored in ~/.nova/Nova.config.json
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import copy
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from novacode_cli.config.config import Settings, console
|
|
12
|
+
|
|
13
|
+
#: The agent roles a model can be chosen for. ``main`` is the agent the user talks
|
|
14
|
+
#: to; ``subagent`` the in-process roster it delegates to; ``async`` the remote
|
|
15
|
+
#: graphs on the LangGraph server; ``dynamic`` the agents discovered in the agent
|
|
16
|
+
#: directories (which is also what an ``/eval`` fan-out dispatches).
|
|
17
|
+
ROLE_NAMES: tuple[str, ...] = ("main", "subagent", "async", "dynamic")
|
|
18
|
+
FACTORY_ROLES: tuple[str, ...] = (
|
|
19
|
+
"requirements",
|
|
20
|
+
"research",
|
|
21
|
+
"architecture",
|
|
22
|
+
"developer",
|
|
23
|
+
"test_engineer",
|
|
24
|
+
"verification",
|
|
25
|
+
"security",
|
|
26
|
+
)
|
|
27
|
+
CAVEMAN_LEVELS: tuple[str, ...] = (
|
|
28
|
+
"lite", "full", "ultra", "wenyan-lite", "wenyan-full", "wenyan-ultra",
|
|
29
|
+
)
|
|
30
|
+
DEFAULT_ATTRIBUTION_NAME = "NovaCode"
|
|
31
|
+
DEFAULT_ATTRIBUTION_EMAIL = "noreply@novacode.invalid"
|
|
32
|
+
|
|
33
|
+
#: Strings a hand-edited boolean key may hold. Python treats every non-empty
|
|
34
|
+
#: string as true, so a bare ``bool(...)`` reads ``"false"`` as "on" -- switching
|
|
35
|
+
#: *on* a feature somebody had just tried to switch off. A value in neither set
|
|
36
|
+
#: (an unrecognised string, a list, ``None``) falls back to the safe default.
|
|
37
|
+
_TRUTHY_STRINGS: frozenset[str] = frozenset({"true", "1", "yes", "on"})
|
|
38
|
+
_FALSY_STRINGS: frozenset[str] = frozenset({"false", "0", "no", "off", ""})
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _config_bool(value: Any, *, default: bool = False) -> bool:
|
|
42
|
+
"""Read a boolean config value, failing *closed* on anything unrecognised.
|
|
43
|
+
|
|
44
|
+
The setters always write a real JSON boolean, so a string or a list only
|
|
45
|
+
reaches here from a hand-edited config file -- which is exactly where the
|
|
46
|
+
``bool("false") is True`` trap lives.
|
|
47
|
+
"""
|
|
48
|
+
if isinstance(value, bool):
|
|
49
|
+
return value
|
|
50
|
+
if isinstance(value, (int, float)):
|
|
51
|
+
return value != 0
|
|
52
|
+
if isinstance(value, str):
|
|
53
|
+
text = value.strip().lower()
|
|
54
|
+
if text in _FALSY_STRINGS:
|
|
55
|
+
return False
|
|
56
|
+
return text in _TRUTHY_STRINGS
|
|
57
|
+
return default
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _browser_server_names(value: object) -> list[str] | None:
|
|
61
|
+
"""Validate exact server identifiers, never wildcard grants."""
|
|
62
|
+
if not isinstance(value, list) or any(
|
|
63
|
+
not isinstance(name, str)
|
|
64
|
+
or not name
|
|
65
|
+
or name.strip() != name
|
|
66
|
+
or not name.isprintable()
|
|
67
|
+
or any(char in name for char in "*?[]")
|
|
68
|
+
for name in value
|
|
69
|
+
):
|
|
70
|
+
return None
|
|
71
|
+
return list(dict.fromkeys(value))
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _role_key(role: str) -> str:
|
|
75
|
+
"""Config key holding one role's model.
|
|
76
|
+
|
|
77
|
+
One top-level key per role, so ``_save`` merges them independently. ``main``
|
|
78
|
+
deliberately reuses the existing ``model`` key rather than duplicating it.
|
|
79
|
+
"""
|
|
80
|
+
return "model" if role == "main" else f"model_role_{role}"
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _require_role(role: str) -> None:
|
|
84
|
+
if role not in ROLE_NAMES:
|
|
85
|
+
raise ValueError(f"Unknown model role {role!r}. Valid roles: {', '.join(ROLE_NAMES)}")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class NovaConfig:
|
|
89
|
+
"""Manages persistent configuration for Nova CLI."""
|
|
90
|
+
|
|
91
|
+
def __init__(self) -> None:
|
|
92
|
+
"""Initialize configuration manager."""
|
|
93
|
+
settings = Settings.from_environment()
|
|
94
|
+
self.config_dir = settings.user_deepagents_dir
|
|
95
|
+
self.config_path = self.config_dir / "Nova.config.json"
|
|
96
|
+
self._config: dict[str, Any] = {}
|
|
97
|
+
self._loaded: dict[str, Any] = {} # what _config held when last synced with disk
|
|
98
|
+
self._load()
|
|
99
|
+
|
|
100
|
+
def _read_disk(self) -> dict[str, Any]:
|
|
101
|
+
if not self.config_path.exists():
|
|
102
|
+
return {}
|
|
103
|
+
try:
|
|
104
|
+
with open(self.config_path, encoding="utf-8") as f:
|
|
105
|
+
return json.load(f)
|
|
106
|
+
except (json.JSONDecodeError, OSError) as e:
|
|
107
|
+
# If config is corrupted, start fresh
|
|
108
|
+
console.print(f"[yellow]Warning: Could not load config: {e}[/yellow]")
|
|
109
|
+
return {}
|
|
110
|
+
|
|
111
|
+
def _load(self) -> None:
|
|
112
|
+
"""Load configuration from disk."""
|
|
113
|
+
self._config = self._read_disk()
|
|
114
|
+
self._loaded = copy.deepcopy(self._config)
|
|
115
|
+
|
|
116
|
+
def _save(self) -> None:
|
|
117
|
+
"""Save configuration to disk atomically (temp file + rename)."""
|
|
118
|
+
# Ensure config directory exists
|
|
119
|
+
self.config_dir.mkdir(parents=True, exist_ok=True)
|
|
120
|
+
|
|
121
|
+
# Write to temp file first, then atomically replace.
|
|
122
|
+
# Use Path.replace (os.replace), not rename: on Windows rename raises
|
|
123
|
+
# FileExistsError when the target exists, whereas replace overwrites
|
|
124
|
+
# atomically on both Windows and POSIX.
|
|
125
|
+
# Write back only the keys THIS instance changed, on top of what is on
|
|
126
|
+
# disk now. Writing the whole in-memory snapshot let any instance loaded
|
|
127
|
+
# earlier (a long-lived ModelManager, another Nova process) put back a
|
|
128
|
+
# model the user had since switched away from, the moment it saved an
|
|
129
|
+
# unrelated setting such as the theme: the "always nemotron" bug.
|
|
130
|
+
merged = self._read_disk()
|
|
131
|
+
for key in set(self._config) | set(self._loaded):
|
|
132
|
+
if key not in self._config:
|
|
133
|
+
if key in self._loaded:
|
|
134
|
+
merged.pop(key, None)
|
|
135
|
+
elif self._config[key] != self._loaded.get(key):
|
|
136
|
+
merged[key] = copy.deepcopy(self._config[key])
|
|
137
|
+
self._config = merged
|
|
138
|
+
self._loaded = copy.deepcopy(merged)
|
|
139
|
+
|
|
140
|
+
tmp_path = self.config_path.with_suffix(".tmp." + str(os.getpid()))
|
|
141
|
+
try:
|
|
142
|
+
tmp_path.write_text(json.dumps(self._config, indent=2), encoding="utf-8")
|
|
143
|
+
tmp_path.replace(self.config_path)
|
|
144
|
+
except Exception:
|
|
145
|
+
try:
|
|
146
|
+
tmp_path.unlink(missing_ok=True)
|
|
147
|
+
except Exception:
|
|
148
|
+
pass
|
|
149
|
+
raise
|
|
150
|
+
|
|
151
|
+
def get_model_config(self) -> dict[str, str] | None:
|
|
152
|
+
"""Get saved model provider configuration.
|
|
153
|
+
|
|
154
|
+
Returns:
|
|
155
|
+
Dict with 'provider' and 'model' keys, or None if not configured
|
|
156
|
+
"""
|
|
157
|
+
self._load() # fresh: another instance or process may have switched it
|
|
158
|
+
return self._config.get("model")
|
|
159
|
+
|
|
160
|
+
def set_model_config(self, provider: str, model: str, base_url: str | None = None) -> None:
|
|
161
|
+
"""Save model provider configuration.
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
provider: Provider ID (openai, anthropic, ollama, google)
|
|
165
|
+
model: Model name
|
|
166
|
+
base_url: Optional OpenAI-compatible endpoint override (Azure,
|
|
167
|
+
LM Studio, vLLM, a LiteLLM proxy…). Omitted from the saved
|
|
168
|
+
config when blank, so the default endpoint is used.
|
|
169
|
+
"""
|
|
170
|
+
entry: dict[str, str] = {"provider": provider, "model": model}
|
|
171
|
+
if base_url:
|
|
172
|
+
entry["base_url"] = base_url
|
|
173
|
+
self._config["model"] = entry
|
|
174
|
+
self._save()
|
|
175
|
+
|
|
176
|
+
def get_model_base_url(self) -> str | None:
|
|
177
|
+
"""The saved endpoint override for the current provider, if any."""
|
|
178
|
+
model_cfg = self._config.get("model")
|
|
179
|
+
if isinstance(model_cfg, dict):
|
|
180
|
+
url = model_cfg.get("base_url")
|
|
181
|
+
if isinstance(url, str) and url.strip():
|
|
182
|
+
return url.strip()
|
|
183
|
+
return None
|
|
184
|
+
|
|
185
|
+
def get_openai_auth_mode(self) -> str:
|
|
186
|
+
"""Selected OpenAI credential: auto, api_key, or ChatGPT plan sign-in."""
|
|
187
|
+
self._load()
|
|
188
|
+
mode = self._config.get("openai_auth_mode", "auto")
|
|
189
|
+
return mode if mode in {"auto", "api_key", "chatgpt"} else "auto"
|
|
190
|
+
|
|
191
|
+
def set_openai_auth_mode(self, mode: str) -> None:
|
|
192
|
+
"""Persist which OpenAI credential Nova should use."""
|
|
193
|
+
if mode not in {"auto", "api_key", "chatgpt"}:
|
|
194
|
+
raise ValueError("OpenAI auth mode must be 'auto', 'api_key', or 'chatgpt'.")
|
|
195
|
+
self._load()
|
|
196
|
+
self._config["openai_auth_mode"] = mode
|
|
197
|
+
self._save()
|
|
198
|
+
|
|
199
|
+
def clear_model_config(self) -> None:
|
|
200
|
+
"""Clear saved model configuration."""
|
|
201
|
+
if "model" in self._config:
|
|
202
|
+
del self._config["model"]
|
|
203
|
+
self._save()
|
|
204
|
+
|
|
205
|
+
# ── Per-role models ─────────────────────────────────────────────────────
|
|
206
|
+
#
|
|
207
|
+
# A role with no saved entry inherits the main agent's model, which is what
|
|
208
|
+
# every role did before this existed, so an untouched config behaves exactly
|
|
209
|
+
# as it did. Each role lives under its own top-level key because `_save`
|
|
210
|
+
# merges per top-level key: one nested `roles` map would let two Nova
|
|
211
|
+
# processes clobber each other's roles, the same way the `credentials`
|
|
212
|
+
# setter re-reads the file to avoid.
|
|
213
|
+
|
|
214
|
+
def get_role_model(self, role: str) -> dict[str, str] | None:
|
|
215
|
+
"""Saved model for *role*, or None when the role inherits the main one."""
|
|
216
|
+
_require_role(role)
|
|
217
|
+
self._load() # fresh: another instance or process may have set it
|
|
218
|
+
entry = self._config.get(_role_key(role))
|
|
219
|
+
return dict(entry) if isinstance(entry, dict) else None
|
|
220
|
+
|
|
221
|
+
def set_role_model(
|
|
222
|
+
self, role: str, provider: str, model: str, base_url: str | None = None
|
|
223
|
+
) -> None:
|
|
224
|
+
"""Save a model for one role.
|
|
225
|
+
|
|
226
|
+
``provider`` + ``model`` are stored separately because that is how the
|
|
227
|
+
rest of Nova resolves them; deepagents is handed the joined
|
|
228
|
+
``provider:model`` spec, which is the form it documents.
|
|
229
|
+
"""
|
|
230
|
+
_require_role(role)
|
|
231
|
+
self._load()
|
|
232
|
+
entry: dict[str, str] = {"provider": provider, "model": model}
|
|
233
|
+
if base_url:
|
|
234
|
+
entry["base_url"] = base_url
|
|
235
|
+
self._config[_role_key(role)] = entry
|
|
236
|
+
self._save()
|
|
237
|
+
|
|
238
|
+
def clear_role_model(self, role: str) -> None:
|
|
239
|
+
"""Drop a role's saved model so it inherits the main agent's again."""
|
|
240
|
+
_require_role(role)
|
|
241
|
+
self._load()
|
|
242
|
+
if _role_key(role) in self._config:
|
|
243
|
+
del self._config[_role_key(role)]
|
|
244
|
+
self._save()
|
|
245
|
+
|
|
246
|
+
def all_role_models(self) -> dict[str, dict[str, str]]:
|
|
247
|
+
"""Every role that has an explicit model, keyed by role name."""
|
|
248
|
+
self._load()
|
|
249
|
+
found: dict[str, dict[str, str]] = {}
|
|
250
|
+
for role in ROLE_NAMES:
|
|
251
|
+
entry = self._config.get(_role_key(role))
|
|
252
|
+
if isinstance(entry, dict):
|
|
253
|
+
found[role] = dict(entry)
|
|
254
|
+
return found
|
|
255
|
+
|
|
256
|
+
def get_factory_model(self, role: str) -> dict[str, str] | None:
|
|
257
|
+
"""Return an explicit factory route, or inherit the session model when unset."""
|
|
258
|
+
if role not in FACTORY_ROLES:
|
|
259
|
+
message = f"Unknown factory role {role!r}"
|
|
260
|
+
raise ValueError(message)
|
|
261
|
+
self._load()
|
|
262
|
+
entry = self._config.get(f"factory_model_{role}")
|
|
263
|
+
if entry is None:
|
|
264
|
+
return None
|
|
265
|
+
if (
|
|
266
|
+
not isinstance(entry, dict)
|
|
267
|
+
or any(
|
|
268
|
+
not isinstance(entry.get(key), str) or not entry[key].strip()
|
|
269
|
+
for key in ("provider", "model")
|
|
270
|
+
)
|
|
271
|
+
or ("base_url" in entry and not isinstance(entry["base_url"], str))
|
|
272
|
+
):
|
|
273
|
+
message = f"Invalid factory model route for {role!r}"
|
|
274
|
+
raise ValueError(message)
|
|
275
|
+
return dict(entry)
|
|
276
|
+
|
|
277
|
+
def set_factory_model(
|
|
278
|
+
self, role: str, provider: str, model: str, base_url: str | None = None
|
|
279
|
+
) -> None:
|
|
280
|
+
"""Save one specialist route without changing ordinary agent model settings."""
|
|
281
|
+
if role not in FACTORY_ROLES:
|
|
282
|
+
message = f"Unknown factory role {role!r}"
|
|
283
|
+
raise ValueError(message)
|
|
284
|
+
if not provider.strip() or not model.strip():
|
|
285
|
+
message = "Factory routes require a provider and model"
|
|
286
|
+
raise ValueError(message)
|
|
287
|
+
self._load()
|
|
288
|
+
entry = {"provider": provider, "model": model}
|
|
289
|
+
if base_url:
|
|
290
|
+
entry["base_url"] = base_url
|
|
291
|
+
self._config[f"factory_model_{role}"] = entry
|
|
292
|
+
self._save()
|
|
293
|
+
|
|
294
|
+
def clear_factory_model(self, role: str) -> None:
|
|
295
|
+
"""Restore session model inheritance for one factory specialist."""
|
|
296
|
+
if role not in FACTORY_ROLES:
|
|
297
|
+
message = f"Unknown factory role {role!r}"
|
|
298
|
+
raise ValueError(message)
|
|
299
|
+
self._load()
|
|
300
|
+
self._config.pop(f"factory_model_{role}", None)
|
|
301
|
+
self._save()
|
|
302
|
+
|
|
303
|
+
# ── Credential metadata ─────────────────────────────────────────────────
|
|
304
|
+
#
|
|
305
|
+
# The secret itself lives in the OS keychain (see
|
|
306
|
+
# `novacode_cli.config.credentials`); only the non-secret facts that have to
|
|
307
|
+
# travel with it — the endpoint it belongs to, a project name, when it was
|
|
308
|
+
# last written — are kept here. Keyed by the credential's environment
|
|
309
|
+
# variable name, which is the stable identifier the keychain entry uses too.
|
|
310
|
+
|
|
311
|
+
def get_credential_meta(self) -> dict[str, dict[str, str]]:
|
|
312
|
+
"""Get recorded metadata for stored credentials.
|
|
313
|
+
|
|
314
|
+
Returns:
|
|
315
|
+
Mapping of environment variable name to its recorded fields
|
|
316
|
+
(``base_url``, ``project``, ``added_at``). Empty when nothing was
|
|
317
|
+
recorded, which is the normal case for a plain key.
|
|
318
|
+
"""
|
|
319
|
+
creds = self._config.get("credentials")
|
|
320
|
+
if not isinstance(creds, dict):
|
|
321
|
+
return {}
|
|
322
|
+
return {
|
|
323
|
+
str(env_var): dict(fields)
|
|
324
|
+
for env_var, fields in creds.items()
|
|
325
|
+
if isinstance(fields, dict)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
def set_credential_meta(
|
|
329
|
+
self,
|
|
330
|
+
env_var: str,
|
|
331
|
+
*,
|
|
332
|
+
base_url: str | None = None,
|
|
333
|
+
project: str | None = None,
|
|
334
|
+
added_at: str | None = None,
|
|
335
|
+
) -> None:
|
|
336
|
+
"""Record metadata for a stored credential.
|
|
337
|
+
|
|
338
|
+
Re-reads the config from disk first so a concurrent Nova that saved a
|
|
339
|
+
credential for a different provider is not clobbered: `_save` merges per
|
|
340
|
+
top-level key, so without the refresh this would write back the whole
|
|
341
|
+
`credentials` map from a stale snapshot.
|
|
342
|
+
|
|
343
|
+
Args:
|
|
344
|
+
env_var: The credential's environment variable name.
|
|
345
|
+
base_url: Endpoint paired with the key, or None.
|
|
346
|
+
project: Project/workspace name paired with the key, or None.
|
|
347
|
+
added_at: ISO-8601 timestamp of the write, or None.
|
|
348
|
+
"""
|
|
349
|
+
self._load()
|
|
350
|
+
creds = self._config.get("credentials")
|
|
351
|
+
if not isinstance(creds, dict):
|
|
352
|
+
creds = {}
|
|
353
|
+
self._config["credentials"] = creds
|
|
354
|
+
entry: dict[str, str] = {}
|
|
355
|
+
if base_url:
|
|
356
|
+
entry["base_url"] = base_url
|
|
357
|
+
if project:
|
|
358
|
+
entry["project"] = project
|
|
359
|
+
if added_at:
|
|
360
|
+
entry["added_at"] = added_at
|
|
361
|
+
creds[env_var] = entry
|
|
362
|
+
self._save()
|
|
363
|
+
|
|
364
|
+
def delete_credential_meta(self, env_var: str) -> None:
|
|
365
|
+
"""Drop recorded metadata for a credential.
|
|
366
|
+
|
|
367
|
+
Args:
|
|
368
|
+
env_var: The credential's environment variable name.
|
|
369
|
+
"""
|
|
370
|
+
self._load()
|
|
371
|
+
creds = self._config.get("credentials")
|
|
372
|
+
if not isinstance(creds, dict) or env_var not in creds:
|
|
373
|
+
return
|
|
374
|
+
del creds[env_var]
|
|
375
|
+
if not creds:
|
|
376
|
+
# Keep the file clean: an empty map and no map mean the same thing,
|
|
377
|
+
# and a leftover `"credentials": {}` reads like configuration the
|
|
378
|
+
# user set.
|
|
379
|
+
del self._config["credentials"]
|
|
380
|
+
self._save()
|
|
381
|
+
|
|
382
|
+
def get_langsmith_settings(self) -> dict[str, str]:
|
|
383
|
+
"""Return the non-secret LangSmith tracing settings."""
|
|
384
|
+
self._load()
|
|
385
|
+
raw = self._config.get("langsmith")
|
|
386
|
+
if not isinstance(raw, dict):
|
|
387
|
+
return {}
|
|
388
|
+
return {
|
|
389
|
+
key: value.strip()
|
|
390
|
+
for key, value in raw.items()
|
|
391
|
+
if key
|
|
392
|
+
in {
|
|
393
|
+
"enabled",
|
|
394
|
+
"endpoint",
|
|
395
|
+
"project",
|
|
396
|
+
"workspace_id",
|
|
397
|
+
"agent_id",
|
|
398
|
+
"agent_environment",
|
|
399
|
+
}
|
|
400
|
+
and isinstance(value, str)
|
|
401
|
+
and value.strip()
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
def set_langsmith_settings(self, values: dict[str, str]) -> None:
|
|
405
|
+
"""Save non-secret LangSmith settings, preserving unrelated config."""
|
|
406
|
+
allowed = {
|
|
407
|
+
"enabled",
|
|
408
|
+
"endpoint",
|
|
409
|
+
"project",
|
|
410
|
+
"workspace_id",
|
|
411
|
+
"agent_id",
|
|
412
|
+
"agent_environment",
|
|
413
|
+
}
|
|
414
|
+
normalized = {
|
|
415
|
+
key: value.strip()
|
|
416
|
+
for key, value in values.items()
|
|
417
|
+
if key in allowed and isinstance(value, str) and value.strip()
|
|
418
|
+
}
|
|
419
|
+
self._load()
|
|
420
|
+
if normalized:
|
|
421
|
+
self._config["langsmith"] = normalized
|
|
422
|
+
else:
|
|
423
|
+
self._config.pop("langsmith", None)
|
|
424
|
+
self._save()
|
|
425
|
+
|
|
426
|
+
# ── Recent model picks ──────────────────────────────────────────────────
|
|
427
|
+
|
|
428
|
+
#: How many recent picks are remembered. Enough to cover the handful of
|
|
429
|
+
#: models someone rotates between; short enough to stay a convenience
|
|
430
|
+
#: rather than a second copy of the model list.
|
|
431
|
+
RECENT_MODELS_LIMIT = 8
|
|
432
|
+
|
|
433
|
+
def get_recent_models(self) -> list[str]:
|
|
434
|
+
"""Get recently selected ``provider:model`` specs, most recent first.
|
|
435
|
+
|
|
436
|
+
Returns:
|
|
437
|
+
The recorded specs, newest first. Empty before any switch.
|
|
438
|
+
"""
|
|
439
|
+
recent = self._config.get("model_recent")
|
|
440
|
+
if not isinstance(recent, list):
|
|
441
|
+
return []
|
|
442
|
+
return [spec for spec in recent if isinstance(spec, str) and spec]
|
|
443
|
+
|
|
444
|
+
def push_recent_model(self, spec: str) -> list[str]:
|
|
445
|
+
"""Record a model pick as the most recent one.
|
|
446
|
+
|
|
447
|
+
Args:
|
|
448
|
+
spec: The ``provider:model`` spec that was selected.
|
|
449
|
+
|
|
450
|
+
Returns:
|
|
451
|
+
The updated recent list, newest first.
|
|
452
|
+
"""
|
|
453
|
+
spec = spec.strip()
|
|
454
|
+
if not spec:
|
|
455
|
+
return self.get_recent_models()
|
|
456
|
+
self._load()
|
|
457
|
+
recent = [entry for entry in self.get_recent_models() if entry != spec]
|
|
458
|
+
recent.insert(0, spec)
|
|
459
|
+
self._config["model_recent"] = recent[: self.RECENT_MODELS_LIMIT]
|
|
460
|
+
self._save()
|
|
461
|
+
return list(self._config["model_recent"])
|
|
462
|
+
|
|
463
|
+
# ── Vision model config (for image routing) ─────────────────────────────
|
|
464
|
+
|
|
465
|
+
VISION_MODEL_DEFAULT = "gemma4:31b-cloud"
|
|
466
|
+
VISION_PROVIDER_DEFAULT = "ollama"
|
|
467
|
+
|
|
468
|
+
def get_vision_model_config(self) -> dict[str, str]:
|
|
469
|
+
"""Get saved vision model provider configuration.
|
|
470
|
+
|
|
471
|
+
Returns:
|
|
472
|
+
Dict with 'provider' and 'model' keys. Defaults to ollama/gemma4:31b-cloud
|
|
473
|
+
when not configured.
|
|
474
|
+
"""
|
|
475
|
+
cfg = self._config.get("vision_model")
|
|
476
|
+
if cfg and isinstance(cfg, dict) and "provider" in cfg and "model" in cfg:
|
|
477
|
+
return {"provider": cfg["provider"], "model": cfg["model"]}
|
|
478
|
+
return {"provider": self.VISION_PROVIDER_DEFAULT, "model": self.VISION_MODEL_DEFAULT}
|
|
479
|
+
|
|
480
|
+
def set_vision_model_config(self, provider: str, model: str) -> None:
|
|
481
|
+
"""Save vision model provider configuration.
|
|
482
|
+
|
|
483
|
+
Args:
|
|
484
|
+
provider: Provider ID (openai, anthropic, ollama, google)
|
|
485
|
+
model: Model name
|
|
486
|
+
"""
|
|
487
|
+
self._config["vision_model"] = {
|
|
488
|
+
"provider": provider,
|
|
489
|
+
"model": model,
|
|
490
|
+
}
|
|
491
|
+
self._save()
|
|
492
|
+
from novacode_cli.bootstrap.vision_router import reset_vision_model_cache
|
|
493
|
+
|
|
494
|
+
reset_vision_model_cache()
|
|
495
|
+
|
|
496
|
+
def clear_vision_model_config(self) -> None:
|
|
497
|
+
"""Clear saved vision model configuration (reverts to default)."""
|
|
498
|
+
if "vision_model" in self._config:
|
|
499
|
+
del self._config["vision_model"]
|
|
500
|
+
self._save()
|
|
501
|
+
from novacode_cli.bootstrap.vision_router import reset_vision_model_cache
|
|
502
|
+
|
|
503
|
+
reset_vision_model_cache()
|
|
504
|
+
|
|
505
|
+
# ── Main-model multimodal override ──────────────────────────────────────
|
|
506
|
+
|
|
507
|
+
def get_main_model_multimodal(self) -> bool | None:
|
|
508
|
+
"""Explicit override for whether the MAIN model accepts images.
|
|
509
|
+
|
|
510
|
+
Returns ``None`` (auto-detect via the pattern registry), ``True``
|
|
511
|
+
(force multimodal — images go straight to the main model), or ``False``
|
|
512
|
+
(force text-only — images are available through the VISION side-call).
|
|
513
|
+
"""
|
|
514
|
+
value = self._config.get("main_model_multimodal")
|
|
515
|
+
if isinstance(value, bool):
|
|
516
|
+
return value
|
|
517
|
+
return None
|
|
518
|
+
|
|
519
|
+
def set_main_model_multimodal(self, value: bool | None) -> None:
|
|
520
|
+
"""Persist the main-model multimodal override (``None`` clears it)."""
|
|
521
|
+
if value is None:
|
|
522
|
+
self._config.pop("main_model_multimodal", None)
|
|
523
|
+
else:
|
|
524
|
+
self._config["main_model_multimodal"] = bool(value)
|
|
525
|
+
self._save()
|
|
526
|
+
|
|
527
|
+
# ── Learning / self-improvement loop (Hermes) ───────────────────────────
|
|
528
|
+
|
|
529
|
+
#: The periodic review + skill-creation loop fires out-of-band LLM calls
|
|
530
|
+
#: (every N tool calls). It is OFF by default to keep per-turn LLM cost and
|
|
531
|
+
#: latency minimal; users who want self-improvement opt in explicitly.
|
|
532
|
+
LEARNING_ENABLED_DEFAULT: bool = True
|
|
533
|
+
|
|
534
|
+
def get_learning_enabled(self) -> bool:
|
|
535
|
+
"""Whether the Hermes learning/review loop is enabled (default: on)."""
|
|
536
|
+
return _config_bool(
|
|
537
|
+
self._config.get("learning_enabled"), default=self.LEARNING_ENABLED_DEFAULT
|
|
538
|
+
)
|
|
539
|
+
|
|
540
|
+
def set_learning_enabled(self, enabled: bool) -> None:
|
|
541
|
+
"""Persist the learning-loop toggle."""
|
|
542
|
+
self._config["learning_enabled"] = bool(enabled)
|
|
543
|
+
self._save()
|
|
544
|
+
|
|
545
|
+
def get_learning_auto_approve(self) -> bool:
|
|
546
|
+
"""Whether new lessons and skills are approved without /learning review.
|
|
547
|
+
|
|
548
|
+
Off by default. Prompt rewrites always wait for review: they change the
|
|
549
|
+
system prompt of every session. Parsed strictly, like the other switches.
|
|
550
|
+
"""
|
|
551
|
+
return _config_bool(self._config.get("learning_auto_approve", False))
|
|
552
|
+
|
|
553
|
+
def set_learning_auto_approve(self, enabled: bool) -> None:
|
|
554
|
+
"""Persist the automatic-approval toggle."""
|
|
555
|
+
self._config["learning_auto_approve"] = bool(enabled)
|
|
556
|
+
self._save()
|
|
557
|
+
|
|
558
|
+
# ── Memory injection budget ─────────────────────────────────────────────
|
|
559
|
+
|
|
560
|
+
def get_memory_block_chars(self) -> int:
|
|
561
|
+
"""Per-block char budget for injected memory files.
|
|
562
|
+
|
|
563
|
+
Applies to each of ``agent.md``, the topic index, ``HABITS.md`` and
|
|
564
|
+
project memory. Defaults to
|
|
565
|
+
:data:`~novacode_cli.memory.limits.DEFAULT_MEMORY_BLOCK_CHARS`.
|
|
566
|
+
"""
|
|
567
|
+
from novacode_cli.memory.limits import DEFAULT_MEMORY_BLOCK_CHARS
|
|
568
|
+
|
|
569
|
+
value = self._config.get("memory_block_chars")
|
|
570
|
+
try:
|
|
571
|
+
n = int(value) # type: ignore[arg-type]
|
|
572
|
+
except (TypeError, ValueError):
|
|
573
|
+
return DEFAULT_MEMORY_BLOCK_CHARS
|
|
574
|
+
return n if n > 0 else DEFAULT_MEMORY_BLOCK_CHARS
|
|
575
|
+
|
|
576
|
+
def set_memory_block_chars(self, chars: int) -> None:
|
|
577
|
+
"""Persist the per-block memory injection budget."""
|
|
578
|
+
self._config["memory_block_chars"] = int(chars)
|
|
579
|
+
self._save()
|
|
580
|
+
|
|
581
|
+
def get_memory_index_chars(self) -> int:
|
|
582
|
+
"""Chars of the topic-memory INDEX injected into the system prompt.
|
|
583
|
+
|
|
584
|
+
The index is a pointer list; the rest is reachable via ``memory_search``.
|
|
585
|
+
Defaults to :data:`~novacode_cli.memory.limits.DEFAULT_MEMORY_INDEX_CHARS`.
|
|
586
|
+
"""
|
|
587
|
+
from novacode_cli.memory.limits import DEFAULT_MEMORY_INDEX_CHARS
|
|
588
|
+
|
|
589
|
+
value = self._config.get("memory_index_chars")
|
|
590
|
+
try:
|
|
591
|
+
n = int(value) # type: ignore[arg-type]
|
|
592
|
+
except (TypeError, ValueError):
|
|
593
|
+
return DEFAULT_MEMORY_INDEX_CHARS
|
|
594
|
+
return n if n > 0 else DEFAULT_MEMORY_INDEX_CHARS
|
|
595
|
+
|
|
596
|
+
def set_memory_index_chars(self, chars: int) -> None:
|
|
597
|
+
"""Persist the topic-index injection budget."""
|
|
598
|
+
self._config["memory_index_chars"] = int(chars)
|
|
599
|
+
self._save()
|
|
600
|
+
|
|
601
|
+
# ── Decision-model tool-result pruning (OFF by default) ─────────────────
|
|
602
|
+
#
|
|
603
|
+
# When enabled, the tool-result reducer clears only the results a local
|
|
604
|
+
# decision model scored stale, instead of everything older than the trigger
|
|
605
|
+
# except the newest few. It is OFF because it was measured and did not win:
|
|
606
|
+
# on six real sessions, capped to the same window the model can be asked
|
|
607
|
+
# about, the existing rule cleared 70 results / 72,682 chars at 0.19
|
|
608
|
+
# regretted per 1k, against 49 / 18,364 at 0.44 for the verdicts. The model
|
|
609
|
+
# itself is good (tev1:4b passes a 12-question positive control 12/12 with a
|
|
610
|
+
# 0.866 margin); the limiting factor is that its ~2,000-token context holds
|
|
611
|
+
# only the newest ~12 results of a session that holds 65-308.
|
|
612
|
+
#
|
|
613
|
+
# Kept behind a flag so it can be tried in a live session, and so the
|
|
614
|
+
# decision stays re-measurable rather than becoming a claim in a comment.
|
|
615
|
+
|
|
616
|
+
#: Model name at the endpoint. `tev1:4b` is the separated one; the 0.8B puts
|
|
617
|
+
#: plainly-false statements at 0.476-0.524, straddling any 0.5 threshold.
|
|
618
|
+
TOOL_VERDICT_DEFAULT_MODEL = "tev1:4b"
|
|
619
|
+
|
|
620
|
+
#: Where the decisions are asked of. Ollama serves the System One shape.
|
|
621
|
+
TOOL_VERDICT_DEFAULT_ENDPOINT = "http://localhost:11434/v1/systemone"
|
|
622
|
+
|
|
623
|
+
TOOL_VERDICT_JEV_ENDPOINT = "https://api.typesafe.ai/v1/systemone"
|
|
624
|
+
TOOL_VERDICT_JEV_MODEL = "jev-latest"
|
|
625
|
+
TOOL_VERDICT_OPENCODE_ENDPOINT = "https://opencode.ai/zen/v1/systemone"
|
|
626
|
+
TOOL_VERDICT_OPENCODE_MODEL = "jev-1.13"
|
|
627
|
+
TOOL_VERDICT_OPENCODE_FREE_MODEL = "jev-1.13-free"
|
|
628
|
+
TOOL_VERDICT_COMMANDCODE_ENDPOINT = "https://api.commandcode.ai/provider/v1/systemone"
|
|
629
|
+
TOOL_VERDICT_COMMANDCODE_MODEL = "typesafe/jev"
|
|
630
|
+
TOOL_VERDICT_OPENAI_ENDPOINT = "https://api.openai.com/v1/decisions"
|
|
631
|
+
TOOL_VERDICT_OPENAI_MODEL = "gpt-6-luna"
|
|
632
|
+
#: ``llama serve`` speaks System One at its default address. In router mode
|
|
633
|
+
#: (the llama.cpp app) the model must be an id it lists at /v1/models.
|
|
634
|
+
TOOL_VERDICT_LLAMACPP_ENDPOINT = "http://127.0.0.1:9931/v1/systemone"
|
|
635
|
+
TOOL_VERDICT_LLAMACPP_MODEL = "ggml-org/Kev-4B-GGUF"
|
|
636
|
+
|
|
637
|
+
def set_tool_verdict_settings(self, *, enabled: bool, endpoint: str, model: str) -> None:
|
|
638
|
+
"""Persist a complete decision configuration in one write."""
|
|
639
|
+
from urllib.parse import urlsplit
|
|
640
|
+
|
|
641
|
+
endpoint, model = endpoint.strip(), model.strip()
|
|
642
|
+
try:
|
|
643
|
+
parts = urlsplit(endpoint)
|
|
644
|
+
valid = (
|
|
645
|
+
parts.scheme in {"http", "https"}
|
|
646
|
+
and bool(parts.hostname)
|
|
647
|
+
and parts.username is None
|
|
648
|
+
and parts.password is None
|
|
649
|
+
)
|
|
650
|
+
_ = parts.port
|
|
651
|
+
except ValueError:
|
|
652
|
+
valid = False
|
|
653
|
+
if not valid:
|
|
654
|
+
message = "Endpoint must be an http(s) URL without embedded credentials."
|
|
655
|
+
raise ValueError(message)
|
|
656
|
+
if not model:
|
|
657
|
+
message = "Decision model cannot be empty."
|
|
658
|
+
raise ValueError(message)
|
|
659
|
+
self._config.update(
|
|
660
|
+
tool_verdicts_enabled=bool(enabled),
|
|
661
|
+
tool_verdict_endpoint=endpoint,
|
|
662
|
+
tool_verdict_model=model,
|
|
663
|
+
)
|
|
664
|
+
self._save()
|
|
665
|
+
|
|
666
|
+
def get_tool_verdicts_enabled(self) -> bool:
|
|
667
|
+
"""Whether the tool-result reducer consults a decision model.
|
|
668
|
+
|
|
669
|
+
Parsed strictly rather than with ``bool()``: ``bool("false")`` is ``True``,
|
|
670
|
+
and this is the master switch for a feature that is off by default, so a
|
|
671
|
+
hand-edited string must never be able to turn it on by accident. See
|
|
672
|
+
:func:`_config_bool`.
|
|
673
|
+
"""
|
|
674
|
+
return _config_bool(self._config.get("tool_verdicts_enabled", False))
|
|
675
|
+
|
|
676
|
+
def set_tool_verdicts_enabled(self, enabled: bool) -> None:
|
|
677
|
+
"""Persist the decision-model pruning flag."""
|
|
678
|
+
self._config["tool_verdicts_enabled"] = bool(enabled)
|
|
679
|
+
self._save()
|
|
680
|
+
|
|
681
|
+
def get_auto_approve_decisions_enabled(self) -> bool:
|
|
682
|
+
"""Whether auto-approve asks the configured decision model for approval."""
|
|
683
|
+
return _config_bool(self._config.get("auto_approve_decisions_enabled", False))
|
|
684
|
+
|
|
685
|
+
def set_auto_approve_decisions_enabled(self, enabled: bool) -> None:
|
|
686
|
+
"""Persist the opt-in decision-model approval setting."""
|
|
687
|
+
self._config["auto_approve_decisions_enabled"] = bool(enabled)
|
|
688
|
+
self._save()
|
|
689
|
+
|
|
690
|
+
def get_tool_verdict_endpoint(self) -> str:
|
|
691
|
+
"""System One endpoint the verdicts are asked of."""
|
|
692
|
+
value = self._config.get("tool_verdict_endpoint")
|
|
693
|
+
if isinstance(value, str) and value.strip():
|
|
694
|
+
return value.strip()
|
|
695
|
+
return self.TOOL_VERDICT_DEFAULT_ENDPOINT
|
|
696
|
+
|
|
697
|
+
def set_tool_verdict_endpoint(self, endpoint: str) -> None:
|
|
698
|
+
"""Persist the System One endpoint."""
|
|
699
|
+
self._config["tool_verdict_endpoint"] = str(endpoint).strip()
|
|
700
|
+
self._save()
|
|
701
|
+
|
|
702
|
+
def get_tool_verdict_model(self) -> str:
|
|
703
|
+
"""Model name at the endpoint."""
|
|
704
|
+
value = self._config.get("tool_verdict_model")
|
|
705
|
+
if isinstance(value, str) and value.strip():
|
|
706
|
+
return value.strip()
|
|
707
|
+
return self.TOOL_VERDICT_DEFAULT_MODEL
|
|
708
|
+
|
|
709
|
+
def set_tool_verdict_model(self, model: str) -> None:
|
|
710
|
+
"""Persist the decision-model name."""
|
|
711
|
+
self._config["tool_verdict_model"] = str(model).strip()
|
|
712
|
+
self._save()
|
|
713
|
+
|
|
714
|
+
def get_tool_verdict_keep_threshold(self) -> float:
|
|
715
|
+
"""Minimum probability that a result is still needed for it to survive.
|
|
716
|
+
|
|
717
|
+
Thresholds do not transfer between models, or between the two Tev1
|
|
718
|
+
sizes, so this is separately settable rather than shared with the
|
|
719
|
+
heuristic's ``keep`` count.
|
|
720
|
+
"""
|
|
721
|
+
from novacode_cli.agents.tool_verdicts import DEFAULT_KEEP_THRESHOLD
|
|
722
|
+
|
|
723
|
+
raw = self._config.get("tool_verdict_keep_threshold")
|
|
724
|
+
try:
|
|
725
|
+
value = float(raw) # type: ignore[arg-type]
|
|
726
|
+
except (TypeError, ValueError):
|
|
727
|
+
return DEFAULT_KEEP_THRESHOLD
|
|
728
|
+
return value if 0.0 < value < 1.0 else DEFAULT_KEEP_THRESHOLD
|
|
729
|
+
|
|
730
|
+
def set_tool_verdict_keep_threshold(self, threshold: float) -> None:
|
|
731
|
+
"""Persist the keep threshold."""
|
|
732
|
+
self._config["tool_verdict_keep_threshold"] = float(threshold)
|
|
733
|
+
self._save()
|
|
734
|
+
|
|
735
|
+
# ── Model routing (/router, OFF by default) ─────────────────────────────
|
|
736
|
+
#
|
|
737
|
+
# When enabled, each turn is classified by a System One decision model
|
|
738
|
+
# (Jev in the cloud, or a local model such as tev1) and routed to one of
|
|
739
|
+
# the configured routes. A route is a ``provider:model`` pair plus the
|
|
740
|
+
# criteria that describe when it should be chosen, so the router is
|
|
741
|
+
# provider- and model-agnostic: any provider ``build_chat_model`` knows
|
|
742
|
+
# about can be a target.
|
|
743
|
+
#
|
|
744
|
+
# The whole block lives under one top-level ``router`` key so ``_save``'s
|
|
745
|
+
# per-key merge keeps it atomic -- a half-written route list is not a state
|
|
746
|
+
# the reader has to defend against.
|
|
747
|
+
|
|
748
|
+
#: Decision-model defaults. Deliberately the same endpoint/model as the
|
|
749
|
+
#: tool-verdict feature, so a user who already configured Jev or tev1 gets
|
|
750
|
+
#: routing working with no extra setup. Stored separately so the two
|
|
751
|
+
#: features can diverge without one silently changing the other.
|
|
752
|
+
ROUTER_DEFAULT_ENDPOINT = TOOL_VERDICT_DEFAULT_ENDPOINT
|
|
753
|
+
ROUTER_DEFAULT_MODEL = TOOL_VERDICT_DEFAULT_MODEL
|
|
754
|
+
|
|
755
|
+
#: Minimum classifier confidence for a route to be taken. Below this the
|
|
756
|
+
#: default route wins, because a coin-flip between two models is worse than
|
|
757
|
+
#: a predictable one.
|
|
758
|
+
ROUTER_DEFAULT_MIN_CONFIDENCE = 0.5
|
|
759
|
+
|
|
760
|
+
def _router_block(self) -> dict[str, Any]:
|
|
761
|
+
"""The active profile settings, with support for pre-profile configs."""
|
|
762
|
+
block = self._config.get("router")
|
|
763
|
+
if not isinstance(block, dict):
|
|
764
|
+
return {}
|
|
765
|
+
profiles = block.get("profiles")
|
|
766
|
+
if isinstance(profiles, dict):
|
|
767
|
+
active = str(block.get("active_profile", "default"))
|
|
768
|
+
profile = profiles.get(active)
|
|
769
|
+
return profile if isinstance(profile, dict) else {}
|
|
770
|
+
return block
|
|
771
|
+
|
|
772
|
+
def _migrate_router_profiles(self) -> dict[str, Any]:
|
|
773
|
+
"""Convert the legacy single-router block into the Default profile."""
|
|
774
|
+
root = self._config.get("router")
|
|
775
|
+
if not isinstance(root, dict):
|
|
776
|
+
root = {}
|
|
777
|
+
if not isinstance(root.get("profiles"), dict):
|
|
778
|
+
legacy = {
|
|
779
|
+
key: copy.deepcopy(value)
|
|
780
|
+
for key, value in root.items()
|
|
781
|
+
if key not in {"profiles", "active_profile"}
|
|
782
|
+
}
|
|
783
|
+
root = {
|
|
784
|
+
"active_profile": "default",
|
|
785
|
+
"profiles": {"default": {"name": "Default", **legacy}},
|
|
786
|
+
}
|
|
787
|
+
self._config["router"] = root
|
|
788
|
+
elif not root["profiles"]:
|
|
789
|
+
root["profiles"]["default"] = {"name": "Default"}
|
|
790
|
+
root["active_profile"] = "default"
|
|
791
|
+
if root.get("active_profile") not in root["profiles"]:
|
|
792
|
+
root["active_profile"] = next(iter(root["profiles"]))
|
|
793
|
+
return root
|
|
794
|
+
|
|
795
|
+
def get_router_profiles(self) -> list[dict[str, str]]:
|
|
796
|
+
"""List named router profiles for the /router profile switcher."""
|
|
797
|
+
root = self._migrate_router_profiles()
|
|
798
|
+
return [
|
|
799
|
+
{"id": str(profile_id), "name": str(profile.get("name", profile_id))}
|
|
800
|
+
for profile_id, profile in root["profiles"].items()
|
|
801
|
+
if isinstance(profile, dict)
|
|
802
|
+
]
|
|
803
|
+
|
|
804
|
+
def get_active_router_profile(self) -> str:
|
|
805
|
+
"""Return the id of the currently selected router profile."""
|
|
806
|
+
return str(self._migrate_router_profiles()["active_profile"])
|
|
807
|
+
|
|
808
|
+
def get_router_profile_settings(self, profile_id: str) -> dict[str, Any]:
|
|
809
|
+
"""Return a detached settings copy for one profile."""
|
|
810
|
+
root = self._migrate_router_profiles()
|
|
811
|
+
profile = root["profiles"].get(profile_id)
|
|
812
|
+
if not isinstance(profile, dict):
|
|
813
|
+
raise ValueError(f"Unknown router profile {profile_id!r}.")
|
|
814
|
+
return copy.deepcopy(profile)
|
|
815
|
+
|
|
816
|
+
def _store_active_router_block(self, block: dict[str, Any]) -> None:
|
|
817
|
+
"""Store settings without losing the profile's display name."""
|
|
818
|
+
root = self._migrate_router_profiles()
|
|
819
|
+
profile_id = str(root["active_profile"])
|
|
820
|
+
existing = root["profiles"].get(profile_id, {})
|
|
821
|
+
profile = copy.deepcopy(block)
|
|
822
|
+
profile.setdefault("name", existing.get("name", profile_id))
|
|
823
|
+
root["profiles"][profile_id] = profile
|
|
824
|
+
|
|
825
|
+
def set_active_router_profile(self, profile_id: str) -> None:
|
|
826
|
+
"""Select an existing router profile."""
|
|
827
|
+
root = self._migrate_router_profiles()
|
|
828
|
+
if profile_id not in root["profiles"]:
|
|
829
|
+
raise ValueError(f"Unknown router profile {profile_id!r}.")
|
|
830
|
+
root["active_profile"] = profile_id
|
|
831
|
+
self._save()
|
|
832
|
+
|
|
833
|
+
def create_router_profile(self, name: str) -> str:
|
|
834
|
+
"""Create and activate a blank named routing profile; return its id."""
|
|
835
|
+
import re
|
|
836
|
+
|
|
837
|
+
name = name.strip()
|
|
838
|
+
profile_id = re.sub(r"[^a-z0-9]+", "-", name.lower()).strip("-")
|
|
839
|
+
if not profile_id:
|
|
840
|
+
raise ValueError("A router profile needs a name.")
|
|
841
|
+
root = self._migrate_router_profiles()
|
|
842
|
+
if profile_id in root["profiles"]:
|
|
843
|
+
raise ValueError(f"Router profile {name!r} already exists.")
|
|
844
|
+
root["profiles"][profile_id] = {"name": name, "enabled": False, "routes": []}
|
|
845
|
+
root["active_profile"] = profile_id
|
|
846
|
+
self._save()
|
|
847
|
+
return profile_id
|
|
848
|
+
|
|
849
|
+
def delete_router_profile(self, profile_id: str) -> None:
|
|
850
|
+
"""Delete a profile, retaining at least one selectable profile."""
|
|
851
|
+
root = self._migrate_router_profiles()
|
|
852
|
+
profiles = root["profiles"]
|
|
853
|
+
if profile_id not in profiles:
|
|
854
|
+
raise ValueError(f"Unknown router profile {profile_id!r}.")
|
|
855
|
+
if len(profiles) == 1:
|
|
856
|
+
raise ValueError("At least one router profile must remain.")
|
|
857
|
+
del profiles[profile_id]
|
|
858
|
+
if root["active_profile"] == profile_id:
|
|
859
|
+
root["active_profile"] = next(iter(profiles))
|
|
860
|
+
self._save()
|
|
861
|
+
|
|
862
|
+
def get_router_enabled(self) -> bool:
|
|
863
|
+
"""Whether turns are routed by a decision model.
|
|
864
|
+
|
|
865
|
+
Parsed strictly rather than with ``bool()`` for the same reason as
|
|
866
|
+
:meth:`get_tool_verdicts_enabled`: ``bool("false")`` is ``True``, and
|
|
867
|
+
this is the master switch for a feature that is off by default.
|
|
868
|
+
"""
|
|
869
|
+
return _config_bool(self._router_block().get("enabled", False))
|
|
870
|
+
|
|
871
|
+
def set_router_enabled(self, enabled: bool) -> None:
|
|
872
|
+
"""Persist the routing flag."""
|
|
873
|
+
block = self._router_block()
|
|
874
|
+
block["enabled"] = bool(enabled)
|
|
875
|
+
self._store_active_router_block(block)
|
|
876
|
+
self._save()
|
|
877
|
+
|
|
878
|
+
def get_router_routes(self) -> list[dict[str, Any]]:
|
|
879
|
+
"""The configured routes, in the order they were added.
|
|
880
|
+
|
|
881
|
+
Returns a deep copy: callers mutate what they get back (the TUI screen
|
|
882
|
+
edits a working list), and a shared reference would let an abandoned
|
|
883
|
+
edit reach the live config.
|
|
884
|
+
"""
|
|
885
|
+
routes = self._router_block().get("routes")
|
|
886
|
+
if not isinstance(routes, list):
|
|
887
|
+
return []
|
|
888
|
+
return [copy.deepcopy(r) for r in routes if isinstance(r, dict)]
|
|
889
|
+
|
|
890
|
+
def set_router_routes(self, routes: list[dict[str, Any]]) -> None:
|
|
891
|
+
"""Persist the route list, validating it first.
|
|
892
|
+
|
|
893
|
+
Validation is here rather than in the UI because this is the last point
|
|
894
|
+
every writer passes through, and a route with an unknown provider would
|
|
895
|
+
otherwise fail at model-construction time -- mid-turn, in the agent,
|
|
896
|
+
where the error is far from its cause.
|
|
897
|
+
|
|
898
|
+
Raises:
|
|
899
|
+
ValueError: A route is malformed, ids collide, or a provider is
|
|
900
|
+
unknown.
|
|
901
|
+
"""
|
|
902
|
+
from novacode_cli.config.model_manager import MODEL_PRESETS
|
|
903
|
+
|
|
904
|
+
cleaned: list[dict[str, Any]] = []
|
|
905
|
+
seen: set[str] = set()
|
|
906
|
+
for index, route in enumerate(routes):
|
|
907
|
+
if not isinstance(route, dict):
|
|
908
|
+
message = f"Route {index} is not an object."
|
|
909
|
+
raise ValueError(message)
|
|
910
|
+
route_id = str(route.get("id", "")).strip()
|
|
911
|
+
provider = str(route.get("provider", "")).strip()
|
|
912
|
+
model = str(route.get("model", "")).strip()
|
|
913
|
+
criteria = str(route.get("criteria", "")).strip()
|
|
914
|
+
if not route_id:
|
|
915
|
+
message = f"Route {index} has no id."
|
|
916
|
+
raise ValueError(message)
|
|
917
|
+
if route_id in seen:
|
|
918
|
+
message = f"Duplicate route id {route_id!r}."
|
|
919
|
+
raise ValueError(message)
|
|
920
|
+
if provider not in MODEL_PRESETS:
|
|
921
|
+
message = f"Route {route_id!r} has unknown provider {provider!r}."
|
|
922
|
+
raise ValueError(message)
|
|
923
|
+
if not model:
|
|
924
|
+
message = f"Route {route_id!r} has no model."
|
|
925
|
+
raise ValueError(message)
|
|
926
|
+
if not criteria:
|
|
927
|
+
message = f"Route {route_id!r} has no criteria."
|
|
928
|
+
raise ValueError(message)
|
|
929
|
+
seen.add(route_id)
|
|
930
|
+
entry: dict[str, Any] = {
|
|
931
|
+
"id": route_id,
|
|
932
|
+
"provider": provider,
|
|
933
|
+
"model": model,
|
|
934
|
+
"criteria": criteria,
|
|
935
|
+
}
|
|
936
|
+
base_url = route.get("base_url")
|
|
937
|
+
if isinstance(base_url, str) and base_url.strip():
|
|
938
|
+
entry["base_url"] = base_url.strip()
|
|
939
|
+
effort = route.get("reasoning_effort")
|
|
940
|
+
if effort is not None:
|
|
941
|
+
if not isinstance(effort, str) or effort not in {"off", "low", "medium", "high"}:
|
|
942
|
+
raise ValueError(f"Route {route_id!r} has invalid reasoning effort.")
|
|
943
|
+
entry["reasoning_effort"] = effort
|
|
944
|
+
cleaned.append(entry)
|
|
945
|
+
|
|
946
|
+
block = self._router_block()
|
|
947
|
+
block["routes"] = cleaned
|
|
948
|
+
self._store_active_router_block(block)
|
|
949
|
+
self._save()
|
|
950
|
+
|
|
951
|
+
def get_router_default_route(self) -> str | None:
|
|
952
|
+
"""Route id used when the classifier fails or is unsure."""
|
|
953
|
+
value = self._router_block().get("default_route")
|
|
954
|
+
if isinstance(value, str) and value.strip():
|
|
955
|
+
return value.strip()
|
|
956
|
+
return None
|
|
957
|
+
|
|
958
|
+
def set_router_default_route(self, route_id: str | None) -> None:
|
|
959
|
+
"""Persist the fallback route id (``None`` clears it)."""
|
|
960
|
+
block = self._router_block()
|
|
961
|
+
if route_id is None or not str(route_id).strip():
|
|
962
|
+
block.pop("default_route", None)
|
|
963
|
+
else:
|
|
964
|
+
block["default_route"] = str(route_id).strip()
|
|
965
|
+
self._store_active_router_block(block)
|
|
966
|
+
self._save()
|
|
967
|
+
|
|
968
|
+
def get_router_decision_endpoint(self) -> str:
|
|
969
|
+
"""System One endpoint the routing decisions are asked of."""
|
|
970
|
+
value = self._router_block().get("decision_endpoint")
|
|
971
|
+
if isinstance(value, str) and value.strip():
|
|
972
|
+
return value.strip()
|
|
973
|
+
return self.ROUTER_DEFAULT_ENDPOINT
|
|
974
|
+
|
|
975
|
+
def set_router_decision_endpoint(self, endpoint: str) -> None:
|
|
976
|
+
"""Persist the routing decision endpoint."""
|
|
977
|
+
block = self._router_block()
|
|
978
|
+
block["decision_endpoint"] = str(endpoint).strip()
|
|
979
|
+
self._store_active_router_block(block)
|
|
980
|
+
self._save()
|
|
981
|
+
|
|
982
|
+
def get_router_decision_model(self) -> str:
|
|
983
|
+
"""Model name at the routing decision endpoint."""
|
|
984
|
+
value = self._router_block().get("decision_model")
|
|
985
|
+
if isinstance(value, str) and value.strip():
|
|
986
|
+
return value.strip()
|
|
987
|
+
return self.ROUTER_DEFAULT_MODEL
|
|
988
|
+
|
|
989
|
+
def set_router_decision_model(self, model: str) -> None:
|
|
990
|
+
"""Persist the routing decision model name."""
|
|
991
|
+
block = self._router_block()
|
|
992
|
+
block["decision_model"] = str(model).strip()
|
|
993
|
+
self._store_active_router_block(block)
|
|
994
|
+
self._save()
|
|
995
|
+
|
|
996
|
+
def get_router_min_confidence(self) -> float:
|
|
997
|
+
"""Minimum classifier confidence for a route to be taken."""
|
|
998
|
+
raw = self._router_block().get("min_confidence")
|
|
999
|
+
try:
|
|
1000
|
+
value = float(raw) # type: ignore[arg-type]
|
|
1001
|
+
except (TypeError, ValueError):
|
|
1002
|
+
return self.ROUTER_DEFAULT_MIN_CONFIDENCE
|
|
1003
|
+
return value if 0.0 < value <= 1.0 else self.ROUTER_DEFAULT_MIN_CONFIDENCE
|
|
1004
|
+
|
|
1005
|
+
def set_router_min_confidence(self, threshold: float) -> None:
|
|
1006
|
+
"""Persist the minimum routing confidence."""
|
|
1007
|
+
block = self._router_block()
|
|
1008
|
+
block["min_confidence"] = float(threshold)
|
|
1009
|
+
self._store_active_router_block(block)
|
|
1010
|
+
self._save()
|
|
1011
|
+
|
|
1012
|
+
# ── Voice config (local STT / VAD / TTS) ────────────────────────────────
|
|
1013
|
+
|
|
1014
|
+
VOICE_DEFAULTS: dict[str, Any] = { # noqa: RUF012
|
|
1015
|
+
"enabled": False,
|
|
1016
|
+
"mode": "push_to_talk", # "push_to_talk" | "listen"
|
|
1017
|
+
"speak_responses": True,
|
|
1018
|
+
"stt_provider": "faster-whisper",
|
|
1019
|
+
"tts_provider": "piper",
|
|
1020
|
+
# Legacy flat keys (deprecated — kept for backward compat; merged into providers dict on save).
|
|
1021
|
+
"stt_model": "base",
|
|
1022
|
+
"stt_device": "auto",
|
|
1023
|
+
"tts_voice": "en_US-lessac-medium",
|
|
1024
|
+
# Per-provider configuration (keys match provider ids in audio/providers.py).
|
|
1025
|
+
"providers": {
|
|
1026
|
+
"faster-whisper": {"model": "distil-large-v3", "device": "auto"},
|
|
1027
|
+
"deepgram": {"api_key": "", "model": "nova-2"},
|
|
1028
|
+
"piper": {"voice": "en_US-lessac-medium"},
|
|
1029
|
+
"elevenlabs": {"api_key": "", "voice_id": "21m00Tcm4TlvDq8ikWAM"},
|
|
1030
|
+
"orpheus": {"voice": "tara", "lang": "en"},
|
|
1031
|
+
},
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
def get_voice_config(self) -> dict[str, Any]:
|
|
1035
|
+
"""Return the saved voice settings merged over the defaults."""
|
|
1036
|
+
merged = dict(self.VOICE_DEFAULTS)
|
|
1037
|
+
cfg = self._config.get("voice")
|
|
1038
|
+
if isinstance(cfg, dict):
|
|
1039
|
+
merged.update({k: cfg[k] for k in cfg if k in self.VOICE_DEFAULTS})
|
|
1040
|
+
return merged
|
|
1041
|
+
|
|
1042
|
+
def set_voice_config(self, **updates: Any) -> dict[str, Any]:
|
|
1043
|
+
"""Merge ``updates`` (known keys only) into the voice config and persist."""
|
|
1044
|
+
cfg = self.get_voice_config()
|
|
1045
|
+
cfg.update({k: v for k, v in updates.items() if k in self.VOICE_DEFAULTS})
|
|
1046
|
+
self._config["voice"] = cfg
|
|
1047
|
+
self._save()
|
|
1048
|
+
return cfg
|
|
1049
|
+
|
|
1050
|
+
def get_voice_provider_config(self, provider: str) -> dict[str, Any]:
|
|
1051
|
+
"""Return saved config for a specific voice provider (e.g. deepgram, elevenlabs)."""
|
|
1052
|
+
cfg = self.get_voice_config()
|
|
1053
|
+
providers = cfg.get("providers", {})
|
|
1054
|
+
return dict(providers.get(provider, {}))
|
|
1055
|
+
|
|
1056
|
+
def set_voice_provider_config(self, provider: str, **updates: Any) -> dict[str, Any]:
|
|
1057
|
+
"""Merge ``updates`` into a provider's config and persist."""
|
|
1058
|
+
cfg = self.get_voice_config()
|
|
1059
|
+
providers = dict(cfg.get("providers", {}))
|
|
1060
|
+
pcfg = dict(providers.get(provider, {}))
|
|
1061
|
+
pcfg.update(updates)
|
|
1062
|
+
providers[provider] = pcfg
|
|
1063
|
+
cfg["providers"] = providers
|
|
1064
|
+
self._config["voice"] = cfg
|
|
1065
|
+
self._save()
|
|
1066
|
+
return pcfg
|
|
1067
|
+
|
|
1068
|
+
def get_attribution(self) -> dict[str, bool]:
|
|
1069
|
+
"""Independent AI attribution preferences, enabled for existing installs."""
|
|
1070
|
+
saved = self.get("attribution", {})
|
|
1071
|
+
saved = saved if isinstance(saved, dict) else {}
|
|
1072
|
+
return {
|
|
1073
|
+
name: _config_bool(saved.get(name), default=True)
|
|
1074
|
+
for name in ("commits", "pullRequests")
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
def get_attribution_identity(self) -> dict[str, str]:
|
|
1078
|
+
"""Read an optional GitHub-linked co-author, rejecting malformed trailer fields."""
|
|
1079
|
+
default = {"name": DEFAULT_ATTRIBUTION_NAME, "email": DEFAULT_ATTRIBUTION_EMAIL}
|
|
1080
|
+
saved = self.get("attribution", {})
|
|
1081
|
+
identity = saved.get("coAuthor") if isinstance(saved, dict) else None
|
|
1082
|
+
if not isinstance(identity, dict):
|
|
1083
|
+
return default
|
|
1084
|
+
name = identity.get("name", DEFAULT_ATTRIBUTION_NAME)
|
|
1085
|
+
email = identity.get("email")
|
|
1086
|
+
if not isinstance(name, str) or not isinstance(email, str):
|
|
1087
|
+
return default
|
|
1088
|
+
name, email = name.strip(), email.strip()
|
|
1089
|
+
if not name or not name.isprintable() or len(name) > 200 or len(email) > 320:
|
|
1090
|
+
return default
|
|
1091
|
+
if any(ord(char) < 32 or char in "<>" for char in name + email):
|
|
1092
|
+
return default
|
|
1093
|
+
if email.count("@") != 1 or any(char.isspace() for char in email):
|
|
1094
|
+
return default
|
|
1095
|
+
if not all(email.split("@")):
|
|
1096
|
+
return default
|
|
1097
|
+
return {"name": name, "email": email}
|
|
1098
|
+
|
|
1099
|
+
def get_code_mode_enabled(self) -> bool:
|
|
1100
|
+
"""Whether tools may be composed with JavaScript (enabled by default)."""
|
|
1101
|
+
return _config_bool(self.get("code_mode_enabled", True), default=True)
|
|
1102
|
+
|
|
1103
|
+
def set_code_mode_enabled(self, enabled: bool) -> None: # noqa: FBT001 -- config setter API.
|
|
1104
|
+
"""Persist the live Code Mode preference."""
|
|
1105
|
+
self.set("code_mode_enabled", bool(enabled))
|
|
1106
|
+
|
|
1107
|
+
def get_browser_mode_servers(self) -> list[str]:
|
|
1108
|
+
"""Explicit browser MCP selections; malformed stored grants fail closed."""
|
|
1109
|
+
return _browser_server_names(self.get("browser_mode_servers", ["obscura"])) or []
|
|
1110
|
+
|
|
1111
|
+
def set_browser_mode_servers(self, servers: list[str]) -> None:
|
|
1112
|
+
"""Persist exact selections, including an empty list for web-search-only mode."""
|
|
1113
|
+
names = _browser_server_names(servers)
|
|
1114
|
+
if names is None:
|
|
1115
|
+
message = "Browser servers must be a list of exact, nonempty MCP server names."
|
|
1116
|
+
raise ValueError(message)
|
|
1117
|
+
self.set("browser_mode_servers", names)
|
|
1118
|
+
|
|
1119
|
+
def get_edit_diagnostics_enabled(self) -> bool:
|
|
1120
|
+
"""Whether file edits are followed by the project's own lint/type checks."""
|
|
1121
|
+
return _config_bool(self.get("edit_diagnostics_enabled", True), default=True)
|
|
1122
|
+
|
|
1123
|
+
def get_edit_diagnostics_project_tools(self) -> bool:
|
|
1124
|
+
"""Whether edit checks may run the workspace's own .venv/node_modules executables."""
|
|
1125
|
+
return _config_bool(self.get("edit_diagnostics_project_tools", False))
|
|
1126
|
+
|
|
1127
|
+
def get_compression_mode(self) -> str:
|
|
1128
|
+
"""Read the exclusive mode, migrating the legacy Caveman switch lazily."""
|
|
1129
|
+
mode = self.get("compression_mode")
|
|
1130
|
+
if "compression_mode" not in self._config:
|
|
1131
|
+
return "caveman" if _config_bool(self.get("caveman_enabled")) else "off"
|
|
1132
|
+
return mode if isinstance(mode, str) and mode in ("off", "caveman", "ponytail") else "off"
|
|
1133
|
+
|
|
1134
|
+
def set_compression_mode(self, mode: str) -> None:
|
|
1135
|
+
"""Persist one active mode and the legacy compatibility switch together."""
|
|
1136
|
+
if mode not in ("off", "caveman", "ponytail"):
|
|
1137
|
+
message = "Unsupported compression mode."
|
|
1138
|
+
raise ValueError(message)
|
|
1139
|
+
self._config.update(compression_mode=mode, caveman_enabled=mode == "caveman")
|
|
1140
|
+
if mode != "off":
|
|
1141
|
+
self._config["compression_last_mode"] = mode
|
|
1142
|
+
self._save()
|
|
1143
|
+
|
|
1144
|
+
def get_preferred_compression_mode(self) -> str:
|
|
1145
|
+
"""Remember the chosen style while off, including profiles predating Lite Mode."""
|
|
1146
|
+
active = self.get_compression_mode()
|
|
1147
|
+
saved = active if active != "off" else self.get("compression_last_mode", "caveman")
|
|
1148
|
+
return saved if saved in ("caveman", "ponytail") else "caveman"
|
|
1149
|
+
|
|
1150
|
+
def get_ponytail_level(self) -> str:
|
|
1151
|
+
"""Read Ponytail intensity independently of the Caveman settings."""
|
|
1152
|
+
level = self.get("ponytail_level", "full")
|
|
1153
|
+
return level if isinstance(level, str) and level in ("lite", "full", "ultra") else "full"
|
|
1154
|
+
|
|
1155
|
+
def set_ponytail_level(self, level: str) -> None:
|
|
1156
|
+
"""Save a supported upstream intensity."""
|
|
1157
|
+
if level not in ("lite", "full", "ultra"):
|
|
1158
|
+
message = "Unsupported Ponytail intensity."
|
|
1159
|
+
raise ValueError(message)
|
|
1160
|
+
self.set("ponytail_level", level)
|
|
1161
|
+
|
|
1162
|
+
def get_caveman_enabled(self) -> bool:
|
|
1163
|
+
"""Whether replies should use the opt-in terse prose style."""
|
|
1164
|
+
return self.get_compression_mode() == "caveman"
|
|
1165
|
+
|
|
1166
|
+
def set_caveman_enabled(self, enabled: bool) -> None:
|
|
1167
|
+
"""Persist the response style independently of model and routing choices."""
|
|
1168
|
+
self.set_compression_mode("caveman" if enabled else "off")
|
|
1169
|
+
|
|
1170
|
+
def get_caveman_level(self) -> str:
|
|
1171
|
+
"""Read the skill's default intensity, tolerating older configurations."""
|
|
1172
|
+
saved = self.get("caveman_level", "full")
|
|
1173
|
+
return saved if isinstance(saved, str) and saved in CAVEMAN_LEVELS else "full"
|
|
1174
|
+
|
|
1175
|
+
def set_caveman_level(self, level: str) -> None:
|
|
1176
|
+
"""Persist a supported intensity without changing the master switch."""
|
|
1177
|
+
if level not in CAVEMAN_LEVELS:
|
|
1178
|
+
raise ValueError("Unsupported Caveman intensity.")
|
|
1179
|
+
self.set("caveman_level", level)
|
|
1180
|
+
|
|
1181
|
+
def get_caveman_features(self) -> dict[str, bool]:
|
|
1182
|
+
"""Read independent switches, effective only while the master mode is on."""
|
|
1183
|
+
master = self.get_caveman_enabled()
|
|
1184
|
+
return {
|
|
1185
|
+
name: master and enabled
|
|
1186
|
+
for name, enabled in self.get_caveman_feature_preferences().items()
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
def get_caveman_feature_preferences(self) -> dict[str, bool]:
|
|
1190
|
+
"""Read saved feature choices independently of the active compression style."""
|
|
1191
|
+
saved = self.get("caveman_features", {})
|
|
1192
|
+
saved = saved if isinstance(saved, dict) else {}
|
|
1193
|
+
return {
|
|
1194
|
+
name: _config_bool(saved.get(name), default=True)
|
|
1195
|
+
for name in ("say", "read", "auto", "blocks", "waste", "browse")
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
def set_caveman_features(self, features: dict[str, bool]) -> None:
|
|
1199
|
+
"""Save all six independent preferences without changing the master toggle."""
|
|
1200
|
+
self.set_caveman_options(features, self.get_caveman_level())
|
|
1201
|
+
|
|
1202
|
+
def set_caveman_options(
|
|
1203
|
+
self,
|
|
1204
|
+
features: dict[str, bool],
|
|
1205
|
+
level: str,
|
|
1206
|
+
*,
|
|
1207
|
+
mode: str | None = None,
|
|
1208
|
+
ponytail_level: str | None = None,
|
|
1209
|
+
) -> None:
|
|
1210
|
+
"""Save a validated Options draft together in one configuration write."""
|
|
1211
|
+
names = {"say", "read", "auto", "blocks", "waste", "browse"}
|
|
1212
|
+
if set(features) != names or any(not isinstance(v, bool) for v in features.values()):
|
|
1213
|
+
raise ValueError("Expected a boolean switch for each of the six Caveman features.")
|
|
1214
|
+
if level not in CAVEMAN_LEVELS:
|
|
1215
|
+
raise ValueError("Unsupported Caveman intensity.")
|
|
1216
|
+
if mode is not None and mode not in ("off", "caveman", "ponytail"):
|
|
1217
|
+
message = "Unsupported compression mode."
|
|
1218
|
+
raise ValueError(message)
|
|
1219
|
+
if ponytail_level is not None and ponytail_level not in ("lite", "full", "ultra"):
|
|
1220
|
+
message = "Unsupported Ponytail intensity."
|
|
1221
|
+
raise ValueError(message)
|
|
1222
|
+
self._config.update(caveman_features=features, caveman_level=level)
|
|
1223
|
+
if mode is not None:
|
|
1224
|
+
self._config.update(compression_mode=mode, caveman_enabled=mode == "caveman")
|
|
1225
|
+
if mode != "off":
|
|
1226
|
+
self._config["compression_last_mode"] = mode
|
|
1227
|
+
if ponytail_level is not None:
|
|
1228
|
+
self._config["ponytail_level"] = ponytail_level
|
|
1229
|
+
self._save()
|
|
1230
|
+
|
|
1231
|
+
def get(self, key: str, default: Any = None) -> Any:
|
|
1232
|
+
"""Get a configuration value.
|
|
1233
|
+
|
|
1234
|
+
Args:
|
|
1235
|
+
key: Configuration key
|
|
1236
|
+
default: Default value if key doesn't exist
|
|
1237
|
+
|
|
1238
|
+
Returns:
|
|
1239
|
+
Configuration value or default
|
|
1240
|
+
"""
|
|
1241
|
+
return self._config.get(key, default)
|
|
1242
|
+
|
|
1243
|
+
def set(self, key: str, value: Any) -> None:
|
|
1244
|
+
"""Set a configuration value.
|
|
1245
|
+
|
|
1246
|
+
Args:
|
|
1247
|
+
key: Configuration key
|
|
1248
|
+
value: Value to set
|
|
1249
|
+
"""
|
|
1250
|
+
self._config[key] = value
|
|
1251
|
+
self._save()
|
|
1252
|
+
|
|
1253
|
+
def get_agent_team_settings(self) -> dict[str, bool]:
|
|
1254
|
+
"""Read opt-in team gates; swarm requires teams to be enabled."""
|
|
1255
|
+
enabled = _config_bool(self.get("agent_teams_enabled"))
|
|
1256
|
+
return {
|
|
1257
|
+
"enabled": enabled,
|
|
1258
|
+
"swarm": enabled and _config_bool(self.get("swarm_enabled")),
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
def set_agent_team_settings(self, *, enabled: bool, swarm: bool) -> None:
|
|
1262
|
+
"""Save the dependent experimental gates together."""
|
|
1263
|
+
self._config["agent_teams_enabled"] = enabled
|
|
1264
|
+
self._config["swarm_enabled"] = enabled and swarm
|
|
1265
|
+
self._save()
|
|
1266
|
+
|
|
1267
|
+
def delete(self, key: str) -> None:
|
|
1268
|
+
"""Delete a configuration value.
|
|
1269
|
+
|
|
1270
|
+
Args:
|
|
1271
|
+
key: Configuration key to delete
|
|
1272
|
+
"""
|
|
1273
|
+
if key in self._config:
|
|
1274
|
+
del self._config[key]
|
|
1275
|
+
self._save()
|
|
1276
|
+
|
|
1277
|
+
def get_all(self) -> dict[str, Any]:
|
|
1278
|
+
"""Get all configuration values.
|
|
1279
|
+
|
|
1280
|
+
Returns:
|
|
1281
|
+
Copy of all configuration
|
|
1282
|
+
"""
|
|
1283
|
+
return self._config.copy()
|