comisai 1.0.28 → 1.0.30

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 (241) hide show
  1. package/node_modules/@comis/agent/dist/bootstrap/sections/tool-descriptions.js +62 -8
  2. package/node_modules/@comis/agent/dist/bootstrap/sections/tooling-sections.js +3 -1
  3. package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.d.ts +7 -0
  4. package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.js +26 -0
  5. package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.d.ts +21 -0
  6. package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.js +29 -9
  7. package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.d.ts +10 -2
  8. package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.js +15 -9
  9. package/node_modules/@comis/agent/dist/context-engine/thinking-block-cleaner.d.ts +17 -2
  10. package/node_modules/@comis/agent/dist/context-engine/thinking-block-cleaner.js +19 -8
  11. package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.js +28 -0
  12. package/node_modules/@comis/agent/dist/executor/executor-response-filter.js +3 -0
  13. package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.js +3 -1
  14. package/node_modules/@comis/agent/dist/executor/phase-filter.d.ts +20 -4
  15. package/node_modules/@comis/agent/dist/executor/phase-filter.js +62 -19
  16. package/node_modules/@comis/agent/dist/executor/pi-executor.js +6 -0
  17. package/node_modules/@comis/agent/dist/executor/stream-wrappers/config-resolver.js +2 -3
  18. package/node_modules/@comis/agent/dist/executor/stream-wrappers/request-body-injector.js +2 -3
  19. package/node_modules/@comis/agent/dist/executor/ttl-guard.js +2 -3
  20. package/node_modules/@comis/agent/dist/index.d.ts +4 -2
  21. package/node_modules/@comis/agent/dist/index.js +3 -2
  22. package/node_modules/@comis/agent/dist/model/compaction-model-resolver.d.ts +41 -0
  23. package/node_modules/@comis/agent/dist/model/compaction-model-resolver.js +51 -0
  24. package/node_modules/@comis/agent/dist/model/model-registry-adapter.js +113 -26
  25. package/node_modules/@comis/agent/dist/model/model-scanner.d.ts +27 -0
  26. package/node_modules/@comis/agent/dist/model/model-scanner.js +64 -23
  27. package/node_modules/@comis/agent/dist/model/operation-model-defaults.d.ts +37 -15
  28. package/node_modules/@comis/agent/dist/model/operation-model-defaults.js +70 -25
  29. package/node_modules/@comis/agent/dist/model/operation-model-resolver.d.ts +2 -2
  30. package/node_modules/@comis/agent/dist/model/operation-model-resolver.js +12 -8
  31. package/node_modules/@comis/agent/dist/provider/capabilities.d.ts +21 -0
  32. package/node_modules/@comis/agent/dist/provider/capabilities.js +28 -0
  33. package/node_modules/@comis/agent/dist/session/orphaned-message-repair.js +61 -1
  34. package/node_modules/@comis/agent/dist/workspace/templates.js +1 -1
  35. package/node_modules/@comis/agent/package.json +1 -1
  36. package/node_modules/@comis/channels/dist/shared/channel-manager.d.ts +19 -1
  37. package/node_modules/@comis/channels/dist/shared/channel-manager.js +59 -3
  38. package/node_modules/@comis/channels/dist/shared/deliver-to-channel.d.ts +10 -0
  39. package/node_modules/@comis/channels/dist/shared/deliver-to-channel.js +25 -10
  40. package/node_modules/@comis/channels/dist/shared/execution-deliver.d.ts +1 -1
  41. package/node_modules/@comis/channels/dist/shared/execution-deliver.js +1 -1
  42. package/node_modules/@comis/channels/dist/shared/execution-pipeline.d.ts +8 -0
  43. package/node_modules/@comis/channels/dist/shared/inbound-pipeline.d.ts +8 -0
  44. package/node_modules/@comis/channels/dist/shared/inbound-route.d.ts +1 -1
  45. package/node_modules/@comis/channels/dist/shared/inbound-route.js +1 -0
  46. package/node_modules/@comis/channels/package.json +1 -1
  47. package/node_modules/@comis/cli/package.json +1 -1
  48. package/node_modules/@comis/core/dist/config/schema-agent.d.ts +15 -3
  49. package/node_modules/@comis/core/dist/config/schema-agent.js +6 -2
  50. package/node_modules/@comis/core/dist/config/schema-integrations.d.ts +4 -4
  51. package/node_modules/@comis/core/dist/config/schema-integrations.js +3 -3
  52. package/node_modules/@comis/core/dist/config/schema-models.d.ts +4 -2
  53. package/node_modules/@comis/core/dist/config/schema-models.js +4 -2
  54. package/node_modules/@comis/core/package.json +1 -1
  55. package/node_modules/@comis/daemon/dist/daemon.js +51 -8
  56. package/node_modules/@comis/daemon/dist/rpc/agent-handlers.js +40 -9
  57. package/node_modules/@comis/daemon/dist/rpc/builtin-provider-guard.d.ts +16 -0
  58. package/node_modules/@comis/daemon/dist/rpc/builtin-provider-guard.js +60 -0
  59. package/node_modules/@comis/daemon/dist/rpc/config-handlers.js +59 -0
  60. package/node_modules/@comis/daemon/dist/rpc/credential-resolver.d.ts +17 -0
  61. package/node_modules/@comis/daemon/dist/rpc/credential-resolver.js +99 -0
  62. package/node_modules/@comis/daemon/dist/rpc/message-handlers.d.ts +5 -0
  63. package/node_modules/@comis/daemon/dist/rpc/message-handlers.js +25 -4
  64. package/node_modules/@comis/daemon/dist/rpc/model-handlers.d.ts +4 -3
  65. package/node_modules/@comis/daemon/dist/rpc/model-handlers.js +21 -3
  66. package/node_modules/@comis/daemon/dist/rpc/provider-handlers.js +82 -6
  67. package/node_modules/@comis/daemon/dist/rpc/rpc-dispatch.d.ts +4 -0
  68. package/node_modules/@comis/daemon/dist/wiring/inbound-message-id-resolver.d.ts +48 -0
  69. package/node_modules/@comis/daemon/dist/wiring/inbound-message-id-resolver.js +58 -0
  70. package/node_modules/@comis/daemon/dist/wiring/setup-agents.d.ts +18 -6
  71. package/node_modules/@comis/daemon/dist/wiring/setup-agents.js +98 -46
  72. package/node_modules/@comis/daemon/dist/wiring/setup-channels.d.ts +13 -1
  73. package/node_modules/@comis/daemon/dist/wiring/setup-channels.js +2 -1
  74. package/node_modules/@comis/daemon/dist/wiring/setup-gateway-rpc.js +1 -1
  75. package/node_modules/@comis/daemon/package.json +2 -2
  76. package/node_modules/@comis/gateway/package.json +1 -1
  77. package/node_modules/@comis/infra/package.json +1 -1
  78. package/node_modules/@comis/memory/package.json +1 -1
  79. package/node_modules/@comis/scheduler/package.json +1 -1
  80. package/node_modules/@comis/shared/package.json +1 -1
  81. package/node_modules/@comis/skills/dist/bridge/mcp-tool-bridge.d.ts +1 -1
  82. package/node_modules/@comis/skills/dist/bridge/mcp-tool-bridge.js +1 -1
  83. package/node_modules/@comis/skills/dist/bridge/tool-audit.js +1 -1
  84. package/node_modules/@comis/skills/dist/builtin/exec-tool.d.ts +12 -11
  85. package/node_modules/@comis/skills/dist/builtin/exec-tool.js +1 -1
  86. package/node_modules/@comis/skills/dist/builtin/file/apply-patch-tool.d.ts +3 -2
  87. package/node_modules/@comis/skills/dist/builtin/file/apply-patch-tool.js +1 -1
  88. package/node_modules/@comis/skills/dist/builtin/file-tools/edit-tool.d.ts +7 -6
  89. package/node_modules/@comis/skills/dist/builtin/file-tools/edit-tool.js +1 -1
  90. package/node_modules/@comis/skills/dist/builtin/file-tools/find-tool.d.ts +6 -5
  91. package/node_modules/@comis/skills/dist/builtin/file-tools/find-tool.js +1 -1
  92. package/node_modules/@comis/skills/dist/builtin/file-tools/grep-tool.d.ts +16 -15
  93. package/node_modules/@comis/skills/dist/builtin/file-tools/grep-tool.js +1 -1
  94. package/node_modules/@comis/skills/dist/builtin/file-tools/ls-tool.d.ts +4 -3
  95. package/node_modules/@comis/skills/dist/builtin/file-tools/ls-tool.js +1 -1
  96. package/node_modules/@comis/skills/dist/builtin/file-tools/notebook-edit-tool.d.ts +7 -6
  97. package/node_modules/@comis/skills/dist/builtin/file-tools/notebook-edit-tool.js +1 -1
  98. package/node_modules/@comis/skills/dist/builtin/file-tools/read-tool.d.ts +6 -5
  99. package/node_modules/@comis/skills/dist/builtin/file-tools/read-tool.js +1 -1
  100. package/node_modules/@comis/skills/dist/builtin/file-tools/write-tool.d.ts +5 -4
  101. package/node_modules/@comis/skills/dist/builtin/file-tools/write-tool.js +1 -1
  102. package/node_modules/@comis/skills/dist/builtin/platform/admin-manage-factory.d.ts +1 -1
  103. package/node_modules/@comis/skills/dist/builtin/platform/agents-manage-tool.d.ts +28 -27
  104. package/node_modules/@comis/skills/dist/builtin/platform/agents-manage-tool.js +1 -1
  105. package/node_modules/@comis/skills/dist/builtin/platform/background-tasks-tool.d.ts +4 -3
  106. package/node_modules/@comis/skills/dist/builtin/platform/background-tasks-tool.js +1 -1
  107. package/node_modules/@comis/skills/dist/builtin/platform/browser-tool-schema.d.ts +67 -66
  108. package/node_modules/@comis/skills/dist/builtin/platform/browser-tool-schema.js +1 -1
  109. package/node_modules/@comis/skills/dist/builtin/platform/channels-manage-tool.d.ts +6 -5
  110. package/node_modules/@comis/skills/dist/builtin/platform/channels-manage-tool.js +1 -1
  111. package/node_modules/@comis/skills/dist/builtin/platform/cron-tool.d.ts +20 -19
  112. package/node_modules/@comis/skills/dist/builtin/platform/cron-tool.js +1 -1
  113. package/node_modules/@comis/skills/dist/builtin/platform/ctx-expand-tool.d.ts +4 -3
  114. package/node_modules/@comis/skills/dist/builtin/platform/ctx-expand-tool.js +1 -1
  115. package/node_modules/@comis/skills/dist/builtin/platform/ctx-inspect-tool.d.ts +3 -2
  116. package/node_modules/@comis/skills/dist/builtin/platform/ctx-inspect-tool.js +1 -1
  117. package/node_modules/@comis/skills/dist/builtin/platform/ctx-recall-tool.d.ts +6 -5
  118. package/node_modules/@comis/skills/dist/builtin/platform/ctx-recall-tool.js +1 -1
  119. package/node_modules/@comis/skills/dist/builtin/platform/ctx-search-tool.d.ts +6 -5
  120. package/node_modules/@comis/skills/dist/builtin/platform/ctx-search-tool.js +1 -1
  121. package/node_modules/@comis/skills/dist/builtin/platform/describe-video-tool.d.ts +4 -3
  122. package/node_modules/@comis/skills/dist/builtin/platform/describe-video-tool.js +1 -1
  123. package/node_modules/@comis/skills/dist/builtin/platform/discord-action-tool.d.ts +2 -1
  124. package/node_modules/@comis/skills/dist/builtin/platform/discord-action-tool.js +1 -1
  125. package/node_modules/@comis/skills/dist/builtin/platform/extract-document-tool.d.ts +4 -3
  126. package/node_modules/@comis/skills/dist/builtin/platform/extract-document-tool.js +1 -1
  127. package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.d.ts +12 -11
  128. package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.js +1 -1
  129. package/node_modules/@comis/skills/dist/builtin/platform/heartbeat-manage-tool.d.ts +23 -22
  130. package/node_modules/@comis/skills/dist/builtin/platform/heartbeat-manage-tool.js +1 -1
  131. package/node_modules/@comis/skills/dist/builtin/platform/image-generate-tool.d.ts +4 -3
  132. package/node_modules/@comis/skills/dist/builtin/platform/image-generate-tool.js +1 -1
  133. package/node_modules/@comis/skills/dist/builtin/platform/image-tool.d.ts +8 -7
  134. package/node_modules/@comis/skills/dist/builtin/platform/image-tool.js +1 -1
  135. package/node_modules/@comis/skills/dist/builtin/platform/mcp-manage-tool.d.ts +9 -8
  136. package/node_modules/@comis/skills/dist/builtin/platform/mcp-manage-tool.js +1 -1
  137. package/node_modules/@comis/skills/dist/builtin/platform/memory-get-tool.d.ts +5 -4
  138. package/node_modules/@comis/skills/dist/builtin/platform/memory-get-tool.js +1 -1
  139. package/node_modules/@comis/skills/dist/builtin/platform/memory-manage-tool.d.ts +12 -11
  140. package/node_modules/@comis/skills/dist/builtin/platform/memory-manage-tool.js +1 -1
  141. package/node_modules/@comis/skills/dist/builtin/platform/memory-search-tool.d.ts +4 -3
  142. package/node_modules/@comis/skills/dist/builtin/platform/memory-search-tool.js +1 -1
  143. package/node_modules/@comis/skills/dist/builtin/platform/memory-store-tool.d.ts +4 -3
  144. package/node_modules/@comis/skills/dist/builtin/platform/memory-store-tool.js +1 -1
  145. package/node_modules/@comis/skills/dist/builtin/platform/message-tool.d.ts +32 -31
  146. package/node_modules/@comis/skills/dist/builtin/platform/message-tool.js +1 -1
  147. package/node_modules/@comis/skills/dist/builtin/platform/messaging-factory.d.ts +1 -1
  148. package/node_modules/@comis/skills/dist/builtin/platform/models-manage-tool.d.ts +4 -3
  149. package/node_modules/@comis/skills/dist/builtin/platform/models-manage-tool.js +11 -4
  150. package/node_modules/@comis/skills/dist/builtin/platform/notify-tool.d.ts +6 -5
  151. package/node_modules/@comis/skills/dist/builtin/platform/notify-tool.js +1 -1
  152. package/node_modules/@comis/skills/dist/builtin/platform/obs-query-tool.d.ts +11 -10
  153. package/node_modules/@comis/skills/dist/builtin/platform/obs-query-tool.js +1 -1
  154. package/node_modules/@comis/skills/dist/builtin/platform/pipeline-tool.d.ts +37 -36
  155. package/node_modules/@comis/skills/dist/builtin/platform/pipeline-tool.js +1 -1
  156. package/node_modules/@comis/skills/dist/builtin/platform/platform-action-tool.d.ts +1 -1
  157. package/node_modules/@comis/skills/dist/builtin/platform/providers-manage-tool.d.ts +21 -20
  158. package/node_modules/@comis/skills/dist/builtin/platform/providers-manage-tool.js +1 -1
  159. package/node_modules/@comis/skills/dist/builtin/platform/session-search-tool.d.ts +6 -5
  160. package/node_modules/@comis/skills/dist/builtin/platform/session-search-tool.js +1 -1
  161. package/node_modules/@comis/skills/dist/builtin/platform/session-status-tool.d.ts +3 -2
  162. package/node_modules/@comis/skills/dist/builtin/platform/session-status-tool.js +1 -1
  163. package/node_modules/@comis/skills/dist/builtin/platform/sessions-history-tool.d.ts +5 -4
  164. package/node_modules/@comis/skills/dist/builtin/platform/sessions-history-tool.js +1 -1
  165. package/node_modules/@comis/skills/dist/builtin/platform/sessions-list-tool.d.ts +4 -3
  166. package/node_modules/@comis/skills/dist/builtin/platform/sessions-list-tool.js +1 -1
  167. package/node_modules/@comis/skills/dist/builtin/platform/sessions-manage-tool.d.ts +5 -4
  168. package/node_modules/@comis/skills/dist/builtin/platform/sessions-manage-tool.js +1 -1
  169. package/node_modules/@comis/skills/dist/builtin/platform/sessions-send-tool.d.ts +7 -6
  170. package/node_modules/@comis/skills/dist/builtin/platform/sessions-send-tool.js +1 -1
  171. package/node_modules/@comis/skills/dist/builtin/platform/sessions-spawn-tool.d.ts +15 -14
  172. package/node_modules/@comis/skills/dist/builtin/platform/sessions-spawn-tool.js +1 -1
  173. package/node_modules/@comis/skills/dist/builtin/platform/skills-manage-tool.d.ts +8 -7
  174. package/node_modules/@comis/skills/dist/builtin/platform/skills-manage-tool.js +1 -1
  175. package/node_modules/@comis/skills/dist/builtin/platform/slack-action-tool.d.ts +2 -1
  176. package/node_modules/@comis/skills/dist/builtin/platform/slack-action-tool.js +1 -1
  177. package/node_modules/@comis/skills/dist/builtin/platform/subagents-tool.d.ts +7 -6
  178. package/node_modules/@comis/skills/dist/builtin/platform/subagents-tool.js +1 -1
  179. package/node_modules/@comis/skills/dist/builtin/platform/telegram-action-tool.d.ts +2 -1
  180. package/node_modules/@comis/skills/dist/builtin/platform/telegram-action-tool.js +1 -1
  181. package/node_modules/@comis/skills/dist/builtin/platform/tokens-manage-tool.d.ts +5 -4
  182. package/node_modules/@comis/skills/dist/builtin/platform/tokens-manage-tool.js +1 -1
  183. package/node_modules/@comis/skills/dist/builtin/platform/transcribe-audio-tool.d.ts +4 -3
  184. package/node_modules/@comis/skills/dist/builtin/platform/transcribe-audio-tool.js +1 -1
  185. package/node_modules/@comis/skills/dist/builtin/platform/tts-tool.d.ts +6 -5
  186. package/node_modules/@comis/skills/dist/builtin/platform/tts-tool.js +1 -1
  187. package/node_modules/@comis/skills/dist/builtin/platform/unified-context-tool.d.ts +13 -12
  188. package/node_modules/@comis/skills/dist/builtin/platform/unified-context-tool.js +1 -1
  189. package/node_modules/@comis/skills/dist/builtin/platform/unified-memory-tool.d.ts +18 -17
  190. package/node_modules/@comis/skills/dist/builtin/platform/unified-memory-tool.js +1 -1
  191. package/node_modules/@comis/skills/dist/builtin/platform/unified-session-tool.d.ts +11 -10
  192. package/node_modules/@comis/skills/dist/builtin/platform/unified-session-tool.js +1 -1
  193. package/node_modules/@comis/skills/dist/builtin/platform/whatsapp-action-tool.d.ts +2 -1
  194. package/node_modules/@comis/skills/dist/builtin/platform/whatsapp-action-tool.js +1 -1
  195. package/node_modules/@comis/skills/dist/builtin/process-tool.d.ts +6 -5
  196. package/node_modules/@comis/skills/dist/builtin/process-tool.js +1 -1
  197. package/node_modules/@comis/skills/dist/builtin/web-fetch-tool.d.ts +5 -4
  198. package/node_modules/@comis/skills/dist/builtin/web-fetch-tool.js +1 -1
  199. package/node_modules/@comis/skills/dist/builtin/web-search-tool.d.ts +9 -8
  200. package/node_modules/@comis/skills/dist/builtin/web-search-tool.js +1 -1
  201. package/node_modules/@comis/skills/package.json +1 -1
  202. package/node_modules/@comis/web/dist/assets/{agent-detail-DqL6Artv.js → agent-detail-71BSbSfD.js} +1 -1
  203. package/node_modules/@comis/web/dist/assets/{agent-editor-CNM_h94Y.js → agent-editor-CTSDZhwT.js} +1 -1
  204. package/node_modules/@comis/web/dist/assets/{agent-list-Dbh-xD_F.js → agent-list-BEhni2ea.js} +1 -1
  205. package/node_modules/@comis/web/dist/assets/{billing-view-C1DmtyzK.js → billing-view-DVP1IvVs.js} +1 -1
  206. package/node_modules/@comis/web/dist/assets/{channel-detail-CtCH22N1.js → channel-detail-N_YK74xC.js} +1 -1
  207. package/node_modules/@comis/web/dist/assets/{channel-list-C7xXn-60.js → channel-list-DRk6ZJaF.js} +1 -1
  208. package/node_modules/@comis/web/dist/assets/{chat-console-C51pjFwk.js → chat-console-Dm-GtSf9.js} +1 -1
  209. package/node_modules/@comis/web/dist/assets/{config-editor-BLArYRB7.js → config-editor-CIferYX6.js} +1 -1
  210. package/node_modules/@comis/web/dist/assets/{context-dag-browser-fuyMinNI.js → context-dag-browser-CL84rXXM.js} +1 -1
  211. package/node_modules/@comis/web/dist/assets/{context-engine-Bngf2bH0.js → context-engine-B1HOTEZv.js} +1 -1
  212. package/node_modules/@comis/web/dist/assets/{delivery-view-C80hucxX.js → delivery-view-Y6JKYVFw.js} +1 -1
  213. package/node_modules/@comis/web/dist/assets/{diagnostics-view-Cl4VbHZ6.js → diagnostics-view-DWV1UQjz.js} +1 -1
  214. package/node_modules/@comis/web/dist/assets/{ic-chat-message-ByFUoMm6.js → ic-chat-message-DfSERzzg.js} +1 -1
  215. package/node_modules/@comis/web/dist/assets/{ic-connection-dot-C4nDHgY2.js → ic-connection-dot-CXyhlJup.js} +1 -1
  216. package/node_modules/@comis/web/dist/assets/{ic-tool-call-Bh5kq-yY.js → ic-tool-call-DNmwTjek.js} +1 -1
  217. package/node_modules/@comis/web/dist/assets/{index-BBkuC-EU.js → index-CBr0Tm9_.js} +2 -2
  218. package/node_modules/@comis/web/dist/assets/{mcp-management-DB-phOo7.js → mcp-management-BaH2-vox.js} +1 -1
  219. package/node_modules/@comis/web/dist/assets/{media-config-CRqZ1ZUH.js → media-config-CZLshJoN.js} +1 -1
  220. package/node_modules/@comis/web/dist/assets/{media-test-C9vE20Oy.js → media-test-C9NUWgo_.js} +1 -1
  221. package/node_modules/@comis/web/dist/assets/{memory-inspector-CeqfnxMZ.js → memory-inspector-D_fmTcRN.js} +1 -1
  222. package/node_modules/@comis/web/dist/assets/{message-center-Daup7Mof.js → message-center-BBFlNCZn.js} +1 -1
  223. package/node_modules/@comis/web/dist/assets/{models-DLYnEU8E.js → models-BytGLm99.js} +1 -1
  224. package/node_modules/@comis/web/dist/assets/{observe-view-BTSt_PO5.js → observe-view-VXtHqaqq.js} +1 -1
  225. package/node_modules/@comis/web/dist/assets/{pipeline-builder-DknfzyLt.js → pipeline-builder-CfXczlfJ.js} +1 -1
  226. package/node_modules/@comis/web/dist/assets/{pipeline-history-JnHZdeU_.js → pipeline-history-CPmXFnbe.js} +1 -1
  227. package/node_modules/@comis/web/dist/assets/{pipeline-history-detail-Dg4knsEb.js → pipeline-history-detail-DcueTMs9.js} +1 -1
  228. package/node_modules/@comis/web/dist/assets/{pipeline-list-AEnibjsp.js → pipeline-list-B-xG5WZh.js} +1 -1
  229. package/node_modules/@comis/web/dist/assets/{pipeline-monitor-DG7RbIOO.js → pipeline-monitor-pnIOYaSY.js} +1 -1
  230. package/node_modules/@comis/web/dist/assets/{scheduler-uL1fYKAT.js → scheduler-BtUIFHhA.js} +1 -1
  231. package/node_modules/@comis/web/dist/assets/{security-C3DywRLH.js → security-C8mWRq2y.js} +1 -1
  232. package/node_modules/@comis/web/dist/assets/{session-detail-BtqCNWXV.js → session-detail-DgdkO5ka.js} +1 -1
  233. package/node_modules/@comis/web/dist/assets/{session-list-CJXWa2XT.js → session-list-DcylcfTn.js} +1 -1
  234. package/node_modules/@comis/web/dist/assets/{setup-wizard-ywn7oJvu.js → setup-wizard-BP5yjsuL.js} +75 -39
  235. package/node_modules/@comis/web/dist/assets/{skills-DX0KYnWD.js → skills-DXt1bX8Z.js} +1 -1
  236. package/node_modules/@comis/web/dist/assets/{subagents-B8p5YJEB.js → subagents-C7YbUHXY.js} +1 -1
  237. package/node_modules/@comis/web/dist/assets/{workspace-manager-CgzNIrw1.js → workspace-manager-DP6pW4wa.js} +1 -1
  238. package/node_modules/@comis/web/dist/index.html +1 -1
  239. package/node_modules/@comis/web/package.json +1 -1
  240. package/npm-shrinkwrap.json +6126 -0
  241. package/package.json +74 -74
