comisai 1.0.33 → 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.
- package/node_modules/@comis/agent/dist/background/auto-background-middleware.d.ts +11 -1
- package/node_modules/@comis/agent/dist/background/auto-background-middleware.js +21 -4
- package/node_modules/@comis/agent/dist/background/background-task-manager.d.ts +2 -2
- package/node_modules/@comis/agent/dist/background/background-task-manager.js +61 -20
- package/node_modules/@comis/agent/dist/background/background-task-persistence.js +10 -3
- package/node_modules/@comis/agent/dist/background/background-task-types.d.ts +10 -3
- package/node_modules/@comis/agent/dist/background/background-task-types.js +1 -1
- package/node_modules/@comis/agent/dist/background/completion-formatter.d.ts +39 -0
- package/node_modules/@comis/agent/dist/background/completion-formatter.js +77 -0
- package/node_modules/@comis/agent/dist/background/completion-runner.d.ts +53 -0
- package/node_modules/@comis/agent/dist/background/completion-runner.js +151 -0
- package/node_modules/@comis/agent/dist/background/index.d.ts +4 -0
- package/node_modules/@comis/agent/dist/background/index.js +2 -0
- package/node_modules/@comis/agent/dist/bridge/bridge-metrics.d.ts +17 -2
- package/node_modules/@comis/agent/dist/bridge/bridge-metrics.js +14 -2
- package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.d.ts +23 -23
- package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.js +72 -60
- package/node_modules/@comis/agent/dist/bridge/thinking-block-hash-invariant.d.ts +6 -7
- package/node_modules/@comis/agent/dist/bridge/thinking-block-hash-invariant.js +24 -25
- package/node_modules/@comis/agent/dist/budget/cost-tracker.d.ts +1 -1
- package/node_modules/@comis/agent/dist/context-engine/constants.d.ts +5 -5
- package/node_modules/@comis/agent/dist/context-engine/constants.js +12 -12
- package/node_modules/@comis/agent/dist/context-engine/context-engine.js +13 -4
- package/node_modules/@comis/agent/dist/context-engine/dag-annotator.d.ts +1 -2
- package/node_modules/@comis/agent/dist/context-engine/dag-annotator.js +1 -2
- package/node_modules/@comis/agent/dist/context-engine/llm-compaction.js +20 -16
- package/node_modules/@comis/agent/dist/context-engine/rehydration.js +6 -6
- package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.d.ts +12 -12
- package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.js +36 -22
- package/node_modules/@comis/agent/dist/context-engine/types-core.d.ts +15 -0
- package/node_modules/@comis/agent/dist/executor/cache-break-detection.d.ts +6 -6
- package/node_modules/@comis/agent/dist/executor/cache-break-detection.js +8 -8
- package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.d.ts +16 -0
- package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.js +46 -5
- package/node_modules/@comis/agent/dist/executor/executor-post-execution.d.ts +30 -0
- package/node_modules/@comis/agent/dist/executor/executor-post-execution.js +17 -1
- package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.js +1 -1
- package/node_modules/@comis/agent/dist/executor/executor-response-filter.d.ts +7 -6
- package/node_modules/@comis/agent/dist/executor/executor-response-filter.js +9 -42
- package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.js +2 -3
- package/node_modules/@comis/agent/dist/executor/gemini-cache-injector.d.ts +2 -2
- package/node_modules/@comis/agent/dist/executor/gemini-cache-injector.js +4 -4
- package/node_modules/@comis/agent/dist/executor/phase-filter.d.ts +2 -2
- package/node_modules/@comis/agent/dist/executor/phase-filter.js +5 -7
- package/node_modules/@comis/agent/dist/executor/pi-executor.d.ts +13 -0
- package/node_modules/@comis/agent/dist/executor/pi-executor.js +71 -6
- package/node_modules/@comis/agent/dist/executor/post-batch-continuation.js +7 -7
- package/node_modules/@comis/agent/dist/executor/stream-wrappers/request-body-injector.d.ts +1 -1
- package/node_modules/@comis/agent/dist/executor/stream-wrappers/request-body-injector.js +1 -1
- package/node_modules/@comis/agent/dist/executor/tool-deferral.d.ts +2 -2
- package/node_modules/@comis/agent/dist/executor/tool-deferral.js +7 -7
- package/node_modules/@comis/agent/dist/index.d.ts +17 -0
- package/node_modules/@comis/agent/dist/index.js +32 -11
- package/node_modules/@comis/agent/dist/model/auth-provider.d.ts +25 -2
- package/node_modules/@comis/agent/dist/model/auth-provider.js +6 -0
- package/node_modules/@comis/agent/dist/model/compaction-model-resolver.d.ts +3 -3
- package/node_modules/@comis/agent/dist/model/compaction-model-resolver.js +3 -3
- package/node_modules/@comis/agent/dist/model/oauth-credential-store-file.d.ts +37 -0
- package/node_modules/@comis/agent/dist/model/oauth-credential-store-file.js +279 -0
- package/node_modules/@comis/agent/dist/model/oauth-credential-store-selector.d.ts +49 -0
- package/node_modules/@comis/agent/dist/model/oauth-credential-store-selector.js +50 -0
- package/node_modules/@comis/agent/dist/model/oauth-device-code.d.ts +57 -0
- package/node_modules/@comis/agent/dist/model/oauth-device-code.js +302 -0
- package/node_modules/@comis/agent/dist/model/oauth-env.d.ts +33 -0
- package/node_modules/@comis/agent/dist/model/oauth-env.js +38 -0
- package/node_modules/@comis/agent/dist/model/oauth-errors.d.ts +41 -0
- package/node_modules/@comis/agent/dist/model/oauth-errors.js +88 -0
- package/node_modules/@comis/agent/dist/model/oauth-identity.d.ts +53 -0
- package/node_modules/@comis/agent/dist/model/oauth-identity.js +141 -0
- package/node_modules/@comis/agent/dist/model/oauth-login-runner.d.ts +99 -0
- package/node_modules/@comis/agent/dist/model/oauth-login-runner.js +374 -0
- package/node_modules/@comis/agent/dist/model/oauth-tls-preflight.d.ts +58 -0
- package/node_modules/@comis/agent/dist/model/oauth-tls-preflight.js +82 -0
- package/node_modules/@comis/agent/dist/model/oauth-token-manager.d.ts +86 -16
- package/node_modules/@comis/agent/dist/model/oauth-token-manager.js +961 -66
- package/node_modules/@comis/agent/dist/model/operation-model-defaults.d.ts +9 -4
- package/node_modules/@comis/agent/dist/model/operation-model-defaults.js +36 -9
- package/node_modules/@comis/agent/dist/model/resolve-provider-api-key.d.ts +48 -0
- package/node_modules/@comis/agent/dist/model/resolve-provider-api-key.js +66 -0
- package/node_modules/@comis/agent/dist/provider/capabilities.d.ts +5 -5
- package/node_modules/@comis/agent/dist/provider/capabilities.js +10 -23
- package/node_modules/@comis/agent/dist/safety/tool-output-safety.js +3 -3
- package/node_modules/@comis/agent/dist/session/comis-session-manager.d.ts +1 -1
- package/node_modules/@comis/agent/dist/session/comis-session-manager.js +1 -1
- package/node_modules/@comis/agent/dist/spawn/narrative-caster.d.ts +10 -0
- package/node_modules/@comis/agent/dist/spawn/narrative-caster.js +5 -1
- package/node_modules/@comis/agent/package.json +1 -1
- package/node_modules/@comis/channels/dist/email/email-adapter.js +6 -6
- package/node_modules/@comis/channels/dist/email/imap-lifecycle.js +7 -7
- package/node_modules/@comis/channels/dist/shared/deliver-to-channel.js +12 -10
- package/node_modules/@comis/channels/dist/telegram/telegram-adapter.js +1 -1
- package/node_modules/@comis/channels/package.json +1 -1
- package/node_modules/@comis/cli/dist/cli.js +2 -0
- package/node_modules/@comis/cli/dist/commands/agent.d.ts +3 -3
- package/node_modules/@comis/cli/dist/commands/agent.js +46 -3
- package/node_modules/@comis/cli/dist/commands/auth.d.ts +37 -0
- package/node_modules/@comis/cli/dist/commands/auth.js +433 -0
- package/node_modules/@comis/cli/dist/commands/doctor.d.ts +4 -1
- package/node_modules/@comis/cli/dist/commands/doctor.js +20 -5
- package/node_modules/@comis/cli/dist/doctor/checks/oauth-health.d.ts +39 -0
- package/node_modules/@comis/cli/dist/doctor/checks/oauth-health.js +399 -0
- package/node_modules/@comis/cli/dist/doctor/types.d.ts +19 -0
- package/node_modules/@comis/cli/dist/index.d.ts +1 -0
- package/node_modules/@comis/cli/dist/index.js +10 -4
- package/node_modules/@comis/cli/dist/output/relative-time.d.ts +23 -0
- package/node_modules/@comis/cli/dist/output/relative-time.js +36 -0
- package/node_modules/@comis/cli/dist/wizard/non-interactive.js +17 -8
- package/node_modules/@comis/cli/dist/wizard/steps/03-provider.js +2 -1
- package/node_modules/@comis/cli/dist/wizard/steps/04-credentials.js +223 -34
- package/node_modules/@comis/cli/dist/wizard/steps/10-write-config.js +14 -0
- package/node_modules/@comis/cli/dist/wizard/steps/11-daemon-start.js +3 -3
- package/node_modules/@comis/cli/dist/wizard/types.d.ts +7 -0
- package/node_modules/@comis/cli/package.json +1 -1
- package/node_modules/@comis/core/dist/bootstrap.d.ts +1 -1
- package/node_modules/@comis/core/dist/config/env-substitution.d.ts +66 -0
- package/node_modules/@comis/core/dist/config/env-substitution.js +115 -0
- package/node_modules/@comis/core/dist/config/index.d.ts +3 -1
- package/node_modules/@comis/core/dist/config/index.js +2 -1
- package/node_modules/@comis/core/dist/config/loader.js +61 -0
- package/node_modules/@comis/core/dist/config/managed-sections.d.ts +3 -3
- package/node_modules/@comis/core/dist/config/managed-sections.js +10 -5
- package/node_modules/@comis/core/dist/config/schema-agent.d.ts +4 -0
- package/node_modules/@comis/core/dist/config/schema-agent.js +16 -1
- package/node_modules/@comis/core/dist/config/schema-background-tasks.d.ts +7 -0
- package/node_modules/@comis/core/dist/config/schema-background-tasks.js +7 -0
- package/node_modules/@comis/core/dist/config/schema-delivery.d.ts +2 -0
- package/node_modules/@comis/core/dist/config/schema-delivery.js +2 -0
- package/node_modules/@comis/core/dist/config/schema-gemini-cache.d.ts +0 -2
- package/node_modules/@comis/core/dist/config/schema-gemini-cache.js +0 -2
- package/node_modules/@comis/core/dist/config/schema-oauth.d.ts +23 -0
- package/node_modules/@comis/core/dist/config/schema-oauth.js +19 -0
- package/node_modules/@comis/core/dist/config/schema-skills.d.ts +6 -8
- package/node_modules/@comis/core/dist/config/schema-skills.js +3 -4
- package/node_modules/@comis/core/dist/config/schema.d.ts +10 -0
- package/node_modules/@comis/core/dist/config/schema.js +3 -0
- package/node_modules/@comis/core/dist/domain/background-task-origin.d.ts +39 -0
- package/node_modules/@comis/core/dist/domain/background-task-origin.js +39 -0
- package/node_modules/@comis/core/dist/event-bus/events-infra.d.ts +71 -2
- package/node_modules/@comis/core/dist/exports/config.d.ts +2 -2
- package/node_modules/@comis/core/dist/exports/config.js +1 -1
- package/node_modules/@comis/core/dist/exports/domain.d.ts +2 -0
- package/node_modules/@comis/core/dist/exports/domain.js +1 -0
- package/node_modules/@comis/core/dist/exports/ports.d.ts +2 -2
- package/node_modules/@comis/core/dist/exports/ports.js +1 -1
- package/node_modules/@comis/core/dist/ports/delivery-queue.d.ts +23 -0
- package/node_modules/@comis/core/dist/ports/delivery-queue.js +2 -0
- package/node_modules/@comis/core/dist/ports/index.d.ts +2 -0
- package/node_modules/@comis/core/dist/ports/index.js +1 -0
- package/node_modules/@comis/core/dist/ports/oauth-credential-store.d.ts +64 -0
- package/node_modules/@comis/core/dist/ports/oauth-credential-store.js +37 -0
- package/node_modules/@comis/core/dist/tool-metadata.d.ts +20 -0
- package/node_modules/@comis/core/package.json +1 -1
- package/node_modules/@comis/daemon/dist/daemon-types.d.ts +23 -3
- package/node_modules/@comis/daemon/dist/daemon.js +82 -19
- package/node_modules/@comis/daemon/dist/health/watchdog.js +18 -3
- package/node_modules/@comis/daemon/dist/index.d.ts +2 -0
- package/node_modules/@comis/daemon/dist/index.js +5 -0
- package/node_modules/@comis/daemon/dist/observability/channel-health-logger.js +3 -3
- package/node_modules/@comis/daemon/dist/observability/delivery-queue-logger.js +1 -1
- package/node_modules/@comis/daemon/dist/rpc/agent-handlers.d.ts +22 -1
- package/node_modules/@comis/daemon/dist/rpc/agent-handlers.js +84 -21
- package/node_modules/@comis/daemon/dist/rpc/agent-inline-workspace.js +2 -2
- package/node_modules/@comis/daemon/dist/rpc/config-handlers.d.ts +9 -1
- package/node_modules/@comis/daemon/dist/rpc/config-handlers.js +104 -23
- package/node_modules/@comis/daemon/dist/rpc/credential-resolver.d.ts +30 -1
- package/node_modules/@comis/daemon/dist/rpc/credential-resolver.js +74 -11
- package/node_modules/@comis/daemon/dist/rpc/mcp-handlers.d.ts +8 -0
- package/node_modules/@comis/daemon/dist/rpc/mcp-handlers.js +22 -8
- package/node_modules/@comis/daemon/dist/rpc/provider-handlers.js +9 -12
- package/node_modules/@comis/daemon/dist/rpc/rpc-dispatch.d.ts +1 -0
- package/node_modules/@comis/daemon/dist/rpc/rpc-dispatch.js +27 -2
- package/node_modules/@comis/daemon/dist/setup-docker-restart-warn.js +0 -1
- package/node_modules/@comis/daemon/dist/wiring/index.d.ts +2 -0
- package/node_modules/@comis/daemon/dist/wiring/index.js +1 -0
- package/node_modules/@comis/daemon/dist/wiring/oauth-preflight.d.ts +21 -0
- package/node_modules/@comis/daemon/dist/wiring/oauth-preflight.js +134 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-agents.d.ts +46 -1
- package/node_modules/@comis/daemon/dist/wiring/setup-agents.js +127 -3
- package/node_modules/@comis/daemon/dist/wiring/setup-background-completion-runner.d.ts +39 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-background-completion-runner.js +32 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-background-tasks.d.ts +10 -3
- package/node_modules/@comis/daemon/dist/wiring/setup-background-tasks.js +11 -5
- package/node_modules/@comis/daemon/dist/wiring/setup-channels.js +20 -1
- package/node_modules/@comis/daemon/dist/wiring/setup-cross-session.js +1 -1
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery.d.ts +14 -5
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery.js +52 -19
- package/node_modules/@comis/daemon/dist/wiring/setup-schedulers.js +4 -0
- package/node_modules/@comis/daemon/package.json +1 -1
- package/node_modules/@comis/gateway/dist/index.d.ts +2 -0
- package/node_modules/@comis/gateway/dist/index.js +2 -0
- package/node_modules/@comis/gateway/dist/oauth/oauth-callback-route.d.ts +66 -0
- package/node_modules/@comis/gateway/dist/oauth/oauth-callback-route.js +212 -0
- package/node_modules/@comis/gateway/dist/server/hono-server.d.ts +14 -0
- package/node_modules/@comis/gateway/dist/server/hono-server.js +10 -0
- package/node_modules/@comis/gateway/package.json +1 -1
- package/node_modules/@comis/infra/dist/logging/log-fields.d.ts +23 -0
- package/node_modules/@comis/infra/package.json +1 -1
- package/node_modules/@comis/memory/dist/compaction.d.ts +3 -5
- package/node_modules/@comis/memory/dist/compaction.js +2 -3
- package/node_modules/@comis/memory/dist/delivery-queue-adapter.d.ts +2 -2
- package/node_modules/@comis/memory/dist/delivery-queue-adapter.js +49 -1
- package/node_modules/@comis/memory/dist/index.d.ts +2 -0
- package/node_modules/@comis/memory/dist/index.js +3 -0
- package/node_modules/@comis/memory/dist/memory-api.d.ts +1 -1
- package/node_modules/@comis/memory/dist/memory-api.js +1 -1
- package/node_modules/@comis/memory/dist/oauth-profile-schema.d.ts +17 -0
- package/node_modules/@comis/memory/dist/oauth-profile-schema.js +33 -0
- package/node_modules/@comis/memory/dist/oauth-profile-store-encrypted.d.ts +27 -0
- package/node_modules/@comis/memory/dist/oauth-profile-store-encrypted.js +144 -0
- package/node_modules/@comis/memory/dist/session-store.d.ts +1 -1
- package/node_modules/@comis/memory/dist/session-store.js +1 -1
- package/node_modules/@comis/memory/dist/sqlite-secret-store.d.ts +29 -3
- package/node_modules/@comis/memory/dist/sqlite-secret-store.js +11 -3
- package/node_modules/@comis/memory/package.json +1 -1
- package/node_modules/@comis/scheduler/dist/execution/execution-lock.d.ts +13 -0
- package/node_modules/@comis/scheduler/dist/execution/execution-lock.js +1 -1
- package/node_modules/@comis/scheduler/dist/execution/index.d.ts +2 -0
- package/node_modules/@comis/scheduler/dist/execution/index.js +2 -0
- package/node_modules/@comis/scheduler/dist/heartbeat/agent-heartbeat-source.js +1 -1
- package/node_modules/@comis/scheduler/dist/index.d.ts +2 -0
- package/node_modules/@comis/scheduler/dist/index.js +2 -0
- package/node_modules/@comis/scheduler/package.json +1 -1
- package/node_modules/@comis/shared/package.json +1 -1
- package/node_modules/@comis/skills/dist/bridge/schema-validator.d.ts +38 -0
- package/node_modules/@comis/skills/dist/bridge/schema-validator.js +169 -0
- package/node_modules/@comis/skills/dist/bridge/tool-metadata-enforcement.js +12 -0
- package/node_modules/@comis/skills/dist/bridge/tool-metadata-registry.js +130 -0
- package/node_modules/@comis/skills/dist/builtin/exec-diagnostics.d.ts +32 -0
- package/node_modules/@comis/skills/dist/builtin/exec-diagnostics.js +127 -0
- package/node_modules/@comis/skills/dist/builtin/exec-security.js +38 -0
- package/node_modules/@comis/skills/dist/builtin/exec-tool.js +9 -0
- package/node_modules/@comis/skills/dist/builtin/file-tools/grep-tool.js +6 -6
- package/node_modules/@comis/skills/dist/builtin/platform/agents-manage-tool.d.ts +5 -4
- package/node_modules/@comis/skills/dist/builtin/platform/agents-manage-tool.js +38 -27
- package/node_modules/@comis/skills/dist/builtin/platform/background-tasks-tool.d.ts +4 -1
- package/node_modules/@comis/skills/dist/builtin/platform/background-tasks-tool.js +3 -3
- package/node_modules/@comis/skills/dist/builtin/platform/cron-tool.js +1 -1
- package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.js +6 -6
- package/node_modules/@comis/skills/dist/builtin/platform/mcp-manage-tool.d.ts +1 -1
- package/node_modules/@comis/skills/dist/builtin/platform/mcp-manage-tool.js +9 -9
- package/node_modules/@comis/skills/dist/builtin/sandbox/bwrap-provider.d.ts +11 -0
- package/node_modules/@comis/skills/dist/builtin/sandbox/bwrap-provider.js +114 -1
- package/node_modules/@comis/skills/dist/builtin/sandbox/detect-provider.js +40 -15
- package/node_modules/@comis/skills/dist/media/ssrf-fetcher.d.ts +7 -0
- package/node_modules/@comis/skills/dist/media/ssrf-fetcher.js +9 -2
- package/node_modules/@comis/skills/package.json +1 -1
- package/node_modules/@comis/web/dist/assets/{agent-detail-71BSbSfD.js → agent-detail-q8t1NB7w.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{agent-editor-CTSDZhwT.js → agent-editor-B46io5gv.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{agent-list-BEhni2ea.js → agent-list-DQ6g2Rcx.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{billing-view-DVP1IvVs.js → billing-view-IWPR8LgF.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{channel-detail-N_YK74xC.js → channel-detail-DlNNZuuC.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{channel-list-DRk6ZJaF.js → channel-list-DhGwxiMc.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{chat-console-Dm-GtSf9.js → chat-console-Nv6fM3Rc.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{config-editor-CIferYX6.js → config-editor-BYKuJF76.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{context-dag-browser-CL84rXXM.js → context-dag-browser-ClNEtzYE.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{context-engine-B1HOTEZv.js → context-engine-BZJ6HChd.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{delivery-view-Y6JKYVFw.js → delivery-view-Cb7I3vGu.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{diagnostics-view-DWV1UQjz.js → diagnostics-view-9u9Lyu5a.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{ic-chat-message-DfSERzzg.js → ic-chat-message-BFt3cVpx.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{ic-connection-dot-CXyhlJup.js → ic-connection-dot-y77LZ3Gu.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{ic-tool-call-DNmwTjek.js → ic-tool-call-qt6w1NQl.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{index-CBr0Tm9_.js → index-8Tg9oc-C.js} +2 -2
- package/node_modules/@comis/web/dist/assets/{mcp-management-BaH2-vox.js → mcp-management-69dtH_kY.js} +2 -2
- package/node_modules/@comis/web/dist/assets/{media-config-CZLshJoN.js → media-config-BdjLj5c1.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{media-test-C9NUWgo_.js → media-test-DuPqrixi.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{memory-inspector-D_fmTcRN.js → memory-inspector-B-Pepbq-.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{message-center-BBFlNCZn.js → message-center-B7l0yNYY.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{models-BytGLm99.js → models-JHFHuv5S.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{observe-view-VXtHqaqq.js → observe-view-r8mqhy4O.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{pipeline-builder-CfXczlfJ.js → pipeline-builder-XjkiZRcR.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{pipeline-history-CPmXFnbe.js → pipeline-history-CZqJv_Hj.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{pipeline-history-detail-DcueTMs9.js → pipeline-history-detail-BEFGMoDy.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{pipeline-list-B-xG5WZh.js → pipeline-list-B6q5LvO1.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{pipeline-monitor-pnIOYaSY.js → pipeline-monitor-BNomXjVL.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{scheduler-BtUIFHhA.js → scheduler-BJEjcGKA.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{security-C8mWRq2y.js → security-2G1jhBfV.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{session-detail-DgdkO5ka.js → session-detail-DmVPzFBR.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{session-list-DcylcfTn.js → session-list-CsqMQoHs.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{setup-wizard-BP5yjsuL.js → setup-wizard-CAdM-gSP.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{skills-DXt1bX8Z.js → skills-2ODqKaWr.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{subagents-C7YbUHXY.js → subagents-BFlwfTbD.js} +1 -1
- package/node_modules/@comis/web/dist/assets/{workspace-manager-DP6pW4wa.js → workspace-manager--CbOx_dI.js} +1 -1
- package/node_modules/@comis/web/dist/index.html +1 -1
- package/node_modules/@comis/web/package.json +1 -1
- package/package.json +17 -16
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Cache break detection module: two-phase detection with Anthropic adapter.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Pre-call: Records prompt state via provider-specific adapter
|
|
6
6
|
* (system hash, per-tool schema hashes, cache_control metadata hash).
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Post-call: Compares cacheRead tokens against baseline using
|
|
9
9
|
* AND-based dual threshold (both >5% relative AND >2000 absolute must exceed).
|
|
10
10
|
* Provider-agnostic.
|
|
11
11
|
*
|
|
@@ -467,18 +467,18 @@ const STANDARD_ANTHROPIC_FIELDS = new Set([
|
|
|
467
467
|
"betas",
|
|
468
468
|
]);
|
|
469
469
|
/**
|
|
470
|
-
* Extract prompt state from Anthropic API payload for
|
|
470
|
+
* Extract prompt state from Anthropic API payload for pre-call recording.
|
|
471
471
|
*
|
|
472
472
|
* CRITICAL: Does NOT mutate the original params object. Creates shallow copies
|
|
473
|
-
* for hashing with cache_control stripped
|
|
474
|
-
* input_schema
|
|
473
|
+
* for hashing with cache_control stripped. Per-tool hashing uses
|
|
474
|
+
* input_schema.
|
|
475
475
|
*/
|
|
476
476
|
export function extractAnthropicPromptState(params, modelId, retention, sessionKey, agentId, headers) {
|
|
477
477
|
// Extract tools (do NOT mutate params)
|
|
478
478
|
const tools = Array.isArray(params.tools)
|
|
479
479
|
? params.tools
|
|
480
480
|
: [];
|
|
481
|
-
// Per-tool hashing using input_schema
|
|
481
|
+
// Per-tool hashing using input_schema.
|
|
482
482
|
// Skip server-side tools (tool_search_tool_regex etc.) which lack input_schema.
|
|
483
483
|
const perToolHashes = {};
|
|
484
484
|
const toolNames = [];
|
|
@@ -510,7 +510,7 @@ export function extractAnthropicPromptState(params, modelId, retention, sessionK
|
|
|
510
510
|
return rest;
|
|
511
511
|
});
|
|
512
512
|
const systemHash = computeHash(systemForHash);
|
|
513
|
-
// Hash cache_control metadata separately
|
|
513
|
+
// Hash cache_control metadata separately
|
|
514
514
|
const cacheMetadata = [
|
|
515
515
|
...tools.map((t) => t.cache_control).filter(Boolean),
|
|
516
516
|
...system.map((b) => b.cache_control).filter(Boolean),
|
|
@@ -600,7 +600,7 @@ export function extractAnthropicPromptState(params, modelId, retention, sessionK
|
|
|
600
600
|
// Gemini adapter
|
|
601
601
|
// ---------------------------------------------------------------------------
|
|
602
602
|
/**
|
|
603
|
-
* Extract Gemini-native prompt state for
|
|
603
|
+
* Extract Gemini-native prompt state for pre-call cache break detection.
|
|
604
604
|
*
|
|
605
605
|
* Gemini payload structure differs from Anthropic:
|
|
606
606
|
* - System prompt: config.systemInstruction (string, not array of blocks)
|
|
@@ -17,6 +17,7 @@ import { type ContextEngine } from "../context-engine/index.js";
|
|
|
17
17
|
import type { TokenAnchor } from "../context-engine/types.js";
|
|
18
18
|
import type { DiscoveryTracker } from "./discovery-tracker.js";
|
|
19
19
|
import type { ExecutionOverrides } from "./types.js";
|
|
20
|
+
import type { OAuthTokenManager } from "../model/oauth-token-manager.js";
|
|
20
21
|
/** Subset of PiExecutorDeps used by context engine setup. */
|
|
21
22
|
export interface ContextEngineSetupDeps {
|
|
22
23
|
logger: ComisLogger;
|
|
@@ -28,6 +29,12 @@ export interface ContextEngineSetupDeps {
|
|
|
28
29
|
getPromptSkillsXml?: () => string;
|
|
29
30
|
contextStore?: import("@comis/memory").ContextStore;
|
|
30
31
|
db?: unknown;
|
|
32
|
+
/**
|
|
33
|
+
* Optional OAuth token manager. When provided, compaction LLM
|
|
34
|
+
* calls route through resolveProviderApiKey for OAuth-eligible providers,
|
|
35
|
+
* with fallthrough to authStorage for non-OAuth providers.
|
|
36
|
+
*/
|
|
37
|
+
oauthManager?: OAuthTokenManager;
|
|
31
38
|
}
|
|
32
39
|
/** Parameters for context engine creation. */
|
|
33
40
|
export interface ContextEngineSetupParams {
|
|
@@ -80,6 +87,15 @@ export interface ContextEngineSetupResult {
|
|
|
80
87
|
contextEngine: ContextEngine;
|
|
81
88
|
/** Getter for accumulated transformContext duration in ms */
|
|
82
89
|
getContextEngineDurationMs: () => number;
|
|
90
|
+
/** Per-execute signature-replay scrub counters. `signatureScrubs`
|
|
91
|
+
* bumps once per non-empty scrubber emission; `signatureScrubsToolCallsAffected`
|
|
92
|
+
* accumulates the toolCallsAffected field across emissions. Surfaced to
|
|
93
|
+
* executor-post-execution.ts so the bookend "Execution complete" INFO log
|
|
94
|
+
* carries the per-execute total instead of the per-event INFO emissions. */
|
|
95
|
+
getSignatureScrubCounters: () => {
|
|
96
|
+
signatureScrubs: number;
|
|
97
|
+
signatureScrubsToolCallsAffected: number;
|
|
98
|
+
};
|
|
83
99
|
}
|
|
84
100
|
/**
|
|
85
101
|
* Create and wire the context engine for a single execution.
|
|
@@ -16,6 +16,7 @@ import { ContextEngineConfigSchema, safePath, } from "@comis/core";
|
|
|
16
16
|
import { createContextEngine } from "../context-engine/index.js";
|
|
17
17
|
import { CHARS_PER_TOKEN_RATIO } from "../context-engine/constants.js";
|
|
18
18
|
import { resolveOperationModel, resolveProviderFamily } from "../model/operation-model-resolver.js";
|
|
19
|
+
import { resolveProviderApiKey } from "../model/resolve-provider-api-key.js";
|
|
19
20
|
import { getBreakpointIndex, getBreakpointIndexMapSize, getSessionLatches, } from "./executor-session-state.js";
|
|
20
21
|
import { shouldDropSignedFields } from "./replay-drift-detector.js";
|
|
21
22
|
import { readFileSync } from "node:fs";
|
|
@@ -47,7 +48,7 @@ export function setupContextEngine(params) {
|
|
|
47
48
|
// consistent decision (cleaner + scrubber must agree). The closure reads
|
|
48
49
|
// the latest model identity each time (handles cycleModel mid-execute).
|
|
49
50
|
// Returns the identity/idle drift only — the kvl tool-defs dimension was
|
|
50
|
-
// removed in
|
|
51
|
+
// removed in favor of the unconditional latest-message
|
|
51
52
|
// preserving scrub in signature-replay-scrubber.
|
|
52
53
|
let memoizedDrift;
|
|
53
54
|
const computeDriftIfNeeded = () => {
|
|
@@ -85,6 +86,12 @@ export function setupContextEngine(params) {
|
|
|
85
86
|
return memoizedDrift;
|
|
86
87
|
}
|
|
87
88
|
};
|
|
89
|
+
// Per-execute counters for the signature-replay scrubber. Live
|
|
90
|
+
// for the lifetime of this setupContextEngine() call (one per execute()),
|
|
91
|
+
// so no reset is needed — the closure goes out of scope at execute end and
|
|
92
|
+
// a fresh setup creates fresh zeroed counters for the next execute.
|
|
93
|
+
let signatureScrubs = 0;
|
|
94
|
+
let signatureScrubsToolCallsAffected = 0;
|
|
88
95
|
const contextEngine = createContextEngine(contextEngineConfig, {
|
|
89
96
|
logger: deps.logger,
|
|
90
97
|
eventBus: deps.eventBus,
|
|
@@ -110,6 +117,17 @@ export function setupContextEngine(params) {
|
|
|
110
117
|
getSystemTokensEstimate: getCachedSystemTokensEstimate,
|
|
111
118
|
// G-09: Notify cache break detector when observation masking modifies content
|
|
112
119
|
onContentModified: () => cacheBreakDetector.notifyContentModification(formattedKey),
|
|
120
|
+
// Accumulate signature-replay scrub counts per-execute. Only
|
|
121
|
+
// counts emissions that actually scrubbed something (zero-touch turns
|
|
122
|
+
// are filtered out — they're not a "scrub" in the post-incident-visibility
|
|
123
|
+
// sense). Sums toolCallsAffected so the bookend "Execution complete" log
|
|
124
|
+
// carries the post-incident-visibility metric.
|
|
125
|
+
onSignatureReplayScrubbed: (stats) => {
|
|
126
|
+
if (stats.scrubbedAssistantMessages > 0) {
|
|
127
|
+
signatureScrubs++;
|
|
128
|
+
signatureScrubsToolCallsAffected += stats.toolCallsAffected;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
113
131
|
// Provide API-grounded token anchor to context engine pipeline
|
|
114
132
|
getTokenAnchor,
|
|
115
133
|
// Reset anchor when compaction replaces the message array
|
|
@@ -146,9 +164,16 @@ export function setupContextEngine(params) {
|
|
|
146
164
|
reasoning: model?.reasoning ?? false,
|
|
147
165
|
};
|
|
148
166
|
},
|
|
149
|
-
getApiKey
|
|
150
|
-
|
|
151
|
-
|
|
167
|
+
// Route compaction's primary getApiKey through the shared
|
|
168
|
+
// dispatch helper so OAuth-eligible providers refresh through
|
|
169
|
+
// OAuthTokenManager + setRuntimeApiKey on every call. Non-OAuth
|
|
170
|
+
// providers (anthropic, openai, etc.) still fall through to
|
|
171
|
+
// authStorage.getApiKey unchanged.
|
|
172
|
+
getApiKey: async () => resolveProviderApiKey(config.provider, {
|
|
173
|
+
authStorage: deps.authStorage,
|
|
174
|
+
oauthManager: deps.oauthManager,
|
|
175
|
+
agentConfig: config,
|
|
176
|
+
}),
|
|
152
177
|
// Resolve compaction model via 5-level priority chain
|
|
153
178
|
// contextEngineOverrides removed -- invocationOverride path eliminated
|
|
154
179
|
// Path 1: operationModels.compaction (operator config) -> explicit_config (Level 2)
|
|
@@ -171,7 +196,17 @@ export function setupContextEngine(params) {
|
|
|
171
196
|
return {
|
|
172
197
|
overrideModel: {
|
|
173
198
|
model: compactionModel,
|
|
174
|
-
|
|
199
|
+
// Route the override-model getApiKey through
|
|
200
|
+
// the shared dispatch helper. Each callsite passes
|
|
201
|
+
// its OWN providerId — config.provider above for the
|
|
202
|
+
// primary, compactionResolution.provider here for the
|
|
203
|
+
// override — both correctly resolve the right OAuth
|
|
204
|
+
// profile via agentConfig.oauthProfiles[providerId].
|
|
205
|
+
getApiKey: async () => resolveProviderApiKey(compactionResolution.provider, {
|
|
206
|
+
authStorage: deps.authStorage,
|
|
207
|
+
oauthManager: deps.oauthManager,
|
|
208
|
+
agentConfig: config,
|
|
209
|
+
}),
|
|
175
210
|
},
|
|
176
211
|
};
|
|
177
212
|
}
|
|
@@ -314,5 +349,11 @@ export function setupContextEngine(params) {
|
|
|
314
349
|
return {
|
|
315
350
|
contextEngine,
|
|
316
351
|
getContextEngineDurationMs: () => contextEngineDurationMs,
|
|
352
|
+
// Expose per-execute signature-replay scrub counters so the
|
|
353
|
+
// bookend "Execution complete" INFO log can roll them up.
|
|
354
|
+
getSignatureScrubCounters: () => ({
|
|
355
|
+
signatureScrubs,
|
|
356
|
+
signatureScrubsToolCallsAffected,
|
|
357
|
+
}),
|
|
317
358
|
};
|
|
318
359
|
}
|
|
@@ -59,6 +59,17 @@ export interface PostExecutionBridgeResult {
|
|
|
59
59
|
sessionCacheSavedUsd?: number;
|
|
60
60
|
/** 1.5: Thinking tokens from SDK reasoningTokens field. */
|
|
61
61
|
thinkingTokens?: number;
|
|
62
|
+
/** Number of pre-LLM-call hash-assertion walks performed (one per turn_start). */
|
|
63
|
+
hashAssertionsRan?: number;
|
|
64
|
+
/** Total cross-turn thinking-block hash mismatches surfaced across all walks. */
|
|
65
|
+
hashAssertionMismatches?: number;
|
|
66
|
+
/** Bridge-side mirror of the scrub counter (carried through buildBridgeResult
|
|
67
|
+
* for symmetry — the canonical per-execute total comes from
|
|
68
|
+
* ceSetup.getSignatureScrubCounters() since the scrubber doesn't write to
|
|
69
|
+
* bridge metrics; included on this interface so consumers reading the
|
|
70
|
+
* bridge-result shape get a coherent type). */
|
|
71
|
+
signatureScrubs?: number;
|
|
72
|
+
signatureScrubsToolCallsAffected?: number;
|
|
62
73
|
}
|
|
63
74
|
/** Bridge interface used by post-execution. */
|
|
64
75
|
export interface PostExecutionBridge {
|
|
@@ -86,6 +97,10 @@ export interface PostExecutionParams {
|
|
|
86
97
|
};
|
|
87
98
|
ceSetup: {
|
|
88
99
|
getContextEngineDurationMs(): number;
|
|
100
|
+
getSignatureScrubCounters(): {
|
|
101
|
+
signatureScrubs: number;
|
|
102
|
+
signatureScrubsToolCallsAffected: number;
|
|
103
|
+
};
|
|
89
104
|
};
|
|
90
105
|
streamSetup: {
|
|
91
106
|
capturedRetention?: {
|
|
@@ -108,6 +123,21 @@ export interface PostExecutionParams {
|
|
|
108
123
|
geminiCacheHit: boolean;
|
|
109
124
|
geminiCachedTokens: number;
|
|
110
125
|
modelTier: string | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* Provider used for this execution. Sourced from `resolvedModel.provider` in
|
|
128
|
+
* pi-executor when available; falls back to `config.provider` when the
|
|
129
|
+
* misconfig silent-fallback path triggers (resolvedModel undefined). The
|
|
130
|
+
* fallback value records operator INTENT — the actual provider chosen by
|
|
131
|
+
* pi-coding-agent's silent-fallback logic is opaque at this layer, and intent
|
|
132
|
+
* is the more useful signal for operator-side cache-hit-rate segmentation.
|
|
133
|
+
*/
|
|
134
|
+
provider: string;
|
|
135
|
+
/**
|
|
136
|
+
* Provider family derived from `resolveProviderCapabilities(provider).providerFamily`.
|
|
137
|
+
* One of "anthropic" | "openai" | "google" | "default". Pre-computed at the
|
|
138
|
+
* call site (pi-executor) so this module stays free of capability-cascade dependencies.
|
|
139
|
+
*/
|
|
140
|
+
providerFamily: string;
|
|
111
141
|
deferralResult: {
|
|
112
142
|
deferredCount: number;
|
|
113
143
|
};
|
|
@@ -139,7 +139,7 @@ export function resetPairedMemoryDedupForTests() {
|
|
|
139
139
|
* @param params - All inputs needed for post-execution cleanup
|
|
140
140
|
*/
|
|
141
141
|
export async function postExecution(params) {
|
|
142
|
-
const { result, session, sm, config, msg, sessionKey, formattedKey, agentId, executionStartMs, executionId, bridge, unsubscribe, contextEngineRef, ceSetup, streamSetup, getTruncationSummary, getTurnBudgetSummary, executionPlanRef, isOnboarding, geminiCacheHit, geminiCachedTokens, modelTier, deferralResult, mergedCustomTools, deliveredGuides, deps, sessionAdapter, executionCacheRetentionClear, adaptiveRetentionClear, } = params;
|
|
142
|
+
const { result, session, sm, config, msg, sessionKey, formattedKey, agentId, executionStartMs, executionId, bridge, unsubscribe, contextEngineRef, ceSetup, streamSetup, getTruncationSummary, getTurnBudgetSummary, executionPlanRef, isOnboarding, geminiCacheHit, geminiCachedTokens, modelTier, provider, providerFamily, deferralResult, mergedCustomTools, deliveredGuides, deps, sessionAdapter, executionCacheRetentionClear, adaptiveRetentionClear, } = params;
|
|
143
143
|
unsubscribe();
|
|
144
144
|
// Clear per-execution cache retention to prevent state leakage
|
|
145
145
|
executionCacheRetentionClear();
|
|
@@ -235,6 +235,10 @@ export async function postExecution(params) {
|
|
|
235
235
|
// Truncation summary from bouncer + turn budget summary
|
|
236
236
|
const truncSummary = getTruncationSummary();
|
|
237
237
|
const turnBudgetSummary = getTurnBudgetSummary();
|
|
238
|
+
// Snapshot the scrub counters once before composing the bookend log so both
|
|
239
|
+
// fields read from the same observation (the getter is cheap but the
|
|
240
|
+
// read-twice pattern would still be a micro-divergence risk).
|
|
241
|
+
const scrubCounters = ceSetup.getSignatureScrubCounters();
|
|
238
242
|
deps.logger.info({
|
|
239
243
|
sessionKey: formattedKey,
|
|
240
244
|
durationMs,
|
|
@@ -274,6 +278,8 @@ export async function postExecution(params) {
|
|
|
274
278
|
geminiCacheHit,
|
|
275
279
|
geminiCachedTokens,
|
|
276
280
|
modelTier,
|
|
281
|
+
provider,
|
|
282
|
+
providerFamily,
|
|
277
283
|
deferredCount: deferralResult.deferredCount,
|
|
278
284
|
activeToolCount: mergedCustomTools.length,
|
|
279
285
|
guidesDelivered: deliveredGuides.size,
|
|
@@ -282,6 +288,16 @@ export async function postExecution(params) {
|
|
|
282
288
|
toolFailureRate: (result.stepsExecuted ?? 0) > 0
|
|
283
289
|
? Math.round(((bridgeResult.failedToolCalls ?? 0) / (result.stepsExecuted ?? 0)) * 100)
|
|
284
290
|
: 0,
|
|
291
|
+
// Per-execute diagnostic counters rolled up from the two demoted log
|
|
292
|
+
// sites. Always populated (no `> 0` gate) — `0` is itself meaningful
|
|
293
|
+
// ("no scrubs/assertions this execute") and gating would lose that
|
|
294
|
+
// signal. hashAssertions* come from the bridge metrics path;
|
|
295
|
+
// signatureScrubs* come from ceSetup since the scrubber doesn't write
|
|
296
|
+
// to bridge state.
|
|
297
|
+
hashAssertionsRan: bridgeResult.hashAssertionsRan ?? 0,
|
|
298
|
+
hashAssertionMismatches: bridgeResult.hashAssertionMismatches ?? 0,
|
|
299
|
+
signatureScrubs: scrubCounters.signatureScrubs,
|
|
300
|
+
signatureScrubsToolCallsAffected: scrubCounters.signatureScrubsToolCallsAffected,
|
|
285
301
|
...(bridgeResult.failedTools && bridgeResult.failedTools.length > 0 && { failedTools: bridgeResult.failedTools }),
|
|
286
302
|
truncatedTools: truncSummary.truncatedTools,
|
|
287
303
|
totalTruncatedChars: truncSummary.totalTruncatedChars,
|
|
@@ -644,7 +644,7 @@ export async function runPrompt(params) {
|
|
|
644
644
|
// NOTE: Only evaluate bridge.getResult().textEmitted when needed to avoid
|
|
645
645
|
// incrementing mock call counters (budget tests use callCount on getResult).
|
|
646
646
|
const rawResponse = getVisibleAssistantText(session);
|
|
647
|
-
const needsRecovery = rawResponse === ""
|
|
647
|
+
const needsRecovery = rawResponse === "";
|
|
648
648
|
// Find the last user message index to bound empty-response recovery
|
|
649
649
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
650
650
|
const sessionMessages = session.messages ?? [];
|
|
@@ -42,10 +42,15 @@ export declare function scanWithOutputGuard(params: {
|
|
|
42
42
|
logger: ComisLogger;
|
|
43
43
|
}): OutputGuardScanResult;
|
|
44
44
|
/**
|
|
45
|
-
* When the final assistant message is
|
|
46
|
-
* silent token (NO_REPLY, HEARTBEAT_OK) but text was emitted in earlier
|
|
45
|
+
* When the final assistant message is empty but text was emitted in earlier
|
|
47
46
|
* turns, recover a meaningful user-visible response.
|
|
48
47
|
*
|
|
48
|
+
* Recovery fires only when `extractedResponse === ""`. Silent tokens
|
|
49
|
+
* (`NO_REPLY`, `HEARTBEAT_OK`) are explicit suppression signals and pass
|
|
50
|
+
* through unchanged — the channel-layer filter
|
|
51
|
+
* (`packages/channels/src/shared/response-filter.ts`) detects and suppresses
|
|
52
|
+
* them downstream.
|
|
53
|
+
*
|
|
49
54
|
* Two-pass strategy (gated):
|
|
50
55
|
* 1. **Tool-call synthesis** (primary) — if ≥1 prior assistant turn within the
|
|
51
56
|
* current execution window contains tool-call blocks, synthesize a
|
|
@@ -62,10 +67,6 @@ export declare function scanWithOutputGuard(params: {
|
|
|
62
67
|
* comment below) ensures the standalone walk only fires when no tool calls
|
|
63
68
|
* were observed; this keeps the pass selection mutually exclusive.
|
|
64
69
|
*
|
|
65
|
-
* Suppressed when a delivery tool (`message`, `notify`) was used — the agent
|
|
66
|
-
* already delivered content via side-channel and the silent final token is
|
|
67
|
-
* intentional.
|
|
68
|
-
*
|
|
69
70
|
* Returns the recovered text, or the original response if no recovery needed.
|
|
70
71
|
*/
|
|
71
72
|
export declare function recoverEmptyFinalResponse(params: {
|
|
@@ -84,16 +84,16 @@ export function scanWithOutputGuard(params) {
|
|
|
84
84
|
// ---------------------------------------------------------------------------
|
|
85
85
|
/** Silent tokens that indicate the final message has no visible content. */
|
|
86
86
|
const SILENT_FINAL_TOKENS = ["NO_REPLY", "HEARTBEAT_OK"];
|
|
87
|
-
/** Tool names whose successful invocation means the agent already delivered
|
|
88
|
-
* content to the user through a side-channel. When one of these tools was
|
|
89
|
-
* called during the execution, a silent final token (NO_REPLY) is intentional
|
|
90
|
-
* and recovery must be suppressed to avoid leaking internal narration. */
|
|
91
|
-
const DELIVERY_TOOL_NAMES = ["message", "notify"];
|
|
92
87
|
/**
|
|
93
|
-
* When the final assistant message is
|
|
94
|
-
* silent token (NO_REPLY, HEARTBEAT_OK) but text was emitted in earlier
|
|
88
|
+
* When the final assistant message is empty but text was emitted in earlier
|
|
95
89
|
* turns, recover a meaningful user-visible response.
|
|
96
90
|
*
|
|
91
|
+
* Recovery fires only when `extractedResponse === ""`. Silent tokens
|
|
92
|
+
* (`NO_REPLY`, `HEARTBEAT_OK`) are explicit suppression signals and pass
|
|
93
|
+
* through unchanged — the channel-layer filter
|
|
94
|
+
* (`packages/channels/src/shared/response-filter.ts`) detects and suppresses
|
|
95
|
+
* them downstream.
|
|
96
|
+
*
|
|
97
97
|
* Two-pass strategy (gated):
|
|
98
98
|
* 1. **Tool-call synthesis** (primary) — if ≥1 prior assistant turn within the
|
|
99
99
|
* current execution window contains tool-call blocks, synthesize a
|
|
@@ -110,29 +110,13 @@ const DELIVERY_TOOL_NAMES = ["message", "notify"];
|
|
|
110
110
|
* comment below) ensures the standalone walk only fires when no tool calls
|
|
111
111
|
* were observed; this keeps the pass selection mutually exclusive.
|
|
112
112
|
*
|
|
113
|
-
* Suppressed when a delivery tool (`message`, `notify`) was used — the agent
|
|
114
|
-
* already delivered content via side-channel and the silent final token is
|
|
115
|
-
* intentional.
|
|
116
|
-
*
|
|
117
113
|
* Returns the recovered text, or the original response if no recovery needed.
|
|
118
114
|
*/
|
|
119
115
|
export function recoverEmptyFinalResponse(params) {
|
|
120
116
|
const { extractedResponse, textEmitted, messages, logger, userMessageIndex } = params;
|
|
121
117
|
const lowerBound = userMessageIndex ?? 0;
|
|
122
|
-
|
|
123
|
-
if ((extractedResponse === "" || isSilentFinalToken) && textEmitted) {
|
|
118
|
+
if (extractedResponse === "" && textEmitted) {
|
|
124
119
|
if (Array.isArray(messages)) {
|
|
125
|
-
// Guard: if the agent already delivered content via a delivery tool
|
|
126
|
-
// (message, notify), the silent final token is intentional — skip
|
|
127
|
-
// recovery to avoid leaking internal narration (e.g. "Now let me
|
|
128
|
-
// generate the chart:" surfaced as a user-visible message).
|
|
129
|
-
if (isSilentFinalToken && hasDeliveryToolCall(messages, lowerBound)) {
|
|
130
|
-
logger.debug({
|
|
131
|
-
hint: "Silent final token after delivery tool call — recovery suppressed",
|
|
132
|
-
extractedResponse,
|
|
133
|
-
}, "Skipping empty-response recovery (delivery tool used)");
|
|
134
|
-
return extractedResponse;
|
|
135
|
-
}
|
|
136
120
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
137
121
|
// Collect tool-call summaries from prior assistant turns within the
|
|
138
122
|
// current execution window (lowerBound .. messages.length).
|
|
@@ -170,7 +154,7 @@ export function recoverEmptyFinalResponse(params) {
|
|
|
170
154
|
`${bullets}\n` +
|
|
171
155
|
`The work was done; the assistant did not summarize. Please ask "what did you do?" if details are needed.`;
|
|
172
156
|
logger.info({
|
|
173
|
-
|
|
157
|
+
submodule: "executor.empty-turn-recovery",
|
|
174
158
|
recoveryPass: "tool-call-synthesis",
|
|
175
159
|
toolCallCount: toolCallSummaries.length,
|
|
176
160
|
toolNames: [...toolNamesSet],
|
|
@@ -226,23 +210,6 @@ function extractVisibleText(content) {
|
|
|
226
210
|
return undefined;
|
|
227
211
|
}
|
|
228
212
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
229
|
-
/** Check whether any assistant turn (from lowerBound onward) contains a tool
|
|
230
|
-
* call to a delivery tool (message, notify). These tools send content to the
|
|
231
|
-
* user through a side-channel, so a subsequent NO_REPLY is intentional. */
|
|
232
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
233
|
-
function hasDeliveryToolCall(messages, lowerBound) {
|
|
234
|
-
for (let i = lowerBound; i < messages.length; i++) {
|
|
235
|
-
const msg = messages[i]; // eslint-disable-line security/detect-object-injection
|
|
236
|
-
if (msg?.role === "assistant" && Array.isArray(msg.content)) {
|
|
237
|
-
const hasDelivery = msg.content.some((b) => (b?.type === "toolCall" || b?.type === "tool_use") &&
|
|
238
|
-
DELIVERY_TOOL_NAMES.includes(b?.name));
|
|
239
|
-
if (hasDelivery)
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
246
213
|
/** Summarize a single tool-call content block as `toolName({primary_arg: "value"})`.
|
|
247
214
|
* Reads `name` from the block, and `input` (Anthropic native) or `arguments`
|
|
248
215
|
* (internal mapped convention) for args. Returns bare tool name on malformed
|
|
@@ -297,8 +297,7 @@ export async function assembleTools(params) {
|
|
|
297
297
|
// discovered) is the only factually-accurate set -- using mergedCustomTools
|
|
298
298
|
// (pre-deferral) would false-positive on currently-deferred tools and tell
|
|
299
299
|
// the agent "call directly, no discovery needed" for tools that aren't
|
|
300
|
-
// actually loaded.
|
|
301
|
-
// .planning/design/discover-tools-bm25-fallback-fix.md
|
|
300
|
+
// actually loaded.
|
|
302
301
|
if (deferralResult.discoverTool) {
|
|
303
302
|
const activeAfterDeferral = new Set([
|
|
304
303
|
...deferralResult.activeTools.map(t => t.name),
|
|
@@ -324,7 +323,7 @@ export async function assembleTools(params) {
|
|
|
324
323
|
}
|
|
325
324
|
// Build deferred context for dynamic preamble injection.
|
|
326
325
|
//
|
|
327
|
-
//
|
|
326
|
+
// Under Anthropic Sonnet/Opus 4.x, request-body-injector.ts
|
|
328
327
|
// strips client-side `discover_tools` from the API payload and replaces it
|
|
329
328
|
// with the server-side `tool_search_tool_regex` + per-tool `defer_loading`
|
|
330
329
|
// flag. Pass `useToolSearch=true` so the preamble teaches the model that
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Injects CachedContent name into Gemini API payloads and atomically strips
|
|
5
5
|
* the three inherited fields (systemInstruction, tools, toolConfig) to avoid
|
|
6
|
-
* double-billing. Operates inside the onPayload hook (post-buildParams)
|
|
6
|
+
* double-billing. Operates inside the onPayload hook (post-buildParams).
|
|
7
7
|
*
|
|
8
8
|
* Handles cache injection, inherited field stripping, and staleness recovery.
|
|
9
9
|
*
|
|
@@ -24,7 +24,7 @@ export interface GeminiCacheInjectorConfig {
|
|
|
24
24
|
/** Callback when a Gemini CachedContent entry is successfully injected.
|
|
25
25
|
* Called with the CacheEntry so the caller can capture cache hit stats for logging. */
|
|
26
26
|
onCacheHit?: (entry: CacheEntry) => void;
|
|
27
|
-
/** Callback for cache break detection
|
|
27
|
+
/** Callback for cache break detection.
|
|
28
28
|
* Called with the API-ready payload AFTER any cache injection. */
|
|
29
29
|
onPayloadForCacheDetection?: (params: Record<string, unknown>, model: {
|
|
30
30
|
id: string;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Injects CachedContent name into Gemini API payloads and atomically strips
|
|
6
6
|
* the three inherited fields (systemInstruction, tools, toolConfig) to avoid
|
|
7
|
-
* double-billing. Operates inside the onPayload hook (post-buildParams)
|
|
7
|
+
* double-billing. Operates inside the onPayload hook (post-buildParams).
|
|
8
8
|
*
|
|
9
9
|
* Handles cache injection, inherited field stripping, and staleness recovery.
|
|
10
10
|
*
|
|
@@ -103,7 +103,7 @@ export function createGeminiCacheInjector(config, logger) {
|
|
|
103
103
|
config.onPayloadForCacheDetection?.(resolvedParams, modelInfo);
|
|
104
104
|
return resolvedParams;
|
|
105
105
|
}
|
|
106
|
-
//
|
|
106
|
+
// Assertion -- all three fields must be present for stripping
|
|
107
107
|
if (configObj.systemInstruction === undefined ||
|
|
108
108
|
configObj.tools === undefined ||
|
|
109
109
|
configObj.toolConfig === undefined) {
|
|
@@ -112,7 +112,7 @@ export function createGeminiCacheInjector(config, logger) {
|
|
|
112
112
|
cacheName: entry.name,
|
|
113
113
|
hint: "Expected fields missing from config -- cache entry stale, evicting",
|
|
114
114
|
errorKind: "validation",
|
|
115
|
-
}, "Gemini cache injector: stale cache detected
|
|
115
|
+
}, "Gemini cache injector: stale cache detected");
|
|
116
116
|
suppressError(config.cacheManager.dispose(config.sessionKey), "stale-cache-eviction-d03");
|
|
117
117
|
config.onPayloadForCacheDetection?.(resolvedParams, modelInfo);
|
|
118
118
|
return resolvedParams;
|
|
@@ -129,7 +129,7 @@ export function createGeminiCacheInjector(config, logger) {
|
|
|
129
129
|
}, "Gemini cache injector: injected cached content");
|
|
130
130
|
// Notify caller of successful cache injection for observability
|
|
131
131
|
config.onCacheHit?.(entry);
|
|
132
|
-
//
|
|
132
|
+
// Cache break detection callback
|
|
133
133
|
config.onPayloadForCacheDetection?.(resolvedParams, modelInfo);
|
|
134
134
|
return resolvedParams;
|
|
135
135
|
},
|
|
@@ -25,13 +25,13 @@ export declare function isVisibleTextBlock(block: any): boolean;
|
|
|
25
25
|
* - cross-turn boundary (role === "user" encountered before a
|
|
26
26
|
* qualifying assistant) — return "" because the user message marks
|
|
27
27
|
* the start of the current execution window; assistants before it
|
|
28
|
-
* belong to prior turns
|
|
28
|
+
* belong to prior turns.
|
|
29
29
|
*
|
|
30
30
|
* When the resulting last assistant contains commentary-phase text
|
|
31
31
|
* blocks, drops them and returns only visible text. Otherwise returns
|
|
32
32
|
* the visible (non-commentary) text blocks of the last assistant
|
|
33
33
|
* directly — does NOT delegate to session.getLastAssistantText(),
|
|
34
34
|
* which walks past empty messages and would re-introduce the
|
|
35
|
-
* synthetic-leak
|
|
35
|
+
* synthetic-leak.
|
|
36
36
|
*/
|
|
37
37
|
export declare function getVisibleAssistantText(session: any): string;
|
|
@@ -41,21 +41,20 @@ export function isVisibleTextBlock(block) {
|
|
|
41
41
|
* - cross-turn boundary (role === "user" encountered before a
|
|
42
42
|
* qualifying assistant) — return "" because the user message marks
|
|
43
43
|
* the start of the current execution window; assistants before it
|
|
44
|
-
* belong to prior turns
|
|
44
|
+
* belong to prior turns.
|
|
45
45
|
*
|
|
46
46
|
* When the resulting last assistant contains commentary-phase text
|
|
47
47
|
* blocks, drops them and returns only visible text. Otherwise returns
|
|
48
48
|
* the visible (non-commentary) text blocks of the last assistant
|
|
49
49
|
* directly — does NOT delegate to session.getLastAssistantText(),
|
|
50
50
|
* which walks past empty messages and would re-introduce the
|
|
51
|
-
* synthetic-leak
|
|
51
|
+
* synthetic-leak.
|
|
52
52
|
*/
|
|
53
53
|
export function getVisibleAssistantText(session) {
|
|
54
54
|
const messages = session?.messages;
|
|
55
55
|
// Find last "real" assistant message in the CURRENT execution window —
|
|
56
56
|
// skip aborted-empty, error-empty, and synthetic-injected; stop at the
|
|
57
|
-
// first user message (turn boundary) to avoid leaking prior-turn text
|
|
58
|
-
// (260501-gyy).
|
|
57
|
+
// first user message (turn boundary) to avoid leaking prior-turn text.
|
|
59
58
|
const lastAssistant = (() => {
|
|
60
59
|
if (!Array.isArray(messages))
|
|
61
60
|
return undefined;
|
|
@@ -93,9 +92,8 @@ export function getVisibleAssistantText(session) {
|
|
|
93
92
|
// No commentary — return lastAssistant's visible text directly.
|
|
94
93
|
// Do NOT delegate to session.getLastAssistantText() because it walks
|
|
95
94
|
// past empty messages (aborted/error/etc.) and re-introduces the
|
|
96
|
-
// synthetic-leak (
|
|
97
|
-
//
|
|
98
|
-
// 260501-cur "Rate limit exceeded" terminal error).
|
|
95
|
+
// synthetic-leak (post-restart-resumption rate-limit returned synthetic
|
|
96
|
+
// placeholder instead of the "Rate limit exceeded" terminal error).
|
|
99
97
|
if (!lastAssistant?.content || !Array.isArray(lastAssistant.content))
|
|
100
98
|
return "";
|
|
101
99
|
return lastAssistant.content
|
|
@@ -33,6 +33,7 @@ import type { MessageSendLimiter } from "../safety/message-send-limiter.js";
|
|
|
33
33
|
import type { ProviderHealthMonitor } from "../safety/provider-health-monitor.js";
|
|
34
34
|
import type { ComisSessionManager } from "../session/comis-session-manager.js";
|
|
35
35
|
import type { AuthRotationAdapter } from "../model/auth-rotation-adapter.js";
|
|
36
|
+
import type { OAuthTokenManager } from "../model/oauth-token-manager.js";
|
|
36
37
|
import type { ActiveRunRegistry } from "./active-run-registry.js";
|
|
37
38
|
import type { GeminiCacheManager } from "./gemini-cache-manager.js";
|
|
38
39
|
import type { BackgroundTaskManager, NotifyFn } from "../background/index.js";
|
|
@@ -120,6 +121,18 @@ export interface PiExecutorDeps {
|
|
|
120
121
|
fallbackModels?: string[];
|
|
121
122
|
/** Optional auth rotation adapter for multi-key providers. */
|
|
122
123
|
authRotation?: AuthRotationAdapter;
|
|
124
|
+
/**
|
|
125
|
+
* Optional OAuth token manager. When provided, the per-LLM-call
|
|
126
|
+
* dispatch hook in execute() resolves the OAuth token via the resolver
|
|
127
|
+
* chain (agent-config -> lastGood -> first available) and sets it into
|
|
128
|
+
* authStorage's runtime override Map for pi-coding-agent's outbound LLM
|
|
129
|
+
* call.
|
|
130
|
+
*
|
|
131
|
+
* Single hook per execute() — long-running execute()s
|
|
132
|
+
* (>= 1 hour) may see token expire mid-loop; revisit if observed
|
|
133
|
+
* in production.
|
|
134
|
+
*/
|
|
135
|
+
oauthManager?: OAuthTokenManager;
|
|
123
136
|
/** Active run registry for mid-execution steering. */
|
|
124
137
|
activeRunRegistry?: ActiveRunRegistry;
|
|
125
138
|
/** Daemon-level tracing defaults for rotation. */
|