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
@@ -4,9 +4,8 @@
4
4
  *
5
5
  * Observed problem: Anthropic 400 `messages.N.content.M: thinking/redacted_thinking
6
6
  * blocks cannot be modified` errors keep firing in production even after the
7
- * surrogate-guard, drift-scrubber, and signed-replay-detector layers shipped
8
- * (260425-rvm), and even after the immutable-section redirect (260425-t40).
9
- * Trace `c7b91328-9dc5-4618-9ae8-ca207b4b93df` on 2026-04-28 hit a 400 ~2.2s
7
+ * surrogate-guard, drift-scrubber, and signed-replay-detector layers shipped,
8
+ * and even after the immutable-section redirect. A trace hit a 400 ~2.2s
10
9
  * after `turn_end` -- meaning *some other layer* mutates a signed thinking
11
10
  * block between the assistant turn and the next replay. We don't know which.
12
11
  *
@@ -24,12 +23,12 @@
24
23
  * - NEVER mutates inputs. Pure read; only output is the structured log.
25
24
  * - NEVER alters request flow. The mismatch is observable signal only --
26
25
  * Anthropic's 400 still surfaces through the existing error path
27
- * (signed-replay-detector -> executor-prompt-runner). Bug A behavior fix
28
- * is a separate quick task gated on what this diagnostic reveals.
26
+ * (signed-replay-detector -> executor-prompt-runner). The behavior fix
27
+ * for the underlying bug is gated on what this diagnostic reveals.
29
28
  *
30
29
  * Logging surface follows CLAUDE.md canonical Pino fields:
31
30
  * - object-first signature: `error({...fields}, "msg")`
32
- * - `module: "agent.bridge.hash-invariant"`
31
+ * - `submodule: "bridge.hash-invariant"` (parent logger binds `module: "agent"`)
33
32
  * - `errorKind: "internal"` (classification per AGENTS.md §2.1)
34
33
  * - `hint`: actionable next step for the on-call diagnoser
35
34
  * - `responseId`, `blockIndex`, `oldHash`, `newHash`,
@@ -51,7 +50,7 @@ import { readFile as fsReadFile } from "node:fs/promises";
51
50
  const HINT = "Locate the context-engine layer that touched this block " +
52
51
  "(likely between turn_end and the next pi-ai serialize step). " +
53
52
  "Compare oldText.firstChars vs newText.firstChars to identify mutation type.";
54
- const MODULE_FIELD = "agent.bridge.hash-invariant";
53
+ const SUBMODULE_FIELD = "bridge.hash-invariant";
55
54
  const ERROR_KIND = "internal";
56
55
  const TEXT_PREFIX_LEN = 32;
57
56
  /** Format the four-field hash payload for one block. */
