comisai 1.0.34 → 1.0.36

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 (284) hide show
  1. package/node_modules/@comis/agent/dist/background/auto-background-middleware.d.ts +11 -1
  2. package/node_modules/@comis/agent/dist/background/auto-background-middleware.js +21 -4
  3. package/node_modules/@comis/agent/dist/background/background-task-manager.d.ts +2 -2
  4. package/node_modules/@comis/agent/dist/background/background-task-manager.js +61 -20
  5. package/node_modules/@comis/agent/dist/background/background-task-persistence.js +10 -3
  6. package/node_modules/@comis/agent/dist/background/background-task-types.d.ts +10 -3
  7. package/node_modules/@comis/agent/dist/background/background-task-types.js +1 -1
  8. package/node_modules/@comis/agent/dist/background/completion-formatter.d.ts +39 -0
  9. package/node_modules/@comis/agent/dist/background/completion-formatter.js +77 -0
  10. package/node_modules/@comis/agent/dist/background/completion-runner.d.ts +53 -0
  11. package/node_modules/@comis/agent/dist/background/completion-runner.js +151 -0
  12. package/node_modules/@comis/agent/dist/background/index.d.ts +4 -0
  13. package/node_modules/@comis/agent/dist/background/index.js +2 -0
  14. package/node_modules/@comis/agent/dist/bridge/bridge-metrics.d.ts +17 -2
  15. package/node_modules/@comis/agent/dist/bridge/bridge-metrics.js +14 -2
  16. package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.d.ts +23 -23
  17. package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.js +72 -60
  18. package/node_modules/@comis/agent/dist/bridge/thinking-block-hash-invariant.d.ts +6 -7
  19. package/node_modules/@comis/agent/dist/bridge/thinking-block-hash-invariant.js +24 -25
  20. package/node_modules/@comis/agent/dist/budget/cost-tracker.d.ts +1 -1
  21. package/node_modules/@comis/agent/dist/context-engine/constants.d.ts +5 -5
  22. package/node_modules/@comis/agent/dist/context-engine/constants.js +12 -12
  23. package/node_modules/@comis/agent/dist/context-engine/context-engine.js +13 -4
  24. package/node_modules/@comis/agent/dist/context-engine/dag-annotator.d.ts +1 -2
  25. package/node_modules/@comis/agent/dist/context-engine/dag-annotator.js +1 -2
  26. package/node_modules/@comis/agent/dist/context-engine/llm-compaction.js +20 -16
  27. package/node_modules/@comis/agent/dist/context-engine/rehydration.js +6 -6
  28. package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.d.ts +12 -12
  29. package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.js +36 -22
  30. package/node_modules/@comis/agent/dist/context-engine/types-core.d.ts +15 -0
  31. package/node_modules/@comis/agent/dist/executor/cache-break-detection.d.ts +6 -6
  32. package/node_modules/@comis/agent/dist/executor/cache-break-detection.js +8 -8
  33. package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.d.ts +16 -0
  34. package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.js +46 -5
  35. package/node_modules/@comis/agent/dist/executor/executor-post-execution.d.ts +30 -0
  36. package/node_modules/@comis/agent/dist/executor/executor-post-execution.js +17 -1
  37. package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.js +1 -1
  38. package/node_modules/@comis/agent/dist/executor/executor-response-filter.d.ts +7 -6
  39. package/node_modules/@comis/agent/dist/executor/executor-response-filter.js +9 -42
  40. package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.js +2 -3
  41. package/node_modules/@comis/agent/dist/executor/gemini-cache-injector.d.ts +2 -2
  42. package/node_modules/@comis/agent/dist/executor/gemini-cache-injector.js +4 -4
  43. package/node_modules/@comis/agent/dist/executor/phase-filter.d.ts +2 -2
  44. package/node_modules/@comis/agent/dist/executor/phase-filter.js +5 -7
  45. package/node_modules/@comis/agent/dist/executor/pi-executor.d.ts +13 -0
  46. package/node_modules/@comis/agent/dist/executor/pi-executor.js +71 -6
  47. package/node_modules/@comis/agent/dist/executor/post-batch-continuation.js +7 -7
  48. package/node_modules/@comis/agent/dist/executor/stream-wrappers/request-body-injector.d.ts +1 -1
  49. package/node_modules/@comis/agent/dist/executor/stream-wrappers/request-body-injector.js +1 -1
  50. package/node_modules/@comis/agent/dist/executor/tool-deferral.d.ts +2 -2
  51. package/node_modules/@comis/agent/dist/executor/tool-deferral.js +7 -7
  52. package/node_modules/@comis/agent/dist/index.d.ts +17 -0
  53. package/node_modules/@comis/agent/dist/index.js +32 -11
  54. package/node_modules/@comis/agent/dist/model/auth-provider.d.ts +25 -2
  55. package/node_modules/@comis/agent/dist/model/auth-provider.js +6 -0
  56. package/node_modules/@comis/agent/dist/model/compaction-model-resolver.d.ts +3 -3
  57. package/node_modules/@comis/agent/dist/model/compaction-model-resolver.js +3 -3
  58. package/node_modules/@comis/agent/dist/model/oauth-credential-store-file.d.ts +37 -0
  59. package/node_modules/@comis/agent/dist/model/oauth-credential-store-file.js +279 -0
  60. package/node_modules/@comis/agent/dist/model/oauth-credential-store-selector.d.ts +49 -0
  61. package/node_modules/@comis/agent/dist/model/oauth-credential-store-selector.js +50 -0
  62. package/node_modules/@comis/agent/dist/model/oauth-device-code.d.ts +57 -0
  63. package/node_modules/@comis/agent/dist/model/oauth-device-code.js +302 -0
  64. package/node_modules/@comis/agent/dist/model/oauth-env.d.ts +33 -0
  65. package/node_modules/@comis/agent/dist/model/oauth-env.js +38 -0
  66. package/node_modules/@comis/agent/dist/model/oauth-errors.d.ts +41 -0
  67. package/node_modules/@comis/agent/dist/model/oauth-errors.js +88 -0
  68. package/node_modules/@comis/agent/dist/model/oauth-identity.d.ts +53 -0
  69. package/node_modules/@comis/agent/dist/model/oauth-identity.js +141 -0
  70. package/node_modules/@comis/agent/dist/model/oauth-login-runner.d.ts +99 -0
  71. package/node_modules/@comis/agent/dist/model/oauth-login-runner.js +374 -0
  72. package/node_modules/@comis/agent/dist/model/oauth-tls-preflight.d.ts +58 -0
  73. package/node_modules/@comis/agent/dist/model/oauth-tls-preflight.js +82 -0
  74. package/node_modules/@comis/agent/dist/model/oauth-token-manager.d.ts +86 -16
  75. package/node_modules/@comis/agent/dist/model/oauth-token-manager.js +961 -66
  76. package/node_modules/@comis/agent/dist/model/operation-model-defaults.d.ts +9 -4
  77. package/node_modules/@comis/agent/dist/model/operation-model-defaults.js +36 -9
  78. package/node_modules/@comis/agent/dist/model/resolve-provider-api-key.d.ts +48 -0
  79. package/node_modules/@comis/agent/dist/model/resolve-provider-api-key.js +66 -0
  80. package/node_modules/@comis/agent/dist/provider/capabilities.d.ts +5 -5
  81. package/node_modules/@comis/agent/dist/provider/capabilities.js +10 -23
  82. package/node_modules/@comis/agent/dist/safety/tool-output-safety.js +3 -3
  83. package/node_modules/@comis/agent/dist/session/comis-session-manager.d.ts +1 -1
  84. package/node_modules/@comis/agent/dist/session/comis-session-manager.js +1 -1
  85. package/node_modules/@comis/agent/dist/spawn/narrative-caster.d.ts +10 -0
  86. package/node_modules/@comis/agent/dist/spawn/narrative-caster.js +5 -1
  87. package/node_modules/@comis/agent/package.json +1 -1
  88. package/node_modules/@comis/channels/dist/email/email-adapter.js +6 -6
  89. package/node_modules/@comis/channels/dist/email/imap-lifecycle.js +7 -7
  90. package/node_modules/@comis/channels/dist/shared/deliver-to-channel.js +12 -10
  91. package/node_modules/@comis/channels/dist/telegram/telegram-adapter.js +1 -1
  92. package/node_modules/@comis/channels/package.json +1 -1
  93. package/node_modules/@comis/cli/dist/cli.js +2 -0
  94. package/node_modules/@comis/cli/dist/commands/agent.d.ts +3 -3
  95. package/node_modules/@comis/cli/dist/commands/agent.js +46 -3
  96. package/node_modules/@comis/cli/dist/commands/auth.d.ts +37 -0
  97. package/node_modules/@comis/cli/dist/commands/auth.js +433 -0
  98. package/node_modules/@comis/cli/dist/commands/doctor.d.ts +4 -1
  99. package/node_modules/@comis/cli/dist/commands/doctor.js +20 -5
  100. package/node_modules/@comis/cli/dist/doctor/checks/oauth-health.d.ts +39 -0
  101. package/node_modules/@comis/cli/dist/doctor/checks/oauth-health.js +399 -0
  102. package/node_modules/@comis/cli/dist/doctor/types.d.ts +19 -0
  103. package/node_modules/@comis/cli/dist/index.d.ts +1 -0
  104. package/node_modules/@comis/cli/dist/index.js +10 -4
  105. package/node_modules/@comis/cli/dist/output/relative-time.d.ts +23 -0
  106. package/node_modules/@comis/cli/dist/output/relative-time.js +36 -0
  107. package/node_modules/@comis/cli/dist/wizard/non-interactive.js +17 -8
  108. package/node_modules/@comis/cli/dist/wizard/steps/03-provider.js +2 -1
  109. package/node_modules/@comis/cli/dist/wizard/steps/04-credentials.js +223 -34
  110. package/node_modules/@comis/cli/dist/wizard/steps/10-write-config.js +14 -0
  111. package/node_modules/@comis/cli/dist/wizard/steps/11-daemon-start.js +3 -3
  112. package/node_modules/@comis/cli/dist/wizard/types.d.ts +7 -0
  113. package/node_modules/@comis/cli/package.json +1 -1
  114. package/node_modules/@comis/core/dist/bootstrap.d.ts +1 -1
  115. package/node_modules/@comis/core/dist/config/env-substitution.d.ts +66 -0
  116. package/node_modules/@comis/core/dist/config/env-substitution.js +115 -0
  117. package/node_modules/@comis/core/dist/config/index.d.ts +3 -1
  118. package/node_modules/@comis/core/dist/config/index.js +2 -1
  119. package/node_modules/@comis/core/dist/config/loader.js +61 -0
  120. package/node_modules/@comis/core/dist/config/managed-sections.d.ts +3 -3
  121. package/node_modules/@comis/core/dist/config/managed-sections.js +10 -5
  122. package/node_modules/@comis/core/dist/config/schema-agent.d.ts +4 -0
  123. package/node_modules/@comis/core/dist/config/schema-agent.js +16 -1
  124. package/node_modules/@comis/core/dist/config/schema-background-tasks.d.ts +7 -0
  125. package/node_modules/@comis/core/dist/config/schema-background-tasks.js +7 -0
  126. package/node_modules/@comis/core/dist/config/schema-delivery.d.ts +2 -0
  127. package/node_modules/@comis/core/dist/config/schema-delivery.js +2 -0
  128. package/node_modules/@comis/core/dist/config/schema-gemini-cache.d.ts +0 -2
  129. package/node_modules/@comis/core/dist/config/schema-gemini-cache.js +0 -2
  130. package/node_modules/@comis/core/dist/config/schema-oauth.d.ts +23 -0
  131. package/node_modules/@comis/core/dist/config/schema-oauth.js +19 -0
  132. package/node_modules/@comis/core/dist/config/schema-skills.d.ts +6 -8
  133. package/node_modules/@comis/core/dist/config/schema-skills.js +3 -4
  134. package/node_modules/@comis/core/dist/config/schema.d.ts +10 -0
  135. package/node_modules/@comis/core/dist/config/schema.js +3 -0
  136. package/node_modules/@comis/core/dist/domain/background-task-origin.d.ts +39 -0
  137. package/node_modules/@comis/core/dist/domain/background-task-origin.js +39 -0
  138. package/node_modules/@comis/core/dist/event-bus/events-infra.d.ts +71 -2
  139. package/node_modules/@comis/core/dist/exports/config.d.ts +2 -2
  140. package/node_modules/@comis/core/dist/exports/config.js +1 -1
  141. package/node_modules/@comis/core/dist/exports/domain.d.ts +2 -0
  142. package/node_modules/@comis/core/dist/exports/domain.js +1 -0
  143. package/node_modules/@comis/core/dist/exports/ports.d.ts +2 -2
  144. package/node_modules/@comis/core/dist/exports/ports.js +1 -1
  145. package/node_modules/@comis/core/dist/ports/delivery-queue.d.ts +23 -0
  146. package/node_modules/@comis/core/dist/ports/delivery-queue.js +2 -0
  147. package/node_modules/@comis/core/dist/ports/index.d.ts +2 -0
  148. package/node_modules/@comis/core/dist/ports/index.js +1 -0
  149. package/node_modules/@comis/core/dist/ports/oauth-credential-store.d.ts +64 -0
  150. package/node_modules/@comis/core/dist/ports/oauth-credential-store.js +37 -0
  151. package/node_modules/@comis/core/dist/tool-metadata.d.ts +20 -0
  152. package/node_modules/@comis/core/package.json +1 -1
  153. package/node_modules/@comis/daemon/dist/daemon-types.d.ts +23 -3
  154. package/node_modules/@comis/daemon/dist/daemon.js +82 -19
  155. package/node_modules/@comis/daemon/dist/index.d.ts +2 -0
  156. package/node_modules/@comis/daemon/dist/index.js +5 -0
  157. package/node_modules/@comis/daemon/dist/observability/channel-health-logger.js +3 -3
  158. package/node_modules/@comis/daemon/dist/observability/delivery-queue-logger.js +1 -1
  159. package/node_modules/@comis/daemon/dist/rpc/agent-handlers.d.ts +22 -1
  160. package/node_modules/@comis/daemon/dist/rpc/agent-handlers.js +84 -21
  161. package/node_modules/@comis/daemon/dist/rpc/agent-inline-workspace.js +2 -2
  162. package/node_modules/@comis/daemon/dist/rpc/config-handlers.d.ts +9 -1
  163. package/node_modules/@comis/daemon/dist/rpc/config-handlers.js +104 -23
  164. package/node_modules/@comis/daemon/dist/rpc/credential-resolver.d.ts +30 -1
  165. package/node_modules/@comis/daemon/dist/rpc/credential-resolver.js +74 -11
  166. package/node_modules/@comis/daemon/dist/rpc/mcp-handlers.d.ts +8 -0
  167. package/node_modules/@comis/daemon/dist/rpc/mcp-handlers.js +22 -8
  168. package/node_modules/@comis/daemon/dist/rpc/provider-handlers.js +9 -12
  169. package/node_modules/@comis/daemon/dist/rpc/rpc-dispatch.d.ts +1 -0
  170. package/node_modules/@comis/daemon/dist/rpc/rpc-dispatch.js +27 -2
  171. package/node_modules/@comis/daemon/dist/setup-docker-restart-warn.js +0 -1
  172. package/node_modules/@comis/daemon/dist/wiring/index.d.ts +2 -0
  173. package/node_modules/@comis/daemon/dist/wiring/index.js +1 -0
  174. package/node_modules/@comis/daemon/dist/wiring/oauth-preflight.d.ts +21 -0
  175. package/node_modules/@comis/daemon/dist/wiring/oauth-preflight.js +134 -0
  176. package/node_modules/@comis/daemon/dist/wiring/setup-agents.d.ts +46 -1
  177. package/node_modules/@comis/daemon/dist/wiring/setup-agents.js +127 -3
  178. package/node_modules/@comis/daemon/dist/wiring/setup-background-completion-runner.d.ts +39 -0
  179. package/node_modules/@comis/daemon/dist/wiring/setup-background-completion-runner.js +32 -0
  180. package/node_modules/@comis/daemon/dist/wiring/setup-background-tasks.d.ts +10 -3
  181. package/node_modules/@comis/daemon/dist/wiring/setup-background-tasks.js +11 -5
  182. package/node_modules/@comis/daemon/dist/wiring/setup-channels.js +20 -1
  183. package/node_modules/@comis/daemon/dist/wiring/setup-cross-session.js +1 -1
  184. package/node_modules/@comis/daemon/dist/wiring/setup-delivery.d.ts +14 -5
  185. package/node_modules/@comis/daemon/dist/wiring/setup-delivery.js +52 -19
  186. package/node_modules/@comis/daemon/dist/wiring/setup-schedulers.js +4 -0
  187. package/node_modules/@comis/daemon/package.json +1 -1
  188. package/node_modules/@comis/gateway/dist/index.d.ts +2 -0
  189. package/node_modules/@comis/gateway/dist/index.js +2 -0
  190. package/node_modules/@comis/gateway/dist/oauth/oauth-callback-route.d.ts +66 -0
  191. package/node_modules/@comis/gateway/dist/oauth/oauth-callback-route.js +212 -0
  192. package/node_modules/@comis/gateway/dist/server/hono-server.d.ts +14 -0
  193. package/node_modules/@comis/gateway/dist/server/hono-server.js +10 -0
  194. package/node_modules/@comis/gateway/package.json +1 -1
  195. package/node_modules/@comis/infra/dist/logging/log-fields.d.ts +23 -0
  196. package/node_modules/@comis/infra/package.json +1 -1
  197. package/node_modules/@comis/memory/dist/compaction.d.ts +3 -5
  198. package/node_modules/@comis/memory/dist/compaction.js +2 -3
  199. package/node_modules/@comis/memory/dist/delivery-queue-adapter.d.ts +2 -2
  200. package/node_modules/@comis/memory/dist/delivery-queue-adapter.js +49 -1
  201. package/node_modules/@comis/memory/dist/index.d.ts +2 -0
  202. package/node_modules/@comis/memory/dist/index.js +3 -0
  203. package/node_modules/@comis/memory/dist/memory-api.d.ts +1 -1
  204. package/node_modules/@comis/memory/dist/memory-api.js +1 -1
  205. package/node_modules/@comis/memory/dist/oauth-profile-schema.d.ts +17 -0
  206. package/node_modules/@comis/memory/dist/oauth-profile-schema.js +33 -0
  207. package/node_modules/@comis/memory/dist/oauth-profile-store-encrypted.d.ts +27 -0
  208. package/node_modules/@comis/memory/dist/oauth-profile-store-encrypted.js +144 -0
  209. package/node_modules/@comis/memory/dist/session-store.d.ts +1 -1
  210. package/node_modules/@comis/memory/dist/session-store.js +1 -1
  211. package/node_modules/@comis/memory/dist/sqlite-secret-store.d.ts +29 -3
  212. package/node_modules/@comis/memory/dist/sqlite-secret-store.js +11 -3
  213. package/node_modules/@comis/memory/package.json +1 -1
  214. package/node_modules/@comis/scheduler/dist/execution/execution-lock.d.ts +13 -0
  215. package/node_modules/@comis/scheduler/dist/execution/execution-lock.js +1 -1
  216. package/node_modules/@comis/scheduler/dist/execution/index.d.ts +2 -0
  217. package/node_modules/@comis/scheduler/dist/execution/index.js +2 -0
  218. package/node_modules/@comis/scheduler/dist/heartbeat/agent-heartbeat-source.js +1 -1
  219. package/node_modules/@comis/scheduler/dist/index.d.ts +2 -0
  220. package/node_modules/@comis/scheduler/dist/index.js +2 -0
  221. package/node_modules/@comis/scheduler/package.json +1 -1
  222. package/node_modules/@comis/shared/package.json +1 -1
  223. package/node_modules/@comis/skills/dist/bridge/schema-validator.d.ts +38 -0
  224. package/node_modules/@comis/skills/dist/bridge/schema-validator.js +169 -0
  225. package/node_modules/@comis/skills/dist/bridge/tool-metadata-enforcement.js +12 -0
  226. package/node_modules/@comis/skills/dist/bridge/tool-metadata-registry.js +130 -0
  227. package/node_modules/@comis/skills/dist/builtin/exec-diagnostics.d.ts +32 -0
  228. package/node_modules/@comis/skills/dist/builtin/exec-diagnostics.js +127 -0
  229. package/node_modules/@comis/skills/dist/builtin/exec-security.js +38 -0
  230. package/node_modules/@comis/skills/dist/builtin/exec-tool.js +9 -0
  231. package/node_modules/@comis/skills/dist/builtin/file-tools/grep-tool.js +6 -6
  232. package/node_modules/@comis/skills/dist/builtin/platform/agents-manage-tool.d.ts +5 -4
  233. package/node_modules/@comis/skills/dist/builtin/platform/agents-manage-tool.js +38 -27
  234. package/node_modules/@comis/skills/dist/builtin/platform/background-tasks-tool.d.ts +4 -1
  235. package/node_modules/@comis/skills/dist/builtin/platform/background-tasks-tool.js +3 -3
  236. package/node_modules/@comis/skills/dist/builtin/platform/cron-tool.js +1 -1
  237. package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.js +6 -6
  238. package/node_modules/@comis/skills/dist/builtin/platform/mcp-manage-tool.d.ts +1 -1
  239. package/node_modules/@comis/skills/dist/builtin/platform/mcp-manage-tool.js +9 -9
  240. package/node_modules/@comis/skills/dist/builtin/sandbox/bwrap-provider.d.ts +11 -0
  241. package/node_modules/@comis/skills/dist/builtin/sandbox/bwrap-provider.js +114 -1
  242. package/node_modules/@comis/skills/dist/builtin/sandbox/detect-provider.js +40 -15
  243. package/node_modules/@comis/skills/dist/media/ssrf-fetcher.d.ts +7 -0
  244. package/node_modules/@comis/skills/dist/media/ssrf-fetcher.js +9 -2
  245. package/node_modules/@comis/skills/package.json +1 -1
  246. package/node_modules/@comis/web/dist/assets/{agent-detail-71BSbSfD.js → agent-detail-q8t1NB7w.js} +1 -1
  247. package/node_modules/@comis/web/dist/assets/{agent-editor-CTSDZhwT.js → agent-editor-B46io5gv.js} +1 -1
  248. package/node_modules/@comis/web/dist/assets/{agent-list-BEhni2ea.js → agent-list-DQ6g2Rcx.js} +1 -1
  249. package/node_modules/@comis/web/dist/assets/{billing-view-DVP1IvVs.js → billing-view-IWPR8LgF.js} +1 -1
  250. package/node_modules/@comis/web/dist/assets/{channel-detail-N_YK74xC.js → channel-detail-DlNNZuuC.js} +1 -1
  251. package/node_modules/@comis/web/dist/assets/{channel-list-DRk6ZJaF.js → channel-list-DhGwxiMc.js} +1 -1
  252. package/node_modules/@comis/web/dist/assets/{chat-console-Dm-GtSf9.js → chat-console-Nv6fM3Rc.js} +1 -1
  253. package/node_modules/@comis/web/dist/assets/{config-editor-CIferYX6.js → config-editor-BYKuJF76.js} +1 -1
  254. package/node_modules/@comis/web/dist/assets/{context-dag-browser-CL84rXXM.js → context-dag-browser-ClNEtzYE.js} +1 -1
  255. package/node_modules/@comis/web/dist/assets/{context-engine-B1HOTEZv.js → context-engine-BZJ6HChd.js} +1 -1
  256. package/node_modules/@comis/web/dist/assets/{delivery-view-Y6JKYVFw.js → delivery-view-Cb7I3vGu.js} +1 -1
  257. package/node_modules/@comis/web/dist/assets/{diagnostics-view-DWV1UQjz.js → diagnostics-view-9u9Lyu5a.js} +1 -1
  258. package/node_modules/@comis/web/dist/assets/{ic-chat-message-DfSERzzg.js → ic-chat-message-BFt3cVpx.js} +1 -1
  259. package/node_modules/@comis/web/dist/assets/{ic-connection-dot-CXyhlJup.js → ic-connection-dot-y77LZ3Gu.js} +1 -1
  260. package/node_modules/@comis/web/dist/assets/{ic-tool-call-DNmwTjek.js → ic-tool-call-qt6w1NQl.js} +1 -1
  261. package/node_modules/@comis/web/dist/assets/{index-CBr0Tm9_.js → index-8Tg9oc-C.js} +2 -2
  262. package/node_modules/@comis/web/dist/assets/{mcp-management-BaH2-vox.js → mcp-management-69dtH_kY.js} +2 -2
  263. package/node_modules/@comis/web/dist/assets/{media-config-CZLshJoN.js → media-config-BdjLj5c1.js} +1 -1
  264. package/node_modules/@comis/web/dist/assets/{media-test-C9NUWgo_.js → media-test-DuPqrixi.js} +1 -1
  265. package/node_modules/@comis/web/dist/assets/{memory-inspector-D_fmTcRN.js → memory-inspector-B-Pepbq-.js} +1 -1
  266. package/node_modules/@comis/web/dist/assets/{message-center-BBFlNCZn.js → message-center-B7l0yNYY.js} +1 -1
  267. package/node_modules/@comis/web/dist/assets/{models-BytGLm99.js → models-JHFHuv5S.js} +1 -1
  268. package/node_modules/@comis/web/dist/assets/{observe-view-VXtHqaqq.js → observe-view-r8mqhy4O.js} +1 -1
  269. package/node_modules/@comis/web/dist/assets/{pipeline-builder-CfXczlfJ.js → pipeline-builder-XjkiZRcR.js} +1 -1
  270. package/node_modules/@comis/web/dist/assets/{pipeline-history-CPmXFnbe.js → pipeline-history-CZqJv_Hj.js} +1 -1
  271. package/node_modules/@comis/web/dist/assets/{pipeline-history-detail-DcueTMs9.js → pipeline-history-detail-BEFGMoDy.js} +1 -1
  272. package/node_modules/@comis/web/dist/assets/{pipeline-list-B-xG5WZh.js → pipeline-list-B6q5LvO1.js} +1 -1
  273. package/node_modules/@comis/web/dist/assets/{pipeline-monitor-pnIOYaSY.js → pipeline-monitor-BNomXjVL.js} +1 -1
  274. package/node_modules/@comis/web/dist/assets/{scheduler-BtUIFHhA.js → scheduler-BJEjcGKA.js} +1 -1
  275. package/node_modules/@comis/web/dist/assets/{security-C8mWRq2y.js → security-2G1jhBfV.js} +1 -1
  276. package/node_modules/@comis/web/dist/assets/{session-detail-DgdkO5ka.js → session-detail-DmVPzFBR.js} +1 -1
  277. package/node_modules/@comis/web/dist/assets/{session-list-DcylcfTn.js → session-list-CsqMQoHs.js} +1 -1
  278. package/node_modules/@comis/web/dist/assets/{setup-wizard-BP5yjsuL.js → setup-wizard-CAdM-gSP.js} +1 -1
  279. package/node_modules/@comis/web/dist/assets/{skills-DXt1bX8Z.js → skills-2ODqKaWr.js} +1 -1
  280. package/node_modules/@comis/web/dist/assets/{subagents-C7YbUHXY.js → subagents-BFlwfTbD.js} +1 -1
  281. package/node_modules/@comis/web/dist/assets/{workspace-manager-DP6pW4wa.js → workspace-manager--CbOx_dI.js} +1 -1
  282. package/node_modules/@comis/web/dist/index.html +1 -1
  283. package/node_modules/@comis/web/package.json +1 -1
  284. package/package.json +17 -16
