securityclaw 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.2] - 2026-03-17
4
+
5
+ ### Changed
6
+ - Simplified the README install section to focus on product overview plus remote install and uninstall flows.
7
+ - Clarified that published npm releases ship with a prebuilt admin frontend bundle.
8
+ - Prevented admin build tooling from being shipped as runtime npm dependencies.
9
+ - Avoided auto-opening the dashboard from short-lived gateway service commands before the persistent admin backend is ready.
10
+
3
11
  ## [0.1.0] - 2026-03-15
4
12
 
5
13
  ### 架构重构
package/README.md CHANGED
@@ -6,112 +6,59 @@ SecurityClaw is a runtime security plugin for [OpenClaw](https://github.com/open
6
6
 
7
7
  ## Why SecurityClaw
8
8
 
9
- LLM agents can execute powerful tools. SecurityClaw provides a policy guardrail layer so risky operations are either blocked, challenged for approval, or allowed with warning and traceability.
9
+ LLM agents can execute powerful tools. SecurityClaw adds a rule-first guardrail layer so risky operations are blocked, challenged for approval, or allowed with warning and traceability.
10
10
 
11
11
  ## Core Capabilities
12
12
 
13
13
  - Runtime policy enforcement for OpenClaw hooks (`before_tool_call`, `after_tool_call`, etc.)
14
14
  - Rule-first security model (`allow`, `warn`, `challenge`, `block`)
15
15
  - Challenge approval workflow with command-based admin handling
16
- - Dynamic sensitive-path registry that maps paths to asset labels before rule evaluation
17
- - Sensitive data scanning and sanitization (DLP)
18
- - Admin dashboard for strategy and account policy operations
19
- - Decision events for audit and observability
20
- - Built-in internationalization (`en` and `zh-CN`) for runtime/admin text
16
+ - Dynamic sensitive-path registry and DLP sanitization
17
+ - Admin dashboard for strategy, account policy, and runtime status
18
+ - Built-in internationalization (`en` and `zh-CN`) for runtime and admin text
21
19
 
22
- ## Architecture
20
+ ## Install
23
21
 
24
- SecurityClaw follows a layered architecture:
25
-
26
- - `domain`: policy, approval, context inference, formatting
27
- - `domain/services/sensitive_path_registry.ts`: built-in + runtime-overridden sensitive path mappings
28
- - `engine`: rule matching, decisioning, DLP scanning
29
- - `config`: base YAML + SQLite runtime override
30
- - `admin`: dashboard backend + frontend
31
- - `monitoring`: runtime status and decision snapshots
32
-
33
- See [Architecture](./docs/ARCHITECTURE.md) and [Technical Solution](./docs/TECHNICAL_SOLUTION.md).
34
-
35
- ## Quick Start
36
-
37
- ### 1. Install dependencies
22
+ Install the latest published release:
38
23
 
39
24
  ```bash
40
- npm install
25
+ npx securityclaw install
41
26
  ```
42
27
 
43
- ### 2. Install into OpenClaw
28
+ Or install through the remote script:
44
29
 
45
30
  ```bash
46
- npm run openclaw:install
31
+ curl -fsSL https://raw.githubusercontent.com/znary/securityclaw/main/install.sh | bash
47
32
  ```
48
33
 
49
- Alternative install paths for end users:
34
+ Install a specific published version:
50
35
 
51
36
  ```bash
52
- npx securityclaw install
53
- curl -fsSL https://raw.githubusercontent.com/znary/securityclaw/main/install.sh | bash
37
+ SECURITYCLAW_VERSION=0.0.2 curl -fsSL https://raw.githubusercontent.com/znary/securityclaw/main/install.sh | bash
54
38
  ```
55
39
 
56
- ### 3. Run verification
40
+ Published npm releases already include the prebuilt admin frontend bundle, so end-user installs do not rebuild the dashboard during plugin installation.
57
41
 
58
- ```bash
59
- npm test
60
- ```
42
+ ## Uninstall
61
43
 
62
- ### 4. Start admin dashboard (standalone)
44
+ Remove the installed plugin from OpenClaw:
63
45
 
64
46
  ```bash
65
- npm run admin
47
+ openclaw plugins uninstall securityclaw
66
48
  ```
67
49
 
68
- Default dashboard URL: `http://127.0.0.1:4780`
69
-
70
- ## OpenClaw Integration
71
-
72
- Preferred local install:
50
+ If you want to preview the removal first:
73
51
 
74
52
  ```bash
75
- npm run openclaw:install
53
+ openclaw plugins uninstall securityclaw --dry-run
76
54
  ```
77
55
 
78
- This creates a versioned plugin archive, installs it through `openclaw plugins install`, restarts the gateway, and verifies gateway health.
79
- See [OpenClaw Install Guide](./docs/OPENCLAW_INSTALL.md) for details.
80
-
81
- ## Approval Commands
82
-
83
- After setting one account policy with `is_admin=true`, the admin can run:
56
+ After install or uninstall, restart or verify the gateway if needed:
84
57
 
85
- - `/securityclaw-approve <approval_id>`
86
- - `/securityclaw-approve <approval_id> long`
87
- - `/securityclaw-reject <approval_id>`
88
- - `/securityclaw-pending`
89
-
90
- ## Admin Dashboard
91
-
92
- Dashboard supports English and Chinese UI switching and stores language preference in local storage.
93
- By default, it follows the host system language.
94
-
95
- Main panels:
96
-
97
- - Overview: posture and trend signals, plus a skill-risk snapshot for high-priority installed skills
98
- - Decisions: recent decision events and reasons
99
- - Policies: grouped rule strategy controls plus sensitive-path registry management
100
- - Skill Interception: installed skill inventory, risk scoring, undeclared-change detection, rescan/quarantine/trust override actions, and interception policy matrix
101
- - Accounts: admin approver account selection and mode settings
102
-
103
- Sensitive path registry behavior:
104
-
105
- - Built-in path patterns cover credentials, personal content, download staging, browser profiles, browser secret stores, and communication stores.
106
- - Registry entries are persisted in SQLite runtime strategy overrides together with rule decisions.
107
- - Built-in entries can be disabled from the dashboard, and custom path rules can be added without editing the base YAML.
108
-
109
- Skill interception behavior:
110
-
111
- - Dashboard discovers installed skills from local OpenClaw / Codex skill roots and stores scan results in SQLite.
112
- - A skill can be flagged when its content changes without a matching version update.
113
- - Overview surfaces the most important skill signals directly so admins can see high-risk items without switching tabs.
114
- - The dedicated Skill Interception panel supports rescan, quarantine, temporary trust override, and risk-matrix editing.
58
+ ```bash
59
+ openclaw gateway restart
60
+ openclaw gateway status
61
+ ```
115
62
 
116
63
  ## Documentation
117
64
 
@@ -121,15 +68,6 @@ Skill interception behavior:
121
68
  - [Runbook](./docs/RUNBOOK.md)
122
69
  - [Integration Guide](./docs/INTEGRATION_GUIDE.md)
123
70
 
124
- ## Development
125
-
126
- ```bash
127
- npm run typecheck
128
- npm run test:unit
129
- npm test
130
- npm run admin:build
131
- ```
132
-
133
71
  ## License
134
72
 
135
73
  MIT. See [LICENSE](./LICENSE).
package/README.zh-CN.md CHANGED
@@ -6,112 +6,59 @@ SecurityClaw 是面向 [OpenClaw](https://github.com/openclaw/openclaw) 的运
6
6
 
7
7
  ## SecurityClaw 解决什么问题
8
8
 
9
- LLM Agent 具备高权限工具调用能力。SecurityClaw 在运行时提供策略护栏,将高风险操作按规则执行为拦截、审批确认、提醒或放行,并保留可追溯审计信息。
9
+ LLM Agent 具备高权限工具调用能力。SecurityClaw 提供一层规则优先的安全护栏,让高风险操作被阻止、进入审批,或在留痕前提下放行。
10
10
 
11
11
  ## 核心能力
12
12
 
13
- - 基于 OpenClaw Hook 的运行时策略执行(`before_tool_call` 等)
13
+ - 基于 OpenClaw Hook 的运行时策略执行(`before_tool_call`、`after_tool_call` 等)
14
14
  - 规则优先决策模型(`allow` / `warn` / `challenge` / `block`)
15
- - Challenge 审批流程与管理员命令处理
16
- - 动态敏感路径注册表,在规则判断前先把路径映射成资产标签
17
- - DLP 扫描与敏感输出净化
18
- - 管理后台(策略与账号策略配置)
19
- - 决策事件与状态观测
20
- - 中英文国际化(`en` / `zh-CN`)
15
+ - 基于管理员命令的审批流程
16
+ - 动态敏感路径注册表与 DLP 敏感信息净化
17
+ - 用于策略、账号策略和运行状态的管理后台
18
+ - 运行时与后台均支持中英文(`en` / `zh-CN`)
21
19
 
22
- ## 架构说明
20
+ ## 安装
23
21
 
24
- 分层结构如下:
25
-
26
- - `domain`:策略、审批、上下文推断、格式化
27
- - `domain/services/sensitive_path_registry.ts`:内置 + 运行时覆写的敏感路径映射
28
- - `engine`:规则匹配、决策引擎、DLP
29
- - `config`:YAML 基线配置 + SQLite 运行时覆盖
30
- - `admin`:管理后台前后端
31
- - `monitoring`:运行状态与决策快照
32
-
33
- 详见 [架构文档](./docs/ARCHITECTURE.md) 与 [技术方案](./docs/TECHNICAL_SOLUTION.md)。
34
-
35
- ## 快速开始
36
-
37
- ### 1. 安装依赖
22
+ 安装最新发布版本:
38
23
 
39
24
  ```bash
40
- npm install
25
+ npx securityclaw install
41
26
  ```
42
27
 
43
- ### 2. 安装到 OpenClaw
28
+ 或者通过远程脚本安装:
44
29
 
45
30
  ```bash
46
- npm run openclaw:install
31
+ curl -fsSL https://raw.githubusercontent.com/znary/securityclaw/main/install.sh | bash
47
32
  ```
48
33
 
49
- 终端用户也可以直接使用:
34
+ 安装指定发布版本:
50
35
 
51
36
  ```bash
52
- npx securityclaw install
53
- curl -fsSL https://raw.githubusercontent.com/znary/securityclaw/main/install.sh | bash
37
+ SECURITYCLAW_VERSION=0.0.2 curl -fsSL https://raw.githubusercontent.com/znary/securityclaw/main/install.sh | bash
54
38
  ```
55
39
 
56
- ### 3. 执行验证
40
+ 发布到 npm 的版本会直接带上预构建好的管理后台前端,因此终端用户安装插件时不需要现场再构建后台资源。
57
41
 
58
- ```bash
59
- npm test
60
- ```
42
+ ## 卸载
61
43
 
62
- ### 4. 启动管理后台(独立模式)
44
+ OpenClaw 中卸载已安装插件:
63
45
 
64
46
  ```bash
65
- npm run admin
47
+ openclaw plugins uninstall securityclaw
66
48
  ```
67
49
 
68
- 默认地址:`http://127.0.0.1:4780`
69
-
70
- ## OpenClaw 集成
71
-
72
- 推荐本地安装方式:
50
+ 如果想先预览会删除什么:
73
51
 
74
52
  ```bash
75
- npm run openclaw:install
53
+ openclaw plugins uninstall securityclaw --dry-run
76
54
  ```
77
55
 
78
- 这条命令会生成带版本号的插件压缩包,通过 `openclaw plugins install` 安装,随后自动重启 gateway 并校验状态。
79
- 详情见 [OpenClaw 安装指南](./docs/OPENCLAW_INSTALL.md)。
80
-
81
- ## 审批命令
82
-
83
- 当账号策略中配置 `is_admin=true` 后,管理员可在聊天渠道执行:
56
+ 安装或卸载后,如有需要可重启并校验 gateway
84
57
 
85
- - `/securityclaw-approve <approval_id>`
86
- - `/securityclaw-approve <approval_id> long`
87
- - `/securityclaw-reject <approval_id>`
88
- - `/securityclaw-pending`
89
-
90
- ## 管理后台
91
-
92
- 管理后台支持中英文切换,并将语言偏好保存在本地存储。
93
- 默认跟随系统语言。
94
-
95
- 核心模块:
96
-
97
- - 概览:总体态势、趋势,以及高优先级已安装 skill 的风险快照
98
- - 决策记录:最近决策事件与原因
99
- - 规则策略:按分组编辑规则动作,并维护敏感路径注册表
100
- - Skill 拦截:已安装 skill 清单、风险打分、未声明变更检测、重扫 / 隔离 / 受信覆盖操作,以及拦截策略矩阵
101
- - 账号策略:管理员审批账号与模式配置
102
-
103
- 敏感路径注册表说明:
104
-
105
- - 内置覆盖凭据目录、个人内容目录、下载暂存区、浏览器资料目录、浏览器密钥库和通信存储。
106
- - 路径注册表与规则动作一起持久化到 SQLite 运行时策略覆盖中。
107
- - 可在后台删除内置项,也可直接添加自定义路径,无需手改基线 YAML。
108
-
109
- Skill 拦截说明:
110
-
111
- - 后台会从本地 OpenClaw / Codex skill 目录自动发现已安装 skills,并把扫描结果持久化到 SQLite。
112
- - 当 skill 内容发生变化、但版本号没有同步更新时,会被标记为“内容变了但版本没变”。
113
- - 概览页会直接展示最值得优先处理的 skill 风险信号,不需要先切到 Skill 页签。
114
- - `Skill 拦截` 面板支持重扫、隔离、临时受信覆盖,以及风险矩阵配置。
58
+ ```bash
59
+ openclaw gateway restart
60
+ openclaw gateway status
61
+ ```
115
62
 
116
63
  ## 文档导航
117
64
 
@@ -121,15 +68,6 @@ Skill 拦截说明:
121
68
  - [运行手册](./docs/RUNBOOK.md)
122
69
  - [集成指南](./docs/INTEGRATION_GUIDE.md)
123
70
 
124
- ## 开发命令
125
-
126
- ```bash
127
- npm run typecheck
128
- npm run test:unit
129
- npm test
130
- npm run admin:build
131
- ```
132
-
133
71
  ## 许可证
134
72
 
135
73
  MIT,详见 [LICENSE](./LICENSE)。
package/index.ts CHANGED
@@ -30,7 +30,6 @@ import {
30
30
  } from "./src/infrastructure/config/plugin_config_parser.ts";
31
31
  import { RuntimeStatusStore } from "./src/monitoring/status_store.ts";
32
32
  import { startAdminServer } from "./admin/server.ts";
33
- import { ensureAdminAssetsBuilt } from "./src/admin/build.ts";
34
33
  import { announceAdminConsole, shouldAnnounceAdminConsoleForArgv } from "./src/admin/console_notice.ts";
35
34
  import { shouldAutoStartAdminServer } from "./src/admin/runtime_guard.ts";
36
35
  import { AccountPolicyEngine } from "./src/domain/services/account_policy_engine.ts";
@@ -1991,69 +1990,67 @@ const plugin = {
1991
1990
  return runtime;
1992
1991
  }
1993
1992
 
1994
- statusStore.markBoot(toStatusConfig(runtime.config, runtime.overrideLoaded, resolved));
1995
- const adminBuildPromise = ensureAdminAssetsBuilt({
1996
- logger: {
1997
- info: (message: string) => api.logger.info?.(`securityclaw: ${message}`)
1993
+ function startManagedAdminConsole(): void {
1994
+ if (!adminAutoStart) {
1995
+ api.logger.info?.("securityclaw: admin auto-start disabled by config");
1996
+ return;
1998
1997
  }
1999
- }).catch((error) => {
2000
- api.logger.warn?.(`securityclaw: failed to refresh admin bundle (${String(error)})`);
2001
- });
2002
- if (adminAutoStart) {
1998
+
2003
1999
  const autoStartDecision = shouldAutoStartAdminServer(process.env);
2004
- if (autoStartDecision.enabled) {
2005
- const adminServerOptions = {
2006
- configPath: resolved.configPath,
2007
- legacyOverridePath: resolved.legacyOverridePath,
2008
- statusPath,
2009
- dbPath,
2010
- unrefOnStart: true,
2011
- logger: {
2012
- info: (message: string) => api.logger.info?.(`securityclaw: ${message}`),
2013
- warn: (message: string) => api.logger.warn?.(`securityclaw: ${message}`)
2014
- },
2015
- ...(pluginConfig.adminPort !== undefined ? { port: pluginConfig.adminPort } : {})
2016
- };
2017
- void adminBuildPromise
2018
- .then(() => startAdminServer(adminServerOptions))
2019
- .then((result) => {
2020
- announceAdminConsole({
2021
- locale: runtimeLocale,
2022
- logger: {
2023
- info: (message: string) => api.logger.info?.(`securityclaw: ${message}`),
2024
- warn: (message: string) => api.logger.warn?.(`securityclaw: ${message}`),
2025
- },
2026
- stateDir,
2027
- state: result.state,
2028
- url: `http://127.0.0.1:${result.runtime.port}`,
2029
- });
2030
- })
2031
- .catch((error) => {
2032
- api.logger.warn?.(`securityclaw: failed to auto-start admin dashboard (${String(error)})`);
2000
+ if (!autoStartDecision.enabled) {
2001
+ if (shouldAnnounceAdminConsoleForArgv(process.argv)) {
2002
+ announceAdminConsole({
2003
+ locale: runtimeLocale,
2004
+ logger: {
2005
+ info: (message: string) => api.logger.info?.(`securityclaw: ${message}`),
2006
+ warn: (message: string) => api.logger.warn?.(`securityclaw: ${message}`),
2007
+ },
2008
+ stateDir,
2009
+ state: "service-command",
2010
+ url: adminConsoleUrl,
2011
+ });
2012
+ api.logger.info?.("securityclaw: admin dashboard is hosted by the background OpenClaw gateway service");
2013
+ } else {
2014
+ api.logger.info?.(
2015
+ `securityclaw: admin auto-start skipped in ${autoStartDecision.reason}; use npm run admin for standalone dashboard`,
2016
+ );
2017
+ }
2018
+ return;
2019
+ }
2020
+
2021
+ const adminServerOptions = {
2022
+ configPath: resolved.configPath,
2023
+ legacyOverridePath: resolved.legacyOverridePath,
2024
+ statusPath,
2025
+ dbPath,
2026
+ unrefOnStart: true,
2027
+ logger: {
2028
+ info: (message: string) => api.logger.info?.(`securityclaw: ${message}`),
2029
+ warn: (message: string) => api.logger.warn?.(`securityclaw: ${message}`),
2030
+ },
2031
+ ...(pluginConfig.adminPort !== undefined ? { port: pluginConfig.adminPort } : {}),
2032
+ };
2033
+
2034
+ void startAdminServer(adminServerOptions)
2035
+ .then((result) => {
2036
+ announceAdminConsole({
2037
+ locale: runtimeLocale,
2038
+ logger: {
2039
+ info: (message: string) => api.logger.info?.(`securityclaw: ${message}`),
2040
+ warn: (message: string) => api.logger.warn?.(`securityclaw: ${message}`),
2041
+ },
2042
+ stateDir,
2043
+ state: result.state,
2044
+ url: `http://127.0.0.1:${result.runtime.port}`,
2033
2045
  });
2034
- } else {
2035
- if (shouldAnnounceAdminConsoleForArgv(process.argv)) {
2036
- announceAdminConsole({
2037
- locale: runtimeLocale,
2038
- logger: {
2039
- info: (message: string) => api.logger.info?.(`securityclaw: ${message}`),
2040
- warn: (message: string) => api.logger.warn?.(`securityclaw: ${message}`),
2041
- },
2042
- stateDir,
2043
- state: "service-command",
2044
- url: adminConsoleUrl,
2045
- });
2046
- api.logger.info?.("securityclaw: admin dashboard is hosted by the background OpenClaw gateway service");
2047
- } else {
2048
- api.logger.info?.(
2049
- `securityclaw: admin auto-start skipped in ${autoStartDecision.reason}; use npm run admin for standalone dashboard`,
2050
- );
2051
- }
2052
- }
2053
- } else {
2054
- api.logger.info?.("securityclaw: admin auto-start disabled by config");
2046
+ })
2047
+ .catch((error) => {
2048
+ api.logger.warn?.(`securityclaw: failed to auto-start admin dashboard (${String(error)})`);
2049
+ });
2055
2050
  }
2056
2051
 
2052
+ statusStore.markBoot(toStatusConfig(runtime.config, runtime.overrideLoaded, resolved));
2053
+
2057
2054
  api.logger.info?.(
2058
2055
  `securityclaw: boot env=${runtime.config.environment} policy_version=${runtime.config.policy_version} dlp_mode=${runtime.config.dlp.on_dlp_hit} rules=${runtime.config.policies.length}`,
2059
2056
  );
@@ -2655,6 +2652,7 @@ const plugin = {
2655
2652
  { priority: 100 },
2656
2653
  );
2657
2654
 
2655
+ startManagedAdminConsole();
2658
2656
  api.logger.info?.(`securityclaw: loaded policy_version=${runtime.config.policy_version}`);
2659
2657
  }
2660
2658
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securityclaw",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "SecurityClaw security plugin for OpenClaw-compatible hooks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -42,7 +42,7 @@
42
42
  "test:unit": "node --test --experimental-strip-types",
43
43
  "test": "npm run typecheck && npm run test:unit",
44
44
  "check": "npm test",
45
- "admin": "node --experimental-strip-types ./admin/server.ts",
45
+ "admin": "npm run admin:build && node --experimental-strip-types ./admin/server.ts",
46
46
  "admin:build": "node ./scripts/build-admin.mjs",
47
47
  "prepack": "npm test && npm run admin:build",
48
48
  "pack:plugin": "node ./scripts/pack-plugin.mjs",
@@ -50,17 +50,15 @@
50
50
  "release:check": "node ./scripts/release-preflight.mjs",
51
51
  "release:dry-run": "npm run release:check && npm publish --dry-run --access public"
52
52
  },
53
- "dependencies": {
54
- "esbuild": "^0.27.4",
55
- "react": "^19.2.4",
56
- "react-dom": "^19.2.4",
57
- "recharts": "^3.8.0"
58
- },
59
53
  "devDependencies": {
60
54
  "@types/node": "^25.5.0",
61
55
  "@types/react": "^19.2.14",
62
56
  "@types/react-dom": "^19.2.3",
57
+ "esbuild": "^0.27.4",
63
58
  "openclaw": "^2026.3.13",
59
+ "react": "^19.2.4",
60
+ "react-dom": "^19.2.4",
61
+ "recharts": "^3.8.0",
64
62
  "typescript": "^5.9.3"
65
63
  },
66
64
  "peerDependencies": {
@@ -168,9 +168,10 @@ export function announceAdminConsole(options: AnnounceAdminConsoleOptions): Anno
168
168
  const { locale, logger, url, state, stateDir, opener = openAdminConsoleInBrowser } = options;
169
169
  const markerPath = stateDir ? resolveAdminConsoleMarkerPath(stateDir) : undefined;
170
170
  const firstRun = markerPath !== undefined && !existsSync(markerPath);
171
+ const shouldAutoOpen = firstRun && state !== "service-command";
171
172
 
172
173
  let openedAutomatically = false;
173
- if (firstRun) {
174
+ if (shouldAutoOpen) {
174
175
  const result = opener(url);
175
176
  if (result.ok) {
176
177
  openedAutomatically = true;