airlock-bot 0.3.1 → 0.4.0
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/README.md +46 -33
- package/airlock.service +1 -0
- package/dist/airlock/context.d.ts.map +1 -1
- package/dist/airlock/context.js +5 -3
- package/dist/airlock/context.js.map +1 -1
- package/dist/airlock/tools.d.ts +15 -3
- package/dist/airlock/tools.d.ts.map +1 -1
- package/dist/airlock/tools.js +29 -1
- package/dist/airlock/tools.js.map +1 -1
- package/dist/allowlist/engine.d.ts +3 -0
- package/dist/allowlist/engine.d.ts.map +1 -1
- package/dist/allowlist/engine.js +46 -2
- package/dist/allowlist/engine.js.map +1 -1
- package/dist/audit/db.d.ts +22 -1
- package/dist/audit/db.d.ts.map +1 -1
- package/dist/audit/db.js +77 -10
- package/dist/audit/db.js.map +1 -1
- package/dist/audit/logger.d.ts +7 -2
- package/dist/audit/logger.d.ts.map +1 -1
- package/dist/audit/logger.js +18 -3
- package/dist/audit/logger.js.map +1 -1
- package/dist/audit/redactor.d.ts.map +1 -1
- package/dist/audit/redactor.js +6 -6
- package/dist/audit/redactor.js.map +1 -1
- package/dist/backend/airlock-adapter.d.ts +20 -2
- package/dist/backend/airlock-adapter.d.ts.map +1 -1
- package/dist/backend/airlock-adapter.js +443 -10
- package/dist/backend/airlock-adapter.js.map +1 -1
- package/dist/backend/cli/adapter.d.ts +4 -2
- package/dist/backend/cli/adapter.d.ts.map +1 -1
- package/dist/backend/cli/adapter.js +36 -11
- package/dist/backend/cli/adapter.js.map +1 -1
- package/dist/backend/cli/builder.d.ts +1 -1
- package/dist/backend/cli/builder.d.ts.map +1 -1
- package/dist/backend/cli/builder.js +28 -12
- package/dist/backend/cli/builder.js.map +1 -1
- package/dist/backend/exec-adapter.d.ts +1 -1
- package/dist/backend/exec-adapter.d.ts.map +1 -1
- package/dist/backend/exec-adapter.js +1 -5
- package/dist/backend/exec-adapter.js.map +1 -1
- package/dist/backend/factory.d.ts +2 -0
- package/dist/backend/factory.d.ts.map +1 -1
- package/dist/backend/factory.js +19 -5
- package/dist/backend/factory.js.map +1 -1
- package/dist/backend/http-adapter.d.ts +6 -3
- package/dist/backend/http-adapter.d.ts.map +1 -1
- package/dist/backend/http-adapter.js +24 -10
- package/dist/backend/http-adapter.js.map +1 -1
- package/dist/backend/mcp-adapter.d.ts +7 -2
- package/dist/backend/mcp-adapter.d.ts.map +1 -1
- package/dist/backend/mcp-adapter.js +74 -16
- package/dist/backend/mcp-adapter.js.map +1 -1
- package/dist/backend/openapi/adapter.d.ts +8 -2
- package/dist/backend/openapi/adapter.d.ts.map +1 -1
- package/dist/backend/openapi/adapter.js +196 -17
- package/dist/backend/openapi/adapter.js.map +1 -1
- package/dist/backend/openapi/parser.d.ts +15 -1
- package/dist/backend/openapi/parser.d.ts.map +1 -1
- package/dist/backend/openapi/parser.js +153 -11
- package/dist/backend/openapi/parser.js.map +1 -1
- package/dist/backend/types.d.ts +12 -1
- package/dist/backend/types.d.ts.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +334 -50
- package/dist/config/loader.js.map +1 -1
- package/dist/config/mutator.d.ts.map +1 -1
- package/dist/config/mutator.js +13 -3
- package/dist/config/mutator.js.map +1 -1
- package/dist/config/profiles.d.ts +2 -1
- package/dist/config/profiles.d.ts.map +1 -1
- package/dist/config/profiles.js +50 -2
- package/dist/config/profiles.js.map +1 -1
- package/dist/config/provider-credentials.d.ts +4 -0
- package/dist/config/provider-credentials.d.ts.map +1 -0
- package/dist/config/provider-credentials.js +48 -0
- package/dist/config/provider-credentials.js.map +1 -0
- package/dist/config/schema.d.ts +2829 -8642
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +337 -122
- package/dist/config/schema.js.map +1 -1
- package/dist/config/watcher.d.ts.map +1 -1
- package/dist/config/watcher.js +3 -0
- package/dist/config/watcher.js.map +1 -1
- package/dist/config/yaml-merge.d.ts +9 -0
- package/dist/config/yaml-merge.d.ts.map +1 -0
- package/dist/config/yaml-merge.js +54 -0
- package/dist/config/yaml-merge.js.map +1 -0
- package/dist/configure-agent/cli.d.ts +26 -0
- package/dist/configure-agent/cli.d.ts.map +1 -1
- package/dist/configure-agent/cli.js +70 -35
- package/dist/configure-agent/cli.js.map +1 -1
- package/dist/configure-cli/cli.d.ts +6 -0
- package/dist/configure-cli/cli.d.ts.map +1 -1
- package/dist/configure-cli/cli.js +45 -14
- package/dist/configure-cli/cli.js.map +1 -1
- package/dist/configure-web/assistant.d.ts +49 -0
- package/dist/configure-web/assistant.d.ts.map +1 -0
- package/dist/configure-web/assistant.js +312 -0
- package/dist/configure-web/assistant.js.map +1 -0
- package/dist/configure-web/changes.d.ts +214 -0
- package/dist/configure-web/changes.d.ts.map +1 -0
- package/dist/configure-web/changes.js +317 -0
- package/dist/configure-web/changes.js.map +1 -0
- package/dist/configure-web/cli.d.ts +33 -11
- package/dist/configure-web/cli.d.ts.map +1 -1
- package/dist/configure-web/cli.js +704 -151
- package/dist/configure-web/cli.js.map +1 -1
- package/dist/discover/cli.js +2 -2
- package/dist/discover/cli.js.map +1 -1
- package/dist/discover/index.d.ts.map +1 -1
- package/dist/discover/index.js +16 -22
- package/dist/discover/index.js.map +1 -1
- package/dist/discover/openapi.d.ts.map +1 -1
- package/dist/discover/openapi.js +2 -0
- package/dist/discover/openapi.js.map +1 -1
- package/dist/discover/strategies/completion.d.ts.map +1 -1
- package/dist/discover/strategies/completion.js +19 -2
- package/dist/discover/strategies/completion.js.map +1 -1
- package/dist/discover/strategies/fig.d.ts +10 -1
- package/dist/discover/strategies/fig.d.ts.map +1 -1
- package/dist/discover/strategies/fig.js +24 -10
- package/dist/discover/strategies/fig.js.map +1 -1
- package/dist/discover/strategies/help-parser.d.ts.map +1 -1
- package/dist/discover/strategies/help-parser.js +9 -6
- package/dist/discover/strategies/help-parser.js.map +1 -1
- package/dist/events/payload-inspector.d.ts +25 -0
- package/dist/events/payload-inspector.d.ts.map +1 -0
- package/dist/events/payload-inspector.js +210 -0
- package/dist/events/payload-inspector.js.map +1 -0
- package/dist/events/protocol.d.ts +227 -0
- package/dist/events/protocol.d.ts.map +1 -0
- package/dist/events/protocol.js +422 -0
- package/dist/events/protocol.js.map +1 -0
- package/dist/events/registry.d.ts +57 -0
- package/dist/events/registry.d.ts.map +1 -0
- package/dist/events/registry.js +179 -0
- package/dist/events/registry.js.map +1 -0
- package/dist/events/schema-validator.d.ts +13 -0
- package/dist/events/schema-validator.d.ts.map +1 -0
- package/dist/events/schema-validator.js +54 -0
- package/dist/events/schema-validator.js.map +1 -0
- package/dist/events/service.d.ts +97 -0
- package/dist/events/service.d.ts.map +1 -0
- package/dist/events/service.js +918 -0
- package/dist/events/service.js.map +1 -0
- package/dist/events/stream-manager.d.ts +58 -0
- package/dist/events/stream-manager.d.ts.map +1 -0
- package/dist/events/stream-manager.js +94 -0
- package/dist/events/stream-manager.js.map +1 -0
- package/dist/events/upstream-client.d.ts +88 -0
- package/dist/events/upstream-client.d.ts.map +1 -0
- package/dist/events/upstream-client.js +437 -0
- package/dist/events/upstream-client.js.map +1 -0
- package/dist/gateway.d.ts +14 -0
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +208 -33
- package/dist/gateway.js.map +1 -1
- package/dist/hitl/api.d.ts.map +1 -1
- package/dist/hitl/api.js +9 -2
- package/dist/hitl/api.js.map +1 -1
- package/dist/hitl/approval-dashboard.d.ts +5 -0
- package/dist/hitl/approval-dashboard.d.ts.map +1 -1
- package/dist/hitl/approval-dashboard.js +107 -20
- package/dist/hitl/approval-dashboard.js.map +1 -1
- package/dist/hitl/approval-stream.d.ts +2 -0
- package/dist/hitl/approval-stream.d.ts.map +1 -1
- package/dist/hitl/approval-stream.js +11 -0
- package/dist/hitl/approval-stream.js.map +1 -1
- package/dist/hitl/engine.d.ts +154 -4
- package/dist/hitl/engine.d.ts.map +1 -1
- package/dist/hitl/engine.js +616 -102
- package/dist/hitl/engine.js.map +1 -1
- package/dist/hitl/formatter.d.ts.map +1 -1
- package/dist/hitl/formatter.js +60 -10
- package/dist/hitl/formatter.js.map +1 -1
- package/dist/hitl/grant-api.d.ts +32 -0
- package/dist/hitl/grant-api.d.ts.map +1 -0
- package/dist/hitl/grant-api.js +249 -0
- package/dist/hitl/grant-api.js.map +1 -0
- package/dist/hitl/grants.d.ts +153 -0
- package/dist/hitl/grants.d.ts.map +1 -0
- package/dist/hitl/grants.js +273 -0
- package/dist/hitl/grants.js.map +1 -0
- package/dist/hitl/parser.d.ts +9 -0
- package/dist/hitl/parser.d.ts.map +1 -1
- package/dist/hitl/parser.js +60 -4
- package/dist/hitl/parser.js.map +1 -1
- package/dist/hitl/provider-factory.js +6 -1
- package/dist/hitl/provider-factory.js.map +1 -1
- package/dist/hitl/providers/composite.d.ts +0 -1
- package/dist/hitl/providers/composite.d.ts.map +1 -1
- package/dist/hitl/providers/composite.js +0 -3
- package/dist/hitl/providers/composite.js.map +1 -1
- package/dist/hitl/providers/dashboard.d.ts +1 -0
- package/dist/hitl/providers/dashboard.d.ts.map +1 -1
- package/dist/hitl/providers/dashboard.js +9 -2
- package/dist/hitl/providers/dashboard.js.map +1 -1
- package/dist/hitl/providers/ios.d.ts +0 -1
- package/dist/hitl/providers/ios.d.ts.map +1 -1
- package/dist/hitl/providers/ios.js +94 -39
- package/dist/hitl/providers/ios.js.map +1 -1
- package/dist/hitl/providers/macos.d.ts +2 -0
- package/dist/hitl/providers/macos.d.ts.map +1 -1
- package/dist/hitl/providers/macos.js +90 -3
- package/dist/hitl/providers/macos.js.map +1 -1
- package/dist/hitl/providers/openclaw.js +3 -9
- package/dist/hitl/providers/openclaw.js.map +1 -1
- package/dist/hitl/providers/stdio.js +3 -9
- package/dist/hitl/providers/stdio.js.map +1 -1
- package/dist/hitl/providers/telegram.d.ts.map +1 -1
- package/dist/hitl/providers/telegram.js +6 -10
- package/dist/hitl/providers/telegram.js.map +1 -1
- package/dist/hitl/providers/tui.d.ts +1 -1
- package/dist/hitl/providers/tui.d.ts.map +1 -1
- package/dist/hitl/providers/tui.js +91 -31
- package/dist/hitl/providers/tui.js.map +1 -1
- package/dist/hitl/providers/types.d.ts +38 -3
- package/dist/hitl/providers/types.d.ts.map +1 -1
- package/dist/hitl/runtime.d.ts +18 -0
- package/dist/hitl/runtime.d.ts.map +1 -0
- package/dist/hitl/runtime.js +60 -0
- package/dist/hitl/runtime.js.map +1 -0
- package/dist/hook/api.d.ts +6 -1
- package/dist/hook/api.d.ts.map +1 -1
- package/dist/hook/api.js +51 -12
- package/dist/hook/api.js.map +1 -1
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/dist/introspect/cli.d.ts.map +1 -1
- package/dist/introspect/cli.js +5 -2
- package/dist/introspect/cli.js.map +1 -1
- package/dist/mcp-apps/ui.d.ts +69 -0
- package/dist/mcp-apps/ui.d.ts.map +1 -0
- package/dist/mcp-apps/ui.js +143 -0
- package/dist/mcp-apps/ui.js.map +1 -0
- package/dist/middleware/audit-args.d.ts +7 -0
- package/dist/middleware/audit-args.d.ts.map +1 -0
- package/dist/middleware/audit-args.js +23 -0
- package/dist/middleware/audit-args.js.map +1 -0
- package/dist/middleware/chain-builder.d.ts +2 -2
- package/dist/middleware/chain-builder.d.ts.map +1 -1
- package/dist/middleware/chain-builder.js +7 -3
- package/dist/middleware/chain-builder.js.map +1 -1
- package/dist/middleware/core/allowlist.d.ts.map +1 -1
- package/dist/middleware/core/allowlist.js +8 -5
- package/dist/middleware/core/allowlist.js.map +1 -1
- package/dist/middleware/core/arg-policy.d.ts +1 -0
- package/dist/middleware/core/arg-policy.d.ts.map +1 -1
- package/dist/middleware/core/arg-policy.js +34 -37
- package/dist/middleware/core/arg-policy.js.map +1 -1
- package/dist/middleware/core/command-policy.d.ts +4 -1
- package/dist/middleware/core/command-policy.d.ts.map +1 -1
- package/dist/middleware/core/command-policy.js +50 -4
- package/dist/middleware/core/command-policy.js.map +1 -1
- package/dist/middleware/core/exec-policy.d.ts.map +1 -1
- package/dist/middleware/core/exec-policy.js +5 -5
- package/dist/middleware/core/exec-policy.js.map +1 -1
- package/dist/middleware/core/execute.d.ts +5 -1
- package/dist/middleware/core/execute.d.ts.map +1 -1
- package/dist/middleware/core/execute.js +18 -15
- package/dist/middleware/core/execute.js.map +1 -1
- package/dist/middleware/core/hitl-gate.d.ts +4 -1
- package/dist/middleware/core/hitl-gate.d.ts.map +1 -1
- package/dist/middleware/core/hitl-gate.js +153 -45
- package/dist/middleware/core/hitl-gate.js.map +1 -1
- package/dist/middleware/core/rate-limiter.d.ts.map +1 -1
- package/dist/middleware/core/rate-limiter.js +23 -7
- package/dist/middleware/core/rate-limiter.js.map +1 -1
- package/dist/middleware/core/schema-validator.d.ts +3 -0
- package/dist/middleware/core/schema-validator.d.ts.map +1 -1
- package/dist/middleware/core/schema-validator.js +31 -12
- package/dist/middleware/core/schema-validator.js.map +1 -1
- package/dist/middleware/core/upload-policy.d.ts +18 -0
- package/dist/middleware/core/upload-policy.d.ts.map +1 -0
- package/dist/middleware/core/upload-policy.js +98 -0
- package/dist/middleware/core/upload-policy.js.map +1 -0
- package/dist/middleware/detectors/injection-detector.d.ts.map +1 -1
- package/dist/middleware/detectors/injection-detector.js +8 -6
- package/dist/middleware/detectors/injection-detector.js.map +1 -1
- package/dist/middleware/detectors/sensitivity-classifier.d.ts.map +1 -1
- package/dist/middleware/detectors/sensitivity-classifier.js +19 -5
- package/dist/middleware/detectors/sensitivity-classifier.js.map +1 -1
- package/dist/middleware/post/untrusted-envelope.d.ts.map +1 -1
- package/dist/middleware/post/untrusted-envelope.js +4 -1
- package/dist/middleware/post/untrusted-envelope.js.map +1 -1
- package/dist/middleware/response.d.ts +33 -0
- package/dist/middleware/response.d.ts.map +1 -0
- package/dist/middleware/response.js +110 -0
- package/dist/middleware/response.js.map +1 -0
- package/dist/middleware/types.d.ts +13 -0
- package/dist/middleware/types.d.ts.map +1 -1
- package/dist/mobile/api.d.ts.map +1 -1
- package/dist/mobile/api.js +57 -34
- package/dist/mobile/api.js.map +1 -1
- package/dist/mobile/apns.d.ts +39 -2
- package/dist/mobile/apns.d.ts.map +1 -1
- package/dist/mobile/apns.js +84 -83
- package/dist/mobile/apns.js.map +1 -1
- package/dist/pool/client-credentials.d.ts +2 -0
- package/dist/pool/client-credentials.d.ts.map +1 -1
- package/dist/pool/client-credentials.js +18 -3
- package/dist/pool/client-credentials.js.map +1 -1
- package/dist/pool/credential-health.d.ts +2 -2
- package/dist/pool/credential-health.d.ts.map +1 -1
- package/dist/pool/credential-health.js +7 -2
- package/dist/pool/credential-health.js.map +1 -1
- package/dist/pool/http-client.d.ts +105 -16
- package/dist/pool/http-client.d.ts.map +1 -1
- package/dist/pool/http-client.js +712 -116
- package/dist/pool/http-client.js.map +1 -1
- package/dist/pool/oauth-callback-router.d.ts +35 -0
- package/dist/pool/oauth-callback-router.d.ts.map +1 -0
- package/dist/pool/oauth-callback-router.js +84 -0
- package/dist/pool/oauth-callback-router.js.map +1 -0
- package/dist/pool/oauth-cli.d.ts +10 -0
- package/dist/pool/oauth-cli.d.ts.map +1 -0
- package/dist/pool/oauth-cli.js +318 -0
- package/dist/pool/oauth-cli.js.map +1 -0
- package/dist/pool/oauth-lock.d.ts +149 -0
- package/dist/pool/oauth-lock.d.ts.map +1 -0
- package/dist/pool/oauth-lock.js +575 -0
- package/dist/pool/oauth-lock.js.map +1 -0
- package/dist/pool/oauth-provider.d.ts +231 -27
- package/dist/pool/oauth-provider.d.ts.map +1 -1
- package/dist/pool/oauth-provider.js +802 -142
- package/dist/pool/oauth-provider.js.map +1 -1
- package/dist/pool/oauth-refresh.d.ts +94 -0
- package/dist/pool/oauth-refresh.d.ts.map +1 -0
- package/dist/pool/oauth-refresh.js +477 -0
- package/dist/pool/oauth-refresh.js.map +1 -0
- package/dist/pool/oauth-store.d.ts +304 -0
- package/dist/pool/oauth-store.d.ts.map +1 -0
- package/dist/pool/oauth-store.js +684 -0
- package/dist/pool/oauth-store.js.map +1 -0
- package/dist/pool/pool.d.ts +37 -4
- package/dist/pool/pool.d.ts.map +1 -1
- package/dist/pool/pool.js +170 -8
- package/dist/pool/pool.js.map +1 -1
- package/dist/pool/required-mcps.d.ts +7 -0
- package/dist/pool/required-mcps.d.ts.map +1 -1
- package/dist/pool/required-mcps.js +40 -2
- package/dist/pool/required-mcps.js.map +1 -1
- package/dist/pool/sse-client.d.ts +17 -3
- package/dist/pool/sse-client.d.ts.map +1 -1
- package/dist/pool/sse-client.js +59 -6
- package/dist/pool/sse-client.js.map +1 -1
- package/dist/pool/status.d.ts +53 -0
- package/dist/pool/status.d.ts.map +1 -1
- package/dist/pool/stdio-client.d.ts +23 -3
- package/dist/pool/stdio-client.d.ts.map +1 -1
- package/dist/pool/stdio-client.js +84 -6
- package/dist/pool/stdio-client.js.map +1 -1
- package/dist/registry/airlock-policy.d.ts +1 -1
- package/dist/registry/airlock-policy.d.ts.map +1 -1
- package/dist/registry/airlock-policy.js +1 -1
- package/dist/registry/airlock-policy.js.map +1 -1
- package/dist/registry/registry.d.ts +22 -2
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +176 -22
- package/dist/registry/registry.js.map +1 -1
- package/dist/registry/sanitizer.d.ts +5 -0
- package/dist/registry/sanitizer.d.ts.map +1 -1
- package/dist/registry/sanitizer.js +17 -13
- package/dist/registry/sanitizer.js.map +1 -1
- package/dist/security/request.d.ts +19 -0
- package/dist/security/request.d.ts.map +1 -1
- package/dist/security/request.js +35 -1
- package/dist/security/request.js.map +1 -1
- package/dist/stdio-mode.d.ts.map +1 -1
- package/dist/stdio-mode.js +237 -50
- package/dist/stdio-mode.js.map +1 -1
- package/dist/tools/api.d.ts.map +1 -1
- package/dist/tools/api.js +49 -15
- package/dist/tools/api.js.map +1 -1
- package/dist/tools/exec.d.ts +1 -1
- package/dist/tools/exec.d.ts.map +1 -1
- package/dist/tools/http.d.ts +7 -3
- package/dist/tools/http.d.ts.map +1 -1
- package/dist/tools/http.js +179 -25
- package/dist/tools/http.js.map +1 -1
- package/dist/transport/agent-server.d.ts +29 -2
- package/dist/transport/agent-server.d.ts.map +1 -1
- package/dist/transport/agent-server.js +190 -32
- package/dist/transport/agent-server.js.map +1 -1
- package/dist/transport/http-server.d.ts +17 -2
- package/dist/transport/http-server.d.ts.map +1 -1
- package/dist/transport/http-server.js +109 -96
- package/dist/transport/http-server.js.map +1 -1
- package/dist/transport/keepalive.d.ts +11 -13
- package/dist/transport/keepalive.d.ts.map +1 -1
- package/dist/transport/keepalive.js +11 -13
- package/dist/transport/keepalive.js.map +1 -1
- package/dist/transport/oauth-callback.d.ts +19 -0
- package/dist/transport/oauth-callback.d.ts.map +1 -0
- package/dist/transport/oauth-callback.js +30 -0
- package/dist/transport/oauth-callback.js.map +1 -0
- package/dist/transport/session-limiter.d.ts +10 -3
- package/dist/transport/session-limiter.d.ts.map +1 -1
- package/dist/transport/session-limiter.js +13 -3
- package/dist/transport/session-limiter.js.map +1 -1
- package/dist/transport/sse-server.d.ts.map +1 -1
- package/dist/transport/sse-server.js +54 -24
- package/dist/transport/sse-server.js.map +1 -1
- package/dist/transport/stdio-server.d.ts +6 -0
- package/dist/transport/stdio-server.d.ts.map +1 -1
- package/dist/transport/stdio-server.js +19 -7
- package/dist/transport/stdio-server.js.map +1 -1
- package/dist/types.d.ts +0 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/uploads/api.d.ts +20 -0
- package/dist/uploads/api.d.ts.map +1 -0
- package/dist/uploads/api.js +280 -0
- package/dist/uploads/api.js.map +1 -0
- package/dist/uploads/refs.d.ts +48 -0
- package/dist/uploads/refs.d.ts.map +1 -0
- package/dist/uploads/refs.js +273 -0
- package/dist/uploads/refs.js.map +1 -0
- package/dist/uploads/resolve.d.ts +117 -0
- package/dist/uploads/resolve.d.ts.map +1 -0
- package/dist/uploads/resolve.js +581 -0
- package/dist/uploads/resolve.js.map +1 -0
- package/dist/uploads/store.d.ts +224 -0
- package/dist/uploads/store.d.ts.map +1 -0
- package/dist/uploads/store.js +1908 -0
- package/dist/uploads/store.js.map +1 -0
- package/dist/util/atomic-file.d.ts +6 -0
- package/dist/util/atomic-file.d.ts.map +1 -1
- package/dist/util/atomic-file.js +42 -2
- package/dist/util/atomic-file.js.map +1 -1
- package/dist/util/is-record.d.ts +3 -0
- package/dist/util/is-record.d.ts.map +1 -0
- package/dist/util/is-record.js +5 -0
- package/dist/util/is-record.js.map +1 -0
- package/dist/util/stable-json.d.ts +3 -0
- package/dist/util/stable-json.d.ts.map +1 -0
- package/dist/util/stable-json.js +10 -0
- package/dist/util/stable-json.js.map +1 -0
- package/dist/util/tool-name.d.ts +9 -0
- package/dist/util/tool-name.d.ts.map +1 -0
- package/dist/util/tool-name.js +14 -0
- package/dist/util/tool-name.js.map +1 -0
- package/dist/web/assets/airlock-shield-fPu067nB.png +0 -0
- package/dist/web/assets/favicon-DL7sWXGq.png +0 -0
- package/dist/web/assets/index-B_qY7DgQ.js +225 -0
- package/dist/web/assets/index-Bc_jHlFK.css +1 -0
- package/dist/web/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/web/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/web/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/web/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/web/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/web/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/web/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/web/index.html +17 -0
- package/examples/airlock.yaml +3 -1
- package/examples/claude-code-setup.md +1 -1
- package/examples/docker-compose.yaml +3 -1
- package/examples/docker-gateway.yaml +2 -1
- package/examples/gateway.yaml +1 -1
- package/examples/profiles.yaml +5 -2
- package/examples/sandbox-presets.yaml +4 -1
- package/extensions/openclaw/index.ts +3 -3
- package/extensions/openclaw/openclaw.plugin.json +4 -4
- package/package.json +25 -10
- package/schema.json +2819 -2029
- package/dist/transport/mcp-normalizer.d.ts +0 -9
- package/dist/transport/mcp-normalizer.d.ts.map +0 -1
- package/dist/transport/mcp-normalizer.js +0 -12
- package/dist/transport/mcp-normalizer.js.map +0 -1
- package/extensions/openclaw/package-lock.json +0 -8548
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync, copyFileSync } from 'fs';
|
|
1
|
+
import { existsSync, readFileSync, copyFileSync, statSync } from 'fs';
|
|
3
2
|
import { isIP } from 'net';
|
|
3
|
+
import { dirname, extname, join, normalize, sep } from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
4
5
|
import { parseArgs } from 'util';
|
|
5
6
|
import Fastify from 'fastify';
|
|
6
|
-
import { parse as parseYaml
|
|
7
|
+
import { parse as parseYaml } from 'yaml';
|
|
7
8
|
import { AuditDb } from '../audit/db.js';
|
|
8
9
|
import { buildAdapters } from '../backend/factory.js';
|
|
9
|
-
import { AuditConfig, GatewayConfig, McpServerConfig, ProviderConfig, getMcpConfigs, } from '../config/schema.js';
|
|
10
|
+
import { AuditConfig, GatewayConfig, McpServerConfig, ProviderConfig, getMcpConfigs, withEnvVarResolution, } from '../config/schema.js';
|
|
11
|
+
import { resolveProviderBearerFile } from '../config/provider-credentials.js';
|
|
10
12
|
import { rememberAllow } from '../config/mutator.js';
|
|
11
13
|
import { validateConfig } from '../config/loader.js';
|
|
12
14
|
import { applyProfiles } from '../config/profiles.js';
|
|
13
15
|
import { ClientPool } from '../pool/pool.js';
|
|
14
16
|
import { checkSuspiciousPatterns } from '../registry/sanitizer.js';
|
|
15
|
-
import {
|
|
17
|
+
import { atomicWriteTextFileSync } from '../util/atomic-file.js';
|
|
16
18
|
import { VERSION } from '../version.js';
|
|
19
|
+
import { stringifyPreservingComments } from '../config/yaml-merge.js';
|
|
20
|
+
import { ChangeConflictError, ChangeValidationError, applyChanges, createAgentKey, hashAgentKey, parseChangeSet, previewChanges, } from './changes.js';
|
|
21
|
+
import { assistantOptionsFromEnv, runAssistantTurn, } from './assistant.js';
|
|
17
22
|
const LATEST_VERSION_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
18
23
|
let latestVersionCache = null;
|
|
19
24
|
const HELP = `
|
|
@@ -28,7 +33,12 @@ Options:
|
|
|
28
33
|
--host <host> Bind host (default: 127.0.0.1)
|
|
29
34
|
--insecure-remote-bind
|
|
30
35
|
Allow binding the unauthenticated UI beyond loopback
|
|
36
|
+
--public-url <url> Gateway URL agents connect to, used in setup snippets
|
|
37
|
+
(default: AIRLOCK_PUBLIC_URL)
|
|
31
38
|
-h, --help Show this help
|
|
39
|
+
|
|
40
|
+
Policy assistant (optional): set AIRLOCK_ASSISTANT_BASE_URL, AIRLOCK_ASSISTANT_MODEL and
|
|
41
|
+
AIRLOCK_ASSISTANT_API_KEY to an OpenAI-compatible chat completions endpoint.
|
|
32
42
|
`;
|
|
33
43
|
const RUN_HELP = `
|
|
34
44
|
airlock run - browser command center for provider health and permissions
|
|
@@ -42,7 +52,12 @@ Options:
|
|
|
42
52
|
--host <host> Bind host (default: 127.0.0.1)
|
|
43
53
|
--insecure-remote-bind
|
|
44
54
|
Allow binding the unauthenticated UI beyond loopback
|
|
55
|
+
--public-url <url> Gateway URL agents connect to, used in setup snippets
|
|
56
|
+
(default: AIRLOCK_PUBLIC_URL)
|
|
45
57
|
-h, --help Show this help
|
|
58
|
+
|
|
59
|
+
Policy assistant (optional): set AIRLOCK_ASSISTANT_BASE_URL, AIRLOCK_ASSISTANT_MODEL and
|
|
60
|
+
AIRLOCK_ASSISTANT_API_KEY to an OpenAI-compatible chat completions endpoint.
|
|
46
61
|
`;
|
|
47
62
|
const DASHBOARD_HELP = `
|
|
48
63
|
airlock dashboard - standalone admin dashboard for a remote Airlock gateway
|
|
@@ -57,7 +72,12 @@ Options:
|
|
|
57
72
|
--insecure-remote-bind Allow binding the unauthenticated dashboard beyond loopback
|
|
58
73
|
--gateway-url <url> Gateway management API URL (default: http://127.0.0.1:4113)
|
|
59
74
|
--gateway-secret <secret> Gateway admin bearer token (default: AIRLOCK_GATEWAY_SECRET or AIRLOCK_API_SECRET)
|
|
75
|
+
--public-url <url> Gateway URL agents connect to, used in setup snippets
|
|
76
|
+
(default: AIRLOCK_PUBLIC_URL)
|
|
60
77
|
-h, --help Show this help
|
|
78
|
+
|
|
79
|
+
Policy assistant (optional): set AIRLOCK_ASSISTANT_BASE_URL, AIRLOCK_ASSISTANT_MODEL and
|
|
80
|
+
AIRLOCK_ASSISTANT_API_KEY to an OpenAI-compatible chat completions endpoint.
|
|
61
81
|
`;
|
|
62
82
|
export async function runCommandCenter(argv) {
|
|
63
83
|
await runConfigureWeb(argv, 'run');
|
|
@@ -72,6 +92,7 @@ export async function runDashboard(argv) {
|
|
|
72
92
|
'gateway-url': { type: 'string', default: 'http://127.0.0.1:4113' },
|
|
73
93
|
'gateway-secret': { type: 'string' },
|
|
74
94
|
'insecure-remote-bind': { type: 'boolean', default: false },
|
|
95
|
+
'public-url': { type: 'string' },
|
|
75
96
|
help: { type: 'boolean', short: 'h', default: false },
|
|
76
97
|
},
|
|
77
98
|
allowPositionals: false,
|
|
@@ -93,6 +114,9 @@ export async function runDashboard(argv) {
|
|
|
93
114
|
assertSafeWebBindHost(host, values['insecure-remote-bind'] === true);
|
|
94
115
|
const app = createConfigureWebApp(configPath, {
|
|
95
116
|
remoteGateway: { url: gatewayUrl, secret: gatewaySecret },
|
|
117
|
+
assistant: assistantOptionsFromEnv(),
|
|
118
|
+
publicGatewayUrl: values['public-url'] ?? process.env['AIRLOCK_PUBLIC_URL'],
|
|
119
|
+
bindHost: host,
|
|
96
120
|
});
|
|
97
121
|
await app.listen({ host, port });
|
|
98
122
|
console.log(`Airlock dashboard running at http://${host}:${port}`);
|
|
@@ -107,6 +131,7 @@ export async function runConfigureWeb(argv, entrypoint = 'configure-web') {
|
|
|
107
131
|
port: { type: 'string', short: 'p', default: '4177' },
|
|
108
132
|
host: { type: 'string', default: '127.0.0.1' },
|
|
109
133
|
'insecure-remote-bind': { type: 'boolean', default: false },
|
|
134
|
+
'public-url': { type: 'string' },
|
|
110
135
|
help: { type: 'boolean', short: 'h', default: false },
|
|
111
136
|
},
|
|
112
137
|
allowPositionals: false,
|
|
@@ -122,7 +147,11 @@ export async function runConfigureWeb(argv, entrypoint = 'configure-web') {
|
|
|
122
147
|
throw new Error(`Invalid --port: ${values.port}`);
|
|
123
148
|
}
|
|
124
149
|
assertSafeWebBindHost(host, values['insecure-remote-bind'] === true);
|
|
125
|
-
const app = createConfigureWebApp(configPath
|
|
150
|
+
const app = createConfigureWebApp(configPath, {
|
|
151
|
+
assistant: assistantOptionsFromEnv(),
|
|
152
|
+
publicGatewayUrl: values['public-url'] ?? process.env['AIRLOCK_PUBLIC_URL'],
|
|
153
|
+
bindHost: host,
|
|
154
|
+
});
|
|
126
155
|
await app.listen({ host, port });
|
|
127
156
|
console.log(`Airlock command center running at http://${host}:${port}`);
|
|
128
157
|
console.log(`Editing ${configPath}`);
|
|
@@ -143,12 +172,194 @@ function isLoopbackBindHost(host) {
|
|
|
143
172
|
return false;
|
|
144
173
|
return Number(normalized.split('.')[0]) === 127;
|
|
145
174
|
}
|
|
175
|
+
function extractHostName(hostHeader) {
|
|
176
|
+
const trimmed = hostHeader.trim().toLowerCase();
|
|
177
|
+
if (trimmed.startsWith('[')) {
|
|
178
|
+
const end = trimmed.indexOf(']');
|
|
179
|
+
return end === -1 ? trimmed : trimmed.slice(0, end + 1);
|
|
180
|
+
}
|
|
181
|
+
const colon = trimmed.indexOf(':');
|
|
182
|
+
return colon === -1 ? trimmed : trimmed.slice(0, colon);
|
|
183
|
+
}
|
|
184
|
+
function isSensitiveWebPath(url) {
|
|
185
|
+
const path = url.split('?')[0] ?? url;
|
|
186
|
+
return (path.startsWith('/api/') ||
|
|
187
|
+
path === '/approve' ||
|
|
188
|
+
path === '/deny' ||
|
|
189
|
+
path === '/events' ||
|
|
190
|
+
path.startsWith('/approval-preview/'));
|
|
191
|
+
}
|
|
192
|
+
function toToolEntry(tool) {
|
|
193
|
+
if ('provider' in tool &&
|
|
194
|
+
typeof tool.provider === 'string' &&
|
|
195
|
+
'shortName' in tool &&
|
|
196
|
+
typeof tool.shortName === 'string' &&
|
|
197
|
+
Array.isArray(tool.tags) &&
|
|
198
|
+
Array.isArray(tool.suspiciousPatterns) &&
|
|
199
|
+
typeof tool.recommended === 'string') {
|
|
200
|
+
return {
|
|
201
|
+
...tool,
|
|
202
|
+
description: tool.description ?? '',
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
const provider = tool.name.split('/')[0] ?? '';
|
|
206
|
+
const suspiciousPatterns = tool.description ? checkSuspiciousPatterns(tool.description) : [];
|
|
207
|
+
return {
|
|
208
|
+
name: tool.name,
|
|
209
|
+
provider,
|
|
210
|
+
shortName: tool.name.split('/').slice(1).join('/') || tool.name,
|
|
211
|
+
description: tool.description ?? '',
|
|
212
|
+
annotations: tool.annotations,
|
|
213
|
+
tags: annotationTags(tool.annotations, suspiciousPatterns),
|
|
214
|
+
suspiciousPatterns,
|
|
215
|
+
recommended: recommendedDecision(tool.annotations, suspiciousPatterns),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
146
218
|
export function createConfigureWebApp(configPath, options = {}) {
|
|
147
219
|
const app = Fastify({ logger: false });
|
|
220
|
+
const enforceLoopbackHost = !options.bindHost || isLoopbackBindHost(options.bindHost);
|
|
221
|
+
// Guard the unauthenticated local UI against DNS rebinding (Host header validation on loopback
|
|
222
|
+
// listeners) and cross-site browser CSRF (Sec-Fetch-Site / Origin checks on API & approval routes).
|
|
223
|
+
app.addHook('onRequest', async (request, reply) => {
|
|
224
|
+
const hostHeader = typeof request.headers.host === 'string' ? request.headers.host : undefined;
|
|
225
|
+
if (enforceLoopbackHost && hostHeader && !isLoopbackBindHost(extractHostName(hostHeader))) {
|
|
226
|
+
return reply.code(403).send({ error: 'Forbidden: invalid Host header' });
|
|
227
|
+
}
|
|
228
|
+
if (!isSensitiveWebPath(request.url))
|
|
229
|
+
return;
|
|
230
|
+
const fetchSite = request.headers['sec-fetch-site'];
|
|
231
|
+
if (typeof fetchSite === 'string' && fetchSite.toLowerCase() === 'cross-site') {
|
|
232
|
+
return reply.code(403).send({ error: 'Forbidden: cross-site request blocked' });
|
|
233
|
+
}
|
|
234
|
+
const originHeader = request.headers.origin;
|
|
235
|
+
if (typeof originHeader === 'string' && originHeader.trim() !== '') {
|
|
236
|
+
if (originHeader === 'null' || !hostHeader) {
|
|
237
|
+
return reply.code(403).send({ error: 'Forbidden: cross-origin request blocked' });
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
const originUrl = new URL(originHeader);
|
|
241
|
+
if (originUrl.host.toLowerCase() !== hostHeader.trim().toLowerCase()) {
|
|
242
|
+
return reply.code(403).send({ error: 'Forbidden: cross-origin request blocked' });
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
return reply.code(403).send({ error: 'Forbidden: invalid Origin header' });
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
const webRoot = findWebRoot();
|
|
251
|
+
const assistant = options.assistant;
|
|
252
|
+
let toolCache = null;
|
|
253
|
+
const loadTools = async () => {
|
|
254
|
+
if (options.remoteGateway) {
|
|
255
|
+
const remote = await remoteGatewayJson(options.remoteGateway, '/admin/tools');
|
|
256
|
+
const tools = (remote.tools ?? [])
|
|
257
|
+
.map(toToolEntry)
|
|
258
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
259
|
+
toolCache = { tools, fetchedAt: Date.now() };
|
|
260
|
+
return { tools, ...(remote.errors ? { errors: remote.errors } : {}) };
|
|
261
|
+
}
|
|
262
|
+
const result = await discoverTools(configPath);
|
|
263
|
+
toolCache = { tools: result.tools ?? [], fetchedAt: Date.now() };
|
|
264
|
+
return result;
|
|
265
|
+
};
|
|
148
266
|
app.get('/', async (_request, reply) => {
|
|
149
|
-
|
|
267
|
+
const index = webRoot ? join(webRoot, 'index.html') : undefined;
|
|
268
|
+
if (!index || !existsSync(index)) {
|
|
269
|
+
reply.type('text/html; charset=utf-8').send(CLASSIC_HTML);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
reply
|
|
273
|
+
.type('text/html; charset=utf-8')
|
|
274
|
+
.header('cache-control', 'no-cache')
|
|
275
|
+
.send(readFileSync(index));
|
|
276
|
+
});
|
|
277
|
+
app.get('/classic', async (_request, reply) => {
|
|
278
|
+
reply.type('text/html; charset=utf-8').send(CLASSIC_HTML);
|
|
279
|
+
});
|
|
280
|
+
app.get('/assets/*', async (request, reply) => {
|
|
281
|
+
const file = webRoot
|
|
282
|
+
? resolveWebAsset(webRoot, request.params['*'])
|
|
283
|
+
: undefined;
|
|
284
|
+
if (!file) {
|
|
285
|
+
reply.code(404);
|
|
286
|
+
return { error: 'Not found' };
|
|
287
|
+
}
|
|
288
|
+
reply
|
|
289
|
+
.type(contentTypeFor(file))
|
|
290
|
+
.header('cache-control', 'public, max-age=31536000, immutable')
|
|
291
|
+
.send(readFileSync(file));
|
|
292
|
+
});
|
|
293
|
+
app.get('/api/state', (_request, reply) => {
|
|
294
|
+
reply.header('cache-control', 'no-store');
|
|
295
|
+
return readState(configPath);
|
|
296
|
+
});
|
|
297
|
+
app.get('/api/meta', () => ({
|
|
298
|
+
version: VERSION,
|
|
299
|
+
publicGatewayUrl: options.publicGatewayUrl ?? null,
|
|
300
|
+
remoteGateway: Boolean(options.remoteGateway),
|
|
301
|
+
// Whether /approve, /deny and /events exist here. `airlock run` and `configure-web` read
|
|
302
|
+
// pending requests from the audit DB but cannot decide them.
|
|
303
|
+
approvals: Boolean(options.approvals || options.remoteGateway),
|
|
304
|
+
assistant: assistant ? { enabled: true, model: assistant.model } : { enabled: false },
|
|
305
|
+
}));
|
|
306
|
+
app.post('/api/changes/preview', async (request, reply) => {
|
|
307
|
+
try {
|
|
308
|
+
return previewChanges(configPath, parseChangeSet(request.body));
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
reply.code(400);
|
|
312
|
+
return { error: err instanceof Error ? err.message : String(err) };
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
app.post('/api/changes/apply', async (request, reply) => {
|
|
316
|
+
try {
|
|
317
|
+
const body = (request.body ?? {});
|
|
318
|
+
const result = applyChanges(configPath, parseChangeSet({ ops: body.ops }), typeof body.version === 'string' ? body.version : undefined);
|
|
319
|
+
reply.header('cache-control', 'no-store');
|
|
320
|
+
return { ...result, state: readState(configPath) };
|
|
321
|
+
}
|
|
322
|
+
catch (err) {
|
|
323
|
+
if (err instanceof ChangeConflictError)
|
|
324
|
+
reply.code(409);
|
|
325
|
+
else
|
|
326
|
+
reply.code(400);
|
|
327
|
+
return {
|
|
328
|
+
error: err instanceof Error ? err.message : String(err),
|
|
329
|
+
...(err instanceof ChangeValidationError ? { diagnostics: err.diagnostics } : {}),
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
app.post('/api/assistant/chat', async (request, reply) => {
|
|
334
|
+
if (!assistant) {
|
|
335
|
+
reply.code(404);
|
|
336
|
+
return {
|
|
337
|
+
error: 'The assistant is not configured. Set AIRLOCK_ASSISTANT_BASE_URL and AIRLOCK_ASSISTANT_MODEL.',
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
try {
|
|
341
|
+
const body = (request.body ?? {});
|
|
342
|
+
return await runAssistantTurn(assistant, {
|
|
343
|
+
configView: () => assistantConfigView(configPath),
|
|
344
|
+
listTools: async () => {
|
|
345
|
+
const fresh = toolCache && Date.now() - toolCache.fetchedAt < 120_000;
|
|
346
|
+
const tools = fresh ? toolCache.tools : (await loadTools()).tools;
|
|
347
|
+
return tools.map((tool) => ({
|
|
348
|
+
name: tool.name,
|
|
349
|
+
provider: tool.provider,
|
|
350
|
+
description: tool.description,
|
|
351
|
+
tags: tool.tags,
|
|
352
|
+
recommended: tool.recommended,
|
|
353
|
+
}));
|
|
354
|
+
},
|
|
355
|
+
preview: (ops) => previewChanges(configPath, ops),
|
|
356
|
+
}, body.messages);
|
|
357
|
+
}
|
|
358
|
+
catch (err) {
|
|
359
|
+
reply.code(502);
|
|
360
|
+
return { error: err instanceof Error ? err.message : String(err) };
|
|
361
|
+
}
|
|
150
362
|
});
|
|
151
|
-
app.get('/api/state', () => readState(configPath));
|
|
152
363
|
app.get('/api/status', async (_request, reply) => {
|
|
153
364
|
try {
|
|
154
365
|
if (options.remoteGateway) {
|
|
@@ -192,10 +403,7 @@ export function createConfigureWebApp(configPath, options = {}) {
|
|
|
192
403
|
});
|
|
193
404
|
app.get('/api/tools', async (_request, reply) => {
|
|
194
405
|
try {
|
|
195
|
-
|
|
196
|
-
return await remoteGatewayJson(options.remoteGateway, '/admin/tools');
|
|
197
|
-
}
|
|
198
|
-
return await discoverTools(configPath);
|
|
406
|
+
return await loadTools();
|
|
199
407
|
}
|
|
200
408
|
catch (err) {
|
|
201
409
|
reply.code(500);
|
|
@@ -205,8 +413,40 @@ export function createConfigureWebApp(configPath, options = {}) {
|
|
|
205
413
|
if (options.remoteGateway) {
|
|
206
414
|
registerRemoteGatewayRoutes(app, configPath, options.remoteGateway);
|
|
207
415
|
}
|
|
416
|
+
else if (options.approvals) {
|
|
417
|
+
options.approvals.registerRoutes(app, configPath);
|
|
418
|
+
}
|
|
208
419
|
else {
|
|
209
|
-
|
|
420
|
+
app.get('/api/grants', (request, reply) => {
|
|
421
|
+
try {
|
|
422
|
+
const { agent } = request.query;
|
|
423
|
+
const agentFilter = typeof agent === 'string' && agent.trim() ? agent.trim() : undefined;
|
|
424
|
+
return readAuditGrants(configPath, agentFilter);
|
|
425
|
+
}
|
|
426
|
+
catch (err) {
|
|
427
|
+
reply.code(500);
|
|
428
|
+
return {
|
|
429
|
+
grants: [],
|
|
430
|
+
canRevoke: false,
|
|
431
|
+
error: err instanceof Error ? err.message : String(err),
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
app.delete('/api/grants/:id', (request, reply) => {
|
|
436
|
+
try {
|
|
437
|
+
const { id } = request.params;
|
|
438
|
+
const revoked = revokeAuditGrant(configPath, id);
|
|
439
|
+
if (!revoked) {
|
|
440
|
+
reply.code(404);
|
|
441
|
+
return { error: 'No active grant found' };
|
|
442
|
+
}
|
|
443
|
+
return { ok: true };
|
|
444
|
+
}
|
|
445
|
+
catch (err) {
|
|
446
|
+
reply.code(500);
|
|
447
|
+
return { error: err instanceof Error ? err.message : String(err) };
|
|
448
|
+
}
|
|
449
|
+
});
|
|
210
450
|
}
|
|
211
451
|
app.post('/api/rules', async (request, reply) => {
|
|
212
452
|
try {
|
|
@@ -260,6 +500,69 @@ export function createConfigureWebApp(configPath, options = {}) {
|
|
|
260
500
|
});
|
|
261
501
|
return app;
|
|
262
502
|
}
|
|
503
|
+
// Assets ship next to the compiled server (dist/web). Running from source with tsx, fall back to the
|
|
504
|
+
// repo's dist/web so `npm run build:web` once is enough to try the UI.
|
|
505
|
+
function findWebRoot() {
|
|
506
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
507
|
+
for (const candidate of [join(here, '../web'), join(here, '../../dist/web')]) {
|
|
508
|
+
if (existsSync(join(candidate, 'index.html')))
|
|
509
|
+
return candidate;
|
|
510
|
+
}
|
|
511
|
+
return undefined;
|
|
512
|
+
}
|
|
513
|
+
function resolveWebAsset(webRoot, relative) {
|
|
514
|
+
const assets = join(webRoot, 'assets');
|
|
515
|
+
const file = normalize(join(assets, relative));
|
|
516
|
+
if (!file.startsWith(assets + sep))
|
|
517
|
+
return undefined;
|
|
518
|
+
try {
|
|
519
|
+
return statSync(file).isFile() ? file : undefined;
|
|
520
|
+
}
|
|
521
|
+
catch {
|
|
522
|
+
return undefined;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
const CONTENT_TYPES = {
|
|
526
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
527
|
+
'.css': 'text/css; charset=utf-8',
|
|
528
|
+
'.svg': 'image/svg+xml',
|
|
529
|
+
'.woff2': 'font/woff2',
|
|
530
|
+
'.woff': 'font/woff',
|
|
531
|
+
'.png': 'image/png',
|
|
532
|
+
'.json': 'application/json',
|
|
533
|
+
};
|
|
534
|
+
function contentTypeFor(file) {
|
|
535
|
+
return CONTENT_TYPES[extname(file)] ?? 'application/octet-stream';
|
|
536
|
+
}
|
|
537
|
+
// What the assistant may read: permission rules only. Keys, provider commands, URLs and env are
|
|
538
|
+
// left out because the model talks to a third-party endpoint.
|
|
539
|
+
export function assistantConfigView(configPath) {
|
|
540
|
+
const state = readState(configPath);
|
|
541
|
+
const raw = readConfigObject(configPath);
|
|
542
|
+
return {
|
|
543
|
+
default_profile: typeof raw.default_profile === 'string' ? raw.default_profile : undefined,
|
|
544
|
+
providers: Object.fromEntries(Object.entries(state.providers).map(([id, provider]) => [
|
|
545
|
+
id,
|
|
546
|
+
{ type: provider.type, enabled: provider.enabled },
|
|
547
|
+
])),
|
|
548
|
+
profiles: state.profiles,
|
|
549
|
+
agents: Object.fromEntries(Object.entries(state.agents).map(([id, agent]) => [
|
|
550
|
+
id,
|
|
551
|
+
{
|
|
552
|
+
extends: agent.extends,
|
|
553
|
+
allow: agent.allow,
|
|
554
|
+
ask: agent.ask,
|
|
555
|
+
deny: agent.deny,
|
|
556
|
+
inherit_default: agent.inheritDefault,
|
|
557
|
+
approval_mode: agent.approvalMode,
|
|
558
|
+
exec: agent.exec,
|
|
559
|
+
http: { domain_allowlist: agent.http.domainAllowlist },
|
|
560
|
+
has_key: agent.hasToken,
|
|
561
|
+
},
|
|
562
|
+
])),
|
|
563
|
+
diagnostics: state.diagnostics,
|
|
564
|
+
};
|
|
565
|
+
}
|
|
263
566
|
export function readState(configPath) {
|
|
264
567
|
const parsed = readConfigObject(configPath);
|
|
265
568
|
const validation = parseGatewayConfig(parsed);
|
|
@@ -269,6 +572,7 @@ export function readState(configPath) {
|
|
|
269
572
|
providers: toEditableProviders(asRecord(parsed.providers)),
|
|
270
573
|
agents: toEditableAgents(asRecord(parsed.agents)),
|
|
271
574
|
profiles: toEditableProfiles(asRecord(parsed.profiles)),
|
|
575
|
+
defaultProfile: typeof parsed.default_profile === 'string' ? parsed.default_profile : undefined,
|
|
272
576
|
diagnostics: config ? validateConfig(config) : validation.diagnostics,
|
|
273
577
|
};
|
|
274
578
|
}
|
|
@@ -305,7 +609,7 @@ export async function readCommandCenterStatus(configPath) {
|
|
|
305
609
|
}
|
|
306
610
|
enabledProviders[id] = parsedProvider.data;
|
|
307
611
|
}
|
|
308
|
-
const parsed = GatewayConfig.parse({ ...raw, providers: enabledProviders });
|
|
612
|
+
const parsed = withEnvVarResolution(false, () => GatewayConfig.parse({ ...raw, providers: enabledProviders }));
|
|
309
613
|
const mcpConfigs = getMcpConfigs(parsed.providers);
|
|
310
614
|
const pool = new ClientPool(mcpConfigs, {
|
|
311
615
|
stdioStderr: 'ignore',
|
|
@@ -391,28 +695,106 @@ export function readAuditLogs(configPath, query = {}) {
|
|
|
391
695
|
db.close();
|
|
392
696
|
}
|
|
393
697
|
}
|
|
698
|
+
export function readAuditGrants(configPath, agent) {
|
|
699
|
+
const parsed = readConfigObject(configPath);
|
|
700
|
+
const auditConfig = AuditConfig.parse(parsed.audit ?? {});
|
|
701
|
+
const dbPath = auditConfig.db_path;
|
|
702
|
+
if (dbPath === ':memory:' || !existsSync(dbPath)) {
|
|
703
|
+
return { grants: [], canRevoke: true };
|
|
704
|
+
}
|
|
705
|
+
const db = new AuditDb(dbPath);
|
|
706
|
+
try {
|
|
707
|
+
const rows = db.getActiveGrants().filter((row) => !agent || row.agent_id === agent);
|
|
708
|
+
const grants = [];
|
|
709
|
+
for (const row of rows) {
|
|
710
|
+
try {
|
|
711
|
+
const scope = JSON.parse(row.scope);
|
|
712
|
+
grants.push({
|
|
713
|
+
id: row.id,
|
|
714
|
+
agentId: row.agent_id,
|
|
715
|
+
scope,
|
|
716
|
+
source: row.source,
|
|
717
|
+
...(row.label ? { label: row.label } : {}),
|
|
718
|
+
...(row.session_id ? { sessionId: row.session_id } : {}),
|
|
719
|
+
...(row.approval_id ? { approvalId: row.approval_id } : {}),
|
|
720
|
+
createdAt: row.created_at,
|
|
721
|
+
...(row.expires_at ? { expiresAt: row.expires_at } : {}),
|
|
722
|
+
...(row.uses_remaining !== null ? { usesRemaining: row.uses_remaining } : {}),
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
catch {
|
|
726
|
+
// skip unreadable grant row
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return { grants, canRevoke: true };
|
|
730
|
+
}
|
|
731
|
+
finally {
|
|
732
|
+
db.close();
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
export function revokeAuditGrant(configPath, id) {
|
|
736
|
+
const parsed = readConfigObject(configPath);
|
|
737
|
+
const auditConfig = AuditConfig.parse(parsed.audit ?? {});
|
|
738
|
+
const dbPath = auditConfig.db_path;
|
|
739
|
+
if (dbPath === ':memory:' || !existsSync(dbPath))
|
|
740
|
+
return false;
|
|
741
|
+
const db = new AuditDb(dbPath);
|
|
742
|
+
try {
|
|
743
|
+
const existing = db.getGrantById(id);
|
|
744
|
+
if (!existing || existing.revoked_at)
|
|
745
|
+
return false;
|
|
746
|
+
db.revokeGrant(id);
|
|
747
|
+
return true;
|
|
748
|
+
}
|
|
749
|
+
finally {
|
|
750
|
+
db.close();
|
|
751
|
+
}
|
|
752
|
+
}
|
|
394
753
|
async function readRemoteCommandCenterStatus(configPath, remoteGateway) {
|
|
395
754
|
const raw = readConfigObject(configPath);
|
|
396
|
-
const config = GatewayConfig.parse(raw);
|
|
397
|
-
const health = await
|
|
755
|
+
const config = withEnvVarResolution(false, () => GatewayConfig.parse(raw));
|
|
756
|
+
const [health, served] = await Promise.all([
|
|
757
|
+
remoteGatewayJson(remoteGateway, '/health'),
|
|
758
|
+
// Tool counts are a nicety; a gateway that can't list them still reports health.
|
|
759
|
+
remoteGatewayJson(remoteGateway, '/admin/tools').catch(() => ({
|
|
760
|
+
tools: [],
|
|
761
|
+
})),
|
|
762
|
+
]);
|
|
398
763
|
const mcpHealth = health.mcpHealth ?? {};
|
|
764
|
+
const oauthHealth = health.oauthHealth ?? {};
|
|
765
|
+
const credentialHealth = health.credentialHealth ?? {};
|
|
766
|
+
const toolNamesByProvider = new Map();
|
|
767
|
+
for (const tool of served.tools ?? []) {
|
|
768
|
+
const provider = tool.name.split('/')[0] ?? '';
|
|
769
|
+
toolNamesByProvider.set(provider, [...(toolNamesByProvider.get(provider) ?? []), tool.name]);
|
|
770
|
+
}
|
|
399
771
|
const providers = Object.entries(config.providers).map(([id, provider]) => {
|
|
400
|
-
const providerConfig = ProviderConfig.parse(provider);
|
|
772
|
+
const providerConfig = withEnvVarResolution(false, () => ProviderConfig.parse(provider));
|
|
401
773
|
const type = providerConfig === 'builtin' ? 'builtin' : providerConfig.type;
|
|
402
774
|
const enabled = providerConfig === 'builtin' ? true : providerConfig.enabled;
|
|
403
775
|
const runtime = mcpHealth[id];
|
|
776
|
+
const status = !enabled
|
|
777
|
+
? 'disabled'
|
|
778
|
+
: (runtime ?? (type === 'builtin' ? 'ok' : 'down'));
|
|
779
|
+
const detailError = oauthHealth[id]?.reason ??
|
|
780
|
+
credentialHealth[id]?.reason ??
|
|
781
|
+
(status === 'down'
|
|
782
|
+
? 'Provider is down on the gateway'
|
|
783
|
+
: status === 'degraded'
|
|
784
|
+
? 'Provider is degraded or awaiting OAuth sign-in'
|
|
785
|
+
: undefined);
|
|
404
786
|
return {
|
|
405
787
|
id,
|
|
406
788
|
type,
|
|
407
789
|
enabled,
|
|
408
|
-
status
|
|
409
|
-
toolCount: 0,
|
|
410
|
-
toolFingerprint:
|
|
411
|
-
...(
|
|
790
|
+
status,
|
|
791
|
+
toolCount: toolNamesByProvider.get(id)?.length ?? 0,
|
|
792
|
+
toolFingerprint: toolFingerprint(toolNamesByProvider.get(id) ?? []),
|
|
793
|
+
...(detailError ? { error: detailError } : {}),
|
|
412
794
|
};
|
|
413
795
|
});
|
|
414
796
|
const ok = providers.filter((provider) => provider.status === 'ok').length;
|
|
415
|
-
const down = providers.filter((provider) => provider.status === 'down').length;
|
|
797
|
+
const down = providers.filter((provider) => provider.status === 'down' || provider.status === 'degraded').length;
|
|
416
798
|
const disabled = providers.filter((provider) => provider.status === 'disabled').length;
|
|
417
799
|
return {
|
|
418
800
|
generatedAt: new Date().toISOString(),
|
|
@@ -422,7 +804,7 @@ async function readRemoteCommandCenterStatus(configPath, remoteGateway) {
|
|
|
422
804
|
ok,
|
|
423
805
|
down,
|
|
424
806
|
disabled,
|
|
425
|
-
tools: 0,
|
|
807
|
+
tools: providers.reduce((sum, provider) => sum + provider.toolCount, 0),
|
|
426
808
|
pendingApprovals: health.pendingApprovals ?? 0,
|
|
427
809
|
},
|
|
428
810
|
};
|
|
@@ -452,6 +834,36 @@ async function readRemoteAuditLogs(remoteGateway, query = {}) {
|
|
|
452
834
|
}),
|
|
453
835
|
status: 'pending',
|
|
454
836
|
created_at: entry.created_at ?? entry.createdAt ?? new Date().toISOString(),
|
|
837
|
+
...(entry.kind ||
|
|
838
|
+
entry.mode ||
|
|
839
|
+
entry.tier ||
|
|
840
|
+
entry.provider ||
|
|
841
|
+
entry.escalated ||
|
|
842
|
+
entry.plan ||
|
|
843
|
+
entry.grantOptions ||
|
|
844
|
+
entry.expiresAt ||
|
|
845
|
+
entry.batchCode
|
|
846
|
+
? {
|
|
847
|
+
meta: JSON.stringify({
|
|
848
|
+
...(entry.kind ? { kind: entry.kind } : {}),
|
|
849
|
+
...(entry.mode ? { mode: entry.mode } : {}),
|
|
850
|
+
...(entry.tier || entry.provider || entry.escalated !== undefined
|
|
851
|
+
? {
|
|
852
|
+
subject: {
|
|
853
|
+
...(entry.tier ? { tier: entry.tier } : {}),
|
|
854
|
+
...(entry.provider ? { provider: entry.provider } : {}),
|
|
855
|
+
...(entry.escalated !== undefined ? { escalated: entry.escalated } : {}),
|
|
856
|
+
},
|
|
857
|
+
}
|
|
858
|
+
: {}),
|
|
859
|
+
...(entry.plan ? { plan: entry.plan } : {}),
|
|
860
|
+
...(entry.grantOptions ? { grantOptions: entry.grantOptions } : {}),
|
|
861
|
+
...(entry.expiresAt ? { expiresAt: entry.expiresAt } : {}),
|
|
862
|
+
...(entry.batchCode ? { batchCode: entry.batchCode } : {}),
|
|
863
|
+
...(entry.batchId ? { batchId: entry.batchId } : {}),
|
|
864
|
+
}),
|
|
865
|
+
}
|
|
866
|
+
: {}),
|
|
455
867
|
})),
|
|
456
868
|
};
|
|
457
869
|
}
|
|
@@ -467,9 +879,9 @@ function registerRemoteGatewayRoutes(app, configPath, remoteGateway) {
|
|
|
467
879
|
return reply.code(502).send({ error: 'Approval preview unavailable.' });
|
|
468
880
|
}
|
|
469
881
|
});
|
|
470
|
-
app.get('/events', (
|
|
882
|
+
app.get('/events', (_request, reply) => {
|
|
471
883
|
const controller = new AbortController();
|
|
472
|
-
|
|
884
|
+
reply.raw.once('close', () => controller.abort());
|
|
473
885
|
void (async () => {
|
|
474
886
|
const response = await remoteGatewayFetch(remoteGateway, '/events', {
|
|
475
887
|
signal: controller.signal,
|
|
@@ -481,7 +893,8 @@ function registerRemoteGatewayRoutes(app, configPath, remoteGateway) {
|
|
|
481
893
|
reply.hijack();
|
|
482
894
|
reply.raw.writeHead(200, {
|
|
483
895
|
'Content-Type': 'text/event-stream',
|
|
484
|
-
'Cache-Control': 'no-cache',
|
|
896
|
+
'Cache-Control': 'no-cache, no-transform',
|
|
897
|
+
'X-Accel-Buffering': 'no',
|
|
485
898
|
Connection: 'keep-alive',
|
|
486
899
|
});
|
|
487
900
|
const reader = response.body.getReader();
|
|
@@ -510,65 +923,129 @@ function registerRemoteGatewayRoutes(app, configPath, remoteGateway) {
|
|
|
510
923
|
const query = request.query;
|
|
511
924
|
const code = typeof query.code === 'string' ? query.code : '';
|
|
512
925
|
if (!code)
|
|
513
|
-
return reply.send({
|
|
926
|
+
return reply.code(400).send({ error: 'code is required' });
|
|
927
|
+
// `remember=temporary` and `grant_*` become a grant on the gateway, so they travel with the
|
|
928
|
+
// approval. `remember=always` edits the config this dashboard owns, which the gateway cannot:
|
|
929
|
+
// it is checked first, kept off the forwarded request, and written only once the gateway has
|
|
930
|
+
// accepted the approval, so a refused approval never leaves a permanent rule behind.
|
|
514
931
|
const remember = typeof query.remember === 'string' ? query.remember : undefined;
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
932
|
+
const persistRemember = remember !== undefined && remember !== 'temporary';
|
|
933
|
+
let remembered;
|
|
934
|
+
if (persistRemember) {
|
|
935
|
+
const checked = await checkRememberAlways(remoteGateway, code, remember);
|
|
936
|
+
if ('error' in checked)
|
|
937
|
+
return reply.code(checked.status).send({ error: checked.error });
|
|
938
|
+
remembered = checked.request;
|
|
939
|
+
}
|
|
940
|
+
const params = new URLSearchParams();
|
|
941
|
+
for (const [key, value] of Object.entries(query)) {
|
|
942
|
+
if (typeof value !== 'string')
|
|
943
|
+
continue;
|
|
944
|
+
if (persistRemember && key === 'remember')
|
|
945
|
+
continue;
|
|
946
|
+
params.set(key, value);
|
|
947
|
+
}
|
|
948
|
+
const forwarded = await forwardRemoteDecision(remoteGateway, 'approve', params);
|
|
949
|
+
if (forwarded.error)
|
|
950
|
+
return reply.code(forwarded.status).send({ error: forwarded.error });
|
|
951
|
+
if (remembered) {
|
|
952
|
+
try {
|
|
953
|
+
rememberAllow({
|
|
954
|
+
configPath,
|
|
955
|
+
agentId: remembered.agentId ?? remembered.agent_id ?? '',
|
|
956
|
+
tool: remembered.tool,
|
|
957
|
+
mode: 'always',
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
catch (err) {
|
|
961
|
+
return reply
|
|
962
|
+
.code(500)
|
|
963
|
+
.send({ error: err instanceof Error ? err.message : 'Failed to update config' });
|
|
964
|
+
}
|
|
519
965
|
}
|
|
520
|
-
await forwardRemoteApproval(remoteGateway, 'approve', code);
|
|
521
966
|
return reply.send({ ok: true });
|
|
522
967
|
});
|
|
523
968
|
app.post('/deny', async (request, reply) => {
|
|
524
969
|
const query = request.query;
|
|
525
970
|
const code = typeof query.code === 'string' ? query.code : '';
|
|
526
|
-
if (code)
|
|
527
|
-
|
|
971
|
+
if (!code)
|
|
972
|
+
return reply.code(400).send({ error: 'code is required' });
|
|
973
|
+
const forwarded = await forwardRemoteDecision(remoteGateway, 'deny', new URLSearchParams({ code }));
|
|
974
|
+
if (forwarded.error)
|
|
975
|
+
return reply.code(forwarded.status).send({ error: forwarded.error });
|
|
528
976
|
return reply.send({ ok: true });
|
|
529
977
|
});
|
|
978
|
+
app.get('/api/grants', async (request, reply) => {
|
|
979
|
+
try {
|
|
980
|
+
const { agent } = request.query;
|
|
981
|
+
const suffix = agent && agent.trim() ? `?agent=${encodeURIComponent(agent.trim())}` : '';
|
|
982
|
+
const result = await remoteGatewayJson(remoteGateway, `/hitl/grants${suffix}`);
|
|
983
|
+
return { grants: result.grants ?? [], canRevoke: true };
|
|
984
|
+
}
|
|
985
|
+
catch (err) {
|
|
986
|
+
reply.code(502);
|
|
987
|
+
return {
|
|
988
|
+
grants: [],
|
|
989
|
+
canRevoke: false,
|
|
990
|
+
error: err instanceof Error ? err.message : String(err),
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
app.delete('/api/grants/:id', async (request, reply) => {
|
|
995
|
+
const { id } = request.params;
|
|
996
|
+
try {
|
|
997
|
+
const response = await remoteGatewayFetch(remoteGateway, `/hitl/grants/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
|
998
|
+
if (!response.ok) {
|
|
999
|
+
return reply.code(response.status).send({ error: await remoteGatewayError(response) });
|
|
1000
|
+
}
|
|
1001
|
+
return reply.send({ ok: true });
|
|
1002
|
+
}
|
|
1003
|
+
catch (err) {
|
|
1004
|
+
return reply.code(502).send({ error: err instanceof Error ? err.message : String(err) });
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
530
1007
|
app.get('/version', () => ({ version: VERSION }));
|
|
531
1008
|
app.get('/version/latest', async (_request, reply) => handleLatestVersion(reply));
|
|
532
1009
|
}
|
|
533
|
-
|
|
534
|
-
|
|
1010
|
+
// Same rules as the gateway's own dashboard: only `always` is persisted here, and only for a
|
|
1011
|
+
// routine tool call that is still pending.
|
|
1012
|
+
async function checkRememberAlways(remoteGateway, code, remember) {
|
|
1013
|
+
if (remember !== 'always')
|
|
535
1014
|
return { status: 400, error: 'Invalid remember mode' };
|
|
1015
|
+
let pending;
|
|
1016
|
+
try {
|
|
1017
|
+
pending = await remoteGatewayJson(remoteGateway, '/hitl/pending');
|
|
1018
|
+
}
|
|
1019
|
+
catch (err) {
|
|
1020
|
+
return { status: 502, error: err instanceof Error ? err.message : String(err) };
|
|
536
1021
|
}
|
|
537
|
-
const pending = await remoteGatewayJson(remoteGateway, '/hitl/pending');
|
|
538
1022
|
const request = pending.find((entry) => entry.code === code);
|
|
539
1023
|
if (!request)
|
|
540
1024
|
return { status: 404, error: 'No pending request found for code' };
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
if (
|
|
545
|
-
return {
|
|
1025
|
+
if ((request.kind ?? 'call') !== 'call' || request.escalated) {
|
|
1026
|
+
return { status: 400, error: 'Only a routine tool call can be remembered' };
|
|
1027
|
+
}
|
|
1028
|
+
if (request.tool.startsWith('event:')) {
|
|
1029
|
+
return {
|
|
1030
|
+
status: 400,
|
|
1031
|
+
error: 'Event subscription approvals cannot be persisted as tool allow rules; add them under events.allow in airlock.yaml',
|
|
1032
|
+
};
|
|
546
1033
|
}
|
|
1034
|
+
return { request };
|
|
1035
|
+
}
|
|
1036
|
+
async function forwardRemoteDecision(remoteGateway, action, params) {
|
|
547
1037
|
try {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
agentId: request.agent_id ?? request.agentId ?? '',
|
|
551
|
-
tool: request.tool,
|
|
552
|
-
mode: remember,
|
|
553
|
-
...(durationMs ? { durationMs } : {}),
|
|
1038
|
+
const response = await remoteGatewayFetch(remoteGateway, `/${action}?${params.toString()}`, {
|
|
1039
|
+
method: 'POST',
|
|
554
1040
|
});
|
|
1041
|
+
if (!response.ok)
|
|
1042
|
+
return { status: response.status, error: await remoteGatewayError(response) };
|
|
555
1043
|
return { status: 200 };
|
|
556
1044
|
}
|
|
557
1045
|
catch (err) {
|
|
558
|
-
return {
|
|
559
|
-
status: 500,
|
|
560
|
-
error: err instanceof Error ? err.message : 'Failed to update config',
|
|
561
|
-
};
|
|
1046
|
+
return { status: 502, error: err instanceof Error ? err.message : String(err) };
|
|
562
1047
|
}
|
|
563
1048
|
}
|
|
564
|
-
async function forwardRemoteApproval(remoteGateway, action, code) {
|
|
565
|
-
const params = new URLSearchParams({ code });
|
|
566
|
-
const response = await remoteGatewayFetch(remoteGateway, `/${action}?${params.toString()}`, {
|
|
567
|
-
method: 'POST',
|
|
568
|
-
});
|
|
569
|
-
if (!response.ok)
|
|
570
|
-
throw new Error(await remoteGatewayError(response));
|
|
571
|
-
}
|
|
572
1049
|
async function remoteGatewayJson(remoteGateway, path, init = {}) {
|
|
573
1050
|
const response = await remoteGatewayFetch(remoteGateway, path, init);
|
|
574
1051
|
if (!response.ok)
|
|
@@ -616,17 +1093,29 @@ export function saveRules(configPath, body) {
|
|
|
616
1093
|
const sectionName = kind === 'agent' ? 'agents' : 'profiles';
|
|
617
1094
|
const section = asMutableRecord(doc[sectionName]);
|
|
618
1095
|
const existing = asMutableRecord(section[id]);
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
1096
|
+
const nextAllow = parseStringArray(body.allow, 'allow');
|
|
1097
|
+
const nextAsk = parseStringArray(body.ask, 'ask');
|
|
1098
|
+
const nextDeny = parseStringArray(body.deny, 'deny');
|
|
1099
|
+
existing.extends = parseStringArray(body.extends, 'extends');
|
|
1100
|
+
existing.allow = nextAllow;
|
|
1101
|
+
existing.ask = nextAsk;
|
|
1102
|
+
existing.deny = nextDeny;
|
|
1103
|
+
if (kind === 'agent' && Array.isArray(existing.remember_allow)) {
|
|
1104
|
+
const allowSet = new Set(nextAllow);
|
|
1105
|
+
const askSet = new Set(nextAsk);
|
|
1106
|
+
const denySet = new Set(nextDeny);
|
|
1107
|
+
const filtered = existing.remember_allow.filter((entry) => {
|
|
1108
|
+
if (!entry || typeof entry !== 'object')
|
|
1109
|
+
return false;
|
|
1110
|
+
const tool = entry.tool;
|
|
1111
|
+
if (typeof tool !== 'string')
|
|
1112
|
+
return false;
|
|
1113
|
+
return allowSet.has(tool) && !askSet.has(tool) && !denySet.has(tool);
|
|
1114
|
+
});
|
|
1115
|
+
if (filtered.length === 0)
|
|
1116
|
+
delete existing.remember_allow;
|
|
1117
|
+
else
|
|
1118
|
+
existing.remember_allow = filtered;
|
|
630
1119
|
}
|
|
631
1120
|
section[id] = existing;
|
|
632
1121
|
doc[sectionName] = section;
|
|
@@ -646,16 +1135,17 @@ export function createEntity(configPath, body) {
|
|
|
646
1135
|
throw new Error(`${kind} "${id}" already exists`);
|
|
647
1136
|
const baseId = parseOptionalId(body.baseId);
|
|
648
1137
|
const base = baseId && section[baseId] ? structuredClone(section[baseId]) : undefined;
|
|
649
|
-
const createdToken = kind === 'agent' ?
|
|
1138
|
+
const createdToken = kind === 'agent' ? createAgentKey() : undefined;
|
|
650
1139
|
if (kind === 'agent') {
|
|
651
1140
|
const agent = asMutableRecord(base);
|
|
652
1141
|
const profileIds = parseOptionalStringArray(body.profileIds, 'profileIds');
|
|
653
1142
|
delete agent.token;
|
|
1143
|
+
delete agent.token_sha256;
|
|
654
1144
|
agent.extends = profileIds ?? stringArray(agent.extends);
|
|
655
1145
|
agent.allow = stringArray(agent.allow);
|
|
656
1146
|
agent.ask = stringArray(agent.ask);
|
|
657
1147
|
agent.deny = stringArray(agent.deny);
|
|
658
|
-
agent.
|
|
1148
|
+
agent.token_sha256 = hashAgentKey(createdToken);
|
|
659
1149
|
section[id] = agent;
|
|
660
1150
|
}
|
|
661
1151
|
else if (base) {
|
|
@@ -692,7 +1182,15 @@ export function upsertProvider(configPath, body) {
|
|
|
692
1182
|
const existing = asMutableRecord(providers[id]);
|
|
693
1183
|
const enabled = body.enabled === undefined ? providerEnabled(existing) : parseBoolean(body.enabled);
|
|
694
1184
|
if (type === 'builtin') {
|
|
695
|
-
|
|
1185
|
+
// Keep a built-in's other fields (instructions, ...) across a toggle, and only use the short
|
|
1186
|
+
// `exec: builtin` form when there is nothing else to keep.
|
|
1187
|
+
const rest = existing.type === 'builtin'
|
|
1188
|
+
? removeUndefined({ ...existing, type: undefined, enabled: undefined })
|
|
1189
|
+
: {};
|
|
1190
|
+
providers[id] =
|
|
1191
|
+
enabled && Object.keys(rest).length === 0
|
|
1192
|
+
? 'builtin'
|
|
1193
|
+
: removeUndefined({ ...rest, type, enabled: enabled ? undefined : false });
|
|
696
1194
|
}
|
|
697
1195
|
else if (type === 'stdio') {
|
|
698
1196
|
const command = typeof body.command === 'string' && body.command.trim()
|
|
@@ -702,12 +1200,27 @@ export function upsertProvider(configPath, body) {
|
|
|
702
1200
|
: '';
|
|
703
1201
|
if (!command)
|
|
704
1202
|
throw new Error('stdio providers require command');
|
|
1203
|
+
const env = parseOptionalStringMap(body.env, 'env');
|
|
1204
|
+
const resolvedEnv = env !== undefined ? (Object.keys(env).length > 0 ? env : undefined) : stringMap(existing.env);
|
|
705
1205
|
providers[id] = removeUndefined({
|
|
706
1206
|
...existing,
|
|
707
1207
|
type,
|
|
708
1208
|
enabled: enabled ? undefined : false,
|
|
709
1209
|
command,
|
|
710
1210
|
args: parseOptionalStringArray(body.args, 'args') ?? stringArray(existing.args),
|
|
1211
|
+
env: resolvedEnv,
|
|
1212
|
+
url: undefined,
|
|
1213
|
+
headers: undefined,
|
|
1214
|
+
oauth: undefined,
|
|
1215
|
+
bearer_token_file: undefined,
|
|
1216
|
+
oauth_callback_mode: undefined,
|
|
1217
|
+
oauth_callback_url: undefined,
|
|
1218
|
+
oauth_callback_port: undefined,
|
|
1219
|
+
oauth_max_refresh_interval_ms: undefined,
|
|
1220
|
+
client_id: undefined,
|
|
1221
|
+
client_secret: undefined,
|
|
1222
|
+
client_credentials: undefined,
|
|
1223
|
+
request_timeout_ms: undefined,
|
|
711
1224
|
});
|
|
712
1225
|
}
|
|
713
1226
|
else {
|
|
@@ -718,12 +1231,44 @@ export function upsertProvider(configPath, body) {
|
|
|
718
1231
|
: '';
|
|
719
1232
|
if (!url)
|
|
720
1233
|
throw new Error(`${type} providers require url`);
|
|
1234
|
+
const headers = parseOptionalStringMap(body.headers, 'headers');
|
|
1235
|
+
const resolvedHeaders = headers !== undefined
|
|
1236
|
+
? Object.keys(headers).length > 0
|
|
1237
|
+
? headers
|
|
1238
|
+
: undefined
|
|
1239
|
+
: stringMap(existing.headers);
|
|
1240
|
+
const bearerTokenFile = type === 'http'
|
|
1241
|
+
? body.bearer_token_file !== undefined
|
|
1242
|
+
? typeof body.bearer_token_file === 'string' && body.bearer_token_file.trim()
|
|
1243
|
+
? body.bearer_token_file.trim()
|
|
1244
|
+
: undefined
|
|
1245
|
+
: typeof existing.bearer_token_file === 'string'
|
|
1246
|
+
? existing.bearer_token_file
|
|
1247
|
+
: undefined
|
|
1248
|
+
: undefined;
|
|
721
1249
|
providers[id] = removeUndefined({
|
|
722
1250
|
...existing,
|
|
723
1251
|
type,
|
|
724
1252
|
enabled: enabled ? undefined : false,
|
|
725
1253
|
url,
|
|
1254
|
+
headers: resolvedHeaders,
|
|
1255
|
+
command: undefined,
|
|
1256
|
+
args: undefined,
|
|
1257
|
+
env: undefined,
|
|
726
1258
|
oauth: type === 'http' ? (parseOptionalBoolean(body.oauth) ?? Boolean(existing.oauth)) : undefined,
|
|
1259
|
+
bearer_token_file: bearerTokenFile,
|
|
1260
|
+
...(type === 'sse'
|
|
1261
|
+
? {
|
|
1262
|
+
oauth_callback_mode: undefined,
|
|
1263
|
+
oauth_callback_url: undefined,
|
|
1264
|
+
oauth_callback_port: undefined,
|
|
1265
|
+
oauth_max_refresh_interval_ms: undefined,
|
|
1266
|
+
client_id: undefined,
|
|
1267
|
+
client_secret: undefined,
|
|
1268
|
+
client_credentials: undefined,
|
|
1269
|
+
request_timeout_ms: undefined,
|
|
1270
|
+
}
|
|
1271
|
+
: {}),
|
|
727
1272
|
});
|
|
728
1273
|
}
|
|
729
1274
|
doc.providers = providers;
|
|
@@ -762,54 +1307,32 @@ export function annotationTags(annotations, suspiciousPatterns = []) {
|
|
|
762
1307
|
tags.push('injection');
|
|
763
1308
|
return tags;
|
|
764
1309
|
}
|
|
765
|
-
export function resolveEditableRuleDecision(rules, toolName) {
|
|
766
|
-
return resolveEditableRuleMatch(rules, toolName).decision;
|
|
767
|
-
}
|
|
768
|
-
export function resolveEditableRuleMatch(rules, toolName) {
|
|
769
|
-
const deny = bestRuleMatch(rules.deny, toolName);
|
|
770
|
-
const ask = bestRuleMatch(rules.ask, toolName);
|
|
771
|
-
const allow = bestRuleMatch(rules.allow, toolName);
|
|
772
|
-
const denySpec = deny?.specificity ?? -1;
|
|
773
|
-
const askSpec = ask?.specificity ?? -1;
|
|
774
|
-
const allowSpec = allow?.specificity ?? -1;
|
|
775
|
-
const best = Math.max(denySpec, askSpec, allowSpec);
|
|
776
|
-
if (best < 0)
|
|
777
|
-
return { decision: 'unset', source: 'none' };
|
|
778
|
-
if (denySpec === best)
|
|
779
|
-
return editableRuleMatch('deny', deny, toolName);
|
|
780
|
-
if (askSpec === best)
|
|
781
|
-
return editableRuleMatch('ask', ask, toolName);
|
|
782
|
-
return editableRuleMatch('allow', allow, toolName);
|
|
783
|
-
}
|
|
784
|
-
function editableRuleMatch(decision, match, toolName) {
|
|
785
|
-
if (!match)
|
|
786
|
-
return { decision, source: 'none' };
|
|
787
|
-
return {
|
|
788
|
-
decision,
|
|
789
|
-
source: match.pattern === toolName ? 'exact' : 'pattern',
|
|
790
|
-
pattern: match.pattern,
|
|
791
|
-
};
|
|
792
|
-
}
|
|
793
|
-
function bestRuleMatch(patterns, toolName) {
|
|
794
|
-
let best;
|
|
795
|
-
for (const pattern of patterns) {
|
|
796
|
-
const specificity = bestSpecificity([pattern], toolName);
|
|
797
|
-
if (specificity >= 0 && (!best || specificity > best.specificity)) {
|
|
798
|
-
best = { pattern, specificity };
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
return best;
|
|
802
|
-
}
|
|
803
1310
|
export async function discoverTools(configPath) {
|
|
804
1311
|
const raw = readConfigObject(configPath);
|
|
805
|
-
const
|
|
1312
|
+
const rawProviders = asRecord(raw.providers);
|
|
1313
|
+
const validProviders = {};
|
|
1314
|
+
const errors = [];
|
|
1315
|
+
for (const [id, rawProvider] of Object.entries(rawProviders)) {
|
|
1316
|
+
if (rawProviderDisabled(rawProvider))
|
|
1317
|
+
continue;
|
|
1318
|
+
if (rawProvider === 'builtin' || asRecord(rawProvider).type === 'builtin') {
|
|
1319
|
+
validProviders[id] = rawProvider;
|
|
1320
|
+
continue;
|
|
1321
|
+
}
|
|
1322
|
+
const parsedProvider = parseMcpProviderStatus(rawProvider);
|
|
1323
|
+
if (!parsedProvider.success) {
|
|
1324
|
+
errors.push(`${id}: ${parsedProvider.error}`);
|
|
1325
|
+
continue;
|
|
1326
|
+
}
|
|
1327
|
+
validProviders[id] = parsedProvider.data;
|
|
1328
|
+
}
|
|
1329
|
+
const parsed = withEnvVarResolution(false, () => GatewayConfig.parse({ ...raw, providers: validProviders }));
|
|
806
1330
|
const mcpConfigs = getMcpConfigs(parsed.providers);
|
|
807
1331
|
const pool = new ClientPool(mcpConfigs, {
|
|
808
1332
|
stdioStderr: 'ignore',
|
|
809
1333
|
healthCheck: false,
|
|
810
1334
|
retryFailedConnections: false,
|
|
811
1335
|
});
|
|
812
|
-
const errors = [];
|
|
813
1336
|
try {
|
|
814
1337
|
await Promise.race([
|
|
815
1338
|
pool.initialize(),
|
|
@@ -826,20 +1349,7 @@ export async function discoverTools(configPath) {
|
|
|
826
1349
|
continue;
|
|
827
1350
|
}
|
|
828
1351
|
for (const tool of result.value) {
|
|
829
|
-
|
|
830
|
-
const suspiciousPatterns = tool.description
|
|
831
|
-
? checkSuspiciousPatterns(tool.description)
|
|
832
|
-
: [];
|
|
833
|
-
tools.push({
|
|
834
|
-
name: tool.name,
|
|
835
|
-
provider,
|
|
836
|
-
shortName: tool.name.split('/').slice(1).join('/') || tool.name,
|
|
837
|
-
description: tool.description ?? '',
|
|
838
|
-
annotations: tool.annotations,
|
|
839
|
-
tags: annotationTags(tool.annotations, suspiciousPatterns),
|
|
840
|
-
suspiciousPatterns,
|
|
841
|
-
recommended: recommendedDecision(tool.annotations, suspiciousPatterns),
|
|
842
|
-
});
|
|
1352
|
+
tools.push(toToolEntry(tool));
|
|
843
1353
|
}
|
|
844
1354
|
}
|
|
845
1355
|
tools.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -849,11 +1359,6 @@ export async function discoverTools(configPath) {
|
|
|
849
1359
|
await pool.stop().catch(() => { });
|
|
850
1360
|
}
|
|
851
1361
|
}
|
|
852
|
-
function withoutDisabledProviders(doc) {
|
|
853
|
-
const providers = asRecord(doc.providers);
|
|
854
|
-
const enabledProviders = Object.fromEntries(Object.entries(providers).filter(([, provider]) => !rawProviderDisabled(provider)));
|
|
855
|
-
return { ...doc, providers: enabledProviders };
|
|
856
|
-
}
|
|
857
1362
|
function rawProviderDisabled(provider) {
|
|
858
1363
|
return asRecord(provider).enabled === false;
|
|
859
1364
|
}
|
|
@@ -886,12 +1391,16 @@ function parseAuditLogQuery(query) {
|
|
|
886
1391
|
function parseMcpProviderStatus(provider) {
|
|
887
1392
|
try {
|
|
888
1393
|
const result = McpServerConfig.safeParse(provider);
|
|
889
|
-
if (result.success)
|
|
890
|
-
return {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
}
|
|
1394
|
+
if (!result.success) {
|
|
1395
|
+
return {
|
|
1396
|
+
success: false,
|
|
1397
|
+
error: result.error.issues.map((issue) => issue.message).join('; '),
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
// Validate bearer_token_file readability now so missing/invalid credential files surface
|
|
1401
|
+
// cleanly as provider errors rather than leaving status at "Not checked yet".
|
|
1402
|
+
resolveProviderBearerFile(result.data);
|
|
1403
|
+
return { success: true, data: result.data };
|
|
895
1404
|
}
|
|
896
1405
|
catch (err) {
|
|
897
1406
|
return {
|
|
@@ -920,11 +1429,11 @@ function writeValidatedConfig(configPath, doc) {
|
|
|
920
1429
|
}
|
|
921
1430
|
const backupPath = configPath.replace(/\.ya?ml$/i, '') + '.bak';
|
|
922
1431
|
copyFileSync(configPath, backupPath);
|
|
923
|
-
|
|
1432
|
+
atomicWriteTextFileSync(configPath, stringifyPreservingComments(readFileSync(configPath, 'utf8'), doc));
|
|
924
1433
|
}
|
|
925
1434
|
function parseGatewayConfig(doc) {
|
|
926
1435
|
try {
|
|
927
|
-
const result = GatewayConfig.safeParse(doc);
|
|
1436
|
+
const result = withEnvVarResolution(false, () => GatewayConfig.safeParse(doc));
|
|
928
1437
|
if (!result.success) {
|
|
929
1438
|
return {
|
|
930
1439
|
diagnostics: [
|
|
@@ -954,7 +1463,18 @@ function toEditableAgents(input) {
|
|
|
954
1463
|
allow: stringArray(agent.allow),
|
|
955
1464
|
ask: stringArray(agent.ask),
|
|
956
1465
|
deny: stringArray(agent.deny),
|
|
957
|
-
hasToken: typeof agent.token === 'string' && agent.token.trim().length > 0
|
|
1466
|
+
hasToken: (typeof agent.token === 'string' && agent.token.trim().length > 0) ||
|
|
1467
|
+
(typeof agent.token_sha256 === 'string' && agent.token_sha256.length > 0),
|
|
1468
|
+
inheritDefault: agent.inherit_default !== false,
|
|
1469
|
+
approvalMode: agent.approval_mode === 'sync' || agent.approval_mode === 'async'
|
|
1470
|
+
? agent.approval_mode
|
|
1471
|
+
: undefined,
|
|
1472
|
+
exec: {
|
|
1473
|
+
allow: stringArray(asRecord(agent.exec).allow),
|
|
1474
|
+
ask: stringArray(asRecord(agent.exec).ask),
|
|
1475
|
+
deny: stringArray(asRecord(agent.exec).deny),
|
|
1476
|
+
},
|
|
1477
|
+
http: { domainAllowlist: stringArray(asRecord(agent.http).domain_allowlist) },
|
|
958
1478
|
},
|
|
959
1479
|
];
|
|
960
1480
|
}));
|
|
@@ -968,13 +1488,18 @@ function toEditableProviders(input) {
|
|
|
968
1488
|
}
|
|
969
1489
|
const provider = asRecord(value);
|
|
970
1490
|
const type = parseProviderType(provider.type);
|
|
1491
|
+
const env = type === 'stdio' ? stringMap(provider.env) : undefined;
|
|
1492
|
+
const headers = type === 'http' || type === 'sse' ? stringMap(provider.headers) : undefined;
|
|
971
1493
|
providers[id] = {
|
|
972
1494
|
type,
|
|
973
1495
|
enabled: providerEnabled(provider),
|
|
974
1496
|
command: typeof provider.command === 'string' ? provider.command : undefined,
|
|
975
1497
|
args: stringArray(provider.args),
|
|
1498
|
+
...(env ? { env } : {}),
|
|
976
1499
|
url: typeof provider.url === 'string' ? provider.url : undefined,
|
|
1500
|
+
...(headers ? { headers } : {}),
|
|
977
1501
|
oauth: typeof provider.oauth === 'boolean' ? provider.oauth : undefined,
|
|
1502
|
+
bearerTokenFile: typeof provider.bearer_token_file === 'string' ? provider.bearer_token_file : undefined,
|
|
978
1503
|
};
|
|
979
1504
|
}
|
|
980
1505
|
return providers;
|
|
@@ -1018,9 +1543,6 @@ function parseOptionalId(value) {
|
|
|
1018
1543
|
return undefined;
|
|
1019
1544
|
return parseId(value);
|
|
1020
1545
|
}
|
|
1021
|
-
function createAgentToken() {
|
|
1022
|
-
return `airlock_agent_${randomBytes(32).toString('base64url')}`;
|
|
1023
|
-
}
|
|
1024
1546
|
function parseBoolean(value) {
|
|
1025
1547
|
if (typeof value === 'boolean')
|
|
1026
1548
|
return value;
|
|
@@ -1047,6 +1569,30 @@ function parseStringArray(value, name) {
|
|
|
1047
1569
|
function parseOptionalStringArray(value, name) {
|
|
1048
1570
|
return value === undefined ? undefined : parseStringArray(value, name);
|
|
1049
1571
|
}
|
|
1572
|
+
function parseOptionalStringMap(value, name) {
|
|
1573
|
+
if (value === undefined)
|
|
1574
|
+
return undefined;
|
|
1575
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
1576
|
+
throw new Error(`${name} must be an object of string key/value pairs`);
|
|
1577
|
+
}
|
|
1578
|
+
const result = {};
|
|
1579
|
+
for (const [k, v] of Object.entries(value)) {
|
|
1580
|
+
const key = k.trim();
|
|
1581
|
+
if (!key)
|
|
1582
|
+
continue;
|
|
1583
|
+
if (typeof v !== 'string') {
|
|
1584
|
+
throw new Error(`${name}.${key} must be a string`);
|
|
1585
|
+
}
|
|
1586
|
+
result[key] = v;
|
|
1587
|
+
}
|
|
1588
|
+
return result;
|
|
1589
|
+
}
|
|
1590
|
+
function stringMap(value) {
|
|
1591
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
1592
|
+
return undefined;
|
|
1593
|
+
const entries = Object.entries(value).filter((entry) => typeof entry[1] === 'string');
|
|
1594
|
+
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
1595
|
+
}
|
|
1050
1596
|
function stringArray(value) {
|
|
1051
1597
|
return Array.isArray(value)
|
|
1052
1598
|
? value.filter((item) => typeof item === 'string')
|
|
@@ -1069,7 +1615,7 @@ function providerEnabled(provider) {
|
|
|
1069
1615
|
function removeUndefined(value) {
|
|
1070
1616
|
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined));
|
|
1071
1617
|
}
|
|
1072
|
-
const
|
|
1618
|
+
export const CLASSIC_HTML = `<!doctype html>
|
|
1073
1619
|
<html lang="en">
|
|
1074
1620
|
<head>
|
|
1075
1621
|
<meta charset="utf-8">
|
|
@@ -1963,7 +2509,8 @@ const INDEX_HTML = `<!doctype html>
|
|
|
1963
2509
|
descriptionExpanded: {},
|
|
1964
2510
|
search: '',
|
|
1965
2511
|
provider: 'all',
|
|
1966
|
-
decision: 'all'
|
|
2512
|
+
decision: 'all',
|
|
2513
|
+
approvals: false
|
|
1967
2514
|
};
|
|
1968
2515
|
|
|
1969
2516
|
const el = (id) => document.getElementById(id);
|
|
@@ -2262,6 +2809,7 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2262
2809
|
}
|
|
2263
2810
|
|
|
2264
2811
|
function approvalButtons(code, options = {}) {
|
|
2812
|
+
if (!state.approvals) return '';
|
|
2265
2813
|
const approveLabel = options.approveLabel || 'Approve';
|
|
2266
2814
|
const remember = options.remember !== false;
|
|
2267
2815
|
return '<button class="approve" data-approval-action="approve" data-code="' + escapeHtml(code) + '">' + escapeHtml(approveLabel) + '</button>' +
|
|
@@ -2317,7 +2865,7 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2317
2865
|
'<div class="detail-label">Arguments</div><pre class="log-args">' + escapeHtml(prettyJson(pending.args)) + '</pre>';
|
|
2318
2866
|
el('approvalModalFooter').innerHTML = approvalButtons(pending.code, { remember: !question, approveLabel: question ? 'Confirm' : 'Approve' });
|
|
2319
2867
|
el('approvalModal').classList.add('open');
|
|
2320
|
-
if (!question) loadApprovalPreview(pending.id);
|
|
2868
|
+
if (!question && state.approvals) loadApprovalPreview(pending.id);
|
|
2321
2869
|
el('approvalModalFooter').querySelectorAll('[data-approval-action]').forEach((button) => {
|
|
2322
2870
|
button.addEventListener('click', () => {
|
|
2323
2871
|
actApproval(
|
|
@@ -2464,7 +3012,7 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2464
3012
|
}
|
|
2465
3013
|
|
|
2466
3014
|
function resultTagClass(result) {
|
|
2467
|
-
if (
|
|
3015
|
+
if (/denied|error|timeout|injection|canary/.test(String(result))) return 'tag-danger';
|
|
2468
3016
|
if (String(result).includes('hitl')) return 'tag-warn';
|
|
2469
3017
|
return 'tag-good';
|
|
2470
3018
|
}
|
|
@@ -3276,7 +3824,7 @@ const INDEX_HTML = `<!doctype html>
|
|
|
3276
3824
|
const target = event.target;
|
|
3277
3825
|
if (target && ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName)) return;
|
|
3278
3826
|
const key = event.key.toLowerCase();
|
|
3279
|
-
if (key !== 'a' && key !== 'd') return;
|
|
3827
|
+
if (!state.approvals || (key !== 'a' && key !== 'd')) return;
|
|
3280
3828
|
const id = state.currentApprovalId || firstPendingApprovalId();
|
|
3281
3829
|
const pending = findPendingApproval(id);
|
|
3282
3830
|
if (!pending?.code) return;
|
|
@@ -3284,7 +3832,12 @@ const INDEX_HTML = `<!doctype html>
|
|
|
3284
3832
|
});
|
|
3285
3833
|
|
|
3286
3834
|
initApprovalSettings();
|
|
3287
|
-
|
|
3835
|
+
// Without approval routes (airlock run, configure-web) there is no stream and nothing to decide.
|
|
3836
|
+
api('/api/meta').then((meta) => {
|
|
3837
|
+
state.approvals = Boolean(meta.approvals);
|
|
3838
|
+
if (state.approvals) connectApprovalEvents();
|
|
3839
|
+
if (state.config) render();
|
|
3840
|
+
}).catch(() => {});
|
|
3288
3841
|
checkVersion().catch(() => {});
|
|
3289
3842
|
loadState().then(() => Promise.all([refreshStatus(), refreshLogs(), refreshTools()])).catch((error) => {
|
|
3290
3843
|
document.body.innerHTML = '<div class="empty">' + escapeHtml(error.message) + '</div>';
|