comisai 1.0.34 → 1.0.37

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 (448) 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 +30 -4
  3. package/node_modules/@comis/agent/dist/background/background-task-manager.d.ts +22 -2
  4. package/node_modules/@comis/agent/dist/background/background-task-manager.js +88 -40
  5. package/node_modules/@comis/agent/dist/background/background-task-persistence.js +34 -4
  6. package/node_modules/@comis/agent/dist/background/background-task-types.d.ts +59 -3
  7. package/node_modules/@comis/agent/dist/background/background-task-types.js +1 -1
  8. package/node_modules/@comis/agent/dist/background/completion-dispatcher.d.ts +130 -0
  9. package/node_modules/@comis/agent/dist/background/completion-dispatcher.js +215 -0
  10. package/node_modules/@comis/agent/dist/background/completion-formatter.d.ts +39 -0
  11. package/node_modules/@comis/agent/dist/background/completion-formatter.js +77 -0
  12. package/node_modules/@comis/agent/dist/background/completion-runner.d.ts +62 -0
  13. package/node_modules/@comis/agent/dist/background/completion-runner.js +234 -0
  14. package/node_modules/@comis/agent/dist/background/index.d.ts +10 -1
  15. package/node_modules/@comis/agent/dist/background/index.js +4 -0
  16. package/node_modules/@comis/agent/dist/background/session-resolver.d.ts +85 -0
  17. package/node_modules/@comis/agent/dist/background/session-resolver.js +78 -0
  18. package/node_modules/@comis/agent/dist/bootstrap/sections/messaging-sections.js +1 -0
  19. package/node_modules/@comis/agent/dist/bootstrap/sections/tool-descriptions.js +3 -3
  20. package/node_modules/@comis/agent/dist/bootstrap/sections/tooling-sections.d.ts +30 -2
  21. package/node_modules/@comis/agent/dist/bootstrap/sections/tooling-sections.js +51 -2
  22. package/node_modules/@comis/agent/dist/bootstrap/system-prompt-assembler.d.ts +22 -0
  23. package/node_modules/@comis/agent/dist/bootstrap/system-prompt-assembler.js +2 -2
  24. package/node_modules/@comis/agent/dist/bridge/bridge-event-handlers.d.ts +1 -5
  25. package/node_modules/@comis/agent/dist/bridge/bridge-event-handlers.js +2 -14
  26. package/node_modules/@comis/agent/dist/bridge/bridge-metrics.d.ts +43 -2
  27. package/node_modules/@comis/agent/dist/bridge/bridge-metrics.js +17 -2
  28. package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.d.ts +32 -23
  29. package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.js +145 -62
  30. package/node_modules/@comis/agent/dist/bridge/thinking-block-hash-invariant.d.ts +6 -7
  31. package/node_modules/@comis/agent/dist/bridge/thinking-block-hash-invariant.js +24 -25
  32. package/node_modules/@comis/agent/dist/budget/cost-tracker.d.ts +1 -1
  33. package/node_modules/@comis/agent/dist/context-engine/constants.d.ts +5 -5
  34. package/node_modules/@comis/agent/dist/context-engine/constants.js +12 -12
  35. package/node_modules/@comis/agent/dist/context-engine/context-engine.js +13 -4
  36. package/node_modules/@comis/agent/dist/context-engine/dag-annotator.d.ts +1 -2
  37. package/node_modules/@comis/agent/dist/context-engine/dag-annotator.js +1 -2
  38. package/node_modules/@comis/agent/dist/context-engine/llm-compaction.js +20 -16
  39. package/node_modules/@comis/agent/dist/context-engine/rehydration.js +6 -6
  40. package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.d.ts +12 -12
  41. package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.js +36 -22
  42. package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.d.ts +10 -10
  43. package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.js +14 -14
  44. package/node_modules/@comis/agent/dist/context-engine/thinking-block-cleaner.d.ts +11 -13
  45. package/node_modules/@comis/agent/dist/context-engine/thinking-block-cleaner.js +14 -15
  46. package/node_modules/@comis/agent/dist/context-engine/types-core.d.ts +15 -0
  47. package/node_modules/@comis/agent/dist/executor/cache-break-detection.d.ts +6 -6
  48. package/node_modules/@comis/agent/dist/executor/cache-break-detection.js +8 -8
  49. package/node_modules/@comis/agent/dist/executor/capability-index-context.d.ts +72 -0
  50. package/node_modules/@comis/agent/dist/executor/capability-index-context.js +329 -0
  51. package/node_modules/@comis/agent/dist/executor/drain-helper.d.ts +122 -0
  52. package/node_modules/@comis/agent/dist/executor/drain-helper.js +173 -0
  53. package/node_modules/@comis/agent/dist/executor/error-classifier.js +2 -2
  54. package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.d.ts +16 -0
  55. package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.js +46 -5
  56. package/node_modules/@comis/agent/dist/executor/executor-post-execution.d.ts +78 -4
  57. package/node_modules/@comis/agent/dist/executor/executor-post-execution.js +150 -31
  58. package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.d.ts +7 -0
  59. package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.js +26 -5
  60. package/node_modules/@comis/agent/dist/executor/executor-response-filter.d.ts +7 -6
  61. package/node_modules/@comis/agent/dist/executor/executor-response-filter.js +9 -42
  62. package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.d.ts +18 -1
  63. package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.js +20 -18
  64. package/node_modules/@comis/agent/dist/executor/gemini-cache-injector.d.ts +2 -2
  65. package/node_modules/@comis/agent/dist/executor/gemini-cache-injector.js +4 -4
  66. package/node_modules/@comis/agent/dist/executor/jit-guide-injector.d.ts +11 -2
  67. package/node_modules/@comis/agent/dist/executor/jit-guide-injector.js +16 -2
  68. package/node_modules/@comis/agent/dist/executor/phase-filter.d.ts +2 -2
  69. package/node_modules/@comis/agent/dist/executor/phase-filter.js +5 -7
  70. package/node_modules/@comis/agent/dist/executor/pi-executor.d.ts +21 -2
  71. package/node_modules/@comis/agent/dist/executor/pi-executor.js +96 -18
  72. package/node_modules/@comis/agent/dist/executor/post-batch-continuation.js +7 -7
  73. package/node_modules/@comis/agent/dist/executor/prompt-assembly.d.ts +9 -1
  74. package/node_modules/@comis/agent/dist/executor/prompt-assembly.js +15 -1
  75. package/node_modules/@comis/agent/dist/executor/stream-wrappers/request-body-injector.d.ts +1 -1
  76. package/node_modules/@comis/agent/dist/executor/stream-wrappers/request-body-injector.js +1 -1
  77. package/node_modules/@comis/agent/dist/executor/tool-deferral.d.ts +18 -27
  78. package/node_modules/@comis/agent/dist/executor/tool-deferral.js +34 -43
  79. package/node_modules/@comis/agent/dist/index.d.ts +17 -0
  80. package/node_modules/@comis/agent/dist/index.js +32 -11
  81. package/node_modules/@comis/agent/dist/model/auth-provider.d.ts +25 -2
  82. package/node_modules/@comis/agent/dist/model/auth-provider.js +6 -0
  83. package/node_modules/@comis/agent/dist/model/compaction-model-resolver.d.ts +3 -3
  84. package/node_modules/@comis/agent/dist/model/compaction-model-resolver.js +3 -3
  85. package/node_modules/@comis/agent/dist/model/model-registry-adapter.js +1 -1
  86. package/node_modules/@comis/agent/dist/model/model-scanner.js +1 -1
  87. package/node_modules/@comis/agent/dist/model/oauth-credential-store-file.d.ts +37 -0
  88. package/node_modules/@comis/agent/dist/model/oauth-credential-store-file.js +279 -0
  89. package/node_modules/@comis/agent/dist/model/oauth-credential-store-selector.d.ts +49 -0
  90. package/node_modules/@comis/agent/dist/model/oauth-credential-store-selector.js +50 -0
  91. package/node_modules/@comis/agent/dist/model/oauth-device-code.d.ts +57 -0
  92. package/node_modules/@comis/agent/dist/model/oauth-device-code.js +302 -0
  93. package/node_modules/@comis/agent/dist/model/oauth-env.d.ts +33 -0
  94. package/node_modules/@comis/agent/dist/model/oauth-env.js +38 -0
  95. package/node_modules/@comis/agent/dist/model/oauth-errors.d.ts +41 -0
  96. package/node_modules/@comis/agent/dist/model/oauth-errors.js +88 -0
  97. package/node_modules/@comis/agent/dist/model/oauth-identity.d.ts +53 -0
  98. package/node_modules/@comis/agent/dist/model/oauth-identity.js +141 -0
  99. package/node_modules/@comis/agent/dist/model/oauth-login-runner.d.ts +99 -0
  100. package/node_modules/@comis/agent/dist/model/oauth-login-runner.js +374 -0
  101. package/node_modules/@comis/agent/dist/model/oauth-tls-preflight.d.ts +58 -0
  102. package/node_modules/@comis/agent/dist/model/oauth-tls-preflight.js +82 -0
  103. package/node_modules/@comis/agent/dist/model/oauth-token-manager.d.ts +86 -16
  104. package/node_modules/@comis/agent/dist/model/oauth-token-manager.js +961 -66
  105. package/node_modules/@comis/agent/dist/model/operation-model-defaults.d.ts +9 -4
  106. package/node_modules/@comis/agent/dist/model/operation-model-defaults.js +36 -9
  107. package/node_modules/@comis/agent/dist/model/resolve-provider-api-key.d.ts +48 -0
  108. package/node_modules/@comis/agent/dist/model/resolve-provider-api-key.js +66 -0
  109. package/node_modules/@comis/agent/dist/provider/capabilities.d.ts +5 -5
  110. package/node_modules/@comis/agent/dist/provider/capabilities.js +10 -23
  111. package/node_modules/@comis/agent/dist/safety/tool-output-safety.js +3 -3
  112. package/node_modules/@comis/agent/dist/safety/tool-retry-breaker.d.ts +11 -1
  113. package/node_modules/@comis/agent/dist/safety/tool-retry-breaker.js +19 -22
  114. package/node_modules/@comis/agent/dist/session/comis-session-manager.d.ts +17 -3
  115. package/node_modules/@comis/agent/dist/session/comis-session-manager.js +1 -1
  116. package/node_modules/@comis/agent/dist/spawn/narrative-caster.d.ts +10 -0
  117. package/node_modules/@comis/agent/dist/spawn/narrative-caster.js +5 -1
  118. package/node_modules/@comis/agent/dist/spawn/pi-mono-adapters.d.ts +1 -1
  119. package/node_modules/@comis/agent/dist/spawn/pi-mono-adapters.js +5 -5
  120. package/node_modules/@comis/agent/dist/workspace/data-env.d.ts +38 -0
  121. package/node_modules/@comis/agent/dist/workspace/data-env.js +56 -0
  122. package/node_modules/@comis/agent/dist/workspace/index.d.ts +1 -0
  123. package/node_modules/@comis/agent/dist/workspace/index.js +1 -0
  124. package/node_modules/@comis/agent/dist/workspace/templates.js +5 -1
  125. package/node_modules/@comis/agent/package.json +1 -1
  126. package/node_modules/@comis/channels/dist/email/email-adapter.js +6 -6
  127. package/node_modules/@comis/channels/dist/email/imap-lifecycle.js +7 -7
  128. package/node_modules/@comis/channels/dist/index.d.ts +1 -1
  129. package/node_modules/@comis/channels/dist/index.js +1 -1
  130. package/node_modules/@comis/channels/dist/shared/channel-manager.d.ts +9 -3
  131. package/node_modules/@comis/channels/dist/shared/deliver-to-channel.js +12 -10
  132. package/node_modules/@comis/channels/dist/shared/inbound-gate.d.ts +1 -1
  133. package/node_modules/@comis/channels/dist/shared/inbound-gate.js +22 -7
  134. package/node_modules/@comis/channels/dist/shared/inbound-pipeline.d.ts +10 -3
  135. package/node_modules/@comis/channels/dist/shared/inbound-route.d.ts +1 -1
  136. package/node_modules/@comis/channels/dist/shared/inbound-route.js +13 -2
  137. package/node_modules/@comis/channels/dist/shared/response-filter.d.ts +11 -24
  138. package/node_modules/@comis/channels/dist/shared/response-filter.js +25 -53
  139. package/node_modules/@comis/channels/dist/telegram/telegram-adapter.js +1 -1
  140. package/node_modules/@comis/channels/package.json +1 -1
  141. package/node_modules/@comis/cli/dist/cli.js +2 -0
  142. package/node_modules/@comis/cli/dist/commands/agent.d.ts +3 -3
  143. package/node_modules/@comis/cli/dist/commands/agent.js +46 -3
  144. package/node_modules/@comis/cli/dist/commands/auth.d.ts +37 -0
  145. package/node_modules/@comis/cli/dist/commands/auth.js +433 -0
  146. package/node_modules/@comis/cli/dist/commands/doctor.d.ts +4 -1
  147. package/node_modules/@comis/cli/dist/commands/doctor.js +20 -5
  148. package/node_modules/@comis/cli/dist/commands/providers.d.ts +1 -2
  149. package/node_modules/@comis/cli/dist/commands/providers.js +5 -6
  150. package/node_modules/@comis/cli/dist/doctor/checks/oauth-health.d.ts +39 -0
  151. package/node_modules/@comis/cli/dist/doctor/checks/oauth-health.js +399 -0
  152. package/node_modules/@comis/cli/dist/doctor/types.d.ts +19 -0
  153. package/node_modules/@comis/cli/dist/index.d.ts +1 -0
  154. package/node_modules/@comis/cli/dist/index.js +10 -4
  155. package/node_modules/@comis/cli/dist/output/relative-time.d.ts +23 -0
  156. package/node_modules/@comis/cli/dist/output/relative-time.js +36 -0
  157. package/node_modules/@comis/cli/dist/wizard/non-interactive.js +17 -8
  158. package/node_modules/@comis/cli/dist/wizard/steps/03-provider.js +2 -1
  159. package/node_modules/@comis/cli/dist/wizard/steps/04-credentials.js +223 -34
  160. package/node_modules/@comis/cli/dist/wizard/steps/10-write-config.js +14 -0
  161. package/node_modules/@comis/cli/dist/wizard/steps/11-daemon-start.js +3 -3
  162. package/node_modules/@comis/cli/dist/wizard/types.d.ts +7 -0
  163. package/node_modules/@comis/cli/package.json +1 -1
  164. package/node_modules/@comis/core/dist/bootstrap.d.ts +1 -1
  165. package/node_modules/@comis/core/dist/config/env-substitution.d.ts +66 -0
  166. package/node_modules/@comis/core/dist/config/env-substitution.js +115 -0
  167. package/node_modules/@comis/core/dist/config/field-metadata.js +2 -0
  168. package/node_modules/@comis/core/dist/config/immutable-keys.js +4 -1
  169. package/node_modules/@comis/core/dist/config/index.d.ts +7 -1
  170. package/node_modules/@comis/core/dist/config/index.js +4 -1
  171. package/node_modules/@comis/core/dist/config/loader.js +61 -0
  172. package/node_modules/@comis/core/dist/config/managed-sections.d.ts +3 -3
  173. package/node_modules/@comis/core/dist/config/managed-sections.js +10 -5
  174. package/node_modules/@comis/core/dist/config/schema-agent.d.ts +4 -792
  175. package/node_modules/@comis/core/dist/config/schema-agent.js +16 -1
  176. package/node_modules/@comis/core/dist/config/schema-approvals.d.ts +0 -14
  177. package/node_modules/@comis/core/dist/config/schema-auto-reply-engine.d.ts +0 -6
  178. package/node_modules/@comis/core/dist/config/schema-background-tasks.d.ts +1 -6
  179. package/node_modules/@comis/core/dist/config/schema-background-tasks.js +7 -0
  180. package/node_modules/@comis/core/dist/config/schema-browser.d.ts +0 -18
  181. package/node_modules/@comis/core/dist/config/schema-channel.d.ts +0 -158
  182. package/node_modules/@comis/core/dist/config/schema-coalescer.d.ts +0 -5
  183. package/node_modules/@comis/core/dist/config/schema-daemon.d.ts +0 -32
  184. package/node_modules/@comis/core/dist/config/schema-delivery.d.ts +1 -17
  185. package/node_modules/@comis/core/dist/config/schema-delivery.js +2 -0
  186. package/node_modules/@comis/core/dist/config/schema-documentation.d.ts +0 -12
  187. package/node_modules/@comis/core/dist/config/schema-embedding.d.ts +0 -20
  188. package/node_modules/@comis/core/dist/config/schema-envelope.d.ts +0 -15
  189. package/node_modules/@comis/core/dist/config/schema-gateway.d.ts +0 -37
  190. package/node_modules/@comis/core/dist/config/schema-gemini-cache.d.ts +0 -4
  191. package/node_modules/@comis/core/dist/config/schema-gemini-cache.js +0 -2
  192. package/node_modules/@comis/core/dist/config/schema-integrations.d.ts +0 -318
  193. package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.d.ts +0 -18
  194. package/node_modules/@comis/core/dist/config/schema-memory-review.d.ts +0 -7
  195. package/node_modules/@comis/core/dist/config/schema-memory.d.ts +0 -16
  196. package/node_modules/@comis/core/dist/config/schema-messages.d.ts +0 -8
  197. package/node_modules/@comis/core/dist/config/schema-models.d.ts +0 -15
  198. package/node_modules/@comis/core/dist/config/schema-notification.d.ts +0 -5
  199. package/node_modules/@comis/core/dist/config/schema-oauth.d.ts +18 -0
  200. package/node_modules/@comis/core/dist/config/schema-oauth.js +19 -0
  201. package/node_modules/@comis/core/dist/config/schema-observability.d.ts +0 -38
  202. package/node_modules/@comis/core/dist/config/schema-output-retention.d.ts +34 -0
  203. package/node_modules/@comis/core/dist/config/schema-output-retention.js +48 -0
  204. package/node_modules/@comis/core/dist/config/schema-plugins.d.ts +0 -8
  205. package/node_modules/@comis/core/dist/config/schema-providers.d.ts +0 -64
  206. package/node_modules/@comis/core/dist/config/schema-queue.d.ts +0 -58
  207. package/node_modules/@comis/core/dist/config/schema-response-prefix.d.ts +0 -2
  208. package/node_modules/@comis/core/dist/config/schema-retry.d.ts +0 -6
  209. package/node_modules/@comis/core/dist/config/schema-scheduler.d.ts +0 -39
  210. package/node_modules/@comis/core/dist/config/schema-secrets.d.ts +0 -3
  211. package/node_modules/@comis/core/dist/config/schema-security.d.ts +0 -18
  212. package/node_modules/@comis/core/dist/config/schema-send-policy.d.ts +0 -13
  213. package/node_modules/@comis/core/dist/config/schema-sender-trust-display.d.ts +0 -5
  214. package/node_modules/@comis/core/dist/config/schema-serializer.js +2 -0
  215. package/node_modules/@comis/core/dist/config/schema-skills.d.ts +0 -63
  216. package/node_modules/@comis/core/dist/config/schema-skills.js +3 -4
  217. package/node_modules/@comis/core/dist/config/schema-streaming.d.ts +0 -38
  218. package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.d.ts +0 -3
  219. package/node_modules/@comis/core/dist/config/schema-tooling.d.ts +87 -0
  220. package/node_modules/@comis/core/dist/config/schema-tooling.js +152 -0
  221. package/node_modules/@comis/core/dist/config/schema-verbosity.d.ts +0 -12
  222. package/node_modules/@comis/core/dist/config/schema-webhooks.d.ts +0 -40
  223. package/node_modules/@comis/core/dist/config/schema.d.ts +50 -37
  224. package/node_modules/@comis/core/dist/config/schema.js +9 -0
  225. package/node_modules/@comis/core/dist/context/context.d.ts +0 -4
  226. package/node_modules/@comis/core/dist/domain/approval-request.d.ts +0 -17
  227. package/node_modules/@comis/core/dist/domain/background-task-origin.d.ts +29 -0
  228. package/node_modules/@comis/core/dist/domain/background-task-origin.js +39 -0
  229. package/node_modules/@comis/core/dist/domain/delivery-origin.d.ts +0 -5
  230. package/node_modules/@comis/core/dist/domain/execution-graph.d.ts +0 -48
  231. package/node_modules/@comis/core/dist/domain/memory-entry.d.ts +0 -3
  232. package/node_modules/@comis/core/dist/domain/model-compat.d.ts +0 -4
  233. package/node_modules/@comis/core/dist/domain/normalized-message.d.ts +0 -15
  234. package/node_modules/@comis/core/dist/domain/provider-capabilities.d.ts +0 -6
  235. package/node_modules/@comis/core/dist/domain/rich-message.d.ts +0 -14
  236. package/node_modules/@comis/core/dist/domain/subagent-context-config.d.ts +0 -22
  237. package/node_modules/@comis/core/dist/domain/subagent-context-types.d.ts +0 -8
  238. package/node_modules/@comis/core/dist/event-bus/events-agent.d.ts +31 -0
  239. package/node_modules/@comis/core/dist/event-bus/events-infra.d.ts +76 -2
  240. package/node_modules/@comis/core/dist/exports/config.d.ts +2 -2
  241. package/node_modules/@comis/core/dist/exports/config.js +3 -1
  242. package/node_modules/@comis/core/dist/exports/domain.d.ts +2 -0
  243. package/node_modules/@comis/core/dist/exports/domain.js +1 -0
  244. package/node_modules/@comis/core/dist/exports/hooks.d.ts +1 -1
  245. package/node_modules/@comis/core/dist/exports/ports.d.ts +2 -2
  246. package/node_modules/@comis/core/dist/exports/ports.js +1 -1
  247. package/node_modules/@comis/core/dist/ports/channel-plugin.d.ts +0 -13
  248. package/node_modules/@comis/core/dist/ports/delivery-queue.d.ts +23 -0
  249. package/node_modules/@comis/core/dist/ports/delivery-queue.js +2 -0
  250. package/node_modules/@comis/core/dist/ports/index.d.ts +4 -0
  251. package/node_modules/@comis/core/dist/ports/index.js +5 -0
  252. package/node_modules/@comis/core/dist/ports/no-op-tool-capability.d.ts +30 -0
  253. package/node_modules/@comis/core/dist/ports/no-op-tool-capability.js +47 -0
  254. package/node_modules/@comis/core/dist/ports/oauth-credential-store.d.ts +64 -0
  255. package/node_modules/@comis/core/dist/ports/oauth-credential-store.js +37 -0
  256. package/node_modules/@comis/core/dist/ports/tool-capability.d.ts +165 -0
  257. package/node_modules/@comis/core/dist/ports/tool-capability.js +15 -0
  258. package/node_modules/@comis/core/dist/security/audit.d.ts +0 -11
  259. package/node_modules/@comis/core/dist/tool-metadata.d.ts +41 -1
  260. package/node_modules/@comis/core/dist/tool-metadata.js +1 -1
  261. package/node_modules/@comis/core/package.json +1 -1
  262. package/node_modules/@comis/daemon/bundled-skills/skill-creator/scripts/validate-skill.py +1 -1
  263. package/node_modules/@comis/daemon/dist/daemon-types.d.ts +23 -3
  264. package/node_modules/@comis/daemon/dist/daemon.js +168 -30
  265. package/node_modules/@comis/daemon/dist/index.d.ts +2 -0
  266. package/node_modules/@comis/daemon/dist/index.js +5 -0
  267. package/node_modules/@comis/daemon/dist/observability/channel-health-logger.js +3 -3
  268. package/node_modules/@comis/daemon/dist/observability/delivery-queue-logger.js +1 -1
  269. package/node_modules/@comis/daemon/dist/rpc/agent-handlers.d.ts +22 -1
  270. package/node_modules/@comis/daemon/dist/rpc/agent-handlers.js +84 -21
  271. package/node_modules/@comis/daemon/dist/rpc/agent-inline-workspace.d.ts +1 -1
  272. package/node_modules/@comis/daemon/dist/rpc/agent-inline-workspace.js +3 -3
  273. package/node_modules/@comis/daemon/dist/rpc/builtin-provider-guard.js +2 -2
  274. package/node_modules/@comis/daemon/dist/rpc/config-handlers.d.ts +9 -1
  275. package/node_modules/@comis/daemon/dist/rpc/config-handlers.js +104 -23
  276. package/node_modules/@comis/daemon/dist/rpc/credential-resolver.d.ts +30 -1
  277. package/node_modules/@comis/daemon/dist/rpc/credential-resolver.js +74 -11
  278. package/node_modules/@comis/daemon/dist/rpc/mcp-handlers.d.ts +8 -0
  279. package/node_modules/@comis/daemon/dist/rpc/mcp-handlers.js +22 -8
  280. package/node_modules/@comis/daemon/dist/rpc/model-handlers.d.ts +1 -1
  281. package/node_modules/@comis/daemon/dist/rpc/model-handlers.js +2 -2
  282. package/node_modules/@comis/daemon/dist/rpc/provider-handlers.js +9 -12
  283. package/node_modules/@comis/daemon/dist/rpc/rpc-dispatch.d.ts +1 -0
  284. package/node_modules/@comis/daemon/dist/rpc/rpc-dispatch.js +27 -2
  285. package/node_modules/@comis/daemon/dist/setup-docker-restart-warn.js +0 -1
  286. package/node_modules/@comis/daemon/dist/sub-agent-runner.d.ts +18 -0
  287. package/node_modules/@comis/daemon/dist/sub-agent-runner.js +41 -9
  288. package/node_modules/@comis/daemon/dist/wiring/index.d.ts +4 -0
  289. package/node_modules/@comis/daemon/dist/wiring/index.js +2 -0
  290. package/node_modules/@comis/daemon/dist/wiring/oauth-preflight.d.ts +21 -0
  291. package/node_modules/@comis/daemon/dist/wiring/oauth-preflight.js +134 -0
  292. package/node_modules/@comis/daemon/dist/wiring/setup-agents.d.ts +81 -2
  293. package/node_modules/@comis/daemon/dist/wiring/setup-agents.js +164 -3
  294. package/node_modules/@comis/daemon/dist/wiring/setup-background-completion-runner.d.ts +58 -0
  295. package/node_modules/@comis/daemon/dist/wiring/setup-background-completion-runner.js +59 -0
  296. package/node_modules/@comis/daemon/dist/wiring/setup-background-tasks.d.ts +10 -3
  297. package/node_modules/@comis/daemon/dist/wiring/setup-background-tasks.js +13 -7
  298. package/node_modules/@comis/daemon/dist/wiring/setup-channels.d.ts +9 -2
  299. package/node_modules/@comis/daemon/dist/wiring/setup-channels.js +35 -10
  300. package/node_modules/@comis/daemon/dist/wiring/setup-cross-session.d.ts +20 -5
  301. package/node_modules/@comis/daemon/dist/wiring/setup-cross-session.js +21 -16
  302. package/node_modules/@comis/daemon/dist/wiring/setup-delivery.d.ts +14 -5
  303. package/node_modules/@comis/daemon/dist/wiring/setup-delivery.js +65 -20
  304. package/node_modules/@comis/daemon/dist/wiring/setup-gateway.d.ts +4 -6
  305. package/node_modules/@comis/daemon/dist/wiring/setup-gateway.js +3 -5
  306. package/node_modules/@comis/daemon/dist/wiring/setup-heartbeat.d.ts +20 -5
  307. package/node_modules/@comis/daemon/dist/wiring/setup-heartbeat.js +11 -2
  308. package/node_modules/@comis/daemon/dist/wiring/setup-output-retention.d.ts +89 -0
  309. package/node_modules/@comis/daemon/dist/wiring/setup-output-retention.js +212 -0
  310. package/node_modules/@comis/daemon/dist/wiring/setup-schedulers.js +4 -0
  311. package/node_modules/@comis/daemon/dist/wiring/setup-tools.d.ts +18 -4
  312. package/node_modules/@comis/daemon/dist/wiring/setup-tools.js +29 -10
  313. package/node_modules/@comis/daemon/dist/wiring/tool-capability-adapter.d.ts +75 -0
  314. package/node_modules/@comis/daemon/dist/wiring/tool-capability-adapter.js +253 -0
  315. package/node_modules/@comis/daemon/package.json +1 -1
  316. package/node_modules/@comis/gateway/dist/index.d.ts +2 -0
  317. package/node_modules/@comis/gateway/dist/index.js +2 -0
  318. package/node_modules/@comis/gateway/dist/oauth/oauth-callback-route.d.ts +66 -0
  319. package/node_modules/@comis/gateway/dist/oauth/oauth-callback-route.js +212 -0
  320. package/node_modules/@comis/gateway/dist/server/hono-server.d.ts +14 -0
  321. package/node_modules/@comis/gateway/dist/server/hono-server.js +10 -0
  322. package/node_modules/@comis/gateway/dist/webhook/webhook-endpoint.d.ts +0 -4
  323. package/node_modules/@comis/gateway/package.json +1 -1
  324. package/node_modules/@comis/infra/dist/logging/log-fields.d.ts +23 -0
  325. package/node_modules/@comis/infra/package.json +1 -1
  326. package/node_modules/@comis/memory/dist/compaction.d.ts +3 -5
  327. package/node_modules/@comis/memory/dist/compaction.js +2 -3
  328. package/node_modules/@comis/memory/dist/delivery-queue-adapter.d.ts +2 -2
  329. package/node_modules/@comis/memory/dist/delivery-queue-adapter.js +49 -1
  330. package/node_modules/@comis/memory/dist/index.d.ts +2 -0
  331. package/node_modules/@comis/memory/dist/index.js +3 -0
  332. package/node_modules/@comis/memory/dist/memory-api.d.ts +1 -1
  333. package/node_modules/@comis/memory/dist/memory-api.js +1 -1
  334. package/node_modules/@comis/memory/dist/oauth-profile-schema.d.ts +17 -0
  335. package/node_modules/@comis/memory/dist/oauth-profile-schema.js +33 -0
  336. package/node_modules/@comis/memory/dist/oauth-profile-store-encrypted.d.ts +27 -0
  337. package/node_modules/@comis/memory/dist/oauth-profile-store-encrypted.js +144 -0
  338. package/node_modules/@comis/memory/dist/session-store.d.ts +1 -1
  339. package/node_modules/@comis/memory/dist/session-store.js +1 -1
  340. package/node_modules/@comis/memory/dist/sqlite-secret-store.d.ts +29 -3
  341. package/node_modules/@comis/memory/dist/sqlite-secret-store.js +11 -3
  342. package/node_modules/@comis/memory/package.json +1 -1
  343. package/node_modules/@comis/scheduler/dist/cron/cron-types.d.ts +0 -42
  344. package/node_modules/@comis/scheduler/dist/execution/execution-lock.d.ts +13 -0
  345. package/node_modules/@comis/scheduler/dist/execution/execution-lock.js +1 -1
  346. package/node_modules/@comis/scheduler/dist/execution/index.d.ts +2 -0
  347. package/node_modules/@comis/scheduler/dist/execution/index.js +2 -0
  348. package/node_modules/@comis/scheduler/dist/heartbeat/agent-heartbeat-source.d.ts +29 -8
  349. package/node_modules/@comis/scheduler/dist/heartbeat/agent-heartbeat-source.js +20 -8
  350. package/node_modules/@comis/scheduler/dist/index.d.ts +2 -0
  351. package/node_modules/@comis/scheduler/dist/index.js +2 -0
  352. package/node_modules/@comis/scheduler/dist/system-events/system-event-types.d.ts +0 -3
  353. package/node_modules/@comis/scheduler/dist/tasks/task-types.d.ts +0 -17
  354. package/node_modules/@comis/scheduler/package.json +1 -1
  355. package/node_modules/@comis/shared/dist/index.d.ts +3 -0
  356. package/node_modules/@comis/shared/dist/index.js +4 -0
  357. package/node_modules/@comis/shared/dist/mcp-tool-name.d.ts +78 -0
  358. package/node_modules/@comis/shared/dist/mcp-tool-name.js +92 -0
  359. package/node_modules/@comis/shared/dist/silent-tokens.d.ts +38 -0
  360. package/node_modules/@comis/shared/dist/silent-tokens.js +51 -0
  361. package/node_modules/@comis/shared/dist/visible-delivery.d.ts +28 -0
  362. package/node_modules/@comis/shared/dist/visible-delivery.js +16 -0
  363. package/node_modules/@comis/shared/package.json +1 -1
  364. package/node_modules/@comis/skills/dist/bridge/mcp-tool-bridge.d.ts +2 -13
  365. package/node_modules/@comis/skills/dist/bridge/mcp-tool-bridge.js +3 -21
  366. package/node_modules/@comis/skills/dist/bridge/schema-validator.d.ts +38 -0
  367. package/node_modules/@comis/skills/dist/bridge/schema-validator.js +169 -0
  368. package/node_modules/@comis/skills/dist/bridge/tool-metadata-enforcement.js +12 -0
  369. package/node_modules/@comis/skills/dist/bridge/tool-metadata-registry.js +133 -3
  370. package/node_modules/@comis/skills/dist/builtin/exec-diagnostics.d.ts +32 -0
  371. package/node_modules/@comis/skills/dist/builtin/exec-diagnostics.js +127 -0
  372. package/node_modules/@comis/skills/dist/builtin/exec-security.js +38 -0
  373. package/node_modules/@comis/skills/dist/builtin/exec-tool.d.ts +55 -9
  374. package/node_modules/@comis/skills/dist/builtin/exec-tool.js +392 -19
  375. package/node_modules/@comis/skills/dist/builtin/file-tools/grep-tool.js +6 -6
  376. package/node_modules/@comis/skills/dist/builtin/install-detour.d.ts +67 -0
  377. package/node_modules/@comis/skills/dist/builtin/install-detour.js +342 -0
  378. package/node_modules/@comis/skills/dist/builtin/platform/admin-manage-factory.js +5 -5
  379. package/node_modules/@comis/skills/dist/builtin/platform/agents-manage-tool.d.ts +7 -6
  380. package/node_modules/@comis/skills/dist/builtin/platform/agents-manage-tool.js +40 -29
  381. package/node_modules/@comis/skills/dist/builtin/platform/background-tasks-tool.d.ts +4 -1
  382. package/node_modules/@comis/skills/dist/builtin/platform/background-tasks-tool.js +3 -3
  383. package/node_modules/@comis/skills/dist/builtin/platform/cron-tool.js +1 -1
  384. package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.js +6 -6
  385. package/node_modules/@comis/skills/dist/builtin/platform/mcp-manage-tool.d.ts +1 -1
  386. package/node_modules/@comis/skills/dist/builtin/platform/mcp-manage-tool.js +9 -9
  387. package/node_modules/@comis/skills/dist/builtin/platform/message-tool.js +18 -0
  388. package/node_modules/@comis/skills/dist/builtin/platform/messaging-factory.d.ts +18 -1
  389. package/node_modules/@comis/skills/dist/builtin/platform/messaging-factory.js +18 -2
  390. package/node_modules/@comis/skills/dist/builtin/platform/models-manage-tool.js +3 -3
  391. package/node_modules/@comis/skills/dist/builtin/process-registry.d.ts +14 -0
  392. package/node_modules/@comis/skills/dist/builtin/process-tool.d.ts +24 -4
  393. package/node_modules/@comis/skills/dist/builtin/process-tool.js +25 -7
  394. package/node_modules/@comis/skills/dist/builtin/sandbox/bwrap-provider.d.ts +11 -0
  395. package/node_modules/@comis/skills/dist/builtin/sandbox/bwrap-provider.js +123 -1
  396. package/node_modules/@comis/skills/dist/builtin/sandbox/detect-provider.js +40 -15
  397. package/node_modules/@comis/skills/dist/index.d.ts +4 -1
  398. package/node_modules/@comis/skills/dist/index.js +3 -1
  399. package/node_modules/@comis/skills/dist/manifest/capability-parser.d.ts +44 -0
  400. package/node_modules/@comis/skills/dist/manifest/capability-parser.js +68 -0
  401. package/node_modules/@comis/skills/dist/manifest/schema.d.ts +44 -37
  402. package/node_modules/@comis/skills/dist/manifest/schema.js +35 -0
  403. package/node_modules/@comis/skills/dist/media/ssrf-fetcher.d.ts +7 -0
  404. package/node_modules/@comis/skills/dist/media/ssrf-fetcher.js +9 -2
  405. package/node_modules/@comis/skills/dist/registry/discovery.d.ts +8 -0
  406. package/node_modules/@comis/skills/dist/registry/discovery.js +10 -3
  407. package/node_modules/@comis/skills/dist/registry/skill-registry.d.ts +45 -1
  408. package/node_modules/@comis/skills/dist/registry/skill-registry.js +70 -7
  409. package/node_modules/@comis/skills/package.json +1 -1
  410. package/node_modules/@comis/web/dist/assets/{agent-detail-71BSbSfD.js → agent-detail-q8t1NB7w.js} +1 -1
  411. package/node_modules/@comis/web/dist/assets/{agent-editor-CTSDZhwT.js → agent-editor-B46io5gv.js} +1 -1
  412. package/node_modules/@comis/web/dist/assets/{agent-list-BEhni2ea.js → agent-list-DQ6g2Rcx.js} +1 -1
  413. package/node_modules/@comis/web/dist/assets/{billing-view-DVP1IvVs.js → billing-view-IWPR8LgF.js} +1 -1
  414. package/node_modules/@comis/web/dist/assets/{channel-detail-N_YK74xC.js → channel-detail-DlNNZuuC.js} +1 -1
  415. package/node_modules/@comis/web/dist/assets/{channel-list-DRk6ZJaF.js → channel-list-DhGwxiMc.js} +1 -1
  416. package/node_modules/@comis/web/dist/assets/{chat-console-Dm-GtSf9.js → chat-console-Nv6fM3Rc.js} +1 -1
  417. package/node_modules/@comis/web/dist/assets/{config-editor-CIferYX6.js → config-editor-BYKuJF76.js} +1 -1
  418. package/node_modules/@comis/web/dist/assets/{context-dag-browser-CL84rXXM.js → context-dag-browser-ClNEtzYE.js} +1 -1
  419. package/node_modules/@comis/web/dist/assets/{context-engine-B1HOTEZv.js → context-engine-BZJ6HChd.js} +1 -1
  420. package/node_modules/@comis/web/dist/assets/{delivery-view-Y6JKYVFw.js → delivery-view-Cb7I3vGu.js} +1 -1
  421. package/node_modules/@comis/web/dist/assets/{diagnostics-view-DWV1UQjz.js → diagnostics-view-9u9Lyu5a.js} +1 -1
  422. package/node_modules/@comis/web/dist/assets/{ic-chat-message-DfSERzzg.js → ic-chat-message-BFt3cVpx.js} +1 -1
  423. package/node_modules/@comis/web/dist/assets/{ic-connection-dot-CXyhlJup.js → ic-connection-dot-y77LZ3Gu.js} +1 -1
  424. package/node_modules/@comis/web/dist/assets/{ic-tool-call-DNmwTjek.js → ic-tool-call-qt6w1NQl.js} +1 -1
  425. package/node_modules/@comis/web/dist/assets/{index-CBr0Tm9_.js → index-8Tg9oc-C.js} +2 -2
  426. package/node_modules/@comis/web/dist/assets/{mcp-management-BaH2-vox.js → mcp-management-69dtH_kY.js} +2 -2
  427. package/node_modules/@comis/web/dist/assets/{media-config-CZLshJoN.js → media-config-BdjLj5c1.js} +1 -1
  428. package/node_modules/@comis/web/dist/assets/{media-test-C9NUWgo_.js → media-test-DuPqrixi.js} +1 -1
  429. package/node_modules/@comis/web/dist/assets/{memory-inspector-D_fmTcRN.js → memory-inspector-B-Pepbq-.js} +1 -1
  430. package/node_modules/@comis/web/dist/assets/{message-center-BBFlNCZn.js → message-center-B7l0yNYY.js} +1 -1
  431. package/node_modules/@comis/web/dist/assets/{models-BytGLm99.js → models-JHFHuv5S.js} +1 -1
  432. package/node_modules/@comis/web/dist/assets/{observe-view-VXtHqaqq.js → observe-view-r8mqhy4O.js} +1 -1
  433. package/node_modules/@comis/web/dist/assets/{pipeline-builder-CfXczlfJ.js → pipeline-builder-XjkiZRcR.js} +1 -1
  434. package/node_modules/@comis/web/dist/assets/{pipeline-history-CPmXFnbe.js → pipeline-history-CZqJv_Hj.js} +1 -1
  435. package/node_modules/@comis/web/dist/assets/{pipeline-history-detail-DcueTMs9.js → pipeline-history-detail-BEFGMoDy.js} +1 -1
  436. package/node_modules/@comis/web/dist/assets/{pipeline-list-B-xG5WZh.js → pipeline-list-B6q5LvO1.js} +1 -1
  437. package/node_modules/@comis/web/dist/assets/{pipeline-monitor-pnIOYaSY.js → pipeline-monitor-BNomXjVL.js} +1 -1
  438. package/node_modules/@comis/web/dist/assets/{scheduler-BtUIFHhA.js → scheduler-BJEjcGKA.js} +1 -1
  439. package/node_modules/@comis/web/dist/assets/{security-C8mWRq2y.js → security-2G1jhBfV.js} +1 -1
  440. package/node_modules/@comis/web/dist/assets/{session-detail-DgdkO5ka.js → session-detail-DmVPzFBR.js} +1 -1
  441. package/node_modules/@comis/web/dist/assets/{session-list-DcylcfTn.js → session-list-CsqMQoHs.js} +1 -1
  442. package/node_modules/@comis/web/dist/assets/{setup-wizard-BP5yjsuL.js → setup-wizard-CAdM-gSP.js} +1 -1
  443. package/node_modules/@comis/web/dist/assets/{skills-DXt1bX8Z.js → skills-2ODqKaWr.js} +1 -1
  444. package/node_modules/@comis/web/dist/assets/{subagents-C7YbUHXY.js → subagents-BFlwfTbD.js} +1 -1
  445. package/node_modules/@comis/web/dist/assets/{workspace-manager-DP6pW4wa.js → workspace-manager--CbOx_dI.js} +1 -1
  446. package/node_modules/@comis/web/dist/index.html +1 -1
  447. package/node_modules/@comis/web/package.json +1 -1
  448. package/package.json +25 -24
