@xopcai/xopc 0.0.28 → 0.0.29

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 (160) hide show
  1. package/dist/extensions/telegram/xopc.extension.json +1 -1
  2. package/dist/gateway/static/root/assets/agents-CkgFSiCY.js +216 -0
  3. package/dist/gateway/static/root/assets/agents-CkgFSiCY.js.map +1 -0
  4. package/dist/gateway/static/root/assets/{apps-page-Co95hLOJ.js → apps-page-Bmq19MS-.js} +2 -2
  5. package/dist/gateway/static/root/assets/{apps-page-Co95hLOJ.js.map → apps-page-Bmq19MS-.js.map} +1 -1
  6. package/dist/gateway/static/root/assets/channels-settings-CE7jrdkO.js +9 -0
  7. package/dist/gateway/static/root/assets/channels-settings-CE7jrdkO.js.map +1 -0
  8. package/dist/gateway/static/root/assets/cron-page-BpPPcykJ.js +2 -0
  9. package/dist/gateway/static/root/assets/cron-page-BpPPcykJ.js.map +1 -0
  10. package/dist/gateway/static/root/assets/{cron-utils-BmzF4m1y.js → cron-utils-N1PqD2DB.js} +2 -2
  11. package/dist/gateway/static/root/assets/{cron-utils-BmzF4m1y.js.map → cron-utils-N1PqD2DB.js.map} +1 -1
  12. package/dist/gateway/static/root/assets/{dist-Dn-ufXyc.js → dist--p2HQ2QF.js} +2 -2
  13. package/dist/gateway/static/root/assets/{dist-Dn-ufXyc.js.map → dist--p2HQ2QF.js.map} +1 -1
  14. package/dist/gateway/static/root/assets/{extension-debug-page-BZ8xQ74_.js → extension-debug-page-DwHCB_6T.js} +2 -2
  15. package/dist/gateway/static/root/assets/{extension-debug-page-BZ8xQ74_.js.map → extension-debug-page-DwHCB_6T.js.map} +1 -1
  16. package/dist/gateway/static/root/assets/{extension-page-BlNgKxwW.js → extension-page-BsYwQIex.js} +2 -2
  17. package/dist/gateway/static/root/assets/{extension-page-BlNgKxwW.js.map → extension-page-BsYwQIex.js.map} +1 -1
  18. package/dist/gateway/static/root/assets/{extension-settings-page-CWTdW_oY.js → extension-settings-page-nsisEgjB.js} +2 -2
  19. package/dist/gateway/static/root/assets/{extension-settings-page-CWTdW_oY.js.map → extension-settings-page-nsisEgjB.js.map} +1 -1
  20. package/dist/gateway/static/root/assets/index-CR8zUHGR.js +4734 -0
  21. package/dist/gateway/static/root/assets/{index-lV8FGWlt.js.map → index-CR8zUHGR.js.map} +1 -1
  22. package/dist/gateway/static/root/assets/index-Dnfha4O2.css +1 -0
  23. package/dist/gateway/static/root/assets/logs-page-CQwdV_Xw.js +2 -0
  24. package/dist/gateway/static/root/assets/{logs-page-DG31RpvG.js.map → logs-page-CQwdV_Xw.js.map} +1 -1
  25. package/dist/gateway/static/root/assets/sessions-page-Be5kIGl_.js +2 -0
  26. package/dist/gateway/static/root/assets/sessions-page-Be5kIGl_.js.map +1 -0
  27. package/dist/gateway/static/root/assets/settings-page-PodSlNwr.js +2 -0
  28. package/dist/gateway/static/root/assets/settings-page-PodSlNwr.js.map +1 -0
  29. package/dist/gateway/static/root/assets/skills-page-Clg8deH0.js +3 -0
  30. package/dist/gateway/static/root/assets/{skills-page-lb7vYtlP.js.map → skills-page-Clg8deH0.js.map} +1 -1
  31. package/dist/gateway/static/root/index.html +2 -2
  32. package/dist/package.js +1 -1
  33. package/dist/src/agent/lifecycle/hook-handler.d.ts +2 -0
  34. package/dist/src/agent/lifecycle/hook-handler.js +24 -0
  35. package/dist/src/agent/lifecycle/hook-handler.js.map +1 -1
  36. package/dist/src/agent/messaging/command-handler.js +10 -2
  37. package/dist/src/agent/messaging/command-handler.js.map +1 -1
  38. package/dist/src/agent/service/process-direct-streaming.js +77 -20
  39. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  40. package/dist/src/agent/service.d.ts +15 -0
  41. package/dist/src/agent/service.js +21 -1
  42. package/dist/src/agent/service.js.map +1 -1
  43. package/dist/src/channels/index.js +2 -2
  44. package/dist/src/channels/manager.js +2 -2
  45. package/dist/src/cli/agent-chat-log-level-preset.d.ts +3 -2
  46. package/dist/src/cli/agent-chat-log-level-preset.js +6 -3
  47. package/dist/src/cli/agent-chat-log-level-preset.js.map +1 -1
  48. package/dist/src/cli/index.js +4 -3
  49. package/dist/src/cli/index.js.map +1 -1
  50. package/dist/src/config/schema.js +5 -2
  51. package/dist/src/config/schema.js.map +1 -1
  52. package/dist/src/extensions/hooks.js +5 -1
  53. package/dist/src/extensions/hooks.js.map +1 -1
  54. package/dist/src/extensions/loader.d.ts +1 -0
  55. package/dist/src/extensions/loader.js +3 -1
  56. package/dist/src/extensions/loader.js.map +1 -1
  57. package/dist/src/extensions/sdk/index.d.ts +1 -1
  58. package/dist/src/extensions/sdk/index.js.map +1 -1
  59. package/dist/src/extensions/types/core.d.ts +8 -0
  60. package/dist/src/extensions/types/hooks.d.ts +16 -1
  61. package/dist/src/extensions/types/hooks.js +1 -0
  62. package/dist/src/extensions/types/hooks.js.map +1 -1
  63. package/dist/src/gateway/agents-admin.d.ts +19 -1
  64. package/dist/src/gateway/agents-admin.js +164 -3
  65. package/dist/src/gateway/agents-admin.js.map +1 -1
  66. package/dist/src/gateway/hono/app.js +1 -0
  67. package/dist/src/gateway/hono/app.js.map +1 -1
  68. package/dist/src/gateway/hono/routes/agents.js +59 -5
  69. package/dist/src/gateway/hono/routes/agents.js.map +1 -1
  70. package/dist/src/gateway/hono/routes/config.js +2 -2
  71. package/dist/src/gateway/hono/routes/config.js.map +1 -1
  72. package/dist/src/gateway/hono/routes/public-gateway.js +1 -0
  73. package/dist/src/gateway/hono/routes/public-gateway.js.map +1 -1
  74. package/dist/src/gateway/hono/routes/sessions.js +17 -0
  75. package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
  76. package/dist/src/gateway/service.d.ts +2 -0
  77. package/dist/src/gateway/service.js +31 -4
  78. package/dist/src/gateway/service.js.map +1 -1
  79. package/dist/src/session/client-history.d.ts +21 -0
  80. package/dist/src/session/client-history.js +89 -0
  81. package/dist/src/session/client-history.js.map +1 -0
  82. package/dist/src/session/index.d.ts +1 -0
  83. package/dist/src/session/index.js +2 -1
  84. package/dist/src/session/manager.d.ts +2 -0
  85. package/dist/src/session/manager.js +5 -0
  86. package/dist/src/session/manager.js.map +1 -1
  87. package/dist/src/session/thinking-resolve.js +1 -1
  88. package/dist/src/session/thinking-resolve.js.map +1 -1
  89. package/dist/src/tui/backends/embedded-backend.d.ts +1 -1
  90. package/dist/src/tui/backends/embedded-backend.js +15 -2
  91. package/dist/src/tui/backends/embedded-backend.js.map +1 -1
  92. package/dist/src/tui/backends/gateway-sse-backend.d.ts +4 -0
  93. package/dist/src/tui/backends/gateway-sse-backend.js +34 -4
  94. package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
  95. package/dist/src/tui/chat-history.d.ts +4 -0
  96. package/dist/src/tui/chat-history.js +29 -0
  97. package/dist/src/tui/chat-history.js.map +1 -0
  98. package/dist/src/tui/components/chat-log.d.ts +3 -1
  99. package/dist/src/tui/components/chat-log.js +17 -3
  100. package/dist/src/tui/components/chat-log.js.map +1 -1
  101. package/dist/src/tui/components/custom-editor.d.ts +1 -0
  102. package/dist/src/tui/components/custom-editor.js +8 -2
  103. package/dist/src/tui/components/custom-editor.js.map +1 -1
  104. package/dist/src/tui/components/fuzzy-filter.d.ts +17 -0
  105. package/dist/src/tui/components/fuzzy-filter.js +85 -0
  106. package/dist/src/tui/components/fuzzy-filter.js.map +1 -0
  107. package/dist/src/tui/components/searchable-select-list.d.ts +39 -0
  108. package/dist/src/tui/components/searchable-select-list.js +257 -0
  109. package/dist/src/tui/components/searchable-select-list.js.map +1 -0
  110. package/dist/src/tui/theme.d.ts +2 -0
  111. package/dist/src/tui/theme.js +7 -1
  112. package/dist/src/tui/theme.js.map +1 -1
  113. package/dist/src/tui/tui-agent-events.d.ts +7 -0
  114. package/dist/src/tui/tui-agent-events.js +103 -0
  115. package/dist/src/tui/tui-agent-events.js.map +1 -0
  116. package/dist/src/tui/tui-backend.d.ts +8 -12
  117. package/dist/src/tui/tui-commands.d.ts +23 -0
  118. package/dist/src/tui/tui-commands.js +165 -0
  119. package/dist/src/tui/tui-commands.js.map +1 -0
  120. package/dist/src/tui/tui-lifecycle.d.ts +26 -0
  121. package/dist/src/tui/tui-lifecycle.js +57 -0
  122. package/dist/src/tui/tui-lifecycle.js.map +1 -0
  123. package/dist/src/tui/tui-local-shell.d.ts +28 -0
  124. package/dist/src/tui/tui-local-shell.js +147 -0
  125. package/dist/src/tui/tui-local-shell.js.map +1 -0
  126. package/dist/src/tui/tui-overlays.d.ts +8 -0
  127. package/dist/src/tui/tui-overlays.js +22 -0
  128. package/dist/src/tui/tui-overlays.js.map +1 -0
  129. package/dist/src/tui/tui-picker-overlay.d.ts +26 -0
  130. package/dist/src/tui/tui-picker-overlay.js +69 -0
  131. package/dist/src/tui/tui-picker-overlay.js.map +1 -0
  132. package/dist/src/tui/tui-stdio-filter.d.ts +17 -0
  133. package/dist/src/tui/tui-stdio-filter.js +96 -0
  134. package/dist/src/tui/tui-stdio-filter.js.map +1 -0
  135. package/dist/src/tui/tui-submit.d.ts +25 -0
  136. package/dist/src/tui/tui-submit.js +102 -0
  137. package/dist/src/tui/tui-submit.js.map +1 -0
  138. package/dist/src/tui/tui-suspend.d.ts +10 -0
  139. package/dist/src/tui/tui-suspend.js +18 -0
  140. package/dist/src/tui/tui-suspend.js.map +1 -0
  141. package/dist/src/tui/tui-types.d.ts +1 -0
  142. package/dist/src/tui/tui-types.js.map +1 -1
  143. package/dist/src/tui/tui.d.ts +2 -0
  144. package/dist/src/tui/tui.js +175 -312
  145. package/dist/src/tui/tui.js.map +1 -1
  146. package/package.json +2 -6
  147. package/dist/gateway/static/root/assets/agents-DplaQYS2.js +0 -216
  148. package/dist/gateway/static/root/assets/agents-DplaQYS2.js.map +0 -1
  149. package/dist/gateway/static/root/assets/channels-settings-CkfSST0k.js +0 -9
  150. package/dist/gateway/static/root/assets/channels-settings-CkfSST0k.js.map +0 -1
  151. package/dist/gateway/static/root/assets/cron-page-D9q6KqL8.js +0 -2
  152. package/dist/gateway/static/root/assets/cron-page-D9q6KqL8.js.map +0 -1
  153. package/dist/gateway/static/root/assets/index-OT4cGzon.css +0 -1
  154. package/dist/gateway/static/root/assets/index-lV8FGWlt.js +0 -4734
  155. package/dist/gateway/static/root/assets/logs-page-DG31RpvG.js +0 -2
  156. package/dist/gateway/static/root/assets/sessions-page-CdmjxDEM.js +0 -2
  157. package/dist/gateway/static/root/assets/sessions-page-CdmjxDEM.js.map +0 -1
  158. package/dist/gateway/static/root/assets/settings-page-DU2XLf5s.js +0 -2
  159. package/dist/gateway/static/root/assets/settings-page-DU2XLf5s.js.map +0 -1
  160. package/dist/gateway/static/root/assets/skills-page-lb7vYtlP.js +0 -3
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["pkg.version"],"sources":["../../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport './agent-chat-log-level-preset.js';\nimport { Command } from 'commander';\nimport { registry, createDefaultContext, type CLIContext } from './registry.js';\nimport pkg from '../../package.json' with { type: 'json' };\nimport { flushAndClose } from '../utils/logger.js'; // Import flushAndClose for graceful shutdown\nimport { registerExtensionCliCommands } from './bootstrap-extensions.js';\n\n// Import order determines display order in help\nimport './commands/setup.js';\nimport './commands/onboard.js';\nimport './commands/agent.js';\nimport './commands/tui.js';\nimport './commands/gateway.js';\nimport './commands/session.js';\nimport './commands/cron.js';\nimport './commands/config.js';\nimport './commands/doctor/index.js';\nimport './commands/image.js';\nimport './commands/channels.js';\nimport './commands/models.js';\nimport { registerExtensionCommands } from './commands/extension.js';\nimport './commands/auth.js';\nimport './commands/skills.js';\nimport './commands/update.js';\nimport './commands/logs.js';\nimport { registerAgentsCli } from './commands/agents.js';\n\n// Global parsed options - updated before each command\nexport let parsedOpts: { config?: string; workspace?: string; verbose?: boolean } = {};\n\nexport function getContextWithOpts(argv: string[] = process.argv): CLIContext {\n return createDefaultContext(argv, parsedOpts);\n}\n\n// Long-running commands that should not auto-exit\nconst LONG_RUNNING_COMMANDS = new Set(['gateway', 'agent', 'tui', 'extension:dev']);\n\nconst program = new Command()\n .name('xopc')\n .description('Ultra-Lightweight Personal AI Assistant')\n .version(pkg.version)\n .option('--verbose', 'Enable verbose logging', false)\n .option('--config <path>', 'Config file path')\n .option('--workspace <path>', 'Workspace directory');\n\n// Hook to capture parsed options before each command runs\nprogram.hook('preAction', (thisCommand) => {\n parsedOpts = thisCommand.opts();\n});\n\n// Hook to ensure process exits after command completion\nprogram.hook('postAction', async (thisCommand) => {\n // Get the actual subcommand being executed (not the root program name)\n const args = thisCommand.args;\n const subCommandName = args.length > 0 ? args[0] : thisCommand.name();\n\n // Skip long-running commands (gateway foreground, agent interactive mode)\n if (LONG_RUNNING_COMMANDS.has(subCommandName)) {\n // For agent command, only skip exit if interactive mode (-i) is used\n if (subCommandName === 'agent') {\n const hasInteractiveFlag = process.argv.includes('-i') || process.argv.includes('--interactive');\n if (!hasInteractiveFlag) {\n // Agent in non-interactive mode should exit normally\n await flushAndClose();\n process.exit(0);\n }\n }\n // Gateway or agent -i: don't exit\n return;\n }\n // For all other commands, flush logs and exit\n await flushAndClose();\n process.exit(0);\n});\n\n// Create initial context (will use env vars and defaults)\nconst ctx = getContextWithOpts(process.argv);\nregistry.install(program, ctx);\nregisterAgentsCli(program);\nregisterExtensionCommands(program);\n\n// Only parse if this is the main module being executed directly\n// Skip parsing when imported as module (e.g., in tests)\nconst isTestEnv = !!process.env.VITEST || !!process.env.TEST || !!process.env.NODE_ENV?.includes('test');\nconst isMainModule = !isTestEnv && import.meta.url.startsWith('file:');\n\nif (isMainModule) {\n // Filter out standalone '--' separator (passed by pnpm run -- <cmd>)\n // npm removes it automatically, pnpm passes it through\n const argv = process.argv.filter((arg, index) => {\n if (arg !== '--') return true;\n // Only filter '--' if it's the separator between script and command\n // (i.e., comes after the script name and before actual args)\n return index < 2; // Keep '--' if it's a script argument (index 0 or 1)\n });\n void registerExtensionCliCommands(program).then(() => {\n program.parse(argv);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;aA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MAAM,KAAK;GACnB"}
1
+ {"version":3,"file":"index.js","names":["pkg.version"],"sources":["../../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport './agent-chat-log-level-preset.js';\nimport { Command } from 'commander';\nimport { registry, createDefaultContext, type CLIContext } from './registry.js';\nimport pkg from '../../package.json' with { type: 'json' };\nimport { flushAndClose } from '../utils/logger.js'; // Import flushAndClose for graceful shutdown\nimport { registerExtensionCliCommands } from './bootstrap-extensions.js';\n\n// Import order determines display order in help\nimport './commands/setup.js';\nimport './commands/onboard.js';\nimport './commands/agent.js';\nimport './commands/tui.js';\nimport './commands/gateway.js';\nimport './commands/session.js';\nimport './commands/cron.js';\nimport './commands/config.js';\nimport './commands/doctor/index.js';\nimport './commands/image.js';\nimport './commands/channels.js';\nimport './commands/models.js';\nimport { registerExtensionCommands } from './commands/extension.js';\nimport './commands/auth.js';\nimport './commands/skills.js';\nimport './commands/update.js';\nimport './commands/logs.js';\nimport { registerAgentsCli } from './commands/agents.js';\n\n// Global parsed options - updated before each command\nexport let parsedOpts: { config?: string; workspace?: string; verbose?: boolean } = {};\n\nexport function getContextWithOpts(argv: string[] = process.argv): CLIContext {\n return createDefaultContext(argv, parsedOpts);\n}\n\n// Long-running commands that should not auto-exit\nconst LONG_RUNNING_COMMANDS = new Set(['gateway', 'agent', 'tui', 'extension:dev']);\n\nconst program = new Command()\n .name('xopc')\n .description('Ultra-Lightweight Personal AI Assistant')\n .version(pkg.version)\n .option('--verbose', 'Enable verbose logging', false)\n .option('--config <path>', 'Config file path')\n .option('--workspace <path>', 'Workspace directory');\n\n// Hook to capture parsed options before each command runs\nprogram.hook('preAction', (thisCommand) => {\n parsedOpts = thisCommand.opts();\n});\n\n// Hook to ensure process exits after command completion\n// Second arg is the command whose action ran; the first is the ancestor that registered the hook\n// (often the root program), so using only the first arg mis-detects the subcommand as \"xopc\".\nprogram.hook('postAction', async (_hookOwner, actionCommand) => {\n const cmd = actionCommand ?? program;\n const args = cmd.args;\n const subCommandName = args.length > 0 ? args[0] : cmd.name();\n\n // Skip long-running commands (gateway foreground, agent interactive mode)\n if (LONG_RUNNING_COMMANDS.has(subCommandName)) {\n // For agent command, only skip exit if interactive mode (-i) is used\n if (subCommandName === 'agent') {\n const hasInteractiveFlag = process.argv.includes('-i') || process.argv.includes('--interactive');\n if (!hasInteractiveFlag) {\n // Agent in non-interactive mode should exit normally\n await flushAndClose();\n process.exit(0);\n }\n }\n // Gateway or agent -i: don't exit\n return;\n }\n // For all other commands, flush logs and exit\n await flushAndClose();\n process.exit(0);\n});\n\n// Create initial context (will use env vars and defaults)\nconst ctx = getContextWithOpts(process.argv);\nregistry.install(program, ctx);\nregisterAgentsCli(program);\nregisterExtensionCommands(program);\n\n// Only parse if this is the main module being executed directly\n// Skip parsing when imported as module (e.g., in tests)\nconst isTestEnv = !!process.env.VITEST || !!process.env.TEST || !!process.env.NODE_ENV?.includes('test');\nconst isMainModule = !isTestEnv && import.meta.url.startsWith('file:');\n\nif (isMainModule) {\n // Filter out standalone '--' separator (passed by pnpm run -- <cmd>)\n // npm removes it automatically, pnpm passes it through\n const argv = process.argv.filter((arg, index) => {\n if (arg !== '--') return true;\n // Only filter '--' if it's the separator between script and command\n // (i.e., comes after the script name and before actual args)\n return index < 2; // Keep '--' if it's a script argument (index 0 or 1)\n });\n void registerExtensionCliCommands(program).then(() => {\n program.parse(argv);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;aAKmD;AAwBnD,IAAW,aAAyE,EAAE;AAEtF,SAAgB,mBAAmB,OAAiB,QAAQ,MAAkB;AAC5E,QAAO,qBAAqB,MAAM,WAAW;;AAI/C,MAAM,wBAAwB,IAAI,IAAI;CAAC;CAAW;CAAS;CAAO;CAAgB,CAAC;AAEnF,MAAM,UAAU,IAAI,SAAS,CAC1B,KAAK,OAAO,CACZ,YAAY,0CAA0C,CACtD,QAAQA,QAAY,CACpB,OAAO,aAAa,0BAA0B,MAAM,CACpD,OAAO,mBAAmB,mBAAmB,CAC7C,OAAO,sBAAsB,sBAAsB;AAGtD,QAAQ,KAAK,cAAc,gBAAgB;AACzC,cAAa,YAAY,MAAM;EAC/B;AAKF,QAAQ,KAAK,cAAc,OAAO,YAAY,kBAAkB;CAC9D,MAAM,MAAM,iBAAiB;CAC7B,MAAM,OAAO,IAAI;CACjB,MAAM,iBAAiB,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,MAAM;AAG7D,KAAI,sBAAsB,IAAI,eAAe,EAAE;AAE7C,MAAI,mBAAmB;OAEjB,EADuB,QAAQ,KAAK,SAAS,KAAK,IAAI,QAAQ,KAAK,SAAS,gBAAgB,GACvE;AAEvB,UAAM,eAAe;AACrB,YAAQ,KAAK,EAAE;;;AAInB;;AAGF,OAAM,eAAe;AACrB,SAAQ,KAAK,EAAE;EACf;AAGF,MAAM,MAAM,mBAAmB,QAAQ,KAAK;AAC5C,SAAS,QAAQ,SAAS,IAAI;AAC9B,kBAAkB,QAAQ;AAC1B,0BAA0B,QAAQ;AAOlC,IAFqB,EADH,CAAC,CAAC,QAAQ,IAAI,UAAU,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAA,cAAuB,SAAS,OAAO,KACrE,OAAO,KAAK,IAAI,WAAW,QAAQ,EAEpD;CAGhB,MAAM,OAAO,QAAQ,KAAK,QAAQ,KAAK,UAAU;AAC/C,MAAI,QAAQ,KAAM,QAAO;AAGzB,SAAO,QAAQ;GACf;AACG,8BAA6B,QAAQ,CAAC,WAAW;AACpD,UAAQ,MAAM,KAAK;GACnB"}
@@ -259,6 +259,9 @@ summaryModel: z.string().optional() }).optional(),
259
259
  maxToolIterations: 20,