@@ -12,9 +12,10 @@
12
12
  * (because the old map was Anthropic/OpenAI/Google only).
13
13
  *
14
14
  * Tier picking: filter to text-capable models with non-zero cost, sort
15
- * ascending by total cost (input + output), pick 10th-percentile = `fast`,
16
- * 50th-percentile = `mid`. All-free-models providers (e.g. local Ollama,
17
- * Z.AI most models) fall back to "first text-capable id" for both slots.
15
+ * ascending by total cost (input + output), pick top-of-cohort (lex-greatest
16
+ * within the cost bucket) at the 10th-percentile = `fast`, 50th-percentile =
17
+ * `mid`. All-free-models providers (e.g. local Ollama, Z.AI most models)
18
+ * fall back to "first text-capable id" for both slots.
18
19
  *
19
20
  * @module
20
21
  */
@@ -32,7 +33,11 @@ import type { ModelOperationType } from "@comis/core";
32
33
  * 3. Filter to non-zero cost (eliminates free/local-only models from
33
34
  * ranking — they won't be reachable in production).
34
35
  * 4. Sort ascending by total cost.
35
- * 5. `fast` = 10th percentile, `mid` = 50th percentile.
36
+ * 5. `fast` and `mid` are top-of-cohort at the 10th and 50th percentile
37
+ * respectively (lex-greatest ID within the cost bucket the percentile
38
+ * lands in). Cost ties broken by lex-greatest ID — avoids picking a
39
+ * model purely because of catalog iteration order (e.g. 9 Anthropic
40
+ * Sonnets all at $18/MTok).
36
41
  * 6. If post-filter set is empty (all-free provider), use the first
37
42
  * text-capable model id for both slots.
38
43
  *
@@ -13,9 +13,10 @@
13
13
  * (because the old map was Anthropic/OpenAI/Google only).
14
14
  *
15
15
  * Tier picking: filter to text-capable models with non-zero cost, sort
16
- * ascending by total cost (input + output), pick 10th-percentile = `fast`,
17
- * 50th-percentile = `mid`. All-free-models providers (e.g. local Ollama,
18
- * Z.AI most models) fall back to "first text-capable id" for both slots.
16
+ * ascending by total cost (input + output), pick top-of-cohort (lex-greatest
17
+ * within the cost bucket) at the 10th-percentile = `fast`, 50th-percentile =
18
+ * `mid`. All-free-models providers (e.g. local Ollama, Z.AI most models)
19
+ * fall back to "first text-capable id" for both slots.
19
20
  *
20
21
  * @module
21
22
  */
@@ -29,6 +30,31 @@ const _nativeProviderSet = new Set(getProviders());
29
30
  function totalCost(m) {
30
31
  return (m.cost?.input ?? 0) + (m.cost?.output ?? 0);
31
32
  }
33
+ /**
34
+ * Pick the "top of cohort" model from a cost-ascending list.
35
+ *
36
+ * Identifies the cost bucket the given percentile lands in, then returns
37
+ * the lex-greatest ID within that bucket. Lex-greatest is a deterministic
38
+ * proxy for "newest/highest version" across the providers we ship — for
39
+ * dated IDs (YYYY-MM-DD, YYMM) and semver-ish IDs (claude-sonnet-4-6 >
40
+ * claude-sonnet-4-5) the lex order matches recency.
41
+ *
42
+ * Why not just take `sortedAsc[idx]`? JavaScript's stable sort preserves
43
+ * original-array order within a cost-tied block, so the previous algorithm
44
+ * picked whatever the catalog happened to enumerate first. With 9 priced
45
+ * Anthropic Sonnets all at $18/MTok, that was `claude-sonnet-4-5` — picked
46
+ * by accident, not by quality signal.
47
+ *
48
+ * Module-internal — not exported.
49
+ */
50
+ function pickFromCohort(sortedAsc, percentile) {
51
+ if (sortedAsc.length === 0)
52
+ return undefined;
53
+ const idx = Math.min(sortedAsc.length - 1, Math.floor(sortedAsc.length * percentile));
54
+ const cohortCost = totalCost(sortedAsc[idx]);
55
+ const cohort = sortedAsc.filter((m) => totalCost(m) === cohortCost);
56
+ return [...cohort].sort((a, b) => b.id.localeCompare(a.id))[0]?.id;
57
+ }
32
58
  /**
33
59
  * Resolve cost-tier model defaults for a given native pi-ai provider.
34
60
  *
@@ -42,7 +68,11 @@ function totalCost(m) {
42
68
  * 3. Filter to non-zero cost (eliminates free/local-only models from
43
69
  * ranking — they won't be reachable in production).
44
70
  * 4. Sort ascending by total cost.
45
- * 5. `fast` = 10th percentile, `mid` = 50th percentile.
71
+ * 5. `fast` and `mid` are top-of-cohort at the 10th and 50th percentile
72
+ * respectively (lex-greatest ID within the cost bucket the percentile
73
+ * lands in). Cost ties broken by lex-greatest ID — avoids picking a
74
+ * model purely because of catalog iteration order (e.g. 9 Anthropic
75
+ * Sonnets all at $18/MTok).
46
76
  * 6. If post-filter set is empty (all-free provider), use the first
47
77
  * text-capable model id for both slots.
48
78
  *
@@ -67,12 +97,9 @@ export function resolveOperationDefaults(provider) {
67
97
  const fallback = textCapable[0]?.id;
68
98
  return { fast: fallback, mid: fallback };
69
99
  }
70
- // Math.min clamp guards single-element arrays (10% of 1 -> 0).
71
- const fastIdx = Math.min(priced.length - 1, Math.floor(priced.length * 0.1));
72
- const midIdx = Math.min(priced.length - 1, Math.floor(priced.length * 0.5));
73
100
  return {
74
- fast: priced[fastIdx].id,
75
- mid: priced[midIdx].id,
101
+ fast: pickFromCohort(priced, 0.1),
102
+ mid: pickFromCohort(priced, 0.5),
76
103
  };
77
104
  }
78
105
  // ---------------------------------------------------------------------------
@@ -0,0 +1,48 @@
1
+ /**
2
+ * resolveProviderApiKey: shared dispatch helper that routes OAuth-eligible
3
+ * providers through the OAuthTokenManager + AuthStorage.setRuntimeApiKey
4
+ * side-effect, and non-OAuth providers through the existing authStorage path.
5
+ *
6
+ * Single attachment surface for the per-LLM-call OAuth dispatch
7
+ * hook. Used by PiExecutor.execute() pre-hook (primary LLM call) and the two
8
+ * compaction getApiKey callbacks in executor-context-engine-setup.ts.
9
+ *
10
+ * Return shape is `Promise<string>` (NOT `Result<T,E>`) because the helper
11
+ * bridges Comis's Result-typed manager with pi-coding-agent's
12
+ * `AuthStorage.getApiKey` contract; the throw mirrors pi-coding-agent's own
13
+ * throw-on-failure shape. On OAuthError the helper propagates a thrown Error —
14
+ * no env-var fallback, no retry, no silent rotation. Outer callers
15
+ * (PiExecutor.execute, gateway routes) surface the throw to the user via their
16
+ * existing error-handling path.
17
+ *
18
+ * @module
19
+ */
20
+ import type { AuthStorage } from "@mariozechner/pi-coding-agent";
21
+ import type { PerAgentConfig } from "@comis/core";
22
+ import type { OAuthTokenManager } from "./oauth-token-manager.js";
23
+ /** Dependencies for the resolveProviderApiKey helper. */
24
+ export interface ResolveProviderApiKeyDeps {
25
+ /** pi-coding-agent AuthStorage instance for non-OAuth providers and the
26
+ * runtime-override target on the OAuth path. */
27
+ authStorage: AuthStorage;
28
+ /** OAuthTokenManager from auth-provider.ts. When undefined the helper
29
+ * defensively falls through to authStorage even for OAuth-eligible
30
+ * providers — matches the "OAuth wiring not yet provided" boot path. */
31
+ oauthManager?: OAuthTokenManager;
32
+ /** Per-agent config carrying optional `oauthProfiles` map. Forwarded to
33
+ * `OAuthTokenManager.getApiKey` as the agentContext argument so the
34
+ * manager's resolver chain (agent-config -> lastGood -> first available)
35
+ * observes per-agent profile preference on every call. */
36
+ agentConfig?: PerAgentConfig;
37
+ }
38
+ /**
39
+ * Resolve the API key for a provider, routing OAuth-eligible providers
40
+ * through the OAuthTokenManager and writing the resolved token into
41
+ * pi-coding-agent's runtime-override Map via setRuntimeApiKey.
42
+ *
43
+ * @param providerId - The provider id (e.g. "openai-codex", "anthropic").
44
+ * @param deps - Dispatch dependencies (authStorage, optional oauthManager, optional agentConfig).
45
+ * @returns The API key string.
46
+ * @throws Error containing the OAuthError.message when manager.getApiKey returns err().
47
+ */
48
+ export declare function resolveProviderApiKey(providerId: string, deps: ResolveProviderApiKeyDeps): Promise<string>;
@@ -0,0 +1,66 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * resolveProviderApiKey: shared dispatch helper that routes OAuth-eligible
4
+ * providers through the OAuthTokenManager + AuthStorage.setRuntimeApiKey
5
+ * side-effect, and non-OAuth providers through the existing authStorage path.
6
+ *
7
+ * Single attachment surface for the per-LLM-call OAuth dispatch
8
+ * hook. Used by PiExecutor.execute() pre-hook (primary LLM call) and the two
9
+ * compaction getApiKey callbacks in executor-context-engine-setup.ts.
10
+ *
11
+ * Return shape is `Promise<string>` (NOT `Result<T,E>`) because the helper
12
+ * bridges Comis's Result-typed manager with pi-coding-agent's
13
+ * `AuthStorage.getApiKey` contract; the throw mirrors pi-coding-agent's own
14
+ * throw-on-failure shape. On OAuthError the helper propagates a thrown Error —
15
+ * no env-var fallback, no retry, no silent rotation. Outer callers
16
+ * (PiExecutor.execute, gateway routes) surface the throw to the user via their
17
+ * existing error-handling path.
18
+ *
19
+ * @module
20
+ */
21
+ import { getOAuthProvider } from "@mariozechner/pi-ai/oauth";
22
+ /**
23
+ * Resolve the API key for a provider, routing OAuth-eligible providers
24
+ * through the OAuthTokenManager and writing the resolved token into
25
+ * pi-coding-agent's runtime-override Map via setRuntimeApiKey.
26
+ *
27
+ * @param providerId - The provider id (e.g. "openai-codex", "anthropic").
28
+ * @param deps - Dispatch dependencies (authStorage, optional oauthManager, optional agentConfig).
29
+ * @returns The API key string.
30
+ * @throws Error containing the OAuthError.message when manager.getApiKey returns err().
31
+ */
32
+ export async function resolveProviderApiKey(providerId, deps) {
33
+ const oauthProvider = getOAuthProvider(providerId);
34
+ if (oauthProvider && deps.oauthManager) {
35
+ const result = await deps.oauthManager.getApiKey(providerId, {
36
+ oauthProfiles: deps.agentConfig?.oauthProfiles,
37
+ });
38
+ if (result.ok) {
39
+ // setRuntimeApiKey carries the token into pi-coding-agent's outbound
40
+ // LLM request via the runtime-override priority path — runtime
41
+ // overrides take HIGHEST priority.
42
+ deps.authStorage.setRuntimeApiKey(providerId, result.value);
43
+ return result.value;
44
+ }
45
+ // Decide whether to fall back to the plain API-key path. Two conditions
46
+ // must hold:
47
+ // 1. The OAuth result is "no credentials anywhere" (NO_CREDENTIALS),
48
+ // not a real failure (REFRESH_FAILED, STORE_FAILED, …) which we
49
+ // propagate fail-loud.
50
+ // 2. The agent did NOT explicitly request an OAuth profile via
51
+ // `oauthProfiles[providerId]`. An explicit profile request that the
52
+ // store cannot satisfy is a real failure — never silently fall back
53
+ // to a different key (security keystone).
54
+ const noCredentials = result.error.code === "NO_CREDENTIALS";
55
+ const requestedProfile = deps.agentConfig?.oauthProfiles?.[providerId];
56
+ if (!noCredentials || requestedProfile !== undefined) {
57
+ // Propagate as throw — outer callers (PiExecutor.execute, gateway
58
+ // routes) lift the throw into a user-facing error result.
59
+ throw new Error(result.error.message);
60
+ }
61
+ // Fall through to authStorage — providers like anthropic accept both
62
+ // OAuth and direct API keys; without an OAuth profile, the plain key
63
+ // (ANTHROPIC_API_KEY etc.) is the valid path.
64
+ }
65
+ return (await deps.authStorage.getApiKey(providerId)) ?? "";
66
+ }
@@ -4,7 +4,7 @@
4
4
  * Resolution order:
5
5
  * 1. DEFAULTS -- complete ProviderCapabilities with safe fallback values
6
6
  * 2. PROVIDER_OVERRIDES[normalizeProviderId(provider)] -- built-in overrides
7
- * for known providers (12 entries covering Anthropic, OpenAI, Google, Mistral)
7
+ * for known providers (8 entries covering Anthropic, OpenAI, Google, Mistral)
8
8
  * 3. userOverrides -- user-supplied config from YAML `providers.entries.*.capabilities`
9
9
  *
10
10
  * Providers NOT in PROVIDER_OVERRIDES (cerebras, groq, xai, etc.) get clean
@@ -35,23 +35,23 @@ export declare function normalizeProviderId(provider: string): string;
35
35
  export declare function resolveProviderCapabilities(provider: string, userOverrides?: Partial<ProviderCapabilities>): ProviderCapabilities;
36
36
  /**
37
37
  * Check if a provider belongs to the Anthropic family.
38
- * True for: anthropic, anthropic-vertex, amazon-bedrock (and their aliases).
38
+ * True for: anthropic, amazon-bedrock (and their aliases).
39
39
  */
40
40
  export declare function isAnthropicFamily(provider: string): boolean;
41
41
  /**
42
42
  * Check if a provider belongs to the OpenAI family.
43
- * True for: openai, azure-openai, azure-openai-responses, openai-codex (and their aliases).
43
+ * True for: openai, azure-openai-responses, openai-codex (and their aliases).
44
44
  */
45
45
  export declare function isOpenAiFamily(provider: string): boolean;
46
46
  /**
47
47
  * Check if a provider belongs to the Google family.
48
- * True for: google, google-gemini-cli, google-antigravity, google-vertex (and their aliases).
48
+ * True for: google, google-vertex (and their aliases).
49
49
  */
50
50
  export declare function isGoogleFamily(provider: string): boolean;
51
51
  /**
52
52
  * Check if a provider is Google AI Studio (api.google.dev, NOT Vertex AI).
53
53
  * True for: "google" only (and aliases: "gcp", "gemini").
54
- * Excludes: google-vertex, google-gemini-cli, google-antigravity.
54
+ * Excludes: google-vertex.
55
55
  *
56
56
  * Only Google AI Studio supports the Caches API used by GeminiCacheManager.
57
57
  */
@@ -5,7 +5,7 @@
5
5
  * Resolution order:
6
6
  * 1. DEFAULTS -- complete ProviderCapabilities with safe fallback values
7
7
  * 2. PROVIDER_OVERRIDES[normalizeProviderId(provider)] -- built-in overrides
8
- * for known providers (12 entries covering Anthropic, OpenAI, Google, Mistral)
8
+ * for known providers (8 entries covering Anthropic, OpenAI, Google, Mistral)
9
9
  * 3. userOverrides -- user-supplied config from YAML `providers.entries.*.capabilities`
10
10
  *
11
11
  * Providers NOT in PROVIDER_OVERRIDES (cerebras, groq, xai, etc.) get clean
@@ -27,10 +27,10 @@ export const DEFAULTS = {
27
27
  /**
28
28
  * Built-in overrides for providers that differ from DEFAULTS.
29
29
  *
30
- * 12 entries covering:
31
- * - Anthropic family (3): anthropic, anthropic-vertex, amazon-bedrock
32
- * - OpenAI family (4): openai, azure-openai, azure-openai-responses, openai-codex
33
- * - Google family (4): google, google-gemini-cli, google-antigravity, google-vertex
30
+ * 8 entries covering:
31
+ * - Anthropic family (2): anthropic, amazon-bedrock
32
+ * - OpenAI family (3): openai, azure-openai-responses, openai-codex
33
+ * - Google family (2): google, google-vertex
34
34
  * - Mistral (1): strict9 tool call ID mode with 7 model hints
35
35
  *
36
36
  * Providers NOT in this map fall through to DEFAULTS via spread.
@@ -38,17 +38,13 @@ export const DEFAULTS = {
38
38
  const PROVIDER_OVERRIDES = {
39
39
  // Anthropic family
40
40
  "anthropic": { providerFamily: "anthropic", dropThinkingBlockModelHints: ["claude"] },
41
- "anthropic-vertex": { providerFamily: "anthropic", dropThinkingBlockModelHints: ["claude"] },
42
41
  "amazon-bedrock": { providerFamily: "anthropic", dropThinkingBlockModelHints: ["claude"] },
43
42
  // OpenAI family
44
43
  "openai": { providerFamily: "openai" },
45
- "azure-openai": { providerFamily: "openai" },
46
44
  "azure-openai-responses": { providerFamily: "openai" },
47
45
  "openai-codex": { providerFamily: "openai" },
48
46
  // Google family
49
47
  "google": { providerFamily: "google" },
50
- "google-gemini-cli": { providerFamily: "google" },
51
- "google-antigravity": { providerFamily: "google" },
52
48
  "google-vertex": { providerFamily: "google" },
53
49
  // Mistral -- strict9 tool call ID normalization
54
50
  "mistral": {
@@ -62,24 +58,15 @@ const PROVIDER_OVERRIDES = {
62
58
  /**
63
59
  * Provider ID alias table. Maps user-friendly shorthand names to canonical
64
60
  * provider IDs used in PROVIDER_OVERRIDES.
65
- *
66
- * AMBIGUITY NOTE: "vertex" maps to "anthropic-vertex" (Anthropic API via
67
- * Google Cloud), NOT "google-vertex". Users targeting Google Vertex AI
68
- * should use "google-vertex" or "gcp-vertex".
69
61
  */
70
62
  const ALIASES = {
71
63
  "aws-bedrock": "amazon-bedrock",
72
64
  "bedrock": "amazon-bedrock",
73
- "vertex": "anthropic-vertex",
74
- "vertex-ai": "anthropic-vertex",
75
- "azure": "azure-openai",
76
65
  "azure-responses": "azure-openai-responses",
77
66
  "codex": "openai-codex",
78
67
  "gcp": "google",
79
68
  "gcp-vertex": "google-vertex",
80
69
  "gemini": "google",
81
- "gemini-cli": "google-gemini-cli",
82
- "antigravity": "google-antigravity",
83
70
  "grok": "xai",
84
71
  };
85
72
  /**
@@ -109,21 +96,21 @@ export function resolveProviderCapabilities(provider, userOverrides) {
109
96
  }
110
97
  /**
111
98
  * Check if a provider belongs to the Anthropic family.
112
- * True for: anthropic, anthropic-vertex, amazon-bedrock (and their aliases).
99
+ * True for: anthropic, amazon-bedrock (and their aliases).
113
100
  */
114
101
  export function isAnthropicFamily(provider) {
115
102
  return resolveProviderCapabilities(provider).providerFamily === "anthropic";
116
103
  }
117
104
  /**
118
105
  * Check if a provider belongs to the OpenAI family.
119
- * True for: openai, azure-openai, azure-openai-responses, openai-codex (and their aliases).
106
+ * True for: openai, azure-openai-responses, openai-codex (and their aliases).
120
107
  */
121
108
  export function isOpenAiFamily(provider) {
122
109
  return resolveProviderCapabilities(provider).providerFamily === "openai";
123
110
  }
124
111
  /**
125
112
  * Check if a provider belongs to the Google family.
126
- * True for: google, google-gemini-cli, google-antigravity, google-vertex (and their aliases).
113
+ * True for: google, google-vertex (and their aliases).
127
114
  */
128
115
  export function isGoogleFamily(provider) {
129
116
  return resolveProviderCapabilities(provider).providerFamily === "google";
@@ -131,7 +118,7 @@ export function isGoogleFamily(provider) {
131
118
  /**
132
119
  * Check if a provider is Google AI Studio (api.google.dev, NOT Vertex AI).
133
120
  * True for: "google" only (and aliases: "gcp", "gemini").
134
- * Excludes: google-vertex, google-gemini-cli, google-antigravity.
121
+ * Excludes: google-vertex.
135
122
  *
136
123
  * Only Google AI Studio supports the Caches API used by GeminiCacheManager.
137
124
  */
@@ -183,7 +170,7 @@ export function validateProviderOverrides(logger) {
183
170
  provider: key,
184
171
  hint: "Provider override exists for unknown pi-ai provider; remove from PROVIDER_OVERRIDES on next bump",
185
172
  errorKind: "config",
186
- module: "agent.capabilities",
173
+ submodule: "capabilities",
187
174
  }, "Capability override has no matching pi-ai provider");
188
175
  }
189
176
  }
@@ -74,15 +74,15 @@ export function sanitizeToolOutput(text, maxChars = DEFAULT_MAX_CHARS, options)
74
74
  if (containsTagBlockChars(text)) {
75
75
  options?.onTagBlockDetected?.();
76
76
  }
77
- // Phase 1: Normalize for pattern matching (NFKC + strip zero-width + tag block)
77
+ // Normalize for pattern matching (NFKC + strip zero-width + tag block)
78
78
  let sanitized = normalizeForMatching(text);
79
- // Phase 2: Redact injection patterns (on normalized text)
79
+ // Redact injection patterns (on normalized text)
80
80
  for (const pattern of INSTRUCTION_PATTERNS) {
81
81
  // Reset lastIndex for sticky/global regexes across multiple calls
82
82
  pattern.lastIndex = 0;
83
83
  sanitized = sanitized.replace(pattern, "[REDACTED]");
84
84
  }
85
- // Phase 3: Truncate oversized output
85
+ // Truncate oversized output
86
86
  if (sanitized.length > maxChars) {
87
87
  const cutPoint = Math.floor(maxChars * 0.95);
88
88
  const lastNewline = sanitized.lastIndexOf("\n", cutPoint);
@@ -105,7 +105,7 @@ export interface ComisSessionManager {
105
105
  */
106
106
  writeSessionMetadata(sessionKey: SessionKey, metadata: SessionMetadata): void;
107
107
  /**
108
- * 260428-iag: Resolve the absolute JSONL session file path for a session key.
108
+ * Resolve the absolute JSONL session file path for a session key.
109
109
  *
110
110
  * Thin synchronous wrapper around `sessionKeyToPath(sessionKey, deps.sessionBaseDir)`
111
111
  * that exposes the path resolver to the wire-edge diagnostic in pi-event-bridge.
@@ -71,7 +71,7 @@ export function createComisSessionManager(deps) {
71
71
  }, { retries: 10, retryMinTimeout: 500 });
72
72
  },
73
73
  getSessionPath(sessionKey) {
74
- // 260428-iag wire-edge diagnostic: pure delegation to sessionKeyToPath
74
+ // wire-edge diagnostic: pure delegation to sessionKeyToPath
75
75
  // (which uses safePath internally). No I/O, no logging.
76
76
  return sessionKeyToPath(sessionKey, deps.sessionBaseDir);
77
77
  },
@@ -34,6 +34,16 @@ export interface CastParams {
34
34
  /** Sub-agent session key for reference. */
35
35
  sessionKey: string;
36
36
  }
37
+ /**
38
+ * Trailing instruction appended to every announcement.
39
+ * MUST start with "Inform the user about this completed background task."
40
+ * for AnnouncementBatcher.stripSystemPrefix() compatibility.
41
+ *
42
+ * Exported so packages/agent/src/background/completion-formatter.ts can
43
+ * reuse the byte-identical string. Do NOT change the string
44
+ * without updating both consumers AND announcement-batcher.ts:81.
45
+ */
46
+ export declare const TRAILING_INSTRUCTION = "Inform the user about this completed background task. Summarize the result in your own voice. If no user notification is needed, respond with NO_REPLY.";
37
47
  /**
38
48
  * Create a NarrativeCaster with the given configuration.
39
49
  *
@@ -20,8 +20,12 @@ const MAX_LABEL_LENGTH = 100;
20
20
  * Trailing instruction appended to every announcement.
21
21
  * MUST start with "Inform the user about this completed background task."
22
22
  * for AnnouncementBatcher.stripSystemPrefix() compatibility.
23
+ *
24
+ * Exported so packages/agent/src/background/completion-formatter.ts can
25
+ * reuse the byte-identical string. Do NOT change the string
26
+ * without updating both consumers AND announcement-batcher.ts:81.
23
27
  */
24
- const TRAILING_INSTRUCTION = "Inform the user about this completed background task. Summarize the result in your own voice. If no user notification is needed, respond with NO_REPLY.";
28
+ export const TRAILING_INSTRUCTION = "Inform the user about this completed background task. Summarize the result in your own voice. If no user notification is needed, respond with NO_REPLY.";
25
29
  /** Human-readable names for condensation levels. */
26
30
  const LEVEL_NAMES = {
27
31
  1: "Passthrough",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@comis/agent",
3
3
  "private": true,
4
- "version": "1.0.34",
4
+ "version": "1.0.36",
5
5
  "author": "Moshe Anconina",
6
6
  "license": "Apache-2.0",
7
7
  "description": "AI agent executor, budget control, and session management for Comis",
@@ -81,12 +81,12 @@ export function createEmailAdapter(deps) {
81
81
  const fromAddress = parsed.from?.value[0]?.address ?? "";
82
82
  // Skip automated senders
83
83
  if (isAutomatedSender(headers, fromAddress)) {
84
- deps.logger.debug({ channelType, module: "email", fromAddress }, "Skipping automated sender");
84
+ deps.logger.debug({ channelType, submodule: "email", fromAddress }, "Skipping automated sender");
85
85
  return;
86
86
  }
87
87
  // Sender allowlist
88
88
  if (!isAllowedSender(fromAddress, deps.allowFrom, deps.allowMode)) {
89
- deps.logger.debug({ channelType, module: "email", fromAddress }, "Sender not in allowlist, skipping");
89
+ deps.logger.debug({ channelType, submodule: "email", fromAddress }, "Sender not in allowlist, skipping");
90
90
  return;
91
91
  }
92
92
  // Map to NormalizedMessage — adapt mailparser's ParsedMail to our structural type
@@ -108,7 +108,7 @@ export function createEmailAdapter(deps) {
108
108
  }
109
109
  }
110
110
  catch (e) {
111
- deps.logger.warn({ err: e, channelType, module: "email", hint: "Failed to process inbound email", errorKind: "parse" }, "Inbound email processing failed");
111
+ deps.logger.warn({ err: e, channelType, submodule: "email", hint: "Failed to process inbound email", errorKind: "parse" }, "Inbound email processing failed");
112
112
  }
113
113
  });
114
114
  // -----------------------------------------------------------------------
@@ -126,7 +126,7 @@ export function createEmailAdapter(deps) {
126
126
  const result = await imapLifecycle.start();
127
127
  if (result.ok) {
128
128
  connected = true;
129
- deps.logger.info({ channelType, module: "email", channelId }, "Email adapter started");
129
+ deps.logger.info({ channelType, submodule: "email", channelId }, "Email adapter started");
130
130
  }
131
131
  return result;
132
132
  }
@@ -139,7 +139,7 @@ export function createEmailAdapter(deps) {
139
139
  transport.close();
140
140
  transport = undefined;
141
141
  }
142
- deps.logger.info({ channelType, module: "email", channelId }, "Email adapter stopped");
142
+ deps.logger.info({ channelType, submodule: "email", channelId }, "Email adapter stopped");
143
143
  return imapResult;
144
144
  }
