comisai 1.0.34 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +30 -4
- package/node_modules/@comis/agent/dist/background/background-task-manager.d.ts +22 -2
- package/node_modules/@comis/agent/dist/background/background-task-manager.js +88 -40
- package/node_modules/@comis/agent/dist/background/background-task-persistence.js +34 -4
- package/node_modules/@comis/agent/dist/background/background-task-types.d.ts +59 -3
- package/node_modules/@comis/agent/dist/background/background-task-types.js +1 -1
- package/node_modules/@comis/agent/dist/background/completion-dispatcher.d.ts +130 -0
- package/node_modules/@comis/agent/dist/background/completion-dispatcher.js +215 -0
- 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 +62 -0
- package/node_modules/@comis/agent/dist/background/completion-runner.js +234 -0
- package/node_modules/@comis/agent/dist/background/index.d.ts +10 -1
- package/node_modules/@comis/agent/dist/background/index.js +4 -0
- package/node_modules/@comis/agent/dist/background/session-resolver.d.ts +85 -0
- package/node_modules/@comis/agent/dist/background/session-resolver.js +78 -0
- package/node_modules/@comis/agent/dist/bootstrap/sections/messaging-sections.js +1 -0
- package/node_modules/@comis/agent/dist/bootstrap/sections/tool-descriptions.js +3 -3
- package/node_modules/@comis/agent/dist/bootstrap/sections/tooling-sections.d.ts +30 -2
- package/node_modules/@comis/agent/dist/bootstrap/sections/tooling-sections.js +51 -2
- package/node_modules/@comis/agent/dist/bootstrap/system-prompt-assembler.d.ts +22 -0
- package/node_modules/@comis/agent/dist/bootstrap/system-prompt-assembler.js +2 -2
- package/node_modules/@comis/agent/dist/bridge/bridge-event-handlers.d.ts +1 -5
- package/node_modules/@comis/agent/dist/bridge/bridge-event-handlers.js +2 -14
- package/node_modules/@comis/agent/dist/bridge/bridge-metrics.d.ts +43 -2
- package/node_modules/@comis/agent/dist/bridge/bridge-metrics.js +17 -2
- package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.d.ts +32 -23
- package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.js +145 -62
- 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/signature-surrogate-guard.d.ts +10 -10
- package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.js +14 -14
- package/node_modules/@comis/agent/dist/context-engine/thinking-block-cleaner.d.ts +11 -13
- package/node_modules/@comis/agent/dist/context-engine/thinking-block-cleaner.js +14 -15
- 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/capability-index-context.d.ts +72 -0
- package/node_modules/@comis/agent/dist/executor/capability-index-context.js +329 -0
- package/node_modules/@comis/agent/dist/executor/drain-helper.d.ts +122 -0
- package/node_modules/@comis/agent/dist/executor/drain-helper.js +173 -0
- package/node_modules/@comis/agent/dist/executor/error-classifier.js +2 -2
- 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 +78 -4
- package/node_modules/@comis/agent/dist/executor/executor-post-execution.js +150 -31
- package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.d.ts +7 -0
- package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.js +26 -5
- 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.d.ts +18 -1
- package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.js +20 -18
- 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/jit-guide-injector.d.ts +11 -2
- package/node_modules/@comis/agent/dist/executor/jit-guide-injector.js +16 -2
- 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 +21 -2
- package/node_modules/@comis/agent/dist/executor/pi-executor.js +96 -18
- package/node_modules/@comis/agent/dist/executor/post-batch-continuation.js +7 -7
- package/node_modules/@comis/agent/dist/executor/prompt-assembly.d.ts +9 -1
- package/node_modules/@comis/agent/dist/executor/prompt-assembly.js +15 -1
- 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 +18 -27
- package/node_modules/@comis/agent/dist/executor/tool-deferral.js +34 -43
- 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/model-registry-adapter.js +1 -1
- package/node_modules/@comis/agent/dist/model/model-scanner.js +1 -1
- 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/safety/tool-retry-breaker.d.ts +11 -1
- package/node_modules/@comis/agent/dist/safety/tool-retry-breaker.js +19 -22
- package/node_modules/@comis/agent/dist/session/comis-session-manager.d.ts +17 -3
- 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/dist/spawn/pi-mono-adapters.d.ts +1 -1
- package/node_modules/@comis/agent/dist/spawn/pi-mono-adapters.js +5 -5
- package/node_modules/@comis/agent/dist/workspace/data-env.d.ts +38 -0
- package/node_modules/@comis/agent/dist/workspace/data-env.js +56 -0
- package/node_modules/@comis/agent/dist/workspace/index.d.ts +1 -0
- package/node_modules/@comis/agent/dist/workspace/index.js +1 -0
- package/node_modules/@comis/agent/dist/workspace/templates.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/index.d.ts +1 -1
- package/node_modules/@comis/channels/dist/index.js +1 -1
- package/node_modules/@comis/channels/dist/shared/channel-manager.d.ts +9 -3
- package/node_modules/@comis/channels/dist/shared/deliver-to-channel.js +12 -10
- package/node_modules/@comis/channels/dist/shared/inbound-gate.d.ts +1 -1
- package/node_modules/@comis/channels/dist/shared/inbound-gate.js +22 -7
- package/node_modules/@comis/channels/dist/shared/inbound-pipeline.d.ts +10 -3
- package/node_modules/@comis/channels/dist/shared/inbound-route.d.ts +1 -1
- package/node_modules/@comis/channels/dist/shared/inbound-route.js +13 -2
- package/node_modules/@comis/channels/dist/shared/response-filter.d.ts +11 -24
- package/node_modules/@comis/channels/dist/shared/response-filter.js +25 -53
- 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/commands/providers.d.ts +1 -2
- package/node_modules/@comis/cli/dist/commands/providers.js +5 -6
- 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/field-metadata.js +2 -0
- package/node_modules/@comis/core/dist/config/immutable-keys.js +4 -1
- package/node_modules/@comis/core/dist/config/index.d.ts +7 -1
- package/node_modules/@comis/core/dist/config/index.js +4 -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 -792
- package/node_modules/@comis/core/dist/config/schema-agent.js +16 -1
- package/node_modules/@comis/core/dist/config/schema-approvals.d.ts +0 -14
- package/node_modules/@comis/core/dist/config/schema-auto-reply-engine.d.ts +0 -6
- package/node_modules/@comis/core/dist/config/schema-background-tasks.d.ts +1 -6
- package/node_modules/@comis/core/dist/config/schema-background-tasks.js +7 -0
- package/node_modules/@comis/core/dist/config/schema-browser.d.ts +0 -18
- package/node_modules/@comis/core/dist/config/schema-channel.d.ts +0 -158
- package/node_modules/@comis/core/dist/config/schema-coalescer.d.ts +0 -5
- package/node_modules/@comis/core/dist/config/schema-daemon.d.ts +0 -32
- package/node_modules/@comis/core/dist/config/schema-delivery.d.ts +1 -17
- package/node_modules/@comis/core/dist/config/schema-delivery.js +2 -0
- package/node_modules/@comis/core/dist/config/schema-documentation.d.ts +0 -12
- package/node_modules/@comis/core/dist/config/schema-embedding.d.ts +0 -20
- package/node_modules/@comis/core/dist/config/schema-envelope.d.ts +0 -15
- package/node_modules/@comis/core/dist/config/schema-gateway.d.ts +0 -37
- package/node_modules/@comis/core/dist/config/schema-gemini-cache.d.ts +0 -4
- package/node_modules/@comis/core/dist/config/schema-gemini-cache.js +0 -2
- package/node_modules/@comis/core/dist/config/schema-integrations.d.ts +0 -318
- package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.d.ts +0 -18
- package/node_modules/@comis/core/dist/config/schema-memory-review.d.ts +0 -7
- package/node_modules/@comis/core/dist/config/schema-memory.d.ts +0 -16
- package/node_modules/@comis/core/dist/config/schema-messages.d.ts +0 -8
- package/node_modules/@comis/core/dist/config/schema-models.d.ts +0 -15
- package/node_modules/@comis/core/dist/config/schema-notification.d.ts +0 -5
- package/node_modules/@comis/core/dist/config/schema-oauth.d.ts +18 -0
- package/node_modules/@comis/core/dist/config/schema-oauth.js +19 -0
- package/node_modules/@comis/core/dist/config/schema-observability.d.ts +0 -38
- package/node_modules/@comis/core/dist/config/schema-output-retention.d.ts +34 -0
- package/node_modules/@comis/core/dist/config/schema-output-retention.js +48 -0
- package/node_modules/@comis/core/dist/config/schema-plugins.d.ts +0 -8
- package/node_modules/@comis/core/dist/config/schema-providers.d.ts +0 -64
- package/node_modules/@comis/core/dist/config/schema-queue.d.ts +0 -58
- package/node_modules/@comis/core/dist/config/schema-response-prefix.d.ts +0 -2
- package/node_modules/@comis/core/dist/config/schema-retry.d.ts +0 -6
- package/node_modules/@comis/core/dist/config/schema-scheduler.d.ts +0 -39
- package/node_modules/@comis/core/dist/config/schema-secrets.d.ts +0 -3
- package/node_modules/@comis/core/dist/config/schema-security.d.ts +0 -18
- package/node_modules/@comis/core/dist/config/schema-send-policy.d.ts +0 -13
- package/node_modules/@comis/core/dist/config/schema-sender-trust-display.d.ts +0 -5
- package/node_modules/@comis/core/dist/config/schema-serializer.js +2 -0
- package/node_modules/@comis/core/dist/config/schema-skills.d.ts +0 -63
- package/node_modules/@comis/core/dist/config/schema-skills.js +3 -4
- package/node_modules/@comis/core/dist/config/schema-streaming.d.ts +0 -38
- package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.d.ts +0 -3
- package/node_modules/@comis/core/dist/config/schema-tooling.d.ts +87 -0
- package/node_modules/@comis/core/dist/config/schema-tooling.js +152 -0
- package/node_modules/@comis/core/dist/config/schema-verbosity.d.ts +0 -12
- package/node_modules/@comis/core/dist/config/schema-webhooks.d.ts +0 -40
- package/node_modules/@comis/core/dist/config/schema.d.ts +50 -37
- package/node_modules/@comis/core/dist/config/schema.js +9 -0
- package/node_modules/@comis/core/dist/context/context.d.ts +0 -4
- package/node_modules/@comis/core/dist/domain/approval-request.d.ts +0 -17
- package/node_modules/@comis/core/dist/domain/background-task-origin.d.ts +29 -0
- package/node_modules/@comis/core/dist/domain/background-task-origin.js +39 -0
- package/node_modules/@comis/core/dist/domain/delivery-origin.d.ts +0 -5
- package/node_modules/@comis/core/dist/domain/execution-graph.d.ts +0 -48
- package/node_modules/@comis/core/dist/domain/memory-entry.d.ts +0 -3
- package/node_modules/@comis/core/dist/domain/model-compat.d.ts +0 -4
- package/node_modules/@comis/core/dist/domain/normalized-message.d.ts +0 -15
- package/node_modules/@comis/core/dist/domain/provider-capabilities.d.ts +0 -6
- package/node_modules/@comis/core/dist/domain/rich-message.d.ts +0 -14
- package/node_modules/@comis/core/dist/domain/subagent-context-config.d.ts +0 -22
- package/node_modules/@comis/core/dist/domain/subagent-context-types.d.ts +0 -8
- package/node_modules/@comis/core/dist/event-bus/events-agent.d.ts +31 -0
- package/node_modules/@comis/core/dist/event-bus/events-infra.d.ts +76 -2
- package/node_modules/@comis/core/dist/exports/config.d.ts +2 -2
- package/node_modules/@comis/core/dist/exports/config.js +3 -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/hooks.d.ts +1 -1
- 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/channel-plugin.d.ts +0 -13
- 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 +4 -0
- package/node_modules/@comis/core/dist/ports/index.js +5 -0
- package/node_modules/@comis/core/dist/ports/no-op-tool-capability.d.ts +30 -0
- package/node_modules/@comis/core/dist/ports/no-op-tool-capability.js +47 -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/ports/tool-capability.d.ts +165 -0
- package/node_modules/@comis/core/dist/ports/tool-capability.js +15 -0
- package/node_modules/@comis/core/dist/security/audit.d.ts +0 -11
- package/node_modules/@comis/core/dist/tool-metadata.d.ts +41 -1
- package/node_modules/@comis/core/dist/tool-metadata.js +1 -1
- package/node_modules/@comis/core/package.json +1 -1
- package/node_modules/@comis/daemon/bundled-skills/skill-creator/scripts/validate-skill.py +1 -1
- package/node_modules/@comis/daemon/dist/daemon-types.d.ts +23 -3
- package/node_modules/@comis/daemon/dist/daemon.js +168 -30
- 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.d.ts +1 -1
- package/node_modules/@comis/daemon/dist/rpc/agent-inline-workspace.js +3 -3
- package/node_modules/@comis/daemon/dist/rpc/builtin-provider-guard.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/model-handlers.d.ts +1 -1
- package/node_modules/@comis/daemon/dist/rpc/model-handlers.js +2 -2
- 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/sub-agent-runner.d.ts +18 -0
- package/node_modules/@comis/daemon/dist/sub-agent-runner.js +41 -9
- package/node_modules/@comis/daemon/dist/wiring/index.d.ts +4 -0
- package/node_modules/@comis/daemon/dist/wiring/index.js +2 -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 +81 -2
- package/node_modules/@comis/daemon/dist/wiring/setup-agents.js +164 -3
- package/node_modules/@comis/daemon/dist/wiring/setup-background-completion-runner.d.ts +58 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-background-completion-runner.js +59 -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 +13 -7
- package/node_modules/@comis/daemon/dist/wiring/setup-channels.d.ts +9 -2
- package/node_modules/@comis/daemon/dist/wiring/setup-channels.js +35 -10
- package/node_modules/@comis/daemon/dist/wiring/setup-cross-session.d.ts +20 -5
- package/node_modules/@comis/daemon/dist/wiring/setup-cross-session.js +21 -16
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery.d.ts +14 -5
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery.js +65 -20
- package/node_modules/@comis/daemon/dist/wiring/setup-gateway.d.ts +4 -6
- package/node_modules/@comis/daemon/dist/wiring/setup-gateway.js +3 -5
- package/node_modules/@comis/daemon/dist/wiring/setup-heartbeat.d.ts +20 -5
- package/node_modules/@comis/daemon/dist/wiring/setup-heartbeat.js +11 -2
- package/node_modules/@comis/daemon/dist/wiring/setup-output-retention.d.ts +89 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-output-retention.js +212 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-schedulers.js +4 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-tools.d.ts +18 -4
- package/node_modules/@comis/daemon/dist/wiring/setup-tools.js +29 -10
- package/node_modules/@comis/daemon/dist/wiring/tool-capability-adapter.d.ts +75 -0
- package/node_modules/@comis/daemon/dist/wiring/tool-capability-adapter.js +253 -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/dist/webhook/webhook-endpoint.d.ts +0 -4
- 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/cron/cron-types.d.ts +0 -42
- 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.d.ts +29 -8
- package/node_modules/@comis/scheduler/dist/heartbeat/agent-heartbeat-source.js +20 -8
- 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/dist/system-events/system-event-types.d.ts +0 -3
- package/node_modules/@comis/scheduler/dist/tasks/task-types.d.ts +0 -17
- package/node_modules/@comis/scheduler/package.json +1 -1
- package/node_modules/@comis/shared/dist/index.d.ts +3 -0
- package/node_modules/@comis/shared/dist/index.js +4 -0
- package/node_modules/@comis/shared/dist/mcp-tool-name.d.ts +78 -0
- package/node_modules/@comis/shared/dist/mcp-tool-name.js +92 -0
- package/node_modules/@comis/shared/dist/silent-tokens.d.ts +38 -0
- package/node_modules/@comis/shared/dist/silent-tokens.js +51 -0
- package/node_modules/@comis/shared/dist/visible-delivery.d.ts +28 -0
- package/node_modules/@comis/shared/dist/visible-delivery.js +16 -0
- package/node_modules/@comis/shared/package.json +1 -1
- package/node_modules/@comis/skills/dist/bridge/mcp-tool-bridge.d.ts +2 -13
- package/node_modules/@comis/skills/dist/bridge/mcp-tool-bridge.js +3 -21
- 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 +133 -3
- 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.d.ts +55 -9
- package/node_modules/@comis/skills/dist/builtin/exec-tool.js +392 -19
- package/node_modules/@comis/skills/dist/builtin/file-tools/grep-tool.js +6 -6
- package/node_modules/@comis/skills/dist/builtin/install-detour.d.ts +67 -0
- package/node_modules/@comis/skills/dist/builtin/install-detour.js +342 -0
- package/node_modules/@comis/skills/dist/builtin/platform/admin-manage-factory.js +5 -5
- package/node_modules/@comis/skills/dist/builtin/platform/agents-manage-tool.d.ts +7 -6
- package/node_modules/@comis/skills/dist/builtin/platform/agents-manage-tool.js +40 -29
- 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/platform/message-tool.js +18 -0
- package/node_modules/@comis/skills/dist/builtin/platform/messaging-factory.d.ts +18 -1
- package/node_modules/@comis/skills/dist/builtin/platform/messaging-factory.js +18 -2
- package/node_modules/@comis/skills/dist/builtin/platform/models-manage-tool.js +3 -3
- package/node_modules/@comis/skills/dist/builtin/process-registry.d.ts +14 -0
- package/node_modules/@comis/skills/dist/builtin/process-tool.d.ts +24 -4
- package/node_modules/@comis/skills/dist/builtin/process-tool.js +25 -7
- 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 +123 -1
- package/node_modules/@comis/skills/dist/builtin/sandbox/detect-provider.js +40 -15
- package/node_modules/@comis/skills/dist/index.d.ts +4 -1
- package/node_modules/@comis/skills/dist/index.js +3 -1
- package/node_modules/@comis/skills/dist/manifest/capability-parser.d.ts +44 -0
- package/node_modules/@comis/skills/dist/manifest/capability-parser.js +68 -0
- package/node_modules/@comis/skills/dist/manifest/schema.d.ts +44 -37
- package/node_modules/@comis/skills/dist/manifest/schema.js +35 -0
- 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/dist/registry/discovery.d.ts +8 -0
- package/node_modules/@comis/skills/dist/registry/discovery.js +10 -3
- package/node_modules/@comis/skills/dist/registry/skill-registry.d.ts +45 -1
- package/node_modules/@comis/skills/dist/registry/skill-registry.js +70 -7
- 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 +25 -24
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline-consumption drain seams.
|
|
3
|
+
*
|
|
4
|
+
* The drain trigger lives at the BRIDGE call site (`tool_execution_end` for
|
|
5
|
+
* `message` send/reply/attach) -- NOT in pi-executor.ts. The helpers in
|
|
6
|
+
* this module are what the bridge invokes:
|
|
7
|
+
*
|
|
8
|
+
* - markRead(key): mark inbound messages for the composite key as read.
|
|
9
|
+
* Reads tool context via `tryGetContext()` so the
|
|
10
|
+
* function does NOT take a passed-in deps object.
|
|
11
|
+
* No-op outside an AsyncLocalStorage scope.
|
|
12
|
+
*
|
|
13
|
+
* - markConsumed(key): mark inbound messages for the composite key as
|
|
14
|
+
* consumed by the agent's response. Same context
|
|
15
|
+
* contract as markRead.
|
|
16
|
+
*
|
|
17
|
+
* - drainAt(key): orchestrator. Runs markRead + markConsumed under
|
|
18
|
+
* a per-composite-key single-tick inflight gate
|
|
19
|
+
* (`drainInflightByKey: Map<string, Promise<void>>`).
|
|
20
|
+
* Concurrent calls for the same composite key
|
|
21
|
+
* return immediately; concurrent calls for
|
|
22
|
+
* DIFFERENT composite keys (different agentId /
|
|
23
|
+
* channelType / channelId) drain independently.
|
|
24
|
+
* Failures are non-fatal: suppressError +
|
|
25
|
+
* structured WARN log. The drainInflightByKey state
|
|
26
|
+
* is owned by the bridge (BridgeMetricsState) so
|
|
27
|
+
* the bridge threads it into drainAt at each call
|
|
28
|
+
* site.
|
|
29
|
+
*
|
|
30
|
+
* The actual inline-consumption queue does not exist as a concrete data
|
|
31
|
+
* structure today -- this module provides the structural seam. Future
|
|
32
|
+
* work plugs queue/state into `tryGetContext()` so markRead / markConsumed
|
|
33
|
+
* read it without re-threading through every caller. Today the helpers
|
|
34
|
+
* are observability-only stubs that log at DEBUG when context is present
|
|
35
|
+
* and fall through silently when outside any request scope.
|
|
36
|
+
*
|
|
37
|
+
* This module lives in `packages/agent/src/executor/` (not in the bridge)
|
|
38
|
+
* so executor-post-execution.ts can re-export the helpers for source-grep
|
|
39
|
+
* tests, while the bridge imports from here directly. This avoids a
|
|
40
|
+
* circular import (executor-post-execution -> pi-executor -> bridge ->
|
|
41
|
+
* executor-post-execution).
|
|
42
|
+
*
|
|
43
|
+
* @module
|
|
44
|
+
*/
|
|
45
|
+
import type { ComisLogger } from "@comis/infra";
|
|
46
|
+
/**
|
|
47
|
+
* Composite drain key uniquely identifies the inline-consumption queue
|
|
48
|
+
* partition for a single (agent, channel, channel-id) triple.
|
|
49
|
+
*
|
|
50
|
+
* Same shape as `BackgroundSessionResolver.ActiveSessionKey` so a single
|
|
51
|
+
* triple is reusable across the bridge / resolver / drain surface.
|
|
52
|
+
*/
|
|
53
|
+
export interface DrainKey {
|
|
54
|
+
agentId: string;
|
|
55
|
+
channelType: string;
|
|
56
|
+
channelId: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* State container for the per-composite-key drain inflight gate.
|
|
60
|
+
*
|
|
61
|
+
* Owned by the bridge (`BridgeMetricsState.drainInflightByKey`) and
|
|
62
|
+
* threaded into `drainAt` at each call site. A `Map` (rather than a single
|
|
63
|
+
* `drainInflight: Promise`) is required so concurrent drains for DIFFERENT
|
|
64
|
+
* composite keys can run independently (multi-agent isolation).
|
|
65
|
+
*/
|
|
66
|
+
export interface DrainInflightState {
|
|
67
|
+
drainInflightByKey: Map<string, Promise<void>>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Format a composite drain key into a deterministic string used as the
|
|
71
|
+
* inflight-gate Map key. Mirrors the resolver's composite-key shape so the
|
|
72
|
+
* gate keys are interchangeable with resolver keys (no parallel formatting
|
|
73
|
+
* surfaces to drift).
|
|
74
|
+
*/
|
|
75
|
+
export declare function formatDrainKey(key: DrainKey): string;
|
|
76
|
+
/**
|
|
77
|
+
* Mark inbound messages for the composite drain key as read.
|
|
78
|
+
*
|
|
79
|
+
* Reads tool context via `tryGetContext()` -- when called outside any
|
|
80
|
+
* AsyncLocalStorage scope (test fixture, sub-agent path), this is a silent
|
|
81
|
+
* no-op. Otherwise emits a DEBUG-level observability log so operators can
|
|
82
|
+
* correlate drain activity with ALS context propagation.
|
|
83
|
+
*
|
|
84
|
+
* @param key - Composite drain key (agentId, channelType, channelId).
|
|
85
|
+
* @param logger - Logger for the (rare) DEBUG observability path.
|
|
86
|
+
*/
|
|
87
|
+
export declare function markRead(key: DrainKey, logger: ComisLogger): void;
|
|
88
|
+
/**
|
|
89
|
+
* Mark inbound messages for the composite drain key as consumed.
|
|
90
|
+
*
|
|
91
|
+
* Same context contract as `markRead`. No-op outside AsyncLocalStorage
|
|
92
|
+
* scope.
|
|
93
|
+
*
|
|
94
|
+
* @param key - Composite drain key (agentId, channelType, channelId).
|
|
95
|
+
* @param logger - Logger for the (rare) DEBUG observability path.
|
|
96
|
+
*/
|
|
97
|
+
export declare function markConsumed(key: DrainKey, logger: ComisLogger): void;
|
|
98
|
+
/**
|
|
99
|
+
* drainAt: composite-keyed inline-consumption drain with single-tick gate.
|
|
100
|
+
*
|
|
101
|
+
* Invoked by the bridge on `tool_execution_end` for successful
|
|
102
|
+
* `message(send|reply|attach)` calls. Runs `markRead` + `markConsumed`
|
|
103
|
+
* under a per-composite-key inflight gate so:
|
|
104
|
+
* - Concurrent drains for the SAME composite key return immediately
|
|
105
|
+
* (lock-safe drain).
|
|
106
|
+
* - Concurrent drains for DIFFERENT composite keys (different
|
|
107
|
+
* agentId / channelType / channelId) run independently (multi-agent
|
|
108
|
+
* isolation).
|
|
109
|
+
*
|
|
110
|
+
* Failures are non-fatal: a per-event `.catch(...)` logs WARN with `hint`
|
|
111
|
+
* + `errorKind`, and the outer `suppressError` ensures the bridge's
|
|
112
|
+
* `tool_execution_end` propagation is never aborted by drain misbehavior.
|
|
113
|
+
*
|
|
114
|
+
* Map-entry cleanup (`.delete(formatted)` in `.finally(...)`) is required
|
|
115
|
+
* to prevent unbounded growth across long-running sessions; the entry is
|
|
116
|
+
* removed within one event-loop tick of the drain promise settling.
|
|
117
|
+
*
|
|
118
|
+
* @param key - Composite drain key (agentId, channelType, channelId).
|
|
119
|
+
* @param state - Bridge-owned inflight-gate Map (drainInflightByKey).
|
|
120
|
+
* @param logger - Logger for the WARN failure log + DEBUG observability.
|
|
121
|
+
*/
|
|
122
|
+
export declare function drainAt(key: DrainKey, state: DrainInflightState, logger: ComisLogger): void;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Inline-consumption drain seams.
|
|
4
|
+
*
|
|
5
|
+
* The drain trigger lives at the BRIDGE call site (`tool_execution_end` for
|
|
6
|
+
* `message` send/reply/attach) -- NOT in pi-executor.ts. The helpers in
|
|
7
|
+
* this module are what the bridge invokes:
|
|
8
|
+
*
|
|
9
|
+
* - markRead(key): mark inbound messages for the composite key as read.
|
|
10
|
+
* Reads tool context via `tryGetContext()` so the
|
|
11
|
+
* function does NOT take a passed-in deps object.
|
|
12
|
+
* No-op outside an AsyncLocalStorage scope.
|
|
13
|
+
*
|
|
14
|
+
* - markConsumed(key): mark inbound messages for the composite key as
|
|
15
|
+
* consumed by the agent's response. Same context
|
|
16
|
+
* contract as markRead.
|
|
17
|
+
*
|
|
18
|
+
* - drainAt(key): orchestrator. Runs markRead + markConsumed under
|
|
19
|
+
* a per-composite-key single-tick inflight gate
|
|
20
|
+
* (`drainInflightByKey: Map<string, Promise<void>>`).
|
|
21
|
+
* Concurrent calls for the same composite key
|
|
22
|
+
* return immediately; concurrent calls for
|
|
23
|
+
* DIFFERENT composite keys (different agentId /
|
|
24
|
+
* channelType / channelId) drain independently.
|
|
25
|
+
* Failures are non-fatal: suppressError +
|
|
26
|
+
* structured WARN log. The drainInflightByKey state
|
|
27
|
+
* is owned by the bridge (BridgeMetricsState) so
|
|
28
|
+
* the bridge threads it into drainAt at each call
|
|
29
|
+
* site.
|
|
30
|
+
*
|
|
31
|
+
* The actual inline-consumption queue does not exist as a concrete data
|
|
32
|
+
* structure today -- this module provides the structural seam. Future
|
|
33
|
+
* work plugs queue/state into `tryGetContext()` so markRead / markConsumed
|
|
34
|
+
* read it without re-threading through every caller. Today the helpers
|
|
35
|
+
* are observability-only stubs that log at DEBUG when context is present
|
|
36
|
+
* and fall through silently when outside any request scope.
|
|
37
|
+
*
|
|
38
|
+
* This module lives in `packages/agent/src/executor/` (not in the bridge)
|
|
39
|
+
* so executor-post-execution.ts can re-export the helpers for source-grep
|
|
40
|
+
* tests, while the bridge imports from here directly. This avoids a
|
|
41
|
+
* circular import (executor-post-execution -> pi-executor -> bridge ->
|
|
42
|
+
* executor-post-execution).
|
|
43
|
+
*
|
|
44
|
+
* @module
|
|
45
|
+
*/
|
|
46
|
+
import { tryGetContext } from "@comis/core";
|
|
47
|
+
import { suppressError } from "@comis/shared";
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Helpers
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
/**
|
|
52
|
+
* Format a composite drain key into a deterministic string used as the
|
|
53
|
+
* inflight-gate Map key. Mirrors the resolver's composite-key shape so the
|
|
54
|
+
* gate keys are interchangeable with resolver keys (no parallel formatting
|
|
55
|
+
* surfaces to drift).
|
|
56
|
+
*/
|
|
57
|
+
export function formatDrainKey(key) {
|
|
58
|
+
return `${key.agentId}:${key.channelType}:${key.channelId}`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Mark inbound messages for the composite drain key as read.
|
|
62
|
+
*
|
|
63
|
+
* Reads tool context via `tryGetContext()` -- when called outside any
|
|
64
|
+
* AsyncLocalStorage scope (test fixture, sub-agent path), this is a silent
|
|
65
|
+
* no-op. Otherwise emits a DEBUG-level observability log so operators can
|
|
66
|
+
* correlate drain activity with ALS context propagation.
|
|
67
|
+
*
|
|
68
|
+
* @param key - Composite drain key (agentId, channelType, channelId).
|
|
69
|
+
* @param logger - Logger for the (rare) DEBUG observability path.
|
|
70
|
+
*/
|
|
71
|
+
export function markRead(key, logger) {
|
|
72
|
+
const ctx = tryGetContext();
|
|
73
|
+
if (!ctx) {
|
|
74
|
+
// No AsyncLocalStorage scope: markRead is a no-op outside a request-
|
|
75
|
+
// scoped context. The bridge's `drainAt` is invoked from inside the
|
|
76
|
+
// request scope, but tests / sub-agent paths may invoke directly.
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// Future: read the inline-consumption queue partition for `key` from
|
|
80
|
+
// `ctx` and flip status. Today: structural seam + observability.
|
|
81
|
+
logger.debug({
|
|
82
|
+
submodule: "drain.markRead",
|
|
83
|
+
agentId: key.agentId,
|
|
84
|
+
channelType: key.channelType,
|
|
85
|
+
channelId: key.channelId,
|
|
86
|
+
traceId: ctx.traceId,
|
|
87
|
+
}, "markRead");
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Mark inbound messages for the composite drain key as consumed.
|
|
91
|
+
*
|
|
92
|
+
* Same context contract as `markRead`. No-op outside AsyncLocalStorage
|
|
93
|
+
* scope.
|
|
94
|
+
*
|
|
95
|
+
* @param key - Composite drain key (agentId, channelType, channelId).
|
|
96
|
+
* @param logger - Logger for the (rare) DEBUG observability path.
|
|
97
|
+
*/
|
|
98
|
+
export function markConsumed(key, logger) {
|
|
99
|
+
const ctx = tryGetContext();
|
|
100
|
+
if (!ctx) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
logger.debug({
|
|
104
|
+
submodule: "drain.markConsumed",
|
|
105
|
+
agentId: key.agentId,
|
|
106
|
+
channelType: key.channelType,
|
|
107
|
+
channelId: key.channelId,
|
|
108
|
+
traceId: ctx.traceId,
|
|
109
|
+
}, "markConsumed");
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Run a single drain pass for the composite key.
|
|
113
|
+
*
|
|
114
|
+
* Calls `markRead` + `markConsumed` sequentially. Both helpers no-op
|
|
115
|
+
* outside an AsyncLocalStorage scope, so this function is safe to invoke
|
|
116
|
+
* from the bridge's event handler without wrapping in `runWithContext`.
|
|
117
|
+
*/
|
|
118
|
+
async function runOneDrainPass(key, logger) {
|
|
119
|
+
markRead(key, logger);
|
|
120
|
+
markConsumed(key, logger);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* drainAt: composite-keyed inline-consumption drain with single-tick gate.
|
|
124
|
+
*
|
|
125
|
+
* Invoked by the bridge on `tool_execution_end` for successful
|
|
126
|
+
* `message(send|reply|attach)` calls. Runs `markRead` + `markConsumed`
|
|
127
|
+
* under a per-composite-key inflight gate so:
|
|
128
|
+
* - Concurrent drains for the SAME composite key return immediately
|
|
129
|
+
* (lock-safe drain).
|
|
130
|
+
* - Concurrent drains for DIFFERENT composite keys (different
|
|
131
|
+
* agentId / channelType / channelId) run independently (multi-agent
|
|
132
|
+
* isolation).
|
|
133
|
+
*
|
|
134
|
+
* Failures are non-fatal: a per-event `.catch(...)` logs WARN with `hint`
|
|
135
|
+
* + `errorKind`, and the outer `suppressError` ensures the bridge's
|
|
136
|
+
* `tool_execution_end` propagation is never aborted by drain misbehavior.
|
|
137
|
+
*
|
|
138
|
+
* Map-entry cleanup (`.delete(formatted)` in `.finally(...)`) is required
|
|
139
|
+
* to prevent unbounded growth across long-running sessions; the entry is
|
|
140
|
+
* removed within one event-loop tick of the drain promise settling.
|
|
141
|
+
*
|
|
142
|
+
* @param key - Composite drain key (agentId, channelType, channelId).
|
|
143
|
+
* @param state - Bridge-owned inflight-gate Map (drainInflightByKey).
|
|
144
|
+
* @param logger - Logger for the WARN failure log + DEBUG observability.
|
|
145
|
+
*/
|
|
146
|
+
export function drainAt(key, state, logger) {
|
|
147
|
+
const formatted = formatDrainKey(key);
|
|
148
|
+
if (state.drainInflightByKey.has(formatted)) {
|
|
149
|
+
// Single-tick gate: a drain is already in flight for this composite
|
|
150
|
+
// key; second concurrent call returns immediately.
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const draining = runOneDrainPass(key, logger)
|
|
154
|
+
.catch((err) => {
|
|
155
|
+
logger.warn({
|
|
156
|
+
submodule: "drain.drainAt",
|
|
157
|
+
agentId: key.agentId,
|
|
158
|
+
channelType: key.channelType,
|
|
159
|
+
channelId: key.channelId,
|
|
160
|
+
err,
|
|
161
|
+
hint: "drainAt failed; will retry on next tool_execution_end. Investigate when this fires repeatedly without recovery.",
|
|
162
|
+
errorKind: "internal",
|
|
163
|
+
}, "drainAt failed");
|
|
164
|
+
})
|
|
165
|
+
.finally(() => {
|
|
166
|
+
state.drainInflightByKey.delete(formatted);
|
|
167
|
+
});
|
|
168
|
+
state.drainInflightByKey.set(formatted, draining);
|
|
169
|
+
// Belt-and-braces: outer suppressError ensures the bridge's
|
|
170
|
+
// tool_execution_end propagation is NEVER aborted by drain misbehavior
|
|
171
|
+
// (fire-and-forget contract).
|
|
172
|
+
suppressError(draining, "drain at bridge call site (B15)");
|
|
173
|
+
}
|
|
@@ -13,9 +13,9 @@ import { isSignedReplayError } from "./signed-replay-detector.js";
|
|
|
13
13
|
const ERROR_PATTERNS = [
|
|
14
14
|
// Billing / credits
|
|
15
15
|
{
|
|
16
|
-
test: /credit balance is too low|billing|purchase credits|insufficient.?funds|payment.?required/i,
|
|
16
|
+
test: /credit balance is too low|billing|purchase credits|insufficient.?funds|payment.?required|usage.?limits?|regain.?access|spend.?(cap|limit)/i,
|
|
17
17
|
category: "credit_exhausted",
|
|
18
|
-
userMessage: "The AI service is currently unavailable due to a billing issue. Please notify the system administrator.",
|
|
18
|
+
userMessage: "The AI service is currently unavailable due to a billing or usage-cap issue. Please notify the system administrator.",
|
|
19
19
|
retryable: false,
|
|
20
20
|
},
|
|
21
21
|
// Rate limiting (429)
|
|
@@ -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
|
}
|
|
@@ -16,8 +16,9 @@ import type { AgentSession } from "@mariozechner/pi-coding-agent";
|
|
|
16
16
|
import type { CacheRetention } from "@mariozechner/pi-ai";
|
|
17
17
|
import { type SessionKey, type NormalizedMessage, type PerAgentConfig, type TypedEventBus, type MemoryPort } from "@comis/core";
|
|
18
18
|
import type { ComisLogger } from "@comis/infra";
|
|
19
|
+
import { drainAt, markRead, markConsumed, formatDrainKey, type DrainKey, type DrainInflightState } from "./drain-helper.js";
|
|
19
20
|
import type { ActiveRunRegistry } from "./active-run-registry.js";
|
|
20
|
-
import type { ComisSessionManager } from "../session/comis-session-manager.js";
|
|
21
|
+
import type { ComisSessionManager, SessionMetadata } from "../session/comis-session-manager.js";
|
|
21
22
|
import type { ExecutionResult, ExecutionOverrides } from "./types.js";
|
|
22
23
|
import type { ExecutionPlan } from "../planner/types.js";
|
|
23
24
|
import type { ContextEngine } from "../context-engine/index.js";
|
|
@@ -53,16 +54,40 @@ export interface PostExecutionBridgeResult {
|
|
|
53
54
|
cacheWrite5mTokens?: number;
|
|
54
55
|
/** Estimated 1h TTL cache write tokens from TTL split data. */
|
|
55
56
|
cacheWrite1hTokens?: number;
|
|
56
|
-
/**
|
|
57
|
+
/** Session-cumulative total cost across all turns (USD). */
|
|
57
58
|
sessionCostUsd?: number;
|
|
58
|
-
/**
|
|
59
|
+
/** Session-cumulative cache savings across all turns (USD). */
|
|
59
60
|
sessionCacheSavedUsd?: number;
|
|
60
|
-
/**
|
|
61
|
+
/** Thinking tokens from SDK reasoningTokens field. */
|
|
61
62
|
thinkingTokens?: number;
|
|
63
|
+
/** Number of pre-LLM-call hash-assertion walks performed (one per turn_start). */
|
|
64
|
+
hashAssertionsRan?: number;
|
|
65
|
+
/** Total cross-turn thinking-block hash mismatches surfaced across all walks. */
|
|
66
|
+
hashAssertionMismatches?: number;
|
|
67
|
+
/** Bridge-side mirror of the scrub counter (carried through buildBridgeResult
|
|
68
|
+
* for symmetry — the canonical per-execute total comes from
|
|
69
|
+
* ceSetup.getSignatureScrubCounters() since the scrubber doesn't write to
|
|
70
|
+
* bridge metrics; included on this interface so consumers reading the
|
|
71
|
+
* bridge-result shape get a coherent type). */
|
|
72
|
+
signatureScrubs?: number;
|
|
73
|
+
signatureScrubsToolCallsAffected?: number;
|
|
62
74
|
}
|
|
63
75
|
/** Bridge interface used by post-execution. */
|
|
64
76
|
export interface PostExecutionBridge {
|
|
65
77
|
getResult(): PostExecutionBridgeResult;
|
|
78
|
+
/**
|
|
79
|
+
* Expose the bridge-owned drain inflight gate so postExecution can fire
|
|
80
|
+
* an end-of-turn backstop `drainAt(...)`. The bridge already drains on
|
|
81
|
+
* `tool_execution_end` for `message` actions (inline-consumption); the
|
|
82
|
+
* end-of-turn backstop closes the residual race for turns that never
|
|
83
|
+
* invoked the `message` tool but still need the inline-consumption
|
|
84
|
+
* queue flipped (NO_REPLY-only turns, sentinel passes, etc.).
|
|
85
|
+
*
|
|
86
|
+
* Both call sites share the SAME composite key gate map so concurrent
|
|
87
|
+
* drains for the same `(agentId, channelType, channelId)` triple
|
|
88
|
+
* collapse to a single in-flight Promise.
|
|
89
|
+
*/
|
|
90
|
+
getDrainState(): DrainInflightState;
|
|
66
91
|
}
|
|
67
92
|
/** Parameters for postExecution(). */
|
|
68
93
|
export interface PostExecutionParams {
|
|
@@ -75,6 +100,9 @@ export interface PostExecutionParams {
|
|
|
75
100
|
msg: NormalizedMessage;
|
|
76
101
|
sessionKey: SessionKey;
|
|
77
102
|
formattedKey: string;
|
|
103
|
+
/** Resolver-aligned key for activeRunRegistry.deregister. Must match the
|
|
104
|
+
* formula used at the corresponding register call site. */
|
|
105
|
+
resolverRegisterKey: string;
|
|
78
106
|
agentId: string | undefined;
|
|
79
107
|
executionStartMs: number;
|
|
80
108
|
executionId: string;
|
|
@@ -86,6 +114,10 @@ export interface PostExecutionParams {
|
|
|
86
114
|
};
|
|
87
115
|
ceSetup: {
|
|
88
116
|
getContextEngineDurationMs(): number;
|
|
117
|
+
getSignatureScrubCounters(): {
|
|
118
|
+
signatureScrubs: number;
|
|
119
|
+
signatureScrubsToolCallsAffected: number;
|
|
120
|
+
};
|
|
89
121
|
};
|
|
90
122
|
streamSetup: {
|
|
91
123
|
capturedRetention?: {
|
|
@@ -108,6 +140,21 @@ export interface PostExecutionParams {
|
|
|
108
140
|
geminiCacheHit: boolean;
|
|
109
141
|
geminiCachedTokens: number;
|
|
110
142
|
modelTier: string | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* Provider used for this execution. Sourced from `resolvedModel.provider` in
|
|
145
|
+
* pi-executor when available; falls back to `config.provider` when the
|
|
146
|
+
* misconfig silent-fallback path triggers (resolvedModel undefined). The
|
|
147
|
+
* fallback value records operator INTENT — the actual provider chosen by
|
|
148
|
+
* pi-coding-agent's silent-fallback logic is opaque at this layer, and intent
|
|
149
|
+
* is the more useful signal for operator-side cache-hit-rate segmentation.
|
|
150
|
+
*/
|
|
151
|
+
provider: string;
|
|
152
|
+
/**
|
|
153
|
+
* Provider family derived from `resolveProviderCapabilities(provider).providerFamily`.
|
|
154
|
+
* One of "anthropic" | "openai" | "google" | "default". Pre-computed at the
|
|
155
|
+
* call site (pi-executor) so this module stays free of capability-cascade dependencies.
|
|
156
|
+
*/
|
|
157
|
+
providerFamily: string;
|
|
111
158
|
deferralResult: {
|
|
112
159
|
deferredCount: number;
|
|
113
160
|
};
|
|
@@ -152,6 +199,33 @@ export declare function shouldStorePairedMemory(userText: string, agentResponse:
|
|
|
152
199
|
export declare function isDuplicatePairedMemory(content: string, agentId: string): boolean;
|
|
153
200
|
/** Reset the paired-memory dedup cache. Exported for unit tests. */
|
|
154
201
|
export declare function resetPairedMemoryDedupForTests(): void;
|
|
202
|
+
/**
|
|
203
|
+
* Build the SessionMetadata payload written to `_session-metadata.json` at the
|
|
204
|
+
* end of an execution.
|
|
205
|
+
*
|
|
206
|
+
* `traceId` and `runId` are deliberately distinct:
|
|
207
|
+
* - `traceId` is the request-scope AsyncLocalStorage value set by
|
|
208
|
+
* `runWithContext` at the channel boundary (execution-execute.ts) and injected
|
|
209
|
+
* into every daemon log line by the Pino tracing mixin. Operators grep
|
|
210
|
+
* daemon.log for this exact value. Pass `tryGetContext()?.traceId` here.
|
|
211
|
+
* - `runId` is the executor-scope UUID minted in pi-executor.ts per
|
|
212
|
+
* `executor.execute()` call. It keys cost-tracker / token_usage rows.
|
|
213
|
+
*
|
|
214
|
+
* They happen to be 1:1 in the steady-state interactive path (one inbound
|
|
215
|
+
* message → one execution), but the schema treats them as distinct because
|
|
216
|
+
* heartbeat / sub-agent paths can fan out one trace into multiple executions.
|
|
217
|
+
*
|
|
218
|
+
* Pure: no I/O, no side effects. The fire-and-forget try/catch around
|
|
219
|
+
* `writeSessionMetadata` lives at the call site.
|
|
220
|
+
*/
|
|
221
|
+
export declare function buildSessionEndMetadata(args: {
|
|
222
|
+
finishReason: string;
|
|
223
|
+
durationMs: number;
|
|
224
|
+
totalTokens: number;
|
|
225
|
+
executionId: string;
|
|
226
|
+
traceId: string | undefined;
|
|
227
|
+
}): SessionMetadata;
|
|
228
|
+
export { drainAt, markRead, markConsumed, formatDrainKey, type DrainKey, type DrainInflightState, };
|
|
155
229
|
/**
|
|
156
230
|
* Run post-execution cleanup for a PiExecutor turn.
|
|
157
231
|
*
|