@@ -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);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Tool retry circuit breaker: per-tool-signature consecutive failure tracking.
3
3
  *
4
- * Prevents infinite retry loops (like the 48-call yfinance incident) by blocking
4
+ * Prevents infinite retry loops (the original repro: 48-call MCP-server retry incident) by blocking
5
5
  * tool calls after repeated failures and providing actionable LLM guidance with
6
6
  * alternative tool suggestions.
7
7
  *
@@ -29,6 +29,16 @@ export interface ToolRetryBreakerConfig {
29
29
  /** Max consecutive same-error-class failures (any args) before blocking.
30
30
  * Stricter than args-based because same error + different args = stronger stuck signal. */
31
31
  maxConsecutiveErrorPatterns?: number;
32
+ /**
33
+ * Operator-supplied tool-alternative map. Keys are tool-name prefixes
34
+ * (e.g., `"mcp__finance-data"`); values are arrays of suggested alternative
35
+ * tool names. Used in block reasons to guide the LLM toward working tools.
36
+ *
37
+ * Defaults to an empty map (no alternatives suggested). The codebase MUST
38
+ * NOT ship hardcoded MCP server names — operators opt in by populating
39
+ * this map in their breaker config.
40
+ */
41
+ toolAlternatives?: Record<string, readonly string[]>;
32
42
  }