145
145
  async function sendMessage(recipient, text, options) {
@@ -172,7 +172,7 @@ export function createEmailAdapter(deps) {
172
172
  const error = mailResult.error instanceof Error
173
173
  ? mailResult.error
174
174
  : new Error(String(mailResult.error));
175
- deps.logger.error({ err: error, channelType, module: "email", hint: "Check SMTP credentials and host", errorKind: "network" }, "Failed to send email");
175
+ deps.logger.error({ err: error, channelType, submodule: "email", hint: "Check SMTP credentials and host", errorKind: "network" }, "Failed to send email");
176
176
  return err(error);
177
177
  }
178
178
  const messageId = mailResult.value.messageId ?? "";
@@ -80,7 +80,7 @@ export function createImapLifecycle(opts) {
80
80
  }
81
81
  }
82
82
  catch (e) {
83
- opts.logger.warn({ err: e, channelType: "email", module: "imap", hint: "Fetch failed, will retry on next event", errorKind: "network" }, "Failed to fetch new messages");
83
+ opts.logger.warn({ err: e, channelType: "email", submodule: "imap", hint: "Fetch failed, will retry on next event", errorKind: "network" }, "Failed to fetch new messages");
84
84
  }
85
85
  }
86
86
  function scheduleReconnect() {
@@ -89,7 +89,7 @@ export function createImapLifecycle(opts) {
89
89
  // Add jitter: random 0-500ms
90
90
  const jitter = Math.floor(Math.random() * 500);
91
91
  const delay = reconnectDelay + jitter;
92
- opts.logger.info({ channelType: "email", module: "imap", delayMs: delay }, "Scheduling IMAP reconnect");
92
+ opts.logger.info({ channelType: "email", submodule: "imap", delayMs: delay }, "Scheduling IMAP reconnect");
93
93
  reconnectTimer = setTimeout(() => {
94
94
  if (stopped)
95
95
  return;
@@ -109,20 +109,20 @@ export function createImapLifecycle(opts) {
109
109
  });
110
110
  client.on("close", () => {
111
111
  if (!stopped) {
112
- opts.logger.info({ channelType: "email", module: "imap" }, "IMAP connection closed, scheduling reconnect");
112
+ opts.logger.info({ channelType: "email", submodule: "imap" }, "IMAP connection closed, scheduling reconnect");
113
113
  scheduleReconnect();
114
114
  }
115
115
  });
116
116
  client.on("error", (e) => {
117
117
  // Check if this is an IDLE-related error for polling fallback
118
118
  if (e.message && /idle/i.test(e.message)) {
119
- opts.logger.warn({ channelType: "email", module: "imap", hint: "Falling back to polling", errorKind: "capability" }, "IDLE not supported, switching to polling fallback");
119
+ opts.logger.warn({ channelType: "email", submodule: "imap", hint: "Falling back to polling", errorKind: "capability" }, "IDLE not supported, switching to polling fallback");
120
120
  startPolling();
121
121
  }
122
122
  });
123
123
  const connectResult = await fromPromise(client.connect());
124
124
  if (!connectResult.ok) {
125
- opts.logger.error({ err: connectResult.error, channelType: "email", module: "imap", hint: "Check IMAP credentials and host", errorKind: "network" }, "IMAP connection failed");
125
+ opts.logger.error({ err: connectResult.error, channelType: "email", submodule: "imap", hint: "Check IMAP credentials and host", errorKind: "network" }, "IMAP connection failed");
126
126
  scheduleReconnect();
127
127
  return err(connectResult.error instanceof Error ? connectResult.error : new Error(String(connectResult.error)));
128
128
  }
@@ -135,11 +135,11 @@ export function createImapLifecycle(opts) {
135
135
  }, STABLE_CONNECTION_MS + 1000);
136
136
  const lockResult = await fromPromise(client.getMailboxLock("INBOX"));
137
137
  if (!lockResult.ok) {
138
- opts.logger.error({ err: lockResult.error, channelType: "email", module: "imap", hint: "Could not lock INBOX", errorKind: "network" }, "Failed to get INBOX lock");
138
+ opts.logger.error({ err: lockResult.error, channelType: "email", submodule: "imap", hint: "Could not lock INBOX", errorKind: "network" }, "Failed to get INBOX lock");
139
139
  return err(lockResult.error instanceof Error ? lockResult.error : new Error(String(lockResult.error)));
140
140
  }
141
141
  lock = lockResult.value;
142
- opts.logger.info({ channelType: "email", module: "imap", host: opts.host }, "IMAP connected and listening");
142
+ opts.logger.info({ channelType: "email", submodule: "imap", host: opts.host }, "IMAP connected and listening");
143
143
  return ok(undefined);
144
144
  }
145
145
  function startPolling() {
@@ -302,10 +302,17 @@ export async function deliverToChannel(adapter, channelId, text, options, deps)
302
302
  if (Object.keys(rest).length > 0)
303
303
  sendOpts.extra = rest;
304
304
  }
305
- // --- Queue: enqueue before send ---
305
+ // --- Queue: enqueue (in_flight lease) before send ---
306
+ // We insert with status='in_flight' so the recurring drainer's
307
+ // `WHERE status='pending'` filter does NOT race-pick this row mid-send.
308
+ // On successful send, ack flips
309
+ // 'in_flight' -> 'delivered'; on permanent failure, fail flips
310
+ // 'in_flight' -> 'failed'; on transient failure, nack flips
311
+ // 'in_flight' -> 'pending' for the drainer to retry. All ack/nack/fail
312
+ // statements are status-agnostic UPDATE-by-id, so no SQL change is needed.
306
313
  let entryId = null;
307
314
  if (deps?.deliveryQueue) {
308
- const enqueueResult = await deps.deliveryQueue.enqueue({
315
+ const enqueueResult = await deps.deliveryQueue.enqueueInFlight({
309
316
  text: chunk,
310
317
  channelType: adapter.channelType,
311
318
  channelId,
@@ -322,14 +329,9 @@ export async function deliverToChannel(adapter, channelId, text, options, deps)
322
329
  });
323
330
  if (enqueueResult.ok) {
324
331
  entryId = enqueueResult.value;
325
- // Emit delivery:enqueued event
326
- deps.eventBus?.emit("delivery:enqueued", {
327
- entryId,
328
- channelId,
329
- channelType: adapter.channelType,
330
- origin: options?.origin ?? "unknown",
331
- timestamp: Date.now(),
332
- });
332
+ // delivery:enqueued is now emitted by the adapter (SqliteDeliveryQueueAdapter
333
+ // emits inside enqueueInFlight after the INSERT succeeds -- single source of
334
+ // truth). No-op here.
333
335
  }
334
336
  // If enqueue fails, log and continue -- queue failure should not block delivery
335
337
  }
@@ -318,7 +318,7 @@ export function createTelegramAdapter(deps) {
318
318
  }, "Callback query failed");
319
319
  }
320
320
  });
