airlock-bot 0.2.37 → 0.3.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 +47 -47
- package/dist/activity/stream.d.ts +29 -0
- package/dist/activity/stream.d.ts.map +1 -0
- package/dist/activity/stream.js +36 -0
- package/dist/activity/stream.js.map +1 -0
- package/dist/airlock/context.d.ts +12 -0
- package/dist/airlock/context.d.ts.map +1 -0
- package/dist/airlock/context.js +32 -0
- package/dist/airlock/context.js.map +1 -0
- package/dist/airlock/tools.d.ts +11 -0
- package/dist/airlock/tools.d.ts.map +1 -0
- package/dist/airlock/tools.js +25 -0
- package/dist/airlock/tools.js.map +1 -0
- package/dist/allowlist/engine.d.ts +12 -0
- package/dist/allowlist/engine.d.ts.map +1 -1
- package/dist/allowlist/engine.js +40 -15
- package/dist/allowlist/engine.js.map +1 -1
- package/dist/audit/api.d.ts +2 -0
- package/dist/audit/api.d.ts.map +1 -1
- package/dist/audit/api.js.map +1 -1
- package/dist/audit/db.d.ts +23 -0
- package/dist/audit/db.d.ts.map +1 -1
- package/dist/audit/db.js +92 -3
- package/dist/audit/db.js.map +1 -1
- package/dist/audit/logger.d.ts +8 -1
- package/dist/audit/logger.d.ts.map +1 -1
- package/dist/audit/logger.js +21 -0
- package/dist/audit/logger.js.map +1 -1
- package/dist/backend/airlock-adapter.d.ts +32 -0
- package/dist/backend/airlock-adapter.d.ts.map +1 -0
- package/dist/backend/airlock-adapter.js +318 -0
- package/dist/backend/airlock-adapter.js.map +1 -0
- package/dist/backend/cli/builder.d.ts.map +1 -1
- package/dist/backend/cli/builder.js +10 -3
- package/dist/backend/cli/builder.js.map +1 -1
- package/dist/backend/factory.d.ts +5 -1
- package/dist/backend/factory.d.ts.map +1 -1
- package/dist/backend/factory.js +5 -5
- package/dist/backend/factory.js.map +1 -1
- package/dist/backend/mcp-adapter.d.ts +1 -0
- package/dist/backend/mcp-adapter.d.ts.map +1 -1
- package/dist/backend/mcp-adapter.js +33 -4
- package/dist/backend/mcp-adapter.js.map +1 -1
- package/dist/backend/openapi/adapter.d.ts.map +1 -1
- package/dist/backend/openapi/adapter.js +66 -31
- package/dist/backend/openapi/adapter.js.map +1 -1
- package/dist/backend/types.d.ts +8 -0
- package/dist/backend/types.d.ts.map +1 -1
- package/dist/config/loader.d.ts +12 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +591 -23
- package/dist/config/loader.js.map +1 -1
- package/dist/config/profiles.d.ts +46 -3
- package/dist/config/profiles.d.ts.map +1 -1
- package/dist/config/profiles.js +377 -3
- package/dist/config/profiles.js.map +1 -1
- package/dist/config/schema.d.ts +6426 -803
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +499 -73
- package/dist/config/schema.js.map +1 -1
- package/dist/configure-cli/cli.d.ts.map +1 -1
- package/dist/configure-cli/cli.js +1 -2
- package/dist/configure-cli/cli.js.map +1 -1
- package/dist/configure-web/cli.d.ts +1 -0
- package/dist/configure-web/cli.d.ts.map +1 -1
- package/dist/configure-web/cli.js +261 -48
- package/dist/configure-web/cli.js.map +1 -1
- package/dist/discover/strategies/completion.d.ts.map +1 -1
- package/dist/discover/strategies/completion.js +3 -3
- package/dist/discover/strategies/completion.js.map +1 -1
- package/dist/gateway.d.ts +21 -1
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +345 -60
- package/dist/gateway.js.map +1 -1
- package/dist/hitl/api.d.ts +2 -0
- package/dist/hitl/api.d.ts.map +1 -1
- package/dist/hitl/api.js +8 -0
- package/dist/hitl/api.js.map +1 -1
- package/dist/hitl/approval-dashboard.d.ts +5 -9
- package/dist/hitl/approval-dashboard.d.ts.map +1 -1
- package/dist/hitl/approval-dashboard.js +8 -55
- package/dist/hitl/approval-dashboard.js.map +1 -1
- package/dist/hitl/approval-stream.d.ts +34 -0
- package/dist/hitl/approval-stream.d.ts.map +1 -0
- package/dist/hitl/approval-stream.js +111 -0
- package/dist/hitl/approval-stream.js.map +1 -0
- package/dist/hitl/batcher.d.ts +2 -0
- package/dist/hitl/batcher.d.ts.map +1 -1
- package/dist/hitl/batcher.js +16 -0
- package/dist/hitl/batcher.js.map +1 -1
- package/dist/hitl/engine.d.ts +16 -7
- package/dist/hitl/engine.d.ts.map +1 -1
- package/dist/hitl/engine.js +109 -35
- package/dist/hitl/engine.js.map +1 -1
- package/dist/hitl/formatter.d.ts.map +1 -1
- package/dist/hitl/formatter.js +2 -0
- package/dist/hitl/formatter.js.map +1 -1
- package/dist/hitl/provider-factory.d.ts +8 -2
- package/dist/hitl/provider-factory.d.ts.map +1 -1
- package/dist/hitl/provider-factory.js +23 -2
- package/dist/hitl/provider-factory.js.map +1 -1
- package/dist/hitl/providers/composite.d.ts +9 -0
- package/dist/hitl/providers/composite.d.ts.map +1 -1
- package/dist/hitl/providers/composite.js +14 -0
- package/dist/hitl/providers/composite.js.map +1 -1
- package/dist/hitl/providers/dashboard.d.ts +12 -2
- package/dist/hitl/providers/dashboard.d.ts.map +1 -1
- package/dist/hitl/providers/dashboard.js +11 -5
- package/dist/hitl/providers/dashboard.js.map +1 -1
- package/dist/hitl/providers/ios.d.ts +23 -0
- package/dist/hitl/providers/ios.d.ts.map +1 -0
- package/dist/hitl/providers/ios.js +183 -0
- package/dist/hitl/providers/ios.js.map +1 -0
- package/dist/hitl/providers/macos.d.ts.map +1 -1
- package/dist/hitl/providers/macos.js +8 -4
- package/dist/hitl/providers/macos.js.map +1 -1
- package/dist/hitl/providers/openclaw.js +2 -2
- package/dist/hitl/providers/openclaw.js.map +1 -1
- package/dist/hitl/providers/stdio.js +2 -2
- package/dist/hitl/providers/stdio.js.map +1 -1
- package/dist/hitl/providers/telegram.js +2 -2
- package/dist/hitl/providers/telegram.js.map +1 -1
- package/dist/hitl/providers/tui.d.ts.map +1 -1
- package/dist/hitl/providers/tui.js +8 -2
- package/dist/hitl/providers/tui.js.map +1 -1
- package/dist/hitl/providers/types.d.ts +14 -0
- package/dist/hitl/providers/types.d.ts.map +1 -1
- package/dist/hook/api.d.ts +2 -0
- package/dist/hook/api.d.ts.map +1 -1
- package/dist/hook/api.js.map +1 -1
- package/dist/hook/normalizer.js +2 -2
- package/dist/hook/normalizer.js.map +1 -1
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/dist/introspect/cli.d.ts +55 -0
- package/dist/introspect/cli.d.ts.map +1 -0
- package/dist/introspect/cli.js +850 -0
- package/dist/introspect/cli.js.map +1 -0
- package/dist/middleware/chain-builder.d.ts +1 -1
- package/dist/middleware/chain-builder.d.ts.map +1 -1
- package/dist/middleware/chain-builder.js +8 -4
- 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 +15 -0
- package/dist/middleware/core/allowlist.js.map +1 -1
- package/dist/middleware/core/arg-policy.d.ts +2 -1
- package/dist/middleware/core/arg-policy.d.ts.map +1 -1
- package/dist/middleware/core/arg-policy.js +158 -46
- package/dist/middleware/core/arg-policy.js.map +1 -1
- package/dist/middleware/core/command-policy.d.ts +13 -0
- package/dist/middleware/core/command-policy.d.ts.map +1 -0
- package/dist/middleware/core/command-policy.js +94 -0
- package/dist/middleware/core/command-policy.js.map +1 -0
- package/dist/middleware/core/exec-policy.d.ts.map +1 -1
- package/dist/middleware/core/exec-policy.js +17 -1
- package/dist/middleware/core/exec-policy.js.map +1 -1
- package/dist/middleware/core/execute.d.ts +2 -0
- package/dist/middleware/core/execute.d.ts.map +1 -1
- package/dist/middleware/core/execute.js +79 -3
- package/dist/middleware/core/execute.js.map +1 -1
- package/dist/middleware/core/hitl-gate.d.ts.map +1 -1
- package/dist/middleware/core/hitl-gate.js +22 -4
- package/dist/middleware/core/hitl-gate.js.map +1 -1
- package/dist/middleware/core/schema-validator.d.ts.map +1 -1
- package/dist/middleware/core/schema-validator.js +7 -3
- package/dist/middleware/core/schema-validator.js.map +1 -1
- package/dist/middleware/detectors/injection-detector.d.ts.map +1 -1
- package/dist/middleware/detectors/injection-detector.js +2 -0
- package/dist/middleware/detectors/injection-detector.js.map +1 -1
- package/dist/middleware/detectors/sensitivity-classifier.js +1 -0
- package/dist/middleware/detectors/sensitivity-classifier.js.map +1 -1
- package/dist/middleware/post/canary-token-injector.d.ts +4 -1
- package/dist/middleware/post/canary-token-injector.d.ts.map +1 -1
- package/dist/middleware/post/canary-token-injector.js +6 -1
- package/dist/middleware/post/canary-token-injector.js.map +1 -1
- package/dist/middleware/post/output-injection-detector.d.ts.map +1 -1
- package/dist/middleware/post/output-injection-detector.js +1 -0
- package/dist/middleware/post/output-injection-detector.js.map +1 -1
- package/dist/middleware/post/untrusted-envelope.d.ts.map +1 -1
- package/dist/middleware/post/untrusted-envelope.js +14 -1
- package/dist/middleware/post/untrusted-envelope.js.map +1 -1
- package/dist/mobile/api.d.ts +20 -0
- package/dist/mobile/api.d.ts.map +1 -0
- package/dist/mobile/api.js +259 -0
- package/dist/mobile/api.js.map +1 -0
- package/dist/mobile/apns.d.ts +68 -0
- package/dist/mobile/apns.d.ts.map +1 -0
- package/dist/mobile/apns.js +322 -0
- package/dist/mobile/apns.js.map +1 -0
- package/dist/pool/client-credentials.d.ts +46 -0
- package/dist/pool/client-credentials.d.ts.map +1 -0
- package/dist/pool/client-credentials.js +204 -0
- package/dist/pool/client-credentials.js.map +1 -0
- package/dist/pool/credential-health.d.ts +54 -0
- package/dist/pool/credential-health.d.ts.map +1 -0
- package/dist/pool/credential-health.js +262 -0
- package/dist/pool/credential-health.js.map +1 -0
- package/dist/pool/http-client.d.ts +52 -2
- package/dist/pool/http-client.d.ts.map +1 -1
- package/dist/pool/http-client.js +302 -17
- package/dist/pool/http-client.js.map +1 -1
- package/dist/pool/oauth-provider.d.ts +23 -0
- package/dist/pool/oauth-provider.d.ts.map +1 -1
- package/dist/pool/oauth-provider.js +134 -6
- package/dist/pool/oauth-provider.js.map +1 -1
- package/dist/pool/oauth-timing.d.ts +3 -0
- package/dist/pool/oauth-timing.d.ts.map +1 -0
- package/dist/pool/oauth-timing.js +8 -0
- package/dist/pool/oauth-timing.js.map +1 -0
- package/dist/pool/pool.d.ts +8 -1
- package/dist/pool/pool.d.ts.map +1 -1
- package/dist/pool/pool.js +17 -4
- package/dist/pool/pool.js.map +1 -1
- package/dist/pool/sse-client.d.ts +10 -1
- package/dist/pool/sse-client.d.ts.map +1 -1
- package/dist/pool/sse-client.js +46 -5
- package/dist/pool/sse-client.js.map +1 -1
- package/dist/pool/status.d.ts +6 -0
- package/dist/pool/status.d.ts.map +1 -0
- package/dist/pool/status.js +2 -0
- package/dist/pool/status.js.map +1 -0
- package/dist/pool/stdio-client.d.ts +11 -1
- package/dist/pool/stdio-client.d.ts.map +1 -1
- package/dist/pool/stdio-client.js +39 -3
- package/dist/pool/stdio-client.js.map +1 -1
- package/dist/registry/airlock-policy.d.ts +3 -0
- package/dist/registry/airlock-policy.d.ts.map +1 -0
- package/dist/registry/airlock-policy.js +50 -0
- package/dist/registry/airlock-policy.js.map +1 -0
- package/dist/registry/registry.d.ts +49 -4
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +160 -19
- package/dist/registry/registry.js.map +1 -1
- package/dist/registry/sanitizer.d.ts +16 -1
- package/dist/registry/sanitizer.d.ts.map +1 -1
- package/dist/registry/sanitizer.js +70 -11
- package/dist/registry/sanitizer.js.map +1 -1
- package/dist/security/blocked-hosts.d.ts +2 -0
- package/dist/security/blocked-hosts.d.ts.map +1 -1
- package/dist/security/blocked-hosts.js +61 -7
- package/dist/security/blocked-hosts.js.map +1 -1
- package/dist/security/request.d.ts +2 -0
- package/dist/security/request.d.ts.map +1 -1
- package/dist/security/request.js +6 -2
- package/dist/security/request.js.map +1 -1
- package/dist/security/secrets.d.ts +12 -0
- package/dist/security/secrets.d.ts.map +1 -0
- package/dist/security/secrets.js +138 -0
- package/dist/security/secrets.js.map +1 -0
- package/dist/setup-openclaw/cli.js +1 -1
- package/dist/stdio-mode.d.ts.map +1 -1
- package/dist/stdio-mode.js +159 -28
- package/dist/stdio-mode.js.map +1 -1
- package/dist/tools/api.d.ts +5 -1
- package/dist/tools/api.d.ts.map +1 -1
- package/dist/tools/api.js +67 -8
- package/dist/tools/api.js.map +1 -1
- package/dist/tools/exec.d.ts +2 -1
- package/dist/tools/exec.d.ts.map +1 -1
- package/dist/tools/exec.js +4 -3
- package/dist/tools/exec.js.map +1 -1
- package/dist/tools/http.d.ts.map +1 -1
- package/dist/tools/http.js +4 -7
- package/dist/tools/http.js.map +1 -1
- package/dist/transport/agent-server.d.ts +4 -0
- package/dist/transport/agent-server.d.ts.map +1 -1
- package/dist/transport/agent-server.js +47 -12
- package/dist/transport/agent-server.js.map +1 -1
- package/dist/transport/http-server.d.ts +4 -0
- package/dist/transport/http-server.d.ts.map +1 -1
- package/dist/transport/http-server.js +69 -9
- package/dist/transport/http-server.js.map +1 -1
- package/dist/transport/keepalive.d.ts +27 -0
- package/dist/transport/keepalive.d.ts.map +1 -0
- package/dist/transport/keepalive.js +30 -0
- package/dist/transport/keepalive.js.map +1 -0
- package/dist/transport/session-limiter.d.ts +84 -0
- package/dist/transport/session-limiter.d.ts.map +1 -0
- package/dist/transport/session-limiter.js +189 -0
- package/dist/transport/session-limiter.js.map +1 -0
- package/dist/transport/sse-server.d.ts +4 -0
- package/dist/transport/sse-server.d.ts.map +1 -1
- package/dist/transport/sse-server.js +27 -9
- package/dist/transport/sse-server.js.map +1 -1
- package/dist/transport/stdio-server.d.ts.map +1 -1
- package/dist/transport/stdio-server.js +4 -0
- package/dist/transport/stdio-server.js.map +1 -1
- package/dist/util/atomic-file.d.ts +9 -0
- package/dist/util/atomic-file.d.ts.map +1 -0
- package/dist/util/atomic-file.js +39 -0
- package/dist/util/atomic-file.js.map +1 -0
- package/dist/util/id.d.ts +1 -1
- package/dist/util/id.d.ts.map +1 -1
- package/dist/util/id.js +3 -3
- package/dist/util/id.js.map +1 -1
- package/examples/airlock.yaml +55 -0
- package/examples/claude-code-setup.md +0 -2
- package/examples/docker-compose.yaml +4 -3
- package/examples/docker-gateway.yaml +8 -3
- package/examples/gateway.yaml +8 -5
- package/examples/profiles.yaml +0 -2
- package/extensions/openclaw/index.ts +9 -6
- package/extensions/openclaw/openclaw.plugin.json +5 -5
- package/package.json +5 -3
- package/schema.json +1194 -19
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { randomBytes } from 'crypto';
|
|
2
2
|
import { existsSync, readFileSync, writeFileSync, copyFileSync } from 'fs';
|
|
3
|
+
import { isIP } from 'net';
|
|
3
4
|
import { parseArgs } from 'util';
|
|
4
5
|
import Fastify from 'fastify';
|
|
5
6
|
import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
|
|
@@ -25,6 +26,8 @@ Options:
|
|
|
25
26
|
-c, --config <path> Airlock config file (default: ./airlock.yaml)
|
|
26
27
|
-p, --port <port> Web UI port (default: 4177)
|
|
27
28
|
--host <host> Bind host (default: 127.0.0.1)
|
|
29
|
+
--insecure-remote-bind
|
|
30
|
+
Allow binding the unauthenticated UI beyond loopback
|
|
28
31
|
-h, --help Show this help
|
|
29
32
|
`;
|
|
30
33
|
const RUN_HELP = `
|
|
@@ -37,6 +40,8 @@ Options:
|
|
|
37
40
|
-c, --config <path> Airlock config file (default: ./airlock.yaml)
|
|
38
41
|
-p, --port <port> Web UI port (default: 4177)
|
|
39
42
|
--host <host> Bind host (default: 127.0.0.1)
|
|
43
|
+
--insecure-remote-bind
|
|
44
|
+
Allow binding the unauthenticated UI beyond loopback
|
|
40
45
|
-h, --help Show this help
|
|
41
46
|
`;
|
|
42
47
|
const DASHBOARD_HELP = `
|
|
@@ -49,7 +54,8 @@ Options:
|
|
|
49
54
|
-c, --config <path> Airlock config file (default: ./airlock.yaml)
|
|
50
55
|
-p, --port <port> Web UI port (default: 4177)
|
|
51
56
|
--host <host> Bind host (default: 127.0.0.1)
|
|
52
|
-
--
|
|
57
|
+
--insecure-remote-bind Allow binding the unauthenticated dashboard beyond loopback
|
|
58
|
+
--gateway-url <url> Gateway management API URL (default: http://127.0.0.1:4113)
|
|
53
59
|
--gateway-secret <secret> Gateway admin bearer token (default: AIRLOCK_GATEWAY_SECRET or AIRLOCK_API_SECRET)
|
|
54
60
|
-h, --help Show this help
|
|
55
61
|
`;
|
|
@@ -63,8 +69,9 @@ export async function runDashboard(argv) {
|
|
|
63
69
|
config: { type: 'string', short: 'c', default: './airlock.yaml' },
|
|
64
70
|
port: { type: 'string', short: 'p', default: '4177' },
|
|
65
71
|
host: { type: 'string', default: '127.0.0.1' },
|
|
66
|
-
'gateway-url': { type: 'string', default: 'http://127.0.0.1:
|
|
72
|
+
'gateway-url': { type: 'string', default: 'http://127.0.0.1:4113' },
|
|
67
73
|
'gateway-secret': { type: 'string' },
|
|
74
|
+
'insecure-remote-bind': { type: 'boolean', default: false },
|
|
68
75
|
help: { type: 'boolean', short: 'h', default: false },
|
|
69
76
|
},
|
|
70
77
|
allowPositionals: false,
|
|
@@ -76,13 +83,14 @@ export async function runDashboard(argv) {
|
|
|
76
83
|
const configPath = values.config ?? './airlock.yaml';
|
|
77
84
|
const port = Number(values.port ?? '4177');
|
|
78
85
|
const host = values.host ?? '127.0.0.1';
|
|
79
|
-
const gatewayUrl = values['gateway-url'] ?? 'http://127.0.0.1:
|
|
86
|
+
const gatewayUrl = values['gateway-url'] ?? 'http://127.0.0.1:4113';
|
|
80
87
|
const gatewaySecret = values['gateway-secret'] ??
|
|
81
88
|
process.env['AIRLOCK_GATEWAY_SECRET'] ??
|
|
82
89
|
process.env['AIRLOCK_API_SECRET'];
|
|
83
90
|
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
84
91
|
throw new Error(`Invalid --port: ${values.port}`);
|
|
85
92
|
}
|
|
93
|
+
assertSafeWebBindHost(host, values['insecure-remote-bind'] === true);
|
|
86
94
|
const app = createConfigureWebApp(configPath, {
|
|
87
95
|
remoteGateway: { url: gatewayUrl, secret: gatewaySecret },
|
|
88
96
|
});
|
|
@@ -98,6 +106,7 @@ export async function runConfigureWeb(argv, entrypoint = 'configure-web') {
|
|
|
98
106
|
config: { type: 'string', short: 'c', default: './airlock.yaml' },
|
|
99
107
|
port: { type: 'string', short: 'p', default: '4177' },
|
|
100
108
|
host: { type: 'string', default: '127.0.0.1' },
|
|
109
|
+
'insecure-remote-bind': { type: 'boolean', default: false },
|
|
101
110
|
help: { type: 'boolean', short: 'h', default: false },
|
|
102
111
|
},
|
|
103
112
|
allowPositionals: false,
|
|
@@ -112,11 +121,28 @@ export async function runConfigureWeb(argv, entrypoint = 'configure-web') {
|
|
|
112
121
|
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
113
122
|
throw new Error(`Invalid --port: ${values.port}`);
|
|
114
123
|
}
|
|
124
|
+
assertSafeWebBindHost(host, values['insecure-remote-bind'] === true);
|
|
115
125
|
const app = createConfigureWebApp(configPath);
|
|
116
126
|
await app.listen({ host, port });
|
|
117
127
|
console.log(`Airlock command center running at http://${host}:${port}`);
|
|
118
128
|
console.log(`Editing ${configPath}`);
|
|
119
129
|
}
|
|
130
|
+
export function assertSafeWebBindHost(host, insecureRemoteBind) {
|
|
131
|
+
if (insecureRemoteBind || isLoopbackBindHost(host))
|
|
132
|
+
return;
|
|
133
|
+
throw new Error('--host binds the unauthenticated Airlock web UI beyond loopback. Use --insecure-remote-bind only when the port is protected by a private network, tunnel, or authenticated reverse proxy.');
|
|
134
|
+
}
|
|
135
|
+
function isLoopbackBindHost(host) {
|
|
136
|
+
const normalized = host.startsWith('[') && host.endsWith(']') ? host.slice(1, -1) : host;
|
|
137
|
+
if (normalized === 'localhost')
|
|
138
|
+
return true;
|
|
139
|
+
const ipVersion = isIP(normalized);
|
|
140
|
+
if (ipVersion === 6)
|
|
141
|
+
return normalized === '::1';
|
|
142
|
+
if (ipVersion !== 4)
|
|
143
|
+
return false;
|
|
144
|
+
return Number(normalized.split('.')[0]) === 127;
|
|
145
|
+
}
|
|
120
146
|
export function createConfigureWebApp(configPath, options = {}) {
|
|
121
147
|
const app = Fastify({ logger: false });
|
|
122
148
|
app.get('/', async (_request, reply) => {
|
|
@@ -152,6 +178,18 @@ export function createConfigureWebApp(configPath, options = {}) {
|
|
|
152
178
|
};
|
|
153
179
|
}
|
|
154
180
|
});
|
|
181
|
+
app.get('/api/activity', async (_request, reply) => {
|
|
182
|
+
try {
|
|
183
|
+
if (options.remoteGateway) {
|
|
184
|
+
return await remoteGatewayJson(options.remoteGateway, '/activity');
|
|
185
|
+
}
|
|
186
|
+
return { events: [] };
|
|
187
|
+
}
|
|
188
|
+
catch (err) {
|
|
189
|
+
reply.code(500);
|
|
190
|
+
return { events: [], error: err instanceof Error ? err.message : String(err) };
|
|
191
|
+
}
|
|
192
|
+
});
|
|
155
193
|
app.get('/api/tools', async (_request, reply) => {
|
|
156
194
|
try {
|
|
157
195
|
if (options.remoteGateway) {
|
|
@@ -483,7 +521,7 @@ async function rememberRemoteDecision(configPath, remoteGateway, code, remember,
|
|
|
483
521
|
return { status: 400, error: 'Invalid remember mode' };
|
|
484
522
|
}
|
|
485
523
|
const pending = await remoteGatewayJson(remoteGateway, '/hitl/pending');
|
|
486
|
-
const request = pending.find((entry) => entry.code === code
|
|
524
|
+
const request = pending.find((entry) => entry.code === code);
|
|
487
525
|
if (!request)
|
|
488
526
|
return { status: 404, error: 'No pending request found for code' };
|
|
489
527
|
const durationMs = typeof durationMsValue === 'string' && durationMsValue.trim()
|
|
@@ -1136,12 +1174,24 @@ const INDEX_HTML = `<!doctype html>
|
|
|
1136
1174
|
justify-content: flex-start;
|
|
1137
1175
|
margin-bottom: 6px;
|
|
1138
1176
|
background: transparent;
|
|
1177
|
+
gap: 8px;
|
|
1139
1178
|
}
|
|
1140
1179
|
.entity.active {
|
|
1141
1180
|
background: #eaf0ff;
|
|
1142
1181
|
border-color: #b9c8ff;
|
|
1143
1182
|
color: #173c9c;
|
|
1144
1183
|
}
|
|
1184
|
+
.entity-issue-pill {
|
|
1185
|
+
margin-left: auto;
|
|
1186
|
+
min-width: 22px;
|
|
1187
|
+
min-height: 20px;
|
|
1188
|
+
padding: 0 7px;
|
|
1189
|
+
border-color: #f2c0bb;
|
|
1190
|
+
background: #fff0ee;
|
|
1191
|
+
color: var(--red);
|
|
1192
|
+
font-weight: 750;
|
|
1193
|
+
justify-content: center;
|
|
1194
|
+
}
|
|
1145
1195
|
.surface-group {
|
|
1146
1196
|
margin-bottom: 14px;
|
|
1147
1197
|
}
|
|
@@ -1310,6 +1360,17 @@ const INDEX_HTML = `<!doctype html>
|
|
|
1310
1360
|
border-color: #f1d99a;
|
|
1311
1361
|
background: #fffaf0;
|
|
1312
1362
|
}
|
|
1363
|
+
.log-row.question {
|
|
1364
|
+
border-color: #c8d7ef;
|
|
1365
|
+
background: #f3f7ff;
|
|
1366
|
+
}
|
|
1367
|
+
.log-row.notification {
|
|
1368
|
+
border-color: #c8d7ef;
|
|
1369
|
+
background: #f7fbff;
|
|
1370
|
+
}
|
|
1371
|
+
.log-row.log {
|
|
1372
|
+
background: #fbfcfe;
|
|
1373
|
+
}
|
|
1313
1374
|
.log-cell {
|
|
1314
1375
|
min-width: 0;
|
|
1315
1376
|
overflow-wrap: anywhere;
|
|
@@ -1754,7 +1815,7 @@ const INDEX_HTML = `<!doctype html>
|
|
|
1754
1815
|
<div class="surface-group">
|
|
1755
1816
|
<div class="section-title" style="margin-top:0">System</div>
|
|
1756
1817
|
<button id="viewActivity" class="entity">Activity</button>
|
|
1757
|
-
<button id="manageProviders" class="entity">Providers</button>
|
|
1818
|
+
<button id="manageProviders" class="entity">Providers <span id="providerIssues" class="pill entity-issue-pill" hidden>0</span></button>
|
|
1758
1819
|
</div>
|
|
1759
1820
|
<div class="row">
|
|
1760
1821
|
<div class="section-title">Agents</div>
|
|
@@ -1873,8 +1934,9 @@ const INDEX_HTML = `<!doctype html>
|
|
|
1873
1934
|
config: null,
|
|
1874
1935
|
status: null,
|
|
1875
1936
|
audit: { dbPath: '', entries: [], pending: [] },
|
|
1876
|
-
|
|
1877
|
-
|
|
1937
|
+
activityEvents: [],
|
|
1938
|
+
livePendingById: {},
|
|
1939
|
+
currentApprovalId: '',
|
|
1878
1940
|
activityAgentId: '',
|
|
1879
1941
|
auditFilters: { agent: '', tool: '', since: '', limit: '50' },
|
|
1880
1942
|
tools: [],
|
|
@@ -1959,7 +2021,13 @@ const INDEX_HTML = `<!doctype html>
|
|
|
1959
2021
|
for (const [key, value] of Object.entries(state.auditFilters)) {
|
|
1960
2022
|
if (String(value || '').trim()) params.set(key, String(value).trim());
|
|
1961
2023
|
}
|
|
1962
|
-
|
|
2024
|
+
const [audit, activity] = await Promise.all([
|
|
2025
|
+
api('/api/logs' + (params.toString() ? '?' + params.toString() : '')),
|
|
2026
|
+
api('/api/activity')
|
|
2027
|
+
]);
|
|
2028
|
+
state.audit = audit;
|
|
2029
|
+
state.activityEvents = Array.isArray(activity.events) ? activity.events : [];
|
|
2030
|
+
reconcileLivePendingWithSnapshot();
|
|
1963
2031
|
render();
|
|
1964
2032
|
} catch (error) {
|
|
1965
2033
|
alert(error.message);
|
|
@@ -2046,26 +2114,41 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2046
2114
|
}
|
|
2047
2115
|
|
|
2048
2116
|
function pendingApprovals(agentId = '') {
|
|
2049
|
-
const
|
|
2050
|
-
for (const request of Object.values(state.livePending || {})) {
|
|
2051
|
-
const pending = normalizePending(request, true);
|
|
2052
|
-
if (pending.code && (!agentId || pending.agentId === agentId)) byCode.set(pending.code, pending);
|
|
2053
|
-
}
|
|
2117
|
+
const byId = new Map();
|
|
2054
2118
|
for (const request of state.audit.pending || []) {
|
|
2055
2119
|
const pending = normalizePending(request, false);
|
|
2056
|
-
if (pending.
|
|
2120
|
+
if (pending.id && (!agentId || pending.agentId === agentId)) byId.set(pending.id, pending);
|
|
2121
|
+
}
|
|
2122
|
+
for (const request of Object.values(state.livePendingById || {})) {
|
|
2123
|
+
const pending = normalizePending(request, true);
|
|
2124
|
+
if (pending.id && (!agentId || pending.agentId === agentId) && !byId.has(pending.id)) {
|
|
2125
|
+
byId.set(pending.id, pending);
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
return Array.from(byId.values());
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
function reconcileLivePendingWithSnapshot() {
|
|
2132
|
+
const snapshotIds = new Set(
|
|
2133
|
+
(state.audit.pending || [])
|
|
2134
|
+
.map((request) => normalizePending(request, false).id)
|
|
2135
|
+
.filter(Boolean)
|
|
2136
|
+
);
|
|
2137
|
+
for (const id of Object.keys(state.livePendingById || {})) {
|
|
2138
|
+
if (!snapshotIds.has(id)) delete state.livePendingById[id];
|
|
2057
2139
|
}
|
|
2058
|
-
return Array.from(byCode.values());
|
|
2059
2140
|
}
|
|
2060
2141
|
|
|
2061
2142
|
function normalizePending(request, live) {
|
|
2062
2143
|
const args = live ? request.args : parseArgs(request.args);
|
|
2144
|
+
const context = request.context || airlockContext(args);
|
|
2063
2145
|
return {
|
|
2064
2146
|
id: request.id || '',
|
|
2065
2147
|
code: request.code || '',
|
|
2066
2148
|
agentId: request.agentId || request.agent_id || '',
|
|
2067
2149
|
tool: request.tool || '',
|
|
2068
|
-
args,
|
|
2150
|
+
args: stripAirlockContext(args),
|
|
2151
|
+
context,
|
|
2069
2152
|
status: request.status || 'pending',
|
|
2070
2153
|
createdAt: request.createdAt || request.created_at || '',
|
|
2071
2154
|
timeoutMs: request.timeoutMs || 0,
|
|
@@ -2084,19 +2167,37 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2084
2167
|
}
|
|
2085
2168
|
}
|
|
2086
2169
|
|
|
2170
|
+
function airlockContext(args) {
|
|
2171
|
+
const raw = args && typeof args === 'object' ? args._airlock : undefined;
|
|
2172
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return undefined;
|
|
2173
|
+
const context = {};
|
|
2174
|
+
if (typeof raw.reason === 'string' && raw.reason.trim()) context.reason = raw.reason.trim();
|
|
2175
|
+
if (typeof raw.note === 'string' && raw.note.trim()) context.note = raw.note.trim();
|
|
2176
|
+
return context.reason || context.note ? context : undefined;
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
function stripAirlockContext(args) {
|
|
2180
|
+
if (!args || typeof args !== 'object' || Array.isArray(args) || !('_airlock' in args)) return args;
|
|
2181
|
+
const clean = { ...args };
|
|
2182
|
+
delete clean._airlock;
|
|
2183
|
+
return clean;
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2087
2186
|
function renderActivity() {
|
|
2088
2187
|
el('activitySurface').hidden = state.activeKind !== 'activity';
|
|
2089
2188
|
renderActivityAgentFilter();
|
|
2090
2189
|
const agentId = state.auditFilters.agent || state.activityAgentId || '';
|
|
2091
2190
|
const pending = pendingApprovals(agentId);
|
|
2092
2191
|
const entries = state.audit.entries || [];
|
|
2192
|
+
const activity = activityEvents(agentId);
|
|
2093
2193
|
const rows = [
|
|
2094
2194
|
...pending.map(pendingRow),
|
|
2195
|
+
...activity.map(activityRow),
|
|
2095
2196
|
...entries.map(auditRow)
|
|
2096
2197
|
];
|
|
2097
2198
|
el('pendingBadge').textContent = 'pending ' + pending.length;
|
|
2098
2199
|
el('activityMeta').textContent = state.audit.dbPath
|
|
2099
|
-
? 'Audit log: ' + state.audit.dbPath + (agentId ? ' · agent ' + agentId : '')
|
|
2200
|
+
? 'Activity events ' + activity.length + ' · Audit log: ' + state.audit.dbPath + (agentId ? ' · agent ' + agentId : '')
|
|
2100
2201
|
: 'Audit log not loaded yet';
|
|
2101
2202
|
el('activityList').innerHTML = rows.length
|
|
2102
2203
|
? rows.join('')
|
|
@@ -2104,7 +2205,7 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2104
2205
|
document.querySelectorAll('[data-pending-row]').forEach((row) => {
|
|
2105
2206
|
row.addEventListener('click', (event) => {
|
|
2106
2207
|
if (event.target.closest('[data-approval-action]')) return;
|
|
2107
|
-
openApprovalModal(row.dataset.
|
|
2208
|
+
openApprovalModal(row.dataset.id);
|
|
2108
2209
|
});
|
|
2109
2210
|
});
|
|
2110
2211
|
document.querySelectorAll('[data-approval-action]').forEach((button) => {
|
|
@@ -2120,6 +2221,10 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2120
2221
|
});
|
|
2121
2222
|
}
|
|
2122
2223
|
|
|
2224
|
+
function activityEvents(agentId = '') {
|
|
2225
|
+
return (state.activityEvents || []).filter((event) => !agentId || event.agentId === agentId);
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2123
2228
|
function renderActivityAgentFilter() {
|
|
2124
2229
|
const agents = Object.keys(state.config.agents);
|
|
2125
2230
|
if (!state.activityAgentId) state.activityAgentId = agents[0] || '';
|
|
@@ -2131,25 +2236,29 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2131
2236
|
}
|
|
2132
2237
|
|
|
2133
2238
|
function pendingRow(entry) {
|
|
2134
|
-
|
|
2135
|
-
|
|
2239
|
+
const question = isUserQuestion(entry);
|
|
2240
|
+
return '<div class="log-row pending' + (question ? ' question' : '') + '" data-pending-row data-id="' + escapeHtml(entry.id) + '" data-code="' + escapeHtml(entry.code) + '">' +
|
|
2241
|
+
'<div class="log-cell"><strong>' + escapeHtml(question ? 'pending question' : 'pending approval') + '</strong><br>' + escapeHtml(formatTime(entry.createdAt)) + '</div>' +
|
|
2136
2242
|
'<div class="log-cell">' + escapeHtml(entry.agentId) + '</div>' +
|
|
2137
|
-
'<div class="log-cell">' + escapeHtml(entry.tool) + '<br><span class="subtle">
|
|
2138
|
-
'<div class="log-cell"><span class="tag tag-warn">' + escapeHtml(entry.status) + '</span></div>' +
|
|
2139
|
-
'<pre class="log-args">' + escapeHtml(
|
|
2140
|
-
'<div class="approval-actions">' + approvalButtons(entry.code) + '</div>' +
|
|
2243
|
+
'<div class="log-cell">' + escapeHtml(question ? questionText(entry) : entry.tool) + '<br><span class="subtle">' + escapeHtml(question ? entry.tool : 'code ' + entry.code) + '</span></div>' +
|
|
2244
|
+
'<div class="log-cell"><span class="tag tag-warn">' + escapeHtml(question ? 'question' : entry.status) + '</span></div>' +
|
|
2245
|
+
'<pre class="log-args">' + escapeHtml(question ? questionPreview(entry) : approvalPreview(entry)) + '</pre>' +
|
|
2246
|
+
'<div class="approval-actions">' + approvalButtons(entry.code, { remember: !question, approveLabel: question ? 'Confirm' : 'Approve' }) + '</div>' +
|
|
2141
2247
|
'</div>';
|
|
2142
2248
|
}
|
|
2143
2249
|
|
|
2144
|
-
function approvalButtons(code) {
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2250
|
+
function approvalButtons(code, options = {}) {
|
|
2251
|
+
const approveLabel = options.approveLabel || 'Approve';
|
|
2252
|
+
const remember = options.remember !== false;
|
|
2253
|
+
return '<button class="approve" data-approval-action="approve" data-code="' + escapeHtml(code) + '">' + escapeHtml(approveLabel) + '</button>' +
|
|
2254
|
+
(remember ? '<button class="approve" data-approval-action="approve" data-code="' + escapeHtml(code) + '" data-remember="temporary" data-duration="3600000">Allow 1h</button>' : '') +
|
|
2255
|
+
(remember ? '<button class="approve" data-approval-action="approve" data-code="' + escapeHtml(code) + '" data-remember="always">Always Allow</button>' : '') +
|
|
2148
2256
|
'<button class="deny" data-approval-action="deny" data-code="' + escapeHtml(code) + '">Deny</button>';
|
|
2149
2257
|
}
|
|
2150
2258
|
|
|
2151
2259
|
async function actApproval(action, code, remember, durationMs) {
|
|
2152
2260
|
if (!code) return;
|
|
2261
|
+
const pending = findPendingApproval(code);
|
|
2153
2262
|
const params = new URLSearchParams({ code });
|
|
2154
2263
|
if (remember) params.set('remember', remember);
|
|
2155
2264
|
if (durationMs) params.set('duration_ms', durationMs);
|
|
@@ -2164,7 +2273,7 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2164
2273
|
}
|
|
2165
2274
|
throw new Error(message);
|
|
2166
2275
|
}
|
|
2167
|
-
delete state.
|
|
2276
|
+
if (pending?.id) delete state.livePendingById[pending.id];
|
|
2168
2277
|
closeApprovalModal();
|
|
2169
2278
|
await Promise.all([refreshLogs(), refreshStatus()]);
|
|
2170
2279
|
render();
|
|
@@ -2172,21 +2281,26 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2172
2281
|
|
|
2173
2282
|
function findPendingApproval(code) {
|
|
2174
2283
|
const agentId = state.activeKind === 'activity' ? state.auditFilters.agent || '' : '';
|
|
2175
|
-
return pendingApprovals(agentId).find((entry) => entry.code === code);
|
|
2284
|
+
return pendingApprovals(agentId).find((entry) => entry.id === code || entry.code === code);
|
|
2176
2285
|
}
|
|
2177
2286
|
|
|
2178
|
-
function openApprovalModal(
|
|
2179
|
-
const pending = findPendingApproval(
|
|
2287
|
+
function openApprovalModal(id) {
|
|
2288
|
+
const pending = findPendingApproval(id);
|
|
2180
2289
|
if (!pending) return;
|
|
2181
|
-
state.
|
|
2182
|
-
|
|
2290
|
+
state.currentApprovalId = pending.id;
|
|
2291
|
+
const question = isUserQuestion(pending);
|
|
2292
|
+
el('approvalModalTitle').textContent = question ? questionText(pending) : pending.tool;
|
|
2183
2293
|
el('approvalModalMeta').textContent = 'agent ' + pending.agentId + ' · code ' + pending.code;
|
|
2184
2294
|
el('approvalModalBody').innerHTML =
|
|
2185
2295
|
'<div class="detail-label">Status</div><div>' + escapeHtml(pending.status) + '</div>' +
|
|
2186
2296
|
'<div class="detail-label">Created</div><div>' + escapeHtml(formatTime(pending.createdAt)) + '</div>' +
|
|
2187
2297
|
(pending.timeoutMs ? '<div class="detail-label">Timeout</div><div>' + Math.round(pending.timeoutMs / 1000) + 's</div>' : '') +
|
|
2298
|
+
(requestReason(pending) ? '<div class="detail-label">Request reason</div><div>' + escapeHtml(requestReason(pending)) + '</div>' : '') +
|
|
2299
|
+
(requestNote(pending) ? '<div class="detail-label">Request note</div><div>' + escapeHtml(requestNote(pending)) + '</div>' : '') +
|
|
2300
|
+
(question ? '<div class="detail-label">Question</div><div>' + escapeHtml(questionText(pending)) + '</div>' : '') +
|
|
2301
|
+
(question && questionContext(pending) ? '<div class="detail-label">Context</div><div>' + escapeHtml(questionContext(pending)) + '</div>' : '') +
|
|
2188
2302
|
'<div class="detail-label">Arguments</div><pre class="log-args">' + escapeHtml(prettyJson(pending.args)) + '</pre>';
|
|
2189
|
-
el('approvalModalFooter').innerHTML = approvalButtons(pending.code);
|
|
2303
|
+
el('approvalModalFooter').innerHTML = approvalButtons(pending.code, { remember: !question, approveLabel: question ? 'Confirm' : 'Approve' });
|
|
2190
2304
|
el('approvalModal').classList.add('open');
|
|
2191
2305
|
el('approvalModalFooter').querySelectorAll('[data-approval-action]').forEach((button) => {
|
|
2192
2306
|
button.addEventListener('click', () => {
|
|
@@ -2202,7 +2316,58 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2202
2316
|
|
|
2203
2317
|
function closeApprovalModal() {
|
|
2204
2318
|
el('approvalModal').classList.remove('open');
|
|
2205
|
-
state.
|
|
2319
|
+
state.currentApprovalId = '';
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
function isUserQuestion(entry) {
|
|
2323
|
+
return entry.tool === 'airlock/ask_user';
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
function questionText(entry) {
|
|
2327
|
+
const value = entry.args?.question ?? entry.args?.title ?? entry.args?.message;
|
|
2328
|
+
return typeof value === 'string' && value.trim() ? value.trim() : 'Question from agent';
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
function questionContext(entry) {
|
|
2332
|
+
const value = entry.args?.context ?? entry.args?.reason;
|
|
2333
|
+
return typeof value === 'string' && value.trim() ? value.trim() : '';
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
function questionPreview(entry) {
|
|
2337
|
+
const lines = ['question: ' + questionText(entry)];
|
|
2338
|
+
const context = questionContext(entry);
|
|
2339
|
+
if (context) lines.push('context: ' + context);
|
|
2340
|
+
return lines.join('\\n');
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
function requestReason(entry) {
|
|
2344
|
+
const value = entry.context?.reason;
|
|
2345
|
+
return typeof value === 'string' && value.trim() ? value.trim() : '';
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
function requestNote(entry) {
|
|
2349
|
+
const value = entry.context?.note;
|
|
2350
|
+
return typeof value === 'string' && value.trim() ? value.trim() : '';
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
function approvalPreview(entry) {
|
|
2354
|
+
const lines = [];
|
|
2355
|
+
const reason = requestReason(entry);
|
|
2356
|
+
const note = requestNote(entry);
|
|
2357
|
+
if (reason) lines.push('request reason: ' + reason);
|
|
2358
|
+
if (note) lines.push('request note: ' + note);
|
|
2359
|
+
lines.push(prettyJson(entry.args));
|
|
2360
|
+
return lines.join('\\n');
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
function activityRow(event) {
|
|
2364
|
+
const tag = event.kind === 'notification' ? 'tag-warn' : resultTagClass(event.severity || 'info');
|
|
2365
|
+
return '<div class="log-row ' + escapeHtml(event.kind) + '">' +
|
|
2366
|
+
'<div class="log-cell"><strong>' + escapeHtml(event.kind) + '</strong><br>' + escapeHtml(formatTime(event.createdAt)) + '</div>' +
|
|
2367
|
+
'<div class="log-cell">' + escapeHtml(event.agentId || '') + '</div>' +
|
|
2368
|
+
'<div class="log-cell">' + escapeHtml(event.title || '') + '<br><span class="subtle">' + escapeHtml(event.body || '') + '</span></div>' +
|
|
2369
|
+
'<div class="log-cell"><span class="tag ' + tag + '">' + escapeHtml(event.severity || 'info') + '</span></div>' +
|
|
2370
|
+
'</div>';
|
|
2206
2371
|
}
|
|
2207
2372
|
|
|
2208
2373
|
function auditRow(entry) {
|
|
@@ -2244,6 +2409,16 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2244
2409
|
function renderProviderNav() {
|
|
2245
2410
|
el('manageProviders').classList.toggle('active', state.activeKind === 'providers');
|
|
2246
2411
|
el('viewActivity').classList.toggle('active', state.activeKind === 'activity');
|
|
2412
|
+
const issues = providerIssueCount();
|
|
2413
|
+
const pill = el('providerIssues');
|
|
2414
|
+
pill.hidden = issues === 0;
|
|
2415
|
+
pill.textContent = String(issues);
|
|
2416
|
+
pill.title = issues === 1 ? '1 provider issue' : issues + ' provider issues';
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
function providerIssueCount() {
|
|
2420
|
+
if (!state.status?.summary) return 0;
|
|
2421
|
+
return (state.status.summary.down || 0) + (state.status.summary.disabled || 0);
|
|
2247
2422
|
}
|
|
2248
2423
|
|
|
2249
2424
|
function renderProvidersManager() {
|
|
@@ -2874,17 +3049,31 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2874
3049
|
events.onmessage = (event) => {
|
|
2875
3050
|
const message = JSON.parse(event.data);
|
|
2876
3051
|
if (message.type === 'new') {
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
3052
|
+
const request = message.request || {};
|
|
3053
|
+
if (request.id) {
|
|
3054
|
+
state.livePendingById[request.id] = request;
|
|
3055
|
+
notifyApproval(request);
|
|
3056
|
+
refreshLogs().catch(() => {});
|
|
3057
|
+
render();
|
|
3058
|
+
}
|
|
2881
3059
|
}
|
|
2882
3060
|
if (message.type === 'resolved') {
|
|
2883
|
-
|
|
3061
|
+
if (message.id) {
|
|
3062
|
+
delete state.livePendingById[message.id];
|
|
3063
|
+
} else if (message.code) {
|
|
3064
|
+
for (const [id, request] of Object.entries(state.livePendingById || {})) {
|
|
3065
|
+
if (request && request.code === message.code) delete state.livePendingById[id];
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
2884
3068
|
refreshLogs().catch(() => {});
|
|
2885
3069
|
refreshStatus().catch(() => {});
|
|
2886
3070
|
render();
|
|
2887
3071
|
}
|
|
3072
|
+
if (message.type === 'activity') {
|
|
3073
|
+
upsertActivityEvent(message.event);
|
|
3074
|
+
notifyActivity(message.event);
|
|
3075
|
+
render();
|
|
3076
|
+
}
|
|
2888
3077
|
};
|
|
2889
3078
|
events.onerror = () => {
|
|
2890
3079
|
events.close();
|
|
@@ -2894,13 +3083,36 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2894
3083
|
function notifyApproval(request) {
|
|
2895
3084
|
if (!el('approvalNotifs').checked) return;
|
|
2896
3085
|
if (!('Notification' in window) || Notification.permission !== 'granted') return;
|
|
3086
|
+
const pending = normalizePending(request, true);
|
|
3087
|
+
const lines = ['agent: ' + pending.agentId, pending.code];
|
|
3088
|
+
const reason = requestReason(pending);
|
|
3089
|
+
if (reason) lines.push('request reason: ' + reason);
|
|
2897
3090
|
new Notification('Airlock: ' + request.tool, {
|
|
2898
|
-
body:
|
|
2899
|
-
tag: request.code,
|
|
3091
|
+
body: lines.join('\\n'),
|
|
3092
|
+
tag: request.id || request.code,
|
|
2900
3093
|
silent: !el('approvalSound').checked
|
|
2901
3094
|
});
|
|
2902
3095
|
}
|
|
2903
3096
|
|
|
3097
|
+
function notifyActivity(event) {
|
|
3098
|
+
if (!event || event.kind !== 'notification') return;
|
|
3099
|
+
if (!el('approvalNotifs').checked) return;
|
|
3100
|
+
if (!('Notification' in window) || Notification.permission !== 'granted') return;
|
|
3101
|
+
new Notification(event.title || 'Airlock notification', {
|
|
3102
|
+
body: event.body || '',
|
|
3103
|
+
tag: event.id,
|
|
3104
|
+
silent: !el('approvalSound').checked
|
|
3105
|
+
});
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
function upsertActivityEvent(event) {
|
|
3109
|
+
if (!event || !event.id) return;
|
|
3110
|
+
state.activityEvents = [
|
|
3111
|
+
event,
|
|
3112
|
+
...(state.activityEvents || []).filter((existing) => existing.id !== event.id)
|
|
3113
|
+
].slice(0, 200);
|
|
3114
|
+
}
|
|
3115
|
+
|
|
2904
3116
|
async function checkVersion() {
|
|
2905
3117
|
try {
|
|
2906
3118
|
const current = await fetch('/version').then((response) => response.json());
|
|
@@ -2923,10 +3135,10 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2923
3135
|
return false;
|
|
2924
3136
|
}
|
|
2925
3137
|
|
|
2926
|
-
function
|
|
3138
|
+
function firstPendingApprovalId() {
|
|
2927
3139
|
const agentId = state.activeKind === 'activity' ? state.auditFilters.agent || '' : '';
|
|
2928
3140
|
const first = pendingApprovals(agentId)[0];
|
|
2929
|
-
return first ? first.
|
|
3141
|
+
return first ? first.id : '';
|
|
2930
3142
|
}
|
|
2931
3143
|
|
|
2932
3144
|
el('refreshTools').addEventListener('click', refreshTools);
|
|
@@ -2981,9 +3193,10 @@ const INDEX_HTML = `<!doctype html>
|
|
|
2981
3193
|
if (target && ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName)) return;
|
|
2982
3194
|
const key = event.key.toLowerCase();
|
|
2983
3195
|
if (key !== 'a' && key !== 'd') return;
|
|
2984
|
-
const
|
|
2985
|
-
|
|
2986
|
-
|
|
3196
|
+
const id = state.currentApprovalId || firstPendingApprovalId();
|
|
3197
|
+
const pending = findPendingApproval(id);
|
|
3198
|
+
if (!pending?.code) return;
|
|
3199
|
+
actApproval(key === 'a' ? 'approve' : 'deny', pending.code).catch((error) => alert(error.message));
|
|
2987
3200
|
});
|
|
2988
3201
|
|
|
2989
3202
|
initApprovalSettings();
|