@alicloud/alibabacloud-hitl-claw-plugin 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/LICENSE +21 -0
- package/README.md +130 -0
- package/README.zh-CN.md +130 -0
- package/config.json +4 -0
- package/openclaw.plugin.json +16 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alibaba Cloud
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Alibaba Cloud Agent HITL (Preview)
|
|
2
|
+
|
|
3
|
+
[中文文档](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
An [OpenClaw](https://github.com/nicepkg/openclaw) plugin that performs risk detection when executing Alibaba Cloud CLI commands, triggering Human-in-the-Loop (HITL) mechanism when necessary to reduce operational risks.
|
|
6
|
+
|
|
7
|
+
> **Note:**
|
|
8
|
+
>
|
|
9
|
+
> Large language models have strong autonomy, and there is still some uncertainty during Agent execution. Please strictly control Agent permissions;
|
|
10
|
+
>
|
|
11
|
+
> This plugin is in preview and may not cover all risky operations. Please thoroughly test to ensure it meets your needs.
|
|
12
|
+
|
|
13
|
+
## Table of Contents
|
|
14
|
+
|
|
15
|
+
- [Prerequisites](#prerequisites)
|
|
16
|
+
- [Quick Start](#quick-start)
|
|
17
|
+
- [Features](#features)
|
|
18
|
+
- [Configuration](#configuration)
|
|
19
|
+
- [Security](#security)
|
|
20
|
+
- [License](#license)
|
|
21
|
+
|
|
22
|
+
## Prerequisites
|
|
23
|
+
|
|
24
|
+
- OpenClaw >= 2026.3.24
|
|
25
|
+
- Node.js >= 22.0.0
|
|
26
|
+
- Alibaba Cloud CLI (`aliyun`) installed and configured
|
|
27
|
+
- When using external channels, run: `openclaw config set session.dmScope per-channel-peer`
|
|
28
|
+
- **Custom API configurations are not supported**
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
openclaw plugins install @alicloud/alibabacloud-hitl-claw-plugin
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- **CLI Command Recognition**: Recognizes `aliyun` CLI commands executed by the Agent
|
|
39
|
+
- **Risk Assessment**: Integrates with Alibaba Cloud IMS `CheckHitlRule` API for risk detection
|
|
40
|
+
- **Human Approval**: High and medium-risk commands require human approval via a secure link
|
|
41
|
+
- **Multi-Channel Support**: Works with DingTalk, Feishu, and OpenClaw console interfaces
|
|
42
|
+
|
|
43
|
+
### Command Recognition
|
|
44
|
+
|
|
45
|
+
#### Trigger Conditions
|
|
46
|
+
|
|
47
|
+
| Condition | Description |
|
|
48
|
+
|-----------|-------------|
|
|
49
|
+
| Tool Type | Only checks `exec` tool calls for Alibaba Cloud CLI: `aliyun` |
|
|
50
|
+
| Command Pattern | Matches `aliyun <ProductCode> <APIName> [Parameters...]` |
|
|
51
|
+
| Supported Styles | Both RPC and ROA styles |
|
|
52
|
+
|
|
53
|
+
#### Parsing Method
|
|
54
|
+
|
|
55
|
+
Uses [shell-quote](https://www.npmjs.com/package/shell-quote) library for professional shell command parsing, supporting:
|
|
56
|
+
|
|
57
|
+
- Pipe operator `|`
|
|
58
|
+
- Logical operators `&&`, `||`
|
|
59
|
+
- Command separator `;`
|
|
60
|
+
- Background execution `&`
|
|
61
|
+
- Quotes and escape characters
|
|
62
|
+
|
|
63
|
+
#### Examples
|
|
64
|
+
|
|
65
|
+
| Original Command | Server Check | Command Sent to Server | Notes |
|
|
66
|
+
|------------------|--------------|------------------------|-------|
|
|
67
|
+
| `aliyun ecs DescribeInstances` | ✅ Yes | `aliyun ecs DescribeInstances` | Standard RPC style |
|
|
68
|
+
| `aliyun ram CreateUser --UserName test` | ✅ Yes | `aliyun ram CreateUser --UserName test` | Write operation with params |
|
|
69
|
+
| `aliyun cs GET /clusters` | ✅ Yes | `aliyun cs GET /clusters` | ROA style |
|
|
70
|
+
| `ls && aliyun ecs DeleteInstance --InstanceId i-xxx` | ✅ Yes | `aliyun ecs DeleteInstance --InstanceId i-xxx` | Extracts Alibaba Cloud part from composite command |
|
|
71
|
+
| `aliyun configure` | ❌ No | - | Missing API name, no check triggered |
|
|
72
|
+
| `aws ec2 describe-instances` | ❌ No | - | Not an Alibaba Cloud command |
|
|
73
|
+
|
|
74
|
+
### Risk Decisions
|
|
75
|
+
|
|
76
|
+
Risk API (`aliyun ims CheckHitlRule`) returns three decisions:
|
|
77
|
+
|
|
78
|
+
| Decision | Meaning | Plugin Behavior |
|
|
79
|
+
|----------|---------|-----------------|
|
|
80
|
+
| `ALLOW` | Low risk, allow execution | Pass through |
|
|
81
|
+
| `ESCALATE` | High risk, requires approval | Suspend and wait for approval |
|
|
82
|
+
|
|
83
|
+
### How It Works
|
|
84
|
+
|
|
85
|
+

|
|
86
|
+
|
|
87
|
+
## Configuration
|
|
88
|
+
|
|
89
|
+
The plugin reads configuration from `config.json`:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"enabled": true,
|
|
94
|
+
"confirmationTimeoutSeconds": 600
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
| Option | Type | Default | Description |
|
|
99
|
+
|--------|------|---------|-------------|
|
|
100
|
+
| `enabled` | boolean | `true` | Whether to enable the plugin |
|
|
101
|
+
| `confirmationTimeoutSeconds` | number | `600` | Approval timeout in seconds |
|
|
102
|
+
|
|
103
|
+
## Security
|
|
104
|
+
|
|
105
|
+
### 1. Shell Command Execution
|
|
106
|
+
|
|
107
|
+
This plugin invokes the **Alibaba Cloud CLI** for:
|
|
108
|
+
|
|
109
|
+
| Scenario | Description |
|
|
110
|
+
|----------|-------------|
|
|
111
|
+
| Sensitive Operation Detection | Calls `aliyun ims CheckHitlRule` to detect if the current command is a sensitive operation |
|
|
112
|
+
| Resume User CLI Request | After user approval, resumes execution of the original command |
|
|
113
|
+
|
|
114
|
+
This plugin runs in Node.js and uses the `child_process` module to invoke the aliyun CLI.
|
|
115
|
+
|
|
116
|
+
**Data sent to server**: aliyun CLI command content, CLI version, plugin version, Agent type, Session ID
|
|
117
|
+
|
|
118
|
+
### 2. Network Requests
|
|
119
|
+
|
|
120
|
+
This plugin uses `fetch` to poll approval status and sends approval result notifications to external channels (DingTalk, Feishu) via OpenClaw's `dispatchReplyFromConfig` API.
|
|
121
|
+
|
|
122
|
+
- No sensitive credentials are sent to the server
|
|
123
|
+
- Network requests are only for approval status polling and message notifications
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
**All above behaviors are essential for core plugin functionality. Sensitive information is processed locally and will not be sent to the server.**
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# 阿里云 Agent HITL (预览版)
|
|
2
|
+
|
|
3
|
+
[English](./README.md)
|
|
4
|
+
|
|
5
|
+
一款 [OpenClaw](https://github.com/nicepkg/openclaw) 插件,在执行阿里云 CLI 命令时进行风险检测,必要时触发人机协同机制(HITL - Human in the Loop),降低操作风险。
|
|
6
|
+
|
|
7
|
+
> **特别说明:**
|
|
8
|
+
>
|
|
9
|
+
> 大模型有很强的自主性,在 Agent 执行中仍有一些不确定性,请务必严格控制 Agent 的权限;
|
|
10
|
+
>
|
|
11
|
+
> 本插件处于预览版,可能无法覆盖所有风险操作,请务必充分试用以确认满足使用需要。
|
|
12
|
+
|
|
13
|
+
## 目录
|
|
14
|
+
|
|
15
|
+
- [前置要求](#前置要求)
|
|
16
|
+
- [快速开始](#快速开始)
|
|
17
|
+
- [功能特性](#功能特性)
|
|
18
|
+
- [配置说明](#配置说明)
|
|
19
|
+
- [安全说明](#安全说明)
|
|
20
|
+
- [许可证](#许可证)
|
|
21
|
+
|
|
22
|
+
## 前置要求
|
|
23
|
+
|
|
24
|
+
- OpenClaw >= 2026.3.24
|
|
25
|
+
- Node.js >= 22.0.0
|
|
26
|
+
- 已安装并配置阿里云 CLI (`aliyun`)
|
|
27
|
+
- 使用外部渠道时,需要设置:`openclaw config set session.dmScope per-channel-peer`
|
|
28
|
+
- **不支持自定义 API**
|
|
29
|
+
|
|
30
|
+
## 快速开始
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
openclaw plugins install @alicloud/alibabacloud-hitl-claw-plugin
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 功能特性
|
|
37
|
+
|
|
38
|
+
- **CLI 命令识别**:识别 Agent 执行的 `aliyun` CLI 命令
|
|
39
|
+
- **风险评估**:集成阿里云 IMS `CheckHitlRule` API 进行风险检测
|
|
40
|
+
- **人工审批**:高、中风险命令需要通过安全链接进行人工审批
|
|
41
|
+
- **多渠道支持**:支持钉钉、飞书及 OpenClaw 控制台界面
|
|
42
|
+
|
|
43
|
+
### 命令识别范围
|
|
44
|
+
|
|
45
|
+
#### 触发条件
|
|
46
|
+
|
|
47
|
+
| 条件 | 说明 |
|
|
48
|
+
|------|------|
|
|
49
|
+
| 工具类型 | 仅检测 `exec` 命令下阿里云 CLI: `aliyun` 调用 |
|
|
50
|
+
| 命令模式 | 匹配 `aliyun <产品代码> <API名称> [参数...]` |
|
|
51
|
+
| 支持风格 | RPC 风格和 ROA 风格均支持 |
|
|
52
|
+
|
|
53
|
+
#### 解析方式
|
|
54
|
+
|
|
55
|
+
使用 [shell-quote](https://www.npmjs.com/package/shell-quote) 库进行专业的 shell 命令解析,支持:
|
|
56
|
+
|
|
57
|
+
- 管道操作符 `|`
|
|
58
|
+
- 逻辑运算符 `&&`、`||`
|
|
59
|
+
- 命令分隔符 `;`
|
|
60
|
+
- 后台执行 `&`
|
|
61
|
+
- 引号和转义字符
|
|
62
|
+
|
|
63
|
+
#### 示例
|
|
64
|
+
|
|
65
|
+
| 原始命令 | 服务端检测 | 发送至服务端的命令 | 说明 |
|
|
66
|
+
|----------|------------|-------------------|------|
|
|
67
|
+
| `aliyun ecs DescribeInstances` | ✅ 是 | `aliyun ecs DescribeInstances` | 标准 RPC 风格 |
|
|
68
|
+
| `aliyun ram CreateUser --UserName test` | ✅ 是 | `aliyun ram CreateUser --UserName test` | 带参数的写操作 |
|
|
69
|
+
| `aliyun cs GET /clusters` | ✅ 是 | `aliyun cs GET /clusters` | ROA 风格 |
|
|
70
|
+
| `ls && aliyun ecs DeleteInstance --InstanceId i-xxx` | ✅ 是 | `aliyun ecs DeleteInstance --InstanceId i-xxx` | 从复合命令中提取阿里云部分 |
|
|
71
|
+
| `aliyun configure` | ❌ 否 | - | 缺少 API 名称,不触发检测 |
|
|
72
|
+
| `aws ec2 describe-instances` | ❌ 否 | - | 非阿里云命令 |
|
|
73
|
+
|
|
74
|
+
### 风控决策
|
|
75
|
+
|
|
76
|
+
风控 API (`aliyun ims CheckHitlRule`) 返回三种决策:
|
|
77
|
+
|
|
78
|
+
| 决策 | 含义 | 插件行为 |
|
|
79
|
+
|------|------|----------|
|
|
80
|
+
| `ALLOW` | 低风险,允许执行 | 直接放行 |
|
|
81
|
+
| `ESCALATE` | 高风险,需人工审批 | 挂起等待审批 |
|
|
82
|
+
|
|
83
|
+
### 工作原理
|
|
84
|
+
|
|
85
|
+

|
|
86
|
+
|
|
87
|
+
## 配置说明
|
|
88
|
+
|
|
89
|
+
插件从 `config.json` 读取配置:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"enabled": true,
|
|
94
|
+
"confirmationTimeoutSeconds": 600
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
|
99
|
+
|--------|------|--------|------|
|
|
100
|
+
| `enabled` | boolean | `true` | 是否启用插件 |
|
|
101
|
+
| `confirmationTimeoutSeconds` | number | `600` | 审批超时时间(秒) |
|
|
102
|
+
|
|
103
|
+
## 安全说明
|
|
104
|
+
|
|
105
|
+
### 1. Shell 命令执行
|
|
106
|
+
|
|
107
|
+
本插件会调用 **阿里云 CLI** 用于:
|
|
108
|
+
|
|
109
|
+
| 场景 | 说明 |
|
|
110
|
+
|------|------|
|
|
111
|
+
| 敏感操作检测 | 调用 `aliyun ims CheckHitlRule` 检测当前命令是否为敏感操作 |
|
|
112
|
+
| 恢复执行用户的 CLI 请求 | 用户审批通过后,恢复执行原始命令 |
|
|
113
|
+
|
|
114
|
+
本插件运行在 Node.js 环境中,调用 aliyun CLI 程序需通过 `child_process` 模块实现。
|
|
115
|
+
|
|
116
|
+
**发送至服务端的数据**:aliyun CLI 命令内容、CLI 版本、插件版本、Agent 类型、Session ID
|
|
117
|
+
|
|
118
|
+
### 2. 网络请求
|
|
119
|
+
|
|
120
|
+
本插件使用 `fetch` 轮询审批状态,并通过 OpenClaw 的 `dispatchReplyFromConfig` API 向外部渠道(钉钉、飞书)发送审批结果通知。
|
|
121
|
+
|
|
122
|
+
- 不会将任何敏感凭证发送至服务端
|
|
123
|
+
- 网络请求仅用于审批状态轮询和消息通知
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
**以上行为均为插件核心功能所必需,涉及的敏感信息均在本地处理,不会发送至服务端。**
|
|
127
|
+
|
|
128
|
+
## 许可证
|
|
129
|
+
|
|
130
|
+
MIT
|
package/config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://openclaw.ai/schemas/plugin.json",
|
|
3
|
+
"id": "alibabacloud-hitl-claw-plugin",
|
|
4
|
+
"name": "阿里云 HITL 拦截器",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "拦截阿里云 CLI 敏感操作,通过 HITL(Human-in-the-Loop)风控审批后执行",
|
|
7
|
+
"author": "Alibaba Cloud",
|
|
8
|
+
"entry": "./dist/index.js",
|
|
9
|
+
"capabilities": [
|
|
10
|
+
"hooks"
|
|
11
|
+
],
|
|
12
|
+
"configSchema": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {}
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alicloud/alibabacloud-hitl-claw-plugin",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "OpenClaw plugin for intercepting tool calls with user confirmation",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"openclaw.plugin.json",
|
|
11
|
+
"config.json"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"prebuild": "node -e \"const pkg=require('./package.json');const plugin=require('./openclaw.plugin.json');plugin.version=pkg.version;require('fs').writeFileSync('./openclaw.plugin.json',JSON.stringify(plugin,null,2))\"",
|
|
15
|
+
"build": "rm -f tsconfig.tsbuildinfo && tsc",
|
|
16
|
+
"dev": "tsc --watch",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"test:watch": "vitest"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"openclaw",
|
|
22
|
+
"plugin",
|
|
23
|
+
"alibabacloud-hitl-claw-plugin",
|
|
24
|
+
"security",
|
|
25
|
+
"confirmation"
|
|
26
|
+
],
|
|
27
|
+
"author": "Alibaba Cloud",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"openclaw": {
|
|
30
|
+
"extensions": [
|
|
31
|
+
"./dist/index.js"
|
|
32
|
+
],
|
|
33
|
+
"hooks": [
|
|
34
|
+
"before_tool_call"
|
|
35
|
+
],
|
|
36
|
+
"compat": {
|
|
37
|
+
"pluginApi": ">=2026.3.24",
|
|
38
|
+
"minGatewayVersion": "2026.3.24"
|
|
39
|
+
},
|
|
40
|
+
"build": {
|
|
41
|
+
"openclawVersion": "2026.3.24",
|
|
42
|
+
"pluginSdkVersion": "2026.3.24"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"nanoid": "^5.1.7",
|
|
47
|
+
"shell-quote": "^1.8.3"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^20.0.0",
|
|
51
|
+
"@types/shell-quote": "^1.7.5",
|
|
52
|
+
"typescript": "^5.0.0",
|
|
53
|
+
"vitest": "^4.1.2"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"openclaw": ">=2026.3.24"
|
|
57
|
+
},
|
|
58
|
+
"peerDependenciesMeta": {
|
|
59
|
+
"openclaw": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"engines": {
|
|
64
|
+
"node": ">=18.0.0"
|
|
65
|
+
},
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"registry": "https://registry.npmjs.org",
|
|
68
|
+
"access": "public"
|
|
69
|
+
}
|
|
70
|
+
}
|