@oked/sdk 0.1.0 → 0.1.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 -21
- package/README.md +107 -107
- package/package.json +51 -51
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 OKed
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OKed
|
|
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
CHANGED
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
# @oked/sdk
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@oked/sdk)
|
|
4
|
-
[](./LICENSE)
|
|
5
|
-
[](./dist/index.d.ts)
|
|
6
|
-
|
|
7
|
-
Core library - programmatic approval API for AI agents. Sends sensitive actions to the OKed backend, waits for a human decision, and resolves only when the user approves or denies.
|
|
8
|
-
|
|
9
|
-
Use this package directly from any Node.js agent (OpenAI SDK, LangChain, custom). For drop-in integrations, see [`@oked/claude-code`](../claude-code) or [`@oked/openclaw`](../openclaw).
|
|
10
|
-
|
|
11
|
-
## Install
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install @oked/sdk
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Quick start
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
import { OKedClient } from "@oked/sdk";
|
|
21
|
-
|
|
22
|
-
const oked = new OKedClient({
|
|
23
|
-
apiKey: process.env.OKED_API_KEY,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const result = await oked.approve({
|
|
27
|
-
action: "deploy",
|
|
28
|
-
description: "Deploy release 2026.04.07 to production",
|
|
29
|
-
tier: "high_stakes",
|
|
30
|
-
session_id: "deploy-123",
|
|
31
|
-
cwd: process.cwd(),
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
if (!result.approved) {
|
|
35
|
-
throw new Error(`Blocked by OKed: ${result.decision}`);
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Configuration
|
|
40
|
-
|
|
41
|
-
Pass to `new OKedClient(config)`:
|
|
42
|
-
|
|
43
|
-
| Key | Type | Default | Description |
|
|
44
|
-
|---|---|---|---|
|
|
45
|
-
| `apiKey` | `string` | `OKED_API_KEY` env | Your OKed API key. Required. |
|
|
46
|
-
| `backendUrl` | `string` | `https://api.oked.ai` | Override the OKed backend URL. |
|
|
47
|
-
| `timeout` | `number` | `300000` | Per-approval timeout in ms. |
|
|
48
|
-
| `strictFailClosed` | `boolean` | `false` | When true, backend outages deny every tier. When false, outages deny only `high_stakes` and allow lower tiers. |
|
|
49
|
-
|
|
50
|
-
## API
|
|
51
|
-
|
|
52
|
-
### `approve(request)`
|
|
53
|
-
|
|
54
|
-
Request an approval for a sensitive action. Resolves when the user responds, the request times out, or the backend denies.
|
|
55
|
-
|
|
56
|
-
Request fields:
|
|
57
|
-
|
|
58
|
-
| Field | Type | Required | Description |
|
|
59
|
-
|---|---|---|---|
|
|
60
|
-
| `action` | `string` | yes | Short action identifier (e.g. `"deploy"`, `"send_email"`). |
|
|
61
|
-
| `description` | `string` | yes | Human-readable summary shown in the approval UI. |
|
|
62
|
-
| `tier` | `"safe" \| "warning" \| "review" \| "high_stakes"` | yes | Risk tier. Use `classify()` if unsure. |
|
|
63
|
-
| `tool_input` | `unknown` | no | Raw tool arguments, included in the audit log. |
|
|
64
|
-
| `session_id` | `string` | no | Groups related approvals under one session. |
|
|
65
|
-
| `cwd` | `string` | no | Working directory, shown in the UI for context. |
|
|
66
|
-
|
|
67
|
-
Response fields:
|
|
68
|
-
|
|
69
|
-
| Field | Type | Description |
|
|
70
|
-
|---|---|---|
|
|
71
|
-
| `approved` | `boolean` | `true` only when the user approved. |
|
|
72
|
-
| `approval_id` | `string` | Opaque id for logs / audit. |
|
|
73
|
-
| `decision` | `"approved" \| "denied" \| "timeout"` | Exact outcome. |
|
|
74
|
-
|
|
75
|
-
### `ping()`
|
|
76
|
-
|
|
77
|
-
Returns `true` when the backend is reachable. Use for startup health checks.
|
|
78
|
-
|
|
79
|
-
### Helpers
|
|
80
|
-
|
|
81
|
-
- `classify(input)` - classifies a shell command or tool call into a risk tier.
|
|
82
|
-
- `describe(input)` - generates a human-readable description for the approval UI.
|
|
83
|
-
|
|
84
|
-
Full type definitions ship with the package (`dist/index.d.ts`).
|
|
85
|
-
|
|
86
|
-
## Environment
|
|
87
|
-
|
|
88
|
-
| Var | Required | Description |
|
|
89
|
-
|---|---|---|
|
|
90
|
-
| `OKED_API_KEY` | yes, unless passed in code | Your OKed API key. |
|
|
91
|
-
| `OKED_BACKEND_URL` | no | Override the hosted backend URL. |
|
|
92
|
-
| `OKED_STRICT_FAIL_CLOSED` | no | Set to `1` or `true` to deny every sensitive action when the backend is unreachable. |
|
|
93
|
-
|
|
94
|
-
## Degraded-mode behavior
|
|
95
|
-
|
|
96
|
-
Explicit user denials return `{ approved: false }` and should always be treated as final. Invalid API keys throw `OKedAuthError` and should deny. If the backend is unreachable, `OKedBackendUnreachableError` lets integrations apply degraded mode: `high_stakes` denies, while lower tiers may proceed unless `strictFailClosed` is enabled. Unexpected errors should be treated as deny.
|
|
97
|
-
|
|
98
|
-
## Development
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
npm install
|
|
102
|
-
npm run build
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## License
|
|
106
|
-
|
|
107
|
-
[MIT](./LICENSE)
|
|
1
|
+
# @oked/sdk
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@oked/sdk)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](./dist/index.d.ts)
|
|
6
|
+
|
|
7
|
+
Core library - programmatic approval API for AI agents. Sends sensitive actions to the OKed backend, waits for a human decision, and resolves only when the user approves or denies.
|
|
8
|
+
|
|
9
|
+
Use this package directly from any Node.js agent (OpenAI SDK, LangChain, custom). For drop-in integrations, see [`@oked/claude-code`](../claude-code) or [`@oked/openclaw`](../openclaw).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @oked/sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { OKedClient } from "@oked/sdk";
|
|
21
|
+
|
|
22
|
+
const oked = new OKedClient({
|
|
23
|
+
apiKey: process.env.OKED_API_KEY,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const result = await oked.approve({
|
|
27
|
+
action: "deploy",
|
|
28
|
+
description: "Deploy release 2026.04.07 to production",
|
|
29
|
+
tier: "high_stakes",
|
|
30
|
+
session_id: "deploy-123",
|
|
31
|
+
cwd: process.cwd(),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (!result.approved) {
|
|
35
|
+
throw new Error(`Blocked by OKed: ${result.decision}`);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
Pass to `new OKedClient(config)`:
|
|
42
|
+
|
|
43
|
+
| Key | Type | Default | Description |
|
|
44
|
+
|---|---|---|---|
|
|
45
|
+
| `apiKey` | `string` | `OKED_API_KEY` env | Your OKed API key. Required. |
|
|
46
|
+
| `backendUrl` | `string` | `https://api.oked.ai` | Override the OKed backend URL. |
|
|
47
|
+
| `timeout` | `number` | `300000` | Per-approval timeout in ms. |
|
|
48
|
+
| `strictFailClosed` | `boolean` | `false` | When true, backend outages deny every tier. When false, outages deny only `high_stakes` and allow lower tiers. |
|
|
49
|
+
|
|
50
|
+
## API
|
|
51
|
+
|
|
52
|
+
### `approve(request)`
|
|
53
|
+
|
|
54
|
+
Request an approval for a sensitive action. Resolves when the user responds, the request times out, or the backend denies.
|
|
55
|
+
|
|
56
|
+
Request fields:
|
|
57
|
+
|
|
58
|
+
| Field | Type | Required | Description |
|
|
59
|
+
|---|---|---|---|
|
|
60
|
+
| `action` | `string` | yes | Short action identifier (e.g. `"deploy"`, `"send_email"`). |
|
|
61
|
+
| `description` | `string` | yes | Human-readable summary shown in the approval UI. |
|
|
62
|
+
| `tier` | `"safe" \| "warning" \| "review" \| "high_stakes"` | yes | Risk tier. Use `classify()` if unsure. |
|
|
63
|
+
| `tool_input` | `unknown` | no | Raw tool arguments, included in the audit log. |
|
|
64
|
+
| `session_id` | `string` | no | Groups related approvals under one session. |
|
|
65
|
+
| `cwd` | `string` | no | Working directory, shown in the UI for context. |
|
|
66
|
+
|
|
67
|
+
Response fields:
|
|
68
|
+
|
|
69
|
+
| Field | Type | Description |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| `approved` | `boolean` | `true` only when the user approved. |
|
|
72
|
+
| `approval_id` | `string` | Opaque id for logs / audit. |
|
|
73
|
+
| `decision` | `"approved" \| "denied" \| "timeout"` | Exact outcome. |
|
|
74
|
+
|
|
75
|
+
### `ping()`
|
|
76
|
+
|
|
77
|
+
Returns `true` when the backend is reachable. Use for startup health checks.
|
|
78
|
+
|
|
79
|
+
### Helpers
|
|
80
|
+
|
|
81
|
+
- `classify(input)` - classifies a shell command or tool call into a risk tier.
|
|
82
|
+
- `describe(input)` - generates a human-readable description for the approval UI.
|
|
83
|
+
|
|
84
|
+
Full type definitions ship with the package (`dist/index.d.ts`).
|
|
85
|
+
|
|
86
|
+
## Environment
|
|
87
|
+
|
|
88
|
+
| Var | Required | Description |
|
|
89
|
+
|---|---|---|
|
|
90
|
+
| `OKED_API_KEY` | yes, unless passed in code | Your OKed API key. |
|
|
91
|
+
| `OKED_BACKEND_URL` | no | Override the hosted backend URL. |
|
|
92
|
+
| `OKED_STRICT_FAIL_CLOSED` | no | Set to `1` or `true` to deny every sensitive action when the backend is unreachable. |
|
|
93
|
+
|
|
94
|
+
## Degraded-mode behavior
|
|
95
|
+
|
|
96
|
+
Explicit user denials return `{ approved: false }` and should always be treated as final. Invalid API keys throw `OKedAuthError` and should deny. If the backend is unreachable, `OKedBackendUnreachableError` lets integrations apply degraded mode: `high_stakes` denies, while lower tiers may proceed unless `strictFailClosed` is enabled. Unexpected errors should be treated as deny.
|
|
97
|
+
|
|
98
|
+
## Development
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm install
|
|
102
|
+
npm run build
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
[MIT](./LICENSE)
|
package/package.json
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@oked/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "OKed SDK - human approval layer for AI agents",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc",
|
|
16
|
-
"dev": "tsc --watch",
|
|
17
|
-
"test": "tsx --test test/*.test.ts",
|
|
18
|
-
"prepublishOnly": "npm run build"
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist"
|
|
22
|
-
],
|
|
23
|
-
"keywords": [
|
|
24
|
-
"approval",
|
|
25
|
-
"agents",
|
|
26
|
-
"ai",
|
|
27
|
-
"sdk",
|
|
28
|
-
"security"
|
|
29
|
-
],
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "git+https://github.com/oked-ai/oked-sdk.git",
|
|
33
|
-
"directory": "packages/sdk"
|
|
34
|
-
},
|
|
35
|
-
"bugs": {
|
|
36
|
-
"url": "https://github.com/oked-ai/oked-sdk/issues"
|
|
37
|
-
},
|
|
38
|
-
"homepage": "https://github.com/oked-ai/oked-sdk#readme",
|
|
39
|
-
"license": "MIT",
|
|
40
|
-
"engines": {
|
|
41
|
-
"node": ">=18"
|
|
42
|
-
},
|
|
43
|
-
"publishConfig": {
|
|
44
|
-
"access": "public"
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"@types/node": "^22.13.10",
|
|
48
|
-
"tsx": "^4.22.0",
|
|
49
|
-
"typescript": "^5.6.0"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@oked/sdk",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "OKed SDK - human approval layer for AI agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"dev": "tsc --watch",
|
|
17
|
+
"test": "tsx --test test/*.test.ts",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"approval",
|
|
25
|
+
"agents",
|
|
26
|
+
"ai",
|
|
27
|
+
"sdk",
|
|
28
|
+
"security"
|
|
29
|
+
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/oked-ai/oked-sdk.git",
|
|
33
|
+
"directory": "packages/sdk"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/oked-ai/oked-sdk/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/oked-ai/oked-sdk#readme",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^22.13.10",
|
|
48
|
+
"tsx": "^4.22.0",
|
|
49
|
+
"typescript": "^5.6.0"
|
|
50
|
+
}
|
|
51
|
+
}
|