@@ -14,6 +14,27 @@ import { relative } from "node:path";
14
14
  import { deliverToChannel, formatForChannel } from "@comis/channels";
15
15
  import { resolveAdapter, authorizeChannelAccess } from "../wiring/daemon-utils.js";
16
16
  // ---------------------------------------------------------------------------
17
+ // Helpers
18
+ // ---------------------------------------------------------------------------
19
+ /**
20
+ * Translate the agent's `message_id` argument to the platform-native id when
21
+ * it matches a recently-received inbound message UUID. Returns the original
22
+ * value when no match (already-native id from message.send, expired UUID,
23
+ * cross-channel mismatch). Always returns a string.
24
+ */
25
+ function resolveMessageId(resolver, messageId, channelType, channelId) {
26
+ if (!resolver)
27
+ return messageId;
28
+ const record = resolver.resolve(messageId);
29
+ if (!record)
30
+ return messageId;
31
+ if (record.channelType !== channelType)
32
+ return messageId;
33
+ if (record.channelId !== channelId)
34
+ return messageId;
35
+ return record.nativeId;
36
+ }
37
+ // ---------------------------------------------------------------------------
17
38
  // Capability guard — maps RPC methods to ChannelCapability feature flags.
18
39
  // When channelPlugins is provided, unsupported actions are rejected before