@@ -148,7 +147,7 @@ export function assertThinkingBlocksUnchanged(prior, current, responseId, deps)
148
147
  if (!now) {
149
148
  mismatchesLogged++;
150
149
  safeLog(deps, {
151
- module: MODULE_FIELD,
150
+ submodule: SUBMODULE_FIELD,
152
151
  responseId,
153
152
  blockIndex: old.blockIndex,
154
153
  oldHash: old.hash,
@@ -166,7 +165,7 @@ export function assertThinkingBlocksUnchanged(prior, current, responseId, deps)
166
165
  if (now.hash !== old.hash) {
167
166
  mismatchesLogged++;
168
167
  safeLog(deps, {
169
- module: MODULE_FIELD,
168
+ submodule: SUBMODULE_FIELD,
170
169
  responseId,
171
170
  blockIndex: old.blockIndex,
172
171
  oldHash: old.hash,
@@ -187,14 +186,14 @@ export function assertThinkingBlocksUnchanged(prior, current, responseId, deps)
187
186
  };
188
187
  }
189
188
  // ---------------------------------------------------------------------------
190
- // 260428-hoy: Canonical thinking-block restoration
189
+ // Canonical thinking-block restoration
191
190
  //
192
191
  // Heals cross-turn mutation of signed thinking blocks before pi-ai serializes
193
192
  // the next API request. Pure / idempotent / never-throws. Runs AFTER
194
193
  // `assertThinkingBlocksUnchanged` so the diagnostic ERROR log captures every
195
194
  // mutation before the heal overwrites it.
196
195
  // ---------------------------------------------------------------------------
197
- const RESTORE_MODULE_FIELD = "agent.bridge.canonical-restore";
196
+ const RESTORE_SUBMODULE_FIELD = "bridge.canonical-restore";
198
197
  const RESTORE_WARN_HINT = "Canonical restore aborted on malformed input; in-memory messages " +
199
198
  "returned unchanged. Inspect prior context-engine layers for shape drift.";
200
199
  /** Best-effort logger.info / logger.warn -- swallows logger errors. */
@@ -232,7 +231,7 @@ function safeRestoreLog(deps, level, payload, msg) {
232
231
  * Never throws. On any unexpected error during the walk (e.g. malformed
233
232
  * canonical entry whose getter throws), the entire result is `{ messages:
234
233
  * <input ref>, restoredCount: 0, affectedResponseIds: [] }` and ONE WARN log
235
- * fires with `module: RESTORE_MODULE_FIELD, errorKind: "internal"`.
234
+ * fires with `submodule: RESTORE_SUBMODULE_FIELD, errorKind: "internal"`.
236
235
  */
237
236
  export function restoreCanonicalThinkingBlocks(messages, canonicalStore, deps) {
238
237
  if (!Array.isArray(messages)) {
@@ -274,7 +273,7 @@ export function restoreCanonicalThinkingBlocks(messages, canonicalStore, deps) {
274
273
  };
275
274
  }
276
275
  safeRestoreLog(deps, "info", {
277
- module: RESTORE_MODULE_FIELD,
276
+ submodule: RESTORE_SUBMODULE_FIELD,
278
277
  restoredCount,
279
278
  affectedResponseIds,
280
279
  }, "Restored canonical thinking blocks before resend");
@@ -284,7 +283,7 @@ export function restoreCanonicalThinkingBlocks(messages, canonicalStore, deps) {
284
283
  // Defensive last-resort: malformed canonical entry or any other thrown
285
284
  // error during the walk. Return the in-memory shape unchanged + WARN log.
286
285
  safeRestoreLog(deps, "warn", {
287
- module: RESTORE_MODULE_FIELD,
286
+ submodule: RESTORE_SUBMODULE_FIELD,
288
287
  errorKind: "internal",
289
288
  hint: RESTORE_WARN_HINT,
290
289
  }, "Canonical restore aborted on malformed input");
@@ -380,16 +379,16 @@ function blockHash(block) {
380
379
  return createHash("sha256").update(input).digest("hex");
381
380
  }
382
381
  // ---------------------------------------------------------------------------
383
- // 260428-iag: Wire-edge diagnostic — diff in-memory thinking blocks against
384
- // persisted JSONL canonical.
382
+ // Wire-edge diagnostic — diff in-memory thinking blocks against persisted
383
+ // JSONL canonical.
385
384
  //
386
385
  // Fires from the pi-event-bridge LLM-error path when Anthropic returns 400
387
386
  // with a "thinking blocks ... cannot be modified" signature, even after the
388
- // 260428-hoy canonical-restore layer ran pre-serialize. The persisted JSONL
389
- // is the only truly immutable record of the assistant message — written
390
- // byte-for-byte from Anthropic's stream at receipt time. A divergence between
391
- // in-memory content and persisted canonical at this point implies the
392
- // mutation occurred AFTER the bridge restoration hook (likely inside pi-ai's
387
+ // canonical-restore layer ran pre-serialize. The persisted JSONL is the only
388
+ // truly immutable record of the assistant message — written byte-for-byte
389
+ // from Anthropic's stream at receipt time. A divergence between in-memory
390
+ // content and persisted canonical at this point implies the mutation
391
+ // occurred AFTER the bridge restoration hook (likely inside pi-ai's
393
392
  // `sanitizeSurrogates` during request serialization).
394
393
  //
395
394
  // Behavior contract (mirrors the rest of this module):
@@ -398,7 +397,7 @@ function blockHash(block) {
398
397
  // and an empty result. The diagnostic must NEVER abort agent flow.
399
398
  // - Caller passes a resolved `jsonlPath`; this helper does not compose paths.
400
399
  // ---------------------------------------------------------------------------
401
- const WIRE_DIFF_MODULE_FIELD = "agent.bridge.wire-diff";
400
+ const WIRE_DIFF_SUBMODULE_FIELD = "bridge.wire-diff";
402
401
  export const WIRE_DIFF_HINT_FILE_MISSING = "JSONL session file unreadable; wire-edge diff skipped. " +
403
402
  "Confirm session path resolution and filesystem permissions.";
404
403
  export const WIRE_DIFF_HINT_NOT_FOUND = "responseId not present in persisted JSONL session file; " +
@@ -462,7 +461,7 @@ export async function diffThinkingBlocksAgainstPersisted(inMemoryContent, respon
462
461
  }
463
462
  catch (readErr) {
464
463
  safeWireDiffLog(deps, "warn", {
465
- module: WIRE_DIFF_MODULE_FIELD,
464
+ submodule: WIRE_DIFF_SUBMODULE_FIELD,
466
465
  errorKind: ERROR_KIND,
467
466
  hint: WIRE_DIFF_HINT_FILE_MISSING,
468
467
  jsonlPath,
@@ -506,7 +505,7 @@ export async function diffThinkingBlocksAgainstPersisted(inMemoryContent, respon
506
505
  }
507
506
  if (persistedContent === null) {
508
507
  safeWireDiffLog(deps, "warn", {
509
- module: WIRE_DIFF_MODULE_FIELD,
508
+ submodule: WIRE_DIFF_SUBMODULE_FIELD,
510
509
  errorKind: ERROR_KIND,
511
510
  hint: WIRE_DIFF_HINT_NOT_FOUND,
512
511
  jsonlPath,
@@ -554,7 +553,7 @@ export async function diffThinkingBlocksAgainstPersisted(inMemoryContent, respon
554
553
  // computeThinkingBlockHashes against malformed input, etc.), degrade
555
554
  // to WARN + empty result.
556
555
  safeWireDiffLog(deps, "warn", {
557
- module: WIRE_DIFF_MODULE_FIELD,
556
+ submodule: WIRE_DIFF_SUBMODULE_FIELD,
558
557
  errorKind: ERROR_KIND,
559
558
  hint: WIRE_DIFF_HINT_INTERNAL,
560
559
  jsonlPath,
@@ -3,7 +3,7 @@ import type { ModelOperationType } from "@comis/core";
3
3
  * Per-agent/channel/execution cost record.
4
4
  *
5
5
  * Captures token counts and cost breakdown for attribution
6
- * and observability. Persistence via event bus comes in Phase 6.
6
+ * and observability. Persistence via event bus is planned.
7
7
  */
8
8
  export interface CostRecord {
9
9
  timestamp: number;
@@ -84,7 +84,7 @@ export declare const BOOTSTRAP_BUDGET_WARN_PERCENT = 85;
84
84
  * Minimum cacheable token thresholds by model family prefix.
85
85
  * Used by: cache breakpoint placement.
86
86
  *
87
- * Values are Anthropic's official API minimums verified 2026-03-30.
87
+ * Values are Anthropic's official API minimums.
88
88
  * Setting lower causes silent no-ops (breakpoints ignored, tokens not cached).
89
89
  */
90
90
  export declare const MIN_CACHEABLE_TOKENS: Record<string, number>;
@@ -131,11 +131,11 @@ export declare const MAX_REHYDRATION_FILES = 5;
131
131
  export declare const MAX_REHYDRATION_FILE_CHARS = 8000;
132
132
  /** Maximum total chars for all rehydration content (safety cap). Used by: rehydration overflow check. */
133
133
  export declare const MAX_REHYDRATION_TOTAL_CHARS = 30000;
134
- /** Maximum chars per individual skill in rehydration restoration (POST-COMPACT-BUDGET).
134
+ /** Maximum chars per individual skill in rehydration restoration.
135
135
  * Skills exceeding this limit are truncated at the boundary with closing tag repair.
136
136
  * Used by: rehydration layer buildSkillsContent(). */
137
137
  export declare const MAX_REHYDRATION_CHARS_PER_SKILL = 5000;
138
- /** Maximum total chars for all rehydration content combined (POST-COMPACT-BUDGET).
138
+ /** Maximum total chars for all rehydration content combined.
139
139
  * This is the token-budgeted restoration cap (50K chars ~ 12,500 tokens at 4:1 ratio).
140
140
  * Used by: rehydration layer overflow check. */
141
141
  export declare const MAX_REHYDRATION_TOKEN_BUDGET_CHARS = 50000;
@@ -169,10 +169,10 @@ export declare const XML_WRAPPER_OVERHEAD_TOKENS = 40;
169
169
  export declare const RECALL_GUIDANCE = "You have access to a context DAG containing your full conversation history. Summaries marked with <context_summary> tags contain compressed versions of earlier exchanges. To view full details of any summarized content, use the ctx_inspect tool with the summary ID. For broader recall across your history, use ctx_search with a text query.";
170
170
  /** Relative threshold for cache break detection. Break detected when cacheRead
171
171
  * drops by more than this fraction of the previous baseline.
172
- * Used by: cache break detector Phase 2 check. */
172
+ * Used by: cache break detector. */
173
173
  export declare const CACHE_BREAK_RELATIVE_THRESHOLD = 0.05;
174
174
  /** Absolute threshold for cache break detection (tokens). Break detected when
175
175
  * cacheRead drops by more than this many tokens from the previous baseline.
176
176
  * Both relative AND absolute thresholds must be exceeded to trigger detection.
177
- * Used by: cache break detector Phase 2 check. */
177
+ * Used by: cache break detector. */
178
178
  export declare const CACHE_BREAK_ABSOLUTE_THRESHOLD = 2000;
@@ -29,12 +29,12 @@ export const CONTEXT_ROT_BUFFER_PERCENT = 25;
29
29
  /** Consecutive layer failures before circuit breaker disables the layer for the session. Used by: layer pipeline runner. */
30
30
  export const LAYER_CIRCUIT_BREAKER_THRESHOLD = 3;
31
31
  // ---------------------------------------------------------------------------
32
- // Thinking Block Cleaner (Layer 4: )
32
+ // Thinking Block Cleaner (Layer 4)
33
33
  // ---------------------------------------------------------------------------
34
34
  /** Default number of recent assistant turns that retain thinking blocks. Used by: thinking block cleaner (Layer 4). */
35
35
  export const DEFAULT_KEEP_WINDOW_TURNS = 10;
36
36
  // ---------------------------------------------------------------------------
37
- // Microcompaction Guard (Layer 2: )
37
+ // Microcompaction Guard (Layer 2)
38
38
  // ---------------------------------------------------------------------------
39
39
  /** Default inline threshold for tool result microcompaction (chars). Used by: microcompaction guard. */
40
40
  export const MAX_INLINE_TOOL_RESULT_CHARS = 8_000;
@@ -59,7 +59,7 @@ export const MAX_REHYDRATION_SKILL_CHARS = 15_000;
59
59
  /** Maximum number of individual skills to restore after compaction. Used by: rehydration skill restoration. */
60
60
  export const MAX_REHYDRATION_SKILLS = 10;
61
61
  // ---------------------------------------------------------------------------
62
- // Observation Masker (Layer 3: )
62
+ // Observation Masker (Layer 3)
63
63
  // ---------------------------------------------------------------------------
64
64
  /** Default observation masking keep window (most recent N tool uses retained). Used by: observation masker. */
65
65
  export const DEFAULT_OBSERVATION_KEEP_WINDOW = 15;
@@ -121,7 +121,7 @@ export const CHARS_PER_TOKEN_RATIO = 3.5;
121
121
  * over the flat 4:1 ratio. Used by: content-aware token estimation. */
122
122
  export const CHARS_PER_TOKEN_RATIO_STRUCTURED = 3;
123
123
  // ---------------------------------------------------------------------------
124
- // Cache Optimization (Layer: )
124
+ // Cache Optimization
125
125
  // ---------------------------------------------------------------------------
126
126
  /** Length of truncated SHA-256 digest for system prompt hash comparison. Used by: prompt-assembly hash validation. */
127
127
  export const SYSTEM_PROMPT_HASH_LENGTH = 16;
@@ -131,7 +131,7 @@ export const BOOTSTRAP_BUDGET_WARN_PERCENT = 85;
131
131
  * Minimum cacheable token thresholds by model family prefix.
132
132
  * Used by: cache breakpoint placement.
133
133
  *
134
- * Values are Anthropic's official API minimums verified 2026-03-30.
134
+ * Values are Anthropic's official API minimums.
135
135
  * Setting lower causes silent no-ops (breakpoints ignored, tokens not cached).
136
136
  */
137
137
  export const MIN_CACHEABLE_TOKENS = {
@@ -167,7 +167,7 @@ export const CACHE_LOOKBACK_WINDOW = 20;
167
167
  * Used by: llm-compaction layer cache-aware trigger. */
168
168
  export const CACHE_AWARE_COMPACTION_BLOCK_THRESHOLD = 60;
169
169
  // ---------------------------------------------------------------------------
170
- // LLM Compaction (Layer 5: )
170
+ // LLM Compaction (Layer 5)
171
171
  // ---------------------------------------------------------------------------
172
172
  /** Context utilization percentage that triggers LLM compaction. Used by: llm-compaction layer. */
173
173
  export const COMPACTION_TRIGGER_PERCENT = 85;
@@ -192,7 +192,7 @@ export const DEFAULT_COMPACTION_PREFIX_ANCHOR_TURNS = 2;
192
192
  * Used by: llm-compaction layer. */
193
193
  export const MIN_MIDDLE_MESSAGES_FOR_COMPACTION = 3;
194
194
  // ---------------------------------------------------------------------------
195
- // Post-Compaction Rehydration (Layer 6: )
195
+ // Post-Compaction Rehydration (Layer 6)
196
196
  // ---------------------------------------------------------------------------
197
197
  /** Maximum number of recently-accessed files to re-inject after compaction. Used by: rehydration layer. */
198
198
  export const MAX_REHYDRATION_FILES = 5;
@@ -200,16 +200,16 @@ export const MAX_REHYDRATION_FILES = 5;
200
200
  export const MAX_REHYDRATION_FILE_CHARS = 8_000;
201
201
  /** Maximum total chars for all rehydration content (safety cap). Used by: rehydration overflow check. */
202
202
  export const MAX_REHYDRATION_TOTAL_CHARS = 30_000;
203
- /** Maximum chars per individual skill in rehydration restoration (POST-COMPACT-BUDGET).
203
+ /** Maximum chars per individual skill in rehydration restoration.
204
204
  * Skills exceeding this limit are truncated at the boundary with closing tag repair.
205
205
  * Used by: rehydration layer buildSkillsContent(). */
206
206
  export const MAX_REHYDRATION_CHARS_PER_SKILL = 5_000;
207
- /** Maximum total chars for all rehydration content combined (POST-COMPACT-BUDGET).
207
+ /** Maximum total chars for all rehydration content combined.
208
208
  * This is the token-budgeted restoration cap (50K chars ~ 12,500 tokens at 4:1 ratio).
209
209
  * Used by: rehydration layer overflow check. */
210
210
  export const MAX_REHYDRATION_TOKEN_BUDGET_CHARS = 50_000;
211
211
  // ---------------------------------------------------------------------------
212
- // Dead Content Evictor (Layer: )
212
+ // Dead Content Evictor
213
213
  // ---------------------------------------------------------------------------
214
214
  /**
215
215
  * Default minimum age (in tool result positions) before content is eligible
@@ -294,10 +294,10 @@ export const RECALL_GUIDANCE = `You have access to a context DAG containing your
294
294
  // ---------------------------------------------------------------------------
295
295
  /** Relative threshold for cache break detection. Break detected when cacheRead
296
296
  * drops by more than this fraction of the previous baseline.
297
- * Used by: cache break detector Phase 2 check. */
297
+ * Used by: cache break detector. */
298
298
  export const CACHE_BREAK_RELATIVE_THRESHOLD = 0.05;
299
299
  /** Absolute threshold for cache break detection (tokens). Break detected when
300
300
  * cacheRead drops by more than this many tokens from the previous baseline.
301
301
  * Both relative AND absolute thresholds must be exceeded to trigger detection.
302
- * Used by: cache break detector Phase 2 check. */
302
+ * Used by: cache break detector. */
303
303
  export const CACHE_BREAK_ABSOLUTE_THRESHOLD = 2_000;
@@ -201,13 +201,22 @@ export function createContextEngine(config, deps) {
201
201
  // most recent one. Always-on — no drift-mode gate. The latest
202
202
  // assistant message keeps its signatures so Anthropic's
203
203
  // extended-thinking continuation can validate the immediate next
204
- // call's prefix. (Replaces 260428-kvl detection-based approach;
205
- // see .planning/quick/260428-lm6 for rationale.)
204
+ // call's prefix.
206
205
  if (deps.getReplayDriftMode) {
207
206
  const getReplayDriftMode = deps.getReplayDriftMode;
208
207
  layers.push(createSignatureReplayScrubber({
209
208
  getReplayDriftMode,
210
- onScrubbed: (stats) => { callbackState.signatureReplayScrubber = stats; },
209
+ onScrubbed: (stats) => {
210
+ // Snapshot the latest stats for the existing post-pipeline DEBUG
211
+ // summary at lines ~720-727 (preserves legacy aliases dropped /
212
+ // signaturesStripped / reason).
213
+ callbackState.signatureReplayScrubber = stats;
214
+ // Also forward stats to the optional per-execute accumulator wired
215
+ // in by executor-context-engine-setup.ts. The two callbacks are
216
+ // deliberately separate: the snapshot consumer overwrites per-call,
217
+ // the accumulator sums across calls.
218
+ deps.onSignatureReplayScrubbed?.(stats);
219
+ },
211
220
  logger: deps.logger,
212
221
  }));
213
222
  }
@@ -241,7 +250,7 @@ export function createContextEngine(config, deps) {
241
250
  // Observation masker: masks old tool results beyond the keep window.
242
251
  // Always active when context engine is enabled. The threshold check inside the
243
252
  // masker handles short-session bypass.
244
- // Phase 8: Three-tier masking (protected/standard/ephemeral) with per-tier counters.
253
+ // Three-tier masking (protected/standard/ephemeral) with per-tier counters.
245
254
  const observationKeepWindow = config.observationKeepWindow ?? 25;
246
255
  const observationTriggerChars = config.observationTriggerChars ?? 120_000;
247
256
  const ephemeralKeepWindow = config.ephemeralKeepWindow;
@@ -15,8 +15,7 @@
15
15
  * - Already-annotated and already-masked results are skipped
16
16
  * - Recent tool results within the keep window are preserved
17
17
  *
18
- * DAG Assembly & Annotation.
19
- * Phase 8: Tier-aware annotation.
18
+ * DAG Assembly & Annotation. Tier-aware annotation.
20
19
  *
21
20
  * @module
22
21
  */
@@ -16,8 +16,7 @@
16
16
  * - Already-annotated and already-masked results are skipped
17
17
  * - Recent tool results within the keep window are preserved
18
18
  *
19
- * DAG Assembly & Annotation.
20
- * Phase 8: Tier-aware annotation.
19
+ * DAG Assembly & Annotation. Tier-aware annotation.
21
20
  *
22
21
  * @module
23
22
  */
@@ -279,21 +279,7 @@ export function createLlmCompactionLayer(config, deps) {
279
279
  return messages;
280
280
  }
281
281
  }
282
- // Step 4: Unified log (conditional spread keeps JSON shape clean).
283
- deps.logger.warn({
284
- messageCount,
285
- ...(blockCountExceeded
286
- ? { blockThreshold, trigger: "block_count" }
287
- : { contextTokens, thresholdTokens, trigger: "token_threshold" }),
288
- windowTokens: budget.windowTokens,
289
- errorKind: "resource",
290
- hint: blockCountExceeded
291
- ? "Message count approaching breakpoint lookback limit; compacting to prevent cache fragmentation"
292
- : "Context approaching capacity; LLM compaction will summarize older messages to free space",
293
- }, blockCountExceeded
294
- ? "LLM compaction triggered: message count exceeds cache lookback threshold"
295
- : "LLM compaction triggered: context exceeds 85% threshold");
296
- // Step 5: Resolve model
282
+ // Step 4: Resolve model
297
283
  /* eslint-disable @typescript-eslint/no-explicit-any */
298
284
  let model;
299
285
  let apiKey;
@@ -365,10 +351,28 @@ export function createLlmCompactionLayer(config, deps) {
365
351
  /* eslint-enable security/detect-object-injection */
366
352
  // Zone 2: Middle (to be summarized)
367
353
  const middleMessages = messages.slice(headEndIndex, tailStartIndex);
368
- // Skip if middle is empty or too small to warrant summarization
354
+ // Skip if middle is empty or too small to warrant summarization.
355
+ // Reset the cooldown counter so we don't re-evaluate (and re-warn)
356
+ // on every subsequent turn when the conversation shape stays this way.
369
357
  if (middleMessages.length < MIN_MIDDLE_MESSAGES_FOR_COMPACTION) {
358
+ turnsSinceLastCompaction = 0;
370
359
  return messages;
371
360
  }
361
+ // Trigger log fires only when compaction will actually run, so log
362
+ // volume reflects real compaction work (not infeasibility re-checks).
363
+ deps.logger.warn({
364
+ messageCount,
365
+ ...(blockCountExceeded
366
+ ? { blockThreshold, trigger: "block_count" }
367
+ : { contextTokens, thresholdTokens, trigger: "token_threshold" }),
368
+ windowTokens: budget.windowTokens,
369
+ errorKind: "resource",
370
+ hint: blockCountExceeded
371
+ ? "Message count approaching breakpoint lookback limit; compacting to prevent cache fragmentation"
372
+ : "Context approaching capacity; LLM compaction will summarize older messages to free space",
373
+ }, blockCountExceeded
374
+ ? "LLM compaction triggered: message count exceeds cache lookback threshold"
375
+ : "LLM compaction triggered: context exceeds 85% threshold");
372
376
  // Step 7: Summarize ONLY the middle zone (do NOT pass head or tail to generateSummary)
373
377
  const compactionResult = await compactWithFallback(middleMessages, model, apiKey, budget.outputReserveTokens, deps.logger);
374
378
  // Build compaction summary message matching SDK format
@@ -96,7 +96,7 @@ function buildSkillsContent(deps) {
96
96
  return "";
97
97
  const closingTag = "</skill>";
98
98
  const skillOpenRegex = /<skill[\s>]/g;
99
- // Phase 1: Extract individual skill blocks and apply per-skill truncation (POST-COMPACT-BUDGET)
99
+ // Extract individual skill blocks and apply per-skill truncation
100
100
  const skillBlocks = [];
101
101
  let match;
102
102
  while ((match = skillOpenRegex.exec(xml)) !== null) {
@@ -105,7 +105,7 @@ function buildSkillsContent(deps) {
105
105
  if (closeIdx === -1)
106
106
  break; // malformed -- stop
107
107
  let skillBlock = xml.slice(startIdx, closeIdx + closingTag.length);
108
- // POST-COMPACT-BUDGET: Per-skill truncation with closing tag repair
108
+ // Per-skill truncation with closing tag repair
109
109
  if (skillBlock.length > MAX_REHYDRATION_CHARS_PER_SKILL) {
110
110
  // Reserve space for repair suffix: "\n...</skill>" = 12 chars
111
111
  const repairSuffix = "\n..." + closingTag;
@@ -120,14 +120,14 @@ function buildSkillsContent(deps) {
120
120
  }
121
121
  if (skillBlocks.length === 0)
122
122
  return "";
123
- // Phase 2: Enforce MAX_REHYDRATION_SKILLS count limit
123
+ // Enforce MAX_REHYDRATION_SKILLS count limit
124
124
  const limitedBlocks = skillBlocks.slice(0, MAX_REHYDRATION_SKILLS);
125
- // Phase 3: Reassemble XML with wrapper
125
+ // Reassemble XML with wrapper
126
126
  // Preserve opening tag from original XML
127
127
  const wrapperOpenEnd = xml.indexOf(">") + 1;
128
128
  const wrapperOpen = xml.slice(0, wrapperOpenEnd);
129
129
  let truncatedXml = wrapperOpen + "\n" + limitedBlocks.join("\n") + "\n</available_skills>";
130
- // Phase 4: Enforce char budget (15K)
130
+ // Enforce char budget (15K)
131
131
  if (truncatedXml.length > MAX_REHYDRATION_SKILL_CHARS) {
132
132
  // Re-truncate at skill boundaries within char budget
133
133
  const withinBudget = truncatedXml.slice(0, MAX_REHYDRATION_SKILL_CHARS);
@@ -236,7 +236,7 @@ export function createRehydrationLayer(deps) {
236
236
  // Position 1 (stable content -- changes rarely, good for KV-cache prefix):
237
237
  const position1Parts = [agentsMdSection, fileSection, skillsSection].filter(Boolean);
238
238
  let position1Text = position1Parts.join("\n\n");
239
- // POST-COMPACT-BUDGET: Enforce total rehydration token budget
239
+ // Enforce total rehydration token budget
240
240
  if (position1Text.length > MAX_REHYDRATION_TOKEN_BUDGET_CHARS) {
241
241
  deps.logger.warn({
242
242
  totalChars: position1Text.length,
@@ -7,20 +7,20 @@
7
7
  * blocks are never modified, anywhere.
8
8
  *
9
9
  * Rationale: Anthropic's signed-thinking validation operates on the full
10
- * (system + tools + history) prefix. After 8 quick tasks of progressively
11
- * narrower drift detection (gj6 → kvl) we proved targeted detection is
12
- * intractable; trace 679c8927 had stable tools (49138 bytes across 4 turns)
13
- * but the system prompt grew +1824 bytes and the 400 fired anyway.
10
+ * (system + tools + history) prefix. After progressive refinement of
11
+ * narrower drift detection we proved targeted detection is intractable;
12
+ * traces with stable tools but a system prompt that grew by ~1.8KB still
13
+ * fired the 400.
14
14
  *
15
- * 260428-lm6 introduced an unconditional drop that preserved the LATEST
16
- * assistant message's signatures, on the theory that the immediate-next
17
- * continuation could still validate them. 260428-nzp's repro proved that
18
- * carve-out doesn't work: cross-turn signature validation covers the whole
19
- * request body (system + tools + history) and comis's dynamic context
20
- * guarantees the surrounding context changes turn-to-turn. So the latest's
21
- * signatures get invalidated too. Drop them all.
15
+ * An earlier unconditional drop preserved the LATEST assistant message's
16
+ * signatures, on the theory that the immediate-next continuation could
17
+ * still validate them. Repro proved that carve-out doesn't work:
18
+ * cross-turn signature validation covers the whole request body (system +
19
+ * tools + history) and comis's dynamic context guarantees the surrounding
20
+ * context changes turn-to-turn. So the latest's signatures get
21
+ * invalidated too. Drop them all.
22
22
  *
23
- * 260430-anthropic-400-thinking-block: the prior cache-fence skip
23
+ * The prior cache-fence skip
24
24
  * (`if (i <= budget.cacheFenceIndex) preserve`) caused a per-execution
25
25
  * regression. In iteration 1 of an execution the fence is -1 so all signed
26
26
  * thinking blocks are stripped and the wire body establishes a cached
@@ -8,20 +8,20 @@
8
8
  * blocks are never modified, anywhere.
9
9
  *
10
10
  * Rationale: Anthropic's signed-thinking validation operates on the full
11
- * (system + tools + history) prefix. After 8 quick tasks of progressively
12
- * narrower drift detection (gj6 → kvl) we proved targeted detection is
13
- * intractable; trace 679c8927 had stable tools (49138 bytes across 4 turns)
14
- * but the system prompt grew +1824 bytes and the 400 fired anyway.
11
+ * (system + tools + history) prefix. After progressive refinement of
12
+ * narrower drift detection we proved targeted detection is intractable;
13
+ * traces with stable tools but a system prompt that grew by ~1.8KB still
14
+ * fired the 400.
15
15
  *
16
- * 260428-lm6 introduced an unconditional drop that preserved the LATEST
17
- * assistant message's signatures, on the theory that the immediate-next
18
- * continuation could still validate them. 260428-nzp's repro proved that
19
- * carve-out doesn't work: cross-turn signature validation covers the whole
20
- * request body (system + tools + history) and comis's dynamic context
21
- * guarantees the surrounding context changes turn-to-turn. So the latest's
22
- * signatures get invalidated too. Drop them all.
16
+ * An earlier unconditional drop preserved the LATEST assistant message's
17
+ * signatures, on the theory that the immediate-next continuation could
18
+ * still validate them. Repro proved that carve-out doesn't work:
19
+ * cross-turn signature validation covers the whole request body (system +
20
+ * tools + history) and comis's dynamic context guarantees the surrounding
21
+ * context changes turn-to-turn. So the latest's signatures get
22
+ * invalidated too. Drop them all.
23
23
  *
24
- * 260430-anthropic-400-thinking-block: the prior cache-fence skip
24
+ * The prior cache-fence skip
25
25
  * (`if (i <= budget.cacheFenceIndex) preserve`) caused a per-execution
26
26
  * regression. In iteration 1 of an execution the fence is -1 so all signed
27
27
  * thinking blocks are stripped and the wire body establishes a cached
@@ -85,11 +85,11 @@ export function createSignatureReplayScrubber(deps) {
85
85
  for (let i = 0; i < messages.length; i++) {
86
86
  // eslint-disable-next-line security/detect-object-injection -- numeric index
87
87
  const original = messages[i];
88
- // 260430-anthropic-400-thinking-block: cacheFenceIndex is intentionally
89
- // NOT consulted here. Stripping uniformly across the array keeps the
90
- // scrubbed prefix identical across iterations of the same execution,
91
- // which is what Anthropic's prompt-cache validator requires. See
92
- // module docstring for the full rationale.
88
+ // cacheFenceIndex is intentionally NOT consulted here. Stripping
89
+ // uniformly across the array keeps the scrubbed prefix identical
90
+ // across iterations of the same execution, which is what Anthropic's
91
+ // prompt-cache validator requires. See module docstring for the full
92
+ // rationale.
93
93
  const msg = original;
94
94
  if (msg.role !== "assistant" || !Array.isArray(msg.content)) {
95
95
  // eslint-disable-next-line security/detect-object-injection -- numeric index
@@ -183,16 +183,30 @@ export function createSignatureReplayScrubber(deps) {
183
183
  signaturesStripped: toolCallsAffected,
184
184
  reason: undefined,
185
185
  });
186
- // Emit INFO once per execute() when at least one assistant message
187
- // was actually scrubbed. Pino object-first; no string interp.
186
+ // Emit once per execute() when at least one assistant message was
187
+ // actually scrubbed. Pino object-first; no string interp.
188
+ //
189
+ // Conditional log level — DEBUG when toolCallsAffected===0
190
+ // (pure-thinking-block scrub, the routine high-frequency case per
191
+ // CLAUDE.md "N times per request -> DEBUG"); INFO when >0
192
+ // (post-incident-visibility case where a tool_call's thoughtSignature
193
+ // was stripped, the originally documented diagnostic value). The outer
194
+ // `scrubbedAssistantMessages > 0` gate is unchanged — empty scrubs
195
+ // never log at this site.
188
196
  if (scrubbedAssistantMessages > 0) {
189
- deps.logger.info({
190
- module: "agent.context-engine.signature-replay-scrub",
197
+ const payload = {
198
+ submodule: "context-engine.signature-replay-scrub",
191
199
  scrubbedAssistantMessages,
192
200
  blocksAffected,
193
201
  toolCallsAffected,
194
202
  latestAssistantIdx: latestIdx,
195
- }, "Dropped thinking signatures from all assistant messages (cross-turn replay)");
203
+ };
204
+ if (toolCallsAffected > 0) {
205
+ deps.logger.info(payload, "Dropped thinking signatures from all assistant messages (cross-turn replay)");
206
+ }
207
+ else {
208
+ deps.logger.debug(payload, "Dropped thinking signatures from all assistant messages (cross-turn replay)");
209
+ }
196
210
  }
197
211
  // Zero-allocation early return when nothing was actually changed.
198
212
  if (!anyChanged)
@@ -131,6 +131,21 @@ export interface ContextEngineDeps {
131
131
  /** Called when observation masking modifies content (maskedCount > 0).
132
132
  * Used by cache break detector to suppress false-positive CacheBreakEvents. */
133
133
  onContentModified?: () => void;
134
+ /** Optional sink for the signature-replay scrubber's per-apply stats.
135
+ * Receives the SAME shape the scrubber emits to its `onScrubbed` callback,
136
+ * so callers can accumulate per-execute totals without the scrubber owning
137
+ * the accumulator. Invoked alongside the existing snapshot wiring in
138
+ * context-engine.ts (the snapshot consumer at lines ~720-727 still works
139
+ * because field names and shapes are unchanged). */
140
+ onSignatureReplayScrubbed?: (stats: {
141
+ scrubbedAssistantMessages: number;
142
+ blocksAffected: number;
143
+ toolCallsAffected: number;
144
+ latestAssistantIdx: number;
145
+ dropped: number;
146
+ signaturesStripped: number;
147
+ reason?: string;
148
+ }) => void;
134
149
  /** Optional getter for the API-grounded token anchor.
135
150
  * Returns the last API response's input_tokens and message count.
136
151
  * When absent or returning null, estimation falls back to char-based heuristics. */
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Cache break detection module: two-phase detection with Anthropic adapter.
3
3
  *
4
- * Phase 1 (pre-call): Records prompt state via provider-specific adapter
4
+ * Pre-call: Records prompt state via provider-specific adapter
5
5
  * (system hash, per-tool schema hashes, cache_control metadata hash).
6
6
  *
7
- * Phase 2 (post-call): Compares cacheRead tokens against baseline using
7
+ * Post-call: Compares cacheRead tokens against baseline using
8
8
  * AND-based dual threshold (both >5% relative AND >2000 absolute must exceed).
9
9
  * Provider-agnostic.
10
10
  *
@@ -202,15 +202,15 @@ export interface CacheBreakDetectorOptions {
202
202
  */
203
203
  export declare function createCacheBreakDetector(logger: DetectorLogger, options?: CacheBreakDetectorOptions): CacheBreakDetector;
204
204
  /**
205
- * Extract prompt state from Anthropic API payload for Phase 1 recording.
205
+ * Extract prompt state from Anthropic API payload for pre-call recording.
206
206
  *
207
207
  * CRITICAL: Does NOT mutate the original params object. Creates shallow copies
208
- * for hashing with cache_control stripped (D-08). Per-tool hashing uses
209
- * input_schema (D-09).
208
+ * for hashing with cache_control stripped. Per-tool hashing uses
209
+ * input_schema.
210
210
  */
211
211
  export declare function extractAnthropicPromptState(params: Record<string, unknown>, modelId: string, retention: string | undefined, sessionKey: string, agentId: string, headers?: Record<string, string>): RecordPromptStateInput;
212
212
  /**
213
- * Extract Gemini-native prompt state for Phase 1 cache break detection.
213
+ * Extract Gemini-native prompt state for pre-call cache break detection.
214
214
  *
215
215
  * Gemini payload structure differs from Anthropic:
216
216
  * - System prompt: config.systemInstruction (string, not array of blocks)