321
- // Start polling (webhook mode deferred to Phase 6/9)
321
+ // Start polling (webhook mode deferred)
322
322
  if (!deps.webhookUrl) {
323
323
  runnerHandle = run(bot);
324
324
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@comis/channels",
3
3
  "private": true,
4
- "version": "1.0.34",
4
+ "version": "1.0.36",
5
5
  "author": "Moshe Anconina",
6
6
  "license": "Apache-2.0",
7
7
  "description": "Chat platform adapters — Discord, Telegram, Slack, WhatsApp, Signal, iMessage, IRC, LINE",
@@ -12,6 +12,7 @@
12
12
  import { createRequire } from "node:module";
13
13
  import { Command } from "commander";
14
14
  import { registerAgentCommand } from "./commands/agent.js";
15
+ import { registerAuthCommand } from "./commands/auth.js";
15
16
  import { registerChannelCommand } from "./commands/channel.js";
16
17
  import { registerConfigCommand } from "./commands/config.js";
17
18
  import { registerDaemonCommand } from "./commands/daemon.js";
@@ -38,6 +39,7 @@ program.name("comis").description("Comis AI agent management CLI").version(cliPk
38
39
  registerDaemonCommand(program);
39
40
  registerConfigCommand(program);
40
41
  registerAgentCommand(program);
42
+ registerAuthCommand(program);
41
43
  registerChannelCommand(program);
42
44
  registerMemoryCommand(program);
43
45
  registerSecurityCommand(program);
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Agent management commands: list, create, configure, delete, models.
2
+ * Agent management commands: list, create, configure, delete, models, set-oauth-profile.
3
3
  *
4
- * Provides `comis agent [list|create|configure|delete|models]` subcommands
5
- * for managing agent configurations via the daemon RPC interface.
4
+ * Provides `comis agent [list|create|configure|delete|models|set-oauth-profile]`
5
+ * subcommands for managing agent configurations via the daemon RPC interface.
6
6
  *
7
7
  * @module
8
8
  */