19
40
  // reaching the adapter, saving a tool call and producing a clear error.
@@ -79,7 +100,7 @@ export function createMessageHandlers(deps) {
79
100
  const channelType = params.channel_type;
80
101
  const channelId = params.channel_id;
81
102
  const text = params.text;
82
- const messageId = params.message_id;
103
+ const messageId = resolveMessageId(deps.inboundMessageIdResolver, params.message_id, channelType, channelId);
83
104
  authorizeChannelAccess(params._originChannelId, channelId, params._trustLevel);
84
105
  const adapter = resolveAdapter(channelType, deps.adaptersByType);
85
106
  const extra = {
@@ -103,7 +124,7 @@ export function createMessageHandlers(deps) {
103
124
  const channelType = params.channel_type;
104
125
  assertCapability("message.react", channelType, deps.channelPlugins);
105
126
  const channelId = params.channel_id;
106
- const messageId = params.message_id;
127
+ const messageId = resolveMessageId(deps.inboundMessageIdResolver, params.message_id, channelType, channelId);
107
128
  const emoji = params.emoji;
108
129
  authorizeChannelAccess(params._originChannelId, channelId, params._trustLevel);
109
130
  const adapter = resolveAdapter(channelType, deps.adaptersByType);
@@ -118,7 +139,7 @@ export function createMessageHandlers(deps) {
118
139
  const channelType = params.channel_type;
119
140
  assertCapability("message.edit", channelType, deps.channelPlugins);
120
141
  const channelId = params.channel_id;
121
- const messageId = params.message_id;
142
+ const messageId = resolveMessageId(deps.inboundMessageIdResolver, params.message_id, channelType, channelId);
122
143
  const text = params.text;
123
144
  authorizeChannelAccess(params._originChannelId, channelId, params._trustLevel);
124
145
  const adapter = resolveAdapter(channelType, deps.adaptersByType);
@@ -132,7 +153,7 @@ export function createMessageHandlers(deps) {
132
153
  const channelType = params.channel_type;
133
154
  assertCapability("message.delete", channelType, deps.channelPlugins);
134
155
  const channelId = params.channel_id;
135
- const messageId = params.message_id;
156
+ const messageId = resolveMessageId(deps.inboundMessageIdResolver, params.message_id, channelType, channelId);
136
157
  authorizeChannelAccess(params._originChannelId, channelId, params._trustLevel);
137
158
  const adapter = resolveAdapter(channelType, deps.adaptersByType);
138
159
  const result = await adapter.deleteMessage(channelId, messageId);
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Model management RPC handler module.
3
3
  * Handles model catalog query methods:
4
- * models.list -- List available models (optionally filtered by provider)
5
- * models.test -- Check provider configuration and catalog status
6
- * Both handlers are read-only -- no approval gate required.
4
+ * models.list -- List available models (optionally filtered by provider)
5
+ * models.test -- Check provider configuration and catalog status
6
+ * models.list_providers -- Live native pi-ai catalog provider list (Layer 1F)
7
+ * All handlers are read-only -- no approval gate required.
7
8
  * @module
8
9
  */
9
10
  import type { ModelCatalog } from "@comis/agent";
@@ -2,11 +2,13 @@
2
2
  /**
3
3
  * Model management RPC handler module.
4
4
  * Handles model catalog query methods:
5
- * models.list -- List available models (optionally filtered by provider)
6
- * models.test -- Check provider configuration and catalog status
7
- * Both handlers are read-only -- no approval gate required.
5
+ * models.list -- List available models (optionally filtered by provider)
6
+ * models.test -- Check provider configuration and catalog status
7
+ * models.list_providers -- Live native pi-ai catalog provider list (Layer 1F)
8
+ * All handlers are read-only -- no approval gate required.
8
9
  * @module
9
10
  */
11
+ import { getProviders } from "@mariozechner/pi-ai";
10
12
  // ---------------------------------------------------------------------------
11
13
  // Factory
12
14
  // ---------------------------------------------------------------------------
@@ -62,6 +64,22 @@ export function createModelHandlers(deps) {
62
64
  };
63
65
  },
64
66
  // -----------------------------------------------------------------------
67
+ // List native pi-ai catalog providers (Layer 1F -- 260430-vwt)
68
+ //
69
+ // Live self-discovery for the agent: returns the de-duplicated, sorted
70
+ // list of provider names from the pi-ai native catalog. Pairs with the
71
+ // tool-descriptions auto-promote guidance so the agent can verify
72
+ // which provider_id values trigger promotion in providers.create.
73
+ // -----------------------------------------------------------------------
74
+ "models.list_providers": async (params) => {
75
+ const trustLevel = params._trustLevel;
76
+ if (trustLevel !== "admin") {
77
+ throw new Error("Admin access required");
78
+ }
79
+ const providers = [...new Set(getProviders())].sort();
80
+ return { providers, count: providers.length };
81
+ },
82
+ // -----------------------------------------------------------------------
65
83
  // Test provider configuration and availability
66
84
  // -----------------------------------------------------------------------
67
85
  "models.test": async (params) => {
@@ -16,6 +16,8 @@
16
16
  * @module
17
17
  */
18
18
  import { ProviderEntrySchema } from "@comis/core";
19
+ import { getModels, getProviders } from "@mariozechner/pi-ai";
20
+ import { checkBuiltInProviderRedundancy } from "./builtin-provider-guard.js";
19
21
  import { persistToConfig } from "./persist-to-config.js";
20
22
  import { probeProviderAuth } from "./probe-provider-auth.js";
21
23
  // ---------------------------------------------------------------------------
@@ -68,6 +70,48 @@ function formatReferenceMessage(refs) {
68
70
  }
69
71
  return parts.join("; ");
70
72
  }
73
+ /**
74
+ * Auto-promote a Partial<ProviderEntry> when the `providerId` matches a
75
+ * native pi-ai catalog entry AND the user has not expressed clear intent
76
+ * to deviate from the native shape.
77
+ *
78
+ * The agent's tool guide currently shows `type:"openai"` as the example
79
+ * for any OpenAI-compatible provider. Without promotion, registering
80
+ * "openrouter" by name with that example shape lands a `type:"openai"`
81
+ * entry that bypasses the OpenRouter native catalog (no costs, wrong
82
+ * context window, single explicit model).
83
+ *
84
+ * Promotion fires when:
85
+ * 1. providerId is in the live pi-ai native catalog, AND
86
+ * 2. config.type is missing or set to "openai" (the passthrough sentinel), AND
87
+ * 3. config.baseUrl is missing or matches the native catalog's baseUrl.
88
+ *
89
+ * Conservatism: a user pointing at a custom proxy whose URL differs from
90
+ * the native one keeps their explicit `type:"openai"` shape -- the URL
91
+ * mismatch is the opt-out signal.
92
+ *
93
+ * Logged at INFO with the original_type / promoted_type so operators can
94
+ * see which entries were rewritten on the way in.
95
+ */
96
+ function normalizeProviderEntry(providerId, config, logger) {
97
+ const native = new Set(getProviders());
98
+ if (!native.has(providerId))
99
+ return config;
100
+ const catalog = getModels(providerId);
101
+ const nativeBaseUrl = catalog[0]?.baseUrl;
102
+ const isPassthroughType = !config.type || config.type === "openai";
103
+ const userBaseUrlMatchesNative = !config.baseUrl || config.baseUrl === nativeBaseUrl;
104
+ if (isPassthroughType && userBaseUrlMatchesNative) {
105
+ logger?.info({
106
+ providerId,
107
+ original_type: config.type,
108
+ promoted_type: providerId,
109
+ hint: "Auto-promoted to native pi-ai catalog provider",
110
+ }, "providers.create: type promoted to native");
111
+ return { ...config, type: providerId };
112
+ }
113
+ return config;
114
+ }
71
115
  // ---------------------------------------------------------------------------
72
116
  // Factory
73
117
  // ---------------------------------------------------------------------------
@@ -152,7 +196,22 @@ export function createProviderHandlers(deps) {
152
196
  throw new Error(`Provider already exists: ${providerId}`);
153
197
  }
154
198
  const config = params.config ?? {};
155
- const parsedConfig = ProviderEntrySchema.parse(config);
199
+ // 260501-gyy: reject redundant catalog-shadowing entries before
200
+ // promotion / probe / persist. A built-in provider with a catalog
201
+ // (or absent) baseUrl is structurally redundant -- pi-ai's dynamic
202
+ // catalog already provides its model list. Production trace
203
+ // 2026-05-01 08:53 showed an LLM agent creating
204
+ // providers.entries.openrouter with an invented model id, leading
205
+ // to a downstream 404.
206
+ const guardResult = checkBuiltInProviderRedundancy(providerId, config);
207
+ if (!guardResult.ok) {
208
+ throw new Error(guardResult.reason);
209
+ }
210
+ // Layer 1C (260430-vwt): auto-promote type to native catalog name
211
+ // when the providerId matches a pi-ai catalog entry AND the user has
212
+ // not opted out via a custom baseUrl.
213
+ const normalizedConfig = normalizeProviderEntry(providerId, config, deps.persistDeps?.logger);
214
+ const parsedConfig = ProviderEntrySchema.parse(normalizedConfig);
156
215
  // Probe provider API key before committing config
157
216
  if (parsedConfig.apiKeyName && deps.secretManager) {
158
217
  const apiKey = deps.secretManager.get(parsedConfig.apiKeyName);
@@ -164,11 +223,15 @@ export function createProviderHandlers(deps) {
164
223
  }
165
224
  }
166
225
  deps.providerEntries[providerId] = parsedConfig;
167
- // Best-effort persistence to config.yaml
226
+ // Best-effort persistence to config.yaml. Persist the normalized
227
+ // config (post-Layer-1C promotion) so the YAML reflects the
228
+ // promoted type -- otherwise the daemon would re-promote on every
229
+ // restart, or worse, the persisted type:"openai" would override the
230
+ // runtime promoted type on subsequent loads.
168
231
  if (deps.persistDeps) {
169
232
  const ctx = params._context;
170
233
  const persistResult = await persistToConfig(deps.persistDeps, {
171
- patch: { providers: { entries: { [providerId]: config } } },
234
+ patch: { providers: { entries: { [providerId]: normalizedConfig } } },
172
235
  actionType: "providers.create",
173
236
  entityId: providerId,
174
237
  actingUser: ctx?.userId ?? params._agentId,
@@ -197,12 +260,25 @@ export function createProviderHandlers(deps) {
197
260
  // Capture user-provided fields BEFORE merge -- persistToConfig does deepMerge internally,
198
261
  // so we only persist the user's partial patch (not the fully merged config).
199
262
  const userPatch = params.config ? structuredClone(params.config) : {};
263
+ // Layer 1C (260430-vwt): on update, only auto-promote when the user
264
+ // is actively changing the `type` field. If `type` is absent from
265
+ // the patch, the user is editing other fields and we must not
266
+ // rewrite their existing type silently.
267
+ let normalizedPatch = config;
268
+ if (config.type !== undefined) {
269
+ normalizedPatch = normalizeProviderEntry(providerId, config, deps.persistDeps?.logger);
270
+ // Mirror the promotion into both the in-memory merge and the persisted patch
271
+ // so the YAML matches the runtime view.
272
+ if (normalizedPatch.type !== config.type) {
273
+ userPatch.type = normalizedPatch.type;
274
+ }
275
+ }
200
276
  // Headers: shallow merge per-key (preserve existing keys, overlay new ones)
201
- if (config.headers && existing.headers) {
202
- config.headers = { ...existing.headers, ...config.headers };
277
+ if (normalizedPatch.headers && existing.headers) {
278
+ normalizedPatch.headers = { ...existing.headers, ...normalizedPatch.headers };
203
279
  }
204
280
  // models[] and capabilities: replaced wholesale via spread (no merge needed)
205
- const merged = { ...existing, ...config };
281
+ const merged = { ...existing, ...normalizedPatch };
206
282
  const parsedConfig = ProviderEntrySchema.parse(merged);
207
283
  deps.providerEntries[providerId] = parsedConfig;
208
284
  // Best-effort persistence to config.yaml -- persist userPatch NOT merged config
@@ -77,6 +77,10 @@ export interface RpcDispatchDeps {
77
77
  };
78
78
  };
79
79
  adaptersByType: Map<string, ChannelPort>;
80
+ /** Resolves daemon NormalizedMessage.id UUIDs back to platform-native
81
+ * message ids for message.delete/edit/react. Optional for backward compat
82
+ * with daemon configs that disable channel adapters entirely. */
83
+ inboundMessageIdResolver?: import("../wiring/inbound-message-id-resolver.js").InboundMessageIdResolver;
80
84
  visionRegistry?: Map<string, VisionProvider>;
81
85
  mediaConfig: {
82
86
  imageAnalysis: {
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Resolves daemon-internal `NormalizedMessage.id` UUIDs to platform-native
3
+ * message ids (e.g. Telegram's integer `message_id`) for inbound messages.
4
+ *
5
+ * The agent's tools see `message_id` as the daemon UUID (from session
6
+ * preamble metadata), but channel adapters need the platform-native id when
7
+ * calling APIs like `bot.api.deleteMessage`. Without translation, those calls
8
+ * fail with `400: Bad Request: message identifier is not specified` (Telegram
9
+ * rejects `Number("e60f9634-...")` → `NaN`).
10
+ *
11
+ * Populated lazily on inbound via `record(msg, channelType)`. The native id
12
+ * is read from `msg.metadata[metaKey]` where metaKey comes from the
13
+ * per-channel `replyToMetaKey` capability. Backed by a TTL cache so stale
14
+ * entries don't accumulate.
15
+ *
16
+ * @module
17
+ */
18
+ import type { NormalizedMessage } from "@comis/core";
19
+ /** A single resolved inbound message record. */
20
+ export interface InboundIdRecord {
21
+ channelType: string;
22
+ channelId: string;
23
+ nativeId: string;
24
+ }
25
+ /** UUID → native message-id resolver for cross-channel inbound messages. */
26
+ export interface InboundMessageIdResolver {
27
+ /** Record an inbound message's UUID → native id mapping. No-op if the
28
+ * channel has no registered metadata key or the metadata is missing. */
29
+ record(msg: NormalizedMessage, channelType: string): void;
30
+ /** Look up native id by daemon UUID. Returns undefined if not found. */
31
+ resolve(uuid: string): InboundIdRecord | undefined;
32
+ }
33
+ /** Options for the resolver factory. */
34
+ export interface InboundMessageIdResolverOpts {
35
+ /** Per-channel metadata key carrying the native id, e.g. {"telegram": "telegramMessageId"}. */
36
+ metaKeyByChannel: Map<string, string>;
37
+ /** Time-to-live in ms for cached entries. Defaults to 1 h. */
38
+ ttlMs?: number;
39
+ /** Max entries before LRU eviction. Defaults to 10_000. */
40
+ maxEntries?: number;
41
+ }
42
+ /**
43
+ * Create an inbound-message-id resolver backed by a TTL cache.
44
+ *
45
+ * @param opts Configuration including the per-channel metadata key map.
46
+ * @returns A resolver that records on inbound and resolves UUIDs on lookup.
47
+ */
48
+ export declare function createInboundMessageIdResolver(opts: InboundMessageIdResolverOpts): InboundMessageIdResolver;
@@ -0,0 +1,58 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * Resolves daemon-internal `NormalizedMessage.id` UUIDs to platform-native
4
+ * message ids (e.g. Telegram's integer `message_id`) for inbound messages.
5
+ *
6
+ * The agent's tools see `message_id` as the daemon UUID (from session
7
+ * preamble metadata), but channel adapters need the platform-native id when
8
+ * calling APIs like `bot.api.deleteMessage`. Without translation, those calls
9
+ * fail with `400: Bad Request: message identifier is not specified` (Telegram
10
+ * rejects `Number("e60f9634-...")` → `NaN`).
11
+ *
12
+ * Populated lazily on inbound via `record(msg, channelType)`. The native id
13
+ * is read from `msg.metadata[metaKey]` where metaKey comes from the
14
+ * per-channel `replyToMetaKey` capability. Backed by a TTL cache so stale
15
+ * entries don't accumulate.
16
+ *
17
+ * @module
18
+ */
19
+ import { createTTLCache } from "@comis/shared";
20
+ // ---------------------------------------------------------------------------
21
+ // Factory
22
+ // ---------------------------------------------------------------------------
23
+ /**
24
+ * Create an inbound-message-id resolver backed by a TTL cache.
25
+ *
26
+ * @param opts Configuration including the per-channel metadata key map.
27
+ * @returns A resolver that records on inbound and resolves UUIDs on lookup.
28
+ */
29
+ export function createInboundMessageIdResolver(opts) {
30
+ const ttlMs = opts.ttlMs ?? 60 * 60 * 1000;
31
+ const maxEntries = opts.maxEntries ?? 10_000;
32
+ const cache = createTTLCache({ ttlMs, maxEntries });
33
+ return {
34
+ record(msg, channelType) {
35
+ const metaKey = opts.metaKeyByChannel.get(channelType);
36
+ if (!metaKey)
37
+ return;
38
+ const meta = msg.metadata;
39
+ // metaKey comes from our internal channelCapabilities map (set at adapter
40
+ // bootstrap, not user-controlled), so dynamic access is safe.
41
+ // eslint-disable-next-line security/detect-object-injection
42
+ const raw = meta?.[metaKey];
43
+ if (raw == null)
44
+ return;
45
+ const nativeId = typeof raw === "number"
46
+ ? String(raw)
47
+ : typeof raw === "string"
48
+ ? raw
49
+ : null;
50
+ if (nativeId == null || nativeId.length === 0)
51
+ return;
52
+ cache.set(msg.id, { channelType, channelId: msg.channelId, nativeId });
53
+ },
54
+ resolve(uuid) {
55
+ return cache.get(uuid);
56
+ },
57
+ };
58
+ }
@@ -164,12 +164,24 @@ export declare function setupAgents(deps: {
164
164
  backgroundNotifyFn?: import("@comis/agent").NotifyFn;
165
165
  }): Promise<AgentsResult>;
166
166
  /**
167
- * Resolve "default" model/provider placeholders to global defaults.
168
- * Called once per agent at daemon startup so executors always receive concrete values.
169
- * Resolution order for model:
170
- * 1. modelsConfig.defaultModel (from YAML models.defaultModel)
171
- * 2. DEFAULT_MODEL_PER_PROVIDER[resolvedProvider]
172
- * 3. DEFAULT_MODEL_PER_PROVIDER["anthropic"] (ultimate fallback)
167
+ * Resolve "default" model/provider placeholders to concrete values from the
168
+ * pi-ai catalog. Called once per agent at daemon startup so executors always
169
+ * receive concrete values.
170
+ *
171
+ * Resolution sources, in priority order:
172
+ * 1. Per-agent explicit value (agentConfig.model / .provider not "default")
173
+ * 2. YAML models.defaultModel / models.defaultProvider (operator override)
174
+ * 3. Catalog heuristic for provider: most-populated native pi-ai provider
175
+ * (e.g. openrouter at 249 models > anthropic at 23). Single source of
176
+ * truth — no env var, no hardcoded FALLBACK_PROVIDER. If users want
177
+ * a specific default, they set models.defaultProvider in YAML.
178
+ * 4. Catalog heuristic for model: resolveOperationDefaults(provider).mid
179
+ * (mid-tier cost), falling back to getModels(provider)[0].id.
180
+ *
181
+ * Throws when the pi-ai catalog is empty (zero providers / zero models for
182
+ * the resolved provider) — the caller is asking for a default and we can't
183
+ * synthesize one. Operators can recover by setting models.defaultProvider /
184
+ * models.defaultModel explicitly.
173
185
  */
174
186
  export declare function resolveAgentModel(agentConfig: {
175
187
  model: string;
@@ -12,7 +12,8 @@ import { createHmac } from "node:crypto";
12
12
  import { homedir } from "node:os";
13
13
  import { existsSync, mkdirSync } from "node:fs";
14
14
  import { isAbsolute, resolve } from "node:path";
15
- import { createCircuitBreaker, createBudgetGuard, createCostTracker, createStepCounter, createSessionLifecycle, ensureWorkspace, resolveWorkspaceDir, createPiExecutor, createComisSessionManager, cleanupStaleLocks, createAuthStorageAdapter, createModelRegistryAdapter, registerCustomProviders, createProviderHealthMonitor, createLastKnownModelTracker, createAuthProfileManager, createAuthRotationAdapter, setSanitizeLogger, setToolNormalizationLogger, LEAN_TOOL_DESCRIPTIONS, resolveDescription, } from "@comis/agent";
15
+ import { getModels, getProviders } from "@mariozechner/pi-ai";
16
+ import { createCircuitBreaker, createBudgetGuard, createCostTracker, createStepCounter, createSessionLifecycle, ensureWorkspace, resolveWorkspaceDir, createPiExecutor, createComisSessionManager, cleanupStaleLocks, createAuthStorageAdapter, createModelRegistryAdapter, registerCustomProviders, createProviderHealthMonitor, createLastKnownModelTracker, createAuthProfileManager, createAuthRotationAdapter, setSanitizeLogger, setToolNormalizationLogger, resolveOperationDefaults, resolveCompactionModel, LEAN_TOOL_DESCRIPTIONS, resolveDescription, } from "@comis/agent";
16
17
  import { agentToolsToToolDefinitions, createSkillRegistry, createRuntimeEligibilityContext, TOOL_PROFILES, } from "@comis/skills";
17
18
  // ---------------------------------------------------------------------------
18
19
  // Single-agent setup (extracted for hot-add reuse)
@@ -28,7 +29,14 @@ export async function setupSingleAgent(agentId, rawAgentConfig, deps) {
28
29
  // Validate agent config with Zod before any runtime setup
29
30
  const agentConfig = PerAgentConfigSchema.parse(rawAgentConfig);
30
31
  const { container, memoryAdapter, agentLogger, resolvedAgentDir } = deps;
31
- // Resolve "default" model/provider to global defaults (MODELS-DEFAULT)
32
+ // Resolve "default" model/provider to global defaults (MODELS-DEFAULT).
33
+ // Resolution sources, in priority order:
34
+ // 1. Per-agent explicit value (agentConfig.model / .provider)
35
+ // 2. modelsConfig.defaultModel / .defaultProvider (YAML models.* section)
36
+ // 3. Pi-ai catalog: most-populated native provider (heuristic), mid-tier
37
+ // cost model from resolveOperationDefaults
38
+ // Surfaces resolution source at INFO once per agent so operators can see
39
+ // which model got picked without having to read the resolver source.
32
40
  const modelsConfig = container.config.models;
33
41
  const resolved = resolveAgentModel(agentConfig, modelsConfig);
34
42
  const effectiveConfig = { ...agentConfig, model: resolved.model, provider: resolved.provider };
@@ -37,8 +45,34 @@ export async function setupSingleAgent(agentId, rawAgentConfig, deps) {
37
45
  // see the resolved model/provider instead of the placeholder "default".
38
46
  container.config.agents[agentId] = effectiveConfig;
39
47
  if (agentConfig.model !== resolved.model || agentConfig.provider !== resolved.provider) {
40
- agentLogger.debug({ agentId, originalModel: agentConfig.model, resolvedModel: resolved.model,
41
- originalProvider: agentConfig.provider, resolvedProvider: resolved.provider }, "Resolved default model/provider for agent");
48
+ const source = modelsConfig.defaultModel || modelsConfig.defaultProvider
49
+ ? "explicit_yaml"
50
+ : "catalog_heuristic";
51
+ agentLogger.info({
52
+ agentId,
53
+ originalModel: agentConfig.model,
54
+ resolvedModel: resolved.model,
55
+ originalProvider: agentConfig.provider,
56
+ resolvedProvider: resolved.provider,
57
+ source,
58
+ }, "Resolved default model/provider for agent");
59
+ }
60
+ // Resolve contextEngine.compactionModel if it was left at the empty-string
61
+ // schema default. The resolved value is informational — actual compaction
62
+ // routing flows through resolveOperationModel(operationType: "compaction")
63
+ // at execute-time. Logging at INFO once per agent at startup gives
64
+ // operators a visible record of which model would back background ops.
65
+ const ceCompactionRaw = effectiveConfig.contextEngine?.compactionModel ?? "";
66
+ if (ceCompactionRaw.length === 0) {
67
+ const resolvedCompaction = resolveCompactionModel(ceCompactionRaw, resolved.provider);
68
+ if (resolvedCompaction.length > 0) {
69
+ agentLogger.info({
70
+ agentId,
71
+ primaryProvider: resolved.provider,
72
+ resolvedCompactionModel: resolvedCompaction,
73
+ source: "catalog_heuristic",
74
+ }, "Resolved compactionModel from pi-ai catalog");
75
+ }
42
76
  }
43
77
  // Each agent gets a dedicated workspace folder:
44
78
  // default agent -> ~/.comis/workspace
@@ -423,50 +457,68 @@ export async function setupAgents(deps) {
423
457
  // Helpers
424
458
  // ---------------------------------------------------------------------------
425
459
  /**
426
- * Default model ID per provider, mirroring @mariozechner/pi-coding-agent's
427
- * defaultModelPerProvider. Used when model: "default" and no
428
- * models.defaultModel is configured.
429
- */
430
- const DEFAULT_MODEL_PER_PROVIDER = {
431
- "amazon-bedrock": "us.anthropic.claude-opus-4-6-v1",
432
- anthropic: "claude-opus-4-6",
433
- openai: "gpt-5.1-codex",
434
- "azure-openai-responses": "gpt-5.2",
435
- "openai-codex": "gpt-5.3-codex",
436
- google: "gemini-2.5-pro",
437
- "google-gemini-cli": "gemini-2.5-pro",
438
- "google-antigravity": "gemini-3-pro-high",
439
- "google-vertex": "gemini-3-pro-preview",
440
- "github-copilot": "gpt-4o",
441
- openrouter: "openai/gpt-5.1-codex",
442
- "vercel-ai-gateway": "anthropic/claude-opus-4-6",
443
- xai: "grok-4-fast-non-reasoning",
444
- groq: "openai/gpt-oss-120b",
445
- cerebras: "zai-glm-4.6",
446
- zai: "glm-4.6",
447
- mistral: "devstral-medium-latest",
448
- minimax: "MiniMax-M2.7",
449
- "minimax-cn": "MiniMax-M2.7",
450
- huggingface: "moonshotai/Kimi-K2.5",
451
- opencode: "claude-opus-4-6",
452
- "kimi-coding": "kimi-k2-thinking",
453
- };
454
- const FALLBACK_PROVIDER = "anthropic";
455
- /**
456
- * Resolve "default" model/provider placeholders to global defaults.
457
- * Called once per agent at daemon startup so executors always receive concrete values.
458
- * Resolution order for model:
459
- * 1. modelsConfig.defaultModel (from YAML models.defaultModel)
460
- * 2. DEFAULT_MODEL_PER_PROVIDER[resolvedProvider]
461
- * 3. DEFAULT_MODEL_PER_PROVIDER["anthropic"] (ultimate fallback)
460
+ * Resolve "default" model/provider placeholders to concrete values from the
461
+ * pi-ai catalog. Called once per agent at daemon startup so executors always
462
+ * receive concrete values.
463
+ *
464
+ * Resolution sources, in priority order:
465
+ * 1. Per-agent explicit value (agentConfig.model / .provider not "default")
466
+ * 2. YAML models.defaultModel / models.defaultProvider (operator override)
467
+ * 3. Catalog heuristic for provider: most-populated native pi-ai provider
468
+ * (e.g. openrouter at 249 models > anthropic at 23). Single source of
469
+ * truth — no env var, no hardcoded FALLBACK_PROVIDER. If users want
470
+ * a specific default, they set models.defaultProvider in YAML.
471
+ * 4. Catalog heuristic for model: resolveOperationDefaults(provider).mid
472
+ * (mid-tier cost), falling back to getModels(provider)[0].id.
473
+ *
474
+ * Throws when the pi-ai catalog is empty (zero providers / zero models for
475
+ * the resolved provider) — the caller is asking for a default and we can't
476
+ * synthesize one. Operators can recover by setting models.defaultProvider /
477
+ * models.defaultModel explicitly.
462
478
  */
463
479
  export function resolveAgentModel(agentConfig, modelsConfig) {
464
- const provider = agentConfig.provider.toLowerCase() === "default"
465
- ? (modelsConfig.defaultProvider || FALLBACK_PROVIDER)
466
- : agentConfig.provider;
467
- const model = agentConfig.model.toLowerCase() === "default"
468
- ? (modelsConfig.defaultModel || DEFAULT_MODEL_PER_PROVIDER[provider] || DEFAULT_MODEL_PER_PROVIDER[FALLBACK_PROVIDER])
469
- : agentConfig.model;
480
+ const providerIsDefault = agentConfig.provider.toLowerCase() === "default";
481
+ const modelIsDefault = agentConfig.model.toLowerCase() === "default";
482
+ // Step 1: resolve provider
483
+ let provider;
484
+ if (!providerIsDefault) {
485
+ provider = agentConfig.provider;
486
+ }
487
+ else if (modelsConfig.defaultProvider) {
488
+ provider = modelsConfig.defaultProvider;
489
+ }
490
+ else {
491
+ // Catalog heuristic: most-populated native provider wins.
492
+ const allProviders = getProviders();
493
+ if (allProviders.length === 0) {
494
+ throw new Error("Pi-ai catalog returned zero providers. " +
495
+ "Install or upgrade @mariozechner/pi-ai, or set models.defaultProvider explicitly.");
496
+ }
497
+ provider = allProviders
498
+ .map((p) => ({ p, n: getModels(p).length }))
499
+ .sort((a, b) => b.n - a.n)[0].p;
500
+ }
501
+ // Step 2: resolve model
502
+ let model;
503
+ if (!modelIsDefault) {
504
+ model = agentConfig.model;
505
+ }
506
+ else if (modelsConfig.defaultModel) {
507
+ model = modelsConfig.defaultModel;
508
+ }
509
+ else {
510
+ // Catalog read: prefer mid-tier from resolveOperationDefaults
511
+ // (catalog-derived, cost-aware), fall back to first model id when
512
+ // resolveOperationDefaults returns {} (custom YAML providers).
513
+ const tier = resolveOperationDefaults(provider);
514
+ const firstId = getModels(provider)[0]?.id;
515
+ const candidate = tier.mid ?? firstId;
516
+ if (!candidate) {
517
+ throw new Error(`No models found for provider "${provider}" in pi-ai catalog. ` +
518
+ "Set models.defaultModel explicitly or upgrade @mariozechner/pi-ai.");
519
+ }
520
+ model = candidate;
521
+ }
470
522
  return { model, provider };
471
523
  }
472
524
  /**
@@ -36,6 +36,11 @@ export interface ChannelsResult {
36
36
  approvalNotifier?: ApprovalNotifier;
37
37
  /** Full plugin objects keyed by channel type for capabilities RPC */
38
38
  channelPlugins: Map<string, ChannelPluginPort>;
39
+ /** Per-channel capability info (notably `replyToMetaKey` — the metadata
40
+ * field carrying the platform-native message id). Used by the inbound
41
+ * UUID resolver so message.delete/edit/react can translate daemon UUIDs
42
+ * back to native ids before calling the channel adapter. */
43
+ channelCapabilities: Map<string, import("./setup-channels-adapters.js").ChannelCapabilityInfo>;
39
44
  /** The command queue instance for parent session TTL extension during graph execution. */
40
45
  commandQueue?: CommandQueue;
41
46
  }
@@ -106,7 +111,14 @@ export interface ChannelsDeps {
106
111
  rpcCall?: RpcCall;
107
112
  /** Optional callback for task extraction after successful agent execution (gated by config.scheduler.tasks.enabled). */
108
113
  onTaskExtraction?: (conversationText: string, sessionKey: string, agentId: string) => Promise<void>;
109
- /** Optional callback fired after each successful inbound message processing. Used by restart continuation tracker. */
114
+ /**
115
+ * Optional callback fired BEFORE each inbound message is dispatched to the
116
+ * executor. Used by the restart continuation tracker so the session is
117
+ * visible in tracker state before any tool call could trigger SIGUSR2.
118
+ * Bypassed for early-return paths (no-adapter, graph-report intercept).
119
+ */
120
+ onMessageReceived?: (msg: NormalizedMessage, channelType: string) => void;
121
+ /** Optional callback fired AFTER each successful inbound message processing. Used by post-processing state (e.g. notification session activity recording). */
110
122
  onMessageProcessed?: (msg: NormalizedMessage, channelType: string) => void;
111
123
  /** Optional approval gate for /approve and /deny chat commands in inbound pipeline (APPR-CHAT). */
112
124
  approvalGate?: import("@comis/core").ApprovalGate;
@@ -486,6 +486,7 @@ export async function setupChannels(deps) {
486
486
  } : undefined,
487
487
  // Task extraction callback (gated by config.scheduler.tasks.enabled)
488
488
  onTaskExtraction: deps.onTaskExtraction,
489
+ onMessageReceived: deps.onMessageReceived,
489
490
  onMessageProcessed: deps.onMessageProcessed,
490
491
  // Graph report button callback intercept: deliver full report as .md file attachment
491
492
  onGraphReportRequest: async (graphId, _channelType, channelId, adapter, threadId) => {
@@ -755,5 +756,5 @@ export async function setupChannels(deps) {
755
756
  const resolveAttachmentByUrl = async (url) => {
756
757
  return resolveAttachment({ url, type: "file" });
757
758
  };
758
- return { adaptersByType, channelManager, compositeResolver, resolveAttachment: resolveAttachmentByUrl, lifecycleReactors, approvalNotifier, channelPlugins, commandQueue };
759
+ return { adaptersByType, channelManager, compositeResolver, resolveAttachment: resolveAttachmentByUrl, lifecycleReactors, approvalNotifier, channelPlugins, channelCapabilities, commandQueue };
759
760
  }
@@ -153,7 +153,7 @@ export function registerRpcMethods(deps) {
153
153
  // -------------------------------------------------------------------------
154
154
  // Model management admin methods
155
155
  // -------------------------------------------------------------------------
156
- registerRpcPassthrough(dynamicRouter, rpcCall, ["models.list", "models.test"], "admin");
156
+ registerRpcPassthrough(dynamicRouter, rpcCall, ["models.list", "models.list_providers", "models.test"], "admin");
157
157
  // -------------------------------------------------------------------------
158
158
  // Token management admin methods
159
159
  // -------------------------------------------------------------------------
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@comis/daemon",
3
3
  "private": true,
4
- "version": "1.0.28",
4
+ "version": "1.0.30",
5
5
  "author": "Moshe Anconina",
6
6
  "license": "Apache-2.0",
7
7
  "description": "Background daemon and orchestrator for the Comis platform",
@@ -45,6 +45,6 @@
45
45
  "test": "vitest run"
46
46
  },
47
47
  "optionalDependencies": {
48
- "sd-notify": "^2.8.0"
48
+ "sd-notify": "2.8.0"
49
49
  }
50
50
  }