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,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Completion dispatcher: routes background_task:completed/failed events
|
|
3
|
+
* through the BackgroundSessionState machine.
|
|
4
|
+
*
|
|
5
|
+
* Subscribes to background_task:completed and background_task:failed BEFORE
|
|
6
|
+
* the existing BackgroundCompletionRunner. On each event:
|
|
7
|
+
* 1. Reads `task.dispatchState`.
|
|
8
|
+
* 2. If "pending": transitions to "notified" only when the runner cannot
|
|
9
|
+
* re-enter the originating session (no active session for the formatted
|
|
10
|
+
* key, or recursion limit reached). Otherwise transitions to "dispatched"
|
|
11
|
+
* and lets the completion-runner perform re-entry.
|
|
12
|
+
* 3. If already "notified" or "dispatched": no-op (at-most-once).
|
|
13
|
+
*
|
|
14
|
+
* The runner is wired AFTER the dispatcher in setup-background-completion-
|
|
15
|
+
* runner.ts so its handler reads the updated `task.dispatchState` and skips
|
|
16
|
+
* its own work when state is "notified" (the dispatcher already fired
|
|
17
|
+
* fallback). This single-owner contract ensures the completion runner does
|
|
18
|
+
* not double-fire user-visible notifications: the dispatcher routes via
|
|
19
|
+
* persistent state instead of an in-memory event handler, and gates on
|
|
20
|
+
* state instead of unconditionally firing.
|
|
21
|
+
*
|
|
22
|
+
* **State persistence:** every transition calls `manager.transitionDispatch
|
|
23
|
+
* State(taskId, next)` (when the manager exposes it) which mutates the
|
|
24
|
+
* in-memory task AND calls persistTaskSync. Recovery-after-SIGKILL reads
|
|
25
|
+
* the persisted state and the manager skips re-emitting completion events
|
|
26
|
+
* for already-dispatched / already-notified tasks.
|
|
27
|
+
*
|
|
28
|
+
* **Failure isolation:** each handler is wrapped in suppressError so a
|
|
29
|
+
* single dispatch's failure does not tear down the subscription
|
|
30
|
+
* (AGENTS §2.1).
|
|
31
|
+
*
|
|
32
|
+
* @module
|
|
33
|
+
*/
|
|
34
|
+
import type { TypedEventBus } from "@comis/core";
|
|
35
|
+
import type { ComisLogger } from "@comis/infra";
|
|
36
|
+
import type { BackgroundTask, BackgroundSessionState, BackgroundTaskNotificationPolicy as NotificationPolicyType } from "./background-task-types.js";
|
|
37
|
+
import type { NotifyFn } from "./background-task-manager.js";
|
|
38
|
+
/**
|
|
39
|
+
* The 3-state typed enum as a runtime array. Order matches transition order:
|
|
40
|
+
* pending → (notified | dispatched).
|
|
41
|
+
*
|
|
42
|
+
* Exported as a `readonly string[]` so tests can assert
|
|
43
|
+
* `STATES === ["pending", "notified", "dispatched"]`.
|
|
44
|
+
*/
|
|
45
|
+
export declare const STATES: readonly BackgroundSessionState[];
|
|
46
|
+
/**
|
|
47
|
+
* Notification policy as a runtime object so it round-trips through
|
|
48
|
+
* JSON.parse(JSON.stringify(...)) preserving identity. A boolean would
|
|
49
|
+
* collapse to true/false on rehydrate and lose the distinction between
|
|
50
|
+
* "deferred" / "immediate" / "silent".
|
|
51
|
+
*
|
|
52
|
+
* The typed enum is the single source of truth. This runtime object is a
|
|
53
|
+
* discoverability surface (tests, debugging, logs); production code uses
|
|
54
|
+
* the type-only `BackgroundTaskNotificationPolicy` from
|
|
55
|
+
* `background-task-types.ts`.
|
|
56
|
+
*/
|
|
57
|
+
export declare const BackgroundTaskNotificationPolicy: Record<string, NotificationPolicyType>;
|
|
58
|
+
/** Public-facing handle on the dispatcher. */
|
|
59
|
+
export interface CompletionDispatcher {
|
|
60
|
+
/** Unsubscribe from the event bus. Idempotent. Awaitable so callers can
|
|
61
|
+
* ensure no in-flight handler outlives daemon shutdown. */
|
|
62
|
+
shutdown(): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
/** Minimal session-store contract the dispatcher needs (active-session check). */
|
|
65
|
+
export interface DispatcherSessionStore {
|
|
66
|
+
loadByFormattedKey(sessionKey: string): unknown | undefined;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Minimal taskManager contract: read + (optionally) persist transitions.
|
|
70
|
+
*
|
|
71
|
+
* `transitionDispatchState` is optional so the dispatcher composes cleanly
|
|
72
|
+
* with the test fixture in completion-dispatcher.test.ts (which constructs
|
|
73
|
+
* `taskManager: { getTask: vi.fn() }` and asserts the at-most-once gate
|
|
74
|
+
* without exercising state persistence). Production wiring adds
|
|
75
|
+
* `transitionDispatchState` on the real BackgroundTaskManager so the
|
|
76
|
+
* recovery-after-SIGKILL contract is binding.
|
|
77
|
+
*/
|
|
78
|
+
export interface DispatcherTaskManager {
|
|
79
|
+
getTask(taskId: string): BackgroundTask | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Atomically transition the in-memory task's dispatchState AND persist.
|
|
82
|
+
* Returns true on success; false if task does not exist. Optional —
|
|
83
|
+
* when absent, the dispatcher routes purely via in-memory state.
|
|
84
|
+
*/
|
|
85
|
+
transitionDispatchState?(taskId: string, next: BackgroundSessionState): boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Dispatcher dependencies.
|
|
89
|
+
*
|
|
90
|
+
* Public minimum: `eventBus`, `taskManager`, `logger`. Tests use
|
|
91
|
+
* `notifyFn`; production wires both `notifyFn` and `fallbackNotifyFn`
|
|
92
|
+
* (they are aliases — the dispatcher prefers `fallbackNotifyFn` when
|
|
93
|
+
* both are provided so production callers reading the daemon wiring
|
|
94
|
+
* see the canonical name).
|
|
95
|
+
*
|
|
96
|
+
* `sessionStore` + `maxBackgroundHops` are optional. When absent, the
|
|
97
|
+
* dispatcher falls back to the safe behavior: pending → dispatched
|
|
98
|
+
* (let the runner attempt re-entry), no fallback notification fired
|
|
99
|
+
* from the dispatcher itself.
|
|
100
|
+
*/
|
|
101
|
+
export interface CompletionDispatcherDeps {
|
|
102
|
+
eventBus: TypedEventBus;
|
|
103
|
+
taskManager: DispatcherTaskManager;
|
|
104
|
+
/**
|
|
105
|
+
* User-visible notification fired when the dispatcher cannot route to
|
|
106
|
+
* the originating session. Either name accepted; `fallbackNotifyFn`
|
|
107
|
+
* preferred when both are provided.
|
|
108
|
+
*/
|
|
109
|
+
fallbackNotifyFn?: NotifyFn;
|
|
110
|
+
/** Alias for `fallbackNotifyFn` (test fixture compatibility). */
|
|
111
|
+
notifyFn?: NotifyFn;
|
|
112
|
+
/** Active-session check (production wiring). When absent, the dispatcher
|
|
113
|
+
* defers to the runner without firing fallback. */
|
|
114
|
+
sessionStore?: DispatcherSessionStore;
|
|
115
|
+
/** Recursion limit for background-task hop counting. When absent, the
|
|
116
|
+
* dispatcher does not enforce the cap (defers to the runner). */
|
|
117
|
+
maxBackgroundHops?: number;
|
|
118
|
+
logger: ComisLogger;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Wire the completion dispatcher against an event bus + task manager.
|
|
122
|
+
* Subscriptions are installed synchronously; call shutdown() to remove them.
|
|
123
|
+
*
|
|
124
|
+
* At-most-once fallback: the state-machine transitions on
|
|
125
|
+
* `task.dispatchState` are the single source of truth. The dispatcher's
|
|
126
|
+
* synchronous transitionDispatchState runs BEFORE the completion-runner's
|
|
127
|
+
* handler reads the updated state, by virtue of the event-bus subscribing
|
|
128
|
+
* the dispatcher first (see setup-background-completion-runner.ts).
|
|
129
|
+
*/
|
|
130
|
+
export declare function createCompletionDispatcher(deps: CompletionDispatcherDeps): CompletionDispatcher;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Completion dispatcher: routes background_task:completed/failed events
|
|
4
|
+
* through the BackgroundSessionState machine.
|
|
5
|
+
*
|
|
6
|
+
* Subscribes to background_task:completed and background_task:failed BEFORE
|
|
7
|
+
* the existing BackgroundCompletionRunner. On each event:
|
|
8
|
+
* 1. Reads `task.dispatchState`.
|
|
9
|
+
* 2. If "pending": transitions to "notified" only when the runner cannot
|
|
10
|
+
* re-enter the originating session (no active session for the formatted
|
|
11
|
+
* key, or recursion limit reached). Otherwise transitions to "dispatched"
|
|
12
|
+
* and lets the completion-runner perform re-entry.
|
|
13
|
+
* 3. If already "notified" or "dispatched": no-op (at-most-once).
|
|
14
|
+
*
|
|
15
|
+
* The runner is wired AFTER the dispatcher in setup-background-completion-
|
|
16
|
+
* runner.ts so its handler reads the updated `task.dispatchState` and skips
|
|
17
|
+
* its own work when state is "notified" (the dispatcher already fired
|
|
18
|
+
* fallback). This single-owner contract ensures the completion runner does
|
|
19
|
+
* not double-fire user-visible notifications: the dispatcher routes via
|
|
20
|
+
* persistent state instead of an in-memory event handler, and gates on
|
|
21
|
+
* state instead of unconditionally firing.
|
|
22
|
+
*
|
|
23
|
+
* **State persistence:** every transition calls `manager.transitionDispatch
|
|
24
|
+
* State(taskId, next)` (when the manager exposes it) which mutates the
|
|
25
|
+
* in-memory task AND calls persistTaskSync. Recovery-after-SIGKILL reads
|
|
26
|
+
* the persisted state and the manager skips re-emitting completion events
|
|
27
|
+
* for already-dispatched / already-notified tasks.
|
|
28
|
+
*
|
|
29
|
+
* **Failure isolation:** each handler is wrapped in suppressError so a
|
|
30
|
+
* single dispatch's failure does not tear down the subscription
|
|
31
|
+
* (AGENTS §2.1).
|
|
32
|
+
*
|
|
33
|
+
* @module
|
|
34
|
+
*/
|
|
35
|
+
import { suppressError } from "@comis/shared";
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// Runtime constants exported for downstream consumers (test surface + ops).
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
/**
|
|
40
|
+
* The 3-state typed enum as a runtime array. Order matches transition order:
|
|
41
|
+
* pending → (notified | dispatched).
|
|
42
|
+
*
|
|
43
|
+
* Exported as a `readonly string[]` so tests can assert
|
|
44
|
+
* `STATES === ["pending", "notified", "dispatched"]`.
|
|
45
|
+
*/
|
|
46
|
+
export const STATES = [
|
|
47
|
+
"pending",
|
|
48
|
+
"notified",
|
|
49
|
+
"dispatched",
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* Notification policy as a runtime object so it round-trips through
|
|
53
|
+
* JSON.parse(JSON.stringify(...)) preserving identity. A boolean would
|
|
54
|
+
* collapse to true/false on rehydrate and lose the distinction between
|
|
55
|
+
* "deferred" / "immediate" / "silent".
|
|
56
|
+
*
|
|
57
|
+
* The typed enum is the single source of truth. This runtime object is a
|
|
58
|
+
* discoverability surface (tests, debugging, logs); production code uses
|
|
59
|
+
* the type-only `BackgroundTaskNotificationPolicy` from
|
|
60
|
+
* `background-task-types.ts`.
|
|
61
|
+
*/
|
|
62
|
+
export const BackgroundTaskNotificationPolicy = {
|
|
63
|
+
DEFERRED: "deferred",
|
|
64
|
+
IMMEDIATE: "immediate",
|
|
65
|
+
SILENT: "silent",
|
|
66
|
+
};
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// Factory
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
/**
|
|
71
|
+
* Wire the completion dispatcher against an event bus + task manager.
|
|
72
|
+
* Subscriptions are installed synchronously; call shutdown() to remove them.
|
|
73
|
+
*
|
|
74
|
+
* At-most-once fallback: the state-machine transitions on
|
|
75
|
+
* `task.dispatchState` are the single source of truth. The dispatcher's
|
|
76
|
+
* synchronous transitionDispatchState runs BEFORE the completion-runner's
|
|
77
|
+
* handler reads the updated state, by virtue of the event-bus subscribing
|
|
78
|
+
* the dispatcher first (see setup-background-completion-runner.ts).
|
|
79
|
+
*/
|
|
80
|
+
export function createCompletionDispatcher(deps) {
|
|
81
|
+
const log = deps.logger.child({ submodule: "completion-dispatcher" });
|
|
82
|
+
const fallback = deps.fallbackNotifyFn ?? deps.notifyFn;
|
|
83
|
+
let stopped = false;
|
|
84
|
+
let inflight = Promise.resolve();
|
|
85
|
+
const onCompleted = (data) => {
|
|
86
|
+
if (stopped)
|
|
87
|
+
return;
|
|
88
|
+
const promise = handleEvent(data.taskId, "completed");
|
|
89
|
+
inflight = inflight.then(() => promise).catch(() => undefined);
|
|
90
|
+
suppressError(promise, "completion dispatcher (completed)");
|
|
91
|
+
};
|
|
92
|
+
const onFailed = (data) => {
|
|
93
|
+
if (stopped)
|
|
94
|
+
return;
|
|
95
|
+
const promise = handleEvent(data.taskId, "failed");
|
|
96
|
+
inflight = inflight.then(() => promise).catch(() => undefined);
|
|
97
|
+
suppressError(promise, "completion dispatcher (failed)");
|
|
98
|
+
};
|
|
99
|
+
deps.eventBus.on("background_task:completed", onCompleted);
|
|
100
|
+
deps.eventBus.on("background_task:failed", onFailed);
|
|
101
|
+
async function handleEvent(taskId, kind) {
|
|
102
|
+
const task = deps.taskManager.getTask(taskId);
|
|
103
|
+
if (!task) {
|
|
104
|
+
log.debug({ taskId, kind, hint: "Task disappeared from manager before dispatcher could resolve it" }, "Completion dispatcher: task not in manager");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const current = task.dispatchState ?? "pending";
|
|
108
|
+
// At-most-once: state machine is the single source of truth.
|
|
109
|
+
if (current === "notified" || current === "dispatched") {
|
|
110
|
+
log.debug({
|
|
111
|
+
taskId,
|
|
112
|
+
dispatchState: current,
|
|
113
|
+
// traceId from task.origin so dispatcher logs stay threaded with
|
|
114
|
+
// the originating request even when the dispatcher runs from a
|
|
115
|
+
// background ALS context.
|
|
116
|
+
traceId: task.origin?.traceId ?? undefined,
|
|
117
|
+
hint: "Task already dispatched/notified; no-op (at-most-once)",
|
|
118
|
+
}, "Completion dispatcher: at-most-once gate");
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// task.dispatchState === "pending". Decide which transition to make.
|
|
122
|
+
// origin is producer-required; read it directly.
|
|
123
|
+
const origin = task.origin;
|
|
124
|
+
// Hop cap (when configured). Recursion limit reached → fallback.
|
|
125
|
+
if (typeof deps.maxBackgroundHops === "number") {
|
|
126
|
+
const nextHopCount = (origin.backgroundHopCount ?? 0) + 1;
|
|
127
|
+
if (nextHopCount >= deps.maxBackgroundHops) {
|
|
128
|
+
transitionTo(taskId, "notified");
|
|
129
|
+
await fireFallback(task, `Background task "${task.toolName}" completed but follow-up was skipped — recursion limit reached. Run again or check the result manually.`);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Active-session check (when configured). No active session → fallback.
|
|
134
|
+
if (deps.sessionStore) {
|
|
135
|
+
const sessionExists = deps.sessionStore.loadByFormattedKey(origin.sessionKey) !== undefined;
|
|
136
|
+
if (!sessionExists) {
|
|
137
|
+
// The originating session is not currently registered. The
|
|
138
|
+
// completion-runner would skip re-entry (no streaming channel) —
|
|
139
|
+
// fire fallback so the user still sees a notification. The
|
|
140
|
+
// dispatcher transitions to "notified" so the runner does NOT
|
|
141
|
+
// also fire (single-owner contract).
|
|
142
|
+
transitionTo(taskId, "notified");
|
|
143
|
+
await fireFallback(task, `Background task "${task.toolName}" completed.`);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Active session exists (or sessionStore not wired): the runner will
|
|
148
|
+
// dispatch via re-entry. Transition to "dispatched" so the runner's
|
|
149
|
+
// handler — which reads task.dispatchState — sees the updated state.
|
|
150
|
+
// We do NOT fire fallback here (zero spurious outbound).
|
|
151
|
+
transitionTo(taskId, "dispatched");
|
|
152
|
+
log.debug({
|
|
153
|
+
taskId,
|
|
154
|
+
sessionKey: origin.sessionKey,
|
|
155
|
+
agentId: origin.agentId,
|
|
156
|
+
toolName: task.toolName,
|
|
157
|
+
// traceId from origin for log continuity.
|
|
158
|
+
traceId: origin.traceId ?? undefined,
|
|
159
|
+
hint: "Runner will re-enter the originating session",
|
|
160
|
+
}, "Completion dispatcher: marked dispatched");
|
|
161
|
+
}
|
|
162
|
+
function transitionTo(taskId, next) {
|
|
163
|
+
if (typeof deps.taskManager.transitionDispatchState === "function") {
|
|
164
|
+
deps.taskManager.transitionDispatchState(taskId, next);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
// No persistent transition wired — mutate the in-memory task directly so
|
|
168
|
+
// the runner (which receives the same event in the same tick) reads the
|
|
169
|
+
// updated state. Test fixtures take this branch.
|
|
170
|
+
const task = deps.taskManager.getTask(taskId);
|
|
171
|
+
if (task)
|
|
172
|
+
task.dispatchState = next;
|
|
173
|
+
}
|
|
174
|
+
async function fireFallback(task, message) {
|
|
175
|
+
if (!fallback) {
|
|
176
|
+
log.debug({
|
|
177
|
+
taskId: task.id,
|
|
178
|
+
// traceId from origin keeps log lines threaded.
|
|
179
|
+
traceId: task.origin?.traceId ?? undefined,
|
|
180
|
+
hint: "No fallbackNotifyFn wired; dispatcher cannot fire user-visible notification",
|
|
181
|
+
}, "Completion dispatcher: fallback skipped (no notifyFn)");
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
await fallback({
|
|
186
|
+
agentId: task.origin.agentId,
|
|
187
|
+
message,
|
|
188
|
+
priority: "normal",
|
|
189
|
+
origin: "background_task",
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
log.warn({
|
|
194
|
+
taskId: task.id,
|
|
195
|
+
agentId: task.origin.agentId,
|
|
196
|
+
err,
|
|
197
|
+
// traceId from origin keeps the WARN line threaded.
|
|
198
|
+
traceId: task.origin?.traceId ?? undefined,
|
|
199
|
+
hint: "fallbackNotifyFn rejected; user will not see the completion notification for this task",
|
|
200
|
+
errorKind: "internal",
|
|
201
|
+
}, "Completion dispatcher: fallbackNotifyFn rejected");
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
async shutdown() {
|
|
206
|
+
if (stopped)
|
|
207
|
+
return;
|
|
208
|
+
stopped = true;
|
|
209
|
+
deps.eventBus.off("background_task:completed", onCompleted);
|
|
210
|
+
deps.eventBus.off("background_task:failed", onFailed);
|
|
211
|
+
// Wait for any in-flight handler to settle before returning.
|
|
212
|
+
await inflight;
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background completion formatter: transforms a BackgroundTask into a
|
|
3
|
+
* tagged announcement string ready for injection into the originating
|
|
4
|
+
* agent's session as a synthetic NormalizedMessage.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the shape of packages/agent/src/spawn/narrative-caster.ts (the
|
|
7
|
+
* sub-agent announcement formatter). Simplified: no condensation levels,
|
|
8
|
+
* no metadata stats, no labels -- just a single tool result with
|
|
9
|
+
* toolName + result/error.
|
|
10
|
+
*
|
|
11
|
+
* The trailing instruction is byte-identical to TRAILING_INSTRUCTION in
|
|
12
|
+
* narrative-caster.ts so AnnouncementBatcher.stripSystemPrefix()
|
|
13
|
+
* (announcement-batcher.ts:81-85) keeps working unchanged.
|
|
14
|
+
*
|
|
15
|
+
* Pure synchronous string formatting -- no async, no LLM calls, no I/O.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
import type { BackgroundTask } from "./background-task-types.js";
|
|
20
|
+
/** Re-export so consumers (tests, completion runner) can assert byte-identity. */
|
|
21
|
+
export { TRAILING_INSTRUCTION } from "../spawn/narrative-caster.js";
|
|
22
|
+
/**
|
|
23
|
+
* Format a BackgroundTask completion or failure into a tagged announcement.
|
|
24
|
+
*
|
|
25
|
+
* Header forms:
|
|
26
|
+
* - success: `[Background Task: ${toolName}]`
|
|
27
|
+
* - failure: `[Background Task Failed: ${toolName}]`
|
|
28
|
+
*
|
|
29
|
+
* Body:
|
|
30
|
+
* - success: `task.result` (already capped at 100 KB by manager.truncateResult).
|
|
31
|
+
* - generic failure: `task.error`.
|
|
32
|
+
* - restart-recovery failure (`task.error === "Daemon restarted while task was running"`):
|
|
33
|
+
* uses the explicit recovery copy.
|
|
34
|
+
*
|
|
35
|
+
* Total-length cap: NormalizedMessageSchema.text limits at 32768 chars.
|
|
36
|
+
* If the assembled string would exceed the cap, only the body section is
|
|
37
|
+
* truncated; the header and trailing instruction are NEVER touched.
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatCompletionAnnouncement(task: BackgroundTask): string;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Background completion formatter: transforms a BackgroundTask into a
|
|
4
|
+
* tagged announcement string ready for injection into the originating
|
|
5
|
+
* agent's session as a synthetic NormalizedMessage.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors the shape of packages/agent/src/spawn/narrative-caster.ts (the
|
|
8
|
+
* sub-agent announcement formatter). Simplified: no condensation levels,
|
|
9
|
+
* no metadata stats, no labels -- just a single tool result with
|
|
10
|
+
* toolName + result/error.
|
|
11
|
+
*
|
|
12
|
+
* The trailing instruction is byte-identical to TRAILING_INSTRUCTION in
|
|
13
|
+
* narrative-caster.ts so AnnouncementBatcher.stripSystemPrefix()
|
|
14
|
+
* (announcement-batcher.ts:81-85) keeps working unchanged.
|
|
15
|
+
*
|
|
16
|
+
* Pure synchronous string formatting -- no async, no LLM calls, no I/O.
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
import { TRAILING_INSTRUCTION } from "../spawn/narrative-caster.js";
|
|
21
|
+
/** Re-export so consumers (tests, completion runner) can assert byte-identity. */
|
|
22
|
+
export { TRAILING_INSTRUCTION } from "../spawn/narrative-caster.js";
|
|
23
|
+
/** NormalizedMessageSchema.text caps at 32768 chars. Reserve headroom for header + trailing instruction. */
|
|
24
|
+
const MAX_ANNOUNCEMENT_CHARS = 32768;
|
|
25
|
+
const TRUNCATION_MARKER = "\n…[truncated]";
|
|
26
|
+
/** Recovery announcement body for tasks failed via recoverOnStartup. */
|
|
27
|
+
const RESTART_RECOVERY_BODY = "This background task was interrupted by a daemon restart. The result is unavailable; let the user know if relevant.";
|
|
28
|
+
const RESTART_RECOVERY_ERROR = "Daemon restarted while task was running";
|
|
29
|
+
/**
|
|
30
|
+
* Format a BackgroundTask completion or failure into a tagged announcement.
|
|
31
|
+
*
|
|
32
|
+
* Header forms:
|
|
33
|
+
* - success: `[Background Task: ${toolName}]`
|
|
34
|
+
* - failure: `[Background Task Failed: ${toolName}]`
|
|
35
|
+
*
|
|
36
|
+
* Body:
|
|
37
|
+
* - success: `task.result` (already capped at 100 KB by manager.truncateResult).
|
|
38
|
+
* - generic failure: `task.error`.
|
|
39
|
+
* - restart-recovery failure (`task.error === "Daemon restarted while task was running"`):
|
|
40
|
+
* uses the explicit recovery copy.
|
|
41
|
+
*
|
|
42
|
+
* Total-length cap: NormalizedMessageSchema.text limits at 32768 chars.
|
|
43
|
+
* If the assembled string would exceed the cap, only the body section is
|
|
44
|
+
* truncated; the header and trailing instruction are NEVER touched.
|
|
45
|
+
*/
|
|
46
|
+
export function formatCompletionAnnouncement(task) {
|
|
47
|
+
const isFailure = task.status === "failed" || task.status === "cancelled";
|
|
48
|
+
const headerPrefix = isFailure ? "Background Task Failed" : "Background Task";
|
|
49
|
+
const header = `[${headerPrefix}: ${task.toolName}]`;
|
|
50
|
+
let body;
|
|
51
|
+
if (isFailure) {
|
|
52
|
+
const rawError = task.error ?? "(no error message)";
|
|
53
|
+
body = rawError === RESTART_RECOVERY_ERROR ? RESTART_RECOVERY_BODY : rawError;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
body = task.result ?? "(no result)";
|
|
57
|
+
}
|
|
58
|
+
// Build assembled string: header, blank line, body, blank line, trailing instruction.
|
|
59
|
+
const sections = [];
|
|
60
|
+
sections.push(header);
|
|
61
|
+
sections.push("");
|
|
62
|
+
sections.push(body);
|
|
63
|
+
sections.push("");
|
|
64
|
+
sections.push(TRAILING_INSTRUCTION);
|
|
65
|
+
let assembled = sections.join("\n");
|
|
66
|
+
// Enforce NormalizedMessageSchema.text.max(32768). Truncate the body section
|
|
67
|
+
// ONLY if needed; header and trailing instruction are byte-identical guarantees.
|
|
68
|
+
if (assembled.length > MAX_ANNOUNCEMENT_CHARS) {
|
|
69
|
+
const headerSection = `${header}\n\n`;
|
|
70
|
+
const tailSection = `\n\n${TRAILING_INSTRUCTION}`;
|
|
71
|
+
const reservedChars = headerSection.length + tailSection.length + TRUNCATION_MARKER.length;
|
|
72
|
+
const allowedBodyChars = MAX_ANNOUNCEMENT_CHARS - reservedChars;
|
|
73
|
+
const truncatedBody = body.slice(0, Math.max(0, allowedBodyChars)) + TRUNCATION_MARKER;
|
|
74
|
+
assembled = headerSection + truncatedBody + tailSection;
|
|
75
|
+
}
|
|
76
|
+
return assembled;
|
|
77
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background completion runner: subscribes to background_task:completed and
|
|
3
|
+
* background_task:failed events from the TypedEventBus and re-enters the
|
|
4
|
+
* originating agent session with a formatted completion announcement.
|
|
5
|
+
*
|
|
6
|
+
* Per-session lock serialization is delegated to the existing session
|
|
7
|
+
* manager (ComisSessionManager.withSession in packages/agent/src/session/).
|
|
8
|
+
* The runner does NOT introduce its own queueing -- one turn per completion
|
|
9
|
+
* event, ordering follows the existing per-session lock.
|
|
10
|
+
*
|
|
11
|
+
* Recursion bound: per-task incoming hop count + 1 must stay below
|
|
12
|
+
* `maxBackgroundHops` (default 3). When the cap is hit, the runner emits
|
|
13
|
+
* the fallback notification instead of triggering executor.execute().
|
|
14
|
+
* The hop count is read from `task.origin.backgroundHopCount`
|
|
15
|
+
* (populated by the originResolver).
|
|
16
|
+
*
|
|
17
|
+
* Latency-instrumentation hook: emits `background_task:reentered`
|
|
18
|
+
* immediately before executor.execute(). Integration tests compute the delta
|
|
19
|
+
* from `background_task:completed.timestamp` to this event for SLO tracking.
|
|
20
|
+
*
|
|
21
|
+
* Failure isolation: each handler is wrapped in suppressError so a single
|
|
22
|
+
* completion's failure does not tear down the subscription (AGENTS §2.1).
|
|
23
|
+
*
|
|
24
|
+
* @module
|
|
25
|
+
*/
|
|
26
|
+
import type { TypedEventBus } from "@comis/core";
|
|
27
|
+
import type { ComisLogger } from "@comis/infra";
|
|
28
|
+
import type { AgentExecutor } from "../executor/types.js";
|
|
29
|
+
import type { BackgroundTaskManager, NotifyFn } from "./background-task-manager.js";
|
|
30
|
+
/** Public-facing handle on the runner returned by createBackgroundCompletionRunner. */
|
|
31
|
+
export interface BackgroundCompletionRunner {
|
|
32
|
+
/** Unsubscribe from the event bus. Idempotent. Awaitable so callers can
|
|
33
|
+
* ensure no in-flight handler outlives the daemon shutdown. */
|
|
34
|
+
shutdown(): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
/** Minimal session-store contract the runner needs (fallback gate). */
|
|
37
|
+
export interface RunnerSessionStore {
|
|
38
|
+
loadByFormattedKey(sessionKey: string): unknown | undefined;
|
|
39
|
+
}
|
|
40
|
+
export interface BackgroundCompletionRunnerDeps {
|
|
41
|
+
eventBus: TypedEventBus;
|
|
42
|
+
getExecutor: (agentId: string) => AgentExecutor;
|
|
43
|
+
sessionStore: RunnerSessionStore;
|
|
44
|
+
/**
|
|
45
|
+
* Includes `transitionDispatchState` in addition to `getTask`. fallbackForTask
|
|
46
|
+
* uses transitionDispatchState to persist `dispatchState = "notified"` BEFORE
|
|
47
|
+
* firing `fallbackNotifyFn`, so a daemon SIGKILL between persist and fire does
|
|
48
|
+
* NOT leak a duplicate notification on recovery (the at-most-once gate binds
|
|
49
|
+
* against on-disk state). The daemon-side wiring at
|
|
50
|
+
* setup-background-completion-runner.ts already passes a manager with
|
|
51
|
+
* both methods.
|
|
52
|
+
*/
|
|
53
|
+
taskManager: Pick<BackgroundTaskManager, "getTask" | "transitionDispatchState">;
|
|
54
|
+
fallbackNotifyFn: NotifyFn;
|
|
55
|
+
maxBackgroundHops: number;
|
|
56
|
+
logger: ComisLogger;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Wire the completion runner against an event bus + executor + session store.
|
|
60
|
+
* Subscriptions are installed synchronously; call shutdown() to remove them.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createBackgroundCompletionRunner(deps: BackgroundCompletionRunnerDeps): BackgroundCompletionRunner;
|