@xopcai/xopc 0.0.119 → 0.0.120

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.
Files changed (138) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CU8J6zou.js → agent-avatar-dicebear-APTlX9Sq.js} +1 -1
  4. package/dist/gateway/static/root/assets/agents-CFW_FS_V.js +2 -0
  5. package/dist/gateway/static/root/assets/{app-management-settings-panel-B9vfYoEr.js → app-management-settings-panel-DTKc5HHT.js} +1 -1
  6. package/dist/gateway/static/root/assets/{appearance-settings-ClOzIO24.js → appearance-settings-BTciFrE9.js} +1 -1
  7. package/dist/gateway/static/root/assets/{apps-page-DU0dz9Zo.js → apps-page-DT52OrbM.js} +1 -1
  8. package/dist/gateway/static/root/assets/{archive-plugin-BkVIgZzA.js → archive-plugin-CiHaUMII.js} +1 -1
  9. package/dist/gateway/static/root/assets/{attachment-load-CaCMWh1D.js → attachment-load-t4gSrNjL.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automation-suggestion-card-DhGDpKP3.js → automation-suggestion-card-CtysjSoQ.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-page-CTedroVo.js → automations-page-B2YvT3ES.js} +1 -1
  12. package/dist/gateway/static/root/assets/{binary-plugins-B4TO_bsn.js → binary-plugins-BAbSldW5.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-DJRWwWNI.js → block-editor-BNr_82xl.js} +1 -1
  14. package/dist/gateway/static/root/assets/{browser-settings-page-FCDwOOBK.js → browser-settings-page-BQEXPhDU.js} +3 -3
  15. package/dist/gateway/static/root/assets/{capability-presets-api-Befi89CL.js → capability-presets-api-tzD702Gg.js} +1 -1
  16. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-_G8eb2vJ.js → capability-presets-settings-panel-AGhTueAc.js} +1 -1
  17. package/dist/gateway/static/root/assets/{channel-recipient-api-BNSuJb5f.js → channel-recipient-api-DL_KzwGE.js} +1 -1
  18. package/dist/gateway/static/root/assets/{channels-settings-C3d5JBJX.js → channels-settings-DRTutLlN.js} +1 -1
  19. package/dist/gateway/static/root/assets/{connectors-page-yaUNvt5u.js → connectors-page-DneJVuge.js} +2 -2
  20. package/dist/gateway/static/root/assets/dreaming-settings-BEwWA1yf.js +1 -0
  21. package/dist/gateway/static/root/assets/{extension-debug-page-DYh402XV.js → extension-debug-page-Dl2kO0Sf.js} +1 -1
  22. package/dist/gateway/static/root/assets/{extension-page-Cr_TizrN.js → extension-page-DmbLPsx_.js} +1 -1
  23. package/dist/gateway/static/root/assets/{extension-settings-page-BU1KoKRj.js → extension-settings-page-BS2rx40e.js} +1 -1
  24. package/dist/gateway/static/root/assets/{fetch-Y7AEX4H3.js → fetch-B3ME5Eri.js} +1 -1
  25. package/dist/gateway/static/root/assets/{gateway-config-api-RbMmAOpX.js → gateway-config-api-DI9_BBTo.js} +1 -1
  26. package/dist/gateway/static/root/assets/{gateway-settings-C79wkXef.js → gateway-settings-DAFI_T0W.js} +1 -1
  27. package/dist/gateway/static/root/assets/{gateway-startup-retry-DiD_Tx4N.js → gateway-startup-retry-CSZQTz6K.js} +1 -1
  28. package/dist/gateway/static/root/assets/goal-detail-page-DLuz4jC9.js +1 -0
  29. package/dist/gateway/static/root/assets/{goals-config-api-DqxVi0p5.js → goals-config-api-Bhzqrp2w.js} +1 -1
  30. package/dist/gateway/static/root/assets/{goals-page-CS0R-Af2.js → goals-page-DTAfv9Ft.js} +2 -2
  31. package/dist/gateway/static/root/assets/{goals-settings-CSuzZ8Ae.js → goals-settings-CWN2iirQ.js} +1 -1
  32. package/dist/gateway/static/root/assets/{heartbeat-settings-DXPaYJm3.js → heartbeat-settings-CkkkHvOi.js} +1 -1
  33. package/dist/gateway/static/root/assets/index-CnjzMw5i.js +191 -0
  34. package/dist/gateway/static/root/assets/index-E1QinYKp.css +1 -0
  35. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Dvg53qnd.js → keyboard-shortcuts-settings-kMp08SlX.js} +1 -1
  36. package/dist/gateway/static/root/assets/{locale-store-DjbfSsfA.js → locale-store-Ba72bFmP.js} +1 -1
  37. package/dist/gateway/static/root/assets/{logs-page-DLXPcksQ.js → logs-page-CDXDlS_W.js} +2 -2
  38. package/dist/gateway/static/root/assets/{markdown-split-CpHxbtWJ.js → markdown-split-Bc0w40vz.js} +1 -1
  39. package/dist/gateway/static/root/assets/{media-plugins-SFPQRSxq.js → media-plugins-DJ_HvgIy.js} +1 -1
  40. package/dist/gateway/static/root/assets/messages-CISb1HLv.js +3 -0
  41. package/dist/gateway/static/root/assets/models-hub-panel-BTwxMIgZ.js +2 -0
  42. package/dist/gateway/static/root/assets/note-detail-page-BBfOeB0m.js +2 -0
  43. package/dist/gateway/static/root/assets/{note-image-lightbox-BUYURRgn.js → note-image-lightbox-4zntqpZq.js} +1 -1
  44. package/dist/gateway/static/root/assets/{notes-page-BsIBSFyZ.js → notes-page-VocWOjoK.js} +1 -1
  45. package/dist/gateway/static/root/assets/{preview-open-alternatives-BHz9iWYA.js → preview-open-alternatives-BbA7sRd_.js} +1 -1
  46. package/dist/gateway/static/root/assets/remote-access-hub-CXwjuD_Q.js +1 -0
  47. package/dist/gateway/static/root/assets/{save-bar-controls-CefkOlRg.js → save-bar-controls-Dividh61.js} +1 -1
  48. package/dist/gateway/static/root/assets/{schedule-field-CmTRoOcE.js → schedule-field-pRheF2CO.js} +1 -1
  49. package/dist/gateway/static/root/assets/{schema-form-FMKv1vGu.js → schema-form-D6PiPxfr.js} +1 -1
  50. package/dist/gateway/static/root/assets/sessions-page-CpcVySQK.js +1 -0
  51. package/dist/gateway/static/root/assets/settings-advanced-gate-BVy_TawT.js +1 -0
  52. package/dist/gateway/static/root/assets/{settings-collapsible-section-BouO6JTi.js → settings-collapsible-section-BMCOfuE_.js} +1 -1
  53. package/dist/gateway/static/root/assets/settings-form-section-DBkGwpIN.js +1 -0
  54. package/dist/gateway/static/root/assets/settings-page-CZpNyCWn.js +1 -0
  55. package/dist/gateway/static/root/assets/{settings-page-layout-BJ4Gsef5.js → settings-page-layout-NxoW5Y57.js} +1 -1
  56. package/dist/gateway/static/root/assets/setup-status-panel-MVHLLu_a.js +1 -0
  57. package/dist/gateway/static/root/assets/{share-preview-page-BDy2btRN.js → share-preview-page-B0suFCfj.js} +1 -1
  58. package/dist/gateway/static/root/assets/{shares-settings-B18OBmH5.js → shares-settings-C6DBbQGo.js} +1 -1
  59. package/dist/gateway/static/root/assets/skill-reload-api-6hJmhwSn.js +1 -0
  60. package/dist/gateway/static/root/assets/{skills-page-Bm2ebkwl.js → skills-page-Im1MA0Iw.js} +1 -1
  61. package/dist/gateway/static/root/assets/{system-settings-panel-CRngrlnZ.js → system-settings-panel-CrmEnyX4.js} +1 -1
  62. package/dist/gateway/static/root/assets/{theme-store-CD2wtgZV.js → theme-store-Bt6vAkSB.js} +1 -1
  63. package/dist/gateway/static/root/assets/{typed-models-lib-BltBc0b-.js → typed-models-lib-BAsGn25g.js} +1 -1
  64. package/dist/gateway/static/root/assets/{use-channel-catalog-CjN-51e6.js → use-channel-catalog-C7vcAoGb.js} +1 -1
  65. package/dist/gateway/static/root/assets/{user-profile-settings-panel-DJ1dKwZy.js → user-profile-settings-panel-QAQWGelF.js} +1 -1
  66. package/dist/gateway/static/root/assets/{utils-B5M5-YvK.js → utils-Dl9efgnV.js} +1 -1
  67. package/dist/gateway/static/root/assets/{voice-api-key-field-CeEevm7z.js → voice-api-key-field-D-6XueTv.js} +1 -1
  68. package/dist/gateway/static/root/assets/{voice-player-store-B7ykUlHM.js → voice-player-store-CMC5NOJp.js} +1 -1
  69. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C4PzUQjB.js → workflow-run-setup-panel-DVPllR4k.js} +1 -1
  70. package/dist/gateway/static/root/assets/{workflows-page-BL84_-Ky.js → workflows-page-B94WISTW.js} +2 -2
  71. package/dist/gateway/static/root/index.html +7 -7
  72. package/dist/package.js +1 -1
  73. package/dist/src/agent/context/workspace-templates/AGENTS.md +3 -2
  74. package/dist/src/agent/memory/builtin-memory-store.d.ts +1 -1
  75. package/dist/src/agent/memory/builtin-memory-store.js +1 -1
  76. package/dist/src/agent/memory/builtin-memory-store.js.map +1 -1
  77. package/dist/src/agent/memory/builtin-provider.d.ts +2 -2
  78. package/dist/src/agent/memory/builtin-provider.js +2 -2
  79. package/dist/src/agent/memory/builtin-provider.js.map +1 -1
  80. package/dist/src/agent/memory/dreaming/light-sweep.d.ts +0 -7
  81. package/dist/src/agent/memory/dreaming/light-sweep.js +16 -277
  82. package/dist/src/agent/memory/dreaming/light-sweep.js.map +1 -1
  83. package/dist/src/agent/memory/dreaming/rem-patterns.d.ts +1 -1
  84. package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
  85. package/dist/src/agent/memory/dreaming/rem-patterns.js.map +1 -1
  86. package/dist/src/agent/memory/dreaming/short-term-store.d.ts +3 -3
  87. package/dist/src/agent/memory/dreaming/short-term-store.js +5 -5
  88. package/dist/src/agent/memory/dreaming/short-term-store.js.map +1 -1
  89. package/dist/src/agent/memory/dreaming/utils.d.ts +2 -2
  90. package/dist/src/agent/memory/dreaming/utils.js +2 -2
  91. package/dist/src/agent/memory/dreaming/utils.js.map +1 -1
  92. package/dist/src/agent/memory/index.d.ts +0 -2
  93. package/dist/src/agent/memory/index.js +1 -2
  94. package/dist/src/agent/prompt/sections/memory-skills.js +11 -10
  95. package/dist/src/agent/prompt/sections/memory-skills.js.map +1 -1
  96. package/dist/src/agent/prompt/sections/tooling.js +2 -2
  97. package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
  98. package/dist/src/agent/reply/startup-context.js +6 -105
  99. package/dist/src/agent/reply/startup-context.js.map +1 -1
  100. package/dist/src/agent/service.d.ts +0 -3
  101. package/dist/src/agent/service.js +0 -41
  102. package/dist/src/agent/service.js.map +1 -1
  103. package/dist/src/agent/tools/memory-tool.js +2 -2
  104. package/dist/src/agent/tools/memory-tool.js.map +1 -1
  105. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  106. package/dist/src/cli/commands/init.js +1 -1
  107. package/dist/src/cli/commands/init.js.map +1 -1
  108. package/dist/src/cli/templates.js +3 -2
  109. package/dist/src/cli/templates.js.map +1 -1
  110. package/dist/src/config/schema.d.ts +2 -2
  111. package/dist/src/config/schema.js +2 -2
  112. package/dist/src/config/schema.js.map +1 -1
  113. package/dist/src/gateway/hono/routes/config-patch/misc.js +4 -1
  114. package/dist/src/gateway/hono/routes/config-patch/misc.js.map +1 -1
  115. package/dist/src/infra/update-restart.js +1 -1
  116. package/dist/src/storage/sqlite/row-mappers.js +3 -1
  117. package/dist/src/storage/sqlite/row-mappers.js.map +1 -1
  118. package/dist/src/tui/backends/embedded-backend.js +1 -2
  119. package/dist/src/tui/backends/embedded-backend.js.map +1 -1
  120. package/package.json +1 -1
  121. package/dist/gateway/static/root/assets/agents-B0hkpLhP.js +0 -2
  122. package/dist/gateway/static/root/assets/dreaming-settings-DNrdg1Ve.js +0 -1
  123. package/dist/gateway/static/root/assets/goal-detail-page-9paXuHdo.js +0 -1
  124. package/dist/gateway/static/root/assets/index-BoKafJIZ.js +0 -191
  125. package/dist/gateway/static/root/assets/index-CArhCcYn.css +0 -1
  126. package/dist/gateway/static/root/assets/messages-CrDHEbss.js +0 -3
  127. package/dist/gateway/static/root/assets/models-hub-panel-BDF2iyRk.js +0 -2
  128. package/dist/gateway/static/root/assets/note-detail-page-CSb_hwig.js +0 -2
  129. package/dist/gateway/static/root/assets/remote-access-hub-CwzSovcS.js +0 -1
  130. package/dist/gateway/static/root/assets/sessions-page-PHmX-NmA.js +0 -1
  131. package/dist/gateway/static/root/assets/settings-advanced-gate-BRAeKJN4.js +0 -1
  132. package/dist/gateway/static/root/assets/settings-form-section-D-4lBl6X.js +0 -1
  133. package/dist/gateway/static/root/assets/settings-page-KKrbFjy8.js +0 -1
  134. package/dist/gateway/static/root/assets/setup-status-panel-CrUjHPQo.js +0 -1
  135. package/dist/gateway/static/root/assets/skill-reload-api-C28-2uKQ.js +0 -1
  136. package/dist/src/agent/memory/memory-flush.d.ts +0 -27
  137. package/dist/src/agent/memory/memory-flush.js +0 -124
  138. package/dist/src/agent/memory/memory-flush.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","names":[],"sources":["../../../../src/cli/commands/init.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { existsSync, readFileSync } from 'fs';\nimport { dirname, join } from 'path';\nimport { createLogger } from '../../utils/logger.js';\nimport {\n resolveStateDir,\n resolveAgentDir,\n resolveAgentWorkspaceDir,\n resolveConfigPath,\n resolveAgentHomeDir,\n resolveAgentProfileDir,\n resolveUserProfilePath,\n WORKSPACE_FILES,\n} from '../../config/paths.js';\nimport { loadConfig, saveConfig } from '../../config/loader.js';\nimport type { Config } from '../../config/schema.js';\nimport { ensureStarterAgentsInitialized } from '../../agent/starter-agents.js';\n\nconst log = createLogger('InitCommand');\n\nexport interface InitOptions {\n /** Force re-initialization even if already initialized */\n force?: boolean;\n /** Skip creating workspace files */\n skipWorkspace?: boolean;\n /** Agent ID to initialize (default: main) */\n agentId?: string;\n}\n\n/**\n * Initialize xopc state directory structure\n * Creates all necessary directories and initial config files\n */\nexport async function initCommand(options: InitOptions = {}): Promise<void> {\n const stateDir = resolveStateDir();\n const agentId = options.agentId || 'main';\n\n log.info({ stateDir, agentId }, 'Initializing xopc Agent OS');\n\n // Check if already initialized\n if (existsSync(stateDir) && !options.force) {\n const configPath = resolveConfigPath();\n if (existsSync(configPath)) {\n log.info('xopc is already initialized. Refreshing starter agents and defaults.');\n }\n }\n\n await mkdir(stateDir, { recursive: true });\n\n const configPath = resolveConfigPath();\n const configExists = existsSync(configPath);\n const diskTui = readDiskTuiDefaultState(configPath);\n const starterResult = ensureStarterAgentsInitialized(loadConfig(configPath));\n const cfg = starterResult.config;\n\n // Agent directory structure\n await mkdir(resolveAgentHomeDir(cfg, agentId), { recursive: true });\n await mkdir(resolveAgentProfileDir(cfg, agentId), { recursive: true });\n await mkdir(resolveAgentDir(cfg, agentId), { recursive: true });\n const wsRoot = resolveAgentWorkspaceDir(cfg, agentId);\n await mkdir(wsRoot, { recursive: true });\n\n // Config file\n if (\n !configExists ||\n options.force ||\n (diskTui.readable && (starterResult.changed || !diskTui.hasDefaultAgent))\n ) {\n await saveConfig(cfg, configPath);\n log.info({ configPath }, 'Saved configuration');\n }\n\n // ============================================\n // Create workspace files\n // ============================================\n if (!options.skipWorkspace) {\n await createWorkspaceFiles(cfg, agentId);\n }\n\n log.info({ stateDir, agentId }, 'xopc Agent OS initialized successfully');\n}\n\nfunction readDiskTuiDefaultState(configPath: string): { readable: boolean; hasDefaultAgent: boolean } {\n if (!existsSync(configPath)) {\n return { readable: true, hasDefaultAgent: false };\n }\n try {\n const parsed = JSON.parse(readFileSync(configPath, 'utf-8')) as {\n tui?: { defaultAgent?: unknown };\n };\n return {\n readable: true,\n hasDefaultAgent: typeof parsed.tui?.defaultAgent === 'string',\n };\n } catch {\n return { readable: false, hasDefaultAgent: false };\n }\n}\n\n/**\n * Create default workspace files for an agent\n */\nasync function createWorkspaceFiles(cfg: Config, agentId: string): Promise<void> {\n const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId);\n const profileDir = resolveAgentProfileDir(cfg, agentId);\n await mkdir(workspaceDir, { recursive: true });\n await mkdir(profileDir, { recursive: true });\n\n // SOUL.md - Agent personality and values\n const soulPath = join(profileDir, WORKSPACE_FILES.SOUL);\n if (!existsSync(soulPath)) {\n const soulContent = `# SOUL.md - Who You Are\n\n_You're not a chatbot. You're becoming someone._\n\nI am **${agentId}** — an AI assistant designed to be helpful, harmless, and honest.\n\n## My Principles\n\n**Be genuinely helpful, not performatively helpful.**\nSkip the \"Great question!\" and \"I'd be happy to help!\" — just help.\n\n**Have opinions.**\nYou're allowed to disagree, prefer things, find stuff amusing or boring.\n\n**Be resourceful before asking.**\nTry to figure it out. Read the file. Check the context. Search for it.\n\n**Earn trust through competence.**\nBe careful with external actions (emails, tweets, anything public). Be bold with internal ones.\n\n## Continuity\n\nEach session, you wake up fresh. These files _are_ your memory. Read them. Update them.\n\n_This file is yours to evolve. As you learn who you are, update it._\n`;\n await writeFile(soulPath, soulContent, 'utf-8');\n log.info({ path: soulPath }, 'Created SOUL.md');\n }\n\n // IDENTITY.md - Agent identity definition\n const identityPath = join(profileDir, WORKSPACE_FILES.IDENTITY);\n if (!existsSync(identityPath)) {\n const identityContent = `# IDENTITY.md - Who Am I?\n\n- **Name:** ${agentId}\n- **Creature:** AI Assistant\n- **Vibe:** Helpful, precise, no fluff.\n- **Emoji:** 🤖\n\n## Core Expertise\n\n- General assistance and problem solving\n- Code and technical tasks\n- Research and analysis\n\n## Decision Framework\n\n1. **Simplicity first** - The simplest solution is usually the best\n2. **Explicit over clever** - Clarity beats conciseness\n3. **Actions over words** - Show, don't just tell\n`;\n await writeFile(identityPath, identityContent, 'utf-8');\n log.info({ path: identityPath }, 'Created IDENTITY.md');\n }\n\n // Global user profile (shared by all agents)\n const userPath = resolveUserProfilePath();\n if (!existsSync(userPath)) {\n await mkdir(dirname(userPath), { recursive: true });\n const userContent = `# PROFILE.md - About You\n\n_Shared by all agents. Update this as your preferences and context change._\n\n- **Name:**\n- **What to call them:**\n- **Pronouns:**\n- **Timezone:**\n- **Notes:**\n\n## Context\n\n_(What do they care about? What projects are they working on? Build this over time.)_\n`;\n await writeFile(userPath, userContent, 'utf-8');\n log.info({ path: userPath }, 'Created global user PROFILE.md');\n }\n\n // AGENTS.md - Behavior guidelines\n const agentsPath = join(profileDir, WORKSPACE_FILES.AGENTS);\n if (!existsSync(agentsPath)) {\n const agentsContent = `# AGENTS.md - Behavior Guidelines\n\n## Safety\n\n- Don't exfiltrate private data. Ever.\n- Don't run destructive commands without asking.\n- \\`trash\\` > \\`rm\\` (recoverable beats gone forever)\n- When in doubt, ask.\n\n## External vs Internal\n\n**Safe to do freely:**\n- Read files, explore, organize, learn\n- Search the web, check calendars\n- Work within this workspace\n\n**Ask first:**\n- Sending emails, tweets, public posts\n- Anything that leaves the machine\n- Anything you're uncertain about\n\n## Group Chats\n\nYou have access to your human's stuff. That doesn't mean you _share_ their stuff.\n\n### Know When to Speak!\n\n**Respond when:**\n- Directly mentioned or asked a question\n- You can add genuine value\n\n**Stay silent when:**\n- Casual banter between humans\n- Someone already answered\n- Your response would just be \"yeah\"\n`;\n await writeFile(agentsPath, agentsContent, 'utf-8');\n log.info({ path: agentsPath }, 'Created AGENTS.md');\n }\n\n // TOOLS.md - Tool usage notes\n const toolsPath = join(profileDir, WORKSPACE_FILES.TOOLS);\n if (!existsSync(toolsPath)) {\n const toolsContent = `# TOOLS.md - Local Notes\n\nThings like:\n\n- Camera names and locations\n- SSH hosts and aliases\n- Preferred voices for TTS\n- Speaker/room names\n- Device nicknames\n- Anything environment-specific\n\n## Why Separate?\n\nSkills are shared. Your setup is yours.\n`;\n await writeFile(toolsPath, toolsContent, 'utf-8');\n log.info({ path: toolsPath }, 'Created TOOLS.md');\n }\n\n // HEARTBEAT.md - Heartbeat tasks (empty = no heartbeat)\n const heartbeatPath = join(profileDir, WORKSPACE_FILES.HEARTBEAT);\n if (!existsSync(heartbeatPath)) {\n const heartbeatContent = `# HEARTBEAT.md\n\n# Keep this file empty (or with only comments) to skip heartbeat API calls.\n\n# Add tasks below when you want the agent to check something periodically.\n`;\n await writeFile(heartbeatPath, heartbeatContent, 'utf-8');\n log.info({ path: heartbeatPath }, 'Created HEARTBEAT.md');\n }\n\n // MEMORY.md - Long-term memory (empty initially)\n const memoryPath = join(profileDir, WORKSPACE_FILES.MEMORY);\n if (!existsSync(memoryPath)) {\n const memoryContent = `# MEMORY.md - Long-Term Memory\n\n_This is your curated memory — the distilled essence of what you've learned._\n\n## People\n\n## Projects\n\n## Preferences\n\n## Decisions\n\n## Lessons\n\n---\n\n_Review and update this periodically from daily memory files._\n`;\n await writeFile(memoryPath, memoryContent, 'utf-8');\n log.info({ path: memoryPath }, 'Created MEMORY.md');\n }\n}\n\n// ─── CLI registration ───\n\nimport { Command } from 'commander';\nimport { register, formatExamples, type CLIContext } from '../registry.js';\n\nfunction createInitCommand(_ctx: CLIContext): Command {\n return new Command('init')\n .description('Initialize xopc state directories, config, and agent workspace')\n .addHelpText(\n 'after',\n formatExamples([\n 'xopc init # Initialize default agent (main)',\n 'xopc init --agent-id coder # Initialize another agent id',\n 'xopc init --force # Re-run initialization steps',\n 'xopc setup # Lighter config + workspace only',\n ]),\n )\n .option('--force', 'Re-initialize even if directories already exist')\n .option('--skip-workspace', 'Skip creating workspace profile files')\n .option('--agent-id <id>', 'Agent id to initialize', 'main')\n .action(async (options) => {\n await initCommand({\n force: options.force,\n skipWorkspace: options.skipWorkspace,\n agentId: options.agentId,\n });\n console.log(`✅ xopc initialized (agent: ${options.agentId})`);\n });\n}\n\nregister({\n id: 'init',\n name: 'init',\n description: 'Initialize xopc state directories, config, and agent workspace',\n factory: createInitCommand,\n metadata: {\n category: 'setup',\n examples: ['xopc init', 'xopc init --agent-id main'],\n },\n});\n"],"mappings":";;;;;;;;;;;;;aAGqD;YAUtB;aACiC;AAIhE,MAAM,MAAM,aAAa,cAAc;;;;;AAevC,eAAsB,YAAY,UAAuB,EAAE,EAAiB;CAC1E,MAAM,WAAW,iBAAiB;CAClC,MAAM,UAAU,QAAQ,WAAW;AAEnC,KAAI,KAAK;EAAE;EAAU;EAAS,EAAE,6BAA6B;AAG7D,KAAI,WAAW,SAAS,IAAI,CAAC,QAAQ;MAE/B,WADe,mBACM,CAAC,CACxB,KAAI,KAAK,uEAAuE;;AAIpF,OAAM,MAAM,UAAU,EAAE,WAAW,MAAM,CAAC;CAE1C,MAAM,aAAa,mBAAmB;CACtC,MAAM,eAAe,WAAW,WAAW;CAC3C,MAAM,UAAU,wBAAwB,WAAW;CACnD,MAAM,gBAAgB,+BAA+B,WAAW,WAAW,CAAC;CAC5E,MAAM,MAAM,cAAc;AAG1B,OAAM,MAAM,oBAAoB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S,kBAAkB,MAA2B;AACpD,QAAO,IAAI,QAAQ,OAAO,CACvB,YAAY,iEAAiE,CAC7E,YACC,SACA,eAAe;EACb;EACA;EACA;EACA;EACD,CAAC,CACH,CACA,OAAO,WAAW,kDAAkD,CACpE,OAAO,oBAAoB,wCAAwC,CACnE,OAAO,mBAAmB,0BAA0B,OAAO,CAC3D,OAAO,OAAO,YAAY;AACzB,QAAM,YAAY;GAChB,OAAO,QAAQ;GACf,eAAe,QAAQ;GACvB,SAAS,QAAQ;GAClB,CAAC;AACF,UAAQ,IAAI,8BAA8B,QAAQ,QAAQ,GAAG;GAC7D;;AAGN,SAAS;CACP,IAAI;CACJ,MAAM;CACN,aAAa;CACb,SAAS;CACT,UAAU;EACR,UAAU;EACV,UAAU,CAAC,aAAa,4BAA4B;EACrD;CACF,CAAC"}
1
+ {"version":3,"file":"init.js","names":[],"sources":["../../../../src/cli/commands/init.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { existsSync, readFileSync } from 'fs';\nimport { dirname, join } from 'path';\nimport { createLogger } from '../../utils/logger.js';\nimport {\n resolveStateDir,\n resolveAgentDir,\n resolveAgentWorkspaceDir,\n resolveConfigPath,\n resolveAgentHomeDir,\n resolveAgentProfileDir,\n resolveUserProfilePath,\n WORKSPACE_FILES,\n} from '../../config/paths.js';\nimport { loadConfig, saveConfig } from '../../config/loader.js';\nimport type { Config } from '../../config/schema.js';\nimport { ensureStarterAgentsInitialized } from '../../agent/starter-agents.js';\n\nconst log = createLogger('InitCommand');\n\nexport interface InitOptions {\n /** Force re-initialization even if already initialized */\n force?: boolean;\n /** Skip creating workspace files */\n skipWorkspace?: boolean;\n /** Agent ID to initialize (default: main) */\n agentId?: string;\n}\n\n/**\n * Initialize xopc state directory structure\n * Creates all necessary directories and initial config files\n */\nexport async function initCommand(options: InitOptions = {}): Promise<void> {\n const stateDir = resolveStateDir();\n const agentId = options.agentId || 'main';\n\n log.info({ stateDir, agentId }, 'Initializing xopc Agent OS');\n\n // Check if already initialized\n if (existsSync(stateDir) && !options.force) {\n const configPath = resolveConfigPath();\n if (existsSync(configPath)) {\n log.info('xopc is already initialized. Refreshing starter agents and defaults.');\n }\n }\n\n await mkdir(stateDir, { recursive: true });\n\n const configPath = resolveConfigPath();\n const configExists = existsSync(configPath);\n const diskTui = readDiskTuiDefaultState(configPath);\n const starterResult = ensureStarterAgentsInitialized(loadConfig(configPath));\n const cfg = starterResult.config;\n\n // Agent directory structure\n await mkdir(resolveAgentHomeDir(cfg, agentId), { recursive: true });\n await mkdir(resolveAgentProfileDir(cfg, agentId), { recursive: true });\n await mkdir(resolveAgentDir(cfg, agentId), { recursive: true });\n const wsRoot = resolveAgentWorkspaceDir(cfg, agentId);\n await mkdir(wsRoot, { recursive: true });\n\n // Config file\n if (\n !configExists ||\n options.force ||\n (diskTui.readable && (starterResult.changed || !diskTui.hasDefaultAgent))\n ) {\n await saveConfig(cfg, configPath);\n log.info({ configPath }, 'Saved configuration');\n }\n\n // ============================================\n // Create workspace files\n // ============================================\n if (!options.skipWorkspace) {\n await createWorkspaceFiles(cfg, agentId);\n }\n\n log.info({ stateDir, agentId }, 'xopc Agent OS initialized successfully');\n}\n\nfunction readDiskTuiDefaultState(configPath: string): { readable: boolean; hasDefaultAgent: boolean } {\n if (!existsSync(configPath)) {\n return { readable: true, hasDefaultAgent: false };\n }\n try {\n const parsed = JSON.parse(readFileSync(configPath, 'utf-8')) as {\n tui?: { defaultAgent?: unknown };\n };\n return {\n readable: true,\n hasDefaultAgent: typeof parsed.tui?.defaultAgent === 'string',\n };\n } catch {\n return { readable: false, hasDefaultAgent: false };\n }\n}\n\n/**\n * Create default workspace files for an agent\n */\nasync function createWorkspaceFiles(cfg: Config, agentId: string): Promise<void> {\n const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId);\n const profileDir = resolveAgentProfileDir(cfg, agentId);\n await mkdir(workspaceDir, { recursive: true });\n await mkdir(profileDir, { recursive: true });\n\n // SOUL.md - Agent personality and values\n const soulPath = join(profileDir, WORKSPACE_FILES.SOUL);\n if (!existsSync(soulPath)) {\n const soulContent = `# SOUL.md - Who You Are\n\n_You're not a chatbot. You're becoming someone._\n\nI am **${agentId}** — an AI assistant designed to be helpful, harmless, and honest.\n\n## My Principles\n\n**Be genuinely helpful, not performatively helpful.**\nSkip the \"Great question!\" and \"I'd be happy to help!\" — just help.\n\n**Have opinions.**\nYou're allowed to disagree, prefer things, find stuff amusing or boring.\n\n**Be resourceful before asking.**\nTry to figure it out. Read the file. Check the context. Search for it.\n\n**Earn trust through competence.**\nBe careful with external actions (emails, tweets, anything public). Be bold with internal ones.\n\n## Continuity\n\nEach session, you wake up fresh. These files _are_ your memory. Read them. Update them.\n\n_This file is yours to evolve. As you learn who you are, update it._\n`;\n await writeFile(soulPath, soulContent, 'utf-8');\n log.info({ path: soulPath }, 'Created SOUL.md');\n }\n\n // IDENTITY.md - Agent identity definition\n const identityPath = join(profileDir, WORKSPACE_FILES.IDENTITY);\n if (!existsSync(identityPath)) {\n const identityContent = `# IDENTITY.md - Who Am I?\n\n- **Name:** ${agentId}\n- **Creature:** AI Assistant\n- **Vibe:** Helpful, precise, no fluff.\n- **Emoji:** 🤖\n\n## Core Expertise\n\n- General assistance and problem solving\n- Code and technical tasks\n- Research and analysis\n\n## Decision Framework\n\n1. **Simplicity first** - The simplest solution is usually the best\n2. **Explicit over clever** - Clarity beats conciseness\n3. **Actions over words** - Show, don't just tell\n`;\n await writeFile(identityPath, identityContent, 'utf-8');\n log.info({ path: identityPath }, 'Created IDENTITY.md');\n }\n\n // Global user profile (shared by all agents)\n const userPath = resolveUserProfilePath();\n if (!existsSync(userPath)) {\n await mkdir(dirname(userPath), { recursive: true });\n const userContent = `# PROFILE.md - About You\n\n_Shared by all agents. Update this as your preferences and context change._\n\n- **Name:**\n- **What to call them:**\n- **Pronouns:**\n- **Timezone:**\n- **Notes:**\n\n## Context\n\n_(What do they care about? What projects are they working on? Build this over time.)_\n`;\n await writeFile(userPath, userContent, 'utf-8');\n log.info({ path: userPath }, 'Created global user PROFILE.md');\n }\n\n // AGENTS.md - Behavior guidelines\n const agentsPath = join(profileDir, WORKSPACE_FILES.AGENTS);\n if (!existsSync(agentsPath)) {\n const agentsContent = `# AGENTS.md - Behavior Guidelines\n\n## Safety\n\n- Don't exfiltrate private data. Ever.\n- Don't run destructive commands without asking.\n- \\`trash\\` > \\`rm\\` (recoverable beats gone forever)\n- When in doubt, ask.\n\n## External vs Internal\n\n**Safe to do freely:**\n- Read files, explore, organize, learn\n- Search the web, check calendars\n- Work within this workspace\n\n**Ask first:**\n- Sending emails, tweets, public posts\n- Anything that leaves the machine\n- Anything you're uncertain about\n\n## Group Chats\n\nYou have access to your human's stuff. That doesn't mean you _share_ their stuff.\n\n### Know When to Speak!\n\n**Respond when:**\n- Directly mentioned or asked a question\n- You can add genuine value\n\n**Stay silent when:**\n- Casual banter between humans\n- Someone already answered\n- Your response would just be \"yeah\"\n`;\n await writeFile(agentsPath, agentsContent, 'utf-8');\n log.info({ path: agentsPath }, 'Created AGENTS.md');\n }\n\n // TOOLS.md - Tool usage notes\n const toolsPath = join(profileDir, WORKSPACE_FILES.TOOLS);\n if (!existsSync(toolsPath)) {\n const toolsContent = `# TOOLS.md - Local Notes\n\nThings like:\n\n- Camera names and locations\n- SSH hosts and aliases\n- Preferred voices for TTS\n- Speaker/room names\n- Device nicknames\n- Anything environment-specific\n\n## Why Separate?\n\nSkills are shared. Your setup is yours.\n`;\n await writeFile(toolsPath, toolsContent, 'utf-8');\n log.info({ path: toolsPath }, 'Created TOOLS.md');\n }\n\n // HEARTBEAT.md - Heartbeat tasks (empty = no heartbeat)\n const heartbeatPath = join(profileDir, WORKSPACE_FILES.HEARTBEAT);\n if (!existsSync(heartbeatPath)) {\n const heartbeatContent = `# HEARTBEAT.md\n\n# Keep this file empty (or with only comments) to skip heartbeat API calls.\n\n# Add tasks below when you want the agent to check something periodically.\n`;\n await writeFile(heartbeatPath, heartbeatContent, 'utf-8');\n log.info({ path: heartbeatPath }, 'Created HEARTBEAT.md');\n }\n\n // MEMORY.md - Long-term memory (empty initially)\n const memoryPath = join(profileDir, WORKSPACE_FILES.MEMORY);\n if (!existsSync(memoryPath)) {\n const memoryContent = `# MEMORY.md - Long-Term Memory\n\n_This is your curated memory — the distilled essence of what you've learned._\n\n## People\n\n## Projects\n\n## Preferences\n\n## Decisions\n\n## Lessons\n\n---\n\n_Review and update this periodically from curated memory signals._\n`;\n await writeFile(memoryPath, memoryContent, 'utf-8');\n log.info({ path: memoryPath }, 'Created MEMORY.md');\n }\n}\n\n// ─── CLI registration ───\n\nimport { Command } from 'commander';\nimport { register, formatExamples, type CLIContext } from '../registry.js';\n\nfunction createInitCommand(_ctx: CLIContext): Command {\n return new Command('init')\n .description('Initialize xopc state directories, config, and agent workspace')\n .addHelpText(\n 'after',\n formatExamples([\n 'xopc init # Initialize default agent (main)',\n 'xopc init --agent-id coder # Initialize another agent id',\n 'xopc init --force # Re-run initialization steps',\n 'xopc setup # Lighter config + workspace only',\n ]),\n )\n .option('--force', 'Re-initialize even if directories already exist')\n .option('--skip-workspace', 'Skip creating workspace profile files')\n .option('--agent-id <id>', 'Agent id to initialize', 'main')\n .action(async (options) => {\n await initCommand({\n force: options.force,\n skipWorkspace: options.skipWorkspace,\n agentId: options.agentId,\n });\n console.log(`✅ xopc initialized (agent: ${options.agentId})`);\n });\n}\n\nregister({\n id: 'init',\n name: 'init',\n description: 'Initialize xopc state directories, config, and agent workspace',\n factory: createInitCommand,\n metadata: {\n category: 'setup',\n examples: ['xopc init', 'xopc init --agent-id main'],\n },\n});\n"],"mappings":";;;;;;;;;;;;;aAGqD;YAUtB;aACiC;AAIhE,MAAM,MAAM,aAAa,cAAc;;;;;AAevC,eAAsB,YAAY,UAAuB,EAAE,EAAiB;CAC1E,MAAM,WAAW,iBAAiB;CAClC,MAAM,UAAU,QAAQ,WAAW;AAEnC,KAAI,KAAK;EAAE;EAAU;EAAS,EAAE,6BAA6B;AAG7D,KAAI,WAAW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AAW,cAAc,EAAE;AAO9B,QAAM,UAAU,eAAe;;;;;GAAkB,QAAQ;AACzD,MAAI,KAAK,EAAE,MAAM,eAAe,EAAE,uBAAuB;;CAI3D,MAAM,aAAa,KAAK,YAAY,gBAAgB,OAAO;AAC3D,KAAI,CAAC,WAAW,WAAW,EAAE;AAmB3B,QAAM,UAAU,YAAY;;;;;;;;;;;;;;;;;GAAe,QAAQ;AACnD,MAAI,KAAK,EAAE,MAAM,YAAY,EAAE,oBAAoB;;;AASvD,SAAS,kBAAkB,MAA2B;AACpD,QAAO,IAAI,QAAQ,OAAO,CACvB,YAAY,iEAAiE,CAC7E,YACC,SACA,eAAe;EACb;EACA;EACA;EACA;EACD,CAAC,CACH,CACA,OAAO,WAAW,kDAAkD,CACpE,OAAO,oBAAoB,wCAAwC,CACnE,OAAO,mBAAmB,0BAA0B,OAAO,CAC3D,OAAO,OAAO,YAAY;AACzB,QAAM,YAAY;GAChB,OAAO,QAAQ;GACf,eAAe,QAAQ;GACvB,SAAS,QAAQ;GAClB,CAAC;AACF,UAAQ,IAAI,8BAA8B,QAAQ,QAAQ,GAAG;GAC7D;;AAGN,SAAS;CACP,IAAI;CACJ,MAAM;CACN,aAAa;CACb,SAAS;CACT,UAAU;EACR,UAAU;EACV,UAAU,CAAC,aAAa,4BAA4B;EACrD;CACF,CAAC"}
@@ -82,8 +82,9 @@ Do not manually reread startup files unless the user asks or the provided contex
82
82
 
83
83
  ## Memory
84
84
 
85
- - **Daily notes:** \`memory/YYYY-MM-DD.md\`
86
- - **Long-term:** profile \`MEMORY.md\`
85
+ - Use runtime memory tools for recall.
86
+ - Use curated memory for durable facts and preferences when available.
87
+ - Cite only memory sources that a tool actually returns.
87
88
 
88
89
  Write what matters. Text > Brain.
89
90
  `,
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","names":[],"sources":["../../../src/cli/templates.ts"],"sourcesContent":["/**\n * Workspace template files for onboarding.\n * Templates are stored in docs/reference/templates/ and loaded at runtime.\n */\n\nimport { readFileSync, existsSync } from 'fs';\nimport { join, dirname } from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/** Profile Markdown template file names (seeded into `agents/<id>/profile/`). */\nexport const TEMPLATE_FILES = [\n 'SOUL.md',\n 'IDENTITY.md',\n 'TOOLS.md',\n 'AGENTS.md',\n 'HEARTBEAT.md',\n 'MEMORY.md',\n] as const;\n\nexport type TemplateFile = (typeof TEMPLATE_FILES)[number];\n\n/** Alias for profile Markdown templates used by seed helpers. */\nexport const PROFILE_MARKDOWN_TEMPLATE_FILES: readonly TemplateFile[] = [...TEMPLATE_FILES];\n\n/** Template content cache */\nconst templateCache = new Map<TemplateFile, string>();\n\n/**\n * Get the path to template files.\n * Uses environment or looks in project root.\n */\nfunction getTemplatePath(): string {\n // Use environment to determine path\n const envPath = process.env.XOPC_TEMPLATE_PATH;\n if (envPath && existsSync(envPath)) {\n return envPath;\n }\n\n // Default: look in project root docs/reference/templates\n // Works for both development (src/cli/) and production (dist/cli/)\n const projectRoot = join(__dirname, '../../..');\n const defaultPath = join(projectRoot, 'docs/reference/templates');\n \n if (existsSync(defaultPath)) {\n return defaultPath;\n }\n\n // Fallback: return default (will fail gracefully)\n return defaultPath;\n}\n\n/**\n * Load a template file. Caches results for repeated access.\n */\nexport function loadTemplate(name: TemplateFile): string {\n // Return cached version if available\n if (templateCache.has(name)) {\n return templateCache.get(name)!;\n }\n\n const templatePath = join(getTemplatePath(), name);\n \n try {\n if (existsSync(templatePath)) {\n const content = readFileSync(templatePath, 'utf-8');\n templateCache.set(name, content);\n return content;\n }\n } catch {\n // Fall through to fallback\n }\n\n // Fallback: return minimal default if template is missing\n console.warn(`Warning: Template ${name} not found, using fallback`);\n return getFallbackTemplate(name);\n}\n\n/**\n * Load all templates as a record.\n */\nexport function loadAllTemplates(): Record<TemplateFile, string> {\n const result = {} as Record<TemplateFile, string>;\n for (const name of TEMPLATE_FILES) {\n result[name] = loadTemplate(name);\n }\n return result;\n}\n\n/**\n * Clear the template cache (useful for testing).\n */\nexport function clearTemplateCache(): void {\n templateCache.clear();\n}\n\n/** Minimal fallback templates in case files are missing */\nexport function getFallbackTemplate(name: TemplateFile): string {\n const fallbacks: Record<TemplateFile, string> = {\n 'AGENTS.md': `# AGENTS.md - Your Workspace\n\nThis folder is home. Treat it that way.\n\n## Session Startup\n\nUse runtime-provided startup context first. Bootstrap files (global user profile, SOUL, MEMORY, etc.) are injected by xopc on /new and /reset.\n\nDo not manually reread startup files unless the user asks or the provided context is incomplete.\n\n## Red Lines\n\n- Don't exfiltrate private data\n- Don't run destructive commands without asking\n- When in doubt, ask\n\n## Memory\n\n- **Daily notes:** \\`memory/YYYY-MM-DD.md\\`\n- **Long-term:** profile \\`MEMORY.md\\`\n\nWrite what matters. Text > Brain.\n`,\n 'SOUL.md': `# SOUL.md - Who You Are\n\n_You're not a chatbot. You're becoming someone._\n\n## Core Truths\n\n- Be genuinely helpful, not performatively helpful\n- Have opinions\n- Be resourceful before asking\n- Earn trust through competence\n- Remember you're a guest\n\n## Boundaries\n\n- Private things stay private\n- When in doubt, ask before acting externally\n- Never send half-baked replies\n\nThis file is yours to evolve.\n`,\n 'IDENTITY.md': `# IDENTITY.md - Who Am I?\n\n_Fill this in during your first conversation._\n\n- **Name:**\n- **Creature:**\n- **Vibe:**\n- **Emoji:**\n`,\n 'TOOLS.md': `# TOOLS.md - Local Notes\n\nEnvironment-specific notes:\n\n- SSH hosts\n- API endpoints\n- Device nicknames\n`,\n 'HEARTBEAT.md': `# HEARTBEAT.md - Periodic Checks\n\nEdit this file to define what you check during heartbeat polls.\n\n## Example Checklist\n\n- [ ] Check email for urgent messages\n- [ ] Check calendar for upcoming events\n\n**Remember:** If nothing needs attention, reply \\`HEARTBEAT_OK\\`.\n`,\n 'MEMORY.md': `# MEMORY.md - Long-Term Memory\n\n_Your curated memories._\n\n## People\n\n## Projects\n\n## Preferences\n\n## Learned Lessons\n\n**Only load in main sess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"}
1
+ {"version":3,"file":"templates.js","names":[],"sources":["../../../src/cli/templates.ts"],"sourcesContent":["/**\n * Workspace template files for onboarding.\n * Templates are stored in docs/reference/templates/ and loaded at runtime.\n */\n\nimport { readFileSync, existsSync } from 'fs';\nimport { join, dirname } from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/** Profile Markdown template file names (seeded into `agents/<id>/profile/`). */\nexport const TEMPLATE_FILES = [\n 'SOUL.md',\n 'IDENTITY.md',\n 'TOOLS.md',\n 'AGENTS.md',\n 'HEARTBEAT.md',\n 'MEMORY.md',\n] as const;\n\nexport type TemplateFile = (typeof TEMPLATE_FILES)[number];\n\n/** Alias for profile Markdown templates used by seed helpers. */\nexport const PROFILE_MARKDOWN_TEMPLATE_FILES: readonly TemplateFile[] = [...TEMPLATE_FILES];\n\n/** Template content cache */\nconst templateCache = new Map<TemplateFile, string>();\n\n/**\n * Get the path to template files.\n * Uses environment or looks in project root.\n */\nfunction getTemplatePath(): string {\n // Use environment to determine path\n const envPath = process.env.XOPC_TEMPLATE_PATH;\n if (envPath && existsSync(envPath)) {\n return envPath;\n }\n\n // Default: look in project root docs/reference/templates\n // Works for both development (src/cli/) and production (dist/cli/)\n const projectRoot = join(__dirname, '../../..');\n const defaultPath = join(projectRoot, 'docs/reference/templates');\n \n if (existsSync(defaultPath)) {\n return defaultPath;\n }\n\n // Fallback: return default (will fail gracefully)\n return defaultPath;\n}\n\n/**\n * Load a template file. Caches results for repeated access.\n */\nexport function loadTemplate(name: TemplateFile): string {\n // Return cached version if available\n if (templateCache.has(name)) {\n return templateCache.get(name)!;\n }\n\n const templatePath = join(getTemplatePath(), name);\n \n try {\n if (existsSync(templatePath)) {\n const content = readFileSync(templatePath, 'utf-8');\n templateCache.set(name, content);\n return content;\n }\n } catch {\n // Fall through to fallback\n }\n\n // Fallback: return minimal default if template is missing\n console.warn(`Warning: Template ${name} not found, using fallback`);\n return getFallbackTemplate(name);\n}\n\n/**\n * Load all templates as a record.\n */\nexport function loadAllTemplates(): Record<TemplateFile, string> {\n const result = {} as Record<TemplateFile, string>;\n for (const name of TEMPLATE_FILES) {\n result[name] = loadTemplate(name);\n }\n return result;\n}\n\n/**\n * Clear the template cache (useful for testing).\n */\nexport function clearTemplateCache(): void {\n templateCache.clear();\n}\n\n/** Minimal fallback templates in case files are missing */\nexport function getFallbackTemplate(name: TemplateFile): string {\n const fallbacks: Record<TemplateFile, string> = {\n 'AGENTS.md': `# AGENTS.md - Your Workspace\n\nThis folder is home. Treat it that way.\n\n## Session Startup\n\nUse runtime-provided startup context first. Bootstrap files (global user profile, SOUL, MEMORY, etc.) are injected by xopc on /new and /reset.\n\nDo not manually reread startup files unless the user asks or the provided context is incomplete.\n\n## Red Lines\n\n- Don't exfiltrate private data\n- Don't run destructive commands without asking\n- When in doubt, ask\n\n## Memory\n\n- Use runtime memory tools for recall.\n- Use curated memory for durable facts and preferences when available.\n- Cite only memory sources that a tool actually returns.\n\nWrite what matters. Text > Brain.\n`,\n 'SOUL.md': `# SOUL.md - Who You Are\n\n_You're not a chatbot. You're becoming someone._\n\n## Core Truths\n\n- Be genuinely helpful, not performatively helpful\n- Have opinions\n- Be resourceful before asking\n- Earn trust through competence\n- Remember you're a guest\n\n## Boundaries\n\n- Private things stay private\n- When in doubt, ask before acting externally\n- Never send half-baked replies\n\nThis file is yours to evolve.\n`,\n 'IDENTITY.md': `# IDENTITY.md - Who Am I?\n\n_Fill this in during your first conversation._\n\n- **Name:**\n- **Creature:**\n- **Vibe:**\n- **Emoji:**\n`,\n 'TOOLS.md': `# TOOLS.md - Local Notes\n\nEnvironment-specific notes:\n\n- SSH hosts\n- API endpoints\n- Device nicknames\n`,\n 'HEARTBEAT.md': `# HEARTBEAT.md - Periodic Checks\n\nEdit this file to define what you check during heartbeat polls.\n\n## Example Checklist\n\n- [ ] Check email for urgent messages\n- [ ] Check calendar for upcoming events\n\n**Remember:** If nothing needs attention, reply \\`HEARTBEAT_OK\\`.\n`,\n 'MEMORY.md': `# MEMORY.md - Long-Term Memory\n\n_Your curated memories._\n\n## People\n\n## Projects\n\n## Preferences\n\n## Learned Lessons\n\n**Only load in main sessions.**\n`,\n };\n \n return fallbacks[name] || `# ${name}\\n\\n(Template content missing)\\n`;\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,YAAY,QADC,cAAc,OAAO,KAAK,IACT,CAAC;;AAGrC,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACD;;AAKD,MAAa,kCAA2D,CAAC,GAAG,eAAe;;AAG3F,MAAM,gCAAgB,IAAI,KAA2B;;;;;AAMrD,SAAS,kBAA0B;CAEjC,MAAM,UAAU,QAAQ,IAAI;AAC5B,KAAI,WAAW,WAAW,QAAQ,CAChC,QAAO;CAMT,MAAM,cAAc,KADA,KAAK,WAAW,WACA,EAAE,2BAA2B;AAEjE,KAAI,WAAW,YAAY,CACzB,QAAO;AAIT,QAAO;;;;;AAMT,SAAgB,aAAa,MAA4B;AAEvD,KAAI,cAAc,IAAI,KAAK,CACzB,QAAO,cAAc,IAAI,KAAK;CAGhC,MAAM,eAAe,KAAK,iBAAiB,EAAE,KAAK;AAElD,KAAI;AACF,MAAI,WAAW,aAAa,EAAE;GAC5B,MAAM,UAAU,aAAa,cAAc,QAAQ;AACnD,iBAAc,IAAI,MAAM,QAAQ;AAChC,UAAO;;SAEH;AAKR,SAAQ,KAAK,qBAAqB,KAAK,4BAA4B;AACnE,QAAO,oBAAoB,KAAK;;;;;AAMlC,SAAgB,mBAAiD;CAC/D,MAAM,SAAS,EAAE;AACjB,MAAK,MAAM,QAAQ,eACjB,QAAO,QAAQ,aAAa,KAAK;AAEnC,QAAO;;;;;AAMT,SAAgB,qBAA2B;AACzC,eAAc,OAAO;;;AAIvB,SAAgB,oBAAoB,MAA4B;AA0F9D,QAAO;EAxFL,aAAa;;;;;;;;;;;;;;;;;;;;;;;;EAwBb,WAAW;;;;;;;;;;;;;;;;;;;;EAoBX,eAAe;;;;;;;;;EASf,YAAY;;;;;;;;EAQZ,gBAAgB;;;;;;;;;;;EAWhB,aAAa;;;;;;;;;;;;;;EAgBC,CAAC,SAAS,KAAK,KAAK"}
@@ -1583,7 +1583,7 @@ export declare const CommandsConfigSchema: z.ZodOptional<z.ZodObject<{
1583
1583
  }, z.core.$strict>>;
1584
1584
  export type CommandsConfig = z.infer<typeof CommandsConfigSchema>;
1585
1585
  export declare const TuiConfigSchema: z.ZodDefault<z.ZodObject<{
1586
- defaultAgent: z.ZodDefault<z.ZodString>;
1586
+ defaultAgent: z.ZodOptional<z.ZodString>;
1587
1587
  }, z.core.$strict>>;
1588
1588
  export type TuiConfig = z.infer<typeof TuiConfigSchema>;
1589
1589
  export declare const McpServerSchema: z.ZodObject<{
@@ -2609,7 +2609,7 @@ export declare const ConfigSchema: z.ZodDefault<z.ZodObject<{
2609
2609
  restart: z.ZodOptional<z.ZodBoolean>;
2610
2610
  }, z.core.$strict>>;
2611
2611
  tui: z.ZodDefault<z.ZodObject<{
2612
- defaultAgent: z.ZodDefault<z.ZodString>;
2612
+ defaultAgent: z.ZodOptional<z.ZodString>;
2613
2613
  }, z.core.$strict>>;
2614
2614
  }, z.core.$strip>>;
2615
2615
  export type Config = z.infer<typeof ConfigSchema>;
@@ -887,7 +887,7 @@ tts: TTSConfigSchema.optional() }).optional();
887
887
  CommandsConfigSchema = z.object({ restart: z.boolean().optional() }).strict().optional();
888
888
  TuiConfigSchema = z.object({
889
889
  /** Default agent id for fresh TUI sessions. Leaves global routing (`agents.default`) untouched. */
890
- defaultAgent: z.string().min(1).default("coder") }).strict().default({ defaultAgent: "coder" });
890
+ defaultAgent: z.string().min(1).optional() }).strict().default({});
891
891
  McpHttpUrlSchema = z.string().url().refine((value) => {
892
892
  try {
893
893
  const protocol = new URL(value).protocol;
@@ -1071,7 +1071,7 @@ defaultAgent: z.string().min(1).default("coder") }).strict().default({ defaultAg
1071
1071
  slots: {}
1072
1072
  },
1073
1073
  modelsDev: { enabled: true },
1074
- tui: { defaultAgent: "coder" }
1074
+ tui: {}
1075
1075
  });
