@runplane/runplane-sdk 1.1.2 → 1.1.3
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 +107 -52
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,83 +1,122 @@
|
|
|
1
1
|
# @runplane/runplane-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Control what your AI agents are allowed to do — in real time.
|
|
4
4
|
|
|
5
5
|
Runplane sits between your AI agents and execution. Every action passes through `guard()`, which enforces a decision before your code runs.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🚀 Start in 2 Minutes
|
|
10
|
+
|
|
11
|
+
### 1. Install the SDK
|
|
8
12
|
|
|
9
13
|
```bash
|
|
10
14
|
npm install @runplane/runplane-sdk
|
|
11
15
|
```
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
### 2. Get your API key (Free 14-day trial)
|
|
20
|
+
|
|
21
|
+
👉 https://runplane.ai/
|
|
22
|
+
|
|
23
|
+
Create your account and copy your API key.
|
|
24
|
+
|
|
25
|
+
⚠️ **Important:** The SDK will not work without a valid API key.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### 3. Run your first protected action
|
|
14
30
|
|
|
15
31
|
```javascript
|
|
16
32
|
require("dotenv").config()
|
|
17
|
-
const { Runplane } = require("@
|
|
33
|
+
const { Runplane } = require("@runplane/runplane-sdk")
|
|
34
|
+
|
|
18
35
|
const runplane = new Runplane({
|
|
19
36
|
apiKey: process.env.RUNPLANE_API_KEY,
|
|
20
37
|
})
|
|
21
38
|
|
|
22
|
-
|
|
23
|
-
await runplane.guard(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
39
|
+
async function main() {
|
|
40
|
+
await runplane.guard(
|
|
41
|
+
"transfer_funds",
|
|
42
|
+
"finance-system",
|
|
43
|
+
{ fromAccountId: "acc_1", toAccountId: "acc_2", amount: 400 },
|
|
44
|
+
async () => {
|
|
45
|
+
return await executeTransfer()
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
main()
|
|
31
51
|
```
|
|
32
52
|
|
|
33
|
-
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 💡 What Runplane Does
|
|
56
|
+
|
|
57
|
+
Runplane gives you **real-time control over AI agent actions**.
|
|
58
|
+
|
|
59
|
+
Before any action runs, Runplane evaluates:
|
|
60
|
+
|
|
61
|
+
* Policies
|
|
62
|
+
* Risk
|
|
63
|
+
* Context
|
|
34
64
|
|
|
35
|
-
|
|
65
|
+
And returns a decision:
|
|
66
|
+
|
|
67
|
+
* **ALLOW** → execution continues
|
|
68
|
+
* **BLOCK** → action is stopped
|
|
69
|
+
* **REQUIRE_APPROVAL** → human approval required
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## ⚙️ How It Works
|
|
74
|
+
|
|
75
|
+
`guard()` calls the Runplane API before executing your handler:
|
|
36
76
|
|
|
37
77
|
1. Sends action + target + context to Runplane
|
|
38
78
|
2. Runplane evaluates policies and risk
|
|
39
|
-
3. Returns
|
|
40
|
-
- **ALLOW** → handler executes immediately
|
|
41
|
-
- **BLOCK** → throws `RunplaneError`, handler never runs
|
|
42
|
-
- **REQUIRE_APPROVAL** → throws `RunplaneError`, awaits human decision
|
|
79
|
+
3. Returns a decision:
|
|
43
80
|
|
|
44
|
-
|
|
81
|
+
* **ALLOW** → handler executes
|
|
82
|
+
* **BLOCK** → throws `RunplaneError`
|
|
83
|
+
* **REQUIRE_APPROVAL** → throws `RunplaneError` and waits for approval
|
|
45
84
|
|
|
46
|
-
|
|
85
|
+
---
|
|
47
86
|
|
|
48
|
-
|
|
87
|
+
## 📘 API Reference
|
|
88
|
+
|
|
89
|
+
### `new Runplane(config)`
|
|
49
90
|
|
|
50
91
|
```javascript
|
|
51
92
|
const runplane = new Runplane({
|
|
52
|
-
apiKey: "your_api_key",
|
|
53
|
-
baseUrl: "https://runplane.ai",
|
|
93
|
+
apiKey: "your_api_key",
|
|
94
|
+
baseUrl: "https://runplane.ai",
|
|
54
95
|
})
|
|
55
96
|
```
|
|
56
97
|
|
|
57
|
-
|
|
98
|
+
---
|
|
58
99
|
|
|
59
|
-
|
|
100
|
+
### `guard(action, target, context, handler)`
|
|
60
101
|
|
|
61
102
|
```javascript
|
|
62
103
|
const result = await runplane.guard(
|
|
63
|
-
"delete_record",
|
|
64
|
-
"hr_system",
|
|
65
|
-
{ employeeId: "emp_123" },
|
|
104
|
+
"delete_record",
|
|
105
|
+
"hr_system",
|
|
106
|
+
{ employeeId: "emp_123" },
|
|
66
107
|
async () => {
|
|
67
|
-
// Your code here - only runs if ALLOW
|
|
68
108
|
return await deleteEmployee("emp_123")
|
|
69
109
|
}
|
|
70
110
|
)
|
|
71
111
|
```
|
|
72
112
|
|
|
73
|
-
**Returns:**
|
|
113
|
+
**Returns:** handler result if ALLOW
|
|
114
|
+
**Throws:** `RunplaneError` if BLOCK or REQUIRE_APPROVAL
|
|
74
115
|
|
|
75
|
-
|
|
116
|
+
---
|
|
76
117
|
|
|
77
118
|
### `decide(payload)`
|
|
78
119
|
|
|
79
|
-
Low-level method to request a decision without automatic enforcement.
|
|
80
|
-
|
|
81
120
|
```javascript
|
|
82
121
|
const result = await runplane.decide({
|
|
83
122
|
action: "send_email",
|
|
@@ -85,17 +124,19 @@ const result = await runplane.decide({
|
|
|
85
124
|
context: { recipients: 1200 },
|
|
86
125
|
})
|
|
87
126
|
|
|
88
|
-
console.log(result.decision)
|
|
127
|
+
console.log(result.decision)
|
|
89
128
|
```
|
|
90
129
|
|
|
91
|
-
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 🧠 Handling Decisions
|
|
92
133
|
|
|
93
134
|
```javascript
|
|
94
135
|
const { Runplane, RunplaneError } = require("@runplane/runplane-sdk")
|
|
95
136
|
|
|
96
137
|
try {
|
|
97
138
|
await runplane.guard("action", "target", {}, async () => {
|
|
98
|
-
//
|
|
139
|
+
// your code
|
|
99
140
|
})
|
|
100
141
|
} catch (err) {
|
|
101
142
|
if (err instanceof RunplaneError) {
|
|
@@ -109,36 +150,50 @@ try {
|
|
|
109
150
|
}
|
|
110
151
|
```
|
|
111
152
|
|
|
112
|
-
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 📊 Decision Types
|
|
113
156
|
|
|
114
|
-
| Decision
|
|
115
|
-
|
|
116
|
-
| `ALLOW`
|
|
117
|
-
| `BLOCK`
|
|
118
|
-
| `REQUIRE_APPROVAL` |
|
|
157
|
+
| Decision | Behavior |
|
|
158
|
+
| ------------------ | ---------------------------- |
|
|
159
|
+
| `ALLOW` | Handler executes immediately |
|
|
160
|
+
| `BLOCK` | Throws `RunplaneError` |
|
|
161
|
+
| `REQUIRE_APPROVAL` | Requires human approval |
|
|
119
162
|
|
|
120
|
-
|
|
163
|
+
---
|
|
121
164
|
|
|
122
|
-
|
|
165
|
+
## ❗ Error Object
|
|
123
166
|
|
|
124
167
|
```javascript
|
|
125
168
|
{
|
|
126
169
|
message: "Runplane blocked this action",
|
|
127
|
-
code: "BLOCK",
|
|
128
|
-
runplane: {
|
|
170
|
+
code: "BLOCK",
|
|
171
|
+
runplane: {
|
|
129
172
|
decision: "BLOCK",
|
|
130
|
-
reason: "Policy
|
|
173
|
+
reason: "Policy violation",
|
|
131
174
|
requestId: "req_abc123",
|
|
132
175
|
riskScore: 91,
|
|
133
176
|
}
|
|
134
177
|
}
|
|
135
178
|
```
|
|
136
179
|
|
|
137
|
-
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## ⚠️ Requirements
|
|
183
|
+
|
|
184
|
+
* Node.js 18+
|
|
185
|
+
* Runplane API key 👉 https://runplane.ai/
|
|
186
|
+
* Internet access
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 💬 Feedback
|
|
191
|
+
|
|
192
|
+
Got stuck? Something unclear? Want to suggest improvements?
|
|
193
|
+
|
|
194
|
+
👉 https://runplane.ai/
|
|
138
195
|
|
|
139
|
-
|
|
140
|
-
- Valid Runplane API key
|
|
141
|
-
- Network access to `https://runplane.ai`
|
|
196
|
+
---
|
|
142
197
|
|
|
143
198
|
## License
|
|
144
199
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runplane/runplane-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Runtime governance SDK for AI agent actions. Wrap sensitive operations with guard() to enforce ALLOW, BLOCK, or REQUIRE_APPROVAL decisions before execution.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|
|
40
|
-
"url": "https://github.com/runplane/sdk.git"
|
|
40
|
+
"url": "git+https://github.com/runplane/sdk.git"
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://runplane.ai/developer",
|
|
43
43
|
"bugs": {
|