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,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encrypted SQLite-backed OAuthCredentialStorePort adapter.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors credential-mapping-store's factory pattern (takes a pre-opened
|
|
5
|
+
* Database instance, does NOT open its own). The lifecycle is owned by
|
|
6
|
+
* the caller — we share the existing secrets.db connection to keep all
|
|
7
|
+
* encrypted-at-rest data in one DB file.
|
|
8
|
+
*
|
|
9
|
+
* The entire OAuthProfile JSON payload is encrypted as one AES-256-GCM
|
|
10
|
+
* blob per row. One ciphertext+iv+authTag+salt set per profile. Atomic
|
|
11
|
+
* update — no half-rotated state where access changes but refresh doesn't.
|
|
12
|
+
*
|
|
13
|
+
* Denormalized expires_at column stays in sync on every write so the
|
|
14
|
+
* doctor can query expiring profiles without decrypting any blob.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
import type Database from "better-sqlite3";
|
|
19
|
+
import type { OAuthCredentialStorePort, SecretsCrypto } from "@comis/core";
|
|
20
|
+
/**
|
|
21
|
+
* Create an encrypted OAuthCredentialStorePort backed by a shared SQLite DB.
|
|
22
|
+
*
|
|
23
|
+
* The adapter does NOT own the db lifecycle — the caller supplies an
|
|
24
|
+
* already-open Database (typically the secrets.db chain). Initializes its
|
|
25
|
+
* own oauth_profiles table via initOAuthProfileSchema (idempotent).
|
|
26
|
+
*/
|
|
27
|
+
export declare function createOAuthProfileStoreEncrypted(db: Database.Database, crypto: SecretsCrypto): OAuthCredentialStorePort;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Encrypted SQLite-backed OAuthCredentialStorePort adapter.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors credential-mapping-store's factory pattern (takes a pre-opened
|
|
6
|
+
* Database instance, does NOT open its own). The lifecycle is owned by
|
|
7
|
+
* the caller — we share the existing secrets.db connection to keep all
|
|
8
|
+
* encrypted-at-rest data in one DB file.
|
|
9
|
+
*
|
|
10
|
+
* The entire OAuthProfile JSON payload is encrypted as one AES-256-GCM
|
|
11
|
+
* blob per row. One ciphertext+iv+authTag+salt set per profile. Atomic
|
|
12
|
+
* update — no half-rotated state where access changes but refresh doesn't.
|
|
13
|
+
*
|
|
14
|
+
* Denormalized expires_at column stays in sync on every write so the
|
|
15
|
+
* doctor can query expiring profiles without decrypting any blob.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
import { ok, err, fromPromise } from "@comis/shared";
|
|
20
|
+
import { validateProfileId } from "@comis/core";
|
|
21
|
+
import { initOAuthProfileSchema } from "./oauth-profile-schema.js";
|
|
22
|
+
const SCHEMA_VERSION = 1;
|
|
23
|
+
/**
|
|
24
|
+
* Create an encrypted OAuthCredentialStorePort backed by a shared SQLite DB.
|
|
25
|
+
*
|
|
26
|
+
* The adapter does NOT own the db lifecycle — the caller supplies an
|
|
27
|
+
* already-open Database (typically the secrets.db chain). Initializes its
|
|
28
|
+
* own oauth_profiles table via initOAuthProfileSchema (idempotent).
|
|
29
|
+
*/
|
|
30
|
+
export function createOAuthProfileStoreEncrypted(db, crypto) {
|
|
31
|
+
initOAuthProfileSchema(db);
|
|
32
|
+
const upsertStmt = db.prepare(`
|
|
33
|
+
INSERT INTO oauth_profiles (
|
|
34
|
+
profile_id, provider, identity,
|
|
35
|
+
credentials_ciphertext, credentials_iv, credentials_auth_tag, credentials_salt,
|
|
36
|
+
expires_at, version, created_at, updated_at
|
|
37
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
38
|
+
ON CONFLICT(profile_id) DO UPDATE SET
|
|
39
|
+
provider = excluded.provider,
|
|
40
|
+
identity = excluded.identity,
|
|
41
|
+
credentials_ciphertext = excluded.credentials_ciphertext,
|
|
42
|
+
credentials_iv = excluded.credentials_iv,
|
|
43
|
+
credentials_auth_tag = excluded.credentials_auth_tag,
|
|
44
|
+
credentials_salt = excluded.credentials_salt,
|
|
45
|
+
expires_at = excluded.expires_at,
|
|
46
|
+
version = excluded.version,
|
|
47
|
+
updated_at = excluded.updated_at
|
|
48
|
+
`);
|
|
49
|
+
const getStmt = db.prepare("SELECT * FROM oauth_profiles WHERE profile_id = ?");
|
|
50
|
+
const deleteStmt = db.prepare("DELETE FROM oauth_profiles WHERE profile_id = ?");
|
|
51
|
+
const listAllStmt = db.prepare("SELECT * FROM oauth_profiles");
|
|
52
|
+
const listByProviderStmt = db.prepare("SELECT * FROM oauth_profiles WHERE provider = ?");
|
|
53
|
+
const existsStmt = db.prepare("SELECT 1 FROM oauth_profiles WHERE profile_id = ?");
|
|
54
|
+
function rowToProfile(row) {
|
|
55
|
+
if (row.version !== SCHEMA_VERSION) {
|
|
56
|
+
return err(new Error("OAuth profile store version mismatch: expected " +
|
|
57
|
+
SCHEMA_VERSION +
|
|
58
|
+
", got " +
|
|
59
|
+
String(row.version) +
|
|
60
|
+
". Hint: drop the oauth_profiles table and re-run `comis auth login` to recreate. Stored profiles for unknown schema versions cannot be migrated."));
|
|
61
|
+
}
|
|
62
|
+
const decryptResult = crypto.decrypt({
|
|
63
|
+
ciphertext: row.credentials_ciphertext,
|
|
64
|
+
iv: row.credentials_iv,
|
|
65
|
+
authTag: row.credentials_auth_tag,
|
|
66
|
+
salt: row.credentials_salt,
|
|
67
|
+
});
|
|
68
|
+
if (!decryptResult.ok)
|
|
69
|
+
return err(decryptResult.error);
|
|
70
|
+
let parsed;
|
|
71
|
+
try {
|
|
72
|
+
parsed = JSON.parse(decryptResult.value);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
return err(new Error("OAuth profile decryption produced invalid JSON: " + String(e)));
|
|
76
|
+
}
|
|
77
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
78
|
+
return err(new Error("OAuth profile decryption produced non-object payload"));
|
|
79
|
+
}
|
|
80
|
+
return ok(parsed);
|
|
81
|
+
}
|
|
82
|
+
const port = {
|
|
83
|
+
async get(profileId) {
|
|
84
|
+
const validation = validateProfileId(profileId);
|
|
85
|
+
if (!validation.ok)
|
|
86
|
+
return err(validation.error);
|
|
87
|
+
return fromPromise((async () => {
|
|
88
|
+
const row = getStmt.get(profileId);
|
|
89
|
+
if (!row)
|
|
90
|
+
return undefined;
|
|
91
|
+
const r = rowToProfile(row);
|
|
92
|
+
if (!r.ok)
|
|
93
|
+
throw r.error;
|
|
94
|
+
return r.value;
|
|
95
|
+
})());
|
|
96
|
+
},
|
|
97
|
+
async set(profileId, profile) {
|
|
98
|
+
const validation = validateProfileId(profileId);
|
|
99
|
+
if (!validation.ok)
|
|
100
|
+
return err(validation.error);
|
|
101
|
+
const fullProfile = { ...profile, profileId, version: SCHEMA_VERSION };
|
|
102
|
+
const payload = JSON.stringify(fullProfile);
|
|
103
|
+
const encryptResult = crypto.encrypt(payload);
|
|
104
|
+
if (!encryptResult.ok)
|
|
105
|
+
return err(encryptResult.error);
|
|
106
|
+
const enc = encryptResult.value;
|
|
107
|
+
const now = Date.now();
|
|
108
|
+
return fromPromise((async () => {
|
|
109
|
+
upsertStmt.run(profileId, validation.value.provider, validation.value.identity, enc.ciphertext, enc.iv, enc.authTag, enc.salt, fullProfile.expires, SCHEMA_VERSION, now, now);
|
|
110
|
+
})());
|
|
111
|
+
},
|
|
112
|
+
async delete(profileId) {
|
|
113
|
+
const validation = validateProfileId(profileId);
|
|
114
|
+
if (!validation.ok)
|
|
115
|
+
return err(validation.error);
|
|
116
|
+
return fromPromise((async () => {
|
|
117
|
+
const result = deleteStmt.run(profileId);
|
|
118
|
+
return result.changes > 0;
|
|
119
|
+
})());
|
|
120
|
+
},
|
|
121
|
+
async list(filter) {
|
|
122
|
+
return fromPromise((async () => {
|
|
123
|
+
const rows = filter?.provider
|
|
124
|
+
? listByProviderStmt.all(filter.provider)
|
|
125
|
+
: listAllStmt.all();
|
|
126
|
+
const profiles = [];
|
|
127
|
+
for (const row of rows) {
|
|
128
|
+
const r = rowToProfile(row);
|
|
129
|
+
if (!r.ok)
|
|
130
|
+
throw r.error;
|
|
131
|
+
profiles.push(r.value);
|
|
132
|
+
}
|
|
133
|
+
return profiles;
|
|
134
|
+
})());
|
|
135
|
+
},
|
|
136
|
+
async has(profileId) {
|
|
137
|
+
const validation = validateProfileId(profileId);
|
|
138
|
+
if (!validation.ok)
|
|
139
|
+
return err(validation.error);
|
|
140
|
+
return fromPromise((async () => existsStmt.get(profileId) !== undefined)());
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
return Object.freeze(port);
|
|
144
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* prepared statements. Sessions survive process restarts since they are
|
|
6
6
|
* stored in SQLite.
|
|
7
7
|
*
|
|
8
|
-
* Factory function pattern (createSessionStore) consistent with
|
|
8
|
+
* Factory function pattern (createSessionStore) consistent with
|
|
9
9
|
* createSecretManager for minimal public surface area.
|
|
10
10
|
*/
|
|
11
11
|
import type Database from "better-sqlite3";
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* prepared statements. Sessions survive process restarts since they are
|
|
7
7
|
* stored in SQLite.
|
|
8
8
|
*
|
|
9
|
-
* Factory function pattern (createSessionStore) consistent with
|
|
9
|
+
* Factory function pattern (createSessionStore) consistent with
|
|
10
10
|
* createSecretManager for minimal public surface area.
|
|
11
11
|
*/
|
|
12
12
|
import { formatSessionKey } from "@comis/core";
|
|
@@ -10,7 +10,32 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Persists encrypted secrets across daemon restarts.
|
|
12
12
|
*/
|
|
13
|
+
import type Database from "better-sqlite3";
|
|
13
14
|
import type { SecretStorePort, SecretsCrypto } from "@comis/core";
|
|
15
|
+
/**
|
|
16
|
+
* Concrete return type of createSqliteSecretStore.
|
|
17
|
+
*
|
|
18
|
+
* Implements SecretStorePort and additionally exposes the underlying
|
|
19
|
+
* better-sqlite3 handle for adapters that need to share the same
|
|
20
|
+
* connection (e.g., the encrypted OAuth profile store).
|
|
21
|
+
*
|
|
22
|
+
* The `db` field is intentionally additive — `SecretStorePort` itself is
|
|
23
|
+
* unchanged and remains the canonical port boundary. Consumers that only
|
|
24
|
+
* need port-level operations should accept `SecretStorePort`, not
|
|
25
|
+
* `SqliteSecretStoreHandle`.
|
|
26
|
+
*/
|
|
27
|
+
export interface SqliteSecretStoreHandle extends SecretStorePort {
|
|
28
|
+
/**
|
|
29
|
+
* Underlying better-sqlite3 handle.
|
|
30
|
+
*
|
|
31
|
+
* Use for sharing the connection with sibling tables in the same DB
|
|
32
|
+
* file (e.g., `oauth_profiles` alongside `secrets`). Eliminates the
|
|
33
|
+
* dual-handle hazard (close-order, schema-init double-execution,
|
|
34
|
+
* prepared-statement cache fragmentation) that two separate handles
|
|
35
|
+
* to the same WAL-mode SQLite file would introduce.
|
|
36
|
+
*/
|
|
37
|
+
readonly db: Database.Database;
|
|
38
|
+
}
|
|
14
39
|
/**
|
|
15
40
|
* Create a SqliteSecretStore bound to the given database path.
|
|
16
41
|
*
|
|
@@ -22,11 +47,12 @@ import type { SecretStorePort, SecretsCrypto } from "@comis/core";
|
|
|
22
47
|
* 5. Validate canary (master key mismatch detection)
|
|
23
48
|
* 6. Second chmod pass (SQLite may create WAL/SHM during canary)
|
|
24
49
|
* 7. Prepare all SQL statements once
|
|
25
|
-
* 8. Return frozen SecretStorePort
|
|
50
|
+
* 8. Return frozen SqliteSecretStoreHandle (SecretStorePort + db field)
|
|
26
51
|
*
|
|
27
52
|
* @param dbPath - Absolute path to the secrets.db file
|
|
28
53
|
* @param crypto - SecretsCrypto engine bound to the current master key
|
|
29
|
-
* @returns SecretStorePort
|
|
54
|
+
* @returns SqliteSecretStoreHandle — a SecretStorePort that also exposes
|
|
55
|
+
* the underlying better-sqlite3 handle on `.db`
|
|
30
56
|
* @throws Error if schema init, canary validation, or DB open fails
|
|
31
57
|
*/
|
|
32
|
-
export declare function createSqliteSecretStore(dbPath: string, crypto: SecretsCrypto):
|
|
58
|
+
export declare function createSqliteSecretStore(dbPath: string, crypto: SecretsCrypto): SqliteSecretStoreHandle;
|
|
@@ -25,11 +25,12 @@ import { openSqliteDatabase, chmodDbFiles } from "./sqlite-adapter-base.js";
|
|
|
25
25
|
* 5. Validate canary (master key mismatch detection)
|
|
26
26
|
* 6. Second chmod pass (SQLite may create WAL/SHM during canary)
|
|
27
27
|
* 7. Prepare all SQL statements once
|
|
28
|
-
* 8. Return frozen SecretStorePort
|
|
28
|
+
* 8. Return frozen SqliteSecretStoreHandle (SecretStorePort + db field)
|
|
29
29
|
*
|
|
30
30
|
* @param dbPath - Absolute path to the secrets.db file
|
|
31
31
|
* @param crypto - SecretsCrypto engine bound to the current master key
|
|
32
|
-
* @returns SecretStorePort
|
|
32
|
+
* @returns SqliteSecretStoreHandle — a SecretStorePort that also exposes
|
|
33
|
+
* the underlying better-sqlite3 handle on `.db`
|
|
33
34
|
* @throws Error if schema init, canary validation, or DB open fails
|
|
34
35
|
*/
|
|
35
36
|
export function createSqliteSecretStore(dbPath, crypto) {
|
|
@@ -149,5 +150,12 @@ export function createSqliteSecretStore(dbPath, crypto) {
|
|
|
149
150
|
db.close();
|
|
150
151
|
},
|
|
151
152
|
};
|
|
152
|
-
return
|
|
153
|
+
// Expose the underlying db handle on the factory return so the encrypted
|
|
154
|
+
// OAuth profile adapter (oauth-profile-store-encrypted) can share this same
|
|
155
|
+
// connection rather than opening a second handle to the same secrets.db
|
|
156
|
+
// file. The SecretStorePort surface itself is unchanged — consumers that
|
|
157
|
+
// only need port-level operations should accept SecretStorePort, not
|
|
158
|
+
// SqliteSecretStoreHandle.
|
|
159
|
+
const handle = { ...store, db };
|
|
160
|
+
return Object.freeze(handle);
|
|
153
161
|
}
|
|
@@ -8,19 +8,14 @@ import { z } from "zod";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const CronScheduleSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
10
10
|
kind: z.ZodLiteral<"cron">;
|
|
11
|
-
/** Standard cron expression (5 or 6 fields) */
|
|
12
11
|
expr: z.ZodString;
|
|
13
|
-
/** IANA timezone (e.g. "America/New_York"), omit for UTC */
|
|
14
12
|
tz: z.ZodOptional<z.ZodString>;
|
|
15
13
|
}, z.core.$strict>, z.ZodObject<{
|
|
16
14
|
kind: z.ZodLiteral<"every">;
|
|
17
|
-
/** Interval in milliseconds */
|
|
18
15
|
everyMs: z.ZodNumber;
|
|
19
|
-
/** Optional anchor timestamp in ms (first tick aligned to this) */
|
|
20
16
|
anchorMs: z.ZodOptional<z.ZodNumber>;
|
|
21
17
|
}, z.core.$strict>, z.ZodObject<{
|
|
22
18
|
kind: z.ZodLiteral<"at">;
|
|
23
|
-
/** ISO 8601 datetime string for one-shot execution */
|
|
24
19
|
at: z.ZodString;
|
|
25
20
|
}, z.core.$strict>], "kind">;
|
|
26
21
|
export type CronSchedule = z.infer<typeof CronScheduleSchema>;
|
|
@@ -32,15 +27,11 @@ export type CronSchedule = z.infer<typeof CronScheduleSchema>;
|
|
|
32
27
|
*/
|
|
33
28
|
export declare const CronPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
34
29
|
kind: z.ZodLiteral<"system_event">;
|
|
35
|
-
/** Event text to emit */
|
|
36
30
|
text: z.ZodString;
|
|
37
31
|
}, z.core.$strict>, z.ZodObject<{
|
|
38
32
|
kind: z.ZodLiteral<"agent_turn">;
|
|
39
|
-
/** Message to send to the agent */
|
|
40
33
|
message: z.ZodString;
|
|
41
|
-
/** Optional model override for this turn */
|
|
42
34
|
model: z.ZodOptional<z.ZodString>;
|
|
43
|
-
/** Optional timeout in seconds for this turn */
|
|
44
35
|
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
45
36
|
}, z.core.$strict>], "kind">;
|
|
46
37
|
export type CronPayload = z.infer<typeof CronPayloadSchema>;
|
|
@@ -80,99 +71,66 @@ export type CronDeliveryTarget = z.infer<typeof CronDeliveryTargetSchema>;
|
|
|
80
71
|
* Full cron job definition.
|
|
81
72
|
*/
|
|
82
73
|
export declare const CronJobSchema: z.ZodObject<{
|
|
83
|
-
/** Unique job identifier */
|
|
84
74
|
id: z.ZodString;
|
|
85
|
-
/** Human-readable job name */
|
|
86
75
|
name: z.ZodString;
|
|
87
|
-
/** Agent ID that owns this job */
|
|
88
76
|
agentId: z.ZodString;
|
|
89
|
-
/** Schedule definition */
|
|
90
77
|
schedule: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
91
78
|
kind: z.ZodLiteral<"cron">;
|
|
92
|
-
/** Standard cron expression (5 or 6 fields) */
|
|
93
79
|
expr: z.ZodString;
|
|
94
|
-
/** IANA timezone (e.g. "America/New_York"), omit for UTC */
|
|
95
80
|
tz: z.ZodOptional<z.ZodString>;
|
|
96
81
|
}, z.core.$strict>, z.ZodObject<{
|
|
97
82
|
kind: z.ZodLiteral<"every">;
|
|
98
|
-
/** Interval in milliseconds */
|
|
99
83
|
everyMs: z.ZodNumber;
|
|
100
|
-
/** Optional anchor timestamp in ms (first tick aligned to this) */
|
|
101
84
|
anchorMs: z.ZodOptional<z.ZodNumber>;
|
|
102
85
|
}, z.core.$strict>, z.ZodObject<{
|
|
103
86
|
kind: z.ZodLiteral<"at">;
|
|
104
|
-
/** ISO 8601 datetime string for one-shot execution */
|
|
105
87
|
at: z.ZodString;
|
|
106
88
|
}, z.core.$strict>], "kind">;
|
|
107
|
-
/** Payload to execute */
|
|
108
89
|
payload: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
109
90
|
kind: z.ZodLiteral<"system_event">;
|
|
110
|
-
/** Event text to emit */
|
|
111
91
|
text: z.ZodString;
|
|
112
92
|
}, z.core.$strict>, z.ZodObject<{
|
|
113
93
|
kind: z.ZodLiteral<"agent_turn">;
|
|
114
|
-
/** Message to send to the agent */
|
|
115
94
|
message: z.ZodString;
|
|
116
|
-
/** Optional model override for this turn */
|
|
117
95
|
model: z.ZodOptional<z.ZodString>;
|
|
118
|
-
/** Optional timeout in seconds for this turn */
|
|
119
96
|
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
120
97
|
}, z.core.$strict>], "kind">;
|
|
121
|
-
/** Session target for execution */
|
|
122
98
|
sessionTarget: z.ZodDefault<z.ZodEnum<{
|
|
123
99
|
main: "main";
|
|
124
100
|
isolated: "isolated";
|
|
125
101
|
}>>;
|
|
126
|
-
/** Wake mode: when to trigger heartbeat after enqueuing a system event. */
|
|
127
102
|
wakeMode: z.ZodDefault<z.ZodEnum<{
|
|
128
103
|
now: "now";
|
|
129
104
|
"next-heartbeat": "next-heartbeat";
|
|
130
105
|
}>>;
|
|
131
|
-
/** Whether to forward isolated session results back to main heartbeat session. */
|
|
132
106
|
forwardToMain: z.ZodDefault<z.ZodBoolean>;
|
|
133
|
-
/** Session history strategy for cron executions. Default: fresh. */
|
|
134
107
|
sessionStrategy: z.ZodDefault<z.ZodEnum<{
|
|
135
108
|
fresh: "fresh";
|
|
136
109
|
rolling: "rolling";
|
|
137
110
|
accumulate: "accumulate";
|
|
138
111
|
}>>;
|
|
139
|
-
/** Number of recent turns to keep for rolling strategy (default 3). */
|
|
140
112
|
maxHistoryTurns: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
141
|
-
/** Per-job cache retention override. Default inherits OPERATION_CACHE_DEFAULTS["cron"] = "short". */
|
|
142
113
|
cacheRetention: z.ZodOptional<z.ZodEnum<{
|
|
143
114
|
none: "none";
|
|
144
115
|
short: "short";
|
|
145
116
|
long: "long";
|
|
146
117
|
}>>;
|
|
147
|
-
/** Per-job tool policy override -- matches AgentConfig.toolPolicy shape.
|
|
148
|
-
*
|
|
149
|
-
* Resolution order: job.toolPolicy > agentConfig.toolPolicy > passthrough
|
|
150
|
-
* (no filtering). Opt-in: omitting this field preserves existing tool set
|
|
151
|
-
* for the job. No silent defaults -- operators explicitly request
|
|
152
|
-
* conservative presets like `{ profile: "cron-minimal" }`. */
|
|
153
118
|
toolPolicy: z.ZodOptional<z.ZodObject<{
|
|
154
119
|
profile: z.ZodDefault<z.ZodString>;
|
|
155
120
|
allow: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
156
121
|
deny: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
157
122
|
}, z.core.$strip>>;
|
|
158
|
-
/** Delivery target for routing results to originating channel */
|
|
159
123
|
deliveryTarget: z.ZodOptional<z.ZodObject<{
|
|
160
124
|
channelId: z.ZodString;
|
|
161
125
|
userId: z.ZodString;
|
|
162
126
|
tenantId: z.ZodString;
|
|
163
127
|
channelType: z.ZodOptional<z.ZodString>;
|
|
164
128
|
}, z.core.$strict>>;
|
|
165
|
-
/** Whether this job is currently enabled */
|
|
166
129
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
167
|
-
/** Next scheduled run timestamp (ms since epoch) */
|
|
168
130
|
nextRunAtMs: z.ZodOptional<z.ZodNumber>;
|
|
169
|
-
/** Last completed run timestamp (ms since epoch) */
|
|
170
131
|
lastRunAtMs: z.ZodOptional<z.ZodNumber>;
|
|
171
|
-
/** Number of consecutive errors */
|
|
172
132
|
consecutiveErrors: z.ZodDefault<z.ZodNumber>;
|
|
173
|
-
/** Maximum consecutive errors before auto-suspend. Per-job override of scheduler default. */
|
|
174
133
|
maxConsecutiveErrors: z.ZodOptional<z.ZodNumber>;
|
|
175
|
-
/** Job creation timestamp (ms since epoch) */
|
|
176
134
|
createdAtMs: z.ZodNumber;
|
|
177
135
|
}, z.core.$strict>;
|
|
178
136
|
export type CronJob = z.infer<typeof CronJobSchema>;
|
|
@@ -14,6 +14,19 @@ export interface ExecutionLockOptions {
|
|
|
14
14
|
updateMs: number;
|
|
15
15
|
/** Callback when lock is compromised (e.g., external release). */
|
|
16
16
|
onCompromised?: (err: Error) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Optional lock-acquisition retry budget. Forwarded to proper-lockfile's
|
|
19
|
+
* own retry option (uses a built-in incremental backoff). When undefined
|
|
20
|
+
* (default), retries: 0 — fail fast on contention. Lets the OAuth manager
|
|
21
|
+
* wait for a sibling refresh to complete (concurrent-refresh acceptance)
|
|
22
|
+
* without callers having to roll their own retry loop.
|
|
23
|
+
*/
|
|
24
|
+
retries?: number | {
|
|
25
|
+
retries: number;
|
|
26
|
+
minTimeout?: number;
|
|
27
|
+
maxTimeout?: number;
|
|
28
|
+
factor?: number;
|
|
29
|
+
};
|
|
17
30
|
}
|
|
18
31
|
/**
|
|
19
32
|
* Acquire a file lock, execute the function, and release the lock.
|
|
@@ -41,7 +41,7 @@ export async function withExecutionLock(lockPath, fn, options) {
|
|
|
41
41
|
release = await lockfile.lock(lockPath, {
|
|
42
42
|
stale: opts.staleMs,
|
|
43
43
|
update: opts.updateMs,
|
|
44
|
-
retries: 0,
|
|
44
|
+
retries: opts.retries ?? 0,
|
|
45
45
|
onCompromised: opts.onCompromised ?? (() => { }),
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { createExecutionTracker } from "./execution-tracker.js";
|
|
2
2
|
export type { ExecutionTracker, ExecutionLogEntry } from "./execution-tracker.js";
|
|
3
|
+
export { withExecutionLock, isLocked } from "./execution-lock.js";
|
|
4
|
+
export type { ExecutionLockOptions } from "./execution-lock.js";
|
|
@@ -37,9 +37,19 @@ interface HeartbeatExecutor {
|
|
|
37
37
|
response: string;
|
|
38
38
|
}>;
|
|
39
39
|
}
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Minimal BackgroundSessionResolver shape -- only needs hasActiveSession()
|
|
42
|
+
* for the queue-busy check. The scheduler package cannot import @comis/agent
|
|
43
|
+
* (would create a cycle), so we re-declare the structural minimum here. The
|
|
44
|
+
* daemon wires `createBackgroundSessionResolver({activeRunRegistry})` and
|
|
45
|
+
* the resulting object is structurally assignable to this shape (R3, B36).
|
|
46
|
+
*/
|
|
47
|
+
interface HeartbeatSessionResolver {
|
|
48
|
+
hasActiveSession(key: {
|
|
49
|
+
agentId: string;
|
|
50
|
+
channelType: string;
|
|
51
|
+
channelId: string;
|
|
52
|
+
}): boolean;
|
|
43
53
|
}
|
|
44
54
|
/** Tool policy filter function signature -- matches applyToolPolicy from @comis/skills.
|
|
45
55
|
* Injected as a dep so scheduler doesn't take a hard dependency on skills. */
|
|
@@ -96,8 +106,12 @@ export interface AgentHeartbeatSourceDeps {
|
|
|
96
106
|
systemEventQueue: SystemEventQueue;
|
|
97
107
|
/** Delivery bridge dependencies for routing notifications. */
|
|
98
108
|
deliveryBridge: DeliveryBridgeDeps;
|
|
99
|
-
/**
|
|
100
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Optional composite-key resolver for queue-busy detection (R3, B36).
|
|
111
|
+
* Wired by the daemon as
|
|
112
|
+
* `createBackgroundSessionResolver({activeRunRegistry})`.
|
|
113
|
+
*/
|
|
114
|
+
sessionResolver?: HeartbeatSessionResolver;
|
|
101
115
|
/** Optional session operations for response processing side-effects. */
|
|
102
116
|
sessionOps?: HeartbeatSessionOps;
|
|
103
117
|
/** Optional: fetch memory stats for an agent (for heartbeat prompt injection). */
|
|
@@ -119,12 +133,19 @@ export interface AgentHeartbeatSourceDeps {
|
|
|
119
133
|
*/
|
|
120
134
|
export declare function resolveHeartbeatModel(perAgentHeartbeatModel: string | undefined, globalHeartbeatModel: string | undefined, agentDefaultModel: string): string;
|
|
121
135
|
/**
|
|
122
|
-
* Check if a session is actively running an agent turn.
|
|
136
|
+
* Check if a session is actively running an agent turn (R3, B36).
|
|
123
137
|
*
|
|
124
|
-
*
|
|
138
|
+
* Uses the composite-key resolver: `(agentId, channelType, channelId)`
|
|
139
|
+
* uniquely identifies a session across multi-agent / multi-channel
|
|
140
|
+
* deployments (the previous single-arg `formattedKey` collapsed those
|
|
141
|
+
* dimensions). Returns false when no resolver is provided (heartbeat
|
|
125
142
|
* operates in isolation without collision detection).
|
|
126
143
|
*/
|
|
127
|
-
export declare function isQueueBusy(
|
|
144
|
+
export declare function isQueueBusy(sessionResolver: HeartbeatSessionResolver | undefined, composite: {
|
|
145
|
+
agentId: string;
|
|
146
|
+
channelType: string;
|
|
147
|
+
channelId: string;
|
|
148
|
+
}): boolean;
|
|
128
149
|
/**
|
|
129
150
|
* Resolve the SessionKey for a heartbeat tick.
|
|
130
151
|
*
|
|
@@ -41,15 +41,18 @@ export function resolveHeartbeatModel(perAgentHeartbeatModel, globalHeartbeatMod
|
|
|
41
41
|
return perAgentHeartbeatModel ?? globalHeartbeatModel ?? agentDefaultModel;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Check if a session is actively running an agent turn.
|
|
44
|
+
* Check if a session is actively running an agent turn (R3, B36).
|
|
45
45
|
*
|
|
46
|
-
*
|
|
46
|
+
* Uses the composite-key resolver: `(agentId, channelType, channelId)`
|
|
47
|
+
* uniquely identifies a session across multi-agent / multi-channel
|
|
48
|
+
* deployments (the previous single-arg `formattedKey` collapsed those
|
|
49
|
+
* dimensions). Returns false when no resolver is provided (heartbeat
|
|
47
50
|
* operates in isolation without collision detection).
|
|
48
51
|
*/
|
|
49
|
-
export function isQueueBusy(
|
|
50
|
-
if (!
|
|
52
|
+
export function isQueueBusy(sessionResolver, composite) {
|
|
53
|
+
if (!sessionResolver)
|
|
51
54
|
return false;
|
|
52
|
-
return
|
|
55
|
+
return sessionResolver.hasActiveSession(composite);
|
|
53
56
|
}
|
|
54
57
|
/**
|
|
55
58
|
* Resolve the SessionKey for a heartbeat tick.
|
|
@@ -99,8 +102,17 @@ export function createAgentHeartbeatSource(deps) {
|
|
|
99
102
|
return;
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
|
-
// 5. Queue-busy check
|
|
103
|
-
|
|
105
|
+
// 5. Queue-busy check (R3, B36): composite-key lookup distinguishes
|
|
106
|
+
// multi-agent / multi-channel collisions. The msg.channelType is the
|
|
107
|
+
// configured target's channelType (defaulting to "heartbeat" when no
|
|
108
|
+
// delivery target is wired). channelId is sessionKey.channelId
|
|
109
|
+
// (matches resolveHeartbeatSessionKey above).
|
|
110
|
+
const heartbeatChannelType = config.target?.channelType ?? "heartbeat";
|
|
111
|
+
if (isQueueBusy(deps.sessionResolver, {
|
|
112
|
+
agentId,
|
|
113
|
+
channelType: heartbeatChannelType,
|
|
114
|
+
channelId: sessionKey.channelId,
|
|
115
|
+
})) {
|
|
104
116
|
logger.debug({ agentId, formattedKey }, "Heartbeat skipped: session queue busy");
|
|
105
117
|
return;
|
|
106
118
|
}
|
|
@@ -158,7 +170,7 @@ export function createAgentHeartbeatSource(deps) {
|
|
|
158
170
|
},
|
|
159
171
|
};
|
|
160
172
|
// 9. Resolve model (for logging)
|
|
161
|
-
const model = resolveHeartbeatModel(undefined, // per-agent heartbeat model
|
|
173
|
+
const model = resolveHeartbeatModel(undefined, // per-agent heartbeat model not in schema
|
|
162
174
|
undefined, // global heartbeat model not yet in schema
|
|
163
175
|
agentConfig.model);
|
|
164
176
|
logger.info({ agentId, trigger, model, channelType: msg.channelType }, "Heartbeat run starting");
|
|
@@ -7,6 +7,8 @@ export { createCronScheduler } from "./cron/index.js";
|
|
|
7
7
|
export type { CronScheduler } from "./cron/index.js";
|
|
8
8
|
export { createExecutionTracker } from "./execution/index.js";
|
|
9
9
|
export type { ExecutionTracker, ExecutionLogEntry } from "./execution/index.js";
|
|
10
|
+
export { withExecutionLock, isLocked } from "./execution/execution-lock.js";
|
|
11
|
+
export type { ExecutionLockOptions } from "./execution/execution-lock.js";
|
|
10
12
|
export { HEARTBEAT_OK_TOKEN, createHeartbeatRunner } from "./heartbeat/index.js";
|
|
11
13
|
export type { HeartbeatCheckResult, HeartbeatSourcePort, HeartbeatRunner } from "./heartbeat/index.js";
|
|
12
14
|
export { resolveEffectiveHeartbeatConfig } from "./heartbeat/index.js";
|
|
@@ -7,6 +7,8 @@ export { createCronStore } from "./cron/index.js";
|
|
|
7
7
|
export { createCronScheduler } from "./cron/index.js";
|
|
8
8
|
// Execution safety
|
|
9
9
|
export { createExecutionTracker } from "./execution/index.js";
|
|
10
|
+
// File-based execution lock (consumed by @comis/agent OAuth file adapter + token manager)
|
|
11
|
+
export { withExecutionLock, isLocked } from "./execution/execution-lock.js";
|
|
10
12
|
// Heartbeat monitoring
|
|
11
13
|
export { HEARTBEAT_OK_TOKEN, createHeartbeatRunner } from "./heartbeat/index.js";
|
|
12
14
|
// Per-agent heartbeat config resolution
|
|
@@ -4,11 +4,8 @@ import { z } from "zod";
|
|
|
4
4
|
* Events are produced by subsystems (cron, exec) and consumed by the heartbeat cycle.
|
|
5
5
|
*/
|
|
6
6
|
export declare const SystemEventEntrySchema: z.ZodObject<{
|
|
7
|
-
/** Event text content (e.g., "Check disk space", "Command completed: git pull") */
|
|
8
7
|
text: z.ZodString;
|
|
9
|
-
/** Classification key for filtering (e.g., "cron:job-abc", "exec:cmd-123") */
|
|
10
8
|
contextKey: z.ZodString;
|
|
11
|
-
/** Timestamp when the event was enqueued (ms since epoch) */
|
|
12
9
|
enqueuedAt: z.ZodNumber;
|
|
13
10
|
}, z.core.$strict>;
|
|
14
11
|
export type SystemEventEntry = z.infer<typeof SystemEventEntrySchema>;
|