@schema-weaver/pg-connector 0.0.0-stage → 2.0.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/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +457 -2
- package/dist/cjs/audit/chain.d.ts +365 -0
- package/dist/cjs/audit/chain.d.ts.map +1 -0
- package/dist/cjs/audit/chain.js +959 -0
- package/dist/cjs/audit/chain.js.map +1 -0
- package/dist/cjs/audit/cloud-client.d.ts +142 -0
- package/dist/cjs/audit/cloud-client.d.ts.map +1 -0
- package/dist/cjs/audit/cloud-client.js +364 -0
- package/dist/cjs/audit/cloud-client.js.map +1 -0
- package/dist/cjs/audit/cloud-writer.d.ts +57 -0
- package/dist/cjs/audit/cloud-writer.d.ts.map +1 -0
- package/dist/cjs/audit/cloud-writer.js +95 -0
- package/dist/cjs/audit/cloud-writer.js.map +1 -0
- package/dist/cjs/audit/context.d.ts +51 -0
- package/dist/cjs/audit/context.d.ts.map +1 -0
- package/dist/cjs/audit/context.js +75 -0
- package/dist/cjs/audit/context.js.map +1 -0
- package/dist/cjs/audit/files.d.ts +111 -0
- package/dist/cjs/audit/files.d.ts.map +1 -0
- package/dist/cjs/audit/files.js +406 -0
- package/dist/cjs/audit/files.js.map +1 -0
- package/dist/cjs/audit/index.d.ts +9 -0
- package/dist/cjs/audit/index.d.ts.map +1 -0
- package/dist/cjs/audit/index.js +68 -0
- package/dist/cjs/audit/index.js.map +1 -0
- package/dist/cjs/audit/local-writer.d.ts +255 -0
- package/dist/cjs/audit/local-writer.d.ts.map +1 -0
- package/dist/cjs/audit/local-writer.js +829 -0
- package/dist/cjs/audit/local-writer.js.map +1 -0
- package/dist/cjs/audit/redact.d.ts +151 -0
- package/dist/cjs/audit/redact.d.ts.map +1 -0
- package/dist/cjs/audit/redact.js +549 -0
- package/dist/cjs/audit/redact.js.map +1 -0
- package/dist/cjs/audit/sanitize.d.ts +78 -0
- package/dist/cjs/audit/sanitize.d.ts.map +1 -0
- package/dist/cjs/audit/sanitize.js +315 -0
- package/dist/cjs/audit/sanitize.js.map +1 -0
- package/dist/cjs/audit/sink.d.ts +278 -0
- package/dist/cjs/audit/sink.d.ts.map +1 -0
- package/dist/cjs/audit/sink.js +819 -0
- package/dist/cjs/audit/sink.js.map +1 -0
- package/dist/cjs/audit/types.d.ts +226 -0
- package/dist/cjs/audit/types.d.ts.map +1 -0
- package/dist/cjs/audit/types.js +3 -0
- package/dist/cjs/audit/types.js.map +1 -0
- package/dist/cjs/audit/verify-cache.d.ts +127 -0
- package/dist/cjs/audit/verify-cache.d.ts.map +1 -0
- package/dist/cjs/audit/verify-cache.js +668 -0
- package/dist/cjs/audit/verify-cache.js.map +1 -0
- package/dist/cjs/channels/agent-session.d.ts +228 -0
- package/dist/cjs/channels/agent-session.d.ts.map +1 -0
- package/dist/cjs/channels/agent-session.js +604 -0
- package/dist/cjs/channels/agent-session.js.map +1 -0
- package/dist/cjs/channels/data-channel.d.ts +181 -0
- package/dist/cjs/channels/data-channel.d.ts.map +1 -0
- package/dist/cjs/channels/data-channel.js +607 -0
- package/dist/cjs/channels/data-channel.js.map +1 -0
- package/dist/cjs/channels/reconnect.d.ts +142 -0
- package/dist/cjs/channels/reconnect.d.ts.map +1 -0
- package/dist/cjs/channels/reconnect.js +247 -0
- package/dist/cjs/channels/reconnect.js.map +1 -0
- package/dist/cjs/channels/types.d.ts +112 -0
- package/dist/cjs/channels/types.d.ts.map +1 -0
- package/dist/cjs/channels/types.js +3 -0
- package/dist/cjs/channels/types.js.map +1 -0
- package/dist/cjs/channels/wake-channel.d.ts +232 -0
- package/dist/cjs/channels/wake-channel.d.ts.map +1 -0
- package/dist/cjs/channels/wake-channel.js +752 -0
- package/dist/cjs/channels/wake-channel.js.map +1 -0
- package/dist/cjs/cli/banner.d.ts +2 -0
- package/dist/cjs/cli/banner.d.ts.map +1 -0
- package/dist/cjs/cli/banner.js +150 -0
- package/dist/cjs/cli/banner.js.map +1 -0
- package/dist/cjs/cli/commands/agent.d.ts +30 -0
- package/dist/cjs/cli/commands/agent.d.ts.map +1 -0
- package/dist/cjs/cli/commands/agent.js +214 -0
- package/dist/cjs/cli/commands/agent.js.map +1 -0
- package/dist/cjs/cli/commands/audit-verify.d.ts +19 -0
- package/dist/cjs/cli/commands/audit-verify.d.ts.map +1 -0
- package/dist/cjs/cli/commands/audit-verify.js +382 -0
- package/dist/cjs/cli/commands/audit-verify.js.map +1 -0
- package/dist/cjs/cli/commands/clean.d.ts +23 -0
- package/dist/cjs/cli/commands/clean.d.ts.map +1 -0
- package/dist/cjs/cli/commands/clean.js +272 -0
- package/dist/cjs/cli/commands/clean.js.map +1 -0
- package/dist/cjs/cli/commands/config-show.d.ts +2 -0
- package/dist/cjs/cli/commands/config-show.d.ts.map +1 -0
- package/dist/cjs/cli/commands/config-show.js +10 -0
- package/dist/cjs/cli/commands/config-show.js.map +1 -0
- package/dist/cjs/cli/commands/config.d.ts +6 -0
- package/dist/cjs/cli/commands/config.d.ts.map +1 -0
- package/dist/cjs/cli/commands/config.js +266 -0
- package/dist/cjs/cli/commands/config.js.map +1 -0
- package/dist/cjs/cli/commands/db-add.d.ts +16 -0
- package/dist/cjs/cli/commands/db-add.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-add.js +613 -0
- package/dist/cjs/cli/commands/db-add.js.map +1 -0
- package/dist/cjs/cli/commands/db-edit.d.ts +2 -0
- package/dist/cjs/cli/commands/db-edit.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-edit.js +388 -0
- package/dist/cjs/cli/commands/db-edit.js.map +1 -0
- package/dist/cjs/cli/commands/db-logs.d.ts +3 -0
- package/dist/cjs/cli/commands/db-logs.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-logs.js +67 -0
- package/dist/cjs/cli/commands/db-logs.js.map +1 -0
- package/dist/cjs/cli/commands/db-ls.d.ts +2 -0
- package/dist/cjs/cli/commands/db-ls.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-ls.js +118 -0
- package/dist/cjs/cli/commands/db-ls.js.map +1 -0
- package/dist/cjs/cli/commands/db-query.d.ts +121 -0
- package/dist/cjs/cli/commands/db-query.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-query.js +802 -0
- package/dist/cjs/cli/commands/db-query.js.map +1 -0
- package/dist/cjs/cli/commands/db-remove.d.ts +2 -0
- package/dist/cjs/cli/commands/db-remove.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-remove.js +51 -0
- package/dist/cjs/cli/commands/db-remove.js.map +1 -0
- package/dist/cjs/cli/commands/db-show.d.ts +2 -0
- package/dist/cjs/cli/commands/db-show.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-show.js +134 -0
- package/dist/cjs/cli/commands/db-show.js.map +1 -0
- package/dist/cjs/cli/commands/db-test.d.ts +3 -0
- package/dist/cjs/cli/commands/db-test.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-test.js +311 -0
- package/dist/cjs/cli/commands/db-test.js.map +1 -0
- package/dist/cjs/cli/commands/db.d.ts +11 -0
- package/dist/cjs/cli/commands/db.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db.js +90 -0
- package/dist/cjs/cli/commands/db.js.map +1 -0
- package/dist/cjs/cli/commands/debug.d.ts +2 -0
- package/dist/cjs/cli/commands/debug.d.ts.map +1 -0
- package/dist/cjs/cli/commands/debug.js +241 -0
- package/dist/cjs/cli/commands/debug.js.map +1 -0
- package/dist/cjs/cli/commands/doctor.d.ts +5 -0
- package/dist/cjs/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cjs/cli/commands/doctor.js +117 -0
- package/dist/cjs/cli/commands/doctor.js.map +1 -0
- package/dist/cjs/cli/commands/index.d.ts +10 -0
- package/dist/cjs/cli/commands/index.d.ts.map +1 -0
- package/dist/cjs/cli/commands/index.js +30 -0
- package/dist/cjs/cli/commands/index.js.map +1 -0
- package/dist/cjs/cli/commands/init.d.ts +2 -0
- package/dist/cjs/cli/commands/init.d.ts.map +1 -0
- package/dist/cjs/cli/commands/init.js +199 -0
- package/dist/cjs/cli/commands/init.js.map +1 -0
- package/dist/cjs/cli/commands/link.d.ts +5 -0
- package/dist/cjs/cli/commands/link.d.ts.map +1 -0
- package/dist/cjs/cli/commands/link.js +44 -0
- package/dist/cjs/cli/commands/link.js.map +1 -0
- package/dist/cjs/cli/commands/logs.d.ts +17 -0
- package/dist/cjs/cli/commands/logs.d.ts.map +1 -0
- package/dist/cjs/cli/commands/logs.js +314 -0
- package/dist/cjs/cli/commands/logs.js.map +1 -0
- package/dist/cjs/cli/commands/project-show.d.ts +2 -0
- package/dist/cjs/cli/commands/project-show.d.ts.map +1 -0
- package/dist/cjs/cli/commands/project-show.js +105 -0
- package/dist/cjs/cli/commands/project-show.js.map +1 -0
- package/dist/cjs/cli/commands/project.d.ts +3 -0
- package/dist/cjs/cli/commands/project.d.ts.map +1 -0
- package/dist/cjs/cli/commands/project.js +64 -0
- package/dist/cjs/cli/commands/project.js.map +1 -0
- package/dist/cjs/cli/commands/service.d.ts +123 -0
- package/dist/cjs/cli/commands/service.d.ts.map +1 -0
- package/dist/cjs/cli/commands/service.js +554 -0
- package/dist/cjs/cli/commands/service.js.map +1 -0
- package/dist/cjs/cli/commands/start.d.ts +6 -0
- package/dist/cjs/cli/commands/start.d.ts.map +1 -0
- package/dist/cjs/cli/commands/start.js +308 -0
- package/dist/cjs/cli/commands/start.js.map +1 -0
- package/dist/cjs/cli/commands/status.d.ts +2 -0
- package/dist/cjs/cli/commands/status.d.ts.map +1 -0
- package/dist/cjs/cli/commands/status.js +225 -0
- package/dist/cjs/cli/commands/status.js.map +1 -0
- package/dist/cjs/cli/commands/stop.d.ts +6 -0
- package/dist/cjs/cli/commands/stop.d.ts.map +1 -0
- package/dist/cjs/cli/commands/stop.js +99 -0
- package/dist/cjs/cli/commands/stop.js.map +1 -0
- package/dist/cjs/cli/daemon/error-tracker.d.ts +119 -0
- package/dist/cjs/cli/daemon/error-tracker.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/error-tracker.js +500 -0
- package/dist/cjs/cli/daemon/error-tracker.js.map +1 -0
- package/dist/cjs/cli/daemon/fault-shutdown.d.ts +144 -0
- package/dist/cjs/cli/daemon/fault-shutdown.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/fault-shutdown.js +312 -0
- package/dist/cjs/cli/daemon/fault-shutdown.js.map +1 -0
- package/dist/cjs/cli/daemon/index.d.ts +12 -0
- package/dist/cjs/cli/daemon/index.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/index.js +23 -0
- package/dist/cjs/cli/daemon/index.js.map +1 -0
- package/dist/cjs/cli/daemon/pid-file.d.ts +13 -0
- package/dist/cjs/cli/daemon/pid-file.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/pid-file.js +90 -0
- package/dist/cjs/cli/daemon/pid-file.js.map +1 -0
- package/dist/cjs/cli/daemon/readiness.d.ts +30 -0
- package/dist/cjs/cli/daemon/readiness.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/readiness.js +74 -0
- package/dist/cjs/cli/daemon/readiness.js.map +1 -0
- package/dist/cjs/cli/daemon/runtime.d.ts +366 -0
- package/dist/cjs/cli/daemon/runtime.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/runtime.js +1343 -0
- package/dist/cjs/cli/daemon/runtime.js.map +1 -0
- package/dist/cjs/cli/daemon/shutdown.d.ts +7 -0
- package/dist/cjs/cli/daemon/shutdown.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/shutdown.js +66 -0
- package/dist/cjs/cli/daemon/shutdown.js.map +1 -0
- package/dist/cjs/cli/daemon/signal-handlers.d.ts +3 -0
- package/dist/cjs/cli/daemon/signal-handlers.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/signal-handlers.js +27 -0
- package/dist/cjs/cli/daemon/signal-handlers.js.map +1 -0
- package/dist/cjs/cli/daemon/state.d.ts +157 -0
- package/dist/cjs/cli/daemon/state.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/state.js +397 -0
- package/dist/cjs/cli/daemon/state.js.map +1 -0
- package/dist/cjs/cli/daemon/status-file.d.ts +139 -0
- package/dist/cjs/cli/daemon/status-file.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/status-file.js +88 -0
- package/dist/cjs/cli/daemon/status-file.js.map +1 -0
- package/dist/cjs/cli/doctor/checks.d.ts +133 -0
- package/dist/cjs/cli/doctor/checks.d.ts.map +1 -0
- package/dist/cjs/cli/doctor/checks.js +677 -0
- package/dist/cjs/cli/doctor/checks.js.map +1 -0
- package/dist/cjs/cli/doctor/fixes.d.ts +9 -0
- package/dist/cjs/cli/doctor/fixes.d.ts.map +1 -0
- package/dist/cjs/cli/doctor/fixes.js +199 -0
- package/dist/cjs/cli/doctor/fixes.js.map +1 -0
- package/dist/cjs/cli/doctor/index.d.ts +7 -0
- package/dist/cjs/cli/doctor/index.d.ts.map +1 -0
- package/dist/cjs/cli/doctor/index.js +27 -0
- package/dist/cjs/cli/doctor/index.js.map +1 -0
- package/dist/cjs/cli/index.d.ts +3 -0
- package/dist/cjs/cli/index.d.ts.map +1 -0
- package/dist/cjs/cli/index.js +336 -0
- package/dist/cjs/cli/index.js.map +1 -0
- package/dist/cjs/cli/interactive.d.ts +8 -0
- package/dist/cjs/cli/interactive.d.ts.map +1 -0
- package/dist/cjs/cli/interactive.js +670 -0
- package/dist/cjs/cli/interactive.js.map +1 -0
- package/dist/cjs/cli/logs/format.d.ts +13 -0
- package/dist/cjs/cli/logs/format.d.ts.map +1 -0
- package/dist/cjs/cli/logs/format.js +178 -0
- package/dist/cjs/cli/logs/format.js.map +1 -0
- package/dist/cjs/cli/logs/index.d.ts +3 -0
- package/dist/cjs/cli/logs/index.d.ts.map +1 -0
- package/dist/cjs/cli/logs/index.js +13 -0
- package/dist/cjs/cli/logs/index.js.map +1 -0
- package/dist/cjs/cli/logs/viewer.d.ts +41 -0
- package/dist/cjs/cli/logs/viewer.d.ts.map +1 -0
- package/dist/cjs/cli/logs/viewer.js +417 -0
- package/dist/cjs/cli/logs/viewer.js.map +1 -0
- package/dist/cjs/cli/ops/operation-logger.d.ts +63 -0
- package/dist/cjs/cli/ops/operation-logger.d.ts.map +1 -0
- package/dist/cjs/cli/ops/operation-logger.js +183 -0
- package/dist/cjs/cli/ops/operation-logger.js.map +1 -0
- package/dist/cjs/cli/palette.d.ts +11 -0
- package/dist/cjs/cli/palette.d.ts.map +1 -0
- package/dist/cjs/cli/palette.js +243 -0
- package/dist/cjs/cli/palette.js.map +1 -0
- package/dist/cjs/cli/prompt.d.ts +186 -0
- package/dist/cjs/cli/prompt.d.ts.map +1 -0
- package/dist/cjs/cli/prompt.js +541 -0
- package/dist/cjs/cli/prompt.js.map +1 -0
- package/dist/cjs/cli/ui/box.d.ts +21 -0
- package/dist/cjs/cli/ui/box.d.ts.map +1 -0
- package/dist/cjs/cli/ui/box.js +72 -0
- package/dist/cjs/cli/ui/box.js.map +1 -0
- package/dist/cjs/cli/ui/clipboard.d.ts +6 -0
- package/dist/cjs/cli/ui/clipboard.d.ts.map +1 -0
- package/dist/cjs/cli/ui/clipboard.js +78 -0
- package/dist/cjs/cli/ui/clipboard.js.map +1 -0
- package/dist/cjs/cli/ui/colors.d.ts +57 -0
- package/dist/cjs/cli/ui/colors.d.ts.map +1 -0
- package/dist/cjs/cli/ui/colors.js +151 -0
- package/dist/cjs/cli/ui/colors.js.map +1 -0
- package/dist/cjs/cli/ui/index.d.ts +9 -0
- package/dist/cjs/cli/ui/index.d.ts.map +1 -0
- package/dist/cjs/cli/ui/index.js +55 -0
- package/dist/cjs/cli/ui/index.js.map +1 -0
- package/dist/cjs/cli/ui/spinner.d.ts +12 -0
- package/dist/cjs/cli/ui/spinner.d.ts.map +1 -0
- package/dist/cjs/cli/ui/spinner.js +82 -0
- package/dist/cjs/cli/ui/spinner.js.map +1 -0
- package/dist/cjs/cli/ui/symbols.d.ts +47 -0
- package/dist/cjs/cli/ui/symbols.d.ts.map +1 -0
- package/dist/cjs/cli/ui/symbols.js +112 -0
- package/dist/cjs/cli/ui/symbols.js.map +1 -0
- package/dist/cjs/cli/ui/table.d.ts +23 -0
- package/dist/cjs/cli/ui/table.d.ts.map +1 -0
- package/dist/cjs/cli/ui/table.js +160 -0
- package/dist/cjs/cli/ui/table.js.map +1 -0
- package/dist/cjs/cli/ui/terminal.d.ts +7 -0
- package/dist/cjs/cli/ui/terminal.d.ts.map +1 -0
- package/dist/cjs/cli/ui/terminal.js +40 -0
- package/dist/cjs/cli/ui/terminal.js.map +1 -0
- package/dist/cjs/config/atomic-write.d.ts +69 -0
- package/dist/cjs/config/atomic-write.d.ts.map +1 -0
- package/dist/cjs/config/atomic-write.js +289 -0
- package/dist/cjs/config/atomic-write.js.map +1 -0
- package/dist/cjs/config/db-config.d.ts +134 -0
- package/dist/cjs/config/db-config.d.ts.map +1 -0
- package/dist/cjs/config/db-config.js +594 -0
- package/dist/cjs/config/db-config.js.map +1 -0
- package/dist/cjs/config/machine-config.d.ts +85 -0
- package/dist/cjs/config/machine-config.d.ts.map +1 -0
- package/dist/cjs/config/machine-config.js +232 -0
- package/dist/cjs/config/machine-config.js.map +1 -0
- package/dist/cjs/config/paths.d.ts +64 -0
- package/dist/cjs/config/paths.d.ts.map +1 -0
- package/dist/cjs/config/paths.js +155 -0
- package/dist/cjs/config/paths.js.map +1 -0
- package/dist/cjs/config/schema.d.ts +72 -0
- package/dist/cjs/config/schema.d.ts.map +1 -0
- package/dist/cjs/config/schema.js +197 -0
- package/dist/cjs/config/schema.js.map +1 -0
- package/dist/cjs/config/token.d.ts +63 -0
- package/dist/cjs/config/token.d.ts.map +1 -0
- package/dist/cjs/config/token.js +146 -0
- package/dist/cjs/config/token.js.map +1 -0
- package/dist/cjs/execution/canceller.d.ts +41 -0
- package/dist/cjs/execution/canceller.d.ts.map +1 -0
- package/dist/cjs/execution/canceller.js +209 -0
- package/dist/cjs/execution/canceller.js.map +1 -0
- package/dist/cjs/execution/database-lookup.d.ts +56 -0
- package/dist/cjs/execution/database-lookup.d.ts.map +1 -0
- package/dist/cjs/execution/database-lookup.js +43 -0
- package/dist/cjs/execution/database-lookup.js.map +1 -0
- package/dist/cjs/execution/dispatcher.d.ts +181 -0
- package/dist/cjs/execution/dispatcher.d.ts.map +1 -0
- package/dist/cjs/execution/dispatcher.js +1296 -0
- package/dist/cjs/execution/dispatcher.js.map +1 -0
- package/dist/cjs/execution/function-effects.d.ts +209 -0
- package/dist/cjs/execution/function-effects.d.ts.map +1 -0
- package/dist/cjs/execution/function-effects.js +596 -0
- package/dist/cjs/execution/function-effects.js.map +1 -0
- package/dist/cjs/execution/introspection.d.ts +76 -0
- package/dist/cjs/execution/introspection.d.ts.map +1 -0
- package/dist/cjs/execution/introspection.js +448 -0
- package/dist/cjs/execution/introspection.js.map +1 -0
- package/dist/cjs/execution/migration-runner.d.ts +128 -0
- package/dist/cjs/execution/migration-runner.d.ts.map +1 -0
- package/dist/cjs/execution/migration-runner.js +798 -0
- package/dist/cjs/execution/migration-runner.js.map +1 -0
- package/dist/cjs/execution/non-tx-detector.d.ts +23 -0
- package/dist/cjs/execution/non-tx-detector.d.ts.map +1 -0
- package/dist/cjs/execution/non-tx-detector.js +218 -0
- package/dist/cjs/execution/non-tx-detector.js.map +1 -0
- package/dist/cjs/execution/pool.d.ts +229 -0
- package/dist/cjs/execution/pool.d.ts.map +1 -0
- package/dist/cjs/execution/pool.js +738 -0
- package/dist/cjs/execution/pool.js.map +1 -0
- package/dist/cjs/execution/query-runner.d.ts +88 -0
- package/dist/cjs/execution/query-runner.d.ts.map +1 -0
- package/dist/cjs/execution/query-runner.js +751 -0
- package/dist/cjs/execution/query-runner.js.map +1 -0
- package/dist/cjs/execution/rate-limiter.d.ts +120 -0
- package/dist/cjs/execution/rate-limiter.d.ts.map +1 -0
- package/dist/cjs/execution/rate-limiter.js +273 -0
- package/dist/cjs/execution/rate-limiter.js.map +1 -0
- package/dist/cjs/execution/search-path.d.ts +161 -0
- package/dist/cjs/execution/search-path.d.ts.map +1 -0
- package/dist/cjs/execution/search-path.js +279 -0
- package/dist/cjs/execution/search-path.js.map +1 -0
- package/dist/cjs/execution/sql-parser.d.ts +195 -0
- package/dist/cjs/execution/sql-parser.d.ts.map +1 -0
- package/dist/cjs/execution/sql-parser.js +704 -0
- package/dist/cjs/execution/sql-parser.js.map +1 -0
- package/dist/cjs/execution/statement-classifier.d.ts +103 -0
- package/dist/cjs/execution/statement-classifier.d.ts.map +1 -0
- package/dist/cjs/execution/statement-classifier.js +535 -0
- package/dist/cjs/execution/statement-classifier.js.map +1 -0
- package/dist/cjs/execution/types.d.ts +189 -0
- package/dist/cjs/execution/types.d.ts.map +1 -0
- package/dist/cjs/execution/types.js +28 -0
- package/dist/cjs/execution/types.js.map +1 -0
- package/dist/cjs/index.d.ts +34 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +98 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/permissions/auto-upgrade.d.ts +40 -0
- package/dist/cjs/permissions/auto-upgrade.d.ts.map +1 -0
- package/dist/cjs/permissions/auto-upgrade.js +168 -0
- package/dist/cjs/permissions/auto-upgrade.js.map +1 -0
- package/dist/cjs/permissions/checker.d.ts +53 -0
- package/dist/cjs/permissions/checker.d.ts.map +1 -0
- package/dist/cjs/permissions/checker.js +326 -0
- package/dist/cjs/permissions/checker.js.map +1 -0
- package/dist/cjs/permissions/manual-approval.d.ts +213 -0
- package/dist/cjs/permissions/manual-approval.d.ts.map +1 -0
- package/dist/cjs/permissions/manual-approval.js +541 -0
- package/dist/cjs/permissions/manual-approval.js.map +1 -0
- package/dist/cjs/permissions/plan-registry.d.ts +274 -0
- package/dist/cjs/permissions/plan-registry.d.ts.map +1 -0
- package/dist/cjs/permissions/plan-registry.js +454 -0
- package/dist/cjs/permissions/plan-registry.js.map +1 -0
- package/dist/cjs/permissions/role-policy.d.ts +217 -0
- package/dist/cjs/permissions/role-policy.d.ts.map +1 -0
- package/dist/cjs/permissions/role-policy.js +584 -0
- package/dist/cjs/permissions/role-policy.js.map +1 -0
- package/dist/cjs/permissions/types.d.ts +126 -0
- package/dist/cjs/permissions/types.d.ts.map +1 -0
- package/dist/cjs/permissions/types.js +3 -0
- package/dist/cjs/permissions/types.js.map +1 -0
- package/dist/cjs/protocol/constants.d.ts +72 -0
- package/dist/cjs/protocol/constants.d.ts.map +1 -0
- package/dist/cjs/protocol/constants.js +107 -0
- package/dist/cjs/protocol/constants.js.map +1 -0
- package/dist/cjs/protocol/envelope.d.ts +165 -0
- package/dist/cjs/protocol/envelope.d.ts.map +1 -0
- package/dist/cjs/protocol/envelope.js +309 -0
- package/dist/cjs/protocol/envelope.js.map +1 -0
- package/dist/cjs/protocol/errors.d.ts +33 -0
- package/dist/cjs/protocol/errors.d.ts.map +1 -0
- package/dist/cjs/protocol/errors.js +391 -0
- package/dist/cjs/protocol/errors.js.map +1 -0
- package/dist/cjs/protocol/messages.d.ts +327 -0
- package/dist/cjs/protocol/messages.d.ts.map +1 -0
- package/dist/cjs/protocol/messages.js +3 -0
- package/dist/cjs/protocol/messages.js.map +1 -0
- package/dist/cjs/protocol/serialize.d.ts +26 -0
- package/dist/cjs/protocol/serialize.d.ts.map +1 -0
- package/dist/cjs/protocol/serialize.js +71 -0
- package/dist/cjs/protocol/serialize.js.map +1 -0
- package/dist/cjs/protocol/validate.d.ts +135 -0
- package/dist/cjs/protocol/validate.d.ts.map +1 -0
- package/dist/cjs/protocol/validate.js +852 -0
- package/dist/cjs/protocol/validate.js.map +1 -0
- package/dist/esm/audit/chain.d.ts +365 -0
- package/dist/esm/audit/chain.d.ts.map +1 -0
- package/dist/esm/audit/chain.js +895 -0
- package/dist/esm/audit/chain.js.map +1 -0
- package/dist/esm/audit/cloud-client.d.ts +142 -0
- package/dist/esm/audit/cloud-client.d.ts.map +1 -0
- package/dist/esm/audit/cloud-client.js +326 -0
- package/dist/esm/audit/cloud-client.js.map +1 -0
- package/dist/esm/audit/cloud-writer.d.ts +57 -0
- package/dist/esm/audit/cloud-writer.d.ts.map +1 -0
- package/dist/esm/audit/cloud-writer.js +91 -0
- package/dist/esm/audit/cloud-writer.js.map +1 -0
- package/dist/esm/audit/context.d.ts +51 -0
- package/dist/esm/audit/context.d.ts.map +1 -0
- package/dist/esm/audit/context.js +69 -0
- package/dist/esm/audit/context.js.map +1 -0
- package/dist/esm/audit/files.d.ts +111 -0
- package/dist/esm/audit/files.d.ts.map +1 -0
- package/dist/esm/audit/files.js +361 -0
- package/dist/esm/audit/files.js.map +1 -0
- package/dist/esm/audit/index.d.ts +9 -0
- package/dist/esm/audit/index.d.ts.map +1 -0
- package/dist/esm/audit/index.js +8 -0
- package/dist/esm/audit/index.js.map +1 -0
- package/dist/esm/audit/local-writer.d.ts +255 -0
- package/dist/esm/audit/local-writer.d.ts.map +1 -0
- package/dist/esm/audit/local-writer.js +785 -0
- package/dist/esm/audit/local-writer.js.map +1 -0
- package/dist/esm/audit/redact.d.ts +151 -0
- package/dist/esm/audit/redact.d.ts.map +1 -0
- package/dist/esm/audit/redact.js +506 -0
- package/dist/esm/audit/redact.js.map +1 -0
- package/dist/esm/audit/sanitize.d.ts +78 -0
- package/dist/esm/audit/sanitize.d.ts.map +1 -0
- package/dist/esm/audit/sanitize.js +307 -0
- package/dist/esm/audit/sanitize.js.map +1 -0
- package/dist/esm/audit/sink.d.ts +278 -0
- package/dist/esm/audit/sink.d.ts.map +1 -0
- package/dist/esm/audit/sink.js +782 -0
- package/dist/esm/audit/sink.js.map +1 -0
- package/dist/esm/audit/types.d.ts +226 -0
- package/dist/esm/audit/types.d.ts.map +1 -0
- package/dist/esm/audit/types.js +2 -0
- package/dist/esm/audit/types.js.map +1 -0
- package/dist/esm/audit/verify-cache.d.ts +127 -0
- package/dist/esm/audit/verify-cache.d.ts.map +1 -0
- package/dist/esm/audit/verify-cache.js +628 -0
- package/dist/esm/audit/verify-cache.js.map +1 -0
- package/dist/esm/channels/agent-session.d.ts +228 -0
- package/dist/esm/channels/agent-session.d.ts.map +1 -0
- package/dist/esm/channels/agent-session.js +566 -0
- package/dist/esm/channels/agent-session.js.map +1 -0
- package/dist/esm/channels/data-channel.d.ts +181 -0
- package/dist/esm/channels/data-channel.d.ts.map +1 -0
- package/dist/esm/channels/data-channel.js +567 -0
- package/dist/esm/channels/data-channel.js.map +1 -0
- package/dist/esm/channels/reconnect.d.ts +142 -0
- package/dist/esm/channels/reconnect.d.ts.map +1 -0
- package/dist/esm/channels/reconnect.js +234 -0
- package/dist/esm/channels/reconnect.js.map +1 -0
- package/dist/esm/channels/types.d.ts +112 -0
- package/dist/esm/channels/types.d.ts.map +1 -0
- package/dist/esm/channels/types.js +2 -0
- package/dist/esm/channels/types.js.map +1 -0
- package/dist/esm/channels/wake-channel.d.ts +232 -0
- package/dist/esm/channels/wake-channel.d.ts.map +1 -0
- package/dist/esm/channels/wake-channel.js +715 -0
- package/dist/esm/channels/wake-channel.js.map +1 -0
- package/dist/esm/cli/banner.d.ts +2 -0
- package/dist/esm/cli/banner.d.ts.map +1 -0
- package/dist/esm/cli/banner.js +114 -0
- package/dist/esm/cli/banner.js.map +1 -0
- package/dist/esm/cli/commands/agent.d.ts +30 -0
- package/dist/esm/cli/commands/agent.d.ts.map +1 -0
- package/dist/esm/cli/commands/agent.js +204 -0
- package/dist/esm/cli/commands/agent.js.map +1 -0
- package/dist/esm/cli/commands/audit-verify.d.ts +19 -0
- package/dist/esm/cli/commands/audit-verify.d.ts.map +1 -0
- package/dist/esm/cli/commands/audit-verify.js +345 -0
- package/dist/esm/cli/commands/audit-verify.js.map +1 -0
- package/dist/esm/cli/commands/clean.d.ts +23 -0
- package/dist/esm/cli/commands/clean.d.ts.map +1 -0
- package/dist/esm/cli/commands/clean.js +235 -0
- package/dist/esm/cli/commands/clean.js.map +1 -0
- package/dist/esm/cli/commands/config-show.d.ts +2 -0
- package/dist/esm/cli/commands/config-show.d.ts.map +1 -0
- package/dist/esm/cli/commands/config-show.js +2 -0
- package/dist/esm/cli/commands/config-show.js.map +1 -0
- package/dist/esm/cli/commands/config.d.ts +6 -0
- package/dist/esm/cli/commands/config.d.ts.map +1 -0
- package/dist/esm/cli/commands/config.js +259 -0
- package/dist/esm/cli/commands/config.js.map +1 -0
- package/dist/esm/cli/commands/db-add.d.ts +16 -0
- package/dist/esm/cli/commands/db-add.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-add.js +576 -0
- package/dist/esm/cli/commands/db-add.js.map +1 -0
- package/dist/esm/cli/commands/db-edit.d.ts +2 -0
- package/dist/esm/cli/commands/db-edit.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-edit.js +352 -0
- package/dist/esm/cli/commands/db-edit.js.map +1 -0
- package/dist/esm/cli/commands/db-logs.d.ts +3 -0
- package/dist/esm/cli/commands/db-logs.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-logs.js +64 -0
- package/dist/esm/cli/commands/db-logs.js.map +1 -0
- package/dist/esm/cli/commands/db-ls.d.ts +2 -0
- package/dist/esm/cli/commands/db-ls.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-ls.js +115 -0
- package/dist/esm/cli/commands/db-ls.js.map +1 -0
- package/dist/esm/cli/commands/db-query.d.ts +121 -0
- package/dist/esm/cli/commands/db-query.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-query.js +754 -0
- package/dist/esm/cli/commands/db-query.js.map +1 -0
- package/dist/esm/cli/commands/db-remove.d.ts +2 -0
- package/dist/esm/cli/commands/db-remove.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-remove.js +48 -0
- package/dist/esm/cli/commands/db-remove.js.map +1 -0
- package/dist/esm/cli/commands/db-show.d.ts +2 -0
- package/dist/esm/cli/commands/db-show.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-show.js +131 -0
- package/dist/esm/cli/commands/db-show.js.map +1 -0
- package/dist/esm/cli/commands/db-test.d.ts +3 -0
- package/dist/esm/cli/commands/db-test.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-test.js +307 -0
- package/dist/esm/cli/commands/db-test.js.map +1 -0
- package/dist/esm/cli/commands/db.d.ts +11 -0
- package/dist/esm/cli/commands/db.d.ts.map +1 -0
- package/dist/esm/cli/commands/db.js +76 -0
- package/dist/esm/cli/commands/db.js.map +1 -0
- package/dist/esm/cli/commands/debug.d.ts +2 -0
- package/dist/esm/cli/commands/debug.d.ts.map +1 -0
- package/dist/esm/cli/commands/debug.js +205 -0
- package/dist/esm/cli/commands/debug.js.map +1 -0
- package/dist/esm/cli/commands/doctor.d.ts +5 -0
- package/dist/esm/cli/commands/doctor.d.ts.map +1 -0
- package/dist/esm/cli/commands/doctor.js +114 -0
- package/dist/esm/cli/commands/doctor.js.map +1 -0
- package/dist/esm/cli/commands/index.d.ts +10 -0
- package/dist/esm/cli/commands/index.d.ts.map +1 -0
- package/dist/esm/cli/commands/index.js +10 -0
- package/dist/esm/cli/commands/index.js.map +1 -0
- package/dist/esm/cli/commands/init.d.ts +2 -0
- package/dist/esm/cli/commands/init.d.ts.map +1 -0
- package/dist/esm/cli/commands/init.js +163 -0
- package/dist/esm/cli/commands/init.js.map +1 -0
- package/dist/esm/cli/commands/link.d.ts +5 -0
- package/dist/esm/cli/commands/link.d.ts.map +1 -0
- package/dist/esm/cli/commands/link.js +41 -0
- package/dist/esm/cli/commands/link.js.map +1 -0
- package/dist/esm/cli/commands/logs.d.ts +17 -0
- package/dist/esm/cli/commands/logs.d.ts.map +1 -0
- package/dist/esm/cli/commands/logs.js +278 -0
- package/dist/esm/cli/commands/logs.js.map +1 -0
- package/dist/esm/cli/commands/project-show.d.ts +2 -0
- package/dist/esm/cli/commands/project-show.d.ts.map +1 -0
- package/dist/esm/cli/commands/project-show.js +69 -0
- package/dist/esm/cli/commands/project-show.js.map +1 -0
- package/dist/esm/cli/commands/project.d.ts +3 -0
- package/dist/esm/cli/commands/project.d.ts.map +1 -0
- package/dist/esm/cli/commands/project.js +60 -0
- package/dist/esm/cli/commands/project.js.map +1 -0
- package/dist/esm/cli/commands/service.d.ts +123 -0
- package/dist/esm/cli/commands/service.d.ts.map +1 -0
- package/dist/esm/cli/commands/service.js +505 -0
- package/dist/esm/cli/commands/service.js.map +1 -0
- package/dist/esm/cli/commands/start.d.ts +6 -0
- package/dist/esm/cli/commands/start.d.ts.map +1 -0
- package/dist/esm/cli/commands/start.js +272 -0
- package/dist/esm/cli/commands/start.js.map +1 -0
- package/dist/esm/cli/commands/status.d.ts +2 -0
- package/dist/esm/cli/commands/status.d.ts.map +1 -0
- package/dist/esm/cli/commands/status.js +222 -0
- package/dist/esm/cli/commands/status.js.map +1 -0
- package/dist/esm/cli/commands/stop.d.ts +6 -0
- package/dist/esm/cli/commands/stop.d.ts.map +1 -0
- package/dist/esm/cli/commands/stop.js +96 -0
- package/dist/esm/cli/commands/stop.js.map +1 -0
- package/dist/esm/cli/daemon/error-tracker.d.ts +119 -0
- package/dist/esm/cli/daemon/error-tracker.d.ts.map +1 -0
- package/dist/esm/cli/daemon/error-tracker.js +451 -0
- package/dist/esm/cli/daemon/error-tracker.js.map +1 -0
- package/dist/esm/cli/daemon/fault-shutdown.d.ts +144 -0
- package/dist/esm/cli/daemon/fault-shutdown.d.ts.map +1 -0
- package/dist/esm/cli/daemon/fault-shutdown.js +273 -0
- package/dist/esm/cli/daemon/fault-shutdown.js.map +1 -0
- package/dist/esm/cli/daemon/index.d.ts +12 -0
- package/dist/esm/cli/daemon/index.d.ts.map +1 -0
- package/dist/esm/cli/daemon/index.js +7 -0
- package/dist/esm/cli/daemon/index.js.map +1 -0
- package/dist/esm/cli/daemon/pid-file.d.ts +13 -0
- package/dist/esm/cli/daemon/pid-file.d.ts.map +1 -0
- package/dist/esm/cli/daemon/pid-file.js +51 -0
- package/dist/esm/cli/daemon/pid-file.js.map +1 -0
- package/dist/esm/cli/daemon/readiness.d.ts +30 -0
- package/dist/esm/cli/daemon/readiness.d.ts.map +1 -0
- package/dist/esm/cli/daemon/readiness.js +70 -0
- package/dist/esm/cli/daemon/readiness.js.map +1 -0
- package/dist/esm/cli/daemon/runtime.d.ts +366 -0
- package/dist/esm/cli/daemon/runtime.d.ts.map +1 -0
- package/dist/esm/cli/daemon/runtime.js +1284 -0
- package/dist/esm/cli/daemon/runtime.js.map +1 -0
- package/dist/esm/cli/daemon/shutdown.d.ts +7 -0
- package/dist/esm/cli/daemon/shutdown.d.ts.map +1 -0
- package/dist/esm/cli/daemon/shutdown.js +63 -0
- package/dist/esm/cli/daemon/shutdown.js.map +1 -0
- package/dist/esm/cli/daemon/signal-handlers.d.ts +3 -0
- package/dist/esm/cli/daemon/signal-handlers.d.ts.map +1 -0
- package/dist/esm/cli/daemon/signal-handlers.js +24 -0
- package/dist/esm/cli/daemon/signal-handlers.js.map +1 -0
- package/dist/esm/cli/daemon/state.d.ts +157 -0
- package/dist/esm/cli/daemon/state.d.ts.map +1 -0
- package/dist/esm/cli/daemon/state.js +352 -0
- package/dist/esm/cli/daemon/state.js.map +1 -0
- package/dist/esm/cli/daemon/status-file.d.ts +139 -0
- package/dist/esm/cli/daemon/status-file.d.ts.map +1 -0
- package/dist/esm/cli/daemon/status-file.js +50 -0
- package/dist/esm/cli/daemon/status-file.js.map +1 -0
- package/dist/esm/cli/doctor/checks.d.ts +133 -0
- package/dist/esm/cli/doctor/checks.d.ts.map +1 -0
- package/dist/esm/cli/doctor/checks.js +624 -0
- package/dist/esm/cli/doctor/checks.js.map +1 -0
- package/dist/esm/cli/doctor/fixes.d.ts +9 -0
- package/dist/esm/cli/doctor/fixes.d.ts.map +1 -0
- package/dist/esm/cli/doctor/fixes.js +163 -0
- package/dist/esm/cli/doctor/fixes.js.map +1 -0
- package/dist/esm/cli/doctor/index.d.ts +7 -0
- package/dist/esm/cli/doctor/index.d.ts.map +1 -0
- package/dist/esm/cli/doctor/index.js +5 -0
- package/dist/esm/cli/doctor/index.js.map +1 -0
- package/dist/esm/cli/index.d.ts +3 -0
- package/dist/esm/cli/index.d.ts.map +1 -0
- package/dist/esm/cli/index.js +333 -0
- package/dist/esm/cli/index.js.map +1 -0
- package/dist/esm/cli/interactive.d.ts +8 -0
- package/dist/esm/cli/interactive.d.ts.map +1 -0
- package/dist/esm/cli/interactive.js +665 -0
- package/dist/esm/cli/interactive.js.map +1 -0
- package/dist/esm/cli/logs/format.d.ts +13 -0
- package/dist/esm/cli/logs/format.d.ts.map +1 -0
- package/dist/esm/cli/logs/format.js +169 -0
- package/dist/esm/cli/logs/format.js.map +1 -0
- package/dist/esm/cli/logs/index.d.ts +3 -0
- package/dist/esm/cli/logs/index.d.ts.map +1 -0
- package/dist/esm/cli/logs/index.js +3 -0
- package/dist/esm/cli/logs/index.js.map +1 -0
- package/dist/esm/cli/logs/viewer.d.ts +41 -0
- package/dist/esm/cli/logs/viewer.d.ts.map +1 -0
- package/dist/esm/cli/logs/viewer.js +412 -0
- package/dist/esm/cli/logs/viewer.js.map +1 -0
- package/dist/esm/cli/ops/operation-logger.d.ts +63 -0
- package/dist/esm/cli/ops/operation-logger.d.ts.map +1 -0
- package/dist/esm/cli/ops/operation-logger.js +142 -0
- package/dist/esm/cli/ops/operation-logger.js.map +1 -0
- package/dist/esm/cli/palette.d.ts +11 -0
- package/dist/esm/cli/palette.d.ts.map +1 -0
- package/dist/esm/cli/palette.js +240 -0
- package/dist/esm/cli/palette.js.map +1 -0
- package/dist/esm/cli/prompt.d.ts +186 -0
- package/dist/esm/cli/prompt.d.ts.map +1 -0
- package/dist/esm/cli/prompt.js +483 -0
- package/dist/esm/cli/prompt.js.map +1 -0
- package/dist/esm/cli/ui/box.d.ts +21 -0
- package/dist/esm/cli/ui/box.d.ts.map +1 -0
- package/dist/esm/cli/ui/box.js +60 -0
- package/dist/esm/cli/ui/box.js.map +1 -0
- package/dist/esm/cli/ui/clipboard.d.ts +6 -0
- package/dist/esm/cli/ui/clipboard.d.ts.map +1 -0
- package/dist/esm/cli/ui/clipboard.js +42 -0
- package/dist/esm/cli/ui/clipboard.js.map +1 -0
- package/dist/esm/cli/ui/colors.d.ts +57 -0
- package/dist/esm/cli/ui/colors.d.ts.map +1 -0
- package/dist/esm/cli/ui/colors.js +126 -0
- package/dist/esm/cli/ui/colors.js.map +1 -0
- package/dist/esm/cli/ui/index.d.ts +9 -0
- package/dist/esm/cli/ui/index.d.ts.map +1 -0
- package/dist/esm/cli/ui/index.js +7 -0
- package/dist/esm/cli/ui/index.js.map +1 -0
- package/dist/esm/cli/ui/spinner.d.ts +12 -0
- package/dist/esm/cli/ui/spinner.d.ts.map +1 -0
- package/dist/esm/cli/ui/spinner.js +78 -0
- package/dist/esm/cli/ui/spinner.js.map +1 -0
- package/dist/esm/cli/ui/symbols.d.ts +47 -0
- package/dist/esm/cli/ui/symbols.d.ts.map +1 -0
- package/dist/esm/cli/ui/symbols.js +109 -0
- package/dist/esm/cli/ui/symbols.js.map +1 -0
- package/dist/esm/cli/ui/table.d.ts +23 -0
- package/dist/esm/cli/ui/table.d.ts.map +1 -0
- package/dist/esm/cli/ui/table.js +156 -0
- package/dist/esm/cli/ui/table.js.map +1 -0
- package/dist/esm/cli/ui/terminal.d.ts +7 -0
- package/dist/esm/cli/ui/terminal.d.ts.map +1 -0
- package/dist/esm/cli/ui/terminal.js +32 -0
- package/dist/esm/cli/ui/terminal.js.map +1 -0
- package/dist/esm/config/atomic-write.d.ts +69 -0
- package/dist/esm/config/atomic-write.d.ts.map +1 -0
- package/dist/esm/config/atomic-write.js +246 -0
- package/dist/esm/config/atomic-write.js.map +1 -0
- package/dist/esm/config/db-config.d.ts +134 -0
- package/dist/esm/config/db-config.d.ts.map +1 -0
- package/dist/esm/config/db-config.js +542 -0
- package/dist/esm/config/db-config.js.map +1 -0
- package/dist/esm/config/machine-config.d.ts +85 -0
- package/dist/esm/config/machine-config.d.ts.map +1 -0
- package/dist/esm/config/machine-config.js +190 -0
- package/dist/esm/config/machine-config.js.map +1 -0
- package/dist/esm/config/paths.d.ts +64 -0
- package/dist/esm/config/paths.d.ts.map +1 -0
- package/dist/esm/config/paths.js +108 -0
- package/dist/esm/config/paths.js.map +1 -0
- package/dist/esm/config/schema.d.ts +72 -0
- package/dist/esm/config/schema.d.ts.map +1 -0
- package/dist/esm/config/schema.js +180 -0
- package/dist/esm/config/schema.js.map +1 -0
- package/dist/esm/config/token.d.ts +63 -0
- package/dist/esm/config/token.d.ts.map +1 -0
- package/dist/esm/config/token.js +104 -0
- package/dist/esm/config/token.js.map +1 -0
- package/dist/esm/execution/canceller.d.ts +41 -0
- package/dist/esm/execution/canceller.d.ts.map +1 -0
- package/dist/esm/execution/canceller.js +205 -0
- package/dist/esm/execution/canceller.js.map +1 -0
- package/dist/esm/execution/database-lookup.d.ts +56 -0
- package/dist/esm/execution/database-lookup.d.ts.map +1 -0
- package/dist/esm/execution/database-lookup.js +38 -0
- package/dist/esm/execution/database-lookup.js.map +1 -0
- package/dist/esm/execution/dispatcher.d.ts +181 -0
- package/dist/esm/execution/dispatcher.d.ts.map +1 -0
- package/dist/esm/execution/dispatcher.js +1258 -0
- package/dist/esm/execution/dispatcher.js.map +1 -0
- package/dist/esm/execution/function-effects.d.ts +209 -0
- package/dist/esm/execution/function-effects.d.ts.map +1 -0
- package/dist/esm/execution/function-effects.js +586 -0
- package/dist/esm/execution/function-effects.js.map +1 -0
- package/dist/esm/execution/introspection.d.ts +76 -0
- package/dist/esm/execution/introspection.d.ts.map +1 -0
- package/dist/esm/execution/introspection.js +442 -0
- package/dist/esm/execution/introspection.js.map +1 -0
- package/dist/esm/execution/migration-runner.d.ts +128 -0
- package/dist/esm/execution/migration-runner.d.ts.map +1 -0
- package/dist/esm/execution/migration-runner.js +754 -0
- package/dist/esm/execution/migration-runner.js.map +1 -0
- package/dist/esm/execution/non-tx-detector.d.ts +23 -0
- package/dist/esm/execution/non-tx-detector.d.ts.map +1 -0
- package/dist/esm/execution/non-tx-detector.js +215 -0
- package/dist/esm/execution/non-tx-detector.js.map +1 -0
- package/dist/esm/execution/pool.d.ts +229 -0
- package/dist/esm/execution/pool.d.ts.map +1 -0
- package/dist/esm/execution/pool.js +685 -0
- package/dist/esm/execution/pool.js.map +1 -0
- package/dist/esm/execution/query-runner.d.ts +88 -0
- package/dist/esm/execution/query-runner.d.ts.map +1 -0
- package/dist/esm/execution/query-runner.js +743 -0
- package/dist/esm/execution/query-runner.js.map +1 -0
- package/dist/esm/execution/rate-limiter.d.ts +120 -0
- package/dist/esm/execution/rate-limiter.d.ts.map +1 -0
- package/dist/esm/execution/rate-limiter.js +269 -0
- package/dist/esm/execution/rate-limiter.js.map +1 -0
- package/dist/esm/execution/search-path.d.ts +161 -0
- package/dist/esm/execution/search-path.d.ts.map +1 -0
- package/dist/esm/execution/search-path.js +270 -0
- package/dist/esm/execution/search-path.js.map +1 -0
- package/dist/esm/execution/sql-parser.d.ts +195 -0
- package/dist/esm/execution/sql-parser.d.ts.map +1 -0
- package/dist/esm/execution/sql-parser.js +683 -0
- package/dist/esm/execution/sql-parser.js.map +1 -0
- package/dist/esm/execution/statement-classifier.d.ts +103 -0
- package/dist/esm/execution/statement-classifier.d.ts.map +1 -0
- package/dist/esm/execution/statement-classifier.js +526 -0
- package/dist/esm/execution/statement-classifier.js.map +1 -0
- package/dist/esm/execution/types.d.ts +189 -0
- package/dist/esm/execution/types.d.ts.map +1 -0
- package/dist/esm/execution/types.js +22 -0
- package/dist/esm/execution/types.js.map +1 -0
- package/dist/esm/index.d.ts +34 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +38 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/permissions/auto-upgrade.d.ts +40 -0
- package/dist/esm/permissions/auto-upgrade.d.ts.map +1 -0
- package/dist/esm/permissions/auto-upgrade.js +164 -0
- package/dist/esm/permissions/auto-upgrade.js.map +1 -0
- package/dist/esm/permissions/checker.d.ts +53 -0
- package/dist/esm/permissions/checker.d.ts.map +1 -0
- package/dist/esm/permissions/checker.js +322 -0
- package/dist/esm/permissions/checker.js.map +1 -0
- package/dist/esm/permissions/manual-approval.d.ts +213 -0
- package/dist/esm/permissions/manual-approval.d.ts.map +1 -0
- package/dist/esm/permissions/manual-approval.js +503 -0
- package/dist/esm/permissions/manual-approval.js.map +1 -0
- package/dist/esm/permissions/plan-registry.d.ts +274 -0
- package/dist/esm/permissions/plan-registry.d.ts.map +1 -0
- package/dist/esm/permissions/plan-registry.js +450 -0
- package/dist/esm/permissions/plan-registry.js.map +1 -0
- package/dist/esm/permissions/role-policy.d.ts +217 -0
- package/dist/esm/permissions/role-policy.d.ts.map +1 -0
- package/dist/esm/permissions/role-policy.js +570 -0
- package/dist/esm/permissions/role-policy.js.map +1 -0
- package/dist/esm/permissions/types.d.ts +126 -0
- package/dist/esm/permissions/types.d.ts.map +1 -0
- package/dist/esm/permissions/types.js +2 -0
- package/dist/esm/permissions/types.js.map +1 -0
- package/dist/esm/protocol/constants.d.ts +72 -0
- package/dist/esm/protocol/constants.d.ts.map +1 -0
- package/dist/esm/protocol/constants.js +104 -0
- package/dist/esm/protocol/constants.js.map +1 -0
- package/dist/esm/protocol/envelope.d.ts +165 -0
- package/dist/esm/protocol/envelope.d.ts.map +1 -0
- package/dist/esm/protocol/envelope.js +263 -0
- package/dist/esm/protocol/envelope.js.map +1 -0
- package/dist/esm/protocol/errors.d.ts +33 -0
- package/dist/esm/protocol/errors.d.ts.map +1 -0
- package/dist/esm/protocol/errors.js +384 -0
- package/dist/esm/protocol/errors.js.map +1 -0
- package/dist/esm/protocol/messages.d.ts +327 -0
- package/dist/esm/protocol/messages.d.ts.map +1 -0
- package/dist/esm/protocol/messages.js +2 -0
- package/dist/esm/protocol/messages.js.map +1 -0
- package/dist/esm/protocol/serialize.d.ts +26 -0
- package/dist/esm/protocol/serialize.d.ts.map +1 -0
- package/dist/esm/protocol/serialize.js +63 -0
- package/dist/esm/protocol/serialize.js.map +1 -0
- package/dist/esm/protocol/validate.d.ts +135 -0
- package/dist/esm/protocol/validate.d.ts.map +1 -0
- package/dist/esm/protocol/validate.js +830 -0
- package/dist/esm/protocol/validate.js.map +1 -0
- package/dist/types/audit/chain.d.ts +365 -0
- package/dist/types/audit/chain.d.ts.map +1 -0
- package/dist/types/audit/cloud-client.d.ts +142 -0
- package/dist/types/audit/cloud-client.d.ts.map +1 -0
- package/dist/types/audit/cloud-writer.d.ts +57 -0
- package/dist/types/audit/cloud-writer.d.ts.map +1 -0
- package/dist/types/audit/context.d.ts +51 -0
- package/dist/types/audit/context.d.ts.map +1 -0
- package/dist/types/audit/files.d.ts +111 -0
- package/dist/types/audit/files.d.ts.map +1 -0
- package/dist/types/audit/index.d.ts +9 -0
- package/dist/types/audit/index.d.ts.map +1 -0
- package/dist/types/audit/local-writer.d.ts +255 -0
- package/dist/types/audit/local-writer.d.ts.map +1 -0
- package/dist/types/audit/redact.d.ts +151 -0
- package/dist/types/audit/redact.d.ts.map +1 -0
- package/dist/types/audit/sanitize.d.ts +78 -0
- package/dist/types/audit/sanitize.d.ts.map +1 -0
- package/dist/types/audit/sink.d.ts +278 -0
- package/dist/types/audit/sink.d.ts.map +1 -0
- package/dist/types/audit/types.d.ts +226 -0
- package/dist/types/audit/types.d.ts.map +1 -0
- package/dist/types/audit/verify-cache.d.ts +127 -0
- package/dist/types/audit/verify-cache.d.ts.map +1 -0
- package/dist/types/channels/agent-session.d.ts +228 -0
- package/dist/types/channels/agent-session.d.ts.map +1 -0
- package/dist/types/channels/data-channel.d.ts +181 -0
- package/dist/types/channels/data-channel.d.ts.map +1 -0
- package/dist/types/channels/reconnect.d.ts +142 -0
- package/dist/types/channels/reconnect.d.ts.map +1 -0
- package/dist/types/channels/types.d.ts +112 -0
- package/dist/types/channels/types.d.ts.map +1 -0
- package/dist/types/channels/wake-channel.d.ts +232 -0
- package/dist/types/channels/wake-channel.d.ts.map +1 -0
- package/dist/types/cli/banner.d.ts +2 -0
- package/dist/types/cli/banner.d.ts.map +1 -0
- package/dist/types/cli/commands/agent.d.ts +30 -0
- package/dist/types/cli/commands/agent.d.ts.map +1 -0
- package/dist/types/cli/commands/audit-verify.d.ts +19 -0
- package/dist/types/cli/commands/audit-verify.d.ts.map +1 -0
- package/dist/types/cli/commands/clean.d.ts +23 -0
- package/dist/types/cli/commands/clean.d.ts.map +1 -0
- package/dist/types/cli/commands/config-show.d.ts +2 -0
- package/dist/types/cli/commands/config-show.d.ts.map +1 -0
- package/dist/types/cli/commands/config.d.ts +6 -0
- package/dist/types/cli/commands/config.d.ts.map +1 -0
- package/dist/types/cli/commands/db-add.d.ts +16 -0
- package/dist/types/cli/commands/db-add.d.ts.map +1 -0
- package/dist/types/cli/commands/db-edit.d.ts +2 -0
- package/dist/types/cli/commands/db-edit.d.ts.map +1 -0
- package/dist/types/cli/commands/db-logs.d.ts +3 -0
- package/dist/types/cli/commands/db-logs.d.ts.map +1 -0
- package/dist/types/cli/commands/db-ls.d.ts +2 -0
- package/dist/types/cli/commands/db-ls.d.ts.map +1 -0
- package/dist/types/cli/commands/db-query.d.ts +121 -0
- package/dist/types/cli/commands/db-query.d.ts.map +1 -0
- package/dist/types/cli/commands/db-remove.d.ts +2 -0
- package/dist/types/cli/commands/db-remove.d.ts.map +1 -0
- package/dist/types/cli/commands/db-show.d.ts +2 -0
- package/dist/types/cli/commands/db-show.d.ts.map +1 -0
- package/dist/types/cli/commands/db-test.d.ts +3 -0
- package/dist/types/cli/commands/db-test.d.ts.map +1 -0
- package/dist/types/cli/commands/db.d.ts +11 -0
- package/dist/types/cli/commands/db.d.ts.map +1 -0
- package/dist/types/cli/commands/debug.d.ts +2 -0
- package/dist/types/cli/commands/debug.d.ts.map +1 -0
- package/dist/types/cli/commands/doctor.d.ts +5 -0
- package/dist/types/cli/commands/doctor.d.ts.map +1 -0
- package/dist/types/cli/commands/index.d.ts +10 -0
- package/dist/types/cli/commands/index.d.ts.map +1 -0
- package/dist/types/cli/commands/init.d.ts +2 -0
- package/dist/types/cli/commands/init.d.ts.map +1 -0
- package/dist/types/cli/commands/link.d.ts +5 -0
- package/dist/types/cli/commands/link.d.ts.map +1 -0
- package/dist/types/cli/commands/logs.d.ts +17 -0
- package/dist/types/cli/commands/logs.d.ts.map +1 -0
- package/dist/types/cli/commands/project-show.d.ts +2 -0
- package/dist/types/cli/commands/project-show.d.ts.map +1 -0
- package/dist/types/cli/commands/project.d.ts +3 -0
- package/dist/types/cli/commands/project.d.ts.map +1 -0
- package/dist/types/cli/commands/service.d.ts +123 -0
- package/dist/types/cli/commands/service.d.ts.map +1 -0
- package/dist/types/cli/commands/start.d.ts +6 -0
- package/dist/types/cli/commands/start.d.ts.map +1 -0
- package/dist/types/cli/commands/status.d.ts +2 -0
- package/dist/types/cli/commands/status.d.ts.map +1 -0
- package/dist/types/cli/commands/stop.d.ts +6 -0
- package/dist/types/cli/commands/stop.d.ts.map +1 -0
- package/dist/types/cli/daemon/error-tracker.d.ts +119 -0
- package/dist/types/cli/daemon/error-tracker.d.ts.map +1 -0
- package/dist/types/cli/daemon/fault-shutdown.d.ts +144 -0
- package/dist/types/cli/daemon/fault-shutdown.d.ts.map +1 -0
- package/dist/types/cli/daemon/index.d.ts +12 -0
- package/dist/types/cli/daemon/index.d.ts.map +1 -0
- package/dist/types/cli/daemon/pid-file.d.ts +13 -0
- package/dist/types/cli/daemon/pid-file.d.ts.map +1 -0
- package/dist/types/cli/daemon/readiness.d.ts +30 -0
- package/dist/types/cli/daemon/readiness.d.ts.map +1 -0
- package/dist/types/cli/daemon/runtime.d.ts +366 -0
- package/dist/types/cli/daemon/runtime.d.ts.map +1 -0
- package/dist/types/cli/daemon/shutdown.d.ts +7 -0
- package/dist/types/cli/daemon/shutdown.d.ts.map +1 -0
- package/dist/types/cli/daemon/signal-handlers.d.ts +3 -0
- package/dist/types/cli/daemon/signal-handlers.d.ts.map +1 -0
- package/dist/types/cli/daemon/state.d.ts +157 -0
- package/dist/types/cli/daemon/state.d.ts.map +1 -0
- package/dist/types/cli/daemon/status-file.d.ts +139 -0
- package/dist/types/cli/daemon/status-file.d.ts.map +1 -0
- package/dist/types/cli/doctor/checks.d.ts +133 -0
- package/dist/types/cli/doctor/checks.d.ts.map +1 -0
- package/dist/types/cli/doctor/fixes.d.ts +9 -0
- package/dist/types/cli/doctor/fixes.d.ts.map +1 -0
- package/dist/types/cli/doctor/index.d.ts +7 -0
- package/dist/types/cli/doctor/index.d.ts.map +1 -0
- package/dist/types/cli/index.d.ts +3 -0
- package/dist/types/cli/index.d.ts.map +1 -0
- package/dist/types/cli/interactive.d.ts +8 -0
- package/dist/types/cli/interactive.d.ts.map +1 -0
- package/dist/types/cli/logs/format.d.ts +13 -0
- package/dist/types/cli/logs/format.d.ts.map +1 -0
- package/dist/types/cli/logs/index.d.ts +3 -0
- package/dist/types/cli/logs/index.d.ts.map +1 -0
- package/dist/types/cli/logs/viewer.d.ts +41 -0
- package/dist/types/cli/logs/viewer.d.ts.map +1 -0
- package/dist/types/cli/ops/operation-logger.d.ts +63 -0
- package/dist/types/cli/ops/operation-logger.d.ts.map +1 -0
- package/dist/types/cli/palette.d.ts +11 -0
- package/dist/types/cli/palette.d.ts.map +1 -0
- package/dist/types/cli/prompt.d.ts +186 -0
- package/dist/types/cli/prompt.d.ts.map +1 -0
- package/dist/types/cli/ui/box.d.ts +21 -0
- package/dist/types/cli/ui/box.d.ts.map +1 -0
- package/dist/types/cli/ui/clipboard.d.ts +6 -0
- package/dist/types/cli/ui/clipboard.d.ts.map +1 -0
- package/dist/types/cli/ui/colors.d.ts +57 -0
- package/dist/types/cli/ui/colors.d.ts.map +1 -0
- package/dist/types/cli/ui/index.d.ts +9 -0
- package/dist/types/cli/ui/index.d.ts.map +1 -0
- package/dist/types/cli/ui/spinner.d.ts +12 -0
- package/dist/types/cli/ui/spinner.d.ts.map +1 -0
- package/dist/types/cli/ui/symbols.d.ts +47 -0
- package/dist/types/cli/ui/symbols.d.ts.map +1 -0
- package/dist/types/cli/ui/table.d.ts +23 -0
- package/dist/types/cli/ui/table.d.ts.map +1 -0
- package/dist/types/cli/ui/terminal.d.ts +7 -0
- package/dist/types/cli/ui/terminal.d.ts.map +1 -0
- package/dist/types/config/atomic-write.d.ts +69 -0
- package/dist/types/config/atomic-write.d.ts.map +1 -0
- package/dist/types/config/db-config.d.ts +134 -0
- package/dist/types/config/db-config.d.ts.map +1 -0
- package/dist/types/config/machine-config.d.ts +85 -0
- package/dist/types/config/machine-config.d.ts.map +1 -0
- package/dist/types/config/paths.d.ts +64 -0
- package/dist/types/config/paths.d.ts.map +1 -0
- package/dist/types/config/schema.d.ts +72 -0
- package/dist/types/config/schema.d.ts.map +1 -0
- package/dist/types/config/token.d.ts +63 -0
- package/dist/types/config/token.d.ts.map +1 -0
- package/dist/types/execution/canceller.d.ts +41 -0
- package/dist/types/execution/canceller.d.ts.map +1 -0
- package/dist/types/execution/database-lookup.d.ts +56 -0
- package/dist/types/execution/database-lookup.d.ts.map +1 -0
- package/dist/types/execution/dispatcher.d.ts +181 -0
- package/dist/types/execution/dispatcher.d.ts.map +1 -0
- package/dist/types/execution/function-effects.d.ts +209 -0
- package/dist/types/execution/function-effects.d.ts.map +1 -0
- package/dist/types/execution/introspection.d.ts +76 -0
- package/dist/types/execution/introspection.d.ts.map +1 -0
- package/dist/types/execution/migration-runner.d.ts +128 -0
- package/dist/types/execution/migration-runner.d.ts.map +1 -0
- package/dist/types/execution/non-tx-detector.d.ts +23 -0
- package/dist/types/execution/non-tx-detector.d.ts.map +1 -0
- package/dist/types/execution/pool.d.ts +229 -0
- package/dist/types/execution/pool.d.ts.map +1 -0
- package/dist/types/execution/query-runner.d.ts +88 -0
- package/dist/types/execution/query-runner.d.ts.map +1 -0
- package/dist/types/execution/rate-limiter.d.ts +120 -0
- package/dist/types/execution/rate-limiter.d.ts.map +1 -0
- package/dist/types/execution/search-path.d.ts +161 -0
- package/dist/types/execution/search-path.d.ts.map +1 -0
- package/dist/types/execution/sql-parser.d.ts +195 -0
- package/dist/types/execution/sql-parser.d.ts.map +1 -0
- package/dist/types/execution/statement-classifier.d.ts +103 -0
- package/dist/types/execution/statement-classifier.d.ts.map +1 -0
- package/dist/types/execution/types.d.ts +189 -0
- package/dist/types/execution/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/permissions/auto-upgrade.d.ts +40 -0
- package/dist/types/permissions/auto-upgrade.d.ts.map +1 -0
- package/dist/types/permissions/checker.d.ts +53 -0
- package/dist/types/permissions/checker.d.ts.map +1 -0
- package/dist/types/permissions/manual-approval.d.ts +213 -0
- package/dist/types/permissions/manual-approval.d.ts.map +1 -0
- package/dist/types/permissions/plan-registry.d.ts +274 -0
- package/dist/types/permissions/plan-registry.d.ts.map +1 -0
- package/dist/types/permissions/role-policy.d.ts +217 -0
- package/dist/types/permissions/role-policy.d.ts.map +1 -0
- package/dist/types/permissions/types.d.ts +126 -0
- package/dist/types/permissions/types.d.ts.map +1 -0
- package/dist/types/protocol/constants.d.ts +72 -0
- package/dist/types/protocol/constants.d.ts.map +1 -0
- package/dist/types/protocol/envelope.d.ts +165 -0
- package/dist/types/protocol/envelope.d.ts.map +1 -0
- package/dist/types/protocol/errors.d.ts +33 -0
- package/dist/types/protocol/errors.d.ts.map +1 -0
- package/dist/types/protocol/messages.d.ts +327 -0
- package/dist/types/protocol/messages.d.ts.map +1 -0
- package/dist/types/protocol/serialize.d.ts +26 -0
- package/dist/types/protocol/serialize.d.ts.map +1 -0
- package/dist/types/protocol/validate.d.ts +135 -0
- package/dist/types/protocol/validate.d.ts.map +1 -0
- package/package.json +116 -4
- package/scripts/generate-systemd-service.mjs +117 -0
|
@@ -0,0 +1,1343 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ALLOW_UNSCOPED_DATABASES_CONFIG_PATH = exports.ALLOW_UNSCOPED_DATABASES_CONFIG_KEY = exports.ALLOWED_DATABASES_CONFIG_KEY = exports.ALLOWED_DATABASES_ENV = exports.MAX_APPROVAL_TIMEOUT_MS = exports.MIN_APPROVAL_TIMEOUT_MS = exports.MAX_POOL_MAX = exports.MIN_POOL_MAX = exports.DEFAULT_POOL_MAX = exports.RuntimeStats = void 0;
|
|
37
|
+
exports.buildDaemonAuditStats = buildDaemonAuditStats;
|
|
38
|
+
exports.createAuditShutdown = createAuditShutdown;
|
|
39
|
+
exports.assertSecureRelayUrl = assertSecureRelayUrl;
|
|
40
|
+
exports.relayHostMismatchWarning = relayHostMismatchWarning;
|
|
41
|
+
exports.resolveRelayOverride = resolveRelayOverride;
|
|
42
|
+
exports.redactUrlForDisplay = redactUrlForDisplay;
|
|
43
|
+
exports.resolvePoolMax = resolvePoolMax;
|
|
44
|
+
exports.resolveApprovalTimeoutMs = resolveApprovalTimeoutMs;
|
|
45
|
+
exports.resolveStatementTimeoutMs = resolveStatementTimeoutMs;
|
|
46
|
+
exports.resolveMaxStreamRows = resolveMaxStreamRows;
|
|
47
|
+
exports.resolveE2EAdminGate = resolveE2EAdminGate;
|
|
48
|
+
exports.resolveSecurityPosture = resolveSecurityPosture;
|
|
49
|
+
exports.formatSecurityPosture = formatSecurityPosture;
|
|
50
|
+
exports.parseScopeRules = parseScopeRules;
|
|
51
|
+
exports.parseScopeEnv = parseScopeEnv;
|
|
52
|
+
exports.resolveDatabaseScope = resolveDatabaseScope;
|
|
53
|
+
exports.resolveDatabaseScopeDecision = resolveDatabaseScopeDecision;
|
|
54
|
+
exports.scopeAllowsEntry = scopeAllowsEntry;
|
|
55
|
+
exports.createLookupDb = createLookupDb;
|
|
56
|
+
exports.databaseScopeWarningLines = databaseScopeWarningLines;
|
|
57
|
+
exports.describeDatabaseScope = describeDatabaseScope;
|
|
58
|
+
exports.runAgent = runAgent;
|
|
59
|
+
const fs = __importStar(require("fs"));
|
|
60
|
+
const db_config_1 = require("../../config/db-config");
|
|
61
|
+
const paths_1 = require("../../config/paths");
|
|
62
|
+
const schema_1 = require("../../config/schema");
|
|
63
|
+
const pid_file_1 = require("./pid-file");
|
|
64
|
+
const status_file_1 = require("./status-file");
|
|
65
|
+
const shutdown_1 = require("./shutdown");
|
|
66
|
+
const signal_handlers_1 = require("./signal-handlers");
|
|
67
|
+
const state_1 = require("./state");
|
|
68
|
+
const error_tracker_1 = require("./error-tracker");
|
|
69
|
+
const operation_logger_1 = require("../ops/operation-logger");
|
|
70
|
+
const pool_1 = require("../../execution/pool");
|
|
71
|
+
const query_runner_1 = require("../../execution/query-runner");
|
|
72
|
+
const migration_runner_1 = require("../../execution/migration-runner");
|
|
73
|
+
const canceller_1 = require("../../execution/canceller");
|
|
74
|
+
const introspection_1 = require("../../execution/introspection");
|
|
75
|
+
const dispatcher_1 = require("../../execution/dispatcher");
|
|
76
|
+
const constants_1 = require("../../protocol/constants");
|
|
77
|
+
const envelope_1 = require("../../protocol/envelope");
|
|
78
|
+
const checker_1 = require("../../permissions/checker");
|
|
79
|
+
const plan_registry_1 = require("../../permissions/plan-registry");
|
|
80
|
+
const auto_upgrade_1 = require("../../permissions/auto-upgrade");
|
|
81
|
+
const manual_approval_1 = require("../../permissions/manual-approval");
|
|
82
|
+
const sink_1 = require("../../audit/sink");
|
|
83
|
+
const local_writer_1 = require("../../audit/local-writer");
|
|
84
|
+
const cloud_writer_1 = require("../../audit/cloud-writer");
|
|
85
|
+
const agent_session_1 = require("../../channels/agent-session");
|
|
86
|
+
const sql_parser_1 = require("../../execution/sql-parser");
|
|
87
|
+
const index_1 = require("../../index");
|
|
88
|
+
class RuntimeStats {
|
|
89
|
+
queries_served = 0;
|
|
90
|
+
streams_served = 0;
|
|
91
|
+
migrations_run = 0;
|
|
92
|
+
cancellations = 0;
|
|
93
|
+
permission_denies = 0;
|
|
94
|
+
audit_buffer_overflows = 0;
|
|
95
|
+
/**
|
|
96
|
+
* Appends this process saw rejected. `audit_events_written` is deliberately
|
|
97
|
+
* absent: it is derived from the sink, never counted here.
|
|
98
|
+
*/
|
|
99
|
+
audit_events_failed = 0;
|
|
100
|
+
}
|
|
101
|
+
exports.RuntimeStats = RuntimeStats;
|
|
102
|
+
/**
|
|
103
|
+
* Reconcile the audit counters from the sink's own health.
|
|
104
|
+
*
|
|
105
|
+
* `events_written` is the sink's count of appends that resolved, so a rejected
|
|
106
|
+
* record can never inflate it. `events_failed` is the greater of the rejection
|
|
107
|
+
* this process counted on the awaited path and the sink's queue-level failure
|
|
108
|
+
* count, which also covers the fire-and-forget `log()` path. `dropped` is the
|
|
109
|
+
* sink's own discard count, carried through unchanged: it has no local counter to
|
|
110
|
+
* reconcile against, because a dropped record never reaches this process at all.
|
|
111
|
+
*/
|
|
112
|
+
function buildDaemonAuditStats(stats, health) {
|
|
113
|
+
return {
|
|
114
|
+
audit_events_written: health.events_written,
|
|
115
|
+
audit_events_failed: Math.max(stats.audit_events_failed, health.events_failed),
|
|
116
|
+
audit_buffer_overflows: stats.audit_buffer_overflows,
|
|
117
|
+
audit_dropped: health.dropped,
|
|
118
|
+
audit: health,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Builds the daemon's audit shutdown step: flush, then close — in that order,
|
|
123
|
+
* exactly once, however many times it is called.
|
|
124
|
+
*
|
|
125
|
+
* Close-after-flush matters: `close()` on its own would be enough for the fd,
|
|
126
|
+
* but the point of flushing first is that records already counted as written by
|
|
127
|
+
* the sink reach the disk, and `LocalAuditWriter.flush()` is what advances the
|
|
128
|
+
* chain head to match. Closing *instead of* flushing would drop both.
|
|
129
|
+
*
|
|
130
|
+
* Idempotent because shutdown can arrive twice (a signal and an explicit
|
|
131
|
+
* `stop`, or a handler registered on two coordinators). Concurrent callers await
|
|
132
|
+
* the *same* promise rather than starting a second flush/close pair, so a signal
|
|
133
|
+
* that lands mid-shutdown cannot interleave with it. A failed attempt is not
|
|
134
|
+
* remembered as done: the memo is cleared so a later stop retries instead of
|
|
135
|
+
* reporting a shutdown that never completed.
|
|
136
|
+
*/
|
|
137
|
+
function createAuditShutdown(target) {
|
|
138
|
+
let pending = null;
|
|
139
|
+
return () => {
|
|
140
|
+
if (pending === null) {
|
|
141
|
+
pending = (async () => {
|
|
142
|
+
await target.flush();
|
|
143
|
+
await target.close();
|
|
144
|
+
})().catch((err) => {
|
|
145
|
+
pending = null;
|
|
146
|
+
throw err;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return pending;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Validate a relay URL with exactly the rule `cloud_url` must already satisfy
|
|
154
|
+
* in `validateMachineConfig`: a well-formed `wss://` URL with an explicit
|
|
155
|
+
* authority and no userinfo. `ws://`, `http://`, `WSS://`, `wss:/host` and
|
|
156
|
+
* unparseable input are all refused.
|
|
157
|
+
*
|
|
158
|
+
* Throws {@link ConfigInvalidError} rather than falling back to the configured
|
|
159
|
+
* URL: silently ignoring the flag would leave the operator believing the agent
|
|
160
|
+
* is talking to the relay they named.
|
|
161
|
+
*/
|
|
162
|
+
function assertSecureRelayUrl(raw) {
|
|
163
|
+
if (typeof raw !== 'string' || raw.trim().length === 0) {
|
|
164
|
+
throw new schema_1.ConfigInvalidError('Relay URL is empty. Expected a wss:// URL with an explicit authority.');
|
|
165
|
+
}
|
|
166
|
+
if (!(0, schema_1.isSecureCloudUrl)(raw)) {
|
|
167
|
+
throw new schema_1.ConfigInvalidError('Refusing relay URL: it must be a wss:// URL with an explicit authority. ' +
|
|
168
|
+
'ws:// and http:// are refused because the agent token is a permanent ' +
|
|
169
|
+
'bearer credential and would travel in cleartext.');
|
|
170
|
+
}
|
|
171
|
+
return raw;
|
|
172
|
+
}
|
|
173
|
+
function urlHost(raw) {
|
|
174
|
+
try {
|
|
175
|
+
return new URL(raw).host || null;
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function relayHostMismatchWarning(configuredHost, relayHost) {
|
|
182
|
+
return (`[security] WARNING: --relay points at a DIFFERENT host than the configured cloud_url.\n` +
|
|
183
|
+
` configured cloud_url host: ${configuredHost}\n` +
|
|
184
|
+
` relay host: ${relayHost}\n` +
|
|
185
|
+
` The agent's permanent token will be presented to ${relayHost}. ` +
|
|
186
|
+
`Anyone who controls that host receives this agent's credentials. ` +
|
|
187
|
+
`Drop --relay to use the configured host.`);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Decide which URL the agent uses, and whether that silently redirects the
|
|
191
|
+
* token to a host the operator never configured.
|
|
192
|
+
*/
|
|
193
|
+
function resolveRelayOverride(relayUrl, persistedCloudUrl) {
|
|
194
|
+
const configuredHost = urlHost(persistedCloudUrl);
|
|
195
|
+
if (!relayUrl) {
|
|
196
|
+
return {
|
|
197
|
+
url: persistedCloudUrl,
|
|
198
|
+
isOverride: false,
|
|
199
|
+
configuredHost,
|
|
200
|
+
relayHost: null,
|
|
201
|
+
hostChanged: false,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const url = assertSecureRelayUrl(relayUrl);
|
|
205
|
+
const relayHost = urlHost(url);
|
|
206
|
+
return {
|
|
207
|
+
url,
|
|
208
|
+
isOverride: true,
|
|
209
|
+
configuredHost,
|
|
210
|
+
relayHost,
|
|
211
|
+
hostChanged: relayHost !== null && configuredHost !== null && relayHost !== configuredHost,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Render a URL for a terminal or a log: scheme and host only. Userinfo, path
|
|
216
|
+
* tokens, query and fragment are masked, so echoing a URL can never disclose a
|
|
217
|
+
* credential.
|
|
218
|
+
*/
|
|
219
|
+
function redactUrlForDisplay(raw) {
|
|
220
|
+
if (typeof raw !== 'string' || raw.length === 0)
|
|
221
|
+
return '(unset)';
|
|
222
|
+
let url;
|
|
223
|
+
try {
|
|
224
|
+
url = new URL(raw);
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
return '(unparseable URL)';
|
|
228
|
+
}
|
|
229
|
+
const hasHiddenParts = url.username.length > 0 ||
|
|
230
|
+
url.password.length > 0 ||
|
|
231
|
+
(url.pathname.length > 0 && url.pathname !== '/') ||
|
|
232
|
+
url.search.length > 0 ||
|
|
233
|
+
url.hash.length > 0;
|
|
234
|
+
const base = `${url.protocol}//${url.host}`;
|
|
235
|
+
return hasHiddenParts ? `${base}/<redacted>` : base;
|
|
236
|
+
}
|
|
237
|
+
/* ------------------------------------------------------------------ */
|
|
238
|
+
/* Security-relevant environment resolution (M-09, L-03) */
|
|
239
|
+
/* ------------------------------------------------------------------ */
|
|
240
|
+
/** Connections per database pool when nothing valid is configured. */
|
|
241
|
+
exports.DEFAULT_POOL_MAX = 15;
|
|
242
|
+
exports.MIN_POOL_MAX = 1;
|
|
243
|
+
exports.MAX_POOL_MAX = 200;
|
|
244
|
+
/**
|
|
245
|
+
* Strict decimal integer parse. `Number()` would accept `0x10`, `1e3` and
|
|
246
|
+
* whitespace-only input, so every override is parsed this way instead.
|
|
247
|
+
*/
|
|
248
|
+
function parseStrictInteger(raw) {
|
|
249
|
+
const trimmed = raw.trim();
|
|
250
|
+
if (!/^[+-]?\d+$/.test(trimmed))
|
|
251
|
+
return null;
|
|
252
|
+
const parsed = Number(trimmed);
|
|
253
|
+
return Number.isSafeInteger(parsed) ? parsed : null;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Resolve the per-pool connection ceiling.
|
|
257
|
+
*
|
|
258
|
+
* Anything that is not an integer inside `[MIN_POOL_MAX, MAX_POOL_MAX]` — a
|
|
259
|
+
* non-numeric value, zero, a negative number, or an absurd ceiling that would
|
|
260
|
+
* be refused by PostgreSQL's own `max_connections` — falls back to the
|
|
261
|
+
* default. Previously `SW_PG_POOL_MAX` was passed straight through
|
|
262
|
+
* `parseInt`, so `abc` produced `NaN` and `999999` asked the database for a
|
|
263
|
+
* connection storm.
|
|
264
|
+
*/
|
|
265
|
+
function resolvePoolMax(env = process.env) {
|
|
266
|
+
const raw = env.SW_PG_POOL_MAX;
|
|
267
|
+
if (typeof raw !== 'string' || raw.trim().length === 0)
|
|
268
|
+
return exports.DEFAULT_POOL_MAX;
|
|
269
|
+
const parsed = parseStrictInteger(raw);
|
|
270
|
+
if (parsed === null || parsed < exports.MIN_POOL_MAX || parsed > exports.MAX_POOL_MAX)
|
|
271
|
+
return exports.DEFAULT_POOL_MAX;
|
|
272
|
+
return parsed;
|
|
273
|
+
}
|
|
274
|
+
/** Shortest approval window that is still an approval rather than a formality. */
|
|
275
|
+
exports.MIN_APPROVAL_TIMEOUT_MS = 5_000;
|
|
276
|
+
exports.MAX_APPROVAL_TIMEOUT_MS = 3_600_000;
|
|
277
|
+
/**
|
|
278
|
+
* Resolve the manual-approval window.
|
|
279
|
+
*
|
|
280
|
+
* `0` and negative values are never honoured: they would expire every pending
|
|
281
|
+
* approval the instant it was created, turning the approval gate into a no-op.
|
|
282
|
+
* Garbage falls back to `DEFAULTS.APPROVAL_TIMEOUT_MS`, and an in-range value
|
|
283
|
+
* is clamped rather than rejected so a deliberate typo cannot silently widen
|
|
284
|
+
* the window.
|
|
285
|
+
*/
|
|
286
|
+
function resolveApprovalTimeoutMs(env = process.env) {
|
|
287
|
+
const raw = env.SW_AGENT_MANUAL_APPROVAL_TIMEOUT_MS;
|
|
288
|
+
const fallback = constants_1.DEFAULTS.APPROVAL_TIMEOUT_MS;
|
|
289
|
+
if (typeof raw !== 'string' || raw.trim().length === 0)
|
|
290
|
+
return fallback;
|
|
291
|
+
const parsed = parseStrictInteger(raw);
|
|
292
|
+
if (parsed === null || parsed <= 0)
|
|
293
|
+
return fallback;
|
|
294
|
+
if (parsed < exports.MIN_APPROVAL_TIMEOUT_MS)
|
|
295
|
+
return exports.MIN_APPROVAL_TIMEOUT_MS;
|
|
296
|
+
if (parsed > exports.MAX_APPROVAL_TIMEOUT_MS)
|
|
297
|
+
return exports.MAX_APPROVAL_TIMEOUT_MS;
|
|
298
|
+
return parsed;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Mirror `PoolManager.maxStatementTimeoutMs` for the startup posture log: the
|
|
302
|
+
* environment may lower the ceiling but never raise it past the compiled-in
|
|
303
|
+
* hard cap.
|
|
304
|
+
*/
|
|
305
|
+
function resolveStatementTimeoutMs(env = process.env) {
|
|
306
|
+
const raw = env.SW_MAX_STATEMENT_TIMEOUT_MS;
|
|
307
|
+
const fallback = Math.min(constants_1.DEFAULTS.QUERY_TIMEOUT_MS, pool_1.MAX_STATEMENT_TIMEOUT_MS);
|
|
308
|
+
if (typeof raw !== 'string' || raw.trim().length === 0)
|
|
309
|
+
return fallback;
|
|
310
|
+
const parsed = parseStrictInteger(raw);
|
|
311
|
+
if (parsed === null || parsed <= 0)
|
|
312
|
+
return fallback;
|
|
313
|
+
return Math.min(parsed, pool_1.MAX_STATEMENT_TIMEOUT_MS);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Mirror the query runner's streaming row ceiling for the posture log. Same
|
|
317
|
+
* rule as its private `readBoundedEnvInt`, including its `parseInt` semantics:
|
|
318
|
+
* NaN, zero and negatives fall back, absurd values are clamped.
|
|
319
|
+
*/
|
|
320
|
+
function resolveMaxStreamRows(env = process.env) {
|
|
321
|
+
const raw = env.SW_AGENT_MAX_STREAM_ROWS;
|
|
322
|
+
if (typeof raw !== 'string' || raw.trim().length === 0)
|
|
323
|
+
return constants_1.DEFAULTS.MAX_STREAM_ROWS;
|
|
324
|
+
const parsed = Number.parseInt(raw.trim(), 10);
|
|
325
|
+
if (!Number.isFinite(parsed) || parsed < 1)
|
|
326
|
+
return constants_1.DEFAULTS.MAX_STREAM_ROWS;
|
|
327
|
+
return Math.min(parsed, 100_000_000);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Gate for the historical `SW_AGENT_E2E` escape hatch that used to start an
|
|
331
|
+
* unauthenticated loopback admin server with `/admin/shutdown`.
|
|
332
|
+
*
|
|
333
|
+
* There is no admin server in this build, so `allowed: true` still starts
|
|
334
|
+
* nothing. The gate exists so the conditions that would have to hold before
|
|
335
|
+
* such a control plane could be reintroduced are stated once, in code, rather
|
|
336
|
+
* than in a comment: never in production, never in a daemonised process, and
|
|
337
|
+
* only with an explicit second opt-in.
|
|
338
|
+
*/
|
|
339
|
+
function resolveE2EAdminGate(env = process.env) {
|
|
340
|
+
const requested = env.SW_AGENT_E2E === '1';
|
|
341
|
+
if (!requested) {
|
|
342
|
+
return { requested: false, allowed: false, reason: 'not requested' };
|
|
343
|
+
}
|
|
344
|
+
const blockers = [];
|
|
345
|
+
if (env.NODE_ENV === 'production')
|
|
346
|
+
blockers.push('NODE_ENV=production');
|
|
347
|
+
if (env.SW_AGENT_DAEMON === '1')
|
|
348
|
+
blockers.push('the process is daemonised');
|
|
349
|
+
if (env.SW_AGENT_DEV_ADMIN !== '1')
|
|
350
|
+
blockers.push('SW_AGENT_DEV_ADMIN=1 not set');
|
|
351
|
+
return {
|
|
352
|
+
requested: true,
|
|
353
|
+
allowed: blockers.length === 0,
|
|
354
|
+
reason: blockers.length === 0
|
|
355
|
+
? 'explicit development opt-in present, and no admin control plane exists to start'
|
|
356
|
+
: `refused (${blockers.join('; ')})`,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* The resolved value of every input that changes this process's security
|
|
361
|
+
* posture, so the effective configuration is observable in the log rather than
|
|
362
|
+
* implicit in whatever environment the process happened to inherit.
|
|
363
|
+
*
|
|
364
|
+
* `env` is the environment the values are actually resolved from — the live one,
|
|
365
|
+
* after the refused variables have been stripped, so a reported value is the
|
|
366
|
+
* value in effect. `inherited` is the pre-strip snapshot, used only to say
|
|
367
|
+
* whether a variable was set at all; pass it so the report can distinguish "not
|
|
368
|
+
* set" from "set, and ignored".
|
|
369
|
+
*/
|
|
370
|
+
function resolveSecurityPosture(env = process.env, inherited = env) {
|
|
371
|
+
const accepted = (name, parse) => {
|
|
372
|
+
const raw = inherited[name];
|
|
373
|
+
if (typeof raw !== 'string' || raw.trim().length === 0)
|
|
374
|
+
return 'from default';
|
|
375
|
+
return parse(raw) === null ? 'rejected, using default' : 'from environment';
|
|
376
|
+
};
|
|
377
|
+
const e2e = resolveE2EAdminGate(inherited);
|
|
378
|
+
const scope = parseScopeEnv(env[exports.ALLOWED_DATABASES_ENV]);
|
|
379
|
+
const agentHome = inherited.PG_CONNECTOR_HOME || inherited.SW_AGENT_HOME;
|
|
380
|
+
return [
|
|
381
|
+
{
|
|
382
|
+
name: 'SW_PG_POOL_MAX',
|
|
383
|
+
resolved: `${resolvePoolMax(env)} connections per database pool`,
|
|
384
|
+
detail: `${accepted('SW_PG_POOL_MAX', (value) => {
|
|
385
|
+
const parsed = parseStrictInteger(value);
|
|
386
|
+
return parsed !== null && parsed >= exports.MIN_POOL_MAX && parsed <= exports.MAX_POOL_MAX ? parsed : null;
|
|
387
|
+
})}; valid range ${exports.MIN_POOL_MAX}-${exports.MAX_POOL_MAX}`,
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
name: 'SW_MAX_STATEMENT_TIMEOUT_MS',
|
|
391
|
+
resolved: `${resolveStatementTimeoutMs(env)} ms`,
|
|
392
|
+
detail: `${accepted('SW_MAX_STATEMENT_TIMEOUT_MS', (value) => {
|
|
393
|
+
const parsed = parseStrictInteger(value);
|
|
394
|
+
return parsed !== null && parsed > 0 ? parsed : null;
|
|
395
|
+
})}; hard cap ${pool_1.MAX_STATEMENT_TIMEOUT_MS} ms`,
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
name: 'SW_AGENT_MANUAL_APPROVAL_TIMEOUT_MS',
|
|
399
|
+
resolved: `${resolveApprovalTimeoutMs(env)} ms`,
|
|
400
|
+
detail: `${accepted('SW_AGENT_MANUAL_APPROVAL_TIMEOUT_MS', (value) => {
|
|
401
|
+
const parsed = parseStrictInteger(value);
|
|
402
|
+
return parsed !== null &&
|
|
403
|
+
parsed >= exports.MIN_APPROVAL_TIMEOUT_MS &&
|
|
404
|
+
parsed <= exports.MAX_APPROVAL_TIMEOUT_MS
|
|
405
|
+
? parsed
|
|
406
|
+
: null;
|
|
407
|
+
})}; clamped to ${exports.MIN_APPROVAL_TIMEOUT_MS}-${exports.MAX_APPROVAL_TIMEOUT_MS} ms`,
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
name: 'SW_AGENT_MAX_STREAM_ROWS',
|
|
411
|
+
resolved: `${resolveMaxStreamRows(env)} rows`,
|
|
412
|
+
detail: accepted('SW_AGENT_MAX_STREAM_ROWS', (value) => {
|
|
413
|
+
const parsed = Number.parseInt(value.trim(), 10);
|
|
414
|
+
return Number.isFinite(parsed) && parsed >= 1 ? parsed : null;
|
|
415
|
+
}),
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
name: 'SW_AGENT_AUDIT_BUFFER',
|
|
419
|
+
resolved: (() => {
|
|
420
|
+
const buf = env.SW_AGENT_AUDIT_BUFFER;
|
|
421
|
+
return typeof buf === 'string' && buf.trim().length > 0
|
|
422
|
+
? `${buf} (as provided)`
|
|
423
|
+
: 'audit sink default';
|
|
424
|
+
})(),
|
|
425
|
+
detail: (() => {
|
|
426
|
+
const buf = inherited.SW_AGENT_AUDIT_BUFFER;
|
|
427
|
+
if (typeof buf !== 'string' || buf.trim().length === 0)
|
|
428
|
+
return 'from default';
|
|
429
|
+
return env.SW_AGENT_AUDIT_BUFFER === undefined
|
|
430
|
+
? 'set but refused; audit queue uses its default depth'
|
|
431
|
+
: 'from environment';
|
|
432
|
+
})(),
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
name: 'SW_AGENT_E2E',
|
|
436
|
+
resolved: e2e.requested ? 'requested' : 'not set',
|
|
437
|
+
detail: `${e2e.reason}; this build starts no inbound admin listener`,
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
name: exports.ALLOWED_DATABASES_ENV,
|
|
441
|
+
resolved: scope
|
|
442
|
+
? `${scope.length} allow-list rule(s)`
|
|
443
|
+
: 'unscoped (all configured databases reachable)',
|
|
444
|
+
detail: typeof env[exports.ALLOWED_DATABASES_ENV] === 'string' &&
|
|
445
|
+
env[exports.ALLOWED_DATABASES_ENV].trim().length > 0
|
|
446
|
+
? 'from environment'
|
|
447
|
+
: `from default (also settable as ${exports.ALLOWED_DATABASES_CONFIG_KEY} in sw-agent.config.json)`,
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
// Named for the variable an operator would actually set. This line reports
|
|
451
|
+
// where the agent token and the audit chain live, so a wrong variable name
|
|
452
|
+
// here sends a relocation attempt nowhere while the agent keeps writing
|
|
453
|
+
// secrets to the default path.
|
|
454
|
+
name: paths_1.AGENT_HOME_ENV_VARS.join(' / '),
|
|
455
|
+
resolved: agentHome ?? 'default (~/.sw-agent)',
|
|
456
|
+
detail: 'holds sw-agent.config.json, the agent token and the audit chain; ' +
|
|
457
|
+
'set either variable to relocate all of it, or leave unset for ' +
|
|
458
|
+
'~/.sw-agent. Not AGENT_HOME — nothing reads that one. ' +
|
|
459
|
+
'PG_CONNECTOR_HOME is refused at runtime, but paths already resolved ' +
|
|
460
|
+
'from it before startup still point there',
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
name: 'SW_AGENT_DEBUG',
|
|
464
|
+
resolved: env.SW_AGENT_DEBUG === '1' ? 'on' : 'off',
|
|
465
|
+
detail: 'verbose logging; never enable in production',
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
name: 'NODE_ENV',
|
|
469
|
+
resolved: env.NODE_ENV ?? 'development',
|
|
470
|
+
detail: 'production forbids every development-only control plane',
|
|
471
|
+
},
|
|
472
|
+
];
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Render the posture block. `secrets` are replaced with `***` in every line, so
|
|
476
|
+
* an agent token or an ingest URL can never reach the log through this path.
|
|
477
|
+
*/
|
|
478
|
+
function formatSecurityPosture(entries, secrets = []) {
|
|
479
|
+
const width = entries.reduce((max, entry) => Math.max(max, entry.name.length), 0);
|
|
480
|
+
const lines = [
|
|
481
|
+
'[security] Effective configuration (resolved values; secrets redacted):',
|
|
482
|
+
...entries.map((entry) => `[security] ${entry.name.padEnd(width)} = ${entry.resolved} — ${entry.detail}`),
|
|
483
|
+
];
|
|
484
|
+
return lines.map((line) => (0, schema_1.redactSecrets)(line, ...secrets));
|
|
485
|
+
}
|
|
486
|
+
/** Environment channel for the allow-list, for installs that cannot edit config. */
|
|
487
|
+
exports.ALLOWED_DATABASES_ENV = 'SW_AGENT_ALLOWED_DATABASES';
|
|
488
|
+
/** Config key read for the allow-list; the schema still needs to declare it. */
|
|
489
|
+
exports.ALLOWED_DATABASES_CONFIG_KEY = 'allowed_databases';
|
|
490
|
+
function isScopeName(value) {
|
|
491
|
+
return typeof value === 'string' && (0, schema_1.isValidIdentifier)(value, 64);
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Parse a `project`, `project:alias` or `:alias` token.
|
|
495
|
+
*/
|
|
496
|
+
function parseScopeToken(token) {
|
|
497
|
+
const raw = token.trim();
|
|
498
|
+
const separator = raw.indexOf(':');
|
|
499
|
+
const project = separator === -1 ? raw : raw.slice(0, separator);
|
|
500
|
+
if (separator === -1) {
|
|
501
|
+
if (!isScopeName(project)) {
|
|
502
|
+
throw new schema_1.ConfigInvalidError(`Invalid ${exports.ALLOWED_DATABASES_ENV} entry '${raw}': names may only contain letters, numbers, hyphens and underscores.`);
|
|
503
|
+
}
|
|
504
|
+
return { project_name: project };
|
|
505
|
+
}
|
|
506
|
+
const alias = raw.slice(separator + 1);
|
|
507
|
+
if (raw.indexOf(':', separator + 1) !== -1) {
|
|
508
|
+
throw new schema_1.ConfigInvalidError(`Invalid ${exports.ALLOWED_DATABASES_ENV} entry '${raw}': expected 'project', 'project:db_alias' or ':db_alias'.`);
|
|
509
|
+
}
|
|
510
|
+
if (project.length > 0 && !isScopeName(project)) {
|
|
511
|
+
throw new schema_1.ConfigInvalidError(`Invalid ${exports.ALLOWED_DATABASES_ENV} entry '${raw}': project names may only contain letters, numbers, hyphens and underscores.`);
|
|
512
|
+
}
|
|
513
|
+
if (alias.length === 0 || !isScopeName(alias)) {
|
|
514
|
+
throw new schema_1.ConfigInvalidError(`Invalid ${exports.ALLOWED_DATABASES_ENV} entry '${raw}': the db_alias part is required when a ':' is present and must be a valid alias.`);
|
|
515
|
+
}
|
|
516
|
+
return project.length > 0 ? { project_name: project, db_alias: alias } : { db_alias: alias };
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Validate an allow-list declaration. Returns null when nothing is configured
|
|
520
|
+
* (the backwards-compatible unscoped case) and throws when something is
|
|
521
|
+
* configured but malformed — a typo must not widen the scope it was meant to
|
|
522
|
+
* narrow.
|
|
523
|
+
*/
|
|
524
|
+
function parseScopeRules(raw) {
|
|
525
|
+
if (raw === undefined || raw === null)
|
|
526
|
+
return null;
|
|
527
|
+
const items = Array.isArray(raw) ? raw : [raw];
|
|
528
|
+
const rules = [];
|
|
529
|
+
for (const item of items) {
|
|
530
|
+
if (typeof item === 'string') {
|
|
531
|
+
rules.push(parseScopeToken(item));
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
if (typeof item !== 'object' || item === null) {
|
|
535
|
+
throw new schema_1.ConfigInvalidError(`Invalid ${exports.ALLOWED_DATABASES_CONFIG_KEY} entry: expected an object with project_name and/or db_alias.`);
|
|
536
|
+
}
|
|
537
|
+
const record = item;
|
|
538
|
+
const project = record.project_name;
|
|
539
|
+
const alias = record.db_alias;
|
|
540
|
+
if (project !== undefined && !isScopeName(project)) {
|
|
541
|
+
throw new schema_1.ConfigInvalidError(`Invalid ${exports.ALLOWED_DATABASES_CONFIG_KEY} project_name: must be 1-64 characters of letters, numbers, hyphens and underscores.`);
|
|
542
|
+
}
|
|
543
|
+
if (alias !== undefined && !isScopeName(alias)) {
|
|
544
|
+
throw new schema_1.ConfigInvalidError(`Invalid ${exports.ALLOWED_DATABASES_CONFIG_KEY} db_alias: must be 1-64 characters of letters, numbers, hyphens and underscores.`);
|
|
545
|
+
}
|
|
546
|
+
if (project === undefined && alias === undefined) {
|
|
547
|
+
throw new schema_1.ConfigInvalidError(`Invalid ${exports.ALLOWED_DATABASES_CONFIG_KEY} entry: set project_name and/or db_alias; an empty rule would permit everything.`);
|
|
548
|
+
}
|
|
549
|
+
const rule = {};
|
|
550
|
+
if (project !== undefined)
|
|
551
|
+
rule.project_name = project;
|
|
552
|
+
if (alias !== undefined)
|
|
553
|
+
rule.db_alias = alias;
|
|
554
|
+
rules.push(rule);
|
|
555
|
+
}
|
|
556
|
+
return rules.length > 0 ? rules : null;
|
|
557
|
+
}
|
|
558
|
+
/** Parse the comma-separated environment form of the allow-list. */
|
|
559
|
+
function parseScopeEnv(raw) {
|
|
560
|
+
if (typeof raw !== 'string' || raw.trim().length === 0)
|
|
561
|
+
return null;
|
|
562
|
+
const tokens = raw
|
|
563
|
+
.split(',')
|
|
564
|
+
.map((token) => token.trim())
|
|
565
|
+
.filter((token) => token.length > 0);
|
|
566
|
+
return tokens.length > 0 ? parseScopeRules(tokens) : null;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Effective allow-list, resolved from both declaration channels.
|
|
570
|
+
*
|
|
571
|
+
* The environment can only **NARROW**. the two were unioned, so anybody
|
|
572
|
+
* who could set `SW_AGENT_ALLOWED_DATABASES` in the daemon's environment could
|
|
573
|
+
* add a database the operator had deliberately excluded — an environment
|
|
574
|
+
* variable is a weaker channel than a config file and must not be the stronger
|
|
575
|
+
* one. When both channels declare a scope, the result is their intersection; a
|
|
576
|
+
* rule survives only if some config rule and some env rule can both match the
|
|
577
|
+
* same entry. An empty intersection is a scope that permits nothing.
|
|
578
|
+
*
|
|
579
|
+
* Null means nothing was declared anywhere. That is no longer "every database is
|
|
580
|
+
* permitted": see {@link resolveDatabaseScopeDecision}.
|
|
581
|
+
*/
|
|
582
|
+
function resolveDatabaseScope(machineConfig, env = process.env) {
|
|
583
|
+
const fromConfig = parseScopeRules(machineConfig[exports.ALLOWED_DATABASES_CONFIG_KEY]);
|
|
584
|
+
const fromEnv = parseScopeEnv(env[exports.ALLOWED_DATABASES_ENV]);
|
|
585
|
+
if (!fromConfig)
|
|
586
|
+
return fromEnv;
|
|
587
|
+
if (!fromEnv)
|
|
588
|
+
return fromConfig;
|
|
589
|
+
return intersectScopeRules(fromConfig, fromEnv);
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Narrow every rule set to what BOTH permit.
|
|
593
|
+
*
|
|
594
|
+
* Rules carry at most a `project_name` and a `db_alias`, each optional, so the
|
|
595
|
+
* intersection of two rules is either empty (they contradict each other) or a
|
|
596
|
+
* single rule carrying every field they agree on. Duplicates are collapsed: an
|
|
597
|
+
* entry must not be able to widen itself by being named twice.
|
|
598
|
+
*/
|
|
599
|
+
function intersectScopeRules(config, env) {
|
|
600
|
+
const out = [];
|
|
601
|
+
for (const c of config) {
|
|
602
|
+
for (const e of env) {
|
|
603
|
+
const merged = {};
|
|
604
|
+
if (c.project_name !== undefined && c.project_name === e.project_name) {
|
|
605
|
+
merged.project_name = c.project_name;
|
|
606
|
+
}
|
|
607
|
+
if (c.db_alias !== undefined && c.db_alias === e.db_alias) {
|
|
608
|
+
merged.db_alias = c.db_alias;
|
|
609
|
+
}
|
|
610
|
+
if (c.project_name !== undefined && e.project_name !== undefined && merged.project_name === undefined) {
|
|
611
|
+
continue; // different projects: no entry satisfies both
|
|
612
|
+
}
|
|
613
|
+
if (c.db_alias !== undefined && e.db_alias !== undefined && merged.db_alias === undefined) {
|
|
614
|
+
continue; // different aliases: no entry satisfies both
|
|
615
|
+
}
|
|
616
|
+
if (merged.project_name === undefined && merged.db_alias === undefined)
|
|
617
|
+
continue;
|
|
618
|
+
if (!out.some((r) => r.project_name === merged.project_name && r.db_alias === merged.db_alias)) {
|
|
619
|
+
out.push(merged);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
return out.length > 0 ? out : [];
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Config key that restores the pre-remediation permissive default.
|
|
627
|
+
*
|
|
628
|
+
* RISK: with no allow-list and this key set to `true`, ONE agent token reaches
|
|
629
|
+
* EVERY configured database on the host — typically dev, staging and production —
|
|
630
|
+
* and any authenticated principal on the relay can name any of them. It exists
|
|
631
|
+
* only so an existing deployment can keep working across this upgrade with a
|
|
632
|
+
* deliberate, visible choice; the default is fail-closed.
|
|
633
|
+
*/
|
|
634
|
+
exports.ALLOW_UNSCOPED_DATABASES_CONFIG_KEY = 'allow_unscoped_databases';
|
|
635
|
+
/** Machine-config path for the same escape hatch. */
|
|
636
|
+
exports.ALLOW_UNSCOPED_DATABASES_CONFIG_PATH = `security.${exports.ALLOW_UNSCOPED_DATABASES_CONFIG_KEY}`;
|
|
637
|
+
/**
|
|
638
|
+
* The effective database scope, and whether this installation fails closed.
|
|
639
|
+
*
|
|
640
|
+
* . The default was "no allow-list means every configured database", so an
|
|
641
|
+
* install that had never been configured — the default install — let a session
|
|
642
|
+
* authenticated for one project read any other project on the host, including
|
|
643
|
+
* production. The default is now the opposite: nothing declared means nothing is
|
|
644
|
+
* reachable except `ping`, and the refusal is audited.
|
|
645
|
+
*
|
|
646
|
+
* Restoring the old behaviour requires the explicit
|
|
647
|
+
* `security.allow_unscoped_databases: true`.
|
|
648
|
+
*/
|
|
649
|
+
function resolveDatabaseScopeDecision(machineConfig, env = process.env) {
|
|
650
|
+
const fromConfig = parseScopeRules(machineConfig[exports.ALLOWED_DATABASES_CONFIG_KEY]);
|
|
651
|
+
const fromEnv = parseScopeEnv(env[exports.ALLOWED_DATABASES_ENV]);
|
|
652
|
+
const allowUnscoped = readAllowUnscoped(machineConfig);
|
|
653
|
+
let rules;
|
|
654
|
+
if (!fromConfig) {
|
|
655
|
+
rules = fromEnv;
|
|
656
|
+
}
|
|
657
|
+
else if (!fromEnv) {
|
|
658
|
+
rules = fromConfig;
|
|
659
|
+
}
|
|
660
|
+
else {
|
|
661
|
+
rules = intersectScopeRules(fromConfig, fromEnv);
|
|
662
|
+
}
|
|
663
|
+
const scoped = rules !== null && rules.length > 0;
|
|
664
|
+
return {
|
|
665
|
+
rules,
|
|
666
|
+
env_narrowed: Boolean(fromConfig && fromEnv),
|
|
667
|
+
allow_unscoped: allowUnscoped,
|
|
668
|
+
scoped,
|
|
669
|
+
// An empty intersection is a scope that permits nothing, which is not the
|
|
670
|
+
// same as no scope at all: it is a deliberate contradiction of the two
|
|
671
|
+
// channels, and it must not fall back to "allow everything".
|
|
672
|
+
fail_closed: !scoped && !allowUnscoped,
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* The escape hatch, read strictly.
|
|
677
|
+
*
|
|
678
|
+
* Read off the raw config object rather than off a typed field so that a config
|
|
679
|
+
* that does not yet declare the key still works; the literal `true` is the only
|
|
680
|
+
* accepted value.
|
|
681
|
+
*/
|
|
682
|
+
function readAllowUnscoped(machineConfig) {
|
|
683
|
+
const security = machineConfig['security'];
|
|
684
|
+
if (typeof security !== 'object' || security === null || Array.isArray(security))
|
|
685
|
+
return false;
|
|
686
|
+
return security[exports.ALLOW_UNSCOPED_DATABASES_CONFIG_KEY] === true;
|
|
687
|
+
}
|
|
688
|
+
/** True when the entry is permitted. An absent allow-list permits everything. */
|
|
689
|
+
function scopeAllowsEntry(rules, entry) {
|
|
690
|
+
if (!rules || rules.length === 0)
|
|
691
|
+
return true;
|
|
692
|
+
return rules.some((rule) => (rule.project_name === undefined || rule.project_name === entry.project_name) &&
|
|
693
|
+
(rule.db_alias === undefined || rule.db_alias === entry.db_alias));
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Resolve an inbound frame's self-declared `project_name` / `db_alias` to a
|
|
697
|
+
* database entry, refusing anything outside the allow-list.
|
|
698
|
+
*
|
|
699
|
+
* Two refusals that did not exist before:
|
|
700
|
+
*
|
|
701
|
+
* - **Fail closed with no allow-list**. With nothing declared, this
|
|
702
|
+
* installation serves `ping` only. Restoring the old "everything is
|
|
703
|
+
* reachable" default requires the explicit
|
|
704
|
+
* `security.allow_unscoped_databases: true`.
|
|
705
|
+
* - **Project/alias collision**. When a frame names BOTH a project and
|
|
706
|
+
* an alias and they select *different* entries, the frame is refused. The
|
|
707
|
+
* old code silently preferred the project, executed against it, echoed the
|
|
708
|
+
* alias back and recorded neither — so the operation and the audit trail
|
|
709
|
+
* both named a database the operation never touched. Naming the same entry
|
|
710
|
+
* two ways is accepted.
|
|
711
|
+
*
|
|
712
|
+
* The result carries the refusal code rather than only `null` so the caller can
|
|
713
|
+
* audit the refusal under its own reason instead of a generic "unavailable".
|
|
714
|
+
*/
|
|
715
|
+
function createLookupDb(opts) {
|
|
716
|
+
const deny = (attempt, code) => {
|
|
717
|
+
opts.onDenied?.({ ...attempt, code });
|
|
718
|
+
return {
|
|
719
|
+
ok: false,
|
|
720
|
+
code,
|
|
721
|
+
reason: attempt.reason,
|
|
722
|
+
asserted_project: attempt.project,
|
|
723
|
+
asserted_db_alias: attempt.db_alias ?? '',
|
|
724
|
+
};
|
|
725
|
+
};
|
|
726
|
+
return (project, alias) => {
|
|
727
|
+
const failClosed = opts.decision?.fail_closed === true;
|
|
728
|
+
// Nothing is reachable without an allow-list unless the operator has
|
|
729
|
+
// explicitly restored the permissive default. `ping` never reaches here:
|
|
730
|
+
// the dispatcher answers it before consulting the lookup.
|
|
731
|
+
if (opts.scope === null && failClosed) {
|
|
732
|
+
return deny({
|
|
733
|
+
project,
|
|
734
|
+
db_alias: alias,
|
|
735
|
+
reason: 'no database allow-list is configured for this agent, so no database is reachable',
|
|
736
|
+
}, 'database_scope_not_configured');
|
|
737
|
+
}
|
|
738
|
+
const databases = opts.getDatabases();
|
|
739
|
+
const byProject = databases.find((entry) => entry.project_name === project);
|
|
740
|
+
const byAlias = alias ? databases.find((entry) => entry.db_alias === alias) : undefined;
|
|
741
|
+
// two names for one entry is fine; two names for two entries is not.
|
|
742
|
+
if (byProject && byAlias && byProject.db_alias !== byAlias.db_alias) {
|
|
743
|
+
return deny({
|
|
744
|
+
project,
|
|
745
|
+
db_alias: alias,
|
|
746
|
+
reason: 'the project and the db_alias in this request name different configured databases',
|
|
747
|
+
}, 'db_alias_project_mismatch');
|
|
748
|
+
}
|
|
749
|
+
if (byProject) {
|
|
750
|
+
if (!scopeAllowsEntry(opts.scope, byProject)) {
|
|
751
|
+
return deny({
|
|
752
|
+
project,
|
|
753
|
+
db_alias: byProject.db_alias,
|
|
754
|
+
reason: "the project is not in this agent's permitted database allow-list",
|
|
755
|
+
}, 'database_out_of_scope');
|
|
756
|
+
}
|
|
757
|
+
return { ok: true, entry: byProject };
|
|
758
|
+
}
|
|
759
|
+
// Protocol also addresses DBs by db_alias. Fall back so relay clients that
|
|
760
|
+
// only know the alias (e.g. the Data Explorer relay) still resolve.
|
|
761
|
+
if (byAlias) {
|
|
762
|
+
if (!scopeAllowsEntry(opts.scope, byAlias)) {
|
|
763
|
+
return deny({
|
|
764
|
+
project,
|
|
765
|
+
db_alias: alias,
|
|
766
|
+
reason: "the database alias is not in this agent's permitted database allow-list",
|
|
767
|
+
}, 'database_out_of_scope');
|
|
768
|
+
}
|
|
769
|
+
return { ok: true, entry: byAlias };
|
|
770
|
+
}
|
|
771
|
+
return {
|
|
772
|
+
ok: false,
|
|
773
|
+
code: 'database_not_found',
|
|
774
|
+
reason: `No configured database matches project "${project}"`,
|
|
775
|
+
asserted_project: project,
|
|
776
|
+
asserted_db_alias: alias ?? '',
|
|
777
|
+
};
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* What an operator needs to know about this installation's database scope.
|
|
782
|
+
*
|
|
783
|
+
* Three states, and they read very differently on purpose:
|
|
784
|
+
*
|
|
785
|
+
* - **scoped** — an allow-list is in force. Nothing to say.
|
|
786
|
+
* - **fail-closed (the new default)** — nothing is declared, so this agent
|
|
787
|
+
* serves `ping` only. This is the upgrade notice asks for: an existing
|
|
788
|
+
* install that never configured `allowed_databases` previously reached every
|
|
789
|
+
* database on the host and will now reach none, and an operator who has not
|
|
790
|
+
* read a changelog needs to be told that in the first seconds of the daemon,
|
|
791
|
+
* not in a log file nobody opens.
|
|
792
|
+
* - **unscoped by explicit opt-in** — every configured database is reachable
|
|
793
|
+
* again, and the risk is named in full.
|
|
794
|
+
*/
|
|
795
|
+
function databaseScopeWarningLines(scope, databases, decision) {
|
|
796
|
+
const scoped = scope !== null && scope.length > 0;
|
|
797
|
+
if (scoped)
|
|
798
|
+
return [];
|
|
799
|
+
const reachable = databases.map((entry) => `${entry.project_name}/${entry.db_alias}`).join(', ');
|
|
800
|
+
const listed = reachable || 'none';
|
|
801
|
+
const restoreHint = `set ${exports.ALLOWED_DATABASES_CONFIG_KEY} in sw-agent.config.json, or ` +
|
|
802
|
+
`${exports.ALLOWED_DATABASES_ENV}, to a list of ` +
|
|
803
|
+
'{ "project_name": ..., "db_alias": ... } pairs';
|
|
804
|
+
if (decision && !decision.allow_unscoped) {
|
|
805
|
+
return [
|
|
806
|
+
'[security] ============================================================================',
|
|
807
|
+
`[security] BREAKING CHANGE: no database allow-list is configured, so this agent now ` +
|
|
808
|
+
`REFUSES every database request. Only 'ping' is answered.`,
|
|
809
|
+
`[security] Before this release an unscoped agent token reached every configured ` +
|
|
810
|
+
`database (${databases.length}): ${listed}.`,
|
|
811
|
+
`[security] To restore that behaviour set 'true' in sw-agent.config.json: ` +
|
|
812
|
+
`{ "security": { "${exports.ALLOW_UNSCOPED_DATABASES_CONFIG_KEY}": true } } — and read ` +
|
|
813
|
+
'the risk first: one token would again reach every database on this host, including',
|
|
814
|
+
'[security] production, and any authenticated principal could name any of them.',
|
|
815
|
+
`[security] To scope instead, ${restoreHint}.`,
|
|
816
|
+
'[security] ============================================================================',
|
|
817
|
+
];
|
|
818
|
+
}
|
|
819
|
+
return [
|
|
820
|
+
'[security] WARNING: no database allow-list is configured for this agent.',
|
|
821
|
+
`[security] The agent token is UNSCOPED: it reaches every configured ` +
|
|
822
|
+
`database (${databases.length}): ${listed}.`,
|
|
823
|
+
'[security] A session authenticated for one project can therefore reach ' +
|
|
824
|
+
`every other project on this host, including production. To scope it, ${restoreHint}.`,
|
|
825
|
+
`[security] This permissive mode is active only because ` +
|
|
826
|
+
`${exports.ALLOW_UNSCOPED_DATABASES_CONFIG_PATH} is explicitly true in the machine config.`,
|
|
827
|
+
];
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* One-line summary for `sw-agent status`.
|
|
831
|
+
*
|
|
832
|
+
* The warning above goes to the console of a detached daemon, which most
|
|
833
|
+
* operators never see; this is the part that has to reach the CLI an operator
|
|
834
|
+
* actually runs. See the `security` block of `DaemonStatus`.
|
|
835
|
+
*/
|
|
836
|
+
function describeDatabaseScope(decision, databases) {
|
|
837
|
+
if (decision.fail_closed) {
|
|
838
|
+
return ('FAIL CLOSED — no allowed_databases allow-list is configured, so every database request ' +
|
|
839
|
+
'is refused (ping only). Set allowed_databases in sw-agent.config.json, or ' +
|
|
840
|
+
`${exports.ALLOWED_DATABASES_ENV}, or set ${exports.ALLOW_UNSCOPED_DATABASES_CONFIG_PATH}: true to ` +
|
|
841
|
+
'restore the previous permissive default.');
|
|
842
|
+
}
|
|
843
|
+
if (decision.allow_unscoped) {
|
|
844
|
+
return (`UNSCOPED BY OPERATOR CHOICE — the token reaches every configured database ` +
|
|
845
|
+
`(${databases.length}): ${databases.map((e) => `${e.project_name}/${e.db_alias}`).join(', ') || 'none'}. ` +
|
|
846
|
+
'Any authenticated principal can name any of them.');
|
|
847
|
+
}
|
|
848
|
+
return `SCOPED — ${decision.rules?.length ?? 0} allow-list rule(s).`;
|
|
849
|
+
}
|
|
850
|
+
async function runAgent(opts) {
|
|
851
|
+
const daemonStartedAt = new Date().toISOString();
|
|
852
|
+
// Snapshot the inherited environment before anything is stripped from it, so
|
|
853
|
+
// the posture log below reports what this process was actually started with.
|
|
854
|
+
const inheritedEnv = { ...process.env };
|
|
855
|
+
// Validate the `--relay` override before applying it. Applied after
|
|
856
|
+
// `validateMachineConfig` used to bypass every check, so `--relay
|
|
857
|
+
// ws://attacker.example` sent the permanent agent token in cleartext from a
|
|
858
|
+
// detached process.
|
|
859
|
+
const relay = resolveRelayOverride(opts.relayUrl, opts.machineConfig.cloud_url);
|
|
860
|
+
if (relay.isOverride && relay.hostChanged && relay.configuredHost && relay.relayHost) {
|
|
861
|
+
console.error(relayHostMismatchWarning(relay.configuredHost, relay.relayHost));
|
|
862
|
+
}
|
|
863
|
+
if (relay.isOverride) {
|
|
864
|
+
opts.machineConfig.cloud_url = relay.url;
|
|
865
|
+
}
|
|
866
|
+
// Refuse any inherited variable that would change the security posture of
|
|
867
|
+
// this process (see UNRECOGNISED_SECURITY_ENV). Without this, a `.service`
|
|
868
|
+
// file, wrapper script, PM2 ecosystem file, CI job, or Dockerfile `ENV` that
|
|
869
|
+
// sets e.g. PG_CONNECTOR_HOME or SW_MAX_STATEMENT_TIMEOUT_MS silently
|
|
870
|
+
// reconfigures the agent that inherits it.
|
|
871
|
+
const refusedEnvVars = (0, state_1.stripUnrecognisedSecurityEnv)();
|
|
872
|
+
// Everything resolved from here on reads the *live* environment, not the
|
|
873
|
+
// snapshot, so a refused variable cannot be honoured through a captured copy.
|
|
874
|
+
// Resolving from `inheritedEnv` would have quietly applied SW_PG_POOL_MAX and
|
|
875
|
+
// SW_AGENT_MANUAL_APPROVAL_TIMEOUT_MS while claiming they were refused.
|
|
876
|
+
// Capture crashes and per-operation errors to errors.jsonl.
|
|
877
|
+
(0, error_tracker_1.installGlobalHandlers)(opts.machineConfig.agent_id);
|
|
878
|
+
for (const name of refusedEnvVars) {
|
|
879
|
+
console.error(`[security] Ignoring ${name}: ${state_1.UNRECOGNISED_SECURITY_ENV[name]} — this variable is not an accepted configuration input.`);
|
|
880
|
+
}
|
|
881
|
+
for (const line of formatSecurityPosture(resolveSecurityPosture(process.env, inheritedEnv), [
|
|
882
|
+
opts.machineConfig.agent_token,
|
|
883
|
+
opts.machineConfig.cloud_telemetry?.ingest_url,
|
|
884
|
+
])) {
|
|
885
|
+
console.log(line);
|
|
886
|
+
}
|
|
887
|
+
const e2eGate = resolveE2EAdminGate(inheritedEnv);
|
|
888
|
+
if (e2eGate.requested) {
|
|
889
|
+
console.error(`[security] WARNING: SW_AGENT_E2E=1 was set in the environment but ${e2eGate.reason}. ` +
|
|
890
|
+
'This build contains no inbound admin control plane, so nothing was started; ' +
|
|
891
|
+
'no /admin/shutdown endpoint exists to call.');
|
|
892
|
+
}
|
|
893
|
+
// Load the real PostgreSQL parser before anything that can classify SQL exists.
|
|
894
|
+
// `classifyStatement()` is fail-closed by design (audit finding C-01): with the
|
|
895
|
+
// WASM module unloaded, `parseSql()` throws and every `query`, `stream_query`
|
|
896
|
+
// and `migration_run` is refused with `parser_unavailable`. Awaited here, after
|
|
897
|
+
// `installGlobalHandlers()` so a load failure is tracked like any other
|
|
898
|
+
// startup error, and before `PlanRegistry` / `PermissionChecker` /
|
|
899
|
+
// `Dispatcher` are constructed, so no request can be classified before the
|
|
900
|
+
// parser is ready. There is deliberately no heuristic fallback: a lexical
|
|
901
|
+
// classifier is the entire vulnerability this finding is about.
|
|
902
|
+
try {
|
|
903
|
+
await (0, sql_parser_1.initSqlParser)();
|
|
904
|
+
}
|
|
905
|
+
catch (err) {
|
|
906
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
907
|
+
(0, error_tracker_1.trackError)(err, { op: 'initSqlParser', level: 'fatal' });
|
|
908
|
+
console.error();
|
|
909
|
+
console.error(`[security] FATAL: ${message}`);
|
|
910
|
+
console.error(' The agent cannot classify SQL without it, so every query, stream and migration ' +
|
|
911
|
+
'would be refused with `parser_unavailable`. Refusing to start rather than falling ' +
|
|
912
|
+
'back to a lexical classifier.');
|
|
913
|
+
console.error(' Reinstall the package so node_modules/pgsql-parser and its libpg-query WASM binary ' +
|
|
914
|
+
'are intact, then run `sw-agent doctor` and `sw-agent start` again.');
|
|
915
|
+
console.error(` Agent log: ${(0, paths_1.getDaemonLogPath)()}`);
|
|
916
|
+
console.error();
|
|
917
|
+
return 1;
|
|
918
|
+
}
|
|
919
|
+
const poolManager = new pool_1.PoolManager({ maxPoolSize: resolvePoolMax() });
|
|
920
|
+
// Assigned further down, after the objects whose callbacks close over it exist.
|
|
921
|
+
// eslint-disable-next-line prefer-const -- deferred initialisation, not reassignment
|
|
922
|
+
let writeStatus;
|
|
923
|
+
let currentDatabasesConfig = opts.databasesConfig;
|
|
924
|
+
let configRevision = Date.now();
|
|
925
|
+
const planRegistry = new plan_registry_1.PlanRegistry();
|
|
926
|
+
const autoUpgradeChecker = new auto_upgrade_1.AutoUpgradeChecker({ planRegistry });
|
|
927
|
+
const auditLocalWriter = new local_writer_1.LocalAuditWriter({
|
|
928
|
+
dir: opts.auditDir,
|
|
929
|
+
maxFileSize: 10 * 1024 * 1024,
|
|
930
|
+
maxArchiveFiles: 10,
|
|
931
|
+
});
|
|
932
|
+
const auditSink = new sink_1.AuditSink({
|
|
933
|
+
agentId: opts.machineConfig.agent_id,
|
|
934
|
+
localWriter: auditLocalWriter,
|
|
935
|
+
cloudWriter: new cloud_writer_1.CloudAuditWriter({
|
|
936
|
+
enabled: opts.machineConfig.cloud_telemetry?.enabled !== false,
|
|
937
|
+
url: opts.machineConfig.cloud_telemetry?.ingest_url,
|
|
938
|
+
cloudUrl: opts.machineConfig.cloud_url,
|
|
939
|
+
agent_token: opts.machineConfig.agent_token,
|
|
940
|
+
agent_id: opts.machineConfig.agent_id,
|
|
941
|
+
}),
|
|
942
|
+
});
|
|
943
|
+
// Deterministic shutdown of the audit path: drain the queue, fsync what was
|
|
944
|
+
// written, then release the handle. Flushing without closing left the long-
|
|
945
|
+
// lived file descriptor to the garbage collector and to process exit (finding
|
|
946
|
+
// M-05), so records that had been counted but not yet committed could be lost
|
|
947
|
+
// and the fd was not released before a restart reopened the same path.
|
|
948
|
+
const closeAudit = createAuditShutdown({
|
|
949
|
+
flush: () => auditSink.flush(),
|
|
950
|
+
close: () => auditLocalWriter.close(),
|
|
951
|
+
});
|
|
952
|
+
// Also enable the operation logger (CLI/lifecycle ops) for cloud delivery.
|
|
953
|
+
(0, operation_logger_1.initOperationLogger)({
|
|
954
|
+
enabled: opts.machineConfig.cloud_telemetry?.enabled !== false,
|
|
955
|
+
cloudUrl: opts.machineConfig.cloud_url,
|
|
956
|
+
token: opts.machineConfig.agent_token,
|
|
957
|
+
agentId: opts.machineConfig.agent_id,
|
|
958
|
+
});
|
|
959
|
+
// Assigned after the dispatcher is built, which itself closes over `session`.
|
|
960
|
+
// eslint-disable-next-line prefer-const -- deferred initialisation, not reassignment
|
|
961
|
+
let session;
|
|
962
|
+
const manualApprovalHandler = new manual_approval_1.ManualApprovalHandler({
|
|
963
|
+
send: async (msg) => {
|
|
964
|
+
if (session) {
|
|
965
|
+
await session.send(msg);
|
|
966
|
+
}
|
|
967
|
+
},
|
|
968
|
+
timeoutMs: resolveApprovalTimeoutMs(),
|
|
969
|
+
auditSink,
|
|
970
|
+
});
|
|
971
|
+
const permissionChecker = new checker_1.PermissionChecker({
|
|
972
|
+
autoUpgradeChecker,
|
|
973
|
+
manualApprovalHandler,
|
|
974
|
+
planRegistry,
|
|
975
|
+
});
|
|
976
|
+
const stats = new RuntimeStats();
|
|
977
|
+
const originalLog = auditSink.log.bind(auditSink);
|
|
978
|
+
const originalLogSync = auditSink.logSync.bind(auditSink);
|
|
979
|
+
const updateStatsFromEvent = (partial) => {
|
|
980
|
+
if (partial.decision === 'allow' && partial.outcome !== 'n/a') {
|
|
981
|
+
if (partial.action === 'query') {
|
|
982
|
+
stats.queries_served++;
|
|
983
|
+
}
|
|
984
|
+
else if (partial.action === 'stream_query') {
|
|
985
|
+
stats.streams_served++;
|
|
986
|
+
}
|
|
987
|
+
else if (partial.action === 'migration_run') {
|
|
988
|
+
stats.migrations_run++;
|
|
989
|
+
}
|
|
990
|
+
else if (partial.action === 'cancel') {
|
|
991
|
+
stats.cancellations++;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
else if (partial.decision === 'deny') {
|
|
995
|
+
if (partial.denial_reason === 'buffer_overflow') {
|
|
996
|
+
stats.audit_buffer_overflows++;
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
stats.permission_denies++;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
1003
|
+
// `audit_events_written` is NOT incremented here. Both durability counters
|
|
1004
|
+
// are reconciled from the sink instead (see `buildDaemonAuditStats`): the
|
|
1005
|
+
// sink increments `events_written` only once an append has actually resolved,
|
|
1006
|
+
// and `log()` hands back no promise to await. Incrementing before the write
|
|
1007
|
+
// resolved claimed a durability the process did not have (audit finding C-06,
|
|
1008
|
+
// item 6).
|
|
1009
|
+
auditSink.log = (partial) => {
|
|
1010
|
+
updateStatsFromEvent(partial);
|
|
1011
|
+
originalLog(partial);
|
|
1012
|
+
};
|
|
1013
|
+
auditSink.logSync = async (partial) => {
|
|
1014
|
+
try {
|
|
1015
|
+
await originalLogSync(partial);
|
|
1016
|
+
}
|
|
1017
|
+
catch (err) {
|
|
1018
|
+
stats.audit_events_failed++;
|
|
1019
|
+
throw err;
|
|
1020
|
+
}
|
|
1021
|
+
// Only a persisted record may move the activity counters: for `logSync` the
|
|
1022
|
+
// append is the gate, so a rejected record means the work never happened.
|
|
1023
|
+
updateStatsFromEvent(partial);
|
|
1024
|
+
};
|
|
1025
|
+
// Create dispatcher dependencies
|
|
1026
|
+
const queryRunner = new query_runner_1.QueryRunner({ poolManager });
|
|
1027
|
+
const migrationRunner = new migration_runner_1.MigrationRunner({ poolManager });
|
|
1028
|
+
// The pool manager is required here, not optional: without it every cancel
|
|
1029
|
+
// opened a fresh TCP + TLS + password-authenticated connection, so a stream
|
|
1030
|
+
// of cancel requests could exhaust max_connections on the database.
|
|
1031
|
+
const canceller = new canceller_1.Canceller({ poolManager });
|
|
1032
|
+
const introspector = new introspection_1.Introspector({ poolManager });
|
|
1033
|
+
const scopeDecision = resolveDatabaseScopeDecision(opts.machineConfig);
|
|
1034
|
+
const databaseScope = scopeDecision.rules;
|
|
1035
|
+
for (const line of databaseScopeWarningLines(databaseScope, currentDatabasesConfig.databases, scopeDecision)) {
|
|
1036
|
+
console.error(line);
|
|
1037
|
+
}
|
|
1038
|
+
// an explicit `admin` ceiling is the documented escape hatch and the
|
|
1039
|
+
// only way past the default `developer` ceiling. Saying so once, loudly, at
|
|
1040
|
+
// startup, is what makes it a deliberate choice rather than an inherited one.
|
|
1041
|
+
const configuredRoleCeiling = opts.machineConfig.security
|
|
1042
|
+
?.max_negotiable_role ?? envelope_1.ENVELOPE_MAX_NEGOTIABLE_ROLE_DEFAULT;
|
|
1043
|
+
if (configuredRoleCeiling === 'admin') {
|
|
1044
|
+
console.error('[security] WARNING: security.max_negotiable_role is "admin". A compromised relay can ' +
|
|
1045
|
+
'then assert the full capability set (ddl, migration_run, approve_ddl) on every ' +
|
|
1046
|
+
'configured database this agent can reach. The default ceiling is ' +
|
|
1047
|
+
`"${envelope_1.ENVELOPE_MAX_NEGOTIABLE_ROLE_DEFAULT}".`);
|
|
1048
|
+
}
|
|
1049
|
+
const deniedScopes = new Set();
|
|
1050
|
+
const lookupDb = createLookupDb({
|
|
1051
|
+
getDatabases: () => currentDatabasesConfig.databases,
|
|
1052
|
+
scope: databaseScope,
|
|
1053
|
+
decision: scopeDecision,
|
|
1054
|
+
onDenied: (attempt) => {
|
|
1055
|
+
const key = `${attempt.code ?? 'refused'}|${attempt.project}|${attempt.db_alias ?? ''}`;
|
|
1056
|
+
if (deniedScopes.has(key))
|
|
1057
|
+
return;
|
|
1058
|
+
deniedScopes.add(key);
|
|
1059
|
+
console.error(`[security] Refused request for project "${attempt.project}"` +
|
|
1060
|
+
`${attempt.db_alias ? ` (alias "${attempt.db_alias}")` : ''}` +
|
|
1061
|
+
`${attempt.code ? ` [${attempt.code}]` : ''}: ${attempt.reason}.`);
|
|
1062
|
+
},
|
|
1063
|
+
});
|
|
1064
|
+
const dispatcher = new dispatcher_1.Dispatcher({
|
|
1065
|
+
poolManager,
|
|
1066
|
+
queryRunner,
|
|
1067
|
+
migrationRunner,
|
|
1068
|
+
canceller,
|
|
1069
|
+
introspector,
|
|
1070
|
+
permissionChecker,
|
|
1071
|
+
planRegistry,
|
|
1072
|
+
lookupDb,
|
|
1073
|
+
getMachineConfig: () => opts.machineConfig,
|
|
1074
|
+
send: (msg) => session.send(msg),
|
|
1075
|
+
waitForDrain: () => session.waitForDrain(),
|
|
1076
|
+
auditSink,
|
|
1077
|
+
});
|
|
1078
|
+
session = new agent_session_1.AgentSession({
|
|
1079
|
+
machineConfig: opts.machineConfig,
|
|
1080
|
+
getDatabases: () => currentDatabasesConfig.databases.map((db) => ({
|
|
1081
|
+
db_alias: db.db_alias,
|
|
1082
|
+
database: db.database,
|
|
1083
|
+
})),
|
|
1084
|
+
onMessage: async (msg) => {
|
|
1085
|
+
try {
|
|
1086
|
+
await dispatcher.handle(msg);
|
|
1087
|
+
}
|
|
1088
|
+
catch (err) {
|
|
1089
|
+
(0, error_tracker_1.trackError)(err, { op: msg.type });
|
|
1090
|
+
throw err;
|
|
1091
|
+
}
|
|
1092
|
+
},
|
|
1093
|
+
onStateChange: () => {
|
|
1094
|
+
writeStatus().catch((err) => {
|
|
1095
|
+
console.error('[stateChange] failed to write status:', err);
|
|
1096
|
+
(0, error_tracker_1.trackError)(err, { op: 'writeStatus' });
|
|
1097
|
+
});
|
|
1098
|
+
},
|
|
1099
|
+
});
|
|
1100
|
+
const shutdown = (0, shutdown_1.createShutdownCoordinator)();
|
|
1101
|
+
// Shutdown registration order matters (sequential execution)
|
|
1102
|
+
// 1. pool-manager: wait for active queries to finish
|
|
1103
|
+
shutdown.register('pool-manager', async () => {
|
|
1104
|
+
await poolManager.closeAll();
|
|
1105
|
+
});
|
|
1106
|
+
// 2. agent-session: close websocket (data channel)
|
|
1107
|
+
shutdown.register('agent-session', async () => {
|
|
1108
|
+
await session.stop();
|
|
1109
|
+
});
|
|
1110
|
+
// 3. audit-sink: flush what was written, then release the handle. The step is
|
|
1111
|
+
// memoised, so the signal path and an explicit stop can both call it.
|
|
1112
|
+
shutdown.register('audit-sink', closeAudit);
|
|
1113
|
+
// 4. operation-logger: flush operation logs
|
|
1114
|
+
shutdown.register('operation-logger', async () => {
|
|
1115
|
+
await (0, operation_logger_1.shutdownOperationLogger)();
|
|
1116
|
+
});
|
|
1117
|
+
// NOTE: there is deliberately no inbound HTTP listener anywhere in this
|
|
1118
|
+
// module. An earlier build started an unauthenticated loopback admin server
|
|
1119
|
+
// (`POST /admin/shutdown`, `GET /admin/stats`, `POST /admin/audit-flush`)
|
|
1120
|
+
// whenever `SW_AGENT_E2E=1`, which shipped in the published bundle and made
|
|
1121
|
+
// the README's "never calls listen()" claim false. Test control planes do
|
|
1122
|
+
// not belong in the daemon; if one is ever needed again it must live in a
|
|
1123
|
+
// separate `*-e2e` entry point that is excluded from the published `files`.
|
|
1124
|
+
// See SECURITY.md for the accurate statement of the network posture.
|
|
1125
|
+
const uninstallSignals = (0, signal_handlers_1.installSignalHandlers)(shutdown);
|
|
1126
|
+
/**
|
|
1127
|
+
* A startup step that throws leaves the daemon to unwind without reaching the
|
|
1128
|
+
* shutdown coordinator, so the audit handle would not be released until the
|
|
1129
|
+
* process died. Close it here instead, then rethrow unchanged.
|
|
1130
|
+
*/
|
|
1131
|
+
const failStartup = async (err, op) => {
|
|
1132
|
+
(0, error_tracker_1.trackError)(err, { op });
|
|
1133
|
+
console.error(`[daemon] ${op} failed; closing the audit writer before giving up:`, err);
|
|
1134
|
+
await closeAudit().catch(() => undefined);
|
|
1135
|
+
throw err;
|
|
1136
|
+
};
|
|
1137
|
+
try {
|
|
1138
|
+
await (0, pid_file_1.writePidFile)({ path: opts.pidFile }, {
|
|
1139
|
+
pid: process.pid,
|
|
1140
|
+
started_at: daemonStartedAt,
|
|
1141
|
+
version: index_1.VERSION,
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
catch (err) {
|
|
1145
|
+
await failStartup(err, 'writePidFile');
|
|
1146
|
+
}
|
|
1147
|
+
let isWritingStatus = false;
|
|
1148
|
+
let hasPendingStatusWrite = false;
|
|
1149
|
+
writeStatus = async () => {
|
|
1150
|
+
if (isWritingStatus) {
|
|
1151
|
+
hasPendingStatusWrite = true;
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
isWritingStatus = true;
|
|
1155
|
+
try {
|
|
1156
|
+
for (;;) {
|
|
1157
|
+
const state = session.getState();
|
|
1158
|
+
const errorStats = (0, error_tracker_1.getErrorLogStats)();
|
|
1159
|
+
const auditStats = buildDaemonAuditStats(stats, auditSink.getHealth());
|
|
1160
|
+
const status = {
|
|
1161
|
+
pid: process.pid,
|
|
1162
|
+
started_at: daemonStartedAt,
|
|
1163
|
+
last_heartbeat: new Date().toISOString(),
|
|
1164
|
+
version: index_1.VERSION,
|
|
1165
|
+
channels: {
|
|
1166
|
+
sse: state.wake === 'connected'
|
|
1167
|
+
? 'connected'
|
|
1168
|
+
: state.wake === 'connecting'
|
|
1169
|
+
? 'connecting'
|
|
1170
|
+
: state.wake === 'error'
|
|
1171
|
+
? 'error'
|
|
1172
|
+
: 'disconnected',
|
|
1173
|
+
wss: state.data === 'open'
|
|
1174
|
+
? 'connected'
|
|
1175
|
+
: state.data === 'connecting'
|
|
1176
|
+
? 'connecting'
|
|
1177
|
+
: state.data === 'error'
|
|
1178
|
+
? 'error'
|
|
1179
|
+
: state.data === 'closed'
|
|
1180
|
+
? 'idle'
|
|
1181
|
+
: 'disconnected',
|
|
1182
|
+
},
|
|
1183
|
+
stats: {
|
|
1184
|
+
queries_served: stats.queries_served,
|
|
1185
|
+
streams_served: stats.streams_served,
|
|
1186
|
+
migrations_run: stats.migrations_run,
|
|
1187
|
+
cancellations: stats.cancellations,
|
|
1188
|
+
permission_denies: stats.permission_denies,
|
|
1189
|
+
audit_events_written: auditStats.audit_events_written,
|
|
1190
|
+
audit_events_failed: auditStats.audit_events_failed,
|
|
1191
|
+
audit_buffer_overflows: auditStats.audit_buffer_overflows,
|
|
1192
|
+
audit_dropped: auditStats.audit_dropped,
|
|
1193
|
+
},
|
|
1194
|
+
audit: auditStats.audit,
|
|
1195
|
+
config: {
|
|
1196
|
+
databases: currentDatabasesConfig.databases.length,
|
|
1197
|
+
projects: new Set(currentDatabasesConfig.databases.map((db) => db.project_name)).size,
|
|
1198
|
+
revision: configRevision,
|
|
1199
|
+
},
|
|
1200
|
+
errors_log: {
|
|
1201
|
+
path: errorStats.path,
|
|
1202
|
+
size_bytes: errorStats.size_bytes,
|
|
1203
|
+
},
|
|
1204
|
+
// / the security posture an operator most needs to see is
|
|
1205
|
+
// the one that is invisible when it is wrong, and the daemon's own
|
|
1206
|
+
// console is not where an operator looks. This block is what
|
|
1207
|
+
// `sw-agent status` reads.
|
|
1208
|
+
security: {
|
|
1209
|
+
database_scope: describeDatabaseScope(scopeDecision, currentDatabasesConfig.databases),
|
|
1210
|
+
allowlist_configured: scopeDecision.scoped,
|
|
1211
|
+
allow_unscoped_databases: scopeDecision.allow_unscoped,
|
|
1212
|
+
fail_closed: scopeDecision.fail_closed,
|
|
1213
|
+
env_narrowed_scope: scopeDecision.env_narrowed,
|
|
1214
|
+
max_negotiable_role: configuredRoleCeiling,
|
|
1215
|
+
},
|
|
1216
|
+
};
|
|
1217
|
+
hasPendingStatusWrite = false;
|
|
1218
|
+
await (0, status_file_1.writeStatusFile)({ path: opts.statusFile }, status);
|
|
1219
|
+
if (!hasPendingStatusWrite) {
|
|
1220
|
+
break;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
finally {
|
|
1225
|
+
isWritingStatus = false;
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
const dbConfigPath = (0, paths_1.getDbConfigPath)();
|
|
1229
|
+
const reloadDbConfig = async () => {
|
|
1230
|
+
try {
|
|
1231
|
+
const next = (0, db_config_1.loadDatabasesConfig)();
|
|
1232
|
+
currentDatabasesConfig = next;
|
|
1233
|
+
configRevision = Date.now();
|
|
1234
|
+
// Close every pool whose connection parameters no longer match the
|
|
1235
|
+
// config: a rotated password, a new host, an ssl_mode change or a
|
|
1236
|
+
// permission_override change. Previously only *removed* aliases were
|
|
1237
|
+
// closed, so an edited entry kept serving from the old pg.Pool until the
|
|
1238
|
+
// idle timer fired — revoking a compromised credential did not take
|
|
1239
|
+
// effect.
|
|
1240
|
+
const closed = await poolManager.reconcile(next.databases);
|
|
1241
|
+
if (closed.length > 0) {
|
|
1242
|
+
console.error(`[config] Closed ${closed.length} connection pool(s) whose settings changed: ${closed.join(', ')}.`);
|
|
1243
|
+
}
|
|
1244
|
+
await writeStatus();
|
|
1245
|
+
}
|
|
1246
|
+
catch (err) {
|
|
1247
|
+
(0, error_tracker_1.trackError)(err, { op: 'reloadDbConfig' });
|
|
1248
|
+
console.error('[config] failed to reload database config:', err);
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1251
|
+
try {
|
|
1252
|
+
fs.watchFile(dbConfigPath, { interval: 1000 }, (curr, prev) => {
|
|
1253
|
+
if (curr.mtimeMs !== prev.mtimeMs || curr.size !== prev.size) {
|
|
1254
|
+
void reloadDbConfig();
|
|
1255
|
+
}
|
|
1256
|
+
});
|
|
1257
|
+
shutdown.register('db-config-watcher', async () => {
|
|
1258
|
+
fs.unwatchFile(dbConfigPath);
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
catch (err) {
|
|
1262
|
+
(0, error_tracker_1.trackError)(err, { op: 'watchDbConfig' });
|
|
1263
|
+
}
|
|
1264
|
+
try {
|
|
1265
|
+
await session.start();
|
|
1266
|
+
}
|
|
1267
|
+
catch (err) {
|
|
1268
|
+
await failStartup(err, 'session.start');
|
|
1269
|
+
}
|
|
1270
|
+
const heartbeat = setInterval(() => {
|
|
1271
|
+
writeStatus().catch((err) => {
|
|
1272
|
+
console.error('[heartbeat] failed to write status:', err);
|
|
1273
|
+
});
|
|
1274
|
+
}, 30_000);
|
|
1275
|
+
let autoExitTimer;
|
|
1276
|
+
if (opts.autoExitMs) {
|
|
1277
|
+
autoExitTimer = setTimeout(() => {
|
|
1278
|
+
debugLog('[daemon] Auto exit triggered');
|
|
1279
|
+
shutdown.shutdown(5_000).catch(() => { });
|
|
1280
|
+
}, opts.autoExitMs);
|
|
1281
|
+
}
|
|
1282
|
+
await new Promise((resolve) => {
|
|
1283
|
+
const checkShutdown = setInterval(() => {
|
|
1284
|
+
if (shutdown.isShuttingDown()) {
|
|
1285
|
+
clearInterval(checkShutdown);
|
|
1286
|
+
debugLog(`[daemon] ${new Date().toISOString()} Shutdown detected, proceeding to cleanup...`);
|
|
1287
|
+
resolve();
|
|
1288
|
+
}
|
|
1289
|
+
}, 100);
|
|
1290
|
+
});
|
|
1291
|
+
debugLog(`[daemon] ${new Date().toISOString()} Awaiting shutdown coordinator...`);
|
|
1292
|
+
const result = await shutdown.shutdown(30_000);
|
|
1293
|
+
debugLog(`[daemon] ${new Date().toISOString()} Shutdown coordinator finished with result: ${result}`);
|
|
1294
|
+
clearInterval(heartbeat);
|
|
1295
|
+
if (autoExitTimer)
|
|
1296
|
+
clearTimeout(autoExitTimer);
|
|
1297
|
+
debugLog(`[daemon] ${new Date().toISOString()} Deleting pid file...`);
|
|
1298
|
+
await (0, pid_file_1.deletePidFile)({ path: opts.pidFile });
|
|
1299
|
+
debugLog(`[daemon] ${new Date().toISOString()} Uninstalling signals...`);
|
|
1300
|
+
uninstallSignals();
|
|
1301
|
+
debugLog(`[daemon] ${new Date().toISOString()} Writing final status...`);
|
|
1302
|
+
const finalErrorStats = (0, error_tracker_1.getErrorLogStats)();
|
|
1303
|
+
const finalAuditStats = buildDaemonAuditStats(stats, auditSink.getHealth());
|
|
1304
|
+
await (0, status_file_1.writeStatusFile)({ path: opts.statusFile }, {
|
|
1305
|
+
pid: process.pid,
|
|
1306
|
+
started_at: daemonStartedAt,
|
|
1307
|
+
last_heartbeat: new Date().toISOString(),
|
|
1308
|
+
version: index_1.VERSION,
|
|
1309
|
+
channels: {
|
|
1310
|
+
sse: 'disconnected',
|
|
1311
|
+
wss: 'disconnected',
|
|
1312
|
+
},
|
|
1313
|
+
stats: {
|
|
1314
|
+
queries_served: stats.queries_served,
|
|
1315
|
+
streams_served: stats.streams_served,
|
|
1316
|
+
migrations_run: stats.migrations_run,
|
|
1317
|
+
cancellations: stats.cancellations,
|
|
1318
|
+
permission_denies: stats.permission_denies,
|
|
1319
|
+
audit_events_written: finalAuditStats.audit_events_written,
|
|
1320
|
+
audit_events_failed: finalAuditStats.audit_events_failed,
|
|
1321
|
+
audit_buffer_overflows: finalAuditStats.audit_buffer_overflows,
|
|
1322
|
+
audit_dropped: finalAuditStats.audit_dropped,
|
|
1323
|
+
},
|
|
1324
|
+
audit: finalAuditStats.audit,
|
|
1325
|
+
config: {
|
|
1326
|
+
databases: currentDatabasesConfig.databases.length,
|
|
1327
|
+
projects: new Set(currentDatabasesConfig.databases.map((db) => db.project_name)).size,
|
|
1328
|
+
revision: configRevision,
|
|
1329
|
+
},
|
|
1330
|
+
errors_log: {
|
|
1331
|
+
path: finalErrorStats.path,
|
|
1332
|
+
size_bytes: finalErrorStats.size_bytes,
|
|
1333
|
+
},
|
|
1334
|
+
});
|
|
1335
|
+
debugLog(`[daemon] runAgent returning exit code: ${result === 'clean' ? 0 : 1}`);
|
|
1336
|
+
return result === 'clean' ? 0 : 1;
|
|
1337
|
+
}
|
|
1338
|
+
function debugLog(message) {
|
|
1339
|
+
if (process.env.SW_AGENT_DEBUG === '1') {
|
|
1340
|
+
console.error(message);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
//# sourceMappingURL=runtime.js.map
|