clawsec 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +560 -0
- package/dist/bin/clawsec.d.ts +7 -0
- package/dist/bin/clawsec.d.ts.map +1 -0
- package/dist/bin/clawsec.js +12 -0
- package/dist/bin/clawsec.js.map +1 -0
- package/dist/src/actions/block.d.ts +22 -0
- package/dist/src/actions/block.d.ts.map +1 -0
- package/dist/src/actions/block.js +83 -0
- package/dist/src/actions/block.js.map +1 -0
- package/dist/src/actions/confirm.d.ts +35 -0
- package/dist/src/actions/confirm.d.ts.map +1 -0
- package/dist/src/actions/confirm.js +156 -0
- package/dist/src/actions/confirm.js.map +1 -0
- package/dist/src/actions/executor.d.ts +64 -0
- package/dist/src/actions/executor.d.ts.map +1 -0
- package/dist/src/actions/executor.js +114 -0
- package/dist/src/actions/executor.js.map +1 -0
- package/dist/src/actions/index.d.ts +13 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/index.js +15 -0
- package/dist/src/actions/index.js.map +1 -0
- package/dist/src/actions/log.d.ts +19 -0
- package/dist/src/actions/log.d.ts.map +1 -0
- package/dist/src/actions/log.js +63 -0
- package/dist/src/actions/log.js.map +1 -0
- package/dist/src/actions/types.d.ts +85 -0
- package/dist/src/actions/types.d.ts.map +1 -0
- package/dist/src/actions/types.js +78 -0
- package/dist/src/actions/types.js.map +1 -0
- package/dist/src/actions/warn.d.ts +22 -0
- package/dist/src/actions/warn.d.ts.map +1 -0
- package/dist/src/actions/warn.js +84 -0
- package/dist/src/actions/warn.js.map +1 -0
- package/dist/src/approval/agent-confirm.d.ts +104 -0
- package/dist/src/approval/agent-confirm.d.ts.map +1 -0
- package/dist/src/approval/agent-confirm.js +173 -0
- package/dist/src/approval/agent-confirm.js.map +1 -0
- package/dist/src/approval/index.d.ts +14 -0
- package/dist/src/approval/index.d.ts.map +1 -0
- package/dist/src/approval/index.js +9 -0
- package/dist/src/approval/index.js.map +1 -0
- package/dist/src/approval/native.d.ts +56 -0
- package/dist/src/approval/native.d.ts.map +1 -0
- package/dist/src/approval/native.js +196 -0
- package/dist/src/approval/native.js.map +1 -0
- package/dist/src/approval/store.d.ts +88 -0
- package/dist/src/approval/store.d.ts.map +1 -0
- package/dist/src/approval/store.js +192 -0
- package/dist/src/approval/store.js.map +1 -0
- package/dist/src/approval/types.d.ts +119 -0
- package/dist/src/approval/types.d.ts.map +1 -0
- package/dist/src/approval/types.js +6 -0
- package/dist/src/approval/types.js.map +1 -0
- package/dist/src/approval/webhook.d.ts +170 -0
- package/dist/src/approval/webhook.d.ts.map +1 -0
- package/dist/src/approval/webhook.js +362 -0
- package/dist/src/approval/webhook.js.map +1 -0
- package/dist/src/cli/commands/audit.d.ts +43 -0
- package/dist/src/cli/commands/audit.d.ts.map +1 -0
- package/dist/src/cli/commands/audit.js +115 -0
- package/dist/src/cli/commands/audit.js.map +1 -0
- package/dist/src/cli/commands/feedback.d.ts +27 -0
- package/dist/src/cli/commands/feedback.d.ts.map +1 -0
- package/dist/src/cli/commands/feedback.js +228 -0
- package/dist/src/cli/commands/feedback.js.map +1 -0
- package/dist/src/cli/commands/index.d.ts +11 -0
- package/dist/src/cli/commands/index.d.ts.map +1 -0
- package/dist/src/cli/commands/index.js +13 -0
- package/dist/src/cli/commands/index.js.map +1 -0
- package/dist/src/cli/commands/status.d.ts +20 -0
- package/dist/src/cli/commands/status.d.ts.map +1 -0
- package/dist/src/cli/commands/status.js +122 -0
- package/dist/src/cli/commands/status.js.map +1 -0
- package/dist/src/cli/commands/test.d.ts +23 -0
- package/dist/src/cli/commands/test.d.ts.map +1 -0
- package/dist/src/cli/commands/test.js +134 -0
- package/dist/src/cli/commands/test.js.map +1 -0
- package/dist/src/cli/commands/types.d.ts +81 -0
- package/dist/src/cli/commands/types.d.ts.map +1 -0
- package/dist/src/cli/commands/types.js +6 -0
- package/dist/src/cli/commands/types.js.map +1 -0
- package/dist/src/cli/index.d.ts +17 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +267 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/config/defaults.d.ts +20 -0
- package/dist/src/config/defaults.d.ts.map +1 -0
- package/dist/src/config/defaults.js +123 -0
- package/dist/src/config/defaults.js.map +1 -0
- package/dist/src/config/index.d.ts +8 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +41 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/config/loader.d.ts +99 -0
- package/dist/src/config/loader.d.ts.map +1 -0
- package/dist/src/config/loader.js +242 -0
- package/dist/src/config/loader.js.map +1 -0
- package/dist/src/config/schema.d.ts +627 -0
- package/dist/src/config/schema.d.ts.map +1 -0
- package/dist/src/config/schema.js +585 -0
- package/dist/src/config/schema.js.map +1 -0
- package/dist/src/detectors/destructive/cloud-detector.d.ts +51 -0
- package/dist/src/detectors/destructive/cloud-detector.d.ts.map +1 -0
- package/dist/src/detectors/destructive/cloud-detector.js +556 -0
- package/dist/src/detectors/destructive/cloud-detector.js.map +1 -0
- package/dist/src/detectors/destructive/code-detector.d.ts +59 -0
- package/dist/src/detectors/destructive/code-detector.d.ts.map +1 -0
- package/dist/src/detectors/destructive/code-detector.js +558 -0
- package/dist/src/detectors/destructive/code-detector.js.map +1 -0
- package/dist/src/detectors/destructive/index.d.ts +54 -0
- package/dist/src/detectors/destructive/index.d.ts.map +1 -0
- package/dist/src/detectors/destructive/index.js +168 -0
- package/dist/src/detectors/destructive/index.js.map +1 -0
- package/dist/src/detectors/destructive/shell-detector.d.ts +43 -0
- package/dist/src/detectors/destructive/shell-detector.d.ts.map +1 -0
- package/dist/src/detectors/destructive/shell-detector.js +302 -0
- package/dist/src/detectors/destructive/shell-detector.js.map +1 -0
- package/dist/src/detectors/destructive/types.d.ts +143 -0
- package/dist/src/detectors/destructive/types.d.ts.map +1 -0
- package/dist/src/detectors/destructive/types.js +6 -0
- package/dist/src/detectors/destructive/types.js.map +1 -0
- package/dist/src/detectors/exfiltration/cloud-detector.d.ts +51 -0
- package/dist/src/detectors/exfiltration/cloud-detector.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/cloud-detector.js +427 -0
- package/dist/src/detectors/exfiltration/cloud-detector.js.map +1 -0
- package/dist/src/detectors/exfiltration/http-detector.d.ts +47 -0
- package/dist/src/detectors/exfiltration/http-detector.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/http-detector.js +429 -0
- package/dist/src/detectors/exfiltration/http-detector.js.map +1 -0
- package/dist/src/detectors/exfiltration/index.d.ts +44 -0
- package/dist/src/detectors/exfiltration/index.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/index.js +118 -0
- package/dist/src/detectors/exfiltration/index.js.map +1 -0
- package/dist/src/detectors/exfiltration/network-detector.d.ts +55 -0
- package/dist/src/detectors/exfiltration/network-detector.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/network-detector.js +504 -0
- package/dist/src/detectors/exfiltration/network-detector.js.map +1 -0
- package/dist/src/detectors/exfiltration/types.d.ts +139 -0
- package/dist/src/detectors/exfiltration/types.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/types.js +6 -0
- package/dist/src/detectors/exfiltration/types.js.map +1 -0
- package/dist/src/detectors/purchase/domain-detector.d.ts +44 -0
- package/dist/src/detectors/purchase/domain-detector.d.ts.map +1 -0
- package/dist/src/detectors/purchase/domain-detector.js +296 -0
- package/dist/src/detectors/purchase/domain-detector.js.map +1 -0
- package/dist/src/detectors/purchase/form-detector.d.ts +27 -0
- package/dist/src/detectors/purchase/form-detector.d.ts.map +1 -0
- package/dist/src/detectors/purchase/form-detector.js +344 -0
- package/dist/src/detectors/purchase/form-detector.js.map +1 -0
- package/dist/src/detectors/purchase/index.d.ts +65 -0
- package/dist/src/detectors/purchase/index.d.ts.map +1 -0
- package/dist/src/detectors/purchase/index.js +216 -0
- package/dist/src/detectors/purchase/index.js.map +1 -0
- package/dist/src/detectors/purchase/spend-tracker.d.ts +132 -0
- package/dist/src/detectors/purchase/spend-tracker.d.ts.map +1 -0
- package/dist/src/detectors/purchase/spend-tracker.js +313 -0
- package/dist/src/detectors/purchase/spend-tracker.js.map +1 -0
- package/dist/src/detectors/purchase/types.d.ts +139 -0
- package/dist/src/detectors/purchase/types.d.ts.map +1 -0
- package/dist/src/detectors/purchase/types.js +6 -0
- package/dist/src/detectors/purchase/types.js.map +1 -0
- package/dist/src/detectors/purchase/url-detector.d.ts +31 -0
- package/dist/src/detectors/purchase/url-detector.d.ts.map +1 -0
- package/dist/src/detectors/purchase/url-detector.js +292 -0
- package/dist/src/detectors/purchase/url-detector.js.map +1 -0
- package/dist/src/detectors/secrets/api-key-detector.d.ts +30 -0
- package/dist/src/detectors/secrets/api-key-detector.d.ts.map +1 -0
- package/dist/src/detectors/secrets/api-key-detector.js +297 -0
- package/dist/src/detectors/secrets/api-key-detector.js.map +1 -0
- package/dist/src/detectors/secrets/index.d.ts +43 -0
- package/dist/src/detectors/secrets/index.d.ts.map +1 -0
- package/dist/src/detectors/secrets/index.js +261 -0
- package/dist/src/detectors/secrets/index.js.map +1 -0
- package/dist/src/detectors/secrets/pii-detector.d.ts +54 -0
- package/dist/src/detectors/secrets/pii-detector.d.ts.map +1 -0
- package/dist/src/detectors/secrets/pii-detector.js +286 -0
- package/dist/src/detectors/secrets/pii-detector.js.map +1 -0
- package/dist/src/detectors/secrets/token-detector.d.ts +51 -0
- package/dist/src/detectors/secrets/token-detector.d.ts.map +1 -0
- package/dist/src/detectors/secrets/token-detector.js +233 -0
- package/dist/src/detectors/secrets/token-detector.js.map +1 -0
- package/dist/src/detectors/secrets/types.d.ts +157 -0
- package/dist/src/detectors/secrets/types.d.ts.map +1 -0
- package/dist/src/detectors/secrets/types.js +6 -0
- package/dist/src/detectors/secrets/types.js.map +1 -0
- package/dist/src/detectors/website/category-detector.d.ts +22 -0
- package/dist/src/detectors/website/category-detector.d.ts.map +1 -0
- package/dist/src/detectors/website/category-detector.js +162 -0
- package/dist/src/detectors/website/category-detector.js.map +1 -0
- package/dist/src/detectors/website/index.d.ts +53 -0
- package/dist/src/detectors/website/index.d.ts.map +1 -0
- package/dist/src/detectors/website/index.js +232 -0
- package/dist/src/detectors/website/index.js.map +1 -0
- package/dist/src/detectors/website/pattern-matcher.d.ts +33 -0
- package/dist/src/detectors/website/pattern-matcher.d.ts.map +1 -0
- package/dist/src/detectors/website/pattern-matcher.js +121 -0
- package/dist/src/detectors/website/pattern-matcher.js.map +1 -0
- package/dist/src/detectors/website/types.d.ts +105 -0
- package/dist/src/detectors/website/types.d.ts.map +1 -0
- package/dist/src/detectors/website/types.js +6 -0
- package/dist/src/detectors/website/types.js.map +1 -0
- package/dist/src/engine/analyzer.d.ts +87 -0
- package/dist/src/engine/analyzer.d.ts.map +1 -0
- package/dist/src/engine/analyzer.js +427 -0
- package/dist/src/engine/analyzer.js.map +1 -0
- package/dist/src/engine/cache.d.ts +80 -0
- package/dist/src/engine/cache.d.ts.map +1 -0
- package/dist/src/engine/cache.js +167 -0
- package/dist/src/engine/cache.js.map +1 -0
- package/dist/src/engine/index.d.ts +11 -0
- package/dist/src/engine/index.d.ts.map +1 -0
- package/dist/src/engine/index.js +11 -0
- package/dist/src/engine/index.js.map +1 -0
- package/dist/src/engine/llm-client.d.ts +210 -0
- package/dist/src/engine/llm-client.d.ts.map +1 -0
- package/dist/src/engine/llm-client.js +506 -0
- package/dist/src/engine/llm-client.js.map +1 -0
- package/dist/src/engine/types.d.ts +163 -0
- package/dist/src/engine/types.d.ts.map +1 -0
- package/dist/src/engine/types.js +21 -0
- package/dist/src/engine/types.js.map +1 -0
- package/dist/src/feedback/index.d.ts +9 -0
- package/dist/src/feedback/index.d.ts.map +1 -0
- package/dist/src/feedback/index.js +8 -0
- package/dist/src/feedback/index.js.map +1 -0
- package/dist/src/feedback/learner.d.ts +222 -0
- package/dist/src/feedback/learner.d.ts.map +1 -0
- package/dist/src/feedback/learner.js +401 -0
- package/dist/src/feedback/learner.js.map +1 -0
- package/dist/src/feedback/store.d.ts +113 -0
- package/dist/src/feedback/store.d.ts.map +1 -0
- package/dist/src/feedback/store.js +228 -0
- package/dist/src/feedback/store.js.map +1 -0
- package/dist/src/feedback/types.d.ts +126 -0
- package/dist/src/feedback/types.d.ts.map +1 -0
- package/dist/src/feedback/types.js +6 -0
- package/dist/src/feedback/types.js.map +1 -0
- package/dist/src/hooks/before-agent-start/handler.d.ts +37 -0
- package/dist/src/hooks/before-agent-start/handler.d.ts.map +1 -0
- package/dist/src/hooks/before-agent-start/handler.js +109 -0
- package/dist/src/hooks/before-agent-start/handler.js.map +1 -0
- package/dist/src/hooks/before-agent-start/index.d.ts +8 -0
- package/dist/src/hooks/before-agent-start/index.d.ts.map +1 -0
- package/dist/src/hooks/before-agent-start/index.js +7 -0
- package/dist/src/hooks/before-agent-start/index.js.map +1 -0
- package/dist/src/hooks/before-agent-start/prompts.d.ts +48 -0
- package/dist/src/hooks/before-agent-start/prompts.d.ts.map +1 -0
- package/dist/src/hooks/before-agent-start/prompts.js +103 -0
- package/dist/src/hooks/before-agent-start/prompts.js.map +1 -0
- package/dist/src/hooks/before-tool-call/handler.d.ts +42 -0
- package/dist/src/hooks/before-tool-call/handler.d.ts.map +1 -0
- package/dist/src/hooks/before-tool-call/handler.js +226 -0
- package/dist/src/hooks/before-tool-call/handler.js.map +1 -0
- package/dist/src/hooks/before-tool-call/index.d.ts +7 -0
- package/dist/src/hooks/before-tool-call/index.d.ts.map +1 -0
- package/dist/src/hooks/before-tool-call/index.js +6 -0
- package/dist/src/hooks/before-tool-call/index.js.map +1 -0
- package/dist/src/hooks/tool-result-persist/filter.d.ts +72 -0
- package/dist/src/hooks/tool-result-persist/filter.d.ts.map +1 -0
- package/dist/src/hooks/tool-result-persist/filter.js +305 -0
- package/dist/src/hooks/tool-result-persist/filter.js.map +1 -0
- package/dist/src/hooks/tool-result-persist/handler.d.ts +49 -0
- package/dist/src/hooks/tool-result-persist/handler.d.ts.map +1 -0
- package/dist/src/hooks/tool-result-persist/handler.js +217 -0
- package/dist/src/hooks/tool-result-persist/handler.js.map +1 -0
- package/dist/src/hooks/tool-result-persist/index.d.ts +11 -0
- package/dist/src/hooks/tool-result-persist/index.d.ts.map +1 -0
- package/dist/src/hooks/tool-result-persist/index.js +11 -0
- package/dist/src/hooks/tool-result-persist/index.js.map +1 -0
- package/dist/src/index.d.ts +256 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +222 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/notifications/discord.d.ts +10 -0
- package/dist/src/notifications/discord.d.ts.map +1 -0
- package/dist/src/notifications/discord.js +218 -0
- package/dist/src/notifications/discord.js.map +1 -0
- package/dist/src/notifications/index.d.ts +37 -0
- package/dist/src/notifications/index.d.ts.map +1 -0
- package/dist/src/notifications/index.js +68 -0
- package/dist/src/notifications/index.js.map +1 -0
- package/dist/src/notifications/slack.d.ts +10 -0
- package/dist/src/notifications/slack.d.ts.map +1 -0
- package/dist/src/notifications/slack.js +218 -0
- package/dist/src/notifications/slack.js.map +1 -0
- package/dist/src/notifications/telegram.d.ts +10 -0
- package/dist/src/notifications/telegram.d.ts.map +1 -0
- package/dist/src/notifications/telegram.js +242 -0
- package/dist/src/notifications/telegram.js.map +1 -0
- package/dist/src/notifications/types.d.ts +119 -0
- package/dist/src/notifications/types.d.ts.map +1 -0
- package/dist/src/notifications/types.js +6 -0
- package/dist/src/notifications/types.js.map +1 -0
- package/dist/src/proxy/index.d.ts +8 -0
- package/dist/src/proxy/index.d.ts.map +1 -0
- package/dist/src/proxy/index.js +9 -0
- package/dist/src/proxy/index.js.map +1 -0
- package/dist/src/proxy/middleware.d.ts +55 -0
- package/dist/src/proxy/middleware.d.ts.map +1 -0
- package/dist/src/proxy/middleware.js +215 -0
- package/dist/src/proxy/middleware.js.map +1 -0
- package/dist/src/proxy/server.d.ts +57 -0
- package/dist/src/proxy/server.d.ts.map +1 -0
- package/dist/src/proxy/server.js +298 -0
- package/dist/src/proxy/server.js.map +1 -0
- package/dist/src/proxy/types.d.ts +136 -0
- package/dist/src/proxy/types.d.ts.map +1 -0
- package/dist/src/proxy/types.js +6 -0
- package/dist/src/proxy/types.js.map +1 -0
- package/dist/src/sanitization/index.d.ts +10 -0
- package/dist/src/sanitization/index.d.ts.map +1 -0
- package/dist/src/sanitization/index.js +9 -0
- package/dist/src/sanitization/index.js.map +1 -0
- package/dist/src/sanitization/patterns.d.ts +51 -0
- package/dist/src/sanitization/patterns.d.ts.map +1 -0
- package/dist/src/sanitization/patterns.js +266 -0
- package/dist/src/sanitization/patterns.js.map +1 -0
- package/dist/src/sanitization/scanner.d.ts +29 -0
- package/dist/src/sanitization/scanner.d.ts.map +1 -0
- package/dist/src/sanitization/scanner.js +328 -0
- package/dist/src/sanitization/scanner.js.map +1 -0
- package/dist/src/sanitization/types.d.ts +57 -0
- package/dist/src/sanitization/types.d.ts.map +1 -0
- package/dist/src/sanitization/types.js +5 -0
- package/dist/src/sanitization/types.js.map +1 -0
- package/openclaw.plugin.json +114 -0
- package/package.json +63 -0
- package/rules/builtin/README.md +139 -0
- package/rules/builtin/ai-services.yaml +70 -0
- package/rules/builtin/api-keys.yaml +64 -0
- package/rules/builtin/authentication.yaml +56 -0
- package/rules/builtin/aws-security.yaml +57 -0
- package/rules/builtin/azure-security.yaml +58 -0
- package/rules/builtin/cicd-security.yaml +64 -0
- package/rules/builtin/cloud-storage.yaml +64 -0
- package/rules/builtin/container-registry.yaml +55 -0
- package/rules/builtin/crypto-wallets.yaml +71 -0
- package/rules/builtin/database-nosql.yaml +58 -0
- package/rules/builtin/database-sql.yaml +62 -0
- package/rules/builtin/development-env.yaml +67 -0
- package/rules/builtin/docker.yaml +57 -0
- package/rules/builtin/filesystem.yaml +71 -0
- package/rules/builtin/financial-pci.yaml +61 -0
- package/rules/builtin/gcp-security.yaml +57 -0
- package/rules/builtin/git-operations.yaml +68 -0
- package/rules/builtin/healthcare-hipaa.yaml +64 -0
- package/rules/builtin/kubernetes.yaml +60 -0
- package/rules/builtin/messaging-services.yaml +53 -0
- package/rules/builtin/minimal.yaml +47 -0
- package/rules/builtin/mobile-development.yaml +61 -0
- package/rules/builtin/monitoring.yaml +63 -0
- package/rules/builtin/network-security.yaml +57 -0
- package/rules/builtin/package-managers.yaml +74 -0
- package/rules/builtin/payment-processing.yaml +66 -0
- package/rules/builtin/pii-protection.yaml +48 -0
- package/rules/builtin/production-strict.yaml +55 -0
- package/rules/builtin/secrets-management.yaml +63 -0
- package/rules/builtin/serverless.yaml +74 -0
- package/rules/builtin/ssh-security.yaml +66 -0
- package/rules/builtin/terraform.yaml +51 -0
- package/rules/builtin/web-security.yaml +62 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Executor Types
|
|
3
|
+
* Type definitions for the action execution system
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Default console logger implementation
|
|
7
|
+
*/
|
|
8
|
+
/* eslint-disable no-console */
|
|
9
|
+
export const consoleLogger = {
|
|
10
|
+
debug: (message, data) => {
|
|
11
|
+
if (data) {
|
|
12
|
+
console.debug(`[clawsec] ${message}`, data);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
console.debug(`[clawsec] ${message}`);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
info: (message, data) => {
|
|
19
|
+
if (data) {
|
|
20
|
+
console.info(`[clawsec] ${message}`, data);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
console.info(`[clawsec] ${message}`);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
warn: (message, data) => {
|
|
27
|
+
if (data) {
|
|
28
|
+
console.warn(`[clawsec] ${message}`, data);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.warn(`[clawsec] ${message}`);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
error: (message, data) => {
|
|
35
|
+
if (data) {
|
|
36
|
+
console.error(`[clawsec] ${message}`, data);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.error(`[clawsec] ${message}`);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
/* eslint-enable no-console */
|
|
44
|
+
/**
|
|
45
|
+
* No-op logger for testing or silent mode
|
|
46
|
+
*/
|
|
47
|
+
export const noOpLogger = {
|
|
48
|
+
debug: () => { },
|
|
49
|
+
info: () => { },
|
|
50
|
+
warn: () => { },
|
|
51
|
+
error: () => { },
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Create a logger based on log level
|
|
55
|
+
*/
|
|
56
|
+
export function createLogger(logLevel) {
|
|
57
|
+
const levels = ['debug', 'info', 'warn', 'error'];
|
|
58
|
+
const minLevel = levels.indexOf(logLevel);
|
|
59
|
+
return {
|
|
60
|
+
debug: (message, data) => {
|
|
61
|
+
if (minLevel <= 0)
|
|
62
|
+
consoleLogger.debug(message, data);
|
|
63
|
+
},
|
|
64
|
+
info: (message, data) => {
|
|
65
|
+
if (minLevel <= 1)
|
|
66
|
+
consoleLogger.info(message, data);
|
|
67
|
+
},
|
|
68
|
+
warn: (message, data) => {
|
|
69
|
+
if (minLevel <= 2)
|
|
70
|
+
consoleLogger.warn(message, data);
|
|
71
|
+
},
|
|
72
|
+
error: (message, data) => {
|
|
73
|
+
if (minLevel <= 3)
|
|
74
|
+
consoleLogger.error(message, data);
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/actions/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8EH;;GAEG;AACH,+BAA+B;AAC/B,MAAM,CAAC,MAAM,aAAa,GAAiB;IACzC,KAAK,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;QACvB,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,CAAC,KAAK,CAAC,aAAa,OAAO,EAA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AM,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE1C,OAAO;QACL,KAAK,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAQ,EAAE;YAC/D,IAAI,QAAQ,IAAI,CAAC;gBAAE,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAQ,EAAE;YAC9D,IAAI,QAAQ,IAAI,CAAC;gBAAE,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAQ,EAAE;YAC9D,IAAI,QAAQ,IAAI,CAAC;gBAAE,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACvD,CAAC;QACD,KAAK,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAQ,EAAE;YAC/D,IAAI,QAAQ,IAAI,CAAC;gBAAE,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACxD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Warn Action Handler
|
|
3
|
+
* Handles warning about potentially risky tool calls while still allowing them
|
|
4
|
+
*/
|
|
5
|
+
import type { ActionContext, ActionHandler, ActionResult, ActionLogger } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generate a warning message about the detected threat
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateWarnMessage(context: ActionContext): string;
|
|
10
|
+
/**
|
|
11
|
+
* Warn action handler implementation
|
|
12
|
+
*/
|
|
13
|
+
export declare class WarnHandler implements ActionHandler {
|
|
14
|
+
private logger;
|
|
15
|
+
constructor(logger?: ActionLogger);
|
|
16
|
+
execute(context: ActionContext): Promise<ActionResult>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a warn action handler with the given logger
|
|
20
|
+
*/
|
|
21
|
+
export declare function createWarnHandler(logger?: ActionLogger): WarnHandler;
|
|
22
|
+
//# sourceMappingURL=warn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn.d.ts","sourceRoot":"","sources":["../../../src/actions/warn.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAwB3F;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CA4BlE;AAED;;GAEG;AACH,qBAAa,WAAY,YAAW,aAAa;IAC/C,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,GAAE,YAAyB;IAIvC,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CAmB7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW,CAEpE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Warn Action Handler
|
|
3
|
+
* Handles warning about potentially risky tool calls while still allowing them
|
|
4
|
+
*/
|
|
5
|
+
import { noOpLogger } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Format a severity level for display
|
|
8
|
+
*/
|
|
9
|
+
function formatSeverity(severity) {
|
|
10
|
+
return severity.toUpperCase();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Format a threat category for display
|
|
14
|
+
*/
|
|
15
|
+
function formatCategory(category) {
|
|
16
|
+
const categoryNames = {
|
|
17
|
+
purchase: 'Purchase/Payment',
|
|
18
|
+
website: 'Website Access',
|
|
19
|
+
destructive: 'Destructive Command',
|
|
20
|
+
secrets: 'Secrets/PII',
|
|
21
|
+
exfiltration: 'Data Transfer',
|
|
22
|
+
};
|
|
23
|
+
return categoryNames[category] || category;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generate a warning message about the detected threat
|
|
27
|
+
*/
|
|
28
|
+
export function generateWarnMessage(context) {
|
|
29
|
+
const { analysis, toolCall } = context;
|
|
30
|
+
const { primaryDetection, detections } = analysis;
|
|
31
|
+
if (!primaryDetection) {
|
|
32
|
+
return `Warning: ${toolCall.toolName} executed with security notice.`;
|
|
33
|
+
}
|
|
34
|
+
const category = formatCategory(primaryDetection.category);
|
|
35
|
+
const severity = formatSeverity(primaryDetection.severity);
|
|
36
|
+
const reason = primaryDetection.reason;
|
|
37
|
+
let message = `[${severity}] Warning: ${category} detected\n`;
|
|
38
|
+
message += `Tool: ${toolCall.toolName}\n`;
|
|
39
|
+
message += `Reason: ${reason}\n`;
|
|
40
|
+
message += `\nAction allowed but logged for audit.`;
|
|
41
|
+
// Include additional detections if any
|
|
42
|
+
if (detections.length > 1) {
|
|
43
|
+
message += `\n\nAdditional warnings (${detections.length - 1}):`;
|
|
44
|
+
for (const detection of detections) {
|
|
45
|
+
if (detection !== primaryDetection) {
|
|
46
|
+
message += `\n- ${formatCategory(detection.category)}: ${detection.reason}`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return message;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Warn action handler implementation
|
|
54
|
+
*/
|
|
55
|
+
export class WarnHandler {
|
|
56
|
+
logger;
|
|
57
|
+
constructor(logger = noOpLogger) {
|
|
58
|
+
this.logger = logger;
|
|
59
|
+
}
|
|
60
|
+
async execute(context) {
|
|
61
|
+
const { analysis, toolCall } = context;
|
|
62
|
+
const message = generateWarnMessage(context);
|
|
63
|
+
// Log the warning
|
|
64
|
+
this.logger.warn('Action executed with warning', {
|
|
65
|
+
toolName: toolCall.toolName,
|
|
66
|
+
category: analysis.primaryDetection?.category,
|
|
67
|
+
severity: analysis.primaryDetection?.severity,
|
|
68
|
+
reason: analysis.primaryDetection?.reason,
|
|
69
|
+
detectionCount: analysis.detections.length,
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
allowed: true,
|
|
73
|
+
message,
|
|
74
|
+
logged: true,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create a warn action handler with the given logger
|
|
80
|
+
*/
|
|
81
|
+
export function createWarnHandler(logger) {
|
|
82
|
+
return new WarnHandler(logger);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=warn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn.js","sourceRoot":"","sources":["../../../src/actions/warn.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC;;GAEG;AACH,SAAS,cAAc,CAAC,QAAgB;IACtC,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,QAAgB;IACtC,MAAM,aAAa,GAA2B;QAC5C,QAAQ,EAAE,kBAAkB;QAC5B,OAAO,EAAE,gBAAgB;QACzB,WAAW,EAAE,qBAAqB;QAClC,OAAO,EAAE,aAAa;QACtB,YAAY,EAAE,eAAe;KAC9B,CAAC;IACF,OAAO,aAAa,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAsB;IACxD,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;IAElD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,YAAY,QAAQ,CAAC,QAAQ,iCAAiC,CAAC;IACxE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C,gBAAgB,EAAE,QAAQ;YAC7C,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,EAAE,QAAQ;YAC7C,MAAM,EAAE,QAAQ,CAAC,gBAAgB,EAAE,MAAM;YACzC,cAAc,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM;SAC3C,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO;YACP,MAAM,EAAE,IAAI;SACb,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAqB;IACrD,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Confirm Handler
|
|
3
|
+
* Handles agent-side confirmation via _clawsec_confirm parameter
|
|
4
|
+
*
|
|
5
|
+
* When a tool call is flagged for confirmation, the agent can acknowledge
|
|
6
|
+
* the risk by retrying the call with a _clawsec_confirm parameter set to
|
|
7
|
+
* the approval ID.
|
|
8
|
+
*/
|
|
9
|
+
import type { ApprovalStore } from './types.js';
|
|
10
|
+
/** Default parameter name for agent confirmation */
|
|
11
|
+
export declare const DEFAULT_CONFIRM_PARAMETER = "_clawsec_confirm";
|
|
12
|
+
/**
|
|
13
|
+
* Result of checking for agent confirmation
|
|
14
|
+
*/
|
|
15
|
+
export interface AgentConfirmResult {
|
|
16
|
+
/** Whether the tool input contains a confirmation parameter */
|
|
17
|
+
confirmed: boolean;
|
|
18
|
+
/** The approval ID from the confirmation parameter */
|
|
19
|
+
approvalId?: string;
|
|
20
|
+
/** Whether the approval ID is valid and the approval can proceed */
|
|
21
|
+
valid: boolean;
|
|
22
|
+
/** Error message if confirmation is invalid */
|
|
23
|
+
error?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Interface for the agent confirm handler
|
|
27
|
+
*/
|
|
28
|
+
export interface AgentConfirmHandler {
|
|
29
|
+
/**
|
|
30
|
+
* Check if tool input contains a valid confirmation
|
|
31
|
+
* @param toolInput - The tool input object
|
|
32
|
+
* @param parameterName - Custom parameter name (defaults to _clawsec_confirm)
|
|
33
|
+
* @returns Result indicating if confirmation is present and valid
|
|
34
|
+
*/
|
|
35
|
+
checkConfirmation(toolInput: Record<string, unknown>, parameterName?: string): AgentConfirmResult;
|
|
36
|
+
/**
|
|
37
|
+
* Remove the confirm parameter from tool input for clean execution
|
|
38
|
+
* @param toolInput - The tool input object
|
|
39
|
+
* @param parameterName - Custom parameter name (defaults to _clawsec_confirm)
|
|
40
|
+
* @returns Tool input without the confirm parameter
|
|
41
|
+
*/
|
|
42
|
+
stripConfirmParameter(toolInput: Record<string, unknown>, parameterName?: string): Record<string, unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* Process agent confirmation: validate and approve if valid
|
|
45
|
+
* @param toolInput - The tool input object
|
|
46
|
+
* @param parameterName - Custom parameter name (defaults to _clawsec_confirm)
|
|
47
|
+
* @returns Result indicating if confirmation succeeded
|
|
48
|
+
*/
|
|
49
|
+
processConfirmation(toolInput: Record<string, unknown>, parameterName?: string): AgentConfirmResult;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Configuration for the agent confirm handler
|
|
53
|
+
*/
|
|
54
|
+
export interface AgentConfirmHandlerConfig {
|
|
55
|
+
/** The approval store to use (defaults to the default singleton) */
|
|
56
|
+
store?: ApprovalStore;
|
|
57
|
+
/** Whether agent confirmation is enabled */
|
|
58
|
+
enabled?: boolean;
|
|
59
|
+
/** Custom parameter name for confirmation */
|
|
60
|
+
parameterName?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Default implementation of the agent confirm handler
|
|
64
|
+
*/
|
|
65
|
+
export declare class DefaultAgentConfirmHandler implements AgentConfirmHandler {
|
|
66
|
+
private store;
|
|
67
|
+
private enabled;
|
|
68
|
+
private defaultParameterName;
|
|
69
|
+
constructor(config?: AgentConfirmHandlerConfig);
|
|
70
|
+
/**
|
|
71
|
+
* Check if tool input contains a valid confirmation
|
|
72
|
+
*/
|
|
73
|
+
checkConfirmation(toolInput: Record<string, unknown>, parameterName?: string): AgentConfirmResult;
|
|
74
|
+
/**
|
|
75
|
+
* Remove the confirm parameter from tool input
|
|
76
|
+
*/
|
|
77
|
+
stripConfirmParameter(toolInput: Record<string, unknown>, parameterName?: string): Record<string, unknown>;
|
|
78
|
+
/**
|
|
79
|
+
* Process agent confirmation: validate and approve if valid
|
|
80
|
+
* This combines checkConfirmation with actually approving the record
|
|
81
|
+
*/
|
|
82
|
+
processConfirmation(toolInput: Record<string, unknown>, parameterName?: string): AgentConfirmResult;
|
|
83
|
+
/**
|
|
84
|
+
* Check if agent confirmation is enabled
|
|
85
|
+
*/
|
|
86
|
+
isEnabled(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Get the default parameter name
|
|
89
|
+
*/
|
|
90
|
+
getParameterName(): string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create an agent confirm handler with the given configuration
|
|
94
|
+
*/
|
|
95
|
+
export declare function createAgentConfirmHandler(config?: AgentConfirmHandlerConfig): DefaultAgentConfirmHandler;
|
|
96
|
+
/**
|
|
97
|
+
* Get the default agent confirm handler singleton
|
|
98
|
+
*/
|
|
99
|
+
export declare function getDefaultAgentConfirmHandler(): DefaultAgentConfirmHandler;
|
|
100
|
+
/**
|
|
101
|
+
* Reset the default handler (mainly for testing)
|
|
102
|
+
*/
|
|
103
|
+
export declare function resetDefaultAgentConfirmHandler(): void;
|
|
104
|
+
//# sourceMappingURL=agent-confirm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-confirm.d.ts","sourceRoot":"","sources":["../../../src/approval/agent-confirm.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,oDAAoD;AACpD,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAE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CACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAY1B;;;OAGG;IACH,mBAAmB,CACjB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,aAAa,CAAC,EAAE,MAAM,GACrB,kBAAkB;IA4BrB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,gBAAgB,IAAI,MAAM;CAG3B;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,CAAC,EAAE,yBAAyB,GACjC,0BAA0B,CAE5B;AAOD;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,0BAA0B,CAK1E;AAED;;GAEG;AACH,wBAAgB,+BAA+B,IAAI,IAAI,CAEtD"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Confirm Handler
|
|
3
|
+
* Handles agent-side confirmation via _clawsec_confirm parameter
|
|
4
|
+
*
|
|
5
|
+
* When a tool call is flagged for confirmation, the agent can acknowledge
|
|
6
|
+
* the risk by retrying the call with a _clawsec_confirm parameter set to
|
|
7
|
+
* the approval ID.
|
|
8
|
+
*/
|
|
9
|
+
import { getDefaultApprovalStore } from './store.js';
|
|
10
|
+
/** Default parameter name for agent confirmation */
|
|
11
|
+
export const DEFAULT_CONFIRM_PARAMETER = '_clawsec_confirm';
|
|
12
|
+
/**
|
|
13
|
+
* Default implementation of the agent confirm handler
|
|
14
|
+
*/
|
|
15
|
+
export class DefaultAgentConfirmHandler {
|
|
16
|
+
store;
|
|
17
|
+
enabled;
|
|
18
|
+
defaultParameterName;
|
|
19
|
+
constructor(config = {}) {
|
|
20
|
+
this.store = config.store ?? getDefaultApprovalStore();
|
|
21
|
+
this.enabled = config.enabled ?? true;
|
|
22
|
+
this.defaultParameterName = config.parameterName ?? DEFAULT_CONFIRM_PARAMETER;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if tool input contains a valid confirmation
|
|
26
|
+
*/
|
|
27
|
+
checkConfirmation(toolInput, parameterName) {
|
|
28
|
+
const paramName = parameterName ?? this.defaultParameterName;
|
|
29
|
+
// Check if confirmation is disabled
|
|
30
|
+
if (!this.enabled) {
|
|
31
|
+
return {
|
|
32
|
+
confirmed: false,
|
|
33
|
+
valid: false,
|
|
34
|
+
error: 'Agent confirmation is disabled',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
// Check if parameter exists
|
|
38
|
+
if (!(paramName in toolInput)) {
|
|
39
|
+
return {
|
|
40
|
+
confirmed: false,
|
|
41
|
+
valid: false,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const approvalId = toolInput[paramName];
|
|
45
|
+
// Validate the approval ID is a non-empty string
|
|
46
|
+
if (typeof approvalId !== 'string' || approvalId.trim() === '') {
|
|
47
|
+
return {
|
|
48
|
+
confirmed: true,
|
|
49
|
+
valid: false,
|
|
50
|
+
error: 'Invalid approval ID: must be a non-empty string',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const trimmedId = approvalId.trim();
|
|
54
|
+
// Look up the approval record
|
|
55
|
+
const record = this.store.get(trimmedId);
|
|
56
|
+
if (!record) {
|
|
57
|
+
return {
|
|
58
|
+
confirmed: true,
|
|
59
|
+
approvalId: trimmedId,
|
|
60
|
+
valid: false,
|
|
61
|
+
error: `Approval not found: No pending approval with ID "${trimmedId}"`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// Check the record status
|
|
65
|
+
if (record.status === 'expired') {
|
|
66
|
+
return {
|
|
67
|
+
confirmed: true,
|
|
68
|
+
approvalId: trimmedId,
|
|
69
|
+
valid: false,
|
|
70
|
+
error: `Approval expired: The approval "${trimmedId}" has expired`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (record.status === 'approved') {
|
|
74
|
+
return {
|
|
75
|
+
confirmed: true,
|
|
76
|
+
approvalId: trimmedId,
|
|
77
|
+
valid: false,
|
|
78
|
+
error: `Already approved: The approval "${trimmedId}" was already approved`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (record.status === 'denied') {
|
|
82
|
+
return {
|
|
83
|
+
confirmed: true,
|
|
84
|
+
approvalId: trimmedId,
|
|
85
|
+
valid: false,
|
|
86
|
+
error: `Already denied: The approval "${trimmedId}" was denied`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// Valid pending approval
|
|
90
|
+
return {
|
|
91
|
+
confirmed: true,
|
|
92
|
+
approvalId: trimmedId,
|
|
93
|
+
valid: true,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Remove the confirm parameter from tool input
|
|
98
|
+
*/
|
|
99
|
+
stripConfirmParameter(toolInput, parameterName) {
|
|
100
|
+
const paramName = parameterName ?? this.defaultParameterName;
|
|
101
|
+
if (!(paramName in toolInput)) {
|
|
102
|
+
return toolInput;
|
|
103
|
+
}
|
|
104
|
+
// Create a shallow copy without the confirm parameter
|
|
105
|
+
const { [paramName]: _, ...cleanedInput } = toolInput;
|
|
106
|
+
return cleanedInput;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Process agent confirmation: validate and approve if valid
|
|
110
|
+
* This combines checkConfirmation with actually approving the record
|
|
111
|
+
*/
|
|
112
|
+
processConfirmation(toolInput, parameterName) {
|
|
113
|
+
const result = this.checkConfirmation(toolInput, parameterName);
|
|
114
|
+
// If not valid, return the check result as-is
|
|
115
|
+
if (!result.valid || !result.approvalId) {
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
// Attempt to approve the record
|
|
119
|
+
const success = this.store.approve(result.approvalId, 'agent');
|
|
120
|
+
if (!success) {
|
|
121
|
+
// This could happen if the record expired between check and approve
|
|
122
|
+
return {
|
|
123
|
+
confirmed: true,
|
|
124
|
+
approvalId: result.approvalId,
|
|
125
|
+
valid: false,
|
|
126
|
+
error: `Failed to approve: Unable to approve "${result.approvalId}"`,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
confirmed: true,
|
|
131
|
+
approvalId: result.approvalId,
|
|
132
|
+
valid: true,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Check if agent confirmation is enabled
|
|
137
|
+
*/
|
|
138
|
+
isEnabled() {
|
|
139
|
+
return this.enabled;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get the default parameter name
|
|
143
|
+
*/
|
|
144
|
+
getParameterName() {
|
|
145
|
+
return this.defaultParameterName;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Create an agent confirm handler with the given configuration
|
|
150
|
+
*/
|
|
151
|
+
export function createAgentConfirmHandler(config) {
|
|
152
|
+
return new DefaultAgentConfirmHandler(config);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Default singleton handler instance
|
|
156
|
+
*/
|
|
157
|
+
let defaultHandler = null;
|
|
158
|
+
/**
|
|
159
|
+
* Get the default agent confirm handler singleton
|
|
160
|
+
*/
|
|
161
|
+
export function getDefaultAgentConfirmHandler() {
|
|
162
|
+
if (!defaultHandler) {
|
|
163
|
+
defaultHandler = createAgentConfirmHandler();
|
|
164
|
+
}
|
|
165
|
+
return defaultHandler;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Reset the default handler (mainly for testing)
|
|
169
|
+
*/
|
|
170
|
+
export function resetDefaultAgentConfirmHandler() {
|
|
171
|
+
defaultHandler = null;
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=agent-confirm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-confirm.js","sourceRoot":"","sources":["../../../src/approval/agent-confirm.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,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B,cAAc,GAAG,yBAAyB,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,+BAA+B;IAC7C,cAAc,GAAG,IAAI,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approval Module
|
|
3
|
+
* Re-exports for the approval system
|
|
4
|
+
*/
|
|
5
|
+
export type { ApprovalStatus, PendingApprovalRecord, PendingApprovalInput, ApprovalStore, ApprovalResult, NativeApprovalHandler, } from './types.js';
|
|
6
|
+
export type { ApprovalStoreConfig } from './store.js';
|
|
7
|
+
export { InMemoryApprovalStore, createApprovalStore, getDefaultApprovalStore, resetDefaultApprovalStore, } from './store.js';
|
|
8
|
+
export type { NativeApprovalHandlerConfig } from './native.js';
|
|
9
|
+
export { DefaultNativeApprovalHandler, createNativeApprovalHandler, getDefaultNativeApprovalHandler, resetDefaultNativeApprovalHandler, } from './native.js';
|
|
10
|
+
export type { AgentConfirmResult, AgentConfirmHandler, AgentConfirmHandlerConfig, } from './agent-confirm.js';
|
|
11
|
+
export { DEFAULT_CONFIRM_PARAMETER, DefaultAgentConfirmHandler, createAgentConfirmHandler, getDefaultAgentConfirmHandler, resetDefaultAgentConfirmHandler, } from './agent-confirm.js';
|
|
12
|
+
export type { WebhookApprovalRequest, WebhookApprovalResponse, WebhookApprovalResult, WebhookApprovalClient, HttpClient, HttpResponse, WebhookApprovalClientConfig, } from './webhook.js';
|
|
13
|
+
export { FetchHttpClient, DefaultWebhookApprovalClient, createWebhookApprovalClient, getDefaultWebhookApprovalClient, configureDefaultWebhookApprovalClient, resetDefaultWebhookApprovalClient, createWebhookRequest, } from './webhook.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/approval/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,EAC3B,+BAA+B,EAC/B,iCAAiC,GAClC,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,6BAA6B,EAC7B,+BAA+B,GAChC,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,2BAA2B,EAC3B,+BAA+B,EAC/B,qCAAqC,EACrC,iCAAiC,EACjC,oBAAoB,GACrB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approval Module
|
|
3
|
+
* Re-exports for the approval system
|
|
4
|
+
*/
|
|
5
|
+
export { InMemoryApprovalStore, createApprovalStore, getDefaultApprovalStore, resetDefaultApprovalStore, } from './store.js';
|
|
6
|
+
export { DefaultNativeApprovalHandler, createNativeApprovalHandler, getDefaultNativeApprovalHandler, resetDefaultNativeApprovalHandler, } from './native.js';
|
|
7
|
+
export { DEFAULT_CONFIRM_PARAMETER, DefaultAgentConfirmHandler, createAgentConfirmHandler, getDefaultAgentConfirmHandler, resetDefaultAgentConfirmHandler, } from './agent-confirm.js';
|
|
8
|
+
export { FetchHttpClient, DefaultWebhookApprovalClient, createWebhookApprovalClient, getDefaultWebhookApprovalClient, configureDefaultWebhookApprovalClient, resetDefaultWebhookApprovalClient, createWebhookRequest, } from './webhook.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/approval/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAIpB,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,EAC3B,+BAA+B,EAC/B,iCAAiC,GAClC,MAAM,aAAa,CAAC;AAQrB,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,6BAA6B,EAC7B,+BAA+B,GAChC,MAAM,oBAAoB,CAAC;AAY5B,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,2BAA2B,EAC3B,+BAA+B,EAC/B,qCAAqC,EACrC,iCAAiC,EACjC,oBAAoB,GACrB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native Approval Handler
|
|
3
|
+
* Handles the /approve and /deny commands for OpenClaw native approval flow
|
|
4
|
+
*/
|
|
5
|
+
import type { ApprovalResult, NativeApprovalHandler, PendingApprovalRecord, ApprovalStore } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for the native approval handler
|
|
8
|
+
*/
|
|
9
|
+
export interface NativeApprovalHandlerConfig {
|
|
10
|
+
/** The approval store to use (defaults to the default singleton) */
|
|
11
|
+
store?: ApprovalStore;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Default implementation of the native approval handler
|
|
15
|
+
*/
|
|
16
|
+
export declare class DefaultNativeApprovalHandler implements NativeApprovalHandler {
|
|
17
|
+
private store;
|
|
18
|
+
constructor(config?: NativeApprovalHandlerConfig);
|
|
19
|
+
/**
|
|
20
|
+
* Handle an /approve command
|
|
21
|
+
*/
|
|
22
|
+
handleApprove(id: string, userId?: string): ApprovalResult;
|
|
23
|
+
/**
|
|
24
|
+
* Handle a deny/reject command
|
|
25
|
+
*/
|
|
26
|
+
handleDeny(id: string): ApprovalResult;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a specific approval has been granted
|
|
29
|
+
*/
|
|
30
|
+
isApproved(id: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Get all pending approval records
|
|
33
|
+
*/
|
|
34
|
+
getPendingApprovals(): PendingApprovalRecord[];
|
|
35
|
+
/**
|
|
36
|
+
* Format a success message for an approved action
|
|
37
|
+
*/
|
|
38
|
+
private formatApprovalMessage;
|
|
39
|
+
/**
|
|
40
|
+
* Format a threat category for display
|
|
41
|
+
*/
|
|
42
|
+
private formatCategory;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a native approval handler with the given configuration
|
|
46
|
+
*/
|
|
47
|
+
export declare function createNativeApprovalHandler(config?: NativeApprovalHandlerConfig): DefaultNativeApprovalHandler;
|
|
48
|
+
/**
|
|
49
|
+
* Get the default native approval handler singleton
|
|
50
|
+
*/
|
|
51
|
+
export declare function getDefaultNativeApprovalHandler(): DefaultNativeApprovalHandler;
|
|
52
|
+
/**
|
|
53
|
+
* Reset the default handler (mainly for testing)
|
|
54
|
+
*/
|
|
55
|
+
export declare function resetDefaultNativeApprovalHandler(): void;
|
|
56
|
+
//# sourceMappingURL=native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/approval/native.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACd,MAAM,YAAY,CAAC;AAGpB;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,oEAAoE;IACpE,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED;;GAEG;AACH,qBAAa,4BAA6B,YAAW,qBAAqB;IACxE,OAAO,CAAC,KAAK,CAAgB;gBAEjB,MAAM,GAAE,2BAAgC;IAIpD;;OAEG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc;IAoE1D;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc;IAmEtC;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAS/B;;OAEG;IACH,mBAAmB,IAAI,qBAAqB,EAAE;IAI9C;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAO7B;;OAEG;IACH,OAAO,CAAC,cAAc;CAUvB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,CAAC,EAAE,2BAA2B,GACnC,4BAA4B,CAE9B;AAOD;;GAEG;AACH,wBAAgB,+BAA+B,IAAI,4BAA4B,CAK9E;AAED;;GAEG;AACH,wBAAgB,iCAAiC,IAAI,IAAI,CAExD"}
|