260
260
  maxRequestsPerTurn: 50,
261
261
  maxToolFailuresPerTurn: 3,
262
+ thinkingDefault: "medium",
263
+ reasoningDefault: "stream",
264
+ verboseDefault: "full",
262
265
  compaction: {
263
266
  enabled: true,
264
267
  mode: "default",
@@ -562,8 +565,8 @@ summaryModel: z.string().optional() }).optional(),
562
565
  maxRequestsPerTurn: 50,
563
566
  maxToolFailuresPerTurn: 3,
564
567
  thinkingDefault: "medium",
565
- reasoningDefault: "off",
566
- verboseDefault: "off",
568
+ reasoningDefault: "stream",
569
+ verboseDefault: "full",
567
570
  compaction: {
568
571
  enabled: true,
569
572
  mode: "default",
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../../../src/config/schema.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport { getDefaultWorkspacePath } from '../agent/agent-scope.js';\n\n// ============================================\n// Agent Configs\n// ============================================\n\nexport const AgentModelRefSchema = z.union([\n z.string(),\n z\n .object({\n primary: z.string().optional(),\n fallbacks: z.array(z.string()).optional(),\n })\n .strict(),\n]);\n\nexport type AgentModelConfig = z.infer<typeof AgentModelRefSchema>;\n\nexport const AgentDefaultsSchema = z.object({\n /** Parent directory: each agent’s Markdown root is `<expanded>/<agentId>/` (e.g. `.../workspace/main`). */\n workspace: z.string().default('~/.xopc/workspace'),\n model: z.union([\n z.string(),\n z.object({\n primary: z.string().optional(),\n fallbacks: z.array(z.string()).optional(),\n }).strict(),\n ]).default(''), // Empty default - will be resolved dynamically at runtime\n /** Vision / image understanding model (provider/model). Falls back to heuristics when unset. */\n imageModel: AgentModelRefSchema.optional(),\n /** Image generation model (provider/model), e.g. openai/gpt-image-1. Thin REST wrapper; OpenAI supported. */\n imageGenerationModel: AgentModelRefSchema.optional(),\n /** Max image size for image tool loads (MB). */\n mediaMaxMb: z.number().positive().optional(),\n maxTokens: z.number().default(8192),\n temperature: z.number().default(0.7),\n maxToolIterations: z.number().default(20),\n // Wall-clock limit for one user turn (LLM + tools). Default 30m if unset; cap 4h.\n maxTaskDurationMs: z.number().min(60000).max(14_400_000).optional(),\n // Reliability settings\n maxRequestsPerTurn: z.number().min(10).max(200).default(50),\n maxToolFailuresPerTurn: z.number().min(1).max(20).default(3),\n // Thinking ability settings\n thinkingDefault: z.enum(['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'adaptive']).optional(),\n reasoningDefault: z.enum(['off', 'on', 'stream']).optional(),\n verboseDefault: z.enum(['off', 'on', 'full']).optional(),\n compaction: z.object({\n enabled: z.boolean().default(true),\n mode: z.enum(['default', 'safeguard']).default('default'),\n reserveTokens: z.number().default(8000),\n triggerThreshold: z.number().min(0.5).max(0.95).default(0.8),\n minMessagesBeforeCompact: z.number().default(10),\n keepRecentMessages: z.number().default(5),\n // Dual-strategy compaction\n evictionWindow: z.number().min(0.1).max(0.5).default(0.2),\n retentionWindow: z.number().min(3).max(20).default(6),\n }).optional(),\n pruning: z.object({\n enabled: z.boolean().default(true),\n maxToolResultChars: z.number().default(10000),\n headKeepRatio: z.number().default(0.3),\n tailKeepRatio: z.number().default(0.3),\n }).optional(),\n /**\n * Curated memory (`agents/<id>/memories/`) + pluggable external provider.\n * Only one external provider at a time.\n */\n memory: z\n .object({\n /** Master switch: curated snapshot, `curated_memory`, prefetch, and external provider. Default true. */\n enabled: z.boolean().optional(),\n /** When false, use workspace bootstrap only (no curated snapshot / tool). Default true. */\n useEnhancedSystem: z.boolean().optional(),\n /** Include USER.md in snapshot. Default true. */\n userProfileEnabled: z.boolean().optional(),\n memoryCharLimit: z.number().positive().optional(),\n userCharLimit: z.number().positive().optional(),\n provider: z.enum(['none', 'stub']).optional(),\n /** How often prefetched external memory is injected into the user message. */\n injectionFrequency: z.enum(['every-turn', 'first-turn']).optional(),\n /** Inject prefetch on turns 1, 1+N, 1+2N, … (only when injectionFrequency is every-turn). Min 1. */\n contextCadence: z.number().int().min(1).optional(),\n /** Reserved for future external “dialectic” sync cadence (not wired yet). */\n dialecticCadence: z.number().int().min(1).optional(),\n /**\n * Background memory consolidation (\"dreaming\"): three-phase sleep model that\n * promotes short-term recall signals into long-term memory (`MEMORY.md`).\n *\n * Phases:\n * - **light** — fast, frequent sweep (default every 6 h): dedup + signal collection.\n * - **deep** — daily deep promotion (default 3 AM): score-gated write to MEMORY.md.\n * - **rem** — weekly pattern discovery (default Sun 5 AM): cross-session insight mining.\n */\n dreaming: z\n .object({\n enabled: z.boolean().optional(),\n /** Legacy top-level cron; prefer per-phase `cron` instead. */\n frequency: z.string().optional(),\n timezone: z.string().optional(),\n phases: z\n .object({\n light: z\n .object({\n enabled: z.boolean().optional(),\n cron: z.string().optional(),\n lookbackDays: z.number().int().min(1).optional(),\n limit: z.number().int().min(0).optional(),\n dedupeSimilarity: z.number().min(0).max(1).optional(),\n })\n .optional(),\n deep: z\n .object({\n enabled: z.boolean().optional(),\n cron: z.string().optional(),\n minScore: z.number().min(0).max(1).optional(),\n minRecallCount: z.number().int().min(1).optional(),\n minUniqueQueries: z.number().int().min(1).optional(),\n limit: z.number().int().min(0).optional(),\n recencyHalfLifeDays: z.number().min(1).optional(),\n maxAgeDays: z.number().int().min(1).optional(),\n })\n .optional(),\n rem: z\n .object({\n enabled: z.boolean().optional(),\n cron: z.string().optional(),\n lookbackDays: z.number().int().min(1).optional(),\n limit: z.number().int().min(0).optional(),\n minPatternStrength: z.number().min(0).max(1).optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional(),\n /** Cross-session transcript search (`session_search` tool). */\n sessionSearch: z\n .object({\n /** Model ref for per-session summaries (e.g. openai/gpt-4o-mini). */\n summaryModel: z.string().optional(),\n })\n .optional(),\n /**\n * Post-turn background review (Hermes-style): optional quiet follow-up that may call\n * `curated_memory` / `skill_manage` so durable facts and reusable workflows persist\n * without bloating the main user-visible turn.\n */\n backgroundReview: z\n .object({\n /** When true, nudges may run after successful turns. Default false (opt-in). */\n enabled: z.boolean().optional(),\n /** User-turn cadence for memory review. 0 disables the memory channel. Default 10. */\n memoryNudgeInterval: z.number().int().min(0).optional(),\n /** LLM rounds without `skill_manage` before a skill review. 0 disables the skill channel. Default 10. */\n skillNudgeInterval: z.number().int().min(0).optional(),\n /** Max tool executions for the review agent. Default 8. */\n maxToolRounds: z.number().int().min(1).max(32).optional(),\n /** Max prior messages passed into the review context (tail). Default 80. */\n maxHistoryMessages: z.number().int().min(10).max(200).optional(),\n /** Wall-clock cap for the review run (ms). Default 120000. */\n maxDurationMs: z.number().int().min(30_000).max(600_000).optional(),\n })\n .optional(),\n /** LLM pass for `web_extract` (markdown-focused extraction). */\n webExtract: z\n .object({\n model: z.string().optional(),\n maxLength: z.number().positive().optional(),\n })\n .optional(),\n /**\n * Headless Playwright tools (`browser_*`). Opt-in. Install browsers once: `npx playwright install chromium`.\n */\n browser: z\n .object({\n enabled: z.boolean().optional(),\n /** Default true when browser tools are enabled. */\n headless: z.boolean().optional(),\n })\n .optional(),\n /** Sub-agent delegation (`delegate_task`). Opt-in. */\n delegate: z\n .object({\n enabled: z.boolean().optional(),\n })\n .optional(),\n /** Sandboxed `execute_code` (programmatic tool calls). Opt-in. */\n executeCode: z\n .object({\n enabled: z.boolean().optional(),\n })\n .optional(),\n /** Optional full system prompt replacement (merged with per-agent entry; entry wins). */\n systemPromptOverride: z.string().optional(),\n /** Optional allowlist of skill names for `<available_skills>`; when set, replaces unfiltered list. */\n skills: z.array(z.string()).optional(),\n /** Disable built-in tools by name (e.g. `shell`, `web_search`). */\n tools: z\n .object({\n disable: z.array(z.string()).optional(),\n })\n .optional(),\n /** Opaque per-process params (reserved for extensions / future use). */\n params: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport const AgentConfigSchema = z.object({\n id: z.string(),\n /** When true, this entry is the default routing agent. */\n default: z.boolean().optional(),\n name: z.string().optional(),\n /** Short human-readable summary for UIs (gateway console, pickers). */\n description: z.string().max(4000).optional(),\n enabled: z.boolean().default(true),\n /** Per-agent workspace root (`~` expanded at runtime). */\n workspace: z.string().optional(),\n /**\n * Internal agent state directory (`…/credentials`, `agent.json`, pid, inbox).\n * Default: `<stateDir>/agents/<id>/agent`.\n */\n agentDir: z.string().optional(),\n model: AgentModelRefSchema.optional(),\n thinkingDefault: z.enum(['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'adaptive']).optional(),\n reasoningDefault: z.enum(['off', 'on', 'stream']).optional(),\n verboseDefault: z.enum(['off', 'on', 'full']).optional(),\n systemPromptOverride: z.string().optional(),\n skills: z.array(z.string()).optional(),\n tools: z\n .object({\n disable: z.array(z.string()).optional(),\n })\n .optional(),\n params: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport const AgentsConfigSchema = z.object({\n /** Default agent id when not specified (routing / session creation). */\n default: z.string().optional(),\n defaults: AgentDefaultsSchema.optional(),\n list: z.array(AgentConfigSchema).optional(),\n}).default({\n defaults: {\n workspace: '~/.xopc/workspace',\n model: '', // Empty default - will be resolved dynamically at runtime\n maxTokens: 8192,\n temperature: 0.7,\n maxToolIterations: 20,\n maxRequestsPerTurn: 50,\n maxToolFailuresPerTurn: 3,\n compaction: {\n enabled: true,\n mode: 'default',\n reserveTokens: 8000,\n triggerThreshold: 0.8,\n minMessagesBeforeCompact: 10,\n keepRecentMessages: 5,\n evictionWindow: 0.2,\n retentionWindow: 6,\n },\n pruning: {\n enabled: true,\n maxToolResultChars: 10000,\n headKeepRatio: 0.3,\n tailKeepRatio: 0.3,\n },\n },\n} as any);\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// ============================================\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 SessionConfigSchema = z.object({\n dmScope: SessionDmScopeSchema.default('main'),\n identityLinks: z.record(z.string(), z.array(z.string())).optional(),\n storage: SessionStorageConfigSchema.optional(),\n}).default({\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 telegram: {\n enabled: false,\n botToken: '',\n allowFrom: [],\n groupAllowFrom: [],\n debug: false,\n dmPolicy: 'pairing' as const,\n groupPolicy: 'open' as const,\n replyToMode: 'off' as const,\n historyLimit: 50,\n textChunkLimit: 4000,\n },\n});\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 WebToolsConfigSchema = z.object({\n /** Search result HTML fallback: cn → Bing, otherwise DuckDuckGo */\n region: z.enum(['cn', 'global']).optional(),\n search: WebSearchConfigSchema.optional(),\n});\n\nexport type WebToolsConfig = z.infer<typeof WebToolsConfigSchema>;\n\nexport const ToolsConfigSchema = z.object({\n web: WebToolsConfigSchema.optional(),\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 })\n .optional();\n\nexport const GatewayAuthSchema = z\n .object({\n mode: z.enum(['none', 'token', 'password']).default('token'),\n token: z.string().optional(),\n password: z.string().optional(),\n rateLimit: GatewayAuthRateLimitSchema,\n })\n .default({\n mode: 'token',\n });\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 GatewayConfigSchema = z.object({\n host: z.string().optional(),\n port: z.number().optional(),\n auth: GatewayAuthSchema.optional(),\n heartbeat: HeartbeatConfigSchema.optional(),\n maxSseConnections: z.number().optional(),\n corsOrigins: z.array(z.string()).optional(),\n /** Base URL for the xopc skills marketplace (public REST API). */\n skillsStoreBaseUrl: z.string().url().optional(),\n}).default({\n host: '127.0.0.1',\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 skillsStoreBaseUrl: 'https://store.xopc.ai',\n});\n\nexport const CronConfigSchema = z.object({\n enabled: z.boolean().optional(),\n maxConcurrentJobs: z.number().optional(),\n defaultTimezone: z.string().optional(),\n historyRetentionDays: z.number().optional(),\n enableMetrics: z.boolean().optional(),\n}).default({\n enabled: true,\n maxConcurrentJobs: 5,\n defaultTimezone: 'UTC',\n historyRetentionDays: 7,\n enableMetrics: true,\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\nexport const STTProviderConfigSchema = z.object({\n apiKey: z.string().optional(),\n model: z.string().optional(),\n});\n\nexport const STTFallbackConfigSchema = z.object({\n enabled: z.boolean().default(true),\n order: z.array(z.enum(['alibaba', 'openai'])).default(['alibaba', 'openai']),\n});\n\nexport const STTConfigSchema = z.object({\n enabled: z.boolean().default(false),\n provider: z.enum(['alibaba', 'openai']).default('alibaba'),\n alibaba: STTProviderConfigSchema.optional(),\n openai: STTProviderConfigSchema.optional(),\n fallback: STTFallbackConfigSchema.optional(),\n});\n\n// ============================================\n// TTS (Text-to-Speech) Config\n// ============================================\n\nexport const TTSProviderConfigSchema = z.object({\n apiKey: z.string().optional(),\n model: z.string().optional(),\n voice: z.string().optional(),\n});\n\nexport const TTSFallbackConfigSchema = z.object({\n enabled: z.boolean().default(true),\n order: z\n .array(z.enum(['openai', 'alibaba', 'edge', 'minimax']))\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.object({\n enabled: z.boolean().default(false),\n provider: z.enum(['openai', 'alibaba', 'edge', 'minimax']).default('openai'),\n trigger: z\n .preprocess(\n (v) => (v === 'auto' ? 'inbound' : v),\n z.enum(['off', 'always', 'inbound', 'tagged']).default('always'),\n ),\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 alibaba: TTSProviderConfigSchema.optional(),\n openai: TTSProviderConfigSchema.optional(),\n edge: TTSEdgeConfigSchema.optional(),\n minimax: TTSProviderConfigSchema.optional(),\n});\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\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\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 tools: ToolsConfigSchema,\n cron: CronConfigSchema,\n extensions: ExtensionsConfigSchema.default({}),\n modelsDev: ModelsDevConfigSchema,\n stt: STTConfigSchema.optional(),\n tts: TTSConfigSchema.optional(),\n update: UpdateConfigSchema,\n}).default({\n agents: {\n defaults: {\n workspace: '~/.xopc/workspace',\n model: '', // Empty default - will be resolved dynamically at runtime\n maxTokens: 8192,\n temperature: 0.7,\n maxToolIterations: 20,\n maxRequestsPerTurn: 50,\n maxToolFailuresPerTurn: 3,\n thinkingDefault: 'medium',\n reasoningDefault: 'off',\n verboseDefault: 'off',\n compaction: {\n enabled: true,\n mode: 'default',\n reserveTokens: 8000,\n triggerThreshold: 0.8,\n minMessagesBeforeCompact: 10,\n keepRecentMessages: 5,\n evictionWindow: 0.2,\n retentionWindow: 6,\n },\n pruning: {\n enabled: true,\n maxToolResultChars: 10000,\n headKeepRatio: 0.3,\n tailKeepRatio: 0.3,\n },\n },\n },\n bindings: [],\n session: {\n dmScope: 'main' as const,\n },\n channels: {\n telegram: {\n enabled: false,\n botToken: '',\n allowFrom: [],\n groupAllowFrom: [],\n debug: false,\n dmPolicy: 'pairing' as const,\n groupPolicy: 'open' as const,\n replyToMode: 'off' as const,\n historyLimit: 50,\n textChunkLimit: 4000,\n },\n },\n gateway: {\n host: '127.0.0.1',\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 skillsStoreBaseUrl: 'https://store.xopc.ai',\n },\n tools: {\n web: {\n search: {\n maxResults: 5,\n providers: [],\n },\n },\n },\n cron: {\n enabled: true,\n maxConcurrentJobs: 5,\n defaultTimezone: 'UTC',\n historyRetentionDays: 7,\n enableMetrics: true,\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 stt: {\n enabled: false,\n provider: 'alibaba',\n alibaba: {\n model: 'paraformer-v2',\n },\n openai: {\n model: 'whisper-1',\n },\n fallback: {\n enabled: true,\n order: ['alibaba', 'openai'],\n },\n },\n tts: {\n enabled: false,\n provider: 'openai',\n trigger: 'always',\n fallback: {\n enabled: true,\n order: ['openai', 'alibaba', 'minimax', 'edge'],\n },\n maxTextLength: 4096,\n timeoutMs: 30000,\n modelOverrides: {\n enabled: true,\n allowText: true,\n allowProvider: false,\n allowVoice: true,\n allowModelId: true,\n allowVoiceSettings: false,\n allowNormalization: false,\n allowSeed: false,\n },\n alibaba: {\n model: 'qwen-tts',\n voice: 'Cherry',\n },\n openai: {\n model: 'tts-1',\n voice: 'alloy',\n },\n edge: {\n enabled: true,\n voice: 'en-US-MichelleNeural',\n lang: 'en-US',\n outputFormat: 'audio-24khz-48kbitrate-mono-mp3',\n },\n minimax: {\n model: 'speech-2.8-hd',\n voice: 'male-qn-qingse',\n },\n },\n});\n\nexport type Config = z.infer<typeof ConfigSchema>;\nexport type AgentDefaults = z.infer<typeof AgentDefaultsSchema>;\nexport type GatewayAuthConfig = z.infer<typeof GatewayAuthSchema>;\nexport type GatewayAuthRateLimitConfig = z.infer<typeof GatewayAuthRateLimitSchema>;\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\n/**\n * Default agent’s resolved Markdown workspace root (`resolveAgentWorkspaceDir` for the default agent id).\n */\nexport function getWorkspacePath(config: Config): string {\n return getDefaultWorkspacePath(config);\n}\n\n/**\n * Primary model ref from `agents.defaults.model` (string or `{ primary }`).\n * Returns undefined when unset or empty.\n */\nexport function getAgentDefaultModelRef(config: Config): string | undefined {\n const raw = config.agents?.defaults?.model;\n if (raw === undefined || raw === null) return undefined;\n const ref = typeof raw === 'string' ? raw : raw.primary;\n if (ref === undefined || ref === null) return undefined;\n const s = String(ref).trim();\n return s ? s : undefined;\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":";;;;;;;;;AA2yBA,SAAgB,iBAAiB,QAAwB;AACvD,QAAO,wBAAwB,OAAO;;;;;;AAOxC,SAAgB,wBAAwB,QAAoC;CAC1E,MAAM,MAAM,OAAO,QAAQ,UAAU;AACrC,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAAM,QAAO,KAAA;CAC9C,MAAM,MAAM,OAAO,QAAQ,WAAW,MAAM,IAAI;AAChD,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAAM,QAAO,KAAA;CAC9C,MAAM,IAAI,OAAO,IAAI,CAAC,MAAM;AAC5B,QAAO,IAAI,IAAI,KAAA;;;AAIjB,SAAgB,cAAc,KAAoC;CAChE,MAAM,UAAU,IAAI,MAAM;CAC1B,MAAM,MAAM,QAA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IACN,OAAO;IACP,OAAO;IACR;GACD,MAAM;IACJ,SAAS;IACT,OAAO;IACP,MAAM;IACN,cAAc;IACf;GACD,SAAS;IACP,OAAO;IACP,OAAO;IACR;GACF;EACF,CAAC"}
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../../src/config/schema.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport { getDefaultWorkspacePath } from '../agent/agent-scope.js';\n\n// ============================================\n// Agent Configs\n// ============================================\n\nexport const AgentModelRefSchema = z.union([\n z.string(),\n z\n .object({\n primary: z.string().optional(),\n fallbacks: z.array(z.string()).optional(),\n })\n .strict(),\n]);\n\nexport type AgentModelConfig = z.infer<typeof AgentModelRefSchema>;\n\nexport const AgentDefaultsSchema = z.object({\n /** Parent directory: each agent’s Markdown root is `<expanded>/<agentId>/` (e.g. `.../workspace/main`). */\n workspace: z.string().default('~/.xopc/workspace'),\n model: z.union([\n z.string(),\n z.object({\n primary: z.string().optional(),\n fallbacks: z.array(z.string()).optional(),\n }).strict(),\n ]).default(''), // Empty default - will be resolved dynamically at runtime\n /** Vision / image understanding model (provider/model). Falls back to heuristics when unset. */\n imageModel: AgentModelRefSchema.optional(),\n /** Image generation model (provider/model), e.g. openai/gpt-image-1. Thin REST wrapper; OpenAI supported. */\n imageGenerationModel: AgentModelRefSchema.optional(),\n /** Max image size for image tool loads (MB). */\n mediaMaxMb: z.number().positive().optional(),\n maxTokens: z.number().default(8192),\n temperature: z.number().default(0.7),\n maxToolIterations: z.number().default(20),\n // Wall-clock limit for one user turn (LLM + tools). Default 30m if unset; cap 4h.\n maxTaskDurationMs: z.number().min(60000).max(14_400_000).optional(),\n // Reliability settings\n maxRequestsPerTurn: z.number().min(10).max(200).default(50),\n maxToolFailuresPerTurn: z.number().min(1).max(20).default(3),\n // Thinking ability settings\n thinkingDefault: z.enum(['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'adaptive']).optional(),\n reasoningDefault: z.enum(['off', 'on', 'stream']).optional(),\n verboseDefault: z.enum(['off', 'on', 'full']).optional(),\n compaction: z.object({\n enabled: z.boolean().default(true),\n mode: z.enum(['default', 'safeguard']).default('default'),\n reserveTokens: z.number().default(8000),\n triggerThreshold: z.number().min(0.5).max(0.95).default(0.8),\n minMessagesBeforeCompact: z.number().default(10),\n keepRecentMessages: z.number().default(5),\n // Dual-strategy compaction\n evictionWindow: z.number().min(0.1).max(0.5).default(0.2),\n retentionWindow: z.number().min(3).max(20).default(6),\n }).optional(),\n pruning: z.object({\n enabled: z.boolean().default(true),\n maxToolResultChars: z.number().default(10000),\n headKeepRatio: z.number().default(0.3),\n tailKeepRatio: z.number().default(0.3),\n }).optional(),\n /**\n * Curated memory (`agents/<id>/memories/`) + pluggable external provider.\n * Only one external provider at a time.\n */\n memory: z\n .object({\n /** Master switch: curated snapshot, `curated_memory`, prefetch, and external provider. Default true. */\n enabled: z.boolean().optional(),\n /** When false, use workspace bootstrap only (no curated snapshot / tool). Default true. */\n useEnhancedSystem: z.boolean().optional(),\n /** Include USER.md in snapshot. Default true. */\n userProfileEnabled: z.boolean().optional(),\n memoryCharLimit: z.number().positive().optional(),\n userCharLimit: z.number().positive().optional(),\n provider: z.enum(['none', 'stub']).optional(),\n /** How often prefetched external memory is injected into the user message. */\n injectionFrequency: z.enum(['every-turn', 'first-turn']).optional(),\n /** Inject prefetch on turns 1, 1+N, 1+2N, … (only when injectionFrequency is every-turn). Min 1. */\n contextCadence: z.number().int().min(1).optional(),\n /** Reserved for future external “dialectic” sync cadence (not wired yet). */\n dialecticCadence: z.number().int().min(1).optional(),\n /**\n * Background memory consolidation (\"dreaming\"): three-phase sleep model that\n * promotes short-term recall signals into long-term memory (`MEMORY.md`).\n *\n * Phases:\n * - **light** — fast, frequent sweep (default every 6 h): dedup + signal collection.\n * - **deep** — daily deep promotion (default 3 AM): score-gated write to MEMORY.md.\n * - **rem** — weekly pattern discovery (default Sun 5 AM): cross-session insight mining.\n */\n dreaming: z\n .object({\n enabled: z.boolean().optional(),\n /** Legacy top-level cron; prefer per-phase `cron` instead. */\n frequency: z.string().optional(),\n timezone: z.string().optional(),\n phases: z\n .object({\n light: z\n .object({\n enabled: z.boolean().optional(),\n cron: z.string().optional(),\n lookbackDays: z.number().int().min(1).optional(),\n limit: z.number().int().min(0).optional(),\n dedupeSimilarity: z.number().min(0).max(1).optional(),\n })\n .optional(),\n deep: z\n .object({\n enabled: z.boolean().optional(),\n cron: z.string().optional(),\n minScore: z.number().min(0).max(1).optional(),\n minRecallCount: z.number().int().min(1).optional(),\n minUniqueQueries: z.number().int().min(1).optional(),\n limit: z.number().int().min(0).optional(),\n recencyHalfLifeDays: z.number().min(1).optional(),\n maxAgeDays: z.number().int().min(1).optional(),\n })\n .optional(),\n rem: z\n .object({\n enabled: z.boolean().optional(),\n cron: z.string().optional(),\n lookbackDays: z.number().int().min(1).optional(),\n limit: z.number().int().min(0).optional(),\n minPatternStrength: z.number().min(0).max(1).optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional(),\n /** Cross-session transcript search (`session_search` tool). */\n sessionSearch: z\n .object({\n /** Model ref for per-session summaries (e.g. openai/gpt-4o-mini). */\n summaryModel: z.string().optional(),\n })\n .optional(),\n /**\n * Post-turn background review (Hermes-style): optional quiet follow-up that may call\n * `curated_memory` / `skill_manage` so durable facts and reusable workflows persist\n * without bloating the main user-visible turn.\n */\n backgroundReview: z\n .object({\n /** When true, nudges may run after successful turns. Default false (opt-in). */\n enabled: z.boolean().optional(),\n /** User-turn cadence for memory review. 0 disables the memory channel. Default 10. */\n memoryNudgeInterval: z.number().int().min(0).optional(),\n /** LLM rounds without `skill_manage` before a skill review. 0 disables the skill channel. Default 10. */\n skillNudgeInterval: z.number().int().min(0).optional(),\n /** Max tool executions for the review agent. Default 8. */\n maxToolRounds: z.number().int().min(1).max(32).optional(),\n /** Max prior messages passed into the review context (tail). Default 80. */\n maxHistoryMessages: z.number().int().min(10).max(200).optional(),\n /** Wall-clock cap for the review run (ms). Default 120000. */\n maxDurationMs: z.number().int().min(30_000).max(600_000).optional(),\n })\n .optional(),\n /** LLM pass for `web_extract` (markdown-focused extraction). */\n webExtract: z\n .object({\n model: z.string().optional(),\n maxLength: z.number().positive().optional(),\n })\n .optional(),\n /**\n * Headless Playwright tools (`browser_*`). Opt-in. Install browsers once: `npx playwright install chromium`.\n */\n browser: z\n .object({\n enabled: z.boolean().optional(),\n /** Default true when browser tools are enabled. */\n headless: z.boolean().optional(),\n })\n .optional(),\n /** Sub-agent delegation (`delegate_task`). Opt-in. */\n delegate: z\n .object({\n enabled: z.boolean().optional(),\n })\n .optional(),\n /** Sandboxed `execute_code` (programmatic tool calls). Opt-in. */\n executeCode: z\n .object({\n enabled: z.boolean().optional(),\n })\n .optional(),\n /** Optional full system prompt replacement (merged with per-agent entry; entry wins). */\n systemPromptOverride: z.string().optional(),\n /** Optional allowlist of skill names for `<available_skills>`; when set, replaces unfiltered list. */\n skills: z.array(z.string()).optional(),\n /** Disable built-in tools by name (e.g. `shell`, `web_search`). */\n tools: z\n .object({\n disable: z.array(z.string()).optional(),\n })\n .optional(),\n /** Opaque per-process params (reserved for extensions / future use). */\n params: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport const AgentConfigSchema = z.object({\n id: z.string(),\n /** When true, this entry is the default routing agent. */\n default: z.boolean().optional(),\n name: z.string().optional(),\n /** Short human-readable summary for UIs (gateway console, pickers). */\n description: z.string().max(4000).optional(),\n enabled: z.boolean().default(true),\n /** Per-agent workspace root (`~` expanded at runtime). */\n workspace: z.string().optional(),\n /**\n * Internal agent state directory (`…/credentials`, `agent.json`, pid, inbox).\n * Default: `<stateDir>/agents/<id>/agent`.\n */\n agentDir: z.string().optional(),\n model: AgentModelRefSchema.optional(),\n thinkingDefault: z.enum(['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'adaptive']).optional(),\n reasoningDefault: z.enum(['off', 'on', 'stream']).optional(),\n verboseDefault: z.enum(['off', 'on', 'full']).optional(),\n systemPromptOverride: z.string().optional(),\n skills: z.array(z.string()).optional(),\n tools: z\n .object({\n disable: z.array(z.string()).optional(),\n })\n .optional(),\n params: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport const AgentsConfigSchema = z.object({\n /** Default agent id when not specified (routing / session creation). */\n default: z.string().optional(),\n defaults: AgentDefaultsSchema.optional(),\n list: z.array(AgentConfigSchema).optional(),\n}).default({\n defaults: {\n workspace: '~/.xopc/workspace',\n model: '', // Empty default - will be resolved dynamically at runtime\n maxTokens: 8192,\n temperature: 0.7,\n maxToolIterations: 20,\n maxRequestsPerTurn: 50,\n maxToolFailuresPerTurn: 3,\n thinkingDefault: 'medium',\n reasoningDefault: 'stream',\n verboseDefault: 'full',\n compaction: {\n enabled: true,\n mode: 'default',\n reserveTokens: 8000,\n triggerThreshold: 0.8,\n minMessagesBeforeCompact: 10,\n keepRecentMessages: 5,\n evictionWindow: 0.2,\n retentionWindow: 6,\n },\n pruning: {\n enabled: true,\n maxToolResultChars: 10000,\n headKeepRatio: 0.3,\n tailKeepRatio: 0.3,\n },\n },\n} as any);\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// ============================================\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 SessionConfigSchema = z.object({\n dmScope: SessionDmScopeSchema.default('main'),\n identityLinks: z.record(z.string(), z.array(z.string())).optional(),\n storage: SessionStorageConfigSchema.optional(),\n}).default({\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 telegram: {\n enabled: false,\n botToken: '',\n allowFrom: [],\n groupAllowFrom: [],\n debug: false,\n dmPolicy: 'pairing' as const,\n groupPolicy: 'open' as const,\n replyToMode: 'off' as const,\n historyLimit: 50,\n textChunkLimit: 4000,\n },\n});\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 WebToolsConfigSchema = z.object({\n /** Search result HTML fallback: cn → Bing, otherwise DuckDuckGo */\n region: z.enum(['cn', 'global']).optional(),\n search: WebSearchConfigSchema.optional(),\n});\n\nexport type WebToolsConfig = z.infer<typeof WebToolsConfigSchema>;\n\nexport const ToolsConfigSchema = z.object({\n web: WebToolsConfigSchema.optional(),\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 })\n .optional();\n\nexport const GatewayAuthSchema = z\n .object({\n mode: z.enum(['none', 'token', 'password']).default('token'),\n token: z.string().optional(),\n password: z.string().optional(),\n rateLimit: GatewayAuthRateLimitSchema,\n })\n .default({\n mode: 'token',\n });\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 GatewayConfigSchema = z.object({\n host: z.string().optional(),\n port: z.number().optional(),\n auth: GatewayAuthSchema.optional(),\n heartbeat: HeartbeatConfigSchema.optional(),\n maxSseConnections: z.number().optional(),\n corsOrigins: z.array(z.string()).optional(),\n /** Base URL for the xopc skills marketplace (public REST API). */\n skillsStoreBaseUrl: z.string().url().optional(),\n}).default({\n host: '127.0.0.1',\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 skillsStoreBaseUrl: 'https://store.xopc.ai',\n});\n\nexport const CronConfigSchema = z.object({\n enabled: z.boolean().optional(),\n maxConcurrentJobs: z.number().optional(),\n defaultTimezone: z.string().optional(),\n historyRetentionDays: z.number().optional(),\n enableMetrics: z.boolean().optional(),\n}).default({\n enabled: true,\n maxConcurrentJobs: 5,\n defaultTimezone: 'UTC',\n historyRetentionDays: 7,\n enableMetrics: true,\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\nexport const STTProviderConfigSchema = z.object({\n apiKey: z.string().optional(),\n model: z.string().optional(),\n});\n\nexport const STTFallbackConfigSchema = z.object({\n enabled: z.boolean().default(true),\n order: z.array(z.enum(['alibaba', 'openai'])).default(['alibaba', 'openai']),\n});\n\nexport const STTConfigSchema = z.object({\n enabled: z.boolean().default(false),\n provider: z.enum(['alibaba', 'openai']).default('alibaba'),\n alibaba: STTProviderConfigSchema.optional(),\n openai: STTProviderConfigSchema.optional(),\n fallback: STTFallbackConfigSchema.optional(),\n});\n\n// ============================================\n// TTS (Text-to-Speech) Config\n// ============================================\n\nexport const TTSProviderConfigSchema = z.object({\n apiKey: z.string().optional(),\n model: z.string().optional(),\n voice: z.string().optional(),\n});\n\nexport const TTSFallbackConfigSchema = z.object({\n enabled: z.boolean().default(true),\n order: z\n .array(z.enum(['openai', 'alibaba', 'edge', 'minimax']))\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.object({\n enabled: z.boolean().default(false),\n provider: z.enum(['openai', 'alibaba', 'edge', 'minimax']).default('openai'),\n trigger: z\n .preprocess(\n (v) => (v === 'auto' ? 'inbound' : v),\n z.enum(['off', 'always', 'inbound', 'tagged']).default('always'),\n ),\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 alibaba: TTSProviderConfigSchema.optional(),\n openai: TTSProviderConfigSchema.optional(),\n edge: TTSEdgeConfigSchema.optional(),\n minimax: TTSProviderConfigSchema.optional(),\n});\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\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\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 tools: ToolsConfigSchema,\n cron: CronConfigSchema,\n extensions: ExtensionsConfigSchema.default({}),\n modelsDev: ModelsDevConfigSchema,\n stt: STTConfigSchema.optional(),\n tts: TTSConfigSchema.optional(),\n update: UpdateConfigSchema,\n}).default({\n agents: {\n defaults: {\n workspace: '~/.xopc/workspace',\n model: '', // Empty default - will be resolved dynamically at runtime\n maxTokens: 8192,\n temperature: 0.7,\n maxToolIterations: 20,\n maxRequestsPerTurn: 50,\n maxToolFailuresPerTurn: 3,\n thinkingDefault: 'medium',\n reasoningDefault: 'stream',\n verboseDefault: 'full',\n compaction: {\n enabled: true,\n mode: 'default',\n reserveTokens: 8000,\n triggerThreshold: 0.8,\n minMessagesBeforeCompact: 10,\n keepRecentMessages: 5,\n evictionWindow: 0.2,\n retentionWindow: 6,\n },\n pruning: {\n enabled: true,\n maxToolResultChars: 10000,\n headKeepRatio: 0.3,\n tailKeepRatio: 0.3,\n },\n },\n },\n bindings: [],\n session: {\n dmScope: 'main' as const,\n },\n channels: {\n telegram: {\n enabled: false,\n botToken: '',\n allowFrom: [],\n groupAllowFrom: [],\n debug: false,\n dmPolicy: 'pairing' as const,\n groupPolicy: 'open' as const,\n replyToMode: 'off' as const,\n historyLimit: 50,\n textChunkLimit: 4000,\n },\n },\n gateway: {\n host: '127.0.0.1',\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 skillsStoreBaseUrl: 'https://store.xopc.ai',\n },\n tools: {\n web: {\n search: {\n maxResults: 5,\n providers: [],\n },\n },\n },\n cron: {\n enabled: true,\n maxConcurrentJobs: 5,\n defaultTimezone: 'UTC',\n historyRetentionDays: 7,\n enableMetrics: true,\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 stt: {\n enabled: false,\n provider: 'alibaba',\n alibaba: {\n model: 'paraformer-v2',\n },\n openai: {\n model: 'whisper-1',\n },\n fallback: {\n enabled: true,\n order: ['alibaba', 'openai'],\n },\n },\n tts: {\n enabled: false,\n provider: 'openai',\n trigger: 'always',\n fallback: {\n enabled: true,\n order: ['openai', 'alibaba', 'minimax', 'edge'],\n },\n maxTextLength: 4096,\n timeoutMs: 30000,\n modelOverrides: {\n enabled: true,\n allowText: true,\n allowProvider: false,\n allowVoice: true,\n allowModelId: true,\n allowVoiceSettings: false,\n allowNormalization: false,\n allowSeed: false,\n },\n alibaba: {\n model: 'qwen-tts',\n voice: 'Cherry',\n },\n openai: {\n model: 'tts-1',\n voice: 'alloy',\n },\n edge: {\n enabled: true,\n voice: 'en-US-MichelleNeural',\n lang: 'en-US',\n outputFormat: 'audio-24khz-48kbitrate-mono-mp3',\n },\n minimax: {\n model: 'speech-2.8-hd',\n voice: 'male-qn-qingse',\n },\n },\n});\n\nexport type Config = z.infer<typeof ConfigSchema>;\nexport type AgentDefaults = z.infer<typeof AgentDefaultsSchema>;\nexport type GatewayAuthConfig = z.infer<typeof GatewayAuthSchema>;\nexport type GatewayAuthRateLimitConfig = z.infer<typeof GatewayAuthRateLimitSchema>;\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\n/**\n * Default agent’s resolved Markdown workspace root (`resolveAgentWorkspaceDir` for the default agent id).\n */\nexport function getWorkspacePath(config: Config): string {\n return getDefaultWorkspacePath(config);\n}\n\n/**\n * Primary model ref from `agents.defaults.model` (string or `{ primary }`).\n * Returns undefined when unset or empty.\n */\nexport function getAgentDefaultModelRef(config: Config): string | undefined {\n const raw = config.agents?.defaults?.model;\n if (raw === undefined || raw === null) return undefined;\n const ref = typeof raw === 'string' ? raw : raw.primary;\n if (ref === undefined || ref === null) return undefined;\n const s = String(ref).trim();\n return s ? s : undefined;\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":";;;;;;;;;AA8yBA,SAAgB,iBAAiB,QAAwB;AACvD,QAAO,wBAAwB,OAAO;;;;;;AAOxC,SAAgB,wBAAwB,QAAoC;CAC1E,MAAM,MAAM,OAAO,QAAQ,UAAU;AACrC,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAAM,QAAO,KAAA;CAC9C,MAAM,MAAM,OAAO,QAAQ,WAAW,MAAM,IAAI;AAChD,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAAM,QAAO,KAAA;CAC9C,MAAM,IAAI,OAAO,IAAI,CAAC,MAAM;AAC5B,QAAO,IAAI,IAAI,KAAA;;;AAIjB,SAAgB,cAAc,KAAoC;CAChE,MAAM,UAAU,IAAI,MAAM;CAC1B,MAAM,MAAM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ACD,SAAS;IACP,OAAO;IACP,OAAO;IACR;GACD,QAAQ;IACN,OAAO;IACP,OAAO;IACR;GACD,MAAM;IACJ,SAAS;IACT,OAAO;IACP,MAAM;IACN,cAAc;IACf;GACD,SAAS;IACP,OAAO;IACP,OAAO;IACR;GACF;EACF,CAAC"}
@@ -309,7 +309,11 @@ function isHookEvent(value) {
309
309
  "llm_output",
310
310
  "inbound_claim",
311
311
  "before_reset",
312
- "before_message_write"
312
+ "before_message_write",
313
+ "subagent_spawning",
314
+ "subagent_delivery_target",
315
+ "subagent_ended",
316
+ "webchat_turn_complete"
313
317
  ].includes(value);
314
318
  }