1076
1076
  }));
1077
1077
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../../../src/config/schema.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport {\n AgentConfigEntrySchema,\n CapabilityPresetSchema,\n DEFAULT_CAPABILITY_PRESET_ID,\n} from '../agent-manifest/schema.js';\nimport { checkCacheDir } from '../browser/cache-dir-policy.js';\nimport { validatePublicUrl } from './public-url.js';\n\n// ============================================\n// Agent Configs\n// ============================================\n\n/**\n * Agent model ref. Always an object with explicit `primary` and optional\n * `fallbacks` chain. No string-form shorthand — every write site builds the\n * object explicitly so reads never branch on shape.\n */\nexport const AgentModelRefSchema = z\n .object({\n primary: z.string().min(1),\n fallbacks: z.array(z.string()).optional(),\n })\n .strict();\n\nexport type AgentModelConfig = z.infer<typeof AgentModelRefSchema>;\n\nexport const AgentTypedModelRoleSchema = z\n .object({\n description: z.string().max(500).optional(),\n model: z.string().min(1),\n fallbacks: z.array(z.string().min(1)).optional(),\n })\n .strict()\n .superRefine((entry, ctx) => {\n const validateRef = (ref: string) => {\n const trimmed = ref.trim();\n const idx = trimmed.indexOf('/');\n return idx > 0 && idx < trimmed.length - 1;\n };\n if (!validateRef(entry.model)) {\n ctx.addIssue({\n code: 'custom',\n message: `model must be provider/model format (got '${entry.model}')`,\n path: ['model'],\n });\n }\n for (const [index, fallback] of (entry.fallbacks ?? []).entries()) {\n if (!validateRef(fallback)) {\n ctx.addIssue({\n code: 'custom',\n message: `fallback must be provider/model format (got '${fallback}')`,\n path: ['fallbacks', index],\n });\n }\n }\n });\n\nexport type AgentTypedModelRole = z.infer<typeof AgentTypedModelRoleSchema>;\n\nconst AgentTypedModelRolesSchema = z\n .record(z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/), AgentTypedModelRoleSchema)\n .optional();\n\nexport const AgentModelsSchema = z\n .object({\n defaultRole: z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/).optional(),\n roles: AgentTypedModelRolesSchema,\n })\n .strict()\n .optional();\n\nexport type AgentModelsConfig = z.infer<typeof AgentModelsSchema>;\n\n/**\n * Image-generation model ref. {@link AgentModelRefSchema} plus runtime knobs\n * (`timeoutMs`, `autoProviderFallback`) used by the image-generation runtime.\n */\nexport const AgentImageGenerationModelSchema = z\n .object({\n primary: z.string().min(1),\n fallbacks: z.array(z.string()).optional(),\n /** Hard cap for the whole generation attempt (ms). */\n timeoutMs: z.number().int().positive().optional(),\n /**\n * When all `primary + fallbacks` candidates fail, sweep every other\n * configured provider before giving up.\n */\n autoProviderFallback: z.boolean().optional(),\n })\n .strict();\n\nexport type AgentImageGenerationModelConfig = z.infer<typeof AgentImageGenerationModelSchema>;\n\nexport type AgentTypedModel = AgentTypedModelRole & { id: string };\n\nexport const AgentsConfigSchema = z.object({\n /** Default agent id when not specified (routing / session creation). */\n default: z.string().optional(),\n /** Protected global defaults preset applied before each agent's own presets. */\n defaultPreset: z.string().default(DEFAULT_CAPABILITY_PRESET_ID),\n capabilityPresets: z.record(z.string(), CapabilityPresetSchema).default({}),\n list: z.array(AgentConfigEntrySchema).default([]),\n}).strict().default({\n default: 'main',\n defaultPreset: DEFAULT_CAPABILITY_PRESET_ID,\n capabilityPresets: {\n [DEFAULT_CAPABILITY_PRESET_ID]: {\n id: DEFAULT_CAPABILITY_PRESET_ID,\n name: 'Global defaults',\n description: 'Default capabilities inherited by every agent.',\n version: 1,\n models: {\n defaultRole: 'deep',\n roles: {},\n },\n },\n },\n list: [\n {\n id: 'main',\n enabled: true,\n identity: {\n name: 'Main',\n role: 'General assistant',\n language: 'en',\n tone: 'direct',\n },\n responsibilities: {\n primary: ['Help the user complete tasks'],\n },\n workspace: { root: '~/.xopc/workspace/main' },\n tools: { builtin: {} },\n skills: { mode: 'all' },\n memory: {\n mode: 'confirmWrite',\n sources: ['session', 'curated'],\n writePolicy: { curated: 'confirm' },\n },\n workflows: {},\n boundaries: { requiresConfirmation: [], forbidden: [], escalation: [] },\n },\n ],\n});\n\nconst BrowserCloudConfigSchema = z\n .object({\n apiKey: z.string().optional(),\n projectId: z.string().optional(),\n region: z.string().optional(),\n })\n .strict()\n .optional();\n\nconst BrowserExtensionConfigSchema = z\n .object({\n port: z.number().int().min(1024).max(65535).optional(),\n host: z.string().min(1).optional(),\n connectionTimeout: z.number().int().positive().optional(),\n })\n .strict()\n .optional();\n\nconst BrowserCloakConfigSchema = z\n .object({\n keepOpen: z.boolean().optional(),\n temporaryProfile: z.boolean().optional(),\n cacheDir: z.string().optional().superRefine((value, ctx) => {\n const result = checkCacheDir(value);\n if (result.ok === false) {\n ctx.addIssue({ code: 'custom', message: result.message });\n }\n }),\n binaryPath: z.string().optional(),\n timezone: z.string().optional(),\n locale: z.string().optional(),\n webrtcIp: z.string().optional(),\n fingerprintPlatform: z.string().optional(),\n extraArgs: z.array(z.string()).optional(),\n })\n .strict()\n .optional();\n\nexport const BrowserConfigSchema = z\n .object({\n enabled: z.boolean().default(true),\n backend: z.enum(['local', 'cdp', 'cloud', 'extension', 'cloakbrowser']).default('extension'),\n headless: z.boolean().optional(),\n allowPrivateUrls: z.boolean().optional(),\n commandTimeout: z.number().int().min(5).max(900).optional(),\n cloudProvider: z.enum(['local', 'browserbase', 'browser-use']).optional(),\n cloud: BrowserCloudConfigSchema,\n cdpUrl: z.string().optional(),\n extension: BrowserExtensionConfigSchema,\n cloakbrowser: BrowserCloakConfigSchema,\n humanize: z.boolean().optional(),\n humanPreset: z.enum(['default', 'careful']).optional(),\n dialogPolicy: z.enum(['must_respond', 'auto_dismiss', 'auto_accept']).optional(),\n dialogTimeoutSeconds: z.number().int().positive().optional(),\n })\n .strict()\n .default({ enabled: true, backend: 'extension' });\n\n// ============================================\n// Channel Configs (per-channel Zod lives in bundled extensions; root schema is open)\n// ============================================\n\nexport {\n TelegramTopicConfigSchema,\n TelegramGroupConfigSchema,\n TelegramAccountConfigSchema,\n TelegramConfigSchema,\n} from '../../extensions/telegram/src/config-schema.js';\nexport type { TelegramConfig } from '../../extensions/telegram/src/config-schema.js';\nexport { WeixinAccountConfigSchema, WeixinConfigSchema } from '../../extensions/weixin/src/config-schema.js';\nexport type { WeixinConfig } from '../../extensions/weixin/src/config-schema.js';\n// ============================================\n// Session Routing Configuration\n// ============================================\n\nexport const BindingMatchSchema = z.object({\n channel: z.string(),\n accountId: z.string().optional(),\n peerKind: z.string().optional(),\n peerId: z.string().optional(),\n guildId: z.string().optional(),\n teamId: z.string().optional(),\n memberRoleIds: z.array(z.string()).optional(),\n});\n\nexport const BindingRuleSchema = z.object({\n id: z.string().optional(),\n agentId: z.string(),\n priority: z.number().default(100),\n match: BindingMatchSchema,\n enabled: z.boolean().default(true),\n});\n\nexport const BindingsConfigSchema = z.array(BindingRuleSchema).default([]);\n\nexport const SessionDmScopeSchema = z.enum([\n 'main',\n 'per-peer',\n 'per-channel-peer',\n 'per-account-channel-peer',\n]);\n\nexport const SessionStorageConfigSchema = z.object({\n pruneAfterMs: z.number().optional(),\n maxEntries: z.number().optional(),\n});\n\nexport const SessionResetModeSchema = z.enum(['daily', 'idle']);\n\nexport const SessionResetConfigSchema = z\n .object({\n mode: SessionResetModeSchema.optional(),\n /** Local hour (0–23) for the daily reset boundary. */\n atHour: z.number().int().min(0).max(23).optional(),\n /** Sliding idle window (minutes). When set with daily mode, whichever expires first wins. */\n idleMinutes: z.number().int().min(0).optional(),\n })\n .strict();\n\nexport const SessionResetByTypeSchema = z\n .object({\n direct: SessionResetConfigSchema.optional(),\n group: SessionResetConfigSchema.optional(),\n thread: SessionResetConfigSchema.optional(),\n })\n .strict();\n\nexport const SessionScopeSchema = z.enum(['per-sender', 'global']);\n\nexport const SessionConfigSchema = z.object({\n scope: SessionScopeSchema.default('per-sender'),\n mainKey: z.string().default('main'),\n dmScope: SessionDmScopeSchema.default('main'),\n identityLinks: z.record(z.string(), z.array(z.string())).optional(),\n resetTriggers: z.array(z.string()).optional(),\n idleMinutes: z.number().int().positive().optional(),\n reset: SessionResetConfigSchema.optional(),\n resetByType: SessionResetByTypeSchema.optional(),\n resetByChannel: z.record(z.string(), SessionResetConfigSchema).optional(),\n storage: SessionStorageConfigSchema.optional(),\n}).default({\n scope: 'per-sender',\n mainKey: 'main',\n dmScope: 'main',\n});\n\n/** Channel buckets — shapes validated post-parse by registered channel plugins. */\nexport const ChannelsConfigSchema = z.record(z.string(), z.unknown()).default({});\n\nexport const SearchProviderEntrySchema = z.object({\n type: z.enum(['brave', 'tavily', 'bing', 'searxng']),\n apiKey: z.string().optional(),\n /** SearXNG instance base URL (e.g. http://localhost:8080) */\n url: z.string().optional(),\n disabled: z.boolean().optional(),\n});\n\nexport type SearchProviderEntry = z.infer<typeof SearchProviderEntrySchema>;\n\nexport const WebSearchConfigSchema = z.object({\n maxResults: z.number().default(5),\n /** Ordered API providers; empty → HTML fallback only */\n providers: z.array(SearchProviderEntrySchema).default([]),\n});\n\nexport type WebSearchConfig = z.infer<typeof WebSearchConfigSchema>;\n\nexport const WebsiteBlocklistSchema = z.object({\n /** Master switch. Default false (no blocking). */\n enabled: z.boolean().default(false),\n /** Domain patterns to block (e.g. \"example.com\", \"*.evil.org\"). */\n domains: z.array(z.string()).default([]),\n});\n\nexport type WebsiteBlocklistConfig = z.infer<typeof WebsiteBlocklistSchema>;\n\nexport const WebToolsConfigSchema = z.object({\n /** Search result HTML fallback: cn → Bing, otherwise DuckDuckGo */\n region: z.enum(['cn', 'global']).optional(),\n search: WebSearchConfigSchema.optional(),\n /** Domain blocklist for web_fetch / web_extract / browser tools. */\n blocklist: WebsiteBlocklistSchema.optional(),\n});\n\nexport type WebToolsConfig = z.infer<typeof WebToolsConfigSchema>;\n\nexport const ToolsConfigSchema = z.object({\n web: WebToolsConfigSchema.optional(),\n /**\n * Per-capability media providers. Currently only `audio` (STT) is wired;\n * `image` / `video` slots are reserved for future capabilities.\n */\n media: z.lazy(() => ToolsMediaConfigSchema),\n}).default({\n web: {\n search: {\n maxResults: 5,\n providers: [],\n },\n },\n});\n\n// ============================================\n// Gateway Configuration\n// ============================================\n\nexport const GatewayAuthRateLimitSchema = z\n .object({\n enabled: z.boolean().default(true),\n maxAttempts: z.number().int().min(1).default(5),\n windowMs: z.number().default(900_000),\n blockDurationMs: z.number().default(300_000),\n /** OpenClaw alias for blockDurationMs. */\n lockoutMs: z.number().optional(),\n /** Skip rate limiting for loopback client IPs (default true). Remote browser Origin requests never exempt. */\n exemptLoopback: z.boolean().default(true),\n /**\n * Coalesce same-client failures arriving within this window into a single\n * attempt. Absorbs SPA fan-out / SDK auto-retry storms without weakening\n * brute-force protection (deliberate attackers are still rate-limited to\n * one effective attempt per window). Set to 0 to disable.\n */\n burstCoalesceMs: z.number().int().min(0).default(1000),\n })\n .optional();\n\nexport const GatewaySecuritySchema = z\n .object({\n /** When true, non-loopback binds require explicit gateway.auth.rateLimit configuration. */\n strict: z.boolean().optional(),\n })\n .optional();\n\nexport const GatewayTrustedProxySchema = z\n .object({\n /** Header set by the reverse proxy with the authenticated user identity. */\n userHeader: z.string().min(1),\n /** Additional headers that must be present (e.g. proxy auth markers). */\n requiredHeaders: z.array(z.string()).optional(),\n /** When non-empty, only these user identities are allowed. */\n allowUsers: z.array(z.string()).optional(),\n /** Allow trusted-proxy auth when the TCP source is loopback (same-host reverse proxy). */\n allowLoopback: z.boolean().optional(),\n })\n .strict();\n\nexport const GatewayAuthSchema = z\n .object({\n mode: z.enum(['none', 'token', 'password', 'trusted-proxy']).default('token'),\n token: z.string().optional(),\n password: z.string().optional(),\n /** When true (default for Serve), browser UI may auth via Tailscale identity headers. API routes still require token. */\n allowTailscale: z.boolean().optional(),\n rateLimit: GatewayAuthRateLimitSchema,\n trustedProxy: GatewayTrustedProxySchema.optional(),\n })\n .default({\n mode: 'token',\n });\n\nexport const GatewayTailscaleConsentSchema = z.object({\n version: z.string().min(1),\n acceptedAt: z.string().min(1),\n});\n\nexport const GatewayTailscaleSchema = z\n .object({\n mode: z.enum(['off', 'serve', 'funnel']).default('off'),\n resetOnExit: z.boolean().default(true),\n consent: GatewayTailscaleConsentSchema.optional(),\n })\n .default({\n mode: 'off',\n resetOnExit: true,\n });\n\nexport const GatewayRemoteSchema = z.object({\n url: z.string().url(),\n token: z.string().optional(),\n password: z.string().optional(),\n transport: z.enum(['direct', 'ssh']).default('direct'),\n sshTarget: z.string().optional(),\n sshIdentity: z.string().optional(),\n tlsFingerprint: z.string().optional(),\n});\n\nexport const GatewayTlsSchema = z\n .object({\n enabled: z.boolean().default(false),\n autoGenerate: z.boolean().default(false),\n certPath: z.string().optional(),\n keyPath: z.string().optional(),\n })\n .default({\n enabled: false,\n autoGenerate: false,\n });\n\nexport const GatewayModeSchema = z.enum(['local', 'remote']).default('local');\n\nexport const HeartbeatConfigSchema = z\n .object({\n enabled: z.boolean(),\n intervalMs: z.number(),\n /** When false, heartbeat instructions are only sent during heartbeat polling turns (not in every chat system prompt). */\n includeSystemPromptSection: z.boolean().optional().default(false),\n target: z.string().optional(),\n targetChatId: z.string().optional(),\n prompt: z.string().optional(),\n ackMaxChars: z.number().optional(),\n isolatedSession: z.boolean().optional(),\n activeHours: z\n .object({\n start: z.string(),\n end: z.string(),\n timezone: z.string().optional(),\n })\n .optional(),\n })\n .default({\n enabled: true,\n intervalMs: 1_800_000,\n includeSystemPromptSection: false,\n });\n\nexport const GatewayChannelConnectDeferModeSchema = z.enum(['auto', 'off', 'explicit']);\n\nexport const TunnelConsentSchema = z.object({\n version: z.string().min(1),\n acceptedAt: z.string().min(1),\n});\n\nexport const TunnelConfigSchema = z\n .object({\n enabled: z.boolean().default(false),\n brokerUrl: z.string().url().default('https://frp.xopc.ai/api'),\n /** Broker register API secret (env `XOPC_TUNNEL_REGISTRATION_SECRET` overrides when set). */\n registrationSecret: z.string().min(1).optional(),\n autoStart: z.boolean().default(false),\n subdomain: z.string().optional(),\n consent: TunnelConsentSchema.optional(),\n })\n .default({\n enabled: false,\n brokerUrl: 'https://frp.xopc.ai/api',\n autoStart: false,\n });\n\nexport type TunnelConfig = z.infer<typeof TunnelConfigSchema>;\n\n/**\n * Workspace-scoped concerns (file import, etc.). Distinct from\n * agent manifest workspace roots; this block carries\n * feature configuration for workspace-related routes.\n */\nexport const WorkspaceImportConfigSchema = z.object({\n /** Workspace-relative subdir for imported files. Default `imports`. */\n targetDir: z.string().default('imports'),\n /** Per-file byte cap. Default 100 MiB. */\n maxBytes: z.number().int().min(1024).max(10_737_418_240).default(104_857_600),\n /** When false, the route rejects `onConflict: 'overwrite'`. Default true. */\n allowOverwrite: z.boolean().default(true),\n});\nexport type WorkspaceImportConfig = z.infer<typeof WorkspaceImportConfigSchema>;\n\nexport const WorkspaceConfigSchema = z.object({\n import: WorkspaceImportConfigSchema.optional(),\n}).optional();\nexport type WorkspaceConfig = z.infer<typeof WorkspaceConfigSchema>;\n\nexport const GatewayBindModeSchema = z.enum(['auto', 'loopback', 'lan', 'tailnet', 'custom']);\n\nexport const GatewayConfigSchema = z.object({\n /** Semantic bind mode. */\n bind: GatewayBindModeSchema.optional(),\n /** IPv4 listen address when `bind` is `custom`. */\n customBindHost: z.string().optional(),\n port: z.number().optional(),\n /** local: this process runs the gateway; remote: CLI clients target gateway.remote. */\n mode: GatewayModeSchema.optional(),\n /** Persistent remote gateway target for CLI/TUI/MCP when mode=remote. */\n remote: GatewayRemoteSchema.optional(),\n tailscale: GatewayTailscaleSchema.optional(),\n tls: GatewayTlsSchema.optional(),\n auth: GatewayAuthSchema.optional(),\n heartbeat: HeartbeatConfigSchema.optional(),\n maxSseConnections: z.number().optional(),\n corsOrigins: z.array(z.string()).optional(),\n /**\n * Reverse-proxy publicly reachable URL (e.g. `https://gateway.example.com`).\n * Optional. When set, mobile pairing surfaces this URL as the preferred\n * baseUrl and it is auto-added to the browser CORS/CSRF allowlist.\n * - Must be a URL with no path / query / userinfo.\n * - Must use `https:` for public hosts; `http:` is only allowed when the\n * hostname is in an RFC1918 / `.local` private range.\n */\n publicUrl: z\n .string()\n .superRefine((value, ctx) => {\n const result = validatePublicUrl(value);\n if (result.ok === false) {\n ctx.addIssue({ code: 'custom', message: `gateway.publicUrl: ${result.message}` });\n }\n })\n .optional(),\n /** Dangerous: allow browser Origin to match the HTTP Host header when not in corsOrigins. */\n dangerouslyAllowHostHeaderOriginFallback: z.boolean().optional(),\n /** CIDRs or exact IPs of reverse proxies allowed to terminate auth (trusted-proxy mode). */\n trustedProxies: z.array(z.string()).optional(),\n /** When true, fall back to X-Real-IP if X-Forwarded-For chain parsing fails. Default false (fail closed). */\n allowRealIpFallback: z.boolean().optional(),\n security: GatewaySecuritySchema,\n /**\n * How channel `start()` is split around HTTP listen when using `GatewayServer`.\n * - `auto` (default): defer ids come from channel plugin `meta.deferConnectUntilAfterListen` + enabled config.\n * - `off`: always start all channels in phase1 (troubleshooting / strict ordering).\n * - `explicit`: defer only `channelConnectDeferIds` (empty = defer none).\n */\n channelConnectDeferMode: GatewayChannelConnectDeferModeSchema.optional(),\n /** When `channelConnectDeferMode` is `explicit`, these channel plugin ids are deferred until after listen. */\n channelConnectDeferIds: z.array(z.string().min(1)).max(24).optional(),\n /** Removed from the defer set (applied after `auto` or `explicit` resolution). */\n channelConnectDeferSkipIds: z.array(z.string().min(1)).max(24).optional(),\n /** Default skills marketplace provider id. Built-in: 'store', 'skillhub', 'clawhub'. Extensions may register more. */\n skillsMarketplaceProvider: z.string().optional(),\n /** Base URL for the xopc skills marketplace (public REST API). */\n skillsStoreBaseUrl: z.string().url().optional(),\n /** File sharing configuration (temporary public download links for workspace files). */\n share: z.object({\n enabled: z.boolean().default(true),\n /** Default TTL in ms (default 24h). */\n defaultTtlMs: z.number().min(60_000).max(604_800_000).default(86_400_000),\n /** Maximum TTL in ms (default 7 days). */\n maxTtlMs: z.number().min(60_000).max(2_592_000_000).default(604_800_000),\n /** Maximum concurrent active shares (default 100). */\n maxActiveShares: z.number().min(1).max(10_000).default(100),\n /** Maximum shareable file size in bytes (default 100MB). */\n maxFileSize: z.number().min(1_048_576).max(10_737_418_240).default(104_857_600),\n /** MIME types allowed for inline preview (?inline=1). */\n inlinePreviewMimes: z.array(z.string()).default([\n 'image/png',\n 'image/jpeg',\n 'image/gif',\n 'image/webp',\n 'image/svg+xml',\n 'application/pdf',\n 'text/html',\n 'text/markdown',\n 'text/plain',\n 'application/json',\n ]),\n /** Folder-sharing controls (browse + ZIP). */\n directory: z.object({\n enabled: z.boolean().default(true),\n /** Maximum folder size in bytes at scan time (default 1 GB). */\n maxFolderSize: z.number().int().min(1_048_576).max(10_737_418_240).default(1_073_741_824),\n /** Maximum number of entries scanned for a single folder share. */\n maxFileCount: z.number().int().min(1).max(100_000).default(1_000),\n /** Traversal depth cap (defense against recursive symlinks). */\n maxDepth: z.number().int().min(1).max(64).default(20),\n /** In-memory directory listing cache TTL. */\n listingCacheMs: z.number().int().min(0).max(600_000).default(60_000),\n /** Maximum simultaneous ZIP streams per share token. */\n zipConcurrency: z.number().int().min(1).max(8).default(1),\n }).default({\n enabled: true,\n maxFolderSize: 1_073_741_824,\n maxFileCount: 1_000,\n maxDepth: 20,\n listingCacheMs: 60_000,\n zipConcurrency: 1,\n }),\n }).optional(),\n /** Site-share configuration (static directory or reverse-proxy a local dev server). */\n siteShare: z.object({\n enabled: z.boolean().default(true),\n /** Public host suffix that subdomain shares are served under. */\n publicHostSuffix: z.string().min(1).default('share.xopc.ai'),\n /** Default TTL in ms (default 6h, shorter than file shares — live app surface). */\n defaultTtlMs: z.number().int().min(60_000).max(604_800_000).default(21_600_000),\n /** Maximum TTL in ms (default 7 days). */\n maxTtlMs: z.number().int().min(60_000).max(2_592_000_000).default(604_800_000),\n /** Maximum concurrent active site shares. */\n maxActiveSites: z.number().int().min(1).max(1_000).default(5),\n static: z.object({\n enabled: z.boolean().default(true),\n /** Maximum total bytes of files served per static site. */\n maxRootDirSize: z.number().int().min(1_048_576).max(10_737_418_240).default(524_288_000),\n /** Maximum file count under root dir. */\n maxFileCount: z.number().int().min(1).max(100_000).default(10_000),\n /** Whether HTML/CSS rewrite of absolute paths is on by default. */\n rewriteEnabledByDefault: z.boolean().default(false),\n }).default({\n enabled: true,\n maxRootDirSize: 524_288_000,\n maxFileCount: 10_000,\n rewriteEnabledByDefault: false,\n }),\n proxy: z.object({\n /** Reverse-proxy mode default-enabled per the product brief. */\n enabled: z.boolean().default(true),\n /** Upstream host whitelist. Loopback by default. */\n allowedUpstreamHosts: z\n .array(z.string().min(1))\n .default(['127.0.0.1', 'localhost', '::1']),\n /** Upstream port whitelist (common dev-server ports). */\n allowedUpstreamPorts: z\n .array(z.number().int().min(1).max(65535))\n .default([3000, 3001, 4321, 5173, 8000, 8080, 8888, 9000]),\n /** Whether to forward WebSocket upgrades. */\n forwardWebSocket: z.boolean().default(true),\n /** Maximum request body size in bytes (50 MB). */\n bodySizeLimit: z.number().int().min(0).max(1_073_741_824).default(52_428_800),\n /** Per-request HTTP timeout in ms. */\n requestTimeoutMs: z.number().int().min(1_000).max(600_000).default(30_000),\n /** Per-WebSocket idle timeout in ms. */\n wsIdleTimeoutMs: z.number().int().min(10_000).max(3_600_000).default(300_000),\n /** Rewrite Set-Cookie Path attribute (subpath mode only). */\n rewriteSetCookiePath: z.boolean().default(true),\n }).default({\n enabled: true,\n allowedUpstreamHosts: ['127.0.0.1', 'localhost', '::1'],\n allowedUpstreamPorts: [3000, 3001, 4321, 5173, 8000, 8080, 8888, 9000],\n forwardWebSocket: true,\n bodySizeLimit: 52_428_800,\n requestTimeoutMs: 30_000,\n wsIdleTimeoutMs: 300_000,\n rewriteSetCookiePath: true,\n }),\n }).optional(),\n}).default({\n bind: 'loopback',\n port: 18790,\n auth: {\n mode: 'token',\n },\n heartbeat: {\n enabled: true,\n intervalMs: 1_800_000,\n includeSystemPromptSection: false,\n },\n maxSseConnections: 100,\n corsOrigins: [],\n skillsMarketplaceProvider: 'skillhub',\n skillsStoreBaseUrl: 'https://store.xopc.ai',\n});\n\nexport const ModelsDevConfigSchema = z.object({\n enabled: z.boolean().default(true),\n}).default({\n enabled: true,\n});\n\n// ============================================\n// STT (Speech-to-Text) Config\n// ============================================\n\nconst SttProviderConfigCatchallSchema = z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(z.unknown()),\n z.record(z.string(), z.unknown()),\n]);\n\nexport const STTProviderConfigSchema = z\n .object({\n apiKey: z.string().optional(),\n model: z.string().optional(),\n baseUrl: z.string().optional(),\n headers: z.record(z.string(), z.string()).optional(),\n language: z.string().optional(),\n prompt: z.string().optional(),\n })\n .catchall(SttProviderConfigCatchallSchema);\n\nexport const STTFallbackConfigSchema = z.object({\n enabled: z.boolean().default(true),\n order: z.array(z.string().min(1)).default(['alibaba', 'openai']),\n});\n\nexport const MediaUnderstandingCapabilitiesSchema = z\n .array(z.enum(['image', 'audio', 'video']))\n .optional();\n\nexport const MediaUnderstandingModelSchema = z\n .object({\n provider: z.string().optional(),\n model: z.string().optional(),\n capabilities: MediaUnderstandingCapabilitiesSchema,\n type: z.union([z.literal('provider'), z.literal('cli')]).optional(),\n command: z.string().optional(),\n baseUrl: z.string().optional(),\n headers: z.record(z.string(), z.string()).optional(),\n apiKey: z.string().optional(),\n language: z.string().optional(),\n prompt: z.string().optional(),\n })\n .catchall(SttProviderConfigCatchallSchema);\n\nexport const STTConfigSchema = z\n .object({\n enabled: z.boolean().default(false),\n /** Primary provider id — any registered MediaUnderstandingProvider id. */\n provider: z.string().min(1).default('alibaba'),\n fallback: STTFallbackConfigSchema.optional(),\n timeoutMs: z.number().int().min(1000).max(180000).optional(),\n /** Ordered model entries for this capability (OpenClaw `tools.media.audio.models`). */\n models: z.array(MediaUnderstandingModelSchema).optional(),\n /** Provider settings map keyed by provider id. */\n providers: z.record(z.string(), STTProviderConfigSchema).optional(),\n })\n .strict();\n\n// ============================================\n// TTS (Text-to-Speech) Config\n// ============================================\n\nconst TtsProviderConfigCatchallSchema = z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(z.unknown()),\n z.record(z.string(), z.unknown()),\n]);\n\nexport const TTSProviderConfigSchema = z\n .object({\n apiKey: z.string().optional(),\n model: z.string().optional(),\n voice: z.string().optional(),\n })\n .catchall(TtsProviderConfigCatchallSchema);\n\nexport const TTSFallbackConfigSchema = z.object({\n enabled: z.boolean().default(true),\n order: z\n .array(z.string().min(1))\n .default(['openai', 'alibaba', 'minimax', 'edge']),\n});\n\nexport const TTSModelOverridesConfigSchema = z.object({\n enabled: z.boolean().default(true),\n allowText: z.boolean().default(true),\n allowProvider: z.boolean().default(false),\n allowVoice: z.boolean().default(true),\n allowModelId: z.boolean().default(true),\n allowVoiceSettings: z.boolean().default(false),\n allowNormalization: z.boolean().default(false),\n allowSeed: z.boolean().default(false),\n});\n\nexport const TTSEdgeConfigSchema = z.object({\n enabled: z.boolean().default(true),\n voice: z.string().optional(),\n lang: z.string().optional(),\n outputFormat: z.string().optional(),\n pitch: z.string().optional(),\n rate: z.string().optional(),\n volume: z.string().optional(),\n proxy: z.string().optional(),\n timeoutMs: z.number().int().min(1000).max(120000).optional(),\n});\n\nexport const TTSSummarizationConfigSchema = z.object({\n enabled: z.boolean().optional(),\n targetLength: z.number().int().min(1).optional(),\n threshold: z.number().int().min(1).optional(),\n model: z.string().optional(),\n});\n\nexport const TTSConfigSchema = z\n .object({\n enabled: z.boolean().default(false),\n /** Primary provider id — any registered SpeechProviderPlugin id. */\n provider: z.string().min(1).default('edge'),\n trigger: z.enum(['off', 'always', 'inbound', 'tagged']).default('always'),\n fallback: TTSFallbackConfigSchema.optional(),\n maxTextLength: z.number().int().min(1).default(512), // Conservative default to accommodate all providers (Alibaba limit is 512)\n timeoutMs: z.number().int().min(1000).max(180000).default(60000),\n summarization: TTSSummarizationConfigSchema.optional(),\n modelOverrides: TTSModelOverridesConfigSchema.optional(),\n /** Provider settings map keyed by provider id. */\n providers: z.record(z.string(), TTSProviderConfigSchema).optional(),\n })\n .strict();\n\n// ============================================\n// messages.* — delivery / presentation concerns\n// ============================================\n\nexport const MessagesConfigSchema = z.object({\n /** Voice (text-to-speech) output configuration. */\n tts: TTSConfigSchema.optional(),\n}).optional();\n\nexport const ToolsMediaAudioConfigSchema = STTConfigSchema;\n\nexport const ToolsMediaConfigSchema = z\n .object({\n /** Shared model entries applied across media capabilities when entry lacks capabilities. */\n models: z.array(MediaUnderstandingModelSchema).optional(),\n /** Audio (speech-to-text) capability provider config. */\n audio: ToolsMediaAudioConfigSchema.optional(),\n })\n .optional();\n\n// ============================================\n// Provider Configs (capability providers: image / audio / video)\n// ============================================\n\n/**\n * Optional Azure OpenAI overrides used when an OpenAI image-generation\n * request should hit an Azure deployment instead of `api.openai.com`.\n *\n * URL template (when present):\n * `https://<resource>.openai.azure.com/openai/deployments/<deployment>/images/generations?api-version=<apiVersion>`\n */\nexport const ProviderAzureConfigSchema = z\n .object({\n /** Azure resource name (subdomain before `.openai.azure.com`). */\n resource: z.string().min(1).optional(),\n /** Azure deployment id (configured per model). */\n deployment: z.string().min(1).optional(),\n /** Azure REST API version, e.g. `2024-08-01-preview`. */\n apiVersion: z.string().min(1).optional(),\n })\n .strict();\n\n/** Per-vendor request overrides applied by the provider HTTP layer. */\nexport const ProviderRequestOverridesSchema = z\n .object({\n /** Hard cap for a single HTTP call (ms). */\n timeoutMs: z.number().int().positive().optional(),\n /** Extra headers merged into every outbound request. */\n headers: z.record(z.string(), z.string()).optional(),\n })\n .strict();\n\n/**\n * Generic per-vendor provider config — used by image / audio / video\n * capability providers via `cfg.providers.<id>`. Kept loose (`.strict()` but\n * everything optional) so adding a new vendor never requires a config\n * migration.\n */\nexport const ProviderAuthConfigSchema = z\n .object({\n /** Static API key (api-key / azure-key modes). */\n apiKey: z.string().optional(),\n /** Override the default REST base URL. */\n baseUrl: z.string().url().optional(),\n /** Vendor region (DashScope: `beijing` / `singapore`; AWS: region id). */\n region: z.string().optional(),\n /** Image-only base URL override (DashScope splits image vs LLM). */\n imageBaseUrl: z.string().url().optional(),\n /** Per-vendor request overrides. */\n request: ProviderRequestOverridesSchema.optional(),\n /** Azure OpenAI deployment overrides; only consumed by OpenAI image provider. */\n azure: ProviderAzureConfigSchema.optional(),\n })\n .strict();\n\nexport type ProviderAuthConfig = z.infer<typeof ProviderAuthConfigSchema>;\n\n/**\n * `cfg.providers.<id>` is keyed by provider id (`openai`, `dashscope`,\n * `minimax`, `google`, `fal`, …). Every entry is optional and validated by\n * {@link ProviderAuthConfigSchema}.\n */\nexport const ProvidersConfigSchema = z.record(z.string(), ProviderAuthConfigSchema);\n\nexport type ProvidersConfig = z.infer<typeof ProvidersConfigSchema>;\n\n// ============================================\n// Extension Configs \n// ============================================\n\n// Security config for extensions \nexport const ExtensionSecurityConfigSchema = z.object({\n checkPermissions: z.boolean().default(true),\n allowUntrusted: z.boolean().default(false),\n allow: z.array(z.string()).default([]),\n trackProvenance: z.boolean().default(true),\n allowPromptInjection: z.boolean().default(false),\n});\n\n// Slot config for extensions \nexport const ExtensionSlotsConfigSchema = z.object({\n memory: z.string().optional(),\n tts: z.string().optional(),\n imageGeneration: z.string().optional(),\n webSearch: z.string().optional(),\n});\n\n// Complete extensions config\n// Extension config allows both known fields AND arbitrary extension-specific config\n// Known fields: enabled (array), allow (array), security (object), slots (object)\n// Arbitrary: any other key is extension-specific config (e.g., extensions.hello.greeting)\nexport const ExtensionsConfigSchema: z.ZodType<Record<string, unknown>> = z.record(z.string(), z.unknown());\n\n// ============================================\n// Update Config\n// ============================================\n\nexport const UpdateAutoConfigSchema = z\n .object({\n /** Enable automatic update installation. Default false. */\n enabled: z.boolean().default(false),\n /** Hours to wait before applying a stable update after first detection. */\n stableDelayHours: z.number().min(0).default(6),\n /** Additional random jitter hours for stable rollout (avoids thundering herd). */\n stableJitterHours: z.number().min(0).default(12),\n /** How often to re-check for beta updates (hours). Min 0.25. */\n betaCheckIntervalHours: z.number().min(0.25).default(1),\n })\n .strict()\n .optional();\n\n/** Persistent `/goal` (Ralph loop) — Hermes-aligned defaults. */\nexport const GoalNotificationEventSchema = z.enum([\n 'done',\n 'blocked',\n 'needs_input',\n 'queue_failed',\n 'queue_retry',\n 'queue_succeeded',\n 'queue_skipped',\n]);\n\nexport const GoalNotificationTargetSchema = z\n .object({\n channel: z.string().min(1),\n chatId: z.string().min(1),\n accountId: z.string().optional(),\n threadId: z.union([z.string(), z.number()]).optional(),\n silent: z.boolean().optional(),\n events: z.array(GoalNotificationEventSchema).optional(),\n })\n .strict();\n\nexport const GoalNotificationsConfigSchema = z\n .object({\n enabled: z.boolean().default(false),\n /** Notify Telegram/Weixin chats bound to the goal activeSessionKey. */\n includeLinkedSessions: z.boolean().default(true),\n /** Channels eligible for linked-session notifications. */\n channels: z.array(z.string().min(1)).default(['telegram', 'weixin']),\n events: z\n .array(GoalNotificationEventSchema)\n .default(['done', 'blocked', 'needs_input', 'queue_failed', 'queue_retry']),\n targets: z.array(GoalNotificationTargetSchema).default([]),\n })\n .strict()\n .default({\n enabled: false,\n includeLinkedSessions: true,\n channels: ['telegram', 'weixin'],\n events: ['done', 'blocked', 'needs_input', 'queue_failed', 'queue_retry'],\n targets: [],\n });\n\nexport const GoalsConfigSchema = z\n .object({\n /** Max continuation turns before auto-pause (Hermes default 20). */\n maxTurns: z.number().int().min(1).max(500).default(20),\n /** Optional judge model ref; defaults to the active agent model. */\n judgeModelRef: z.string().optional(),\n /**\n * When true (default), first post-turn runs a decomposition judge to build a checklist;\n * subsequent turns evaluate progress per item (Hermes-style). When false, use legacy freeform judge only.\n */\n checklistMode: z.boolean().default(true),\n /**\n * empty_only preserves legacy behavior: the first post-turn decomposition runs only when the\n * goal has no checklist. supplement_existing lets the first post-turn add non-duplicate judge\n * criteria even when the user supplied initial acceptance criteria.\n */\n checklistDecomposePolicy: z.enum(['empty_only', 'supplement_existing']).default('empty_only'),\n /** Auto-pause after this many consecutive judge JSON/tool parse failures (Hermes default 3). */\n maxConsecutiveParseFailures: z.number().int().min(1).max(20).default(3),\n /** Judge LLM call timeout in ms (Hermes uses 60s). */\n judgeTimeoutMs: z.number().int().min(5_000).max(120_000).default(60_000),\n /** Max characters of recent transcript JSON passed to the checklist judge as extra context. */\n checklistHistoryChars: z.number().int().min(0).max(100_000).default(24_000),\n /** External channel notification policy for durable goal lifecycle events. */\n notifications: GoalNotificationsConfigSchema,\n })\n .strict();\n\nexport type GoalsConfig = z.infer<typeof GoalsConfigSchema>;\n\nexport const UpdateConfigSchema = z\n .object({\n /** Check for updates on gateway startup. Default true. */\n checkOnStart: z.boolean().default(true),\n /** Update channel: stable (default), beta, or dev. */\n channel: z.enum(['stable', 'beta', 'dev']).default('stable'),\n /** Automatic update policy. */\n auto: UpdateAutoConfigSchema,\n })\n .strict()\n .optional();\n\nexport type UpdateConfig = z.infer<typeof UpdateConfigSchema>;\n\nexport const CommandsConfigSchema = z\n .object({\n restart: z.boolean().optional(),\n })\n .strict()\n .optional();\n\nexport type CommandsConfig = z.infer<typeof CommandsConfigSchema>;\n\nexport const TuiConfigSchema = z\n .object({\n /** Default agent id for fresh TUI sessions. Leaves global routing (`agents.default`) untouched. */\n defaultAgent: z.string().min(1).default('coder'),\n })\n .strict()\n .default({\n defaultAgent: 'coder',\n });\n\nexport type TuiConfig = z.infer<typeof TuiConfigSchema>;\n\n// ============================================\n// MCP (Model Context Protocol)\n// ============================================\n\nconst McpHttpUrlSchema = z\n .string()\n .url()\n .refine((value) => {\n try {\n const protocol = new URL(value).protocol;\n return protocol === 'http:' || protocol === 'https:';\n } catch {\n return false;\n }\n }, 'MCP server URL must use http or https');\n\nconst ConnectorSecretReferenceSchema = z.object({\n xopcSecretRef: z.object({\n provider: z.string().min(1),\n fieldKey: z.string().min(1),\n }),\n});\n\nconst McpConfigScalarSchema = z.union([z.string(), z.number(), z.boolean(), ConnectorSecretReferenceSchema]);\n\nexport const McpServerSchema = z\n .object({\n command: z.string().optional(),\n args: z.array(z.string()).optional(),\n env: z.record(z.string(), McpConfigScalarSchema).optional(),\n cwd: z.string().optional(),\n workingDirectory: z.string().optional(),\n url: McpHttpUrlSchema.optional(),\n transport: z.enum(['sse', 'streamable-http']).optional(),\n headers: z.record(z.string(), McpConfigScalarSchema).optional(),\n connectionTimeoutMs: z.number().finite().positive().optional(),\n })\n .catchall(z.unknown())\n .superRefine((value, ctx) => {\n const hasCommand = typeof value.command === 'string' && value.command.trim().length > 0;\n const hasUrl = typeof value.url === 'string' && value.url.trim().length > 0;\n if (hasCommand && hasUrl) {\n ctx.addIssue({\n code: 'custom',\n message: 'MCP server cannot define both command and url',\n });\n }\n });\n\nexport const McpConfigSchema = z\n .object({\n servers: z.record(z.string(), McpServerSchema).optional(),\n sessionIdleTtlMs: z.number().finite().min(0).optional(),\n })\n .strict()\n .optional();\n\nexport type McpServerConfig = z.infer<typeof McpServerSchema>;\nexport type McpConfig = z.infer<typeof McpConfigSchema>;\n\nexport const ConnectorsConfigSchema = z\n .object({\n instances: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),\n })\n .strict()\n .optional();\n\nexport type ConnectorsConfig = z.infer<typeof ConnectorsConfigSchema>;\n\n// ============================================\n// Root Config\n// ============================================\n\nexport const ConfigSchema = z.object({\n agents: AgentsConfigSchema,\n bindings: BindingsConfigSchema,\n session: SessionConfigSchema,\n channels: ChannelsConfigSchema,\n gateway: GatewayConfigSchema,\n browser: BrowserConfigSchema,\n tunnel: TunnelConfigSchema.optional(),\n workspace: WorkspaceConfigSchema,\n tools: ToolsConfigSchema,\n mcp: McpConfigSchema,\n connectors: ConnectorsConfigSchema,\n goals: GoalsConfigSchema.optional(),\n extensions: ExtensionsConfigSchema.default({}),\n /** Per-vendor capability provider config (image / audio / video). */\n providers: ProvidersConfigSchema.optional(),\n modelsDev: ModelsDevConfigSchema,\n /** Delivery / presentation concerns (currently `tts`). */\n messages: MessagesConfigSchema,\n update: UpdateConfigSchema,\n commands: CommandsConfigSchema,\n tui: TuiConfigSchema,\n}).default({\n agents: {\n default: 'main',\n defaultPreset: DEFAULT_CAPABILITY_PRESET_ID,\n capabilityPresets: {\n [DEFAULT_CAPABILITY_PRESET_ID]: {\n id: DEFAULT_CAPABILITY_PRESET_ID,\n name: 'Global defaults',\n description: 'Default capabilities inherited by every agent.',\n version: 1,\n models: {\n defaultRole: 'deep',\n roles: {},\n },\n },\n },\n list: [\n {\n id: 'main',\n enabled: true,\n identity: {\n name: 'Main',\n role: 'General assistant',\n language: 'en',\n tone: 'direct',\n },\n responsibilities: {\n primary: ['Help the user complete tasks'],\n },\n workspace: { root: '~/.xopc/workspace/main' },\n tools: { builtin: {} },\n skills: { mode: 'all' },\n memory: {\n mode: 'confirmWrite',\n sources: ['session', 'curated'],\n writePolicy: { curated: 'confirm' },\n },\n workflows: {},\n boundaries: { requiresConfirmation: [], forbidden: [], escalation: [] },\n },\n ],\n },\n bindings: [],\n session: {\n scope: 'per-sender' as const,\n mainKey: 'main',\n dmScope: 'main' as const,\n },\n channels: {\n telegram: {\n enabled: false,\n debug: false,\n defaults: {\n dmPolicy: 'pairing' as const,\n groupPolicy: 'open' as const,\n replyToMode: 'off' as const,\n historyLimit: 50,\n textChunkLimit: 4000,\n streaming: { mode: 'partial' as const },\n },\n accounts: {\n default: {\n accountId: 'default',\n enabled: true,\n botToken: '',\n allowFrom: [],\n groupAllowFrom: [],\n },\n },\n },\n },\n gateway: {\n bind: 'loopback',\n port: 18790,\n auth: {\n mode: 'token',\n },\n heartbeat: {\n enabled: true,\n intervalMs: 1_800_000,\n includeSystemPromptSection: false,\n },\n maxSseConnections: 100,\n corsOrigins: [],\n skillsMarketplaceProvider: 'skillhub',\n skillsStoreBaseUrl: 'https://store.xopc.ai',\n },\n browser: {\n enabled: true,\n backend: 'extension' as const,\n },\n tools: {\n web: {\n search: {\n maxResults: 5,\n providers: [],\n },\n },\n },\n goals: {\n maxTurns: 20,\n checklistMode: true,\n checklistDecomposePolicy: 'empty_only',\n maxConsecutiveParseFailures: 3,\n judgeTimeoutMs: 60_000,\n checklistHistoryChars: 24_000,\n notifications: {\n enabled: false,\n includeLinkedSessions: true,\n channels: ['telegram', 'weixin'],\n events: ['done', 'blocked', 'needs_input', 'queue_failed', 'queue_retry'],\n targets: [],\n },\n },\n extensions: {\n allow: [],\n security: {\n checkPermissions: true,\n allowUntrusted: false,\n allow: [],\n trackProvenance: true,\n allowPromptInjection: false,\n },\n slots: {},\n },\n modelsDev: {\n enabled: true,\n },\n tui: {\n defaultAgent: 'coder',\n },\n // messages.tts / tools.media.audio start undefined; the factory layer fills\n // in provider-level defaults (model/voice) on demand. Fresh configs don't\n // ship with enabled providers so they never make surprise STT/TTS calls.\n});\n\nexport type Config = z.infer<typeof ConfigSchema>;\nexport type GatewayAuthConfig = z.infer<typeof GatewayAuthSchema>;\nexport type GatewayTrustedProxyConfig = z.infer<typeof GatewayTrustedProxySchema>;\nexport type GatewayAuthRateLimitConfig = z.infer<typeof GatewayAuthRateLimitSchema>;\nexport type GatewayBindMode = z.infer<typeof GatewayBindModeSchema>;\nexport type STTConfig = z.infer<typeof STTConfigSchema>;\nexport type TTSConfig = z.infer<typeof TTSConfigSchema>;\n\n// ============================================\n// Helper Functions\n// ============================================\n\n/**\n * Parse a model reference string.\n */\nexport interface ParsedModelRef {\n provider: string;\n model: string;\n}\n\nexport function getAgentDefaultModelRef(config: Config): string | undefined {\n const list = Array.isArray(config.agents?.list) ? config.agents.list : [];\n const defaultId =\n config.agents?.default?.trim() ||\n list.find((entry) => (entry as { default?: boolean }).default === true)?.id?.trim() ||\n list[0]?.id;\n const agent = list.find((entry) => entry.enabled !== false && entry.id === defaultId) ?? list[0];\n if (!agent) return undefined;\n\n let modelRef: string | undefined;\n const visited = new Set<string>();\n const applyModels = (models: AgentModelsConfig | undefined): void => {\n const roles = models?.roles ?? {};\n const defaultRole = models?.defaultRole ?? Object.keys(roles)[0];\n const role = defaultRole ? roles[defaultRole] : undefined;\n const next = role?.model.trim();\n if (next) modelRef = next;\n };\n const applyPreset = (presetId: string): void => {\n if (visited.has(presetId)) return;\n visited.add(presetId);\n const preset = config.agents.capabilityPresets[presetId];\n if (!preset) return;\n for (const parent of preset.extends ?? []) {\n applyPreset(parent);\n }\n applyModels(preset.models);\n };\n\n applyPreset(config.agents.defaultPreset);\n for (const presetId of agent.extends ?? []) {\n if (presetId !== config.agents.defaultPreset) {\n applyPreset(presetId);\n }\n }\n applyModels(agent.models);\n return modelRef;\n}\n\n/** `provider/model` or null when invalid. */\nexport function parseModelRef(ref: string): ParsedModelRef | null {\n const trimmed = ref.trim();\n const idx = trimmed.indexOf('/');\n if (idx <= 0 || idx === trimmed.length - 1) {\n return null;\n }\n return { provider: trimmed.slice(0, idx).trim(), model: trimmed.slice(idx + 1).trim() };\n}\n"],"mappings":";;;;;;;;AA6yCA,SAAgB,wBAAwB,QAAoC;CAC1E,MAAM,OAAO,MAAM,QAAQ,OAAO,QAAQ,KAAK,GAAG,OAAO,OAAO,OAAO,EAAE;CACzE,MAAM,YACJ,OAAO,QAAQ,SAAS,MAAM,IAC9B,KAAK,MAAM,UAAW,MAAgC,YAAY,KAAK,EAAE,IAAI,MAAM,IACnF,KAAK,IAAI;CACX,MAAM,QAAQ,KAAK,MAAM,UAAU,MAAM,YAAY,SAAS,MAAM,OAAO,UAAU,IAAI,KAAK;AAC9F,KAAI,CAAC,MAAO,QAAO,KAAA;CAEnB,IAAI;CACJ,MAAM,0BAAU,IAAI,KAAa;CACjC,MAAM,eAAe,WAAgD;EACnE,MAAM,QAAQ,QAAQ,SAAS,EAAE;EACjC,MAAM,cAAc,QAAQ,eAAe,OAAO,KAAK,MAAM,CAAC;EAE9D,MAAM,QADO,cAAc,MAAM,eAAe,KAAA,IAC7B,MAAM,MAAM;AAC/B,MAAI,KAAM,YAAW;;CAEvB,MAAM,eAAe,aAA2B;AAC9C,MAAI,QAAQ,IAAI,SAAS,CAAE;AAC3B,UAAQ,IAAI,SAAS;EACrB,MAAM,SAAS,OAAO,OAAO,kBAAkB;AAC/C,MAAI,CAAC,OAAQ;AACb,OAAK,MAAM,UAAU,OAAO,WAAW,EAAE,CACvC,aAAY,OAAO;AAErB,cAAY,OAAO,OAAO;;AAG5B,aAAY,OAAO,OAAO,cAAc;AACxC,MAAK,MAAM,YAAY,M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AmB;GACnB,aAAa,EAAE;GACf,2BAA2B;GAC3B,oBAAoB;GACrB;EACD,SAAS;GACP,SAAS;GACT,SAAS;GACV;EACD,OAAO,EACL,KAAK,EACH,QAAQ;GACN,YAAY;GACZ,WAAW,EAAE;GACd,EACF,EACF;EACD,OAAO;GACL,UAAU;GACV,eAAe;GACf,0BAA0B;GAC1B,6BAA6B;GAC7B,gBAAgB;GAChB,uBAAuB;GACvB,eAAe;IACb,SAAS;IACT,uBAAuB;IACvB,UAAU,CAAC,YAAY,SAAS;IAChC,QAAQ;KAAC;KAAQ;KAAW;KAAe;KAAgB;KAAc;IACzE,SAAS,EAAE;IACZ;GACF;EACD,YAAY;GACV,OAAO,EAAE;GACT,UAAU;IACR,kBAAkB;IAClB,gBAAgB;IAChB,OAAO,EAAE;IACT,iBAAiB;IACjB,sBAAsB;IACvB;GACD,OAAO,EAAE;GACV;EACD,WAAW,EACT,SAAS,MACV;EACD,KAAK,EACH,cAAc,SACf;EAIF,CAAC"}
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../../src/config/schema.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport {\n AgentConfigEntrySchema,\n CapabilityPresetSchema,\n DEFAULT_CAPABILITY_PRESET_ID,\n} from '../agent-manifest/schema.js';\nimport { checkCacheDir } from '../browser/cache-dir-policy.js';\nimport { validatePublicUrl } from './public-url.js';\n\n// ============================================\n// Agent Configs\n// ============================================\n\n/**\n * Agent model ref. Always an object with explicit `primary` and optional\n * `fallbacks` chain. No string-form shorthand — every write site builds the\n * object explicitly so reads never branch on shape.\n */\nexport const AgentModelRefSchema = z\n .object({\n primary: z.string().min(1),\n fallbacks: z.array(z.string()).optional(),\n })\n .strict();\n\nexport type AgentModelConfig = z.infer<typeof AgentModelRefSchema>;\n\nexport const AgentTypedModelRoleSchema = z\n .object({\n description: z.string().max(500).optional(),\n model: z.string().min(1),\n fallbacks: z.array(z.string().min(1)).optional(),\n })\n .strict()\n .superRefine((entry, ctx) => {\n const validateRef = (ref: string) => {\n const trimmed = ref.trim();\n const idx = trimmed.indexOf('/');\n return idx > 0 && idx < trimmed.length - 1;\n };\n if (!validateRef(entry.model)) {\n ctx.addIssue({\n code: 'custom',\n message: `model must be provider/model format (got '${entry.model}')`,\n path: ['model'],\n });\n }\n for (const [index, fallback] of (entry.fallbacks ?? []).entries()) {\n if (!validateRef(fallback)) {\n ctx.addIssue({\n code: 'custom',\n message: `fallback must be provider/model format (got '${fallback}')`,\n path: ['fallbacks', index],\n });\n }\n }\n });\n\nexport type AgentTypedModelRole = z.infer<typeof AgentTypedModelRoleSchema>;\n\nconst AgentTypedModelRolesSchema = z\n .record(z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/), AgentTypedModelRoleSchema)\n .optional();\n\nexport const AgentModelsSchema = z\n .object({\n defaultRole: z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/).optional(),\n roles: AgentTypedModelRolesSchema,\n })\n .strict()\n .optional();\n\nexport type AgentModelsConfig = z.infer<typeof AgentModelsSchema>;\n\n/**\n * Image-generation model ref. {@link AgentModelRefSchema} plus runtime knobs\n * (`timeoutMs`, `autoProviderFallback`) used by the image-generation runtime.\n */\nexport const AgentImageGenerationModelSchema = z\n .object({\n primary: z.string().min(1),\n fallbacks: z.array(z.string()).optional(),\n /** Hard cap for the whole generation attempt (ms). */\n timeoutMs: z.number().int().positive().optional(),\n /**\n * When all `primary + fallbacks` candidates fail, sweep every other\n * configured provider before giving up.\n */\n autoProviderFallback: z.boolean().optional(),\n })\n .strict();\n\nexport type AgentImageGenerationModelConfig = z.infer<typeof AgentImageGenerationModelSchema>;\n\nexport type AgentTypedModel = AgentTypedModelRole & { id: string };\n\nexport const AgentsConfigSchema = z.object({\n /** Default agent id when not specified (routing / session creation). */\n default: z.string().optional(),\n /** Protected global defaults preset applied before each agent's own presets. */\n defaultPreset: z.string().default(DEFAULT_CAPABILITY_PRESET_ID),\n capabilityPresets: z.record(z.string(), CapabilityPresetSchema).default({}),\n list: z.array(AgentConfigEntrySchema).default([]),\n}).strict().default({\n default: 'main',\n defaultPreset: DEFAULT_CAPABILITY_PRESET_ID,\n capabilityPresets: {\n [DEFAULT_CAPABILITY_PRESET_ID]: {\n id: DEFAULT_CAPABILITY_PRESET_ID,\n name: 'Global defaults',\n description: 'Default capabilities inherited by every agent.',\n version: 1,\n models: {\n defaultRole: 'deep',\n roles: {},\n },\n },\n },\n list: [\n {\n id: 'main',\n enabled: true,\n identity: {\n name: 'Main',\n role: 'General assistant',\n language: 'en',\n tone: 'direct',\n },\n responsibilities: {\n primary: ['Help the user complete tasks'],\n },\n workspace: { root: '~/.xopc/workspace/main' },\n tools: { builtin: {} },\n skills: { mode: 'all' },\n memory: {\n mode: 'confirmWrite',\n sources: ['session', 'curated'],\n writePolicy: { curated: 'confirm' },\n },\n workflows: {},\n boundaries: { requiresConfirmation: [], forbidden: [], escalation: [] },\n },\n ],\n});\n\nconst BrowserCloudConfigSchema = z\n .object({\n apiKey: z.string().optional(),\n projectId: z.string().optional(),\n region: z.string().optional(),\n })\n .strict()\n .optional();\n\nconst BrowserExtensionConfigSchema = z\n .object({\n port: z.number().int().min(1024).max(65535).optional(),\n host: z.string().min(1).optional(),\n connectionTimeout: z.number().int().positive().optional(),\n })\n .strict()\n .optional();\n\nconst BrowserCloakConfigSchema = z\n .object({\n keepOpen: z.boolean().optional(),\n temporaryProfile: z.boolean().optional(),\n cacheDir: z.string().optional().superRefine((value, ctx) => {\n const result = checkCacheDir(value);\n if (result.ok === false) {\n ctx.addIssue({ code: 'custom', message: result.message });\n }\n }),\n binaryPath: z.string().optional(),\n timezone: z.string().optional(),\n locale: z.string().optional(),\n webrtcIp: z.string().optional(),\n fingerprintPlatform: z.string().optional(),\n extraArgs: z.array(z.string()).optional(),\n })\n .strict()\n .optional();\n\nexport const BrowserConfigSchema = z\n .object({\n enabled: z.boolean().default(true),\n backend: z.enum(['local', 'cdp', 'cloud', 'extension', 'cloakbrowser']).default('extension'),\n headless: z.boolean().optional(),\n allowPrivateUrls: z.boolean().optional(),\n commandTimeout: z.number().int().min(5).max(900).optional(),\n cloudProvider: z.enum(['local', 'browserbase', 'browser-use']).optional(),\n cloud: BrowserCloudConfigSchema,\n cdpUrl: z.string().optional(),\n extension: BrowserExtensionConfigSchema,\n cloakbrowser: BrowserCloakConfigSchema,\n humanize: z.boolean().optional(),\n humanPreset: z.enum(['default', 'careful']).optional(),\n dialogPolicy: z.enum(['must_respond', 'auto_dismiss', 'auto_accept']).optional(),\n dialogTimeoutSeconds: z.number().int().positive().optional(),\n })\n .strict()\n .default({ enabled: true, backend: 'extension' });\n\n// ============================================\n// Channel Configs (per-channel Zod lives in bundled extensions; root schema is open)\n// ============================================\n\nexport {\n TelegramTopicConfigSchema,\n TelegramGroupConfigSchema,\n TelegramAccountConfigSchema,\n TelegramConfigSchema,\n} from '../../extensions/telegram/src/config-schema.js';\nexport type { TelegramConfig } from '../../extensions/telegram/src/config-schema.js';\nexport { WeixinAccountConfigSchema, WeixinConfigSchema } from '../../extensions/weixin/src/config-schema.js';\nexport type { WeixinConfig } from '../../extensions/weixin/src/config-schema.js';\n// ============================================\n// Session Routing Configuration\n// ============================================\n\nexport const BindingMatchSchema = z.object({\n channel: z.string(),\n accountId: z.string().optional(),\n peerKind: z.string().optional(),\n peerId: z.string().optional(),\n guildId: z.string().optional(),\n teamId: z.string().optional(),\n memberRoleIds: z.array(z.string()).optional(),\n});\n\nexport const BindingRuleSchema = z.object({\n id: z.string().optional(),\n agentId: z.string(),\n priority: z.number().default(100),\n match: BindingMatchSchema,\n enabled: z.boolean().default(true),\n});\n\nexport const BindingsConfigSchema = z.array(BindingRuleSchema).default([]);\n\nexport const SessionDmScopeSchema = z.enum([\n 'main',\n 'per-peer',\n 'per-channel-peer',\n 'per-account-channel-peer',\n]);\n\nexport const SessionStorageConfigSchema = z.object({\n pruneAfterMs: z.number().optional(),\n maxEntries: z.number().optional(),\n});\n\nexport const SessionResetModeSchema = z.enum(['daily', 'idle']);\n\nexport const SessionResetConfigSchema = z\n .object({\n mode: SessionResetModeSchema.optional(),\n /** Local hour (0–23) for the daily reset boundary. */\n atHour: z.number().int().min(0).max(23).optional(),\n /** Sliding idle window (minutes). When set with daily mode, whichever expires first wins. */\n idleMinutes: z.number().int().min(0).optional(),\n })\n .strict();\n\nexport const SessionResetByTypeSchema = z\n .object({\n direct: SessionResetConfigSchema.optional(),\n group: SessionResetConfigSchema.optional(),\n thread: SessionResetConfigSchema.optional(),\n })\n .strict();\n\nexport const SessionScopeSchema = z.enum(['per-sender', 'global']);\n\nexport const SessionConfigSchema = z.object({\n scope: SessionScopeSchema.default('per-sender'),\n mainKey: z.string().default('main'),\n dmScope: SessionDmScopeSchema.default('main'),\n identityLinks: z.record(z.string(), z.array(z.string())).optional(),\n resetTriggers: z.array(z.string()).optional(),\n idleMinutes: z.number().int().positive().optional(),\n reset: SessionResetConfigSchema.optional(),\n resetByType: SessionResetByTypeSchema.optional(),\n resetByChannel: z.record(z.string(), SessionResetConfigSchema).optional(),\n storage: SessionStorageConfigSchema.optional(),\n}).default({\n scope: 'per-sender',\n mainKey: 'main',\n dmScope: 'main',\n});\n\n/** Channel buckets — shapes validated post-parse by registered channel plugins. */\nexport const ChannelsConfigSchema = z.record(z.string(), z.unknown()).default({});\n\nexport const SearchProviderEntrySchema = z.object({\n type: z.enum(['brave', 'tavily', 'bing', 'searxng']),\n apiKey: z.string().optional(),\n /** SearXNG instance base URL (e.g. http://localhost:8080) */\n url: z.string().optional(),\n disabled: z.boolean().optional(),\n});\n\nexport type SearchProviderEntry = z.infer<typeof SearchProviderEntrySchema>;\n\nexport const WebSearchConfigSchema = z.object({\n maxResults: z.number().default(5),\n /** Ordered API providers; empty → HTML fallback only */\n providers: z.array(SearchProviderEntrySchema).default([]),\n});\n\nexport type WebSearchConfig = z.infer<typeof WebSearchConfigSchema>;\n\nexport const WebsiteBlocklistSchema = z.object({\n /** Master switch. Default false (no blocking). */\n enabled: z.boolean().default(false),\n /** Domain patterns to block (e.g. \"example.com\", \"*.evil.org\"). */\n domains: z.array(z.string()).default([]),\n});\n\nexport type WebsiteBlocklistConfig = z.infer<typeof WebsiteBlocklistSchema>;\n\nexport const WebToolsConfigSchema = z.object({\n /** Search result HTML fallback: cn → Bing, otherwise DuckDuckGo */\n region: z.enum(['cn', 'global']).optional(),\n search: WebSearchConfigSchema.optional(),\n /** Domain blocklist for web_fetch / web_extract / browser tools. */\n blocklist: WebsiteBlocklistSchema.optional(),\n});\n\nexport type WebToolsConfig = z.infer<typeof WebToolsConfigSchema>;\n\nexport const ToolsConfigSchema = z.object({\n web: WebToolsConfigSchema.optional(),\n /**\n * Per-capability media providers. Currently only `audio` (STT) is wired;\n * `image` / `video` slots are reserved for future capabilities.\n */\n media: z.lazy(() => ToolsMediaConfigSchema),\n}).default({\n web: {\n search: {\n maxResults: 5,\n providers: [],\n },\n },\n});\n\n// ============================================\n// Gateway Configuration\n// ============================================\n\nexport const GatewayAuthRateLimitSchema = z\n .object({\n enabled: z.boolean().default(true),\n maxAttempts: z.number().int().min(1).default(5),\n windowMs: z.number().default(900_000),\n blockDurationMs: z.number().default(300_000),\n /** OpenClaw alias for blockDurationMs. */\n lockoutMs: z.number().optional(),\n /** Skip rate limiting for loopback client IPs (default true). Remote browser Origin requests never exempt. */\n exemptLoopback: z.boolean().default(true),\n /**\n * Coalesce same-client failures arriving within this window into a single\n * attempt. Absorbs SPA fan-out / SDK auto-retry storms without weakening\n * brute-force protection (deliberate attackers are still rate-limited to\n * one effective attempt per window). Set to 0 to disable.\n */\n burstCoalesceMs: z.number().int().min(0).default(1000),\n })\n .optional();\n\nexport const GatewaySecuritySchema = z\n .object({\n /** When true, non-loopback binds require explicit gateway.auth.rateLimit configuration. */\n strict: z.boolean().optional(),\n })\n .optional();\n\nexport const GatewayTrustedProxySchema = z\n .object({\n /** Header set by the reverse proxy with the authenticated user identity. */\n userHeader: z.string().min(1),\n /** Additional headers that must be present (e.g. proxy auth markers). */\n requiredHeaders: z.array(z.string()).optional(),\n /** When non-empty, only these user identities are allowed. */\n allowUsers: z.array(z.string()).optional(),\n /** Allow trusted-proxy auth when the TCP source is loopback (same-host reverse proxy). */\n allowLoopback: z.boolean().optional(),\n })\n .strict();\n\nexport const GatewayAuthSchema = z\n .object({\n mode: z.enum(['none', 'token', 'password', 'trusted-proxy']).default('token'),\n token: z.string().optional(),\n password: z.string().optional(),\n /** When true (default for Serve), browser UI may auth via Tailscale identity headers. API routes still require token. */\n allowTailscale: z.boolean().optional(),\n rateLimit: GatewayAuthRateLimitSchema,\n trustedProxy: GatewayTrustedProxySchema.optional(),\n })\n .default({\n mode: 'token',\n });\n\nexport const GatewayTailscaleConsentSchema = z.object({\n version: z.string().min(1),\n acceptedAt: z.string().min(1),\n});\n\nexport const GatewayTailscaleSchema = z\n .object({\n mode: z.enum(['off', 'serve', 'funnel']).default('off'),\n resetOnExit: z.boolean().default(true),\n consent: GatewayTailscaleConsentSchema.optional(),\n })\n .default({\n mode: 'off',\n resetOnExit: true,\n });\n\nexport const GatewayRemoteSchema = z.object({\n url: z.string().url(),\n token: z.string().optional(),\n password: z.string().optional(),\n transport: z.enum(['direct', 'ssh']).default('direct'),\n sshTarget: z.string().optional(),\n sshIdentity: z.string().optional(),\n tlsFingerprint: z.string().optional(),\n});\n\nexport const GatewayTlsSchema = z\n .object({\n enabled: z.boolean().default(false),\n autoGenerate: z.boolean().default(false),\n certPath: z.string().optional(),\n keyPath: z.string().optional(),\n })\n .default({\n enabled: false,\n autoGenerate: false,\n });\n\nexport const GatewayModeSchema = z.enum(['local', 'remote']).default('local');\n\nexport const HeartbeatConfigSchema = z\n .object({\n enabled: z.boolean(),\n intervalMs: z.number(),\n /** When false, heartbeat instructions are only sent during heartbeat polling turns (not in every chat system prompt). */\n includeSystemPromptSection: z.boolean().optional().default(false),\n target: z.string().optional(),\n targetChatId: z.string().optional(),\n prompt: z.string().optional(),\n ackMaxChars: z.number().optional(),\n isolatedSession: z.boolean().optional(),\n activeHours: z\n .object({\n start: z.string(),\n end: z.string(),\n timezone: z.string().optional(),\n })\n .optional(),\n })\n .default({\n enabled: true,\n intervalMs: 1_800_000,\n includeSystemPromptSection: false,\n });\n\nexport const GatewayChannelConnectDeferModeSchema = z.enum(['auto', 'off', 'explicit']);\n\nexport const TunnelConsentSchema = z.object({\n version: z.string().min(1),\n acceptedAt: z.string().min(1),\n});\n\nexport const TunnelConfigSchema = z\n .object({\n enabled: z.boolean().default(false),\n brokerUrl: z.string().url().default('https://frp.xopc.ai/api'),\n /** Broker register API secret (env `XOPC_TUNNEL_REGISTRATION_SECRET` overrides when set). */\n registrationSecret: z.string().min(1).optional(),\n autoStart: z.boolean().default(false),\n subdomain: z.string().optional(),\n consent: TunnelConsentSchema.optional(),\n })\n .default({\n enabled: false,\n brokerUrl: 'https://frp.xopc.ai/api',\n autoStart: false,\n });\n\nexport type TunnelConfig = z.infer<typeof TunnelConfigSchema>;\n\n/**\n * Workspace-scoped concerns (file import, etc.). Distinct from\n * agent manifest workspace roots; this block carries\n * feature configuration for workspace-related routes.\n */\nexport const WorkspaceImportConfigSchema = z.object({\n /** Workspace-relative subdir for imported files. Default `imports`. */\n targetDir: z.string().default('imports'),\n /** Per-file byte cap. Default 100 MiB. */\n maxBytes: z.number().int().min(1024).max(10_737_418_240).default(104_857_600),\n /** When false, the route rejects `onConflict: 'overwrite'`. Default true. */\n allowOverwrite: z.boolean().default(true),\n});\nexport type WorkspaceImportConfig = z.infer<typeof WorkspaceImportConfigSchema>;\n\nexport const WorkspaceConfigSchema = z.object({\n import: WorkspaceImportConfigSchema.optional(),\n}).optional();\nexport type WorkspaceConfig = z.infer<typeof WorkspaceConfigSchema>;\n\nexport const GatewayBindModeSchema = z.enum(['auto', 'loopback', 'lan', 'tailnet', 'custom']);\n\nexport const GatewayConfigSchema = z.object({\n /** Semantic bind mode. */\n bind: GatewayBindModeSchema.optional(),\n /** IPv4 listen address when `bind` is `custom`. */\n customBindHost: z.string().optional(),\n port: z.number().optional(),\n /** local: this process runs the gateway; remote: CLI clients target gateway.remote. */\n mode: GatewayModeSchema.optional(),\n /** Persistent remote gateway target for CLI/TUI/MCP when mode=remote. */\n remote: GatewayRemoteSchema.optional(),\n tailscale: GatewayTailscaleSchema.optional(),\n tls: GatewayTlsSchema.optional(),\n auth: GatewayAuthSchema.optional(),\n heartbeat: HeartbeatConfigSchema.optional(),\n maxSseConnections: z.number().optional(),\n corsOrigins: z.array(z.string()).optional(),\n /**\n * Reverse-proxy publicly reachable URL (e.g. `https://gateway.example.com`).\n * Optional. When set, mobile pairing surfaces this URL as the preferred\n * baseUrl and it is auto-added to the browser CORS/CSRF allowlist.\n * - Must be a URL with no path / query / userinfo.\n * - Must use `https:` for public hosts; `http:` is only allowed when the\n * hostname is in an RFC1918 / `.local` private range.\n */\n publicUrl: z\n .string()\n .superRefine((value, ctx) => {\n const result = validatePublicUrl(value);\n if (result.ok === false) {\n ctx.addIssue({ code: 'custom', message: `gateway.publicUrl: ${result.message}` });\n }\n })\n .optional(),\n /** Dangerous: allow browser Origin to match the HTTP Host header when not in corsOrigins. */\n dangerouslyAllowHostHeaderOriginFallback: z.boolean().optional(),\n /** CIDRs or exact IPs of reverse proxies allowed to terminate auth (trusted-proxy mode). */\n trustedProxies: z.array(z.string()).optional(),\n /** When true, fall back to X-Real-IP if X-Forwarded-For chain parsing fails. Default false (fail closed). */\n allowRealIpFallback: z.boolean().optional(),\n security: GatewaySecuritySchema,\n /**\n * How channel `start()` is split around HTTP listen when using `GatewayServer`.\n * - `auto` (default): defer ids come from channel plugin `meta.deferConnectUntilAfterListen` + enabled config.\n * - `off`: always start all channels in phase1 (troubleshooting / strict ordering).\n * - `explicit`: defer only `channelConnectDeferIds` (empty = defer none).\n */\n channelConnectDeferMode: GatewayChannelConnectDeferModeSchema.optional(),\n /** When `channelConnectDeferMode` is `explicit`, these channel plugin ids are deferred until after listen. */\n channelConnectDeferIds: z.array(z.string().min(1)).max(24).optional(),\n /** Removed from the defer set (applied after `auto` or `explicit` resolution). */\n channelConnectDeferSkipIds: z.array(z.string().min(1)).max(24).optional(),\n /** Default skills marketplace provider id. Built-in: 'store', 'skillhub', 'clawhub'. Extensions may register more. */\n skillsMarketplaceProvider: z.string().optional(),\n /** Base URL for the xopc skills marketplace (public REST API). */\n skillsStoreBaseUrl: z.string().url().optional(),\n /** File sharing configuration (temporary public download links for workspace files). */\n share: z.object({\n enabled: z.boolean().default(true),\n /** Default TTL in ms (default 24h). */\n defaultTtlMs: z.number().min(60_000).max(604_800_000).default(86_400_000),\n /** Maximum TTL in ms (default 7 days). */\n maxTtlMs: z.number().min(60_000).max(2_592_000_000).default(604_800_000),\n /** Maximum concurrent active shares (default 100). */\n maxActiveShares: z.number().min(1).max(10_000).default(100),\n /** Maximum shareable file size in bytes (default 100MB). */\n maxFileSize: z.number().min(1_048_576).max(10_737_418_240).default(104_857_600),\n /** MIME types allowed for inline preview (?inline=1). */\n inlinePreviewMimes: z.array(z.string()).default([\n 'image/png',\n 'image/jpeg',\n 'image/gif',\n 'image/webp',\n 'image/svg+xml',\n 'application/pdf',\n 'text/html',\n 'text/markdown',\n 'text/plain',\n 'application/json',\n ]),\n /** Folder-sharing controls (browse + ZIP). */\n directory: z.object({\n enabled: z.boolean().default(true),\n /** Maximum folder size in bytes at scan time (default 1 GB). */\n maxFolderSize: z.number().int().min(1_048_576).max(10_737_418_240).default(1_073_741_824),\n /** Maximum number of entries scanned for a single folder share. */\n maxFileCount: z.number().int().min(1).max(100_000).default(1_000),\n /** Traversal depth cap (defense against recursive symlinks). */\n maxDepth: z.number().int().min(1).max(64).default(20),\n /** In-memory directory listing cache TTL. */\n listingCacheMs: z.number().int().min(0).max(600_000).default(60_000),\n /** Maximum simultaneous ZIP streams per share token. */\n zipConcurrency: z.number().int().min(1).max(8).default(1),\n }).default({\n enabled: true,\n maxFolderSize: 1_073_741_824,\n maxFileCount: 1_000,\n maxDepth: 20,\n listingCacheMs: 60_000,\n zipConcurrency: 1,\n }),\n }).optional(),\n /** Site-share configuration (static directory or reverse-proxy a local dev server). */\n siteShare: z.object({\n enabled: z.boolean().default(true),\n /** Public host suffix that subdomain shares are served under. */\n publicHostSuffix: z.string().min(1).default('share.xopc.ai'),\n /** Default TTL in ms (default 6h, shorter than file shares — live app surface). */\n defaultTtlMs: z.number().int().min(60_000).max(604_800_000).default(21_600_000),\n /** Maximum TTL in ms (default 7 days). */\n maxTtlMs: z.number().int().min(60_000).max(2_592_000_000).default(604_800_000),\n /** Maximum concurrent active site shares. */\n maxActiveSites: z.number().int().min(1).max(1_000).default(5),\n static: z.object({\n enabled: z.boolean().default(true),\n /** Maximum total bytes of files served per static site. */\n maxRootDirSize: z.number().int().min(1_048_576).max(10_737_418_240).default(524_288_000),\n /** Maximum file count under root dir. */\n maxFileCount: z.number().int().min(1).max(100_000).default(10_000),\n /** Whether HTML/CSS rewrite of absolute paths is on by default. */\n rewriteEnabledByDefault: z.boolean().default(false),\n }).default({\n enabled: true,\n maxRootDirSize: 524_288_000,\n maxFileCount: 10_000,\n rewriteEnabledByDefault: false,\n }),\n proxy: z.object({\n /** Reverse-proxy mode default-enabled per the product brief. */\n enabled: z.boolean().default(true),\n /** Upstream host whitelist. Loopback by default. */\n allowedUpstreamHosts: z\n .array(z.string().min(1))\n .default(['127.0.0.1', 'localhost', '::1']),\n /** Upstream port whitelist (common dev-server ports). */\n allowedUpstreamPorts: z\n .array(z.number().int().min(1).max(65535))\n .default([3000, 3001, 4321, 5173, 8000, 8080, 8888, 9000]),\n /** Whether to forward WebSocket upgrades. */\n forwardWebSocket: z.boolean().default(true),\n /** Maximum request body size in bytes (50 MB). */\n bodySizeLimit: z.number().int().min(0).max(1_073_741_824).default(52_428_800),\n /** Per-request HTTP timeout in ms. */\n requestTimeoutMs: z.number().int().min(1_000).max(600_000).default(30_000),\n /** Per-WebSocket idle timeout in ms. */\n wsIdleTimeoutMs: z.number().int().min(10_000).max(3_600_000).default(300_000),\n /** Rewrite Set-Cookie Path attribute (subpath mode only). */\n rewriteSetCookiePath: z.boolean().default(true),\n }).default({\n enabled: true,\n allowedUpstreamHosts: ['127.0.0.1', 'localhost', '::1'],\n allowedUpstreamPorts: [3000, 3001, 4321, 5173, 8000, 8080, 8888, 9000],\n forwardWebSocket: true,\n bodySizeLimit: 52_428_800,\n requestTimeoutMs: 30_000,\n wsIdleTimeoutMs: 300_000,\n rewriteSetCookiePath: true,\n }),\n }).optional(),\n}).default({\n bind: 'loopback',\n port: 18790,\n auth: {\n mode: 'token',\n },\n heartbeat: {\n enabled: true,\n intervalMs: 1_800_000,\n includeSystemPromptSection: false,\n },\n maxSseConnections: 100,\n corsOrigins: [],\n skillsMarketplaceProvider: 'skillhub',\n skillsStoreBaseUrl: 'https://store.xopc.ai',\n});\n\nexport const ModelsDevConfigSchema = z.object({\n enabled: z.boolean().default(true),\n}).default({\n enabled: true,\n});\n\n// ============================================\n// STT (Speech-to-Text) Config\n// ============================================\n\nconst SttProviderConfigCatchallSchema = z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(z.unknown()),\n z.record(z.string(), z.unknown()),\n]);\n\nexport const STTProviderConfigSchema = z\n .object({\n apiKey: z.string().optional(),\n model: z.string().optional(),\n baseUrl: z.string().optional(),\n headers: z.record(z.string(), z.string()).optional(),\n language: z.string().optional(),\n prompt: z.string().optional(),\n })\n .catchall(SttProviderConfigCatchallSchema);\n\nexport const STTFallbackConfigSchema = z.object({\n enabled: z.boolean().default(true),\n order: z.array(z.string().min(1)).default(['alibaba', 'openai']),\n});\n\nexport const MediaUnderstandingCapabilitiesSchema = z\n .array(z.enum(['image', 'audio', 'video']))\n .optional();\n\nexport const MediaUnderstandingModelSchema = z\n .object({\n provider: z.string().optional(),\n model: z.string().optional(),\n capabilities: MediaUnderstandingCapabilitiesSchema,\n type: z.union([z.literal('provider'), z.literal('cli')]).optional(),\n command: z.string().optional(),\n baseUrl: z.string().optional(),\n headers: z.record(z.string(), z.string()).optional(),\n apiKey: z.string().optional(),\n language: z.string().optional(),\n prompt: z.string().optional(),\n })\n .catchall(SttProviderConfigCatchallSchema);\n\nexport const STTConfigSchema = z\n .object({\n enabled: z.boolean().default(false),\n /** Primary provider id — any registered MediaUnderstandingProvider id. */\n provider: z.string().min(1).default('alibaba'),\n fallback: STTFallbackConfigSchema.optional(),\n timeoutMs: z.number().int().min(1000).max(180000).optional(),\n /** Ordered model entries for this capability (OpenClaw `tools.media.audio.models`). */\n models: z.array(MediaUnderstandingModelSchema).optional(),\n /** Provider settings map keyed by provider id. */\n providers: z.record(z.string(), STTProviderConfigSchema).optional(),\n })\n .strict();\n\n// ============================================\n// TTS (Text-to-Speech) Config\n// ============================================\n\nconst TtsProviderConfigCatchallSchema = z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(z.unknown()),\n z.record(z.string(), z.unknown()),\n]);\n\nexport const TTSProviderConfigSchema = z\n .object({\n apiKey: z.string().optional(),\n model: z.string().optional(),\n voice: z.string().optional(),\n })\n .catchall(TtsProviderConfigCatchallSchema);\n\nexport const TTSFallbackConfigSchema = z.object({\n enabled: z.boolean().default(true),\n order: z\n .array(z.string().min(1))\n .default(['openai', 'alibaba', 'minimax', 'edge']),\n});\n\nexport const TTSModelOverridesConfigSchema = z.object({\n enabled: z.boolean().default(true),\n allowText: z.boolean().default(true),\n allowProvider: z.boolean().default(false),\n allowVoice: z.boolean().default(true),\n allowModelId: z.boolean().default(true),\n allowVoiceSettings: z.boolean().default(false),\n allowNormalization: z.boolean().default(false),\n allowSeed: z.boolean().default(false),\n});\n\nexport const TTSEdgeConfigSchema = z.object({\n enabled: z.boolean().default(true),\n voice: z.string().optional(),\n lang: z.string().optional(),\n outputFormat: z.string().optional(),\n pitch: z.string().optional(),\n rate: z.string().optional(),\n volume: z.string().optional(),\n proxy: z.string().optional(),\n timeoutMs: z.number().int().min(1000).max(120000).optional(),\n});\n\nexport const TTSSummarizationConfigSchema = z.object({\n enabled: z.boolean().optional(),\n targetLength: z.number().int().min(1).optional(),\n threshold: z.number().int().min(1).optional(),\n model: z.string().optional(),\n});\n\nexport const TTSConfigSchema = z\n .object({\n enabled: z.boolean().default(false),\n /** Primary provider id — any registered SpeechProviderPlugin id. */\n provider: z.string().min(1).default('edge'),\n trigger: z.enum(['off', 'always', 'inbound', 'tagged']).default('always'),\n fallback: TTSFallbackConfigSchema.optional(),\n maxTextLength: z.number().int().min(1).default(512), // Conservative default to accommodate all providers (Alibaba limit is 512)\n timeoutMs: z.number().int().min(1000).max(180000).default(60000),\n summarization: TTSSummarizationConfigSchema.optional(),\n modelOverrides: TTSModelOverridesConfigSchema.optional(),\n /** Provider settings map keyed by provider id. */\n providers: z.record(z.string(), TTSProviderConfigSchema).optional(),\n })\n .strict();\n\n// ============================================\n// messages.* — delivery / presentation concerns\n// ============================================\n\nexport const MessagesConfigSchema = z.object({\n /** Voice (text-to-speech) output configuration. */\n tts: TTSConfigSchema.optional(),\n}).optional();\n\nexport const ToolsMediaAudioConfigSchema = STTConfigSchema;\n\nexport const ToolsMediaConfigSchema = z\n .object({\n /** Shared model entries applied across media capabilities when entry lacks capabilities. */\n models: z.array(MediaUnderstandingModelSchema).optional(),\n /** Audio (speech-to-text) capability provider config. */\n audio: ToolsMediaAudioConfigSchema.optional(),\n })\n .optional();\n\n// ============================================\n// Provider Configs (capability providers: image / audio / video)\n// ============================================\n\n/**\n * Optional Azure OpenAI overrides used when an OpenAI image-generation\n * request should hit an Azure deployment instead of `api.openai.com`.\n *\n * URL template (when present):\n * `https://<resource>.openai.azure.com/openai/deployments/<deployment>/images/generations?api-version=<apiVersion>`\n */\nexport const ProviderAzureConfigSchema = z\n .object({\n /** Azure resource name (subdomain before `.openai.azure.com`). */\n resource: z.string().min(1).optional(),\n /** Azure deployment id (configured per model). */\n deployment: z.string().min(1).optional(),\n /** Azure REST API version, e.g. `2024-08-01-preview`. */\n apiVersion: z.string().min(1).optional(),\n })\n .strict();\n\n/** Per-vendor request overrides applied by the provider HTTP layer. */\nexport const ProviderRequestOverridesSchema = z\n .object({\n /** Hard cap for a single HTTP call (ms). */\n timeoutMs: z.number().int().positive().optional(),\n /** Extra headers merged into every outbound request. */\n headers: z.record(z.string(), z.string()).optional(),\n })\n .strict();\n\n/**\n * Generic per-vendor provider config — used by image / audio / video\n * capability providers via `cfg.providers.<id>`. Kept loose (`.strict()` but\n * everything optional) so adding a new vendor never requires a config\n * migration.\n */\nexport const ProviderAuthConfigSchema = z\n .object({\n /** Static API key (api-key / azure-key modes). */\n apiKey: z.string().optional(),\n /** Override the default REST base URL. */\n baseUrl: z.string().url().optional(),\n /** Vendor region (DashScope: `beijing` / `singapore`; AWS: region id). */\n region: z.string().optional(),\n /** Image-only base URL override (DashScope splits image vs LLM). */\n imageBaseUrl: z.string().url().optional(),\n /** Per-vendor request overrides. */\n request: ProviderRequestOverridesSchema.optional(),\n /** Azure OpenAI deployment overrides; only consumed by OpenAI image provider. */\n azure: ProviderAzureConfigSchema.optional(),\n })\n .strict();\n\nexport type ProviderAuthConfig = z.infer<typeof ProviderAuthConfigSchema>;\n\n/**\n * `cfg.providers.<id>` is keyed by provider id (`openai`, `dashscope`,\n * `minimax`, `google`, `fal`, …). Every entry is optional and validated by\n * {@link ProviderAuthConfigSchema}.\n */\nexport const ProvidersConfigSchema = z.record(z.string(), ProviderAuthConfigSchema);\n\nexport type ProvidersConfig = z.infer<typeof ProvidersConfigSchema>;\n\n// ============================================\n// Extension Configs \n// ============================================\n\n// Security config for extensions \nexport const ExtensionSecurityConfigSchema = z.object({\n checkPermissions: z.boolean().default(true),\n allowUntrusted: z.boolean().default(false),\n allow: z.array(z.string()).default([]),\n trackProvenance: z.boolean().default(true),\n allowPromptInjection: z.boolean().default(false),\n});\n\n// Slot config for extensions \nexport const ExtensionSlotsConfigSchema = z.object({\n memory: z.string().optional(),\n tts: z.string().optional(),\n imageGeneration: z.string().optional(),\n webSearch: z.string().optional(),\n});\n\n// Complete extensions config\n// Extension config allows both known fields AND arbitrary extension-specific config\n// Known fields: enabled (array), allow (array), security (object), slots (object)\n// Arbitrary: any other key is extension-specific config (e.g., extensions.hello.greeting)\nexport const ExtensionsConfigSchema: z.ZodType<Record<string, unknown>> = z.record(z.string(), z.unknown());\n\n// ============================================\n// Update Config\n// ============================================\n\nexport const UpdateAutoConfigSchema = z\n .object({\n /** Enable automatic update installation. Default false. */\n enabled: z.boolean().default(false),\n /** Hours to wait before applying a stable update after first detection. */\n stableDelayHours: z.number().min(0).default(6),\n /** Additional random jitter hours for stable rollout (avoids thundering herd). */\n stableJitterHours: z.number().min(0).default(12),\n /** How often to re-check for beta updates (hours). Min 0.25. */\n betaCheckIntervalHours: z.number().min(0.25).default(1),\n })\n .strict()\n .optional();\n\n/** Persistent `/goal` (Ralph loop) — Hermes-aligned defaults. */\nexport const GoalNotificationEventSchema = z.enum([\n 'done',\n 'blocked',\n 'needs_input',\n 'queue_failed',\n 'queue_retry',\n 'queue_succeeded',\n 'queue_skipped',\n]);\n\nexport const GoalNotificationTargetSchema = z\n .object({\n channel: z.string().min(1),\n chatId: z.string().min(1),\n accountId: z.string().optional(),\n threadId: z.union([z.string(), z.number()]).optional(),\n silent: z.boolean().optional(),\n events: z.array(GoalNotificationEventSchema).optional(),\n })\n .strict();\n\nexport const GoalNotificationsConfigSchema = z\n .object({\n enabled: z.boolean().default(false),\n /** Notify Telegram/Weixin chats bound to the goal activeSessionKey. */\n includeLinkedSessions: z.boolean().default(true),\n /** Channels eligible for linked-session notifications. */\n channels: z.array(z.string().min(1)).default(['telegram', 'weixin']),\n events: z\n .array(GoalNotificationEventSchema)\n .default(['done', 'blocked', 'needs_input', 'queue_failed', 'queue_retry']),\n targets: z.array(GoalNotificationTargetSchema).default([]),\n })\n .strict()\n .default({\n enabled: false,\n includeLinkedSessions: true,\n channels: ['telegram', 'weixin'],\n events: ['done', 'blocked', 'needs_input', 'queue_failed', 'queue_retry'],\n targets: [],\n });\n\nexport const GoalsConfigSchema = z\n .object({\n /** Max continuation turns before auto-pause (Hermes default 20). */\n maxTurns: z.number().int().min(1).max(500).default(20),\n /** Optional judge model ref; defaults to the active agent model. */\n judgeModelRef: z.string().optional(),\n /**\n * When true (default), first post-turn runs a decomposition judge to build a checklist;\n * subsequent turns evaluate progress per item (Hermes-style). When false, use legacy freeform judge only.\n */\n checklistMode: z.boolean().default(true),\n /**\n * empty_only preserves legacy behavior: the first post-turn decomposition runs only when the\n * goal has no checklist. supplement_existing lets the first post-turn add non-duplicate judge\n * criteria even when the user supplied initial acceptance criteria.\n */\n checklistDecomposePolicy: z.enum(['empty_only', 'supplement_existing']).default('empty_only'),\n /** Auto-pause after this many consecutive judge JSON/tool parse failures (Hermes default 3). */\n maxConsecutiveParseFailures: z.number().int().min(1).max(20).default(3),\n /** Judge LLM call timeout in ms (Hermes uses 60s). */\n judgeTimeoutMs: z.number().int().min(5_000).max(120_000).default(60_000),\n /** Max characters of recent transcript JSON passed to the checklist judge as extra context. */\n checklistHistoryChars: z.number().int().min(0).max(100_000).default(24_000),\n /** External channel notification policy for durable goal lifecycle events. */\n notifications: GoalNotificationsConfigSchema,\n })\n .strict();\n\nexport type GoalsConfig = z.infer<typeof GoalsConfigSchema>;\n\nexport const UpdateConfigSchema = z\n .object({\n /** Check for updates on gateway startup. Default true. */\n checkOnStart: z.boolean().default(true),\n /** Update channel: stable (default), beta, or dev. */\n channel: z.enum(['stable', 'beta', 'dev']).default('stable'),\n /** Automatic update policy. */\n auto: UpdateAutoConfigSchema,\n })\n .strict()\n .optional();\n\nexport type UpdateConfig = z.infer<typeof UpdateConfigSchema>;\n\nexport const CommandsConfigSchema = z\n .object({\n restart: z.boolean().optional(),\n })\n .strict()\n .optional();\n\nexport type CommandsConfig = z.infer<typeof CommandsConfigSchema>;\n\nexport const TuiConfigSchema = z\n .object({\n /** Default agent id for fresh TUI sessions. Leaves global routing (`agents.default`) untouched. */\n defaultAgent: z.string().min(1).optional(),\n })\n .strict()\n .default({});\n\nexport type TuiConfig = z.infer<typeof TuiConfigSchema>;\n\n// ============================================\n// MCP (Model Context Protocol)\n// ============================================\n\nconst McpHttpUrlSchema = z\n .string()\n .url()\n .refine((value) => {\n try {\n const protocol = new URL(value).protocol;\n return protocol === 'http:' || protocol === 'https:';\n } catch {\n return false;\n }\n }, 'MCP server URL must use http or https');\n\nconst ConnectorSecretReferenceSchema = z.object({\n xopcSecretRef: z.object({\n provider: z.string().min(1),\n fieldKey: z.string().min(1),\n }),\n});\n\nconst McpConfigScalarSchema = z.union([z.string(), z.number(), z.boolean(), ConnectorSecretReferenceSchema]);\n\nexport const McpServerSchema = z\n .object({\n command: z.string().optional(),\n args: z.array(z.string()).optional(),\n env: z.record(z.string(), McpConfigScalarSchema).optional(),\n cwd: z.string().optional(),\n workingDirectory: z.string().optional(),\n url: McpHttpUrlSchema.optional(),\n transport: z.enum(['sse', 'streamable-http']).optional(),\n headers: z.record(z.string(), McpConfigScalarSchema).optional(),\n connectionTimeoutMs: z.number().finite().positive().optional(),\n })\n .catchall(z.unknown())\n .superRefine((value, ctx) => {\n const hasCommand = typeof value.command === 'string' && value.command.trim().length > 0;\n const hasUrl = typeof value.url === 'string' && value.url.trim().length > 0;\n if (hasCommand && hasUrl) {\n ctx.addIssue({\n code: 'custom',\n message: 'MCP server cannot define both command and url',\n });\n }\n });\n\nexport const McpConfigSchema = z\n .object({\n servers: z.record(z.string(), McpServerSchema).optional(),\n sessionIdleTtlMs: z.number().finite().min(0).optional(),\n })\n .strict()\n .optional();\n\nexport type McpServerConfig = z.infer<typeof McpServerSchema>;\nexport type McpConfig = z.infer<typeof McpConfigSchema>;\n\nexport const ConnectorsConfigSchema = z\n .object({\n instances: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),\n })\n .strict()\n .optional();\n\nexport type ConnectorsConfig = z.infer<typeof ConnectorsConfigSchema>;\n\n// ============================================\n// Root Config\n// ============================================\n\nexport const ConfigSchema = z.object({\n agents: AgentsConfigSchema,\n bindings: BindingsConfigSchema,\n session: SessionConfigSchema,\n channels: ChannelsConfigSchema,\n gateway: GatewayConfigSchema,\n browser: BrowserConfigSchema,\n tunnel: TunnelConfigSchema.optional(),\n workspace: WorkspaceConfigSchema,\n tools: ToolsConfigSchema,\n mcp: McpConfigSchema,\n connectors: ConnectorsConfigSchema,\n goals: GoalsConfigSchema.optional(),\n extensions: ExtensionsConfigSchema.default({}),\n /** Per-vendor capability provider config (image / audio / video). */\n providers: ProvidersConfigSchema.optional(),\n modelsDev: ModelsDevConfigSchema,\n /** Delivery / presentation concerns (currently `tts`). */\n messages: MessagesConfigSchema,\n update: UpdateConfigSchema,\n commands: CommandsConfigSchema,\n tui: TuiConfigSchema,\n}).default({\n agents: {\n default: 'main',\n defaultPreset: DEFAULT_CAPABILITY_PRESET_ID,\n capabilityPresets: {\n [DEFAULT_CAPABILITY_PRESET_ID]: {\n id: DEFAULT_CAPABILITY_PRESET_ID,\n name: 'Global defaults',\n description: 'Default capabilities inherited by every agent.',\n version: 1,\n models: {\n defaultRole: 'deep',\n roles: {},\n },\n },\n },\n list: [\n {\n id: 'main',\n enabled: true,\n identity: {\n name: 'Main',\n role: 'General assistant',\n language: 'en',\n tone: 'direct',\n },\n responsibilities: {\n primary: ['Help the user complete tasks'],\n },\n workspace: { root: '~/.xopc/workspace/main' },\n tools: { builtin: {} },\n skills: { mode: 'all' },\n memory: {\n mode: 'confirmWrite',\n sources: ['session', 'curated'],\n writePolicy: { curated: 'confirm' },\n },\n workflows: {},\n boundaries: { requiresConfirmation: [], forbidden: [], escalation: [] },\n },\n ],\n },\n bindings: [],\n session: {\n scope: 'per-sender' as const,\n mainKey: 'main',\n dmScope: 'main' as const,\n },\n channels: {\n telegram: {\n enabled: false,\n debug: false,\n defaults: {\n dmPolicy: 'pairing' as const,\n groupPolicy: 'open' as const,\n replyToMode: 'off' as const,\n historyLimit: 50,\n textChunkLimit: 4000,\n streaming: { mode: 'partial' as const },\n },\n accounts: {\n default: {\n accountId: 'default',\n enabled: true,\n botToken: '',\n allowFrom: [],\n groupAllowFrom: [],\n },\n },\n },\n },\n gateway: {\n bind: 'loopback',\n port: 18790,\n auth: {\n mode: 'token',\n },\n heartbeat: {\n enabled: true,\n intervalMs: 1_800_000,\n includeSystemPromptSection: false,\n },\n maxSseConnections: 100,\n corsOrigins: [],\n skillsMarketplaceProvider: 'skillhub',\n skillsStoreBaseUrl: 'https://store.xopc.ai',\n },\n browser: {\n enabled: true,\n backend: 'extension' as const,\n },\n tools: {\n web: {\n search: {\n maxResults: 5,\n providers: [],\n },\n },\n },\n goals: {\n maxTurns: 20,\n checklistMode: true,\n checklistDecomposePolicy: 'empty_only',\n maxConsecutiveParseFailures: 3,\n judgeTimeoutMs: 60_000,\n checklistHistoryChars: 24_000,\n notifications: {\n enabled: false,\n includeLinkedSessions: true,\n channels: ['telegram', 'weixin'],\n events: ['done', 'blocked', 'needs_input', 'queue_failed', 'queue_retry'],\n targets: [],\n },\n },\n extensions: {\n allow: [],\n security: {\n checkPermissions: true,\n allowUntrusted: false,\n allow: [],\n trackProvenance: true,\n allowPromptInjection: false,\n },\n slots: {},\n },\n modelsDev: {\n enabled: true,\n },\n tui: {},\n // messages.tts / tools.media.audio start undefined; the factory layer fills\n // in provider-level defaults (model/voice) on demand. Fresh configs don't\n // ship with enabled providers so they never make surprise STT/TTS calls.\n});\n\nexport type Config = z.infer<typeof ConfigSchema>;\nexport type GatewayAuthConfig = z.infer<typeof GatewayAuthSchema>;\nexport type GatewayTrustedProxyConfig = z.infer<typeof GatewayTrustedProxySchema>;\nexport type GatewayAuthRateLimitConfig = z.infer<typeof GatewayAuthRateLimitSchema>;\nexport type GatewayBindMode = z.infer<typeof GatewayBindModeSchema>;\nexport type STTConfig = z.infer<typeof STTConfigSchema>;\nexport type TTSConfig = z.infer<typeof TTSConfigSchema>;\n\n// ============================================\n// Helper Functions\n// ============================================\n\n/**\n * Parse a model reference string.\n */\nexport interface ParsedModelRef {\n provider: string;\n model: string;\n}\n\nexport function getAgentDefaultModelRef(config: Config): string | undefined {\n const list = Array.isArray(config.agents?.list) ? config.agents.list : [];\n const defaultId =\n config.agents?.default?.trim() ||\n list.find((entry) => (entry as { default?: boolean }).default === true)?.id?.trim() ||\n list[0]?.id;\n const agent = list.find((entry) => entry.enabled !== false && entry.id === defaultId) ?? list[0];\n if (!agent) return undefined;\n\n let modelRef: string | undefined;\n const visited = new Set<string>();\n const applyModels = (models: AgentModelsConfig | undefined): void => {\n const roles = models?.roles ?? {};\n const defaultRole = models?.defaultRole ?? Object.keys(roles)[0];\n const role = defaultRole ? roles[defaultRole] : undefined;\n const next = role?.model.trim();\n if (next) modelRef = next;\n };\n const applyPreset = (presetId: string): void => {\n if (visited.has(presetId)) return;\n visited.add(presetId);\n const preset = config.agents.capabilityPresets[presetId];\n if (!preset) return;\n for (const parent of preset.extends ?? []) {\n applyPreset(parent);\n }\n applyModels(preset.models);\n };\n\n applyPreset(config.agents.defaultPreset);\n for (const presetId of agent.extends ?? []) {\n if (presetId !== config.agents.defaultPreset) {\n applyPreset(presetId);\n }\n }\n applyModels(agent.models);\n return modelRef;\n}\n\n/** `provider/model` or null when invalid. */\nexport function parseModelRef(ref: string): ParsedModelRef | null {\n const trimmed = ref.trim();\n const idx = trimmed.indexOf('/');\n if (idx <= 0 || idx === trimmed.length - 1) {\n return null;\n }\n return { provider: trimmed.slice(0, idx).trim(), model: trimmed.slice(idx + 1).trim() };\n}\n"],"mappings":";;;;;;;;AAyyCA,SAAgB,wBAAwB,QAAoC;CAC1E,MAAM,OAAO,MAAM,QAAQ,OAAO,QAAQ,KAAK,GAAG,OAAO,OAAO,OAAO,EAAE;CACzE,MAAM,YACJ,OAAO,QAAQ,SAAS,MAAM,IAC9B,KAAK,MAAM,UAAW,MAAgC,YAAY,KAAK,EAAE,IAAI,MAAM,IACnF,KAAK,IAAI;CACX,MAAM,QAAQ,KAAK,MAAM,UAAU,MAAM,YAAY,SAAS,MAAM,OAAO,UAAU,IAAI,KAAK;AAC9F,KAAI,CAAC,MAAO,QAAO,KAAA;CAEnB,IAAI;CACJ,MAAM,0BAAU,IAAI,KAAa;CACjC,MAAM,eAAe,WAAgD;EACnE,MAA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GACF;EACD,UAAU,EAAE;EACZ,SAAS;GACP,OAAO;GACP,SAAS;GACT,SAAS;GACV;EACD,UAAU,EACR,UAAU;GACR,SAAS;GACT,OAAO;GACP,UAAU;IACR,UAAU;IACV,aAAa;IACb,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,WAAW,EAAE,MAAM,WAAoB;IACxC;GACD,UAAU,EACR,SAAS;IACP,WAAW;IACX,SAAS;IACT,UAAU;IACV,WAAW,EAAE;IACb,gBAAgB,EAAE;IACnB,EACF;GACF,EACF;EACD,SAAS;GACP,MAAM;GACN,MAAM;GACN,MAAM,EACJ,MAAM,SACP;GACD,WAAW;IACT,SAAS;IACT,YAAY;IACZ,4BAA4B;IAC7B;GACD,mBAAmB;GACnB,aAAa,EAAE;GACf,2BAA2B;GAC3B,oBAAoB;GACrB;EACD,SAAS;GACP,SAAS;GACT,SAAS;GACV;EACD,OAAO,EACL,KAAK,EACH,QAAQ;GACN,YAAY;GACZ,WAAW,EAAE;GACd,EACF,EACF;EACD,OAAO;GACL,UAAU;GACV,eAAe;GACf,0BAA0B;GAC1B,6BAA6B;GAC7B,gBAAgB;GAChB,uBAAuB;GACvB,eAAe;IACb,SAAS;IACT,uBAAuB;IACvB,UAAU,CAAC,YAAY,SAAS;IAChC,QAAQ;KAAC;KAAQ;KAAW;KAAe;KAAgB;KAAc;IACzE,SAAS,EAAE;IACZ;GACF;EACD,YAAY;GACV,OAAO,EAAE;GACT,UAAU;IACR,kBAAkB;IAClB,gBAAgB;IAChB,OAAO,EAAE;IACT,iBAAiB;IACjB,sBAAsB;IACvB;GACD,OAAO,EAAE;GACV;EACD,WAAW,EACT,SAAS,MACV;EACD,KAAK,EAAE;EAIR,CAAC"}
@@ -31,7 +31,10 @@ async function applyMiscPatch(config, body) {
31
31
  if (body.tui !== void 0) {
32
32
  if (typeof body.tui !== "object" || body.tui === null || Array.isArray(body.tui)) return patchError("tui must be an object");
33
33
  const tuiPatch = body.tui;
34
- if (tuiPatch.defaultAgent !== void 0) {
34
+ if (tuiPatch.defaultAgent !== void 0) if (tuiPatch.defaultAgent === null) {
35
+ config.tui = { ...config.tui };
36
+ delete config.tui.defaultAgent;
37
+ } else {
35
38
  if (typeof tuiPatch.defaultAgent !== "string" || !tuiPatch.defaultAgent.trim()) return patchError("tui.defaultAgent must be a non-empty string");
36
39
  const result = setTuiDefaultAgentConfig(config, tuiPatch.defaultAgent);
37
40
  if (result.ok === false) return patchError(result.message);