@wrongstack/core 0.297.0 → 0.298.1
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/dist/chronicle/index.js +126 -22
- package/dist/chronicle/project-server-client.d.ts +12 -0
- package/dist/chronicle/project-server-protocol.d.ts +22 -0
- package/dist/chronicle/project-server.js +238 -157
- package/dist/coordination/agents/index.js +136 -1
- package/dist/coordination/agents/role-skills.d.ts +3 -2
- package/dist/coordination/brain-trace.d.ts +2 -1
- package/dist/coordination/director/director-task-registry.d.ts +12 -0
- package/dist/coordination/fleet-supervisor.d.ts +21 -0
- package/dist/coordination/index.d.ts +23 -21
- package/dist/coordination/index.js +16493 -16068
- package/dist/coordination/mail-tools.d.ts +3 -3
- package/dist/coordination/mailbox-credential-store.d.ts +22 -2
- package/dist/coordination/mailbox-credential-throttle.d.ts +63 -0
- package/dist/coordination/mailbox-project-server-client.d.ts +16 -0
- package/dist/coordination/mailbox-project-server-protocol.d.ts +43 -5
- package/dist/coordination/mailbox-project-server.js +508 -253
- package/dist/coordination/provider-status-tracker.d.ts +2 -0
- package/dist/coordination/remote-mailbox-credential-store.d.ts +5 -5
- package/dist/coordination/remote-mailbox.d.ts +8 -4
- package/dist/coordination/sqlite-mailbox-credentials.d.ts +11 -0
- package/dist/core/fallback-profile-manager.d.ts +14 -0
- package/dist/core/index.js +451 -137
- package/dist/core/instruction-bundle.d.ts +12 -0
- package/dist/core/system-prompt-builder.d.ts +14 -0
- package/dist/core/system-prompt-skill-bodies.d.ts +1 -1
- package/dist/core/system-prompt-skill-text.d.ts +1 -2
- package/dist/defaults/index.js +2191 -1208
- package/dist/design/index.js +47 -8
- package/dist/execution/design-materialize.d.ts +22 -0
- package/dist/execution/index.js +495 -248
- package/dist/execution/skill-loader.d.ts +10 -1
- package/dist/execution/tool-error-taxonomy.d.ts +31 -0
- package/dist/execution/tool-executor.d.ts +1 -0
- package/dist/goal/index.js +3 -1
- package/dist/hooks/index.js +5 -0
- package/dist/hq/auth-audit.d.ts +6 -0
- package/dist/hq/auth-store.d.ts +59 -3
- package/dist/hq/index.js +401 -101
- package/dist/hq/kanban-store.d.ts +3 -0
- package/dist/hq/protocol/core.d.ts +3 -15
- package/dist/hq/protocol/envelope.d.ts +29 -0
- package/dist/hq/protocol/governance.d.ts +34 -0
- package/dist/hq/protocol/project.d.ts +3 -0
- package/dist/hq/protocol/resume.d.ts +1 -1
- package/dist/hq/protocol.d.ts +9 -8
- package/dist/hq/protocol.js +675 -0
- package/dist/index.js +9012 -6916
- package/dist/infrastructure/index.js +199 -102
- package/dist/kernel/events/session-events.d.ts +3 -0
- package/dist/kernel/events/tool-events.d.ts +3 -1
- package/dist/models/index.js +1 -1
- package/dist/observability/index.js +27 -0
- package/dist/observability/prometheus.d.ts +11 -0
- package/dist/plugin/index.d.ts +5 -1
- package/dist/plugin/index.js +988 -558
- package/dist/plugins/auto-review-plugin.d.ts +1 -11
- package/dist/plugins/review-store-maintenance.d.ts +26 -0
- package/dist/plugins/review-types.d.ts +6 -0
- package/dist/security/auto-approve-policy.d.ts +37 -0
- package/dist/security/capabilities.d.ts +45 -1
- package/dist/security/error-sanitize.d.ts +49 -0
- package/dist/security/file-permissions.d.ts +41 -0
- package/dist/security/index.d.ts +9 -6
- package/dist/security/index.js +3008 -2029
- package/dist/security/permission-helpers.d.ts +93 -0
- package/dist/security/permission-policy.d.ts +37 -35
- package/dist/security/secret-vault.d.ts +17 -0
- package/dist/security/totp.d.ts +86 -0
- package/dist/skills/frontmatter.d.ts +12 -1
- package/dist/skills/github-fetcher.d.ts +48 -0
- package/dist/skills/index.js +137 -26
- package/dist/skills/limits.d.ts +19 -0
- package/dist/skills/skill-installer.d.ts +13 -0
- package/dist/storage/index.js +929 -733
- package/dist/storage/provider-config-watcher.d.ts +1 -0
- package/dist/storage/session-helpers.d.ts +1 -0
- package/dist/storage/session-store.d.ts +9 -2
- package/dist/storage/session-workspace-checkpoints.d.ts +5 -0
- package/dist/tools/fallback-manage-tools.d.ts +6 -0
- package/dist/tools/index.js +287 -131
- package/dist/tools/mcp-use.d.ts +1 -1
- package/dist/types/blocks.d.ts +7 -0
- package/dist/types/config/autonomy.d.ts +15 -7
- package/dist/types/config/mcp-features.d.ts +9 -1
- package/dist/types/config/root.d.ts +10 -4
- package/dist/types/context-window.d.ts +15 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/secret-vault.d.ts +8 -0
- package/dist/types/session.d.ts +2 -0
- package/dist/types/skill.d.ts +56 -0
- package/dist/types/tool-executor.d.ts +2 -0
- package/dist/utils/env-typed.d.ts +64 -0
- package/dist/utils/glob-match.d.ts +21 -1
- package/dist/utils/heap-watchdog.js +1 -1
- package/dist/utils/incoming-images.d.ts +19 -0
- package/dist/utils/index.d.ts +16 -12
- package/dist/utils/index.js +3128 -2800
- package/dist/utils/path-segment.d.ts +29 -0
- package/dist/utils/sage-output-block.js +48 -0
- package/dist/utils/win32-cmd.d.ts +25 -0
- package/dist/worktree/index.js +5 -0
- package/instructions/llm/chimera-review.md +4 -6
- package/package.json +13 -4
- package/skills/auto-review/SKILL.md +11 -76
- package/skills/chimera/SKILL.md +31 -49
- package/skills/data-governance/SKILL.md +92 -0
- package/skills/wrongstack-kanban/SKILL.md +125 -64
- package/dist/agent-status-helpers.d.ts.map +0 -1
- package/dist/agent-status-tracker.d.ts.map +0 -1
- package/dist/boot.d.ts.map +0 -1
- package/dist/chronicle/context.d.ts.map +0 -1
- package/dist/chronicle/decision-adapter.d.ts.map +0 -1
- package/dist/chronicle/domain-adapter.d.ts.map +0 -1
- package/dist/chronicle/event-hash.d.ts.map +0 -1
- package/dist/chronicle/file-observer.d.ts.map +0 -1
- package/dist/chronicle/health-monitor.d.ts.map +0 -1
- package/dist/chronicle/identity.d.ts.map +0 -1
- package/dist/chronicle/index.d.ts.map +0 -1
- package/dist/chronicle/index.js.map +0 -7
- package/dist/chronicle/journal.d.ts.map +0 -1
- package/dist/chronicle/legacy-journal-import.d.ts.map +0 -1
- package/dist/chronicle/metrics-store.d.ts.map +0 -1
- package/dist/chronicle/partition-filename.d.ts.map +0 -1
- package/dist/chronicle/partition-range-cache.d.ts.map +0 -1
- package/dist/chronicle/process-adapter.d.ts.map +0 -1
- package/dist/chronicle/project-access.d.ts.map +0 -1
- package/dist/chronicle/project-server-client.d.ts.map +0 -1
- package/dist/chronicle/project-server-endpoint.d.ts.map +0 -1
- package/dist/chronicle/project-server-protocol.d.ts.map +0 -1
- package/dist/chronicle/project-server.d.ts.map +0 -1
- package/dist/chronicle/project-server.js.map +0 -7
- package/dist/chronicle/prompt-manifest.d.ts.map +0 -1
- package/dist/chronicle/provider-adapter.d.ts.map +0 -1
- package/dist/chronicle/query.d.ts.map +0 -1
- package/dist/chronicle/review-adapter.d.ts.map +0 -1
- package/dist/chronicle/rollup-adapter.d.ts.map +0 -1
- package/dist/chronicle/sink.d.ts.map +0 -1
- package/dist/chronicle/sqlite-journal.d.ts.map +0 -1
- package/dist/chronicle/sqlite-query.d.ts.map +0 -1
- package/dist/chronicle/stream-adapter.d.ts.map +0 -1
- package/dist/chronicle/tool-adapter.d.ts.map +0 -1
- package/dist/chronicle/types.d.ts.map +0 -1
- package/dist/coordination/adaptive-concurrency.d.ts.map +0 -1
- package/dist/coordination/agent-bridge.d.ts.map +0 -1
- package/dist/coordination/agent-monitor.d.ts.map +0 -1
- package/dist/coordination/agent-subagent-runner.d.ts.map +0 -1
- package/dist/coordination/agents/agent-prompts.d.ts.map +0 -1
- package/dist/coordination/agents/index.d.ts.map +0 -1
- package/dist/coordination/agents/index.js.map +0 -7
- package/dist/coordination/agents/phase1-discovery.d.ts.map +0 -1
- package/dist/coordination/agents/phase2-planning.d.ts.map +0 -1
- package/dist/coordination/agents/phase3-build.d.ts.map +0 -1
- package/dist/coordination/agents/phase3-techstack.d.ts.map +0 -1
- package/dist/coordination/agents/phase3-wave1-platform.d.ts.map +0 -1
- package/dist/coordination/agents/phase3-wave2-meta.d.ts.map +0 -1
- package/dist/coordination/agents/phase4-verify.d.ts.map +0 -1
- package/dist/coordination/agents/phase5-review.d.ts.map +0 -1
- package/dist/coordination/agents/phase6-domain.d.ts.map +0 -1
- package/dist/coordination/agents/phase7-knowledge.d.ts.map +0 -1
- package/dist/coordination/agents/phase8-delivery.d.ts.map +0 -1
- package/dist/coordination/agents/phase8-wave3-products.d.ts.map +0 -1
- package/dist/coordination/agents/phase9-meta.d.ts.map +0 -1
- package/dist/coordination/agents/phase9-wave4-platform-meta.d.ts.map +0 -1
- package/dist/coordination/agents/project-agent-config-validation.d.ts.map +0 -1
- package/dist/coordination/agents/project-agent-consolidation.d.ts.map +0 -1
- package/dist/coordination/agents/project-agent-files.d.ts.map +0 -1
- package/dist/coordination/agents/project-agent-identity-types.d.ts.map +0 -1
- package/dist/coordination/agents/project-agent-identity.d.ts.map +0 -1
- package/dist/coordination/agents/project-agent-knowledge-manifests.d.ts.map +0 -1
- package/dist/coordination/agents/project-agent-learning-entries.d.ts.map +0 -1
- package/dist/coordination/agents/project-agent-learning-normalize.d.ts.map +0 -1
- package/dist/coordination/agents/project-agent-learning-policy.d.ts.map +0 -1
- package/dist/coordination/agents/project-agent-learning-structured.d.ts.map +0 -1
- package/dist/coordination/agents/project-agent-paths.d.ts.map +0 -1
- package/dist/coordination/agents/project-agent-profile.d.ts.map +0 -1
- package/dist/coordination/agents/role-skills.d.ts.map +0 -1
- package/dist/coordination/agents/types.d.ts.map +0 -1
- package/dist/coordination/agents.d.ts.map +0 -1
- package/dist/coordination/auto-extend.d.ts.map +0 -1
- package/dist/coordination/autonomous-brain.d.ts.map +0 -1
- package/dist/coordination/autonomous-coordinator.d.ts.map +0 -1
- package/dist/coordination/brain-cache.d.ts.map +0 -1
- package/dist/coordination/brain-heuristics.d.ts.map +0 -1
- package/dist/coordination/brain-ledger.d.ts.map +0 -1
- package/dist/coordination/brain-monitor.d.ts.map +0 -1
- package/dist/coordination/brain-rules.d.ts.map +0 -1
- package/dist/coordination/brain-telemetry.d.ts.map +0 -1
- package/dist/coordination/brain-trace.d.ts.map +0 -1
- package/dist/coordination/brain.d.ts.map +0 -1
- package/dist/coordination/change-manager.d.ts.map +0 -1
- package/dist/coordination/checkpoint-wiring.d.ts.map +0 -1
- package/dist/coordination/collab-bus.d.ts.map +0 -1
- package/dist/coordination/collab-debug-types.d.ts.map +0 -1
- package/dist/coordination/collab-debug.d.ts.map +0 -1
- package/dist/coordination/collab-director-host.d.ts.map +0 -1
- package/dist/coordination/commit-safety.d.ts.map +0 -1
- package/dist/coordination/consensus-protocol.d.ts.map +0 -1
- package/dist/coordination/coordinator/error-classifier.d.ts.map +0 -1
- package/dist/coordination/delegate-tool.d.ts.map +0 -1
- package/dist/coordination/dep-watcher-bridge.d.ts.map +0 -1
- package/dist/coordination/dep-watcher.d.ts.map +0 -1
- package/dist/coordination/director/director-btw-notes.d.ts.map +0 -1
- package/dist/coordination/director/director-budget-policy.d.ts.map +0 -1
- package/dist/coordination/director/director-collab.d.ts.map +0 -1
- package/dist/coordination/director/director-errors.d.ts.map +0 -1
- package/dist/coordination/director/director-task-registry.d.ts.map +0 -1
- package/dist/coordination/director/director-toolset.d.ts.map +0 -1
- package/dist/coordination/director-basic-tools.d.ts.map +0 -1
- package/dist/coordination/director-collab-tools.d.ts.map +0 -1
- package/dist/coordination/director-host-contracts.d.ts.map +0 -1
- package/dist/coordination/director-input-helpers.d.ts.map +0 -1
- package/dist/coordination/director-kanban-queue-helpers.d.ts.map +0 -1
- package/dist/coordination/director-options.d.ts.map +0 -1
- package/dist/coordination/director-prompts.d.ts.map +0 -1
- package/dist/coordination/director-quality-gate-tool.d.ts.map +0 -1
- package/dist/coordination/director-session.d.ts.map +0 -1
- package/dist/coordination/director-spawn-model.d.ts.map +0 -1
- package/dist/coordination/director-tools.d.ts.map +0 -1
- package/dist/coordination/director.d.ts.map +0 -1
- package/dist/coordination/dispatcher.d.ts.map +0 -1
- package/dist/coordination/file-author-tracker.d.ts.map +0 -1
- package/dist/coordination/fleet-bus.d.ts.map +0 -1
- package/dist/coordination/fleet-event-validation.d.ts.map +0 -1
- package/dist/coordination/fleet-manager.d.ts.map +0 -1
- package/dist/coordination/fleet-spawn.d.ts.map +0 -1
- package/dist/coordination/fleet-status-tool.d.ts.map +0 -1
- package/dist/coordination/fleet-supervisor.d.ts.map +0 -1
- package/dist/coordination/fleet.d.ts.map +0 -1
- package/dist/coordination/global-mailbox-completion.d.ts.map +0 -1
- package/dist/coordination/global-mailbox-paths.d.ts.map +0 -1
- package/dist/coordination/icoordinator.d.ts.map +0 -1
- package/dist/coordination/ifleet-manager.d.ts.map +0 -1
- package/dist/coordination/in-memory-transport.d.ts.map +0 -1
- package/dist/coordination/index.d.ts.map +0 -1
- package/dist/coordination/index.js.map +0 -7
- package/dist/coordination/knowledge-graph.d.ts.map +0 -1
- package/dist/coordination/large-answer-store.d.ts.map +0 -1
- package/dist/coordination/mail-tools.d.ts.map +0 -1
- package/dist/coordination/mailbox-actions.d.ts.map +0 -1
- package/dist/coordination/mailbox-auth-types.d.ts.map +0 -1
- package/dist/coordination/mailbox-codecs.d.ts.map +0 -1
- package/dist/coordination/mailbox-constants.d.ts.map +0 -1
- package/dist/coordination/mailbox-credential-store.d.ts.map +0 -1
- package/dist/coordination/mailbox-events.d.ts.map +0 -1
- package/dist/coordination/mailbox-health.d.ts.map +0 -1
- package/dist/coordination/mailbox-hooks.d.ts.map +0 -1
- package/dist/coordination/mailbox-http-auth.d.ts.map +0 -1
- package/dist/coordination/mailbox-http-rate-limit.d.ts.map +0 -1
- package/dist/coordination/mailbox-http-router.d.ts.map +0 -1
- package/dist/coordination/mailbox-http-validation.d.ts.map +0 -1
- package/dist/coordination/mailbox-message-codec.d.ts.map +0 -1
- package/dist/coordination/mailbox-parse-state.d.ts.map +0 -1
- package/dist/coordination/mailbox-project-server-client.d.ts.map +0 -1
- package/dist/coordination/mailbox-project-server-endpoint.d.ts.map +0 -1
- package/dist/coordination/mailbox-project-server-protocol.d.ts.map +0 -1
- package/dist/coordination/mailbox-project-server.d.ts.map +0 -1
- package/dist/coordination/mailbox-project-server.js.map +0 -7
- package/dist/coordination/mailbox-receipt-folding.d.ts.map +0 -1
- package/dist/coordination/mailbox-registry-codec.d.ts.map +0 -1
- package/dist/coordination/mailbox-retention-state.d.ts.map +0 -1
- package/dist/coordination/mailbox-status-mappers.d.ts.map +0 -1
- package/dist/coordination/mailbox-tool.d.ts.map +0 -1
- package/dist/coordination/mailbox-type-properties.d.ts.map +0 -1
- package/dist/coordination/mailbox-types.d.ts.map +0 -1
- package/dist/coordination/model-matrix.d.ts.map +0 -1
- package/dist/coordination/multi-agent-coordinator.d.ts.map +0 -1
- package/dist/coordination/multi-agent-timeout.d.ts.map +0 -1
- package/dist/coordination/null-fleet-bus.d.ts.map +0 -1
- package/dist/coordination/package-author-tracker.d.ts.map +0 -1
- package/dist/coordination/package-outdated-watcher.d.ts.map +0 -1
- package/dist/coordination/provider-status-tracker.d.ts.map +0 -1
- package/dist/coordination/remote-mailbox-credential-store.d.ts.map +0 -1
- package/dist/coordination/remote-mailbox.d.ts.map +0 -1
- package/dist/coordination/single-instance-mailbox.d.ts.map +0 -1
- package/dist/coordination/spawn-budget.d.ts.map +0 -1
- package/dist/coordination/sqlite-mailbox-compaction.d.ts.map +0 -1
- package/dist/coordination/sqlite-mailbox-credentials.d.ts.map +0 -1
- package/dist/coordination/sqlite-mailbox-rows.d.ts.map +0 -1
- package/dist/coordination/sqlite-mailbox-schema.d.ts.map +0 -1
- package/dist/coordination/sqlite-mailbox.d.ts.map +0 -1
- package/dist/coordination/subagent-budget.d.ts.map +0 -1
- package/dist/coordination/subagent-nicknames.d.ts.map +0 -1
- package/dist/coordination/subagent-result-tool.d.ts.map +0 -1
- package/dist/coordination/task-auctioneer.d.ts.map +0 -1
- package/dist/coordination/task-dag.d.ts.map +0 -1
- package/dist/coordination/techstack-mailbox-consumer.d.ts.map +0 -1
- package/dist/coordination/transport.d.ts.map +0 -1
- package/dist/coordination/worktree-task-runner.d.ts.map +0 -1
- package/dist/core/agent-internals.d.ts.map +0 -1
- package/dist/core/agent-loop.d.ts.map +0 -1
- package/dist/core/agent-response.d.ts.map +0 -1
- package/dist/core/agent-tools.d.ts.map +0 -1
- package/dist/core/agent-types.d.ts.map +0 -1
- package/dist/core/agent.d.ts.map +0 -1
- package/dist/core/btw.d.ts.map +0 -1
- package/dist/core/context.d.ts.map +0 -1
- package/dist/core/continue-intent.d.ts.map +0 -1
- package/dist/core/continue-to-next-iteration.d.ts.map +0 -1
- package/dist/core/conversation-state.d.ts.map +0 -1
- package/dist/core/fallback-model.d.ts.map +0 -1
- package/dist/core/fallback-profile-manager.d.ts.map +0 -1
- package/dist/core/fleet-pulse.d.ts.map +0 -1
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js.map +0 -7
- package/dist/core/input-builder.d.ts.map +0 -1
- package/dist/core/instruction-bundle.d.ts.map +0 -1
- package/dist/core/iteration-limit.d.ts.map +0 -1
- package/dist/core/mailbox-loop.d.ts.map +0 -1
- package/dist/core/model-availability-calendar.d.ts.map +0 -1
- package/dist/core/model-ref.d.ts.map +0 -1
- package/dist/core/model-ref.js.map +0 -7
- package/dist/core/modes/brief.d.ts.map +0 -1
- package/dist/core/modes/default.d.ts.map +0 -1
- package/dist/core/modes/teach.d.ts.map +0 -1
- package/dist/core/provider-runner.d.ts.map +0 -1
- package/dist/core/queued-messages.d.ts.map +0 -1
- package/dist/core/request-provider-binding.d.ts.map +0 -1
- package/dist/core/run-env.d.ts.map +0 -1
- package/dist/core/streaming-response-builder.d.ts.map +0 -1
- package/dist/core/system-prompt-blocks.d.ts.map +0 -1
- package/dist/core/system-prompt-builder.d.ts.map +0 -1
- package/dist/core/system-prompt-environment-probes.d.ts.map +0 -1
- package/dist/core/system-prompt-environment.d.ts.map +0 -1
- package/dist/core/system-prompt-memory-skills.d.ts.map +0 -1
- package/dist/core/system-prompt-plan.d.ts.map +0 -1
- package/dist/core/system-prompt-shell.d.ts.map +0 -1
- package/dist/core/system-prompt-skill-bodies.d.ts.map +0 -1
- package/dist/core/system-prompt-skill-text.d.ts.map +0 -1
- package/dist/defaults/index.d.ts.map +0 -1
- package/dist/defaults/index.js.map +0 -7
- package/dist/design/index.d.ts.map +0 -1
- package/dist/design/index.js.map +0 -7
- package/dist/execution/auto-compaction-middleware.d.ts.map +0 -1
- package/dist/execution/autonomous-runner.d.ts.map +0 -1
- package/dist/execution/autonomy-brain.d.ts.map +0 -1
- package/dist/execution/autonomy-prompt-contributor.d.ts.map +0 -1
- package/dist/execution/brain-chain.d.ts.map +0 -1
- package/dist/execution/brain-circuit.d.ts.map +0 -1
- package/dist/execution/brain-evaluation.d.ts.map +0 -1
- package/dist/execution/brain-runtime-constants.d.ts.map +0 -1
- package/dist/execution/brain-runtime.d.ts.map +0 -1
- package/dist/execution/compaction-core.d.ts.map +0 -1
- package/dist/execution/compaction-scoring.d.ts.map +0 -1
- package/dist/execution/compaction-summary-cache.d.ts.map +0 -1
- package/dist/execution/compactor.d.ts.map +0 -1
- package/dist/execution/council-brain.d.ts.map +0 -1
- package/dist/execution/council-orchestrator.d.ts.map +0 -1
- package/dist/execution/council-personas.d.ts.map +0 -1
- package/dist/execution/council-profiles.d.ts.map +0 -1
- package/dist/execution/council-prompts.d.ts.map +0 -1
- package/dist/execution/council-resolution.d.ts.map +0 -1
- package/dist/execution/design-color.d.ts.map +0 -1
- package/dist/execution/design-detect.d.ts.map +0 -1
- package/dist/execution/design-kit-loader.d.ts.map +0 -1
- package/dist/execution/design-materialize.d.ts.map +0 -1
- package/dist/execution/design-project-store.d.ts.map +0 -1
- package/dist/execution/design-tune.d.ts.map +0 -1
- package/dist/execution/design-verify.d.ts.map +0 -1
- package/dist/execution/enhance-recovery.d.ts.map +0 -1
- package/dist/execution/error-handler.d.ts.map +0 -1
- package/dist/execution/eternal-autonomy-types.d.ts.map +0 -1
- package/dist/execution/eternal-autonomy.d.ts.map +0 -1
- package/dist/execution/goal-preamble.d.ts.map +0 -1
- package/dist/execution/index.d.ts.map +0 -1
- package/dist/execution/index.js.map +0 -7
- package/dist/execution/intelligent-compactor.d.ts.map +0 -1
- package/dist/execution/model-runtime.d.ts.map +0 -1
- package/dist/execution/one-shot-llm.d.ts.map +0 -1
- package/dist/execution/parallel-eternal-engine.d.ts.map +0 -1
- package/dist/execution/prompt-enhancer.d.ts.map +0 -1
- package/dist/execution/prompt-enhancer.js.map +0 -7
- package/dist/execution/prompt-loader.d.ts.map +0 -1
- package/dist/execution/provider-runner-impl.d.ts.map +0 -1
- package/dist/execution/regex-patterns.d.ts.map +0 -1
- package/dist/execution/retry-policy.d.ts.map +0 -1
- package/dist/execution/selective-compactor.d.ts.map +0 -1
- package/dist/execution/skill-loader.d.ts.map +0 -1
- package/dist/execution/strategy-compactor.d.ts.map +0 -1
- package/dist/execution/subagent-compaction.d.ts.map +0 -1
- package/dist/execution/tool-executor-logging.d.ts.map +0 -1
- package/dist/execution/tool-executor-results.d.ts.map +0 -1
- package/dist/execution/tool-executor-stream.d.ts.map +0 -1
- package/dist/execution/tool-executor-support.d.ts.map +0 -1
- package/dist/execution/tool-executor.d.ts.map +0 -1
- package/dist/extension/extension-points.d.ts.map +0 -1
- package/dist/extension/index.d.ts.map +0 -1
- package/dist/extension/index.js.map +0 -7
- package/dist/extension/registry.d.ts.map +0 -1
- package/dist/fleet-notifier.d.ts.map +0 -1
- package/dist/goal/checkpoint.d.ts.map +0 -1
- package/dist/goal/goal-assessor.d.ts.map +0 -1
- package/dist/goal/goal-planner.d.ts.map +0 -1
- package/dist/goal/goal-runner.d.ts.map +0 -1
- package/dist/goal/index.d.ts.map +0 -1
- package/dist/goal/index.js.map +0 -7
- package/dist/goal/phase-board-mutations.d.ts.map +0 -1
- package/dist/goal/phase-graph-builder.d.ts.map +0 -1
- package/dist/goal/phase-orchestrator-integration.d.ts.map +0 -1
- package/dist/goal/phase-orchestrator-queries.d.ts.map +0 -1
- package/dist/goal/phase-orchestrator-runtime.d.ts.map +0 -1
- package/dist/goal/phase-orchestrator-types.d.ts.map +0 -1
- package/dist/goal/phase-orchestrator.d.ts.map +0 -1
- package/dist/goal/phase-store.d.ts.map +0 -1
- package/dist/goal/types.d.ts.map +0 -1
- package/dist/hooks/http-executor.d.ts.map +0 -1
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js.map +0 -7
- package/dist/hooks/registry.d.ts.map +0 -1
- package/dist/hooks/runner.d.ts.map +0 -1
- package/dist/hooks/shell-executor.d.ts.map +0 -1
- package/dist/hooks/shell-hooks-equal.d.ts.map +0 -1
- package/dist/hq/alerts.d.ts.map +0 -1
- package/dist/hq/auth-audit.d.ts.map +0 -1
- package/dist/hq/auth-store.d.ts.map +0 -1
- package/dist/hq/bootstrap-store.d.ts.map +0 -1
- package/dist/hq/brain-bridge.d.ts.map +0 -1
- package/dist/hq/bridge-context.d.ts.map +0 -1
- package/dist/hq/commands.d.ts.map +0 -1
- package/dist/hq/cost-bridge.d.ts.map +0 -1
- package/dist/hq/exposure.d.ts.map +0 -1
- package/dist/hq/factory.d.ts.map +0 -1
- package/dist/hq/fleet-bridge.d.ts.map +0 -1
- package/dist/hq/index.d.ts.map +0 -1
- package/dist/hq/index.js.map +0 -7
- package/dist/hq/kanban-store.d.ts.map +0 -1
- package/dist/hq/mailbox-mapper.d.ts.map +0 -1
- package/dist/hq/persistence/event-log.d.ts.map +0 -1
- package/dist/hq/persistence/jsonl-io.d.ts.map +0 -1
- package/dist/hq/persistence/simple-log.d.ts.map +0 -1
- package/dist/hq/persistence/snapshot-store.d.ts.map +0 -1
- package/dist/hq/persistence/timeseries-store.d.ts.map +0 -1
- package/dist/hq/persistence.d.ts.map +0 -1
- package/dist/hq/protocol/brain.d.ts.map +0 -1
- package/dist/hq/protocol/browser.d.ts.map +0 -1
- package/dist/hq/protocol/client.d.ts.map +0 -1
- package/dist/hq/protocol/core.d.ts.map +0 -1
- package/dist/hq/protocol/fleet.d.ts.map +0 -1
- package/dist/hq/protocol/kanban.d.ts.map +0 -1
- package/dist/hq/protocol/mailbox.d.ts.map +0 -1
- package/dist/hq/protocol/mcp.d.ts.map +0 -1
- package/dist/hq/protocol/peer.d.ts.map +0 -1
- package/dist/hq/protocol/project.d.ts.map +0 -1
- package/dist/hq/protocol/resume.d.ts.map +0 -1
- package/dist/hq/protocol/session.d.ts.map +0 -1
- package/dist/hq/protocol/tool.d.ts.map +0 -1
- package/dist/hq/protocol.d.ts.map +0 -1
- package/dist/hq/publisher.d.ts.map +0 -1
- package/dist/hq/redaction.d.ts.map +0 -1
- package/dist/hq/session-bridge.d.ts.map +0 -1
- package/dist/hq/tool-bridge.d.ts.map +0 -1
- package/dist/hq/transcript-mapper.d.ts.map +0 -1
- package/dist/hq/worktree-bridge.d.ts.map +0 -1
- package/dist/hq/write-queues.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -7
- package/dist/infrastructure/context-manager.d.ts.map +0 -1
- package/dist/infrastructure/index.d.ts.map +0 -1
- package/dist/infrastructure/index.js.map +0 -7
- package/dist/infrastructure/logger.d.ts.map +0 -1
- package/dist/infrastructure/mcp-servers.d.ts.map +0 -1
- package/dist/infrastructure/path-resolver.d.ts.map +0 -1
- package/dist/infrastructure/provider-cache-ledger.d.ts.map +0 -1
- package/dist/infrastructure/token-counter.d.ts.map +0 -1
- package/dist/kernel/container.d.ts.map +0 -1
- package/dist/kernel/events/agent-events.d.ts.map +0 -1
- package/dist/kernel/events/brain-events.d.ts.map +0 -1
- package/dist/kernel/events/file-events.d.ts.map +0 -1
- package/dist/kernel/events/fleet-events.d.ts.map +0 -1
- package/dist/kernel/events/memory-events.d.ts.map +0 -1
- package/dist/kernel/events/network-events.d.ts.map +0 -1
- package/dist/kernel/events/process-events.d.ts.map +0 -1
- package/dist/kernel/events/provider-events.d.ts.map +0 -1
- package/dist/kernel/events/sdd-events.d.ts.map +0 -1
- package/dist/kernel/events/session-events.d.ts.map +0 -1
- package/dist/kernel/events/tool-events.d.ts.map +0 -1
- package/dist/kernel/events/worktree-events.d.ts.map +0 -1
- package/dist/kernel/events.d.ts.map +0 -1
- package/dist/kernel/index.d.ts.map +0 -1
- package/dist/kernel/index.js.map +0 -7
- package/dist/kernel/pipeline.d.ts.map +0 -1
- package/dist/kernel/run-controller.d.ts.map +0 -1
- package/dist/kernel/tokens.d.ts.map +0 -1
- package/dist/mailbox-attach.d.ts.map +0 -1
- package/dist/middleware/collab-pause.d.ts.map +0 -1
- package/dist/models/alibaba-token-plan-catalog.d.ts.map +0 -1
- package/dist/models/codex-catalog.d.ts.map +0 -1
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/index.js.map +0 -7
- package/dist/models/llm-selector.d.ts.map +0 -1
- package/dist/models/mode-store.d.ts.map +0 -1
- package/dist/models/model-intelligence.d.ts.map +0 -1
- package/dist/models/model-router.d.ts.map +0 -1
- package/dist/models/models-registry.d.ts.map +0 -1
- package/dist/models/provider-model-resolve.d.ts.map +0 -1
- package/dist/notifications/index.d.ts.map +0 -1
- package/dist/notifications/index.js.map +0 -7
- package/dist/notifications/notifier-impl.d.ts.map +0 -1
- package/dist/notifications/notifier.d.ts.map +0 -1
- package/dist/notifications/types.d.ts.map +0 -1
- package/dist/observability/event-bridge.d.ts.map +0 -1
- package/dist/observability/health.d.ts.map +0 -1
- package/dist/observability/index.d.ts.map +0 -1
- package/dist/observability/index.js.map +0 -7
- package/dist/observability/metrics.d.ts.map +0 -1
- package/dist/observability/network-telemetry.d.ts.map +0 -1
- package/dist/observability/otel-tracer.d.ts.map +0 -1
- package/dist/observability/otlp-metrics.d.ts.map +0 -1
- package/dist/observability/otlp-traces.d.ts.map +0 -1
- package/dist/observability/process-telemetry.d.ts.map +0 -1
- package/dist/observability/prometheus.d.ts.map +0 -1
- package/dist/observability/redact-command.d.ts.map +0 -1
- package/dist/observability/tracer.d.ts.map +0 -1
- package/dist/plugin/api.d.ts.map +0 -1
- package/dist/plugin/config.d.ts.map +0 -1
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/plugin/index.js.map +0 -7
- package/dist/plugin/loader.d.ts.map +0 -1
- package/dist/plugins/auto-review-plugin.d.ts.map +0 -1
- package/dist/plugins/chimera-plugin.d.ts.map +0 -1
- package/dist/plugins/prompts-plugin.d.ts.map +0 -1
- package/dist/plugins/review-claim-registry.d.ts.map +0 -1
- package/dist/plugins/review-context-builder.d.ts.map +0 -1
- package/dist/plugins/review-finding-commands.d.ts.map +0 -1
- package/dist/plugins/review-finding-integration.d.ts.map +0 -1
- package/dist/plugins/review-finding-parser.d.ts.map +0 -1
- package/dist/plugins/review-finding-store.d.ts.map +0 -1
- package/dist/plugins/review-finding-types.d.ts.map +0 -1
- package/dist/plugins/review-report-integration.d.ts.map +0 -1
- package/dist/plugins/review-report-store.d.ts.map +0 -1
- package/dist/plugins/review-report-types.d.ts.map +0 -1
- package/dist/plugins/review-types.d.ts.map +0 -1
- package/dist/plugins/skills-plugin.d.ts.map +0 -1
- package/dist/plugins/sync-plugin.d.ts.map +0 -1
- package/dist/prompts/index.d.ts.map +0 -1
- package/dist/prompts/prompt-installer.d.ts.map +0 -1
- package/dist/prompts/prompt-manifest-store.d.ts.map +0 -1
- package/dist/registry/index.d.ts.map +0 -1
- package/dist/registry/index.js.map +0 -7
- package/dist/registry/provider-registry.d.ts.map +0 -1
- package/dist/registry/slash-command-registry.d.ts.map +0 -1
- package/dist/registry/tool-registry.d.ts.map +0 -1
- package/dist/replay/hash.d.ts.map +0 -1
- package/dist/replay/index.d.ts.map +0 -1
- package/dist/replay/index.js.map +0 -7
- package/dist/replay/replay-provider-runner.d.ts.map +0 -1
- package/dist/security/capabilities.d.ts.map +0 -1
- package/dist/security/config-secrets.d.ts.map +0 -1
- package/dist/security/directory-permission-policy.d.ts.map +0 -1
- package/dist/security/directory-policy-schema.d.ts.map +0 -1
- package/dist/security/index.d.ts.map +0 -1
- package/dist/security/index.js.map +0 -7
- package/dist/security/kanban-boundary.d.ts.map +0 -1
- package/dist/security/permission-policy-schema.d.ts.map +0 -1
- package/dist/security/permission-policy.d.ts.map +0 -1
- package/dist/security/readonly-permission-policy.d.ts.map +0 -1
- package/dist/security/secret-scrubber.d.ts.map +0 -1
- package/dist/security/secret-vault.d.ts.map +0 -1
- package/dist/security/trust-boundary.d.ts.map +0 -1
- package/dist/security/yolo-risk.d.ts.map +0 -1
- package/dist/session-registry-atomic-file.d.ts.map +0 -1
- package/dist/session-registry-types.d.ts.map +0 -1
- package/dist/session-registry.d.ts.map +0 -1
- package/dist/skills/foreign-sources.d.ts.map +0 -1
- package/dist/skills/frontmatter.d.ts.map +0 -1
- package/dist/skills/github-fetcher.d.ts.map +0 -1
- package/dist/skills/index.d.ts.map +0 -1
- package/dist/skills/index.js.map +0 -7
- package/dist/skills/limits.d.ts.map +0 -1
- package/dist/skills/manifest-store.d.ts.map +0 -1
- package/dist/skills/registry/github-direct-adapter.d.ts.map +0 -1
- package/dist/skills/registry/registry-adapter.d.ts.map +0 -1
- package/dist/skills/registry/skills-sh-adapter.d.ts.map +0 -1
- package/dist/skills/skill-generator.d.ts.map +0 -1
- package/dist/skills/skill-installer.d.ts.map +0 -1
- package/dist/storage/annotations-store.d.ts.map +0 -1
- package/dist/storage/attachment-store.d.ts.map +0 -1
- package/dist/storage/cloud-sync.d.ts.map +0 -1
- package/dist/storage/completed-work-checkpoint.d.ts.map +0 -1
- package/dist/storage/config-loader/bootstrap.d.ts.map +0 -1
- package/dist/storage/config-loader/default-repair.d.ts.map +0 -1
- package/dist/storage/config-loader/defaults.d.ts.map +0 -1
- package/dist/storage/config-loader/diagnostics.d.ts.map +0 -1
- package/dist/storage/config-loader/env-overrides.d.ts.map +0 -1
- package/dist/storage/config-loader/in-project-policy.d.ts.map +0 -1
- package/dist/storage/config-loader/inline-provider-models.d.ts.map +0 -1
- package/dist/storage/config-loader/legacy-sage-migration.d.ts.map +0 -1
- package/dist/storage/config-loader/path-identity.d.ts.map +0 -1
- package/dist/storage/config-loader/types.d.ts.map +0 -1
- package/dist/storage/config-loader/validation.d.ts.map +0 -1
- package/dist/storage/config-loader.d.ts.map +0 -1
- package/dist/storage/config-migration.d.ts.map +0 -1
- package/dist/storage/config-store.d.ts.map +0 -1
- package/dist/storage/director-state.d.ts.map +0 -1
- package/dist/storage/file-session-writer.d.ts.map +0 -1
- package/dist/storage/goal-coordination.d.ts.map +0 -1
- package/dist/storage/goal-kanban.d.ts.map +0 -1
- package/dist/storage/goal-store.d.ts.map +0 -1
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js.map +0 -7
- package/dist/storage/input-history-store.d.ts.map +0 -1
- package/dist/storage/memory-backend.d.ts.map +0 -1
- package/dist/storage/memory-consolidator.d.ts.map +0 -1
- package/dist/storage/memory-graph-backend.d.ts.map +0 -1
- package/dist/storage/plan-store.d.ts.map +0 -1
- package/dist/storage/plan-templates.d.ts.map +0 -1
- package/dist/storage/prompt-store.d.ts.map +0 -1
- package/dist/storage/prompt-usage-store.d.ts.map +0 -1
- package/dist/storage/provider-config-watcher.d.ts.map +0 -1
- package/dist/storage/queue-store.d.ts.map +0 -1
- package/dist/storage/recovery-lock.d.ts.map +0 -1
- package/dist/storage/replay-log-store.d.ts.map +0 -1
- package/dist/storage/session-analyzer.d.ts.map +0 -1
- package/dist/storage/session-checkpoint-cas.d.ts.map +0 -1
- package/dist/storage/session-event-bridge.d.ts.map +0 -1
- package/dist/storage/session-helpers.d.ts.map +0 -1
- package/dist/storage/session-id-resolver.d.ts.map +0 -1
- package/dist/storage/session-id.d.ts.map +0 -1
- package/dist/storage/session-read-scrubber.d.ts.map +0 -1
- package/dist/storage/session-reader.d.ts.map +0 -1
- package/dist/storage/session-recovery.d.ts.map +0 -1
- package/dist/storage/session-resume-validation.d.ts.map +0 -1
- package/dist/storage/session-rewind-apply.d.ts.map +0 -1
- package/dist/storage/session-rewinder.d.ts.map +0 -1
- package/dist/storage/session-store/delete-session-artifacts.d.ts.map +0 -1
- package/dist/storage/session-store/delete-session-guards.d.ts.map +0 -1
- package/dist/storage/session-store/directory-scan.d.ts.map +0 -1
- package/dist/storage/session-store/directory-session-files.d.ts.map +0 -1
- package/dist/storage/session-store/events.d.ts.map +0 -1
- package/dist/storage/session-store/fork-session.d.ts.map +0 -1
- package/dist/storage/session-store/index-reader.d.ts.map +0 -1
- package/dist/storage/session-store/load-cache.d.ts.map +0 -1
- package/dist/storage/session-store/load-session-data.d.ts.map +0 -1
- package/dist/storage/session-store/paths.d.ts.map +0 -1
- package/dist/storage/session-store/prune-helpers.d.ts.map +0 -1
- package/dist/storage/session-store/replay.d.ts.map +0 -1
- package/dist/storage/session-store/search-events.d.ts.map +0 -1
- package/dist/storage/session-store/shard-manifest.d.ts.map +0 -1
- package/dist/storage/session-store/summary-builder.d.ts.map +0 -1
- package/dist/storage/session-store/summary-header.d.ts.map +0 -1
- package/dist/storage/session-store/types.d.ts.map +0 -1
- package/dist/storage/session-store.d.ts.map +0 -1
- package/dist/storage/session-summary.d.ts.map +0 -1
- package/dist/storage/session-tool-call-ends.d.ts.map +0 -1
- package/dist/storage/session-writer-scrubber.d.ts.map +0 -1
- package/dist/storage/session-writer-truncate.d.ts.map +0 -1
- package/dist/storage/storage-concurrency.d.ts.map +0 -1
- package/dist/storage/task-store.d.ts.map +0 -1
- package/dist/storage/todos-checkpoint.d.ts.map +0 -1
- package/dist/storage/tool-audit-log.d.ts.map +0 -1
- package/dist/tasking/index.d.ts.map +0 -1
- package/dist/tasking/index.js.map +0 -7
- package/dist/tasking/task-store.d.ts.map +0 -1
- package/dist/tasking/task-tracker.d.ts.map +0 -1
- package/dist/tools/council-tool.d.ts.map +0 -1
- package/dist/tools/fallback-chain-manage-tool.d.ts.map +0 -1
- package/dist/tools/fallback-favorite-manage-tool.d.ts.map +0 -1
- package/dist/tools/fallback-manage-helpers.d.ts.map +0 -1
- package/dist/tools/fallback-manage-tool-options.d.ts.map +0 -1
- package/dist/tools/fallback-manage-tools.d.ts.map +0 -1
- package/dist/tools/fallback-model-ref-parse.d.ts.map +0 -1
- package/dist/tools/fallback-provider-key-store.d.ts.map +0 -1
- package/dist/tools/fallback-system-config-view-tool.d.ts.map +0 -1
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js.map +0 -7
- package/dist/tools/mcp-control.d.ts.map +0 -1
- package/dist/tools/mcp-use.d.ts.map +0 -1
- package/dist/tools/one-shot-llm-tool.d.ts.map +0 -1
- package/dist/tools/plugin-manager.d.ts.map +0 -1
- package/dist/types/agent-bridge.d.ts.map +0 -1
- package/dist/types/attachment.d.ts.map +0 -1
- package/dist/types/autonomy.d.ts.map +0 -1
- package/dist/types/blocks.d.ts.map +0 -1
- package/dist/types/compactor.d.ts.map +0 -1
- package/dist/types/config/autonomy.d.ts.map +0 -1
- package/dist/types/config/context.d.ts.map +0 -1
- package/dist/types/config/fleet-chat.d.ts.map +0 -1
- package/dist/types/config/mcp-features.d.ts.map +0 -1
- package/dist/types/config/providers.d.ts.map +0 -1
- package/dist/types/config/root.d.ts.map +0 -1
- package/dist/types/config/runtime.d.ts.map +0 -1
- package/dist/types/config/skills-fleet-brain.d.ts.map +0 -1
- package/dist/types/config/tools.d.ts.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/context-evidence.d.ts.map +0 -1
- package/dist/types/context-window.d.ts.map +0 -1
- package/dist/types/council.d.ts.map +0 -1
- package/dist/types/default-config.d.ts.map +0 -1
- package/dist/types/design-kit.d.ts.map +0 -1
- package/dist/types/error-handler.d.ts.map +0 -1
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/file-event-record.d.ts.map +0 -1
- package/dist/types/hooks.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js.map +0 -7
- package/dist/types/input-reader.d.ts.map +0 -1
- package/dist/types/logger.d.ts.map +0 -1
- package/dist/types/memory.d.ts.map +0 -1
- package/dist/types/messages.d.ts.map +0 -1
- package/dist/types/mode-prompts.d.ts.map +0 -1
- package/dist/types/mode.d.ts.map +0 -1
- package/dist/types/models-registry.d.ts.map +0 -1
- package/dist/types/multi-agent.d.ts.map +0 -1
- package/dist/types/observability.d.ts.map +0 -1
- package/dist/types/one-shot-llm.d.ts.map +0 -1
- package/dist/types/path-resolver.d.ts.map +0 -1
- package/dist/types/permission.d.ts.map +0 -1
- package/dist/types/plugin.d.ts.map +0 -1
- package/dist/types/prompt-registry.d.ts.map +0 -1
- package/dist/types/prompt.d.ts.map +0 -1
- package/dist/types/provider-runner.d.ts.map +0 -1
- package/dist/types/provider.d.ts.map +0 -1
- package/dist/types/quota-regex.d.ts.map +0 -1
- package/dist/types/renderer.d.ts.map +0 -1
- package/dist/types/retry-policy.d.ts.map +0 -1
- package/dist/types/secret-scrubber.d.ts.map +0 -1
- package/dist/types/secret-vault.d.ts.map +0 -1
- package/dist/types/selector.d.ts.map +0 -1
- package/dist/types/session-markers.d.ts.map +0 -1
- package/dist/types/session-markers.js.map +0 -7
- package/dist/types/session-reader.d.ts.map +0 -1
- package/dist/types/session-rewinder.d.ts.map +0 -1
- package/dist/types/session.d.ts.map +0 -1
- package/dist/types/side-effect.d.ts.map +0 -1
- package/dist/types/skill.d.ts.map +0 -1
- package/dist/types/slash-command.d.ts.map +0 -1
- package/dist/types/spec.d.ts.map +0 -1
- package/dist/types/system-prompt-contributor.d.ts.map +0 -1
- package/dist/types/system-prompt.d.ts.map +0 -1
- package/dist/types/task-graph.d.ts.map +0 -1
- package/dist/types/token-counter.d.ts.map +0 -1
- package/dist/types/tool-executor.d.ts.map +0 -1
- package/dist/types/tool-markers.d.ts.map +0 -1
- package/dist/types/tool.d.ts.map +0 -1
- package/dist/types/utility-types.d.ts.map +0 -1
- package/dist/utils/assert-never.d.ts.map +0 -1
- package/dist/utils/atomic-write.d.ts.map +0 -1
- package/dist/utils/cache-key.d.ts.map +0 -1
- package/dist/utils/child-env.d.ts.map +0 -1
- package/dist/utils/color.d.ts.map +0 -1
- package/dist/utils/compaction-preview.d.ts.map +0 -1
- package/dist/utils/config-backup.d.ts.map +0 -1
- package/dist/utils/config-json.d.ts.map +0 -1
- package/dist/utils/connectivity.d.ts.map +0 -1
- package/dist/utils/context-breakdown.d.ts.map +0 -1
- package/dist/utils/context-evidence.d.ts.map +0 -1
- package/dist/utils/continuous-memory-profiler.d.ts.map +0 -1
- package/dist/utils/crash-shield.d.ts.map +0 -1
- package/dist/utils/deep-merge.d.ts.map +0 -1
- package/dist/utils/diff.d.ts.map +0 -1
- package/dist/utils/error.d.ts.map +0 -1
- package/dist/utils/error.js.map +0 -7
- package/dist/utils/expect-defined.d.ts.map +0 -1
- package/dist/utils/expect-defined.js.map +0 -7
- package/dist/utils/glob-expand.d.ts.map +0 -1
- package/dist/utils/glob-match.d.ts.map +0 -1
- package/dist/utils/heap-watchdog-types.d.ts.map +0 -1
- package/dist/utils/heap-watchdog.d.ts.map +0 -1
- package/dist/utils/heap-watchdog.js.map +0 -7
- package/dist/utils/incoming-images.d.ts.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -7
- package/dist/utils/instruction-file.d.ts.map +0 -1
- package/dist/utils/ip-guard.d.ts.map +0 -1
- package/dist/utils/json-repair.d.ts.map +0 -1
- package/dist/utils/json-schema-validate.d.ts.map +0 -1
- package/dist/utils/lru-cache.d.ts.map +0 -1
- package/dist/utils/memory-flight-recorder.d.ts.map +0 -1
- package/dist/utils/merge-custom-models.d.ts.map +0 -1
- package/dist/utils/merge-models-payload.d.ts.map +0 -1
- package/dist/utils/message-invariants.d.ts.map +0 -1
- package/dist/utils/newline-normalize.d.ts.map +0 -1
- package/dist/utils/perf-profile.d.ts.map +0 -1
- package/dist/utils/pid.d.ts.map +0 -1
- package/dist/utils/project-identity.d.ts.map +0 -1
- package/dist/utils/project-watch.d.ts.map +0 -1
- package/dist/utils/regex-guard.d.ts.map +0 -1
- package/dist/utils/safe-json.d.ts.map +0 -1
- package/dist/utils/sage-output-block.d.ts.map +0 -1
- package/dist/utils/session-scoped-path.d.ts.map +0 -1
- package/dist/utils/sleep.d.ts.map +0 -1
- package/dist/utils/slug.d.ts.map +0 -1
- package/dist/utils/socket-path.d.ts.map +0 -1
- package/dist/utils/sqlite-warning.d.ts.map +0 -1
- package/dist/utils/string.d.ts.map +0 -1
- package/dist/utils/task-format.d.ts.map +0 -1
- package/dist/utils/term.d.ts.map +0 -1
- package/dist/utils/todos-format.d.ts.map +0 -1
- package/dist/utils/token-estimate.d.ts.map +0 -1
- package/dist/utils/tool-description-mode.d.ts.map +0 -1
- package/dist/utils/tool-name.d.ts.map +0 -1
- package/dist/utils/tool-output-serializer.d.ts.map +0 -1
- package/dist/utils/tool-result-render-mode.d.ts.map +0 -1
- package/dist/utils/tool-subject.d.ts.map +0 -1
- package/dist/utils/tool-wire-compact.d.ts.map +0 -1
- package/dist/utils/tree-kill.d.ts.map +0 -1
- package/dist/utils/tree-kill.js.map +0 -7
- package/dist/utils/ulid.d.ts.map +0 -1
- package/dist/utils/walk-ignore.d.ts.map +0 -1
- package/dist/utils/wstack-paths.d.ts.map +0 -1
- package/dist/worktree/index.d.ts.map +0 -1
- package/dist/worktree/index.js.map +0 -7
- package/dist/worktree/worktree-git.d.ts.map +0 -1
- package/dist/worktree/worktree-managed-ops.d.ts.map +0 -1
- package/dist/worktree/worktree-manager.d.ts.map +0 -1
- package/dist/worktree/worktree-types.d.ts.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/coordination/mailbox-project-server.ts
|
|
4
|
+
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
4
5
|
import * as fs5 from "node:fs";
|
|
5
6
|
import * as fsPromises from "node:fs/promises";
|
|
6
7
|
import * as net from "node:net";
|
|
@@ -250,6 +251,127 @@ function makePatternMatcher(pattern) {
|
|
|
250
251
|
return (e) => e === pattern;
|
|
251
252
|
}
|
|
252
253
|
|
|
254
|
+
// src/utils/atomic-write.ts
|
|
255
|
+
import {
|
|
256
|
+
createPersistencePrimitives
|
|
257
|
+
} from "@wrongstack/persistence";
|
|
258
|
+
|
|
259
|
+
// src/types/errors.ts
|
|
260
|
+
var ERROR_CODES = {
|
|
261
|
+
// Provider
|
|
262
|
+
PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED",
|
|
263
|
+
PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
|
|
264
|
+
PROVIDER_OVERLOADED: "PROVIDER_OVERLOADED",
|
|
265
|
+
PROVIDER_INVALID_REQUEST: "PROVIDER_INVALID_REQUEST",
|
|
266
|
+
PROVIDER_SERVER_ERROR: "PROVIDER_SERVER_ERROR",
|
|
267
|
+
PROVIDER_NETWORK_ERROR: "PROVIDER_NETWORK_ERROR",
|
|
268
|
+
PROVIDER_CONTEXT_OVERFLOW: "PROVIDER_CONTEXT_OVERFLOW",
|
|
269
|
+
// Tool
|
|
270
|
+
TOOL_NOT_FOUND: "TOOL_NOT_FOUND",
|
|
271
|
+
TOOL_PERMISSION_DENIED: "TOOL_PERMISSION_DENIED",
|
|
272
|
+
TOOL_EXECUTION_FAILED: "TOOL_EXECUTION_FAILED",
|
|
273
|
+
TOOL_TIMEOUT: "TOOL_TIMEOUT",
|
|
274
|
+
TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID",
|
|
275
|
+
// Config
|
|
276
|
+
CONFIG_INVALID: "CONFIG_INVALID",
|
|
277
|
+
CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
|
|
278
|
+
CONFIG_PARSE_FAILED: "CONFIG_PARSE_FAILED",
|
|
279
|
+
CONFIG_MIGRATION_NEEDED: "CONFIG_MIGRATION_NEEDED",
|
|
280
|
+
// Plugin
|
|
281
|
+
PLUGIN_LOAD_FAILED: "PLUGIN_LOAD_FAILED",
|
|
282
|
+
PLUGIN_API_MISMATCH: "PLUGIN_API_MISMATCH",
|
|
283
|
+
PLUGIN_MISSING_DEPENDENCY: "PLUGIN_MISSING_DEPENDENCY",
|
|
284
|
+
// Agent
|
|
285
|
+
AGENT_ITERATION_LIMIT: "AGENT_ITERATION_LIMIT",
|
|
286
|
+
AGENT_CONTEXT_OVERFLOW: "AGENT_CONTEXT_OVERFLOW",
|
|
287
|
+
AGENT_ABORTED: "AGENT_ABORTED",
|
|
288
|
+
AGENT_RUN_FAILED: "AGENT_RUN_FAILED",
|
|
289
|
+
// Session
|
|
290
|
+
SESSION_NOT_FOUND: "SESSION_NOT_FOUND",
|
|
291
|
+
SESSION_CORRUPTED: "SESSION_CORRUPTED",
|
|
292
|
+
SESSION_WRITE_FAILED: "SESSION_WRITE_FAILED",
|
|
293
|
+
// Container / Registry
|
|
294
|
+
CONTAINER_TOKEN_ALREADY_BOUND: "CONTAINER_TOKEN_ALREADY_BOUND",
|
|
295
|
+
CONTAINER_TOKEN_NOT_BOUND: "CONTAINER_TOKEN_NOT_BOUND",
|
|
296
|
+
CONTAINER_CIRCULAR_DEPENDENCY: "CONTAINER_CIRCULAR_DEPENDENCY",
|
|
297
|
+
REGISTRY_DUPLICATE: "REGISTRY_DUPLICATE",
|
|
298
|
+
REGISTRY_NOT_FOUND: "REGISTRY_NOT_FOUND",
|
|
299
|
+
REGISTRY_INVALID: "REGISTRY_INVALID",
|
|
300
|
+
// File system
|
|
301
|
+
FS_READ_FAILED: "FS_READ_FAILED",
|
|
302
|
+
FS_WRITE_FAILED: "FS_WRITE_FAILED",
|
|
303
|
+
FS_MKDIR_FAILED: "FS_MKDIR_FAILED",
|
|
304
|
+
FS_DELETE_FAILED: "FS_DELETE_FAILED",
|
|
305
|
+
FS_ATOMIC_WRITE_FAILED: "FS_ATOMIC_WRITE_FAILED",
|
|
306
|
+
// SDD (Spec-Driven Development)
|
|
307
|
+
SDD_VALIDATION_FAILED: "SDD_VALIDATION_FAILED",
|
|
308
|
+
SDD_PARSE_FAILED: "SDD_PARSE_FAILED",
|
|
309
|
+
SDD_INVALID_STATE: "SDD_INVALID_STATE",
|
|
310
|
+
SDD_NOT_READY: "SDD_NOT_READY",
|
|
311
|
+
// General
|
|
312
|
+
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
313
|
+
PARSE_FAILED: "PARSE_FAILED",
|
|
314
|
+
UNKNOWN: "UNKNOWN"
|
|
315
|
+
};
|
|
316
|
+
var WrongStackError = class extends Error {
|
|
317
|
+
code;
|
|
318
|
+
subsystem;
|
|
319
|
+
severity;
|
|
320
|
+
recoverable;
|
|
321
|
+
context;
|
|
322
|
+
constructor(opts) {
|
|
323
|
+
super(opts.message, { cause: opts.cause });
|
|
324
|
+
this.name = "WrongStackError";
|
|
325
|
+
this.code = opts.code;
|
|
326
|
+
this.subsystem = opts.subsystem;
|
|
327
|
+
this.severity = opts.severity ?? "error";
|
|
328
|
+
this.recoverable = opts.recoverable ?? false;
|
|
329
|
+
this.context = opts.context;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Render a one-line user-facing description.
|
|
333
|
+
* Subclasses should override for domain-specific formatting.
|
|
334
|
+
*/
|
|
335
|
+
describe() {
|
|
336
|
+
const ctx = this.context ? ` ${formatContext(this.context)}` : "";
|
|
337
|
+
return `${this.code}: ${this.message}${ctx}`;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
function formatContext(ctx) {
|
|
341
|
+
const parts = Object.entries(ctx).filter(([, v]) => v !== void 0).slice(0, 3).map(([k, v]) => `${k}=${String(v)}`);
|
|
342
|
+
return parts.length > 0 ? `[${parts.join(" ")}]` : "";
|
|
343
|
+
}
|
|
344
|
+
var FsError = class extends WrongStackError {
|
|
345
|
+
path;
|
|
346
|
+
constructor(opts) {
|
|
347
|
+
super({
|
|
348
|
+
message: opts.message,
|
|
349
|
+
code: opts.code,
|
|
350
|
+
subsystem: "fs",
|
|
351
|
+
severity: "error",
|
|
352
|
+
recoverable: opts.code !== ERROR_CODES.FS_READ_FAILED,
|
|
353
|
+
context: { path: opts.path, ...opts.context },
|
|
354
|
+
cause: opts.cause
|
|
355
|
+
});
|
|
356
|
+
this.name = "FsError";
|
|
357
|
+
this.path = opts.path;
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
// src/utils/atomic-write.ts
|
|
362
|
+
var primitives = createPersistencePrimitives({
|
|
363
|
+
createLockTimeoutError: ({ targetPath, timeoutMs }) => new FsError({
|
|
364
|
+
message: `Timed out waiting for file lock: ${targetPath}`,
|
|
365
|
+
code: "FS_ATOMIC_WRITE_FAILED",
|
|
366
|
+
path: targetPath,
|
|
367
|
+
context: { timeoutMs }
|
|
368
|
+
})
|
|
369
|
+
});
|
|
370
|
+
var atomicWrite = primitives.atomicWrite;
|
|
371
|
+
var atomicReplaceWithWriter = primitives.atomicReplaceWithWriter;
|
|
372
|
+
var ensureDir = primitives.ensureDir;
|
|
373
|
+
var withFileLock = primitives.withFileLock;
|
|
374
|
+
|
|
253
375
|
// src/utils/heap-watchdog.ts
|
|
254
376
|
import * as fs from "node:fs";
|
|
255
377
|
import * as fsp2 from "node:fs/promises";
|
|
@@ -770,7 +892,7 @@ function startHeapWatchdog(opts = {}) {
|
|
|
770
892
|
dirReady = true;
|
|
771
893
|
}
|
|
772
894
|
await fsp2.appendFile(targetPath, `${line}
|
|
773
|
-
`, "utf8");
|
|
895
|
+
`, { encoding: "utf8", mode: 384 });
|
|
774
896
|
});
|
|
775
897
|
const drainWrites = async (firstLine) => {
|
|
776
898
|
let line = firstLine;
|
|
@@ -956,6 +1078,72 @@ function useDaemonPerfDefaults() {
|
|
|
956
1078
|
daemonDefaults = true;
|
|
957
1079
|
}
|
|
958
1080
|
|
|
1081
|
+
// src/coordination/mailbox-credential-store.ts
|
|
1082
|
+
import * as crypto from "node:crypto";
|
|
1083
|
+
var CREDENTIAL_STORE_FILE = "_mailbox_credentials.json";
|
|
1084
|
+
var MAX_CREDENTIAL_TTL = {
|
|
1085
|
+
agent: 7 * 24 * 60 * 60 * 1e3,
|
|
1086
|
+
// 7 days
|
|
1087
|
+
operator: 24 * 60 * 60 * 1e3,
|
|
1088
|
+
// 24 hours
|
|
1089
|
+
service: 30 * 24 * 60 * 60 * 1e3
|
|
1090
|
+
// 30 days
|
|
1091
|
+
};
|
|
1092
|
+
var ROTATION_OVERLAP_MS = 60 * 60 * 1e3;
|
|
1093
|
+
function createMailboxCredential(opts, now = Date.now()) {
|
|
1094
|
+
const ttlMs = Math.min(opts.ttlMs, MAX_CREDENTIAL_TTL[opts.kind]);
|
|
1095
|
+
const credentialId = crypto.randomUUID();
|
|
1096
|
+
const secret = crypto.randomBytes(32).toString("hex");
|
|
1097
|
+
const verifierKey = crypto.createHash("sha256").update(secret).digest();
|
|
1098
|
+
const verifier = crypto.createHmac("sha256", verifierKey).update(credentialId).digest("hex");
|
|
1099
|
+
return {
|
|
1100
|
+
credential: {
|
|
1101
|
+
credentialId,
|
|
1102
|
+
verifier,
|
|
1103
|
+
verifierAlgorithm: "hmac-sha256",
|
|
1104
|
+
principalId: opts.principalId,
|
|
1105
|
+
projectId: opts.projectId,
|
|
1106
|
+
capabilities: opts.capabilities,
|
|
1107
|
+
kind: opts.kind,
|
|
1108
|
+
issuedAt: new Date(now).toISOString(),
|
|
1109
|
+
expiresAt: new Date(now + ttlMs).toISOString(),
|
|
1110
|
+
notBefore: opts.notBefore?.toISOString(),
|
|
1111
|
+
status: "active",
|
|
1112
|
+
statusChangedAt: new Date(now).toISOString(),
|
|
1113
|
+
supersedes: opts.supersedes,
|
|
1114
|
+
lastModifiedBy: opts.issuedBy
|
|
1115
|
+
},
|
|
1116
|
+
secret
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
function redactMailboxCredential(credential) {
|
|
1120
|
+
const { verifier: _verifier, verifierAlgorithm: _algorithm, ...rest } = credential;
|
|
1121
|
+
return rest;
|
|
1122
|
+
}
|
|
1123
|
+
function verifyMailboxCredential(credential, secret, now = Date.now()) {
|
|
1124
|
+
if (credential === void 0) {
|
|
1125
|
+
return { valid: false, reason: "credential not found" };
|
|
1126
|
+
}
|
|
1127
|
+
const rotationStillValid = credential.status === "rotated_out" && credential.rotationValidUntil !== void 0 && new Date(credential.rotationValidUntil).getTime() >= now;
|
|
1128
|
+
if (credential.status !== "active" && !rotationStillValid) {
|
|
1129
|
+
return { valid: false, reason: `credential is ${credential.status}`, credential };
|
|
1130
|
+
}
|
|
1131
|
+
if (new Date(credential.expiresAt).getTime() <= now) {
|
|
1132
|
+
return { valid: false, reason: "credential expired", credential };
|
|
1133
|
+
}
|
|
1134
|
+
if (credential.notBefore !== void 0 && new Date(credential.notBefore).getTime() > now) {
|
|
1135
|
+
return { valid: false, reason: "credential not yet valid", credential };
|
|
1136
|
+
}
|
|
1137
|
+
const verifierKey = crypto.createHash("sha256").update(secret).digest();
|
|
1138
|
+
const expected = crypto.createHmac("sha256", verifierKey).update(credential.credentialId).digest("hex");
|
|
1139
|
+
const actualBytes = Buffer.from(credential.verifier, "hex");
|
|
1140
|
+
const expectedBytes = Buffer.from(expected, "hex");
|
|
1141
|
+
if (actualBytes.length !== expectedBytes.length || !crypto.timingSafeEqual(actualBytes, expectedBytes)) {
|
|
1142
|
+
return { valid: false, reason: "invalid secret" };
|
|
1143
|
+
}
|
|
1144
|
+
return { valid: true, credential };
|
|
1145
|
+
}
|
|
1146
|
+
|
|
959
1147
|
// src/coordination/mailbox-events.ts
|
|
960
1148
|
var MailboxEventEmitter = class {
|
|
961
1149
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -984,7 +1172,7 @@ var MailboxEventEmitter = class {
|
|
|
984
1172
|
};
|
|
985
1173
|
|
|
986
1174
|
// src/coordination/mailbox-project-server-endpoint.ts
|
|
987
|
-
import { createHash } from "node:crypto";
|
|
1175
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
988
1176
|
import * as fs2 from "node:fs";
|
|
989
1177
|
import * as os2 from "node:os";
|
|
990
1178
|
import * as path4 from "node:path";
|
|
@@ -997,7 +1185,7 @@ import {
|
|
|
997
1185
|
} from "@wrongstack/persistence";
|
|
998
1186
|
|
|
999
1187
|
// src/coordination/mailbox-project-server-protocol.ts
|
|
1000
|
-
var MAILBOX_PROJECT_SERVER_PROTOCOL_VERSION =
|
|
1188
|
+
var MAILBOX_PROJECT_SERVER_PROTOCOL_VERSION = 4;
|
|
1001
1189
|
var MAILBOX_PROJECT_SERVER_MAX_FRAME_CHARS = 16 * 1024 * 1024;
|
|
1002
1190
|
var MAILBOX_SERVER_OPERATION_NAMES = {
|
|
1003
1191
|
ping: true,
|
|
@@ -1113,7 +1301,7 @@ function normalizeLocalPath(value) {
|
|
|
1113
1301
|
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
1114
1302
|
}
|
|
1115
1303
|
function mailboxProjectServerKey(projectDir2) {
|
|
1116
|
-
return
|
|
1304
|
+
return createHash2("sha256").update(normalizeLocalPath(projectDir2)).digest("hex").slice(0, 24);
|
|
1117
1305
|
}
|
|
1118
1306
|
function mailboxProjectServerEndpoint(projectDir2) {
|
|
1119
1307
|
const key = mailboxProjectServerKey(projectDir2);
|
|
@@ -1141,19 +1329,6 @@ import { randomUUID as randomUUID2 } from "node:crypto";
|
|
|
1141
1329
|
import * as fs4 from "node:fs";
|
|
1142
1330
|
import * as path6 from "node:path";
|
|
1143
1331
|
|
|
1144
|
-
// src/coordination/mailbox-constants.ts
|
|
1145
|
-
var AGENT_STALE_MS = 6e4;
|
|
1146
|
-
var CLIENT_STALE_MS = 6e4;
|
|
1147
|
-
var HEARTBEAT_THROTTLE_MS = 5e3;
|
|
1148
|
-
var LINE_SEPARATOR = "\n";
|
|
1149
|
-
var AUTO_COMPACT_INTERVAL_MS = 3e5;
|
|
1150
|
-
var AUTO_COMPACT_READ_MAX_AGE_MS = 6e5;
|
|
1151
|
-
var AUTO_COMPACT_DEFAULT_TTL_MS = 864e5;
|
|
1152
|
-
var AUTO_COMPACT_TYPE_TTL_MS = {
|
|
1153
|
-
status: 18e5
|
|
1154
|
-
// 30 min
|
|
1155
|
-
};
|
|
1156
|
-
|
|
1157
1332
|
// src/coordination/global-mailbox-completion.ts
|
|
1158
1333
|
function isMailboxMessageProjection(msg) {
|
|
1159
1334
|
if (!("recipientState" in msg)) return false;
|
|
@@ -1171,6 +1346,19 @@ function isMessageCompletedForActor(msg, actorId) {
|
|
|
1171
1346
|
return msg.completed === true;
|
|
1172
1347
|
}
|
|
1173
1348
|
|
|
1349
|
+
// src/coordination/mailbox-constants.ts
|
|
1350
|
+
var AGENT_STALE_MS = 6e4;
|
|
1351
|
+
var CLIENT_STALE_MS = 6e4;
|
|
1352
|
+
var HEARTBEAT_THROTTLE_MS = 5e3;
|
|
1353
|
+
var LINE_SEPARATOR = "\n";
|
|
1354
|
+
var AUTO_COMPACT_INTERVAL_MS = 3e5;
|
|
1355
|
+
var AUTO_COMPACT_READ_MAX_AGE_MS = 6e5;
|
|
1356
|
+
var AUTO_COMPACT_DEFAULT_TTL_MS = 864e5;
|
|
1357
|
+
var AUTO_COMPACT_TYPE_TTL_MS = {
|
|
1358
|
+
status: 18e5
|
|
1359
|
+
// 30 min
|
|
1360
|
+
};
|
|
1361
|
+
|
|
1174
1362
|
// src/coordination/mailbox-types.ts
|
|
1175
1363
|
function mailboxIdentityBase(agentId) {
|
|
1176
1364
|
return agentId.split(/[@#]/, 1)[0].trim().toLowerCase();
|
|
@@ -1227,161 +1415,6 @@ function isMailboxReceiptRecordV2(value) {
|
|
|
1227
1415
|
return true;
|
|
1228
1416
|
}
|
|
1229
1417
|
|
|
1230
|
-
// src/coordination/mailbox-receipt-folding.ts
|
|
1231
|
-
function isFanOutRecipient(to) {
|
|
1232
|
-
if (to === "*") return true;
|
|
1233
|
-
if (to.startsWith("@session:")) return true;
|
|
1234
|
-
return !to.includes("@") && !to.includes("#");
|
|
1235
|
-
}
|
|
1236
|
-
function materializeMessage(msg, msgReceipts) {
|
|
1237
|
-
const recipientState = foldRecipientState(msg, msgReceipts);
|
|
1238
|
-
const legacyGlobalCompletion = classifyLegacyCompletion(msg, msgReceipts);
|
|
1239
|
-
return {
|
|
1240
|
-
...msg,
|
|
1241
|
-
recipientState,
|
|
1242
|
-
...legacyGlobalCompletion ? { legacyGlobalCompletion: true } : {}
|
|
1243
|
-
};
|
|
1244
|
-
}
|
|
1245
|
-
function foldRecipientState(msg, v2Receipts) {
|
|
1246
|
-
const state = {};
|
|
1247
|
-
for (const [actorId, readAt] of Object.entries(msg.readBy)) {
|
|
1248
|
-
state[actorId] = { actorId, readAt };
|
|
1249
|
-
}
|
|
1250
|
-
if (msg.completed && msg.completedBy && !isFanOutRecipient(msg.to)) {
|
|
1251
|
-
const existing = state[msg.completedBy] ?? { actorId: msg.completedBy };
|
|
1252
|
-
state[msg.completedBy] = {
|
|
1253
|
-
...existing,
|
|
1254
|
-
completedAt: msg.completedAt ?? msg.timestamp,
|
|
1255
|
-
completedBy: msg.completedBy,
|
|
1256
|
-
...msg.outcome !== void 0 ? { outcome: msg.outcome } : {}
|
|
1257
|
-
};
|
|
1258
|
-
}
|
|
1259
|
-
const sorted = [...v2Receipts].sort((a, b) => a.timestamp.localeCompare(b.timestamp));
|
|
1260
|
-
for (const receipt of sorted) {
|
|
1261
|
-
const actorId = receipt.actorId;
|
|
1262
|
-
const existing = state[actorId] ?? { actorId };
|
|
1263
|
-
const readAt = existing.readAt ?? (receipt.read === true ? receipt.timestamp : void 0);
|
|
1264
|
-
let completedAt = existing.completedAt;
|
|
1265
|
-
let completedBy = existing.completedBy;
|
|
1266
|
-
if (receipt.completed === true) {
|
|
1267
|
-
completedAt = receipt.timestamp;
|
|
1268
|
-
completedBy = actorId;
|
|
1269
|
-
} else if (receipt.completed === false) {
|
|
1270
|
-
completedAt = void 0;
|
|
1271
|
-
completedBy = void 0;
|
|
1272
|
-
}
|
|
1273
|
-
const outcome = receipt.outcome !== void 0 ? receipt.outcome : existing.outcome;
|
|
1274
|
-
state[actorId] = { actorId, readAt, completedAt, completedBy, outcome };
|
|
1275
|
-
}
|
|
1276
|
-
return state;
|
|
1277
|
-
}
|
|
1278
|
-
function classifyLegacyCompletion(msg, v2Receipts) {
|
|
1279
|
-
if (!msg.completed) return false;
|
|
1280
|
-
if (v2Receipts.some((r) => r.completed === true)) return false;
|
|
1281
|
-
return isFanOutRecipient(msg.to);
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
|
-
// src/coordination/mailbox-retention-state.ts
|
|
1285
|
-
function resolveMailboxRetentionState(message, agentStatuses) {
|
|
1286
|
-
const projection = message;
|
|
1287
|
-
if (projection.legacyGlobalCompletion) {
|
|
1288
|
-
return { completed: true, completedAt: message.completedAt ?? message.timestamp };
|
|
1289
|
-
}
|
|
1290
|
-
const recipientState = projection.recipientState;
|
|
1291
|
-
if (recipientState === void 0) {
|
|
1292
|
-
return message.completed ? { completed: true, completedAt: message.completedAt ?? message.timestamp } : { completed: false };
|
|
1293
|
-
}
|
|
1294
|
-
const relevantRecipients = resolveRelevantRecipients(message, recipientState, agentStatuses);
|
|
1295
|
-
if (relevantRecipients.length === 0) return { completed: false };
|
|
1296
|
-
const completionTimes = [];
|
|
1297
|
-
for (const actorId of relevantRecipients) {
|
|
1298
|
-
const completedAt = recipientState[actorId]?.completedAt;
|
|
1299
|
-
if (completedAt === void 0) return { completed: false };
|
|
1300
|
-
completionTimes.push(completedAt);
|
|
1301
|
-
}
|
|
1302
|
-
return {
|
|
1303
|
-
completed: true,
|
|
1304
|
-
// Retention starts only after the last intended recipient completed.
|
|
1305
|
-
completedAt: completionTimes.reduce((latest, time) => time > latest ? time : latest)
|
|
1306
|
-
};
|
|
1307
|
-
}
|
|
1308
|
-
function projectMailboxCompletion(message, actorId, agentStatuses) {
|
|
1309
|
-
const projection = message;
|
|
1310
|
-
let state;
|
|
1311
|
-
if (actorId === void 0) {
|
|
1312
|
-
state = resolveMailboxRetentionState(message, agentStatuses);
|
|
1313
|
-
} else if (projection.legacyGlobalCompletion) {
|
|
1314
|
-
state = { completed: true, completedAt: message.completedAt ?? message.timestamp };
|
|
1315
|
-
} else if (projection.recipientState !== void 0) {
|
|
1316
|
-
const completedAt = projection.recipientState[actorId]?.completedAt;
|
|
1317
|
-
state = completedAt === void 0 ? { completed: false } : { completed: true, completedAt };
|
|
1318
|
-
} else {
|
|
1319
|
-
state = message.completed ? { completed: true, completedAt: message.completedAt ?? message.timestamp } : { completed: false };
|
|
1320
|
-
}
|
|
1321
|
-
const result = {
|
|
1322
|
-
...projection,
|
|
1323
|
-
completed: state.completed,
|
|
1324
|
-
readBy: { ...message.readBy }
|
|
1325
|
-
};
|
|
1326
|
-
if (state.completedAt === void 0) delete result.completedAt;
|
|
1327
|
-
else result.completedAt = state.completedAt;
|
|
1328
|
-
return result;
|
|
1329
|
-
}
|
|
1330
|
-
function resolveRelevantRecipients(message, recipientState, agentStatuses) {
|
|
1331
|
-
const statuses = agentStatuses ?? [];
|
|
1332
|
-
const receiptActors = Object.keys(recipientState);
|
|
1333
|
-
if (message.to === "*") {
|
|
1334
|
-
if (statuses.length === 0) return [];
|
|
1335
|
-
const registeredRecipients = statuses.filter((status) => isMailboxMessageVisibleTo(message, status.agentId, status.role)).map((status) => status.agentId);
|
|
1336
|
-
return [.../* @__PURE__ */ new Set([...registeredRecipients, ...receiptActors])];
|
|
1337
|
-
}
|
|
1338
|
-
if (message.to.startsWith("@session:")) {
|
|
1339
|
-
if (statuses.length === 0) return [];
|
|
1340
|
-
const sessionId = message.to.slice("@session:".length);
|
|
1341
|
-
const registeredRecipients = statuses.filter(
|
|
1342
|
-
(status) => status.sessionId === sessionId && isMailboxMessageVisibleTo(message, status.agentId, status.role)
|
|
1343
|
-
).map((status) => status.agentId);
|
|
1344
|
-
return [.../* @__PURE__ */ new Set([...registeredRecipients, ...receiptActors])];
|
|
1345
|
-
}
|
|
1346
|
-
if (message.to.includes("@")) return [message.to];
|
|
1347
|
-
if (statuses.length === 0) return [];
|
|
1348
|
-
const aliasRecipients = statuses.filter(
|
|
1349
|
-
(status) => (status.role?.toLowerCase() === message.to.toLowerCase() || mailboxIdentityBase(status.agentId) === message.to.toLowerCase()) && isMailboxMessageVisibleTo(message, status.agentId, status.role)
|
|
1350
|
-
).map((status) => status.agentId);
|
|
1351
|
-
return [.../* @__PURE__ */ new Set([...aliasRecipients, ...receiptActors])];
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
// src/coordination/mailbox-status-mappers.ts
|
|
1355
|
-
function mapRegisteredAgentsToStatuses(registry, now, staleMs) {
|
|
1356
|
-
return Array.from(registry.values()).map((agent) => ({
|
|
1357
|
-
agentId: agent.agentId,
|
|
1358
|
-
name: agent.name,
|
|
1359
|
-
role: agent.role,
|
|
1360
|
-
sessionId: agent.sessionId,
|
|
1361
|
-
status: agent.status,
|
|
1362
|
-
currentTool: agent.currentTool,
|
|
1363
|
-
currentTask: agent.currentTask,
|
|
1364
|
-
iterations: agent.iterations,
|
|
1365
|
-
toolCalls: agent.toolCalls,
|
|
1366
|
-
lastActivityAt: agent.lastSeenAt,
|
|
1367
|
-
lastSeenAt: agent.lastSeenAt,
|
|
1368
|
-
online: now - new Date(agent.lastSeenAt).getTime() < staleMs,
|
|
1369
|
-
pid: agent.pid,
|
|
1370
|
-
source: agent.source
|
|
1371
|
-
})).sort((a, b) => b.lastSeenAt.localeCompare(a.lastSeenAt));
|
|
1372
|
-
}
|
|
1373
|
-
function mapRegisteredClientsToStatuses(registry, now, staleMs) {
|
|
1374
|
-
return Array.from(registry.values()).map((client) => ({
|
|
1375
|
-
clientId: client.clientId,
|
|
1376
|
-
name: client.name,
|
|
1377
|
-
source: client.source,
|
|
1378
|
-
sessionId: client.sessionId,
|
|
1379
|
-
lastSeenAt: client.lastSeenAt,
|
|
1380
|
-
online: now - new Date(client.lastSeenAt).getTime() < staleMs,
|
|
1381
|
-
pid: client.pid
|
|
1382
|
-
})).sort((a, b) => b.lastSeenAt.localeCompare(a.lastSeenAt));
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
1418
|
// src/coordination/mailbox-message-codec.ts
|
|
1386
1419
|
var MESSAGE_TYPES = /* @__PURE__ */ new Set([
|
|
1387
1420
|
"note",
|
|
@@ -1544,6 +1577,161 @@ function applyAckToMessage(msg, ack) {
|
|
|
1544
1577
|
}
|
|
1545
1578
|
}
|
|
1546
1579
|
|
|
1580
|
+
// src/coordination/mailbox-receipt-folding.ts
|
|
1581
|
+
function isFanOutRecipient(to) {
|
|
1582
|
+
if (to === "*") return true;
|
|
1583
|
+
if (to.startsWith("@session:")) return true;
|
|
1584
|
+
return !to.includes("@") && !to.includes("#");
|
|
1585
|
+
}
|
|
1586
|
+
function materializeMessage(msg, msgReceipts) {
|
|
1587
|
+
const recipientState = foldRecipientState(msg, msgReceipts);
|
|
1588
|
+
const legacyGlobalCompletion = classifyLegacyCompletion(msg, msgReceipts);
|
|
1589
|
+
return {
|
|
1590
|
+
...msg,
|
|
1591
|
+
recipientState,
|
|
1592
|
+
...legacyGlobalCompletion ? { legacyGlobalCompletion: true } : {}
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
function foldRecipientState(msg, v2Receipts) {
|
|
1596
|
+
const state = {};
|
|
1597
|
+
for (const [actorId, readAt] of Object.entries(msg.readBy)) {
|
|
1598
|
+
state[actorId] = { actorId, readAt };
|
|
1599
|
+
}
|
|
1600
|
+
if (msg.completed && msg.completedBy && !isFanOutRecipient(msg.to)) {
|
|
1601
|
+
const existing = state[msg.completedBy] ?? { actorId: msg.completedBy };
|
|
1602
|
+
state[msg.completedBy] = {
|
|
1603
|
+
...existing,
|
|
1604
|
+
completedAt: msg.completedAt ?? msg.timestamp,
|
|
1605
|
+
completedBy: msg.completedBy,
|
|
1606
|
+
...msg.outcome !== void 0 ? { outcome: msg.outcome } : {}
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
const sorted = [...v2Receipts].sort((a, b) => a.timestamp.localeCompare(b.timestamp));
|
|
1610
|
+
for (const receipt of sorted) {
|
|
1611
|
+
const actorId = receipt.actorId;
|
|
1612
|
+
const existing = state[actorId] ?? { actorId };
|
|
1613
|
+
const readAt = existing.readAt ?? (receipt.read === true ? receipt.timestamp : void 0);
|
|
1614
|
+
let completedAt = existing.completedAt;
|
|
1615
|
+
let completedBy = existing.completedBy;
|
|
1616
|
+
if (receipt.completed === true) {
|
|
1617
|
+
completedAt = receipt.timestamp;
|
|
1618
|
+
completedBy = actorId;
|
|
1619
|
+
} else if (receipt.completed === false) {
|
|
1620
|
+
completedAt = void 0;
|
|
1621
|
+
completedBy = void 0;
|
|
1622
|
+
}
|
|
1623
|
+
const outcome = receipt.outcome !== void 0 ? receipt.outcome : existing.outcome;
|
|
1624
|
+
state[actorId] = { actorId, readAt, completedAt, completedBy, outcome };
|
|
1625
|
+
}
|
|
1626
|
+
return state;
|
|
1627
|
+
}
|
|
1628
|
+
function classifyLegacyCompletion(msg, v2Receipts) {
|
|
1629
|
+
if (!msg.completed) return false;
|
|
1630
|
+
if (v2Receipts.some((r) => r.completed === true)) return false;
|
|
1631
|
+
return isFanOutRecipient(msg.to);
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
// src/coordination/mailbox-retention-state.ts
|
|
1635
|
+
function resolveMailboxRetentionState(message, agentStatuses) {
|
|
1636
|
+
const projection = message;
|
|
1637
|
+
if (projection.legacyGlobalCompletion) {
|
|
1638
|
+
return { completed: true, completedAt: message.completedAt ?? message.timestamp };
|
|
1639
|
+
}
|
|
1640
|
+
const recipientState = projection.recipientState;
|
|
1641
|
+
if (recipientState === void 0) {
|
|
1642
|
+
return message.completed ? { completed: true, completedAt: message.completedAt ?? message.timestamp } : { completed: false };
|
|
1643
|
+
}
|
|
1644
|
+
const relevantRecipients = resolveRelevantRecipients(message, recipientState, agentStatuses);
|
|
1645
|
+
if (relevantRecipients.length === 0) return { completed: false };
|
|
1646
|
+
const completionTimes = [];
|
|
1647
|
+
for (const actorId of relevantRecipients) {
|
|
1648
|
+
const completedAt = recipientState[actorId]?.completedAt;
|
|
1649
|
+
if (completedAt === void 0) return { completed: false };
|
|
1650
|
+
completionTimes.push(completedAt);
|
|
1651
|
+
}
|
|
1652
|
+
return {
|
|
1653
|
+
completed: true,
|
|
1654
|
+
// Retention starts only after the last intended recipient completed.
|
|
1655
|
+
completedAt: completionTimes.reduce((latest, time) => time > latest ? time : latest)
|
|
1656
|
+
};
|
|
1657
|
+
}
|
|
1658
|
+
function projectMailboxCompletion(message, actorId, agentStatuses) {
|
|
1659
|
+
const projection = message;
|
|
1660
|
+
let state;
|
|
1661
|
+
if (actorId === void 0) {
|
|
1662
|
+
state = resolveMailboxRetentionState(message, agentStatuses);
|
|
1663
|
+
} else if (projection.legacyGlobalCompletion) {
|
|
1664
|
+
state = { completed: true, completedAt: message.completedAt ?? message.timestamp };
|
|
1665
|
+
} else if (projection.recipientState !== void 0) {
|
|
1666
|
+
const completedAt = projection.recipientState[actorId]?.completedAt;
|
|
1667
|
+
state = completedAt === void 0 ? { completed: false } : { completed: true, completedAt };
|
|
1668
|
+
} else {
|
|
1669
|
+
state = message.completed ? { completed: true, completedAt: message.completedAt ?? message.timestamp } : { completed: false };
|
|
1670
|
+
}
|
|
1671
|
+
const result = {
|
|
1672
|
+
...projection,
|
|
1673
|
+
completed: state.completed,
|
|
1674
|
+
readBy: { ...message.readBy }
|
|
1675
|
+
};
|
|
1676
|
+
if (state.completedAt === void 0) delete result.completedAt;
|
|
1677
|
+
else result.completedAt = state.completedAt;
|
|
1678
|
+
return result;
|
|
1679
|
+
}
|
|
1680
|
+
function resolveRelevantRecipients(message, recipientState, agentStatuses) {
|
|
1681
|
+
const statuses = agentStatuses ?? [];
|
|
1682
|
+
const receiptActors = Object.keys(recipientState);
|
|
1683
|
+
if (message.to === "*") {
|
|
1684
|
+
if (statuses.length === 0) return [];
|
|
1685
|
+
const registeredRecipients = statuses.filter((status) => isMailboxMessageVisibleTo(message, status.agentId, status.role)).map((status) => status.agentId);
|
|
1686
|
+
return [.../* @__PURE__ */ new Set([...registeredRecipients, ...receiptActors])];
|
|
1687
|
+
}
|
|
1688
|
+
if (message.to.startsWith("@session:")) {
|
|
1689
|
+
if (statuses.length === 0) return [];
|
|
1690
|
+
const sessionId = message.to.slice("@session:".length);
|
|
1691
|
+
const registeredRecipients = statuses.filter(
|
|
1692
|
+
(status) => status.sessionId === sessionId && isMailboxMessageVisibleTo(message, status.agentId, status.role)
|
|
1693
|
+
).map((status) => status.agentId);
|
|
1694
|
+
return [.../* @__PURE__ */ new Set([...registeredRecipients, ...receiptActors])];
|
|
1695
|
+
}
|
|
1696
|
+
if (message.to.includes("@")) return [message.to];
|
|
1697
|
+
if (statuses.length === 0) return [];
|
|
1698
|
+
const aliasRecipients = statuses.filter(
|
|
1699
|
+
(status) => (status.role?.toLowerCase() === message.to.toLowerCase() || mailboxIdentityBase(status.agentId) === message.to.toLowerCase()) && isMailboxMessageVisibleTo(message, status.agentId, status.role)
|
|
1700
|
+
).map((status) => status.agentId);
|
|
1701
|
+
return [.../* @__PURE__ */ new Set([...aliasRecipients, ...receiptActors])];
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
// src/coordination/mailbox-status-mappers.ts
|
|
1705
|
+
function mapRegisteredAgentsToStatuses(registry, now, staleMs) {
|
|
1706
|
+
return Array.from(registry.values()).map((agent) => ({
|
|
1707
|
+
agentId: agent.agentId,
|
|
1708
|
+
name: agent.name,
|
|
1709
|
+
role: agent.role,
|
|
1710
|
+
sessionId: agent.sessionId,
|
|
1711
|
+
status: agent.status,
|
|
1712
|
+
currentTool: agent.currentTool,
|
|
1713
|
+
currentTask: agent.currentTask,
|
|
1714
|
+
iterations: agent.iterations,
|
|
1715
|
+
toolCalls: agent.toolCalls,
|
|
1716
|
+
lastActivityAt: agent.lastSeenAt,
|
|
1717
|
+
lastSeenAt: agent.lastSeenAt,
|
|
1718
|
+
online: now - new Date(agent.lastSeenAt).getTime() < staleMs,
|
|
1719
|
+
pid: agent.pid,
|
|
1720
|
+
source: agent.source
|
|
1721
|
+
})).sort((a, b) => b.lastSeenAt.localeCompare(a.lastSeenAt));
|
|
1722
|
+
}
|
|
1723
|
+
function mapRegisteredClientsToStatuses(registry, now, staleMs) {
|
|
1724
|
+
return Array.from(registry.values()).map((client) => ({
|
|
1725
|
+
clientId: client.clientId,
|
|
1726
|
+
name: client.name,
|
|
1727
|
+
source: client.source,
|
|
1728
|
+
sessionId: client.sessionId,
|
|
1729
|
+
lastSeenAt: client.lastSeenAt,
|
|
1730
|
+
online: now - new Date(client.lastSeenAt).getTime() < staleMs,
|
|
1731
|
+
pid: client.pid
|
|
1732
|
+
})).sort((a, b) => b.lastSeenAt.localeCompare(a.lastSeenAt));
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1547
1735
|
// src/coordination/sqlite-mailbox-compaction.ts
|
|
1548
1736
|
async function purgeStale(ctx, options) {
|
|
1549
1737
|
const completedMaxAgeMs = options?.completedMaxAgeMs ?? 864e5;
|
|
@@ -1627,67 +1815,63 @@ async function autoCompact(ctx, options) {
|
|
|
1627
1815
|
};
|
|
1628
1816
|
}
|
|
1629
1817
|
|
|
1630
|
-
// src/coordination/mailbox-credential-
|
|
1631
|
-
|
|
1632
|
-
var
|
|
1633
|
-
var
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
}
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
}
|
|
1668
|
-
function verifyMailboxCredential(credential, secret, now = Date.now()) {
|
|
1669
|
-
if (credential === void 0) {
|
|
1670
|
-
return { valid: false, reason: "credential not found" };
|
|
1671
|
-
}
|
|
1672
|
-
const rotationStillValid = credential.status === "rotated_out" && credential.rotationValidUntil !== void 0 && new Date(credential.rotationValidUntil).getTime() >= now;
|
|
1673
|
-
if (credential.status !== "active" && !rotationStillValid) {
|
|
1674
|
-
return { valid: false, reason: `credential is ${credential.status}`, credential };
|
|
1818
|
+
// src/coordination/mailbox-credential-throttle.ts
|
|
1819
|
+
var CREDENTIAL_VERIFY_MAX_FAILURES = 10;
|
|
1820
|
+
var CREDENTIAL_VERIFY_WINDOW_MS = 6e4;
|
|
1821
|
+
var CREDENTIAL_VERIFY_COOLDOWN_MS = 6e4;
|
|
1822
|
+
var MAX_TRACKED_IDS = 4096;
|
|
1823
|
+
var CredentialVerifyThrottle = class {
|
|
1824
|
+
constructor(maxFailures = CREDENTIAL_VERIFY_MAX_FAILURES, windowMs = CREDENTIAL_VERIFY_WINDOW_MS, cooldownMs = CREDENTIAL_VERIFY_COOLDOWN_MS) {
|
|
1825
|
+
this.maxFailures = maxFailures;
|
|
1826
|
+
this.windowMs = windowMs;
|
|
1827
|
+
this.cooldownMs = cooldownMs;
|
|
1828
|
+
}
|
|
1829
|
+
maxFailures;
|
|
1830
|
+
windowMs;
|
|
1831
|
+
cooldownMs;
|
|
1832
|
+
records = /* @__PURE__ */ new Map();
|
|
1833
|
+
/** Is this credential id allowed another attempt right now? */
|
|
1834
|
+
check(credentialId, now = Date.now()) {
|
|
1835
|
+
const record = this.records.get(credentialId);
|
|
1836
|
+
if (record === void 0) return { allowed: true, retryAfterMs: 0 };
|
|
1837
|
+
if (record.blockedUntil > now) {
|
|
1838
|
+
return { allowed: false, retryAfterMs: record.blockedUntil - now };
|
|
1839
|
+
}
|
|
1840
|
+
return { allowed: true, retryAfterMs: 0 };
|
|
1841
|
+
}
|
|
1842
|
+
/** Record a failed verification. Starts the cooldown once the limit is hit. */
|
|
1843
|
+
recordFailure(credentialId, now = Date.now()) {
|
|
1844
|
+
const record = this.records.get(credentialId);
|
|
1845
|
+
if (record === void 0 || now - record.windowStartedAt > this.windowMs) {
|
|
1846
|
+
this.evictIfFull();
|
|
1847
|
+
this.records.set(credentialId, { failures: 1, windowStartedAt: now, blockedUntil: 0 });
|
|
1848
|
+
return;
|
|
1849
|
+
}
|
|
1850
|
+
record.failures += 1;
|
|
1851
|
+
if (record.failures >= this.maxFailures) {
|
|
1852
|
+
record.blockedUntil = now + this.cooldownMs;
|
|
1853
|
+
record.failures = 0;
|
|
1854
|
+
record.windowStartedAt = now;
|
|
1855
|
+
}
|
|
1675
1856
|
}
|
|
1676
|
-
|
|
1677
|
-
|
|
1857
|
+
/**
|
|
1858
|
+
* Clear the counter after a successful verification. A legitimate holder who
|
|
1859
|
+
* fluffed a few attempts is not left in a cooldown they cannot exit.
|
|
1860
|
+
*/
|
|
1861
|
+
recordSuccess(credentialId) {
|
|
1862
|
+
this.records.delete(credentialId);
|
|
1678
1863
|
}
|
|
1679
|
-
|
|
1680
|
-
|
|
1864
|
+
/** Test seam. */
|
|
1865
|
+
reset() {
|
|
1866
|
+
this.records.clear();
|
|
1681
1867
|
}
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
if (actualBytes.length !== expectedBytes.length || !crypto.timingSafeEqual(actualBytes, expectedBytes)) {
|
|
1687
|
-
return { valid: false, reason: "invalid secret", credential };
|
|
1868
|
+
evictIfFull() {
|
|
1869
|
+
if (this.records.size < MAX_TRACKED_IDS) return;
|
|
1870
|
+
const oldest = this.records.keys().next();
|
|
1871
|
+
if (!oldest.done) this.records.delete(oldest.value);
|
|
1688
1872
|
}
|
|
1689
|
-
|
|
1690
|
-
|
|
1873
|
+
};
|
|
1874
|
+
var credentialVerifyThrottle = new CredentialVerifyThrottle();
|
|
1691
1875
|
|
|
1692
1876
|
// src/coordination/sqlite-mailbox-rows.ts
|
|
1693
1877
|
var MALFORMED_TIMESTAMP = "last_seen_at NOT GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T*'";
|
|
@@ -1967,7 +2151,17 @@ function credentialIssue(db, transaction, options) {
|
|
|
1967
2151
|
return issued;
|
|
1968
2152
|
}
|
|
1969
2153
|
function credentialVerify(db, credentialId, secret) {
|
|
1970
|
-
|
|
2154
|
+
const decision = credentialVerifyThrottle.check(credentialId);
|
|
2155
|
+
if (!decision.allowed) {
|
|
2156
|
+
return {
|
|
2157
|
+
valid: false,
|
|
2158
|
+
reason: `too many failed verification attempts \u2014 retry in ${Math.ceil(decision.retryAfterMs / 1e3)}s`
|
|
2159
|
+
};
|
|
2160
|
+
}
|
|
2161
|
+
const result = verifyMailboxCredential(credentialGet(db, credentialId) ?? void 0, secret);
|
|
2162
|
+
if (result.valid) credentialVerifyThrottle.recordSuccess(credentialId);
|
|
2163
|
+
else credentialVerifyThrottle.recordFailure(credentialId);
|
|
2164
|
+
return result;
|
|
1971
2165
|
}
|
|
1972
2166
|
function credentialRevoke(db, credentialId, reason, by) {
|
|
1973
2167
|
const credential = credentialGet(db, credentialId);
|
|
@@ -2482,7 +2676,41 @@ var SqliteMailbox = class {
|
|
|
2482
2676
|
where.push("reply_to = ?");
|
|
2483
2677
|
params.push(query.replyTo);
|
|
2484
2678
|
}
|
|
2485
|
-
|
|
2679
|
+
if (query.unreadBy !== void 0) {
|
|
2680
|
+
if (!isMailboxLeader(query.unreadBy, query.readerRole)) {
|
|
2681
|
+
where.push("COALESCE(json_extract(data, '$.audience'), 'all') <> 'leaders'");
|
|
2682
|
+
}
|
|
2683
|
+
if (!query.incompleteOnly) {
|
|
2684
|
+
where.push(`NOT EXISTS (
|
|
2685
|
+
SELECT 1 FROM message_receipts AS unread_receipt
|
|
2686
|
+
WHERE unread_receipt.message_id = messages.id
|
|
2687
|
+
AND unread_receipt.actor_id = ?
|
|
2688
|
+
AND unread_receipt.read_at IS NOT NULL
|
|
2689
|
+
)`);
|
|
2690
|
+
params.push(query.unreadBy);
|
|
2691
|
+
where.push(`NOT EXISTS (
|
|
2692
|
+
SELECT 1 FROM json_each(json_extract(data, '$.readBy')) AS legacy_read
|
|
2693
|
+
WHERE legacy_read.key = ?
|
|
2694
|
+
)`);
|
|
2695
|
+
params.push(query.unreadBy);
|
|
2696
|
+
} else {
|
|
2697
|
+
where.push("legacy_global_completion = 0");
|
|
2698
|
+
where.push(`NOT EXISTS (
|
|
2699
|
+
SELECT 1 FROM message_receipts AS completed_receipt
|
|
2700
|
+
WHERE completed_receipt.message_id = messages.id
|
|
2701
|
+
AND completed_receipt.actor_id = ?
|
|
2702
|
+
AND completed_receipt.completed_at IS NOT NULL
|
|
2703
|
+
)`);
|
|
2704
|
+
params.push(query.unreadBy);
|
|
2705
|
+
where.push(`(
|
|
2706
|
+
completed = 0 OR EXISTS (
|
|
2707
|
+
SELECT 1 FROM message_receipts AS any_receipt
|
|
2708
|
+
WHERE any_receipt.message_id = messages.id
|
|
2709
|
+
)
|
|
2710
|
+
)`);
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
const canPreLimit = !query.incompleteOnly || query.unreadBy !== void 0;
|
|
2486
2714
|
let sql = "SELECT id, data, legacy_global_completion FROM messages";
|
|
2487
2715
|
if (where.length > 0) sql += ` WHERE ${where.join(" AND ")}`;
|
|
2488
2716
|
sql += " ORDER BY timestamp DESC, rowid DESC";
|
|
@@ -2494,10 +2722,14 @@ var SqliteMailbox = class {
|
|
|
2494
2722
|
const messages = this.materializeMessageRows(rows).filter((message) => {
|
|
2495
2723
|
if (query.to !== void 0 && message.to !== query.to && message.to !== "*") return false;
|
|
2496
2724
|
if (query.from !== void 0 && message.from !== query.from) return false;
|
|
2497
|
-
if (query.sessionId !== void 0 && message.senderSessionId !== query.sessionId)
|
|
2498
|
-
|
|
2499
|
-
if (
|
|
2500
|
-
|
|
2725
|
+
if (query.sessionId !== void 0 && message.senderSessionId !== query.sessionId)
|
|
2726
|
+
return false;
|
|
2727
|
+
if (query.unreadBy !== void 0 && !isMailboxMessageVisibleTo(message, query.unreadBy, query.readerRole))
|
|
2728
|
+
return false;
|
|
2729
|
+
if (!query.incompleteOnly && query.unreadBy !== void 0 && query.unreadBy in message.readBy)
|
|
2730
|
+
return false;
|
|
2731
|
+
if (query.incompleteOnly && (query.unreadBy === void 0 ? projectMailboxCompletion(message, void 0, statuses).completed : isMessageCompletedForActor(message, query.unreadBy)))
|
|
2732
|
+
return false;
|
|
2501
2733
|
if (type !== void 0 && message.type !== type) return false;
|
|
2502
2734
|
if (priorityRank[message.priority] < minimumRank) return false;
|
|
2503
2735
|
if (query.since !== void 0 && message.timestamp <= query.since) return false;
|
|
@@ -2889,6 +3121,11 @@ var stopMemoryWatchdog = startSharedHeapWatchdog({
|
|
|
2889
3121
|
pendingRequests
|
|
2890
3122
|
})
|
|
2891
3123
|
});
|
|
3124
|
+
var authToken = randomBytes2(16).toString("hex");
|
|
3125
|
+
var markMetadataWritten;
|
|
3126
|
+
var metadataWritten = new Promise((resolve5) => {
|
|
3127
|
+
markMetadataWritten = resolve5;
|
|
3128
|
+
});
|
|
2892
3129
|
var serverInfo = {
|
|
2893
3130
|
protocolVersion: MAILBOX_PROJECT_SERVER_PROTOCOL_VERSION,
|
|
2894
3131
|
pid: process.pid,
|
|
@@ -3032,7 +3269,12 @@ async function dispatch(op, rawArgs) {
|
|
|
3032
3269
|
}
|
|
3033
3270
|
case "credentialVerify": {
|
|
3034
3271
|
const args = rawArgs;
|
|
3035
|
-
return activeMailbox.credentialVerify(args.credentialId, args.secret)
|
|
3272
|
+
return Promise.resolve(activeMailbox.credentialVerify(args.credentialId, args.secret)).then(
|
|
3273
|
+
(result) => result.valid ? {
|
|
3274
|
+
...result,
|
|
3275
|
+
credential: result.credential ? redactMailboxCredential(result.credential) : void 0
|
|
3276
|
+
} : { valid: false, reason: result.reason }
|
|
3277
|
+
);
|
|
3036
3278
|
}
|
|
3037
3279
|
case "credentialRevoke": {
|
|
3038
3280
|
const args = rawArgs;
|
|
@@ -3047,16 +3289,33 @@ async function dispatch(op, rawArgs) {
|
|
|
3047
3289
|
}
|
|
3048
3290
|
case "credentialGet": {
|
|
3049
3291
|
const args = rawArgs;
|
|
3050
|
-
return activeMailbox.credentialGet(args.credentialId)
|
|
3292
|
+
return Promise.resolve(activeMailbox.credentialGet(args.credentialId)).then(
|
|
3293
|
+
(credential) => credential ? redactMailboxCredential(credential) : null
|
|
3294
|
+
);
|
|
3051
3295
|
}
|
|
3052
3296
|
case "credentialList":
|
|
3053
|
-
return activeMailbox.credentialList()
|
|
3297
|
+
return Promise.resolve(activeMailbox.credentialList()).then(
|
|
3298
|
+
(credentials) => credentials.map(redactMailboxCredential)
|
|
3299
|
+
);
|
|
3054
3300
|
case "credentialStatusCounts":
|
|
3055
3301
|
return activeMailbox.credentialStatusCounts();
|
|
3056
3302
|
}
|
|
3057
3303
|
}
|
|
3304
|
+
function checkAuthToken(state, message) {
|
|
3305
|
+
if (message.type === "heartbeat") return true;
|
|
3306
|
+
if (message.authToken === authToken) return true;
|
|
3307
|
+
send(state, {
|
|
3308
|
+
type: "response",
|
|
3309
|
+
id: message.id,
|
|
3310
|
+
ok: false,
|
|
3311
|
+
error: "Mailbox IPC request rejected: missing or invalid authToken. Reconnect to refresh metadata (.mailbox-server.json#authToken).",
|
|
3312
|
+
errorName: "UnauthorizedMailboxRequest"
|
|
3313
|
+
});
|
|
3314
|
+
return false;
|
|
3315
|
+
}
|
|
3058
3316
|
function handleMessage(state, message) {
|
|
3059
3317
|
state.lastSeenAt = Date.now();
|
|
3318
|
+
if (!checkAuthToken(state, message)) return;
|
|
3060
3319
|
if (message.type === "heartbeat") return;
|
|
3061
3320
|
if (message.type === "shutdown") {
|
|
3062
3321
|
send(state, {
|
|
@@ -3124,18 +3383,9 @@ function scheduleIdleStop() {
|
|
|
3124
3383
|
}
|
|
3125
3384
|
async function writeMetadata() {
|
|
3126
3385
|
await fsPromises.mkdir(projectDir, { recursive: true });
|
|
3127
|
-
const
|
|
3128
|
-
await
|
|
3129
|
-
`, {
|
|
3130
|
-
encoding: "utf8",
|
|
3131
|
-
mode: 384
|
|
3132
|
-
});
|
|
3133
|
-
try {
|
|
3134
|
-
await fsPromises.rename(temporary, metadataPath);
|
|
3135
|
-
} catch {
|
|
3136
|
-
await fsPromises.rm(metadataPath, { force: true });
|
|
3137
|
-
await fsPromises.rename(temporary, metadataPath);
|
|
3138
|
-
}
|
|
3386
|
+
const metadata = { ...serverStatus(), authToken };
|
|
3387
|
+
await atomicWrite(metadataPath, `${JSON.stringify(metadata, null, 2)}
|
|
3388
|
+
`, { mode: 384 });
|
|
3139
3389
|
}
|
|
3140
3390
|
async function removeOwnedMetadata() {
|
|
3141
3391
|
try {
|
|
@@ -3151,6 +3401,7 @@ async function stop(_reason) {
|
|
|
3151
3401
|
idleTimer = void 0;
|
|
3152
3402
|
clearInterval(leaseSweep);
|
|
3153
3403
|
stopAutoCompact?.();
|
|
3404
|
+
await removeOwnedMetadata();
|
|
3154
3405
|
const serverClosed = new Promise((resolve5) => server.close(() => resolve5()));
|
|
3155
3406
|
for (const state of clients) state.socket.end();
|
|
3156
3407
|
const forceCloseTimer = setTimeout(() => {
|
|
@@ -3164,7 +3415,6 @@ async function stop(_reason) {
|
|
|
3164
3415
|
await mailbox?.close().catch(() => {
|
|
3165
3416
|
});
|
|
3166
3417
|
mailbox = void 0;
|
|
3167
|
-
await removeOwnedMetadata();
|
|
3168
3418
|
if (process.platform !== "win32") {
|
|
3169
3419
|
await fsPromises.rm(endpoint, { force: true }).catch(() => {
|
|
3170
3420
|
});
|
|
@@ -3182,7 +3432,9 @@ var server = net.createServer((socket) => {
|
|
|
3182
3432
|
socket.setEncoding("utf8");
|
|
3183
3433
|
const state = { socket, buffer: "", lastSeenAt: Date.now() };
|
|
3184
3434
|
clients.add(state);
|
|
3185
|
-
|
|
3435
|
+
void metadataWritten.then(() => {
|
|
3436
|
+
if (!socket.destroyed) send(state, { type: "hello", ...serverInfo });
|
|
3437
|
+
});
|
|
3186
3438
|
socket.on("data", (chunk) => onData(state, chunk));
|
|
3187
3439
|
socket.on("error", () => {
|
|
3188
3440
|
});
|
|
@@ -3244,7 +3496,10 @@ server.on("listening", () => {
|
|
|
3244
3496
|
return;
|
|
3245
3497
|
}
|
|
3246
3498
|
stopAutoCompact = mailbox.startAutoCompactTimer();
|
|
3247
|
-
void writeMetadata().then(() =>
|
|
3499
|
+
void writeMetadata().then(() => {
|
|
3500
|
+
markMetadataWritten?.();
|
|
3501
|
+
scheduleIdleStop();
|
|
3502
|
+
}).catch(() => {
|
|
3248
3503
|
void stop("metadata-write-failed").finally(() => {
|
|
3249
3504
|
process.exitCode = 1;
|
|
3250
3505
|
});
|