315
319
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","names":["typedResult"],"sources":["../../../src/extensions/hooks.ts"],"sourcesContent":["/**\n * Extension Hook System\n */\n\nimport type {\n ExtensionHookEvent,\n HookAgentContext as HookContext,\n AgentMessage,\n BeforeAgentStartContext,\n BeforeToolCallContext,\n BeforeToolCallResult,\n MessageSendingContext,\n MessageSendingResult,\n MessageSentContext,\n} from './types/hooks.js';\n\nimport { ExtensionRegistryImpl as ExtensionRegistry } from './loader.js';\nimport { HOOK_EXECUTION_MODES } from './types/hooks.js';\n\n// ============================================================================\n// Hook Runner Options\n// ============================================================================\n\nexport interface HookRunnerOptions {\n catchErrors?: boolean;\n logger?: HookLogger;\n}\n\nexport interface HookLogger {\n debug?: (message: string) => void;\n info: (message: string) => void;\n warn: (message: string) => void;\n error: (message: string) => void;\n}\n\n// ============================================================================\n// Extension Hook Runner\n// ============================================================================\n\nexport class ExtensionHookRunner {\n private registry: ExtensionRegistry;\n private options: HookRunnerOptions;\n\n constructor(registry: ExtensionRegistry, options?: HookRunnerOptions) {\n this.registry = registry;\n this.options = options || {};\n }\n\n getRegistry(): ExtensionRegistry {\n return this.registry;\n }\n\n async runHooks<K extends ExtensionHookEvent>(\n event: K,\n eventData: unknown,\n context: HookContext,\n ): Promise<{ success: boolean; results: unknown[] }> {\n const handlers = this.registry.getHooks(event);\n const results: unknown[] = [];\n\n for (const handler of handlers) {\n try {\n const result = await handler(eventData, context);\n results.push({ success: true, result });\n } catch (error) {\n results.push({ \n success: false, \n error: error instanceof Error ? error.message : String(error) \n });\n \n if (!this.options.catchErrors) {\n throw error;\n }\n \n this.options.logger?.error?.(\n `Hook error in ${event}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n return { success: true, results };\n }\n\n async runHooksWithResult<K extends ExtensionHookEvent>(\n event: K,\n eventData: BeforeAgentStartContext,\n context: HookContext,\n ): Promise<BeforeAgentStartContext> {\n const handlers = this.registry.getHooks(event);\n let modifiedData = { ...eventData };\n\n for (const handler of handlers) {\n try {\n const result = await handler(modifiedData, context);\n if (result && typeof result === 'object') {\n modifiedData = { ...modifiedData, ...result };\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(`Hook modification error: ${error}`);\n }\n }\n\n return modifiedData;\n }\n\n async runBeforeToolCall(\n toolName: string,\n params: Record<string, unknown>,\n context: HookContext,\n ): Promise<{ allowed: boolean; params?: Record<string, unknown>; reason?: string }> {\n const event: BeforeToolCallContext = {\n ...context,\n toolName,\n params,\n timestamp: new Date(),\n };\n\n const handlers = this.registry.getHooks('before_tool_call');\n let modifiedParams = { ...params };\n let blocked = false;\n let blockReason: string | undefined;\n\n for (const handler of handlers) {\n try {\n const result = await handler(event, context);\n if (result && typeof result === 'object') {\n const typedResult = result as BeforeToolCallResult;\n if (typedResult.block) {\n blocked = true;\n blockReason = typedResult.blockReason;\n }\n if (typedResult.params) {\n modifiedParams = typedResult.params;\n }\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(`before_tool_call hook error: ${error}`);\n }\n }\n\n if (blocked) {\n return { allowed: false, reason: blockReason };\n }\n\n return { allowed: true, params: modifiedParams };\n }\n\n async runMessageSending(\n to: string,\n content: string,\n context: HookContext,\n opts?: { channel?: string },\n ): Promise<{ send: boolean; content?: string; reason?: string }> {\n const event: MessageSendingContext = {\n ...context,\n to,\n content,\n channel: opts?.channel,\n timestamp: new Date(),\n };\n\n const handlers = this.registry.getHooks('message_sending');\n let modifiedContent = content;\n let cancelled = false;\n let cancelReason: string | undefined;\n\n for (const handler of handlers) {\n try {\n const result = await handler(event, context);\n if (result && typeof result === 'object') {\n const typedResult = result as MessageSendingResult;\n if (typedResult.cancel) {\n cancelled = true;\n cancelReason = typedResult.cancelReason;\n }\n if (typedResult.content) {\n modifiedContent = typedResult.content;\n }\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(`message_sending hook error: ${error}`);\n }\n }\n\n if (cancelled) {\n return { send: false, reason: cancelReason };\n }\n\n return { send: true, content: modifiedContent };\n }\n\n async runMessageSent(\n to: string,\n content: string,\n success: boolean,\n error: string | undefined,\n context: HookContext,\n opts?: { channel?: string },\n ): Promise<void> {\n const event: MessageSentContext = {\n ...context,\n to,\n content,\n success,\n error,\n channel: opts?.channel,\n timestamp: new Date(),\n };\n\n const handlers = this.registry.getHooks('message_sent');\n for (const handler of handlers) {\n try {\n await handler(event, context);\n } catch (err) {\n if (!this.options.catchErrors) {\n throw err;\n }\n this.options.logger?.warn?.(\n `message_sent hook error: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n }\n\n // Enhanced Hook Methods\n async runContextHook(\n messages: AgentMessage[],\n context?: HookContext,\n ): Promise<{ messages: AgentMessage[]; modified: boolean }> {\n const handlers = this.registry.getHooks('context');\n \n if (handlers.length === 0) {\n return { messages, modified: false };\n }\n\n let currentMessages = [...messages];\n let modified = false;\n\n const event = {\n messages: currentMessages,\n timestamp: new Date(),\n ...context,\n };\n\n for (const handler of handlers) {\n try {\n const result = await handler(event, context || {});\n \n if (result && typeof result === 'object' && 'messages' in result) {\n const typedResult = result as { messages: AgentMessage[] };\n currentMessages = typedResult.messages as AgentMessage[];\n event.messages = currentMessages;\n modified = true;\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(\n `context hook error: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n return { messages: currentMessages as AgentMessage[], modified };\n }\n\n async runInputHook(\n text: string,\n images: Array<{ type: string; data: string; mimeType?: string }> | undefined,\n source: string,\n context?: HookContext,\n ): Promise<{\n text: string;\n images: Array<{ type: string; data: string; mimeType?: string }> | undefined;\n action: 'continue' | 'handled';\n skipAgent: boolean;\n response?: string;\n }> {\n const handlers = this.registry.getHooks('input');\n\n if (handlers.length === 0) {\n return {\n text,\n images,\n action: 'continue',\n skipAgent: false,\n };\n }\n\n let currentText = text;\n let currentImages = images;\n\n const event = {\n text: currentText,\n images: currentImages,\n source,\n timestamp: new Date(),\n ...context,\n };\n\n for (const handler of handlers) {\n try {\n const result = await handler(event, context || {});\n\n if (result && typeof result === 'object') {\n const typedResult = result as {\n action: 'continue' | 'handled' | 'transform';\n text?: string;\n images?: Array<{ type: string; data: string; mimeType?: string }>;\n response?: string;\n };\n\n if (typedResult.action === 'transform') {\n if (typedResult.text !== undefined) {\n currentText = typedResult.text;\n event.text = currentText;\n }\n if (typedResult.images !== undefined) {\n currentImages = typedResult.images;\n event.images = currentImages;\n }\n continue;\n }\n\n if (typedResult.action === 'handled') {\n return {\n text: currentText,\n images: currentImages,\n action: 'handled',\n skipAgent: true,\n response: typedResult.response,\n };\n }\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(\n `input hook error: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n return {\n text: currentText,\n images: currentImages,\n action: 'continue',\n skipAgent: false,\n };\n }\n\n // Three-Mode Hook Execution\n async runVoidHook<K extends ExtensionHookEvent>(\n hookName: K,\n eventData: unknown,\n context: HookContext,\n ): Promise<void> {\n const handlers = this.registry.getHooks(hookName);\n if (handlers.length === 0) return;\n\n await Promise.allSettled(\n handlers.map(async (handler) => {\n try {\n await handler(eventData, context);\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(\n `Void hook error in ${hookName}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n })\n );\n }\n\n async runModifyingHook<K extends ExtensionHookEvent, R = unknown>(\n hookName: K,\n eventData: unknown,\n context: HookContext,\n merge?: (current: R, next: R) => R,\n ): Promise<R | undefined> {\n const handlers = this.registry.getHooks(hookName);\n if (handlers.length === 0) return undefined;\n\n let result: R | undefined;\n\n for (const handler of handlers) {\n try {\n const handlerResult = await handler(eventData, context);\n if (handlerResult && typeof handlerResult === 'object') {\n if (merge && result) {\n result = merge(result, handlerResult as R);\n } else if (!result) {\n result = handlerResult as R;\n }\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(\n `Modifying hook error in ${hookName}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n return result;\n }\n\n async runClaimingHook<K extends ExtensionHookEvent>(\n hookName: K,\n eventData: unknown,\n context: HookContext,\n ): Promise<{ handled: boolean; result?: unknown }> {\n const handlers = this.registry.getHooks(hookName);\n\n for (const handler of handlers) {\n try {\n const result = await handler(eventData, context);\n \n if (result && typeof result === 'object' && 'handled' in result) {\n const typedResult = result as { handled: boolean };\n if (typedResult.handled) {\n return { handled: true, result };\n }\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(\n `Claiming hook error in ${hookName}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n return { handled: false };\n }\n\n async runHooksByMode<K extends ExtensionHookEvent>(\n hookName: K,\n eventData: unknown,\n context: HookContext,\n ): Promise<{ success: boolean; result?: unknown }> {\n const mode = HOOK_EXECUTION_MODES[hookName];\n\n switch (mode) {\n case 'void':\n await this.runVoidHook(hookName, eventData, context);\n return { success: true };\n\n case 'modifying':\n const modifyingResult = await this.runModifyingHook(hookName, eventData, context);\n return { success: true, result: modifyingResult };\n\n case 'claiming':\n const claimingResult = await this.runClaimingHook(hookName, eventData, context);\n return { success: true, result: claimingResult };\n\n default: {\n const fallbackResult = await this.runHooks(hookName, eventData, context);\n return { success: fallbackResult.success };\n }\n }\n }\n}\n\n// ============================================================================\n// Hook Utilities\n// ============================================================================\n\nexport function createHookContext(overrides?: Partial<HookContext>): HookContext {\n return {\n timestamp: new Date(),\n ...overrides,\n };\n}\n\nexport function isHookEvent(value: string): value is ExtensionHookEvent {\n const hookEvents: ExtensionHookEvent[] = [\n 'before_agent_start',\n 'agent_end',\n 'before_compaction',\n 'after_compaction',\n 'message_received',\n 'message_sending',\n 'message_sent',\n 'before_tool_call',\n 'after_tool_call',\n 'session_start',\n 'session_end',\n 'gateway_start',\n 'gateway_stop',\n 'context',\n 'input',\n 'turn_start',\n 'turn_end',\n 'tool_execution_start',\n 'tool_execution_update',\n 'tool_execution_end',\n 'before_model_resolve',\n 'before_prompt_build',\n 'llm_input',\n 'llm_output',\n 'inbound_claim',\n 'before_reset',\n 'before_message_write',\n ];\n return hookEvents.includes(value as ExtensionHookEvent);\n}\n\nexport type { HookContext };\n"],"mappings":";;AAuCA,IAAa,sBAAb,MAAiC;CAC/B;CACA;CAEA,YAAY,UAA6B,SAA6B;AACpE,OAAK,WAAW;AAChB,OAAK,UAAU,WAAW,EAAE;;CAG9B,cAAiC;AAC/B,SAAO,KAAK;;CAGd,MAAM,SACJ,OACA,WACA,SACmD;EACnD,MAAM,WAAW,KAAK,SAAS,SAAS,MAAM;EAC9C,MAAM,UAAqB,EAAE;AAE7B,OAAK,MAAM,WAAW,SACpB,KAAI;GACF,MAAM,SAAS,MAAM,QAAQ,WAAW,QAAQ;AAChD,WAAQ,KAAK;IAAE,SAAS;IAAM;IAAQ,CAAC;WAChC,OAAO;AACd,WAAQ,KAAK;IACX,SAAS;IACT,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAC9D,CAAC;AAEF,OAAI,CAAC,KAAK,QAAQ,YAChB,OAAM;AAGR,QAAK,QAAQ,QAAQ,QACnB,iBAA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,YAChB,OAAM;AAER,QAAK,QAAQ,QAAQ,OACnB,0BAA0B,SAAS,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GAC9F;;AAIL,SAAO,EAAE,SAAS,OAAO;;CAG3B,MAAM,eACJ,UACA,WACA,SACiD;AAGjD,UAFa,qBAAqB,WAElC;GACE,KAAK;AACH,UAAM,KAAK,YAAY,UAAU,WAAW,QAAQ;AACpD,WAAO,EAAE,SAAS,MAAM;GAE1B,KAAK,YAEH,QAAO;IAAE,SAAS;IAAM,QAAQ,MADF,KAAK,iBAAiB,UAAU,WAAW,QAAQ;IAChC;GAEnD,KAAK,WAEH,QAAO;IAAE,SAAS;IAAM,QAAQ,MADH,KAAK,gBAAgB,UAAU,WAAW,QAAQ;IAC/B;GAElD,QAEE,QAAO,EAAE,UAAS,MADW,KAAK,SAAS,UAAU,WAAW,QAAQ,EACvC,SAAS;;;;AAUlD,SAAgB,kBAAkB,WAA+C;AAC/E,QAAO;EACL,2BAAW,IAAI,MAAM;EACrB,GAAG;EACJ;;AAGH,SAAgB,YAAY,OAA4C;AA8BtE,QAAO;EA5BL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEe,CAAC,SAAS,MAA4B"}
1
+ {"version":3,"file":"hooks.js","names":["typedResult"],"sources":["../../../src/extensions/hooks.ts"],"sourcesContent":["/**\n * Extension Hook System\n */\n\nimport type {\n ExtensionHookEvent,\n HookAgentContext as HookContext,\n AgentMessage,\n BeforeAgentStartContext,\n BeforeToolCallContext,\n BeforeToolCallResult,\n MessageSendingContext,\n MessageSendingResult,\n MessageSentContext,\n} from './types/hooks.js';\n\nimport { ExtensionRegistryImpl as ExtensionRegistry } from './loader.js';\nimport { HOOK_EXECUTION_MODES } from './types/hooks.js';\n\n// ============================================================================\n// Hook Runner Options\n// ============================================================================\n\nexport interface HookRunnerOptions {\n catchErrors?: boolean;\n logger?: HookLogger;\n}\n\nexport interface HookLogger {\n debug?: (message: string) => void;\n info: (message: string) => void;\n warn: (message: string) => void;\n error: (message: string) => void;\n}\n\n// ============================================================================\n// Extension Hook Runner\n// ============================================================================\n\nexport class ExtensionHookRunner {\n private registry: ExtensionRegistry;\n private options: HookRunnerOptions;\n\n constructor(registry: ExtensionRegistry, options?: HookRunnerOptions) {\n this.registry = registry;\n this.options = options || {};\n }\n\n getRegistry(): ExtensionRegistry {\n return this.registry;\n }\n\n async runHooks<K extends ExtensionHookEvent>(\n event: K,\n eventData: unknown,\n context: HookContext,\n ): Promise<{ success: boolean; results: unknown[] }> {\n const handlers = this.registry.getHooks(event);\n const results: unknown[] = [];\n\n for (const handler of handlers) {\n try {\n const result = await handler(eventData, context);\n results.push({ success: true, result });\n } catch (error) {\n results.push({ \n success: false, \n error: error instanceof Error ? error.message : String(error) \n });\n \n if (!this.options.catchErrors) {\n throw error;\n }\n \n this.options.logger?.error?.(\n `Hook error in ${event}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n return { success: true, results };\n }\n\n async runHooksWithResult<K extends ExtensionHookEvent>(\n event: K,\n eventData: BeforeAgentStartContext,\n context: HookContext,\n ): Promise<BeforeAgentStartContext> {\n const handlers = this.registry.getHooks(event);\n let modifiedData = { ...eventData };\n\n for (const handler of handlers) {\n try {\n const result = await handler(modifiedData, context);\n if (result && typeof result === 'object') {\n modifiedData = { ...modifiedData, ...result };\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(`Hook modification error: ${error}`);\n }\n }\n\n return modifiedData;\n }\n\n async runBeforeToolCall(\n toolName: string,\n params: Record<string, unknown>,\n context: HookContext,\n ): Promise<{ allowed: boolean; params?: Record<string, unknown>; reason?: string }> {\n const event: BeforeToolCallContext = {\n ...context,\n toolName,\n params,\n timestamp: new Date(),\n };\n\n const handlers = this.registry.getHooks('before_tool_call');\n let modifiedParams = { ...params };\n let blocked = false;\n let blockReason: string | undefined;\n\n for (const handler of handlers) {\n try {\n const result = await handler(event, context);\n if (result && typeof result === 'object') {\n const typedResult = result as BeforeToolCallResult;\n if (typedResult.block) {\n blocked = true;\n blockReason = typedResult.blockReason;\n }\n if (typedResult.params) {\n modifiedParams = typedResult.params;\n }\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(`before_tool_call hook error: ${error}`);\n }\n }\n\n if (blocked) {\n return { allowed: false, reason: blockReason };\n }\n\n return { allowed: true, params: modifiedParams };\n }\n\n async runMessageSending(\n to: string,\n content: string,\n context: HookContext,\n opts?: { channel?: string },\n ): Promise<{ send: boolean; content?: string; reason?: string }> {\n const event: MessageSendingContext = {\n ...context,\n to,\n content,\n channel: opts?.channel,\n timestamp: new Date(),\n };\n\n const handlers = this.registry.getHooks('message_sending');\n let modifiedContent = content;\n let cancelled = false;\n let cancelReason: string | undefined;\n\n for (const handler of handlers) {\n try {\n const result = await handler(event, context);\n if (result && typeof result === 'object') {\n const typedResult = result as MessageSendingResult;\n if (typedResult.cancel) {\n cancelled = true;\n cancelReason = typedResult.cancelReason;\n }\n if (typedResult.content) {\n modifiedContent = typedResult.content;\n }\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(`message_sending hook error: ${error}`);\n }\n }\n\n if (cancelled) {\n return { send: false, reason: cancelReason };\n }\n\n return { send: true, content: modifiedContent };\n }\n\n async runMessageSent(\n to: string,\n content: string,\n success: boolean,\n error: string | undefined,\n context: HookContext,\n opts?: { channel?: string },\n ): Promise<void> {\n const event: MessageSentContext = {\n ...context,\n to,\n content,\n success,\n error,\n channel: opts?.channel,\n timestamp: new Date(),\n };\n\n const handlers = this.registry.getHooks('message_sent');\n for (const handler of handlers) {\n try {\n await handler(event, context);\n } catch (err) {\n if (!this.options.catchErrors) {\n throw err;\n }\n this.options.logger?.warn?.(\n `message_sent hook error: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n }\n\n // Enhanced Hook Methods\n async runContextHook(\n messages: AgentMessage[],\n context?: HookContext,\n ): Promise<{ messages: AgentMessage[]; modified: boolean }> {\n const handlers = this.registry.getHooks('context');\n \n if (handlers.length === 0) {\n return { messages, modified: false };\n }\n\n let currentMessages = [...messages];\n let modified = false;\n\n const event = {\n messages: currentMessages,\n timestamp: new Date(),\n ...context,\n };\n\n for (const handler of handlers) {\n try {\n const result = await handler(event, context || {});\n \n if (result && typeof result === 'object' && 'messages' in result) {\n const typedResult = result as { messages: AgentMessage[] };\n currentMessages = typedResult.messages as AgentMessage[];\n event.messages = currentMessages;\n modified = true;\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(\n `context hook error: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n return { messages: currentMessages as AgentMessage[], modified };\n }\n\n async runInputHook(\n text: string,\n images: Array<{ type: string; data: string; mimeType?: string }> | undefined,\n source: string,\n context?: HookContext,\n ): Promise<{\n text: string;\n images: Array<{ type: string; data: string; mimeType?: string }> | undefined;\n action: 'continue' | 'handled';\n skipAgent: boolean;\n response?: string;\n }> {\n const handlers = this.registry.getHooks('input');\n\n if (handlers.length === 0) {\n return {\n text,\n images,\n action: 'continue',\n skipAgent: false,\n };\n }\n\n let currentText = text;\n let currentImages = images;\n\n const event = {\n text: currentText,\n images: currentImages,\n source,\n timestamp: new Date(),\n ...context,\n };\n\n for (const handler of handlers) {\n try {\n const result = await handler(event, context || {});\n\n if (result && typeof result === 'object') {\n const typedResult = result as {\n action: 'continue' | 'handled' | 'transform';\n text?: string;\n images?: Array<{ type: string; data: string; mimeType?: string }>;\n response?: string;\n };\n\n if (typedResult.action === 'transform') {\n if (typedResult.text !== undefined) {\n currentText = typedResult.text;\n event.text = currentText;\n }\n if (typedResult.images !== undefined) {\n currentImages = typedResult.images;\n event.images = currentImages;\n }\n continue;\n }\n\n if (typedResult.action === 'handled') {\n return {\n text: currentText,\n images: currentImages,\n action: 'handled',\n skipAgent: true,\n response: typedResult.response,\n };\n }\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(\n `input hook error: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n return {\n text: currentText,\n images: currentImages,\n action: 'continue',\n skipAgent: false,\n };\n }\n\n // Three-Mode Hook Execution\n async runVoidHook<K extends ExtensionHookEvent>(\n hookName: K,\n eventData: unknown,\n context: HookContext,\n ): Promise<void> {\n const handlers = this.registry.getHooks(hookName);\n if (handlers.length === 0) return;\n\n await Promise.allSettled(\n handlers.map(async (handler) => {\n try {\n await handler(eventData, context);\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(\n `Void hook error in ${hookName}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n })\n );\n }\n\n async runModifyingHook<K extends ExtensionHookEvent, R = unknown>(\n hookName: K,\n eventData: unknown,\n context: HookContext,\n merge?: (current: R, next: R) => R,\n ): Promise<R | undefined> {\n const handlers = this.registry.getHooks(hookName);\n if (handlers.length === 0) return undefined;\n\n let result: R | undefined;\n\n for (const handler of handlers) {\n try {\n const handlerResult = await handler(eventData, context);\n if (handlerResult && typeof handlerResult === 'object') {\n if (merge && result) {\n result = merge(result, handlerResult as R);\n } else if (!result) {\n result = handlerResult as R;\n }\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(\n `Modifying hook error in ${hookName}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n return result;\n }\n\n async runClaimingHook<K extends ExtensionHookEvent>(\n hookName: K,\n eventData: unknown,\n context: HookContext,\n ): Promise<{ handled: boolean; result?: unknown }> {\n const handlers = this.registry.getHooks(hookName);\n\n for (const handler of handlers) {\n try {\n const result = await handler(eventData, context);\n \n if (result && typeof result === 'object' && 'handled' in result) {\n const typedResult = result as { handled: boolean };\n if (typedResult.handled) {\n return { handled: true, result };\n }\n }\n } catch (error) {\n if (!this.options.catchErrors) {\n throw error;\n }\n this.options.logger?.warn?.(\n `Claiming hook error in ${hookName}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n return { handled: false };\n }\n\n async runHooksByMode<K extends ExtensionHookEvent>(\n hookName: K,\n eventData: unknown,\n context: HookContext,\n ): Promise<{ success: boolean; result?: unknown }> {\n const mode = HOOK_EXECUTION_MODES[hookName];\n\n switch (mode) {\n case 'void':\n await this.runVoidHook(hookName, eventData, context);\n return { success: true };\n\n case 'modifying':\n const modifyingResult = await this.runModifyingHook(hookName, eventData, context);\n return { success: true, result: modifyingResult };\n\n case 'claiming':\n const claimingResult = await this.runClaimingHook(hookName, eventData, context);\n return { success: true, result: claimingResult };\n\n default: {\n const fallbackResult = await this.runHooks(hookName, eventData, context);\n return { success: fallbackResult.success };\n }\n }\n }\n}\n\n// ============================================================================\n// Hook Utilities\n// ============================================================================\n\nexport function createHookContext(overrides?: Partial<HookContext>): HookContext {\n return {\n timestamp: new Date(),\n ...overrides,\n };\n}\n\nexport function isHookEvent(value: string): value is ExtensionHookEvent {\n const hookEvents: ExtensionHookEvent[] = [\n 'before_agent_start',\n 'agent_end',\n 'before_compaction',\n 'after_compaction',\n 'message_received',\n 'message_sending',\n 'message_sent',\n 'before_tool_call',\n 'after_tool_call',\n 'session_start',\n 'session_end',\n 'gateway_start',\n 'gateway_stop',\n 'context',\n 'input',\n 'turn_start',\n 'turn_end',\n 'tool_execution_start',\n 'tool_execution_update',\n 'tool_execution_end',\n 'before_model_resolve',\n 'before_prompt_build',\n 'llm_input',\n 'llm_output',\n 'inbound_claim',\n 'before_reset',\n 'before_message_write',\n 'subagent_spawning',\n 'subagent_delivery_target',\n 'subagent_ended',\n 'webchat_turn_complete',\n ];\n return hookEvents.includes(value as ExtensionHookEvent);\n}\n\nexport type { HookContext };\n"],"mappings":";;AAuCA,IAAa,sBAAb,MAAiC;CAC/B;CACA;CAEA,YAAY,UAA6B,SAA6B;AACpE,OAA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A;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEe,CAAC,SAAS,MAA4B"}
@@ -108,6 +108,7 @@ export declare class ExtensionLoader {
108
108
  setRuntimeContext(ctx: {
109
109
  bus: MessageBus;
110
110
  sessionManager?: SessionManager;
111
+ scheduleWebchatContinuation?: (sessionKey: string, message: string) => void;
111
112
  }): void;
112
113
  getRegistry(): ExtensionRegistryImpl;
113
114
  /**
@@ -254,6 +254,7 @@ var ExtensionLoader = class {
254
254
  */
255
255
  setRuntimeContext(ctx) {
256
256
  this._runtimeContext = ctx;
257
+ this.cache.invalidate();
257
258
  }
258
259
  getRegistry() {
259
260
  return this.registry;
@@ -647,7 +648,8 @@ var ExtensionLoader = class {
647
648
  config: this._appConfig,
648
649
  bus: this._runtimeContext.bus,
649
650
  log: logger,
650
- sessionManager: this._runtimeContext.sessionManager
651
+ sessionManager: this._runtimeContext.sessionManager,
652
+ scheduleWebchatContinuation: this._runtimeContext.scheduleWebchatContinuation
651
653
  } : this._appConfig ? {
652
654
  config: this._appConfig,
653
655
  log: logger