33
43
  /** Tool retry breaker interface -- tracks per-tool-signature failures. */
34
44
  export interface ToolRetryBreaker {
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Tool retry circuit breaker: per-tool-signature consecutive failure tracking.
4
4
  *
5
- * Prevents infinite retry loops (like the 48-call yfinance incident) by blocking
5
+ * Prevents infinite retry loops (the original repro: 48-call MCP-server retry incident) by blocking
6
6
  * tool calls after repeated failures and providing actionable LLM guidance with
7
7
  * alternative tool suggestions.
8
8
  *
@@ -17,16 +17,6 @@
17
17
  * @module
18
18
  */
19
19
  // ---------------------------------------------------------------------------
20
- // Alternative tool mapping (hardcoded v1)
21
- // ---------------------------------------------------------------------------
22
- /**
23
- * Maps tool name prefixes to alternative tools that can serve similar purposes.
24
- * Used in block reasons to guide the LLM toward working alternatives.
25
- */
26
- const TOOL_ALTERNATIVES = {
27
- "mcp__yfinance": ["web_search", "mcp__tavily--tavily-search", "web_fetch"],
28
- };
29
- // ---------------------------------------------------------------------------
30
20
  // Error tag extraction
31
21
  // ---------------------------------------------------------------------------
32
22
  /**
@@ -154,17 +144,6 @@ function fingerprint(toolName, args) {
154
144
  const sortedArgs = JSON.stringify(Object.fromEntries(Object.entries(args).sort()));
155
145
  return `${toolName}::${sortedArgs}`;
156
146
  }
157
- /**
158
- * Find alternative tools for a given tool name by prefix matching.
159
- * @returns Array of alternative tool names, empty if none known.
160
- */
161
- function findAlternatives(toolName) {
162
- for (const [prefix, alts] of Object.entries(TOOL_ALTERNATIVES)) {
163
- if (toolName.startsWith(prefix))
164
- return alts;
165
- }
166
- return [];
167
- }
168
147
  /**
169
148
  * When tool failures are caused by the macOS sandbox-exec profile denying writes
170
149
  * to protected paths (~/.comis/skills/, global node_modules, ~/.gitconfig,
@@ -246,6 +225,7 @@ function buildBlockReason(toolName, count, lastError, alternatives, isToolLevel)
246
225
  export function createToolRetryBreaker(config) {
247
226
  const { maxConsecutiveFailures, maxToolFailures, suggestAlternatives } = config;
248
227
  const maxErrorPatterns = config.maxConsecutiveErrorPatterns ?? 2;
228
+ const toolAlternatives = config.toolAlternatives ?? {};
249
229
  // Per-fingerprint (tool+args) consecutive failure tracking
250
230
  const signatureFailures = new Map();
251
231
  // Per-tool-name total failure count (across all args)
@@ -254,6 +234,23 @@ export function createToolRetryBreaker(config) {
254
234
  const blockedTools = new Set();
255
235
  // Per-error-pattern consecutive failure tracking (keyed by `${toolName}::err::${errorTag}`)
256
236
  const errorPatternFailures = new Map();
237
+ /**
238
+ * Find alternative tools for a given tool name by prefix matching against
239
+ * `config.toolAlternatives`. Closed-over the factory's `toolAlternatives`
240
+ * local; defaults to no alternatives when the config field is omitted.
241
+ * Spread to a fresh mutable array so the readonly-input / mutable-output
242
+ * contract documented in `ToolRetryVerdict.alternatives?: string[]` is
243
+ * preserved.
244
+ *
245
+ * @returns Array of alternative tool names, empty if no prefix match.
246
+ */
247
+ function findAlternatives(toolName) {
248
+ for (const [prefix, alts] of Object.entries(toolAlternatives)) {
249
+ if (toolName.startsWith(prefix))
250
+ return [...alts];
251
+ }
252
+ return [];
253
+ }
257
254
  return {
258
255
  beforeToolCall(toolName, args) {
259
256
  // Check tool-level block first (all args blocked)
@@ -30,11 +30,25 @@ export interface ComisSessionManagerDeps {
30
30
  * Session metadata written as a companion file alongside the JSONL.
31
31
  * The SDK controls the JSONL format, so enrichment data (traceId, runId, session_end)
32
32
  * is stored in `_session-metadata.json` next to the `.jsonl` file.
33
+ *
34
+ * `traceId` and `runId` are deliberately distinct identifiers:
35
+ * - `traceId` is the request-scope AsyncLocalStorage value set by
36
+ * `runWithContext` at the channel boundary (channels/.../execution-execute.ts).
37
+ * The Pino tracing mixin (infra/.../log-fields.ts) injects it into every
38
+ * daemon log line, so an operator can grep daemon.log for this exact value
39
+ * to find every log entry produced while handling this turn.
40
+ * - `runId` is the executor-scope UUID minted per `executor.execute()` call
41
+ * in pi-executor.ts. It keys cost-tracker / token_usage rows in the
42
+ * observability store.
43
+ *
44
+ * They are 1:1 in the steady-state interactive path (one inbound message →
45
+ * one execution), but heartbeat and sub-agent paths can fan out a single
46
+ * trace into multiple executions.
33
47
  */
34
48
  export interface SessionMetadata {
35
- /** Trace ID for cross-correlating with daemon logs */
49
+ /** Request-scope trace ID from runWithContext; matches traceId in daemon.log. */
36
50
  traceId?: string;
37
- /** Execution run ID */
51
+ /** Executor-scope run ID; keys cost-tracker / token_usage rows. */
38
52
  runId?: string;
39
53
  /** Session end marker with completion details */
40
54
  sessionEnd?: {
@@ -105,7 +119,7 @@ export interface ComisSessionManager {
105
119
  */
106
120
  writeSessionMetadata(sessionKey: SessionKey, metadata: SessionMetadata): void;
107
121
  /**
108
- * 260428-iag: Resolve the absolute JSONL session file path for a session key.
122
+ * Resolve the absolute JSONL session file path for a session key.
109
123
  *
110
124
  * Thin synchronous wrapper around `sessionKeyToPath(sessionKey, deps.sessionBaseDir)`
111
125
  * 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,5 +1,5 @@
1
1
  /**
2
- * Pi-mono adapter wrappers for sub-agent ephemeral sessions (R-11).
2
+ * Pi-mono adapter wrappers for sub-agent ephemeral sessions.
3
3
  *
4
4
  * Provides `createEphemeralComisSessionManager()` — a zero-persistence
5
5
  * ComisSessionManager whose `withSession` uses `SessionManager.inMemory()`
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  /**
3
- * Pi-mono adapter wrappers for sub-agent ephemeral sessions (R-11).
3
+ * Pi-mono adapter wrappers for sub-agent ephemeral sessions.
4
4
  *
5
5
  * Provides `createEphemeralComisSessionManager()` — a zero-persistence
6
6
  * ComisSessionManager whose `withSession` uses `SessionManager.inMemory()`
@@ -51,10 +51,10 @@ export function createEphemeralComisSessionManager(cwd) {
51
51
  // No-op: no companion file for in-memory sessions
52
52
  },
53
53
  getSessionPath() {
54
- // 260428-iag wire-edge diagnostic: ephemeral sub-agent sessions never
55
- // persist a JSONL file, so there is no path to return. Empty string
56
- // signals "no persisted file"; the bridge's wire-diff hook short-circuits
57
- // when jsonlPath.length === 0.
54
+ // Wire-edge diagnostic: ephemeral sub-agent sessions never persist a
55
+ // JSONL file, so there is no path to return. Empty string signals
56
+ // "no persisted file"; the bridge's wire-diff hook short-circuits when
57
+ // jsonlPath.length === 0.
58
58
  return "";
59
59
  },
60
60
  };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Workspace-internal data env resolver.
3
+ *
4
+ * Returns environment variables for python/matplotlib subprocesses that
5
+ * derive ALL paths from `workspaceDir`. Avoids slow pip installs in the
6
+ * chart hot path and matplotlib Fontconfig errors from a non-writable
7
+ * default cache dir.
8
+ *
9
+ * This file contains no host-env reads. Subprocesses inheriting the
10
+ * daemon's full environment can pick up host paths (e.g.
11
+ * `/root/.cache/matplotlib`) that fail under read-only systemd hardening
12
+ * (`ProtectSystem=strict`) and leak host PATH into the agent's tool
13
+ * execution.
14
+ *
15
+ * matplotlib + python deps install into the agent workspace's `venv/`.
16
+ * The Dockerfile pre-warms the default workspace's venv at image build
17
+ * time so first-chart latency drops; subsequent chart calls reuse the
18
+ * venv. Full Docker image size goes up (acceptable trade-off).
19
+ *
20
+ * Mirrors workspace-resolver.ts's safePath + workspaceDir precedent
21
+ * (no path.join, no host-env reads).
22
+ *
23
+ * @module
24
+ */
25
+ /**
26
+ * Resolve workspace-internal env vars for python/matplotlib subprocesses.
27
+ *
28
+ * The returned record is intended to be MERGED over an existing subprocess
29
+ * env at the call site (e.g. exec-tool's `{ ...baseEnv, ...resolveDataEnv(...) }`),
30
+ * so the workspace-internal values win on collision and the host PATH /
31
+ * cache dirs are not surfaced inside the subprocess.
32
+ *
33
+ * @param opts.workspaceDir - Absolute path to the agent workspace.
34
+ * @returns env-var record suitable for `child_process.spawn(..., { env })`.
35
+ */
36
+ export declare function resolveDataEnv(opts: {
37
+ workspaceDir: string;
38
+ }): Record<string, string>;