2025-12-05 02:53:44 +09:00
import { z } from "zod"
2026-01-05 21:12:05 +09:00
import { AnyMcpNameSchema , McpNameSchema } from "../mcp/types"
2025-12-05 02:53:44 +09:00
const PermissionValue = z . enum ( [ "ask" , "allow" , "deny" ] )
const BashPermission = z . union ( [
PermissionValue ,
z . record ( z . string ( ) , PermissionValue ) ,
] )
const AgentPermissionSchema = z . object ( {
edit : PermissionValue.optional ( ) ,
bash : BashPermission.optional ( ) ,
webfetch : PermissionValue.optional ( ) ,
doom_loop : PermissionValue.optional ( ) ,
external_directory : PermissionValue.optional ( ) ,
} )
2025-12-13 22:13:23 +09:00
export const BuiltinAgentNameSchema = z . enum ( [
2025-12-19 04:11:20 +09:00
"Sisyphus" ,
2025-12-05 02:53:44 +09:00
"oracle" ,
"librarian" ,
"explore" ,
"frontend-ui-ux-engineer" ,
"document-writer" ,
2025-12-13 17:47:35 +07:00
"multimodal-looker" ,
2026-01-09 02:24:43 +09:00
"Metis (Plan Consultant)" ,
2026-01-09 03:44:35 +09:00
"Momus (Plan Reviewer)" ,
"orchestrator-sisyphus" ,
2025-12-05 02:53:44 +09:00
] )
2026-01-02 00:01:44 +09:00
export const BuiltinSkillNameSchema = z . enum ( [
"playwright" ,
2026-01-09 02:24:43 +09:00
"frontend-ui-ux" ,
"git-master" ,
2026-01-02 00:01:44 +09:00
] )
2025-12-13 22:13:23 +09:00
export const OverridableAgentNameSchema = z . enum ( [
"build" ,
2025-12-14 21:59:17 +09:00
"plan" ,
2025-12-19 04:11:20 +09:00
"Sisyphus" ,
2026-01-12 19:46:47 +11:00
"Sisyphus-Junior" ,
2025-12-25 21:00:04 +09:00
"OpenCode-Builder" ,
2026-01-09 02:24:43 +09:00
"Prometheus (Planner)" ,
"Metis (Plan Consultant)" ,
2026-01-09 03:44:35 +09:00
"Momus (Plan Reviewer)" ,
2025-12-13 22:13:23 +09:00
"oracle" ,
"librarian" ,
"explore" ,
"frontend-ui-ux-engineer" ,
"document-writer" ,
"multimodal-looker" ,
2026-01-09 03:44:35 +09:00
"orchestrator-sisyphus" ,
2025-12-13 22:13:23 +09:00
] )
export const AgentNameSchema = BuiltinAgentNameSchema
2025-12-13 03:10:39 +00:00
export const HookNameSchema = z . enum ( [
"todo-continuation-enforcer" ,
"context-window-monitor" ,
"session-recovery" ,
2025-12-13 13:02:55 +09:00
"session-notification" ,
2025-12-13 03:10:39 +00:00
"comment-checker" ,
"grep-output-truncator" ,
2025-12-30 22:22:50 +09:00
"tool-output-truncator" ,
2025-12-13 03:10:39 +00:00
"directory-agents-injector" ,
"directory-readme-injector" ,
"empty-task-response-detector" ,
"think-mode" ,
2025-12-30 11:40:02 +09:00
"anthropic-context-window-limit-recovery" ,
2025-12-13 03:10:39 +00:00
"rules-injector" ,
"background-notification" ,
"auto-update-checker" ,
2025-12-14 17:16:52 +09:00
"startup-toast" ,
2025-12-14 10:56:50 +09:00
"keyword-detector" ,
2025-12-13 21:42:05 +09:00
"agent-usage-reminder" ,
2025-12-14 22:34:55 +09:00
"non-interactive-env" ,
2025-12-15 19:02:31 +09:00
"interactive-bash-session" ,
2025-12-16 21:02:38 +09:00
"empty-message-sanitizer" ,
2025-12-26 21:14:11 +07:00
"thinking-block-validator" ,
2025-12-30 17:41:03 +09:00
"ralph-loop" ,
2025-12-31 12:55:39 +09:00
"preemptive-compaction" ,
"compaction-context-injector" ,
"claude-code-hooks" ,
2026-01-01 20:59:36 +09:00
"auto-slash-command" ,
2026-01-02 21:08:45 +09:00
"edit-error-recovery" ,
2026-01-13 23:06:58 +09:00
"sisyphus-task-retry" ,
2026-01-09 02:24:43 +09:00
"prometheus-md-only" ,
"start-work" ,
"sisyphus-orchestrator" ,
2025-12-13 03:10:39 +00:00
] )
2025-12-28 17:30:27 +09:00
export const BuiltinCommandNameSchema = z . enum ( [
"init-deep" ,
2026-01-09 02:24:43 +09:00
"start-work" ,
2025-12-28 17:30:27 +09:00
] )
2025-12-05 02:53:44 +09:00
export const AgentOverrideConfigSchema = z . object ( {
2026-01-09 02:24:43 +09:00
/** @deprecated Use `category` instead. Model is inherited from category defaults. */
2025-12-05 02:53:44 +09:00
model : z.string ( ) . optional ( ) ,
2026-01-10 21:44:20 +00:00
variant : z.string ( ) . optional ( ) ,
2026-01-09 02:24:43 +09:00
/** Category name to inherit model and other settings from CategoryConfig */
category : z.string ( ) . optional ( ) ,
/** Skill names to inject into agent prompt */
skills : z.array ( z . string ( ) ) . optional ( ) ,
2025-12-05 02:53:44 +09:00
temperature : z.number ( ) . min ( 0 ) . max ( 2 ) . optional ( ) ,
top_p : z.number ( ) . min ( 0 ) . max ( 1 ) . optional ( ) ,
prompt : z.string ( ) . optional ( ) ,
2025-12-25 01:49:16 +09:00
prompt_append : z.string ( ) . optional ( ) ,
2025-12-05 02:53:44 +09:00
tools : z.record ( z . string ( ) , z . boolean ( ) ) . optional ( ) ,
disable : z.boolean ( ) . optional ( ) ,
description : z.string ( ) . optional ( ) ,
mode : z.enum ( [ "subagent" , "primary" , "all" ] ) . optional ( ) ,
color : z
. string ( )
. regex ( /^#[0-9A-Fa-f]{6}$/ )
. optional ( ) ,
permission : AgentPermissionSchema.optional ( ) ,
} )
2025-12-14 17:48:41 +09:00
export const AgentOverridesSchema = z . object ( {
build : AgentOverrideConfigSchema.optional ( ) ,
2025-12-14 21:59:17 +09:00
plan : AgentOverrideConfigSchema.optional ( ) ,
2025-12-19 04:11:20 +09:00
Sisyphus : AgentOverrideConfigSchema.optional ( ) ,
2026-01-12 19:46:47 +11:00
"Sisyphus-Junior" : AgentOverrideConfigSchema . optional ( ) ,
2025-12-25 21:00:04 +09:00
"OpenCode-Builder" : AgentOverrideConfigSchema . optional ( ) ,
2026-01-09 02:24:43 +09:00
"Prometheus (Planner)" : AgentOverrideConfigSchema . optional ( ) ,
"Metis (Plan Consultant)" : AgentOverrideConfigSchema . optional ( ) ,
2026-01-09 03:44:35 +09:00
"Momus (Plan Reviewer)" : AgentOverrideConfigSchema . optional ( ) ,
2025-12-14 17:48:41 +09:00
oracle : AgentOverrideConfigSchema.optional ( ) ,
librarian : AgentOverrideConfigSchema.optional ( ) ,
explore : AgentOverrideConfigSchema.optional ( ) ,
"frontend-ui-ux-engineer" : AgentOverrideConfigSchema . optional ( ) ,
"document-writer" : AgentOverrideConfigSchema . optional ( ) ,
"multimodal-looker" : AgentOverrideConfigSchema . optional ( ) ,
2026-01-09 03:44:35 +09:00
"orchestrator-sisyphus" : AgentOverrideConfigSchema . optional ( ) ,
2025-12-14 17:48:41 +09:00
} )
2025-12-05 02:53:44 +09:00
2025-12-12 13:23:50 +07:00
export const ClaudeCodeConfigSchema = z . object ( {
mcp : z.boolean ( ) . optional ( ) ,
commands : z.boolean ( ) . optional ( ) ,
skills : z.boolean ( ) . optional ( ) ,
agents : z.boolean ( ) . optional ( ) ,
hooks : z.boolean ( ) . optional ( ) ,
2025-12-27 17:56:40 +08:00
plugins : z.boolean ( ) . optional ( ) ,
plugins_override : z.record ( z . string ( ) , z . boolean ( ) ) . optional ( ) ,
2025-12-12 13:23:50 +07:00
} )
2025-12-19 04:11:20 +09:00
export const SisyphusAgentConfigSchema = z . object ( {
2025-12-14 21:59:17 +09:00
disabled : z.boolean ( ) . optional ( ) ,
2025-12-26 03:37:50 +09:00
default_builder_enabled : z.boolean ( ) . optional ( ) ,
2025-12-25 17:00:07 +09:00
planner_enabled : z.boolean ( ) . optional ( ) ,
replace_plan : z.boolean ( ) . optional ( ) ,
2025-12-14 17:16:52 +09:00
} )
2026-01-09 02:24:43 +09:00
export const CategoryConfigSchema = z . object ( {
model : z.string ( ) ,
2026-01-10 21:44:20 +00:00
variant : z.string ( ) . optional ( ) ,
2026-01-09 02:24:43 +09:00
temperature : z.number ( ) . min ( 0 ) . max ( 2 ) . optional ( ) ,
top_p : z.number ( ) . min ( 0 ) . max ( 1 ) . optional ( ) ,
maxTokens : z.number ( ) . optional ( ) ,
thinking : z.object ( {
type : z . enum ( [ "enabled" , "disabled" ] ) ,
budgetTokens : z.number ( ) . optional ( ) ,
} ) . optional ( ) ,
reasoningEffort : z.enum ( [ "low" , "medium" , "high" ] ) . optional ( ) ,
textVerbosity : z.enum ( [ "low" , "medium" , "high" ] ) . optional ( ) ,
tools : z.record ( z . string ( ) , z . boolean ( ) ) . optional ( ) ,
prompt_append : z.string ( ) . optional ( ) ,
} )
export const BuiltinCategoryNameSchema = z . enum ( [
"visual-engineering" ,
"ultrabrain" ,
"artistry" ,
"quick" ,
"most-capable" ,
"writing" ,
"general" ,
] )
export const CategoriesConfigSchema = z . record ( z . string ( ) , CategoryConfigSchema )
2025-12-28 14:55:27 +09:00
export const CommentCheckerConfigSchema = z . object ( {
/** Custom prompt to replace the default warning message. Use {{comments}} placeholder for detected comments XML. */
custom_prompt : z.string ( ) . optional ( ) ,
} )
2025-12-27 09:20:42 +00:00
export const DynamicContextPruningConfigSchema = z . object ( {
/** Enable dynamic context pruning (default: false) */
enabled : z.boolean ( ) . default ( false ) ,
/** Notification level: off, minimal, or detailed (default: detailed) */
notification : z.enum ( [ "off" , "minimal" , "detailed" ] ) . default ( "detailed" ) ,
/** Turn protection - prevent pruning recent tool outputs */
turn_protection : z.object ( {
enabled : z.boolean ( ) . default ( true ) ,
turns : z.number ( ) . min ( 1 ) . max ( 10 ) . default ( 3 ) ,
} ) . optional ( ) ,
/** Tools that should never be pruned */
protected_tools : z.array ( z . string ( ) ) . default ( [
"task" , "todowrite" , "todoread" ,
"lsp_rename" , "lsp_code_action_resolve" ,
"session_read" , "session_write" , "session_search" ,
] ) ,
/** Pruning strategies configuration */
strategies : z.object ( {
/** Remove duplicate tool calls (same tool + same args) */
deduplication : z.object ( {
enabled : z.boolean ( ) . default ( true ) ,
} ) . optional ( ) ,
/** Prune write inputs when file subsequently read */
supersede_writes : z.object ( {
enabled : z.boolean ( ) . default ( true ) ,
/** Aggressive mode: prune any write if ANY subsequent read */
aggressive : z.boolean ( ) . default ( false ) ,
} ) . optional ( ) ,
/** Prune errored tool inputs after N turns */
purge_errors : z.object ( {
enabled : z.boolean ( ) . default ( true ) ,
turns : z.number ( ) . min ( 1 ) . max ( 20 ) . default ( 5 ) ,
} ) . optional ( ) ,
} ) . optional ( ) ,
} )
2025-12-19 02:45:59 +09:00
export const ExperimentalConfigSchema = z . object ( {
aggressive_truncation : z.boolean ( ) . optional ( ) ,
auto_resume : z.boolean ( ) . optional ( ) ,
2026-01-02 00:24:41 +09:00
/** Enable preemptive compaction at threshold (default: true since v2.9.0) */
2025-12-20 13:19:32 +09:00
preemptive_compaction : z.boolean ( ) . optional ( ) ,
/** Threshold percentage to trigger preemptive compaction (default: 0.80) */
preemptive_compaction_threshold : z.number ( ) . min ( 0.5 ) . max ( 0.95 ) . optional ( ) ,
2025-12-30 22:22:50 +09:00
/** Truncate all tool outputs, not just whitelisted tools (default: false). Tool output truncator is enabled by default - disable via disabled_hooks. */
2025-12-30 20:42:06 +09:00
truncate_all_tool_outputs : z.boolean ( ) . optional ( ) ,
2025-12-27 09:20:42 +00:00
/** Dynamic context pruning configuration */
dynamic_context_pruning : DynamicContextPruningConfigSchema.optional ( ) ,
2025-12-30 20:27:19 +09:00
/** Enable DCP (Dynamic Context Pruning) for compaction - runs first when token limit exceeded (default: false) */
dcp_for_compaction : z.boolean ( ) . optional ( ) ,
2025-12-19 02:45:59 +09:00
} )
2025-12-30 15:15:43 +09:00
export const SkillSourceSchema = z . union ( [
z . string ( ) ,
z . object ( {
path : z.string ( ) ,
recursive : z.boolean ( ) . optional ( ) ,
glob : z.string ( ) . optional ( ) ,
} ) ,
] )
export const SkillDefinitionSchema = z . object ( {
description : z.string ( ) . optional ( ) ,
template : z.string ( ) . optional ( ) ,
from : z . string ( ) . optional ( ) ,
model : z.string ( ) . optional ( ) ,
agent : z.string ( ) . optional ( ) ,
subtask : z.boolean ( ) . optional ( ) ,
"argument-hint" : z . string ( ) . optional ( ) ,
license : z.string ( ) . optional ( ) ,
compatibility : z.string ( ) . optional ( ) ,
metadata : z.record ( z . string ( ) , z . unknown ( ) ) . optional ( ) ,
"allowed-tools" : z . array ( z . string ( ) ) . optional ( ) ,
disable : z.boolean ( ) . optional ( ) ,
} )
export const SkillEntrySchema = z . union ( [
z . boolean ( ) ,
SkillDefinitionSchema ,
] )
export const SkillsConfigSchema = z . union ( [
z . array ( z . string ( ) ) ,
z . record ( z . string ( ) , SkillEntrySchema ) . and ( z . object ( {
sources : z.array ( SkillSourceSchema ) . optional ( ) ,
enable : z.array ( z . string ( ) ) . optional ( ) ,
disable : z.array ( z . string ( ) ) . optional ( ) ,
} ) . partial ( ) ) ,
] )
2025-12-30 17:41:03 +09:00
export const RalphLoopConfigSchema = z . object ( {
/** Enable ralph loop functionality (default: false - opt-in feature) */
enabled : z.boolean ( ) . default ( false ) ,
/** Default max iterations if not specified in command (default: 100) */
default_max_iterations : z.number ( ) . min ( 1 ) . max ( 1000 ) . default ( 100 ) ,
/** Custom state file directory relative to project root (default: .opencode/) */
state_dir : z.string ( ) . optional ( ) ,
} )
2026-01-07 01:24:47 +09:00
export const BackgroundTaskConfigSchema = z . object ( {
defaultConcurrency : z.number ( ) . min ( 1 ) . optional ( ) ,
providerConcurrency : z.record ( z . string ( ) , z . number ( ) . min ( 1 ) ) . optional ( ) ,
modelConcurrency : z.record ( z . string ( ) , z . number ( ) . min ( 1 ) ) . optional ( ) ,
} )
2026-01-07 11:44:03 -03:00
export const NotificationConfigSchema = z . object ( {
/** Force enable session-notification even if external notification plugins are detected (default: false) */
force_enable : z.boolean ( ) . optional ( ) ,
} )
2026-01-09 02:24:43 +09:00
export const GitMasterConfigSchema = z . object ( {
/** Add "Ultraworked with Sisyphus" footer to commit messages (default: true) */
commit_footer : z.boolean ( ) . default ( true ) ,
/** Add "Co-authored-by: Sisyphus" trailer to commit messages (default: true) */
include_co_authored_by : z.boolean ( ) . default ( true ) ,
} )
2026-01-10 13:00:25 +08:00
2025-12-05 02:53:44 +09:00
export const OhMyOpenCodeConfigSchema = z . object ( {
$schema : z.string ( ) . optional ( ) ,
2026-01-05 21:12:05 +09:00
disabled_mcps : z.array ( AnyMcpNameSchema ) . optional ( ) ,
2025-12-13 22:13:23 +09:00
disabled_agents : z.array ( BuiltinAgentNameSchema ) . optional ( ) ,
2026-01-02 00:01:44 +09:00
disabled_skills : z.array ( BuiltinSkillNameSchema ) . optional ( ) ,
2025-12-13 03:10:39 +00:00
disabled_hooks : z.array ( HookNameSchema ) . optional ( ) ,
2025-12-28 17:30:27 +09:00
disabled_commands : z.array ( BuiltinCommandNameSchema ) . optional ( ) ,
2025-12-05 02:53:44 +09:00
agents : AgentOverridesSchema.optional ( ) ,
2026-01-09 02:24:43 +09:00
categories : CategoriesConfigSchema.optional ( ) ,
2025-12-12 13:23:50 +07:00
claude_code : ClaudeCodeConfigSchema.optional ( ) ,
2025-12-13 12:13:50 +09:00
google_auth : z.boolean ( ) . optional ( ) ,
2025-12-19 04:11:20 +09:00
sisyphus_agent : SisyphusAgentConfigSchema.optional ( ) ,
2025-12-28 14:55:27 +09:00
comment_checker : CommentCheckerConfigSchema.optional ( ) ,
2025-12-19 02:45:59 +09:00
experimental : ExperimentalConfigSchema.optional ( ) ,
2025-12-19 14:05:09 +09:00
auto_update : z.boolean ( ) . optional ( ) ,
2025-12-30 15:15:43 +09:00
skills : SkillsConfigSchema.optional ( ) ,
2025-12-30 17:41:03 +09:00
ralph_loop : RalphLoopConfigSchema.optional ( ) ,
2026-01-07 01:24:47 +09:00
background_task : BackgroundTaskConfigSchema.optional ( ) ,
2026-01-07 11:44:03 -03:00
notification : NotificationConfigSchema.optional ( ) ,
2026-01-09 02:24:43 +09:00
git_master : GitMasterConfigSchema.optional ( ) ,
2025-12-05 02:53:44 +09:00
} )
export type OhMyOpenCodeConfig = z . infer < typeof OhMyOpenCodeConfigSchema >
export type AgentOverrideConfig = z . infer < typeof AgentOverrideConfigSchema >
export type AgentOverrides = z . infer < typeof AgentOverridesSchema >
2026-01-07 01:24:47 +09:00
export type BackgroundTaskConfig = z . infer < typeof BackgroundTaskConfigSchema >
2025-12-05 02:53:44 +09:00
export type AgentName = z . infer < typeof AgentNameSchema >
2025-12-13 03:10:39 +00:00
export type HookName = z . infer < typeof HookNameSchema >
2025-12-28 17:30:27 +09:00
export type BuiltinCommandName = z . infer < typeof BuiltinCommandNameSchema >
2026-01-02 00:01:44 +09:00
export type BuiltinSkillName = z . infer < typeof BuiltinSkillNameSchema >
2025-12-19 04:11:20 +09:00
export type SisyphusAgentConfig = z . infer < typeof SisyphusAgentConfigSchema >
2025-12-28 14:55:27 +09:00
export type CommentCheckerConfig = z . infer < typeof CommentCheckerConfigSchema >
2025-12-19 02:45:59 +09:00
export type ExperimentalConfig = z . infer < typeof ExperimentalConfigSchema >
2025-12-27 09:20:42 +00:00
export type DynamicContextPruningConfig = z . infer < typeof DynamicContextPruningConfigSchema >
2025-12-30 15:15:43 +09:00
export type SkillsConfig = z . infer < typeof SkillsConfigSchema >
export type SkillDefinition = z . infer < typeof SkillDefinitionSchema >
2025-12-30 17:41:03 +09:00
export type RalphLoopConfig = z . infer < typeof RalphLoopConfigSchema >
2026-01-07 11:44:03 -03:00
export type NotificationConfig = z . infer < typeof NotificationConfigSchema >
2026-01-09 02:24:43 +09:00
export type CategoryConfig = z . infer < typeof CategoryConfigSchema >
export type CategoriesConfig = z . infer < typeof CategoriesConfigSchema >
export type BuiltinCategoryName = z . infer < typeof BuiltinCategoryNameSchema >
export type GitMasterConfig = z . infer < typeof GitMasterConfigSchema >
2025-12-05 03:58:21 +09:00
2026-01-05 21:12:05 +09:00
export { AnyMcpNameSchema , type AnyMcpName , McpNameSchema , type McpName } from "../mcp/types"