openclaw-brokerkit 0.1.0 → 0.3.0
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 +109 -98
- package/dist/src/browser-session.js +7 -0
- package/dist/src/commands.js +8 -9
- package/dist/src/generated/openapi-operator-v1.js +5 -0
- package/dist/src/generated/operator-v1.js +14 -11
- package/dist/src/generated/operator-validators.js +2920 -0
- package/dist/src/http.js +92 -18
- package/dist/src/operator-v1.js +26 -80
- package/dist/src/revisions.js +108 -0
- package/dist/src/runtime.js +52 -17
- package/dist/ui/assets/index-xbT6e20b.js +149 -0
- package/dist/ui/index.html +1 -2
- package/package.json +24 -7
- package/dist/ui/assets/index-8w0_bcoC.js +0 -143
- package/dist/ui/assets/index-D8Ypbs3j.css +0 -1
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# OpenClaw BrokerKit
|
|
2
2
|
|
|
3
|
-
`openclaw-brokerkit` adds a provider-neutral
|
|
4
|
-
commands to OpenClaw. It connects to one or
|
|
5
|
-
|
|
6
|
-
executable plans.
|
|
3
|
+
`openclaw-brokerkit` is an OpenClaw plugin that adds a provider-neutral
|
|
4
|
+
Approvals tab and `/brokerkit` commands to OpenClaw. It connects to one or
|
|
5
|
+
more BrokerKit Operator V1 sources; the brokers remain authoritative and
|
|
6
|
+
retain all provider credentials and executable plans.
|
|
7
7
|
|
|
8
|
-
The minimum supported host is `openclaw@2026.7.1
|
|
8
|
+
The minimum supported host is `openclaw@2026.7.1`, the first stable
|
|
9
9
|
SDK used by this package that includes public tab descriptors.
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Install an exact release from
|
|
14
14
|
[npm](https://www.npmjs.com/package/openclaw-brokerkit) through OpenClaw:
|
|
15
15
|
|
|
16
16
|
```sh
|
|
@@ -24,15 +24,16 @@ pnpm --filter openclaw-brokerkit build
|
|
|
24
24
|
openclaw plugins install --link ./plugins/openclaw
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
Choose
|
|
27
|
+
## Choose a trust mode
|
|
28
28
|
|
|
29
|
-
- `direct` trusts the OpenClaw process with operator SecretRefs and enables
|
|
30
|
-
tab, background reconciliation, `/brokerkit` commands, and channel
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
- `direct` trusts the OpenClaw process with operator SecretRefs and enables
|
|
30
|
+
the tab, background reconciliation, `/brokerkit` commands, and channel
|
|
31
|
+
delivery.
|
|
32
|
+
- `delegated-web` packages only the tab UI and delegates authenticated
|
|
33
|
+
browser requests to a same-origin trusted backend. It gives OpenClaw no
|
|
34
|
+
broker credential and registers no command or background source service.
|
|
34
35
|
|
|
35
|
-
##
|
|
36
|
+
## Direct mode configuration
|
|
36
37
|
|
|
37
38
|
```json5
|
|
38
39
|
{
|
|
@@ -46,7 +47,7 @@ Choose one explicit trust mode:
|
|
|
46
47
|
{
|
|
47
48
|
id: "hf-primary",
|
|
48
49
|
label: "Hugging Face",
|
|
49
|
-
endpoint: "
|
|
50
|
+
endpoint: "https://hf-broker.example.com",
|
|
50
51
|
operatorCredential: {
|
|
51
52
|
source: "env",
|
|
52
53
|
provider: "default",
|
|
@@ -61,12 +62,34 @@ Choose one explicit trust mode:
|
|
|
61
62
|
}
|
|
62
63
|
```
|
|
63
64
|
|
|
64
|
-
Literal operator credentials are rejected.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
Literal operator credentials are rejected; `operatorCredential.source` is
|
|
66
|
+
`env`, `file`, or `exec`. Non-loopback endpoints require HTTPS. Each
|
|
67
|
+
`endpoint` is the broker's Operator V1 listener, not its agent listener. The
|
|
68
|
+
plugin stores only cursors, opaque handles, generic channel destinations, and
|
|
69
|
+
delivery bookkeeping under the OpenClaw service state directory.
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
## Commands
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
/brokerkit subscribe
|
|
75
|
+
/brokerkit unsubscribe
|
|
76
|
+
/brokerkit pending
|
|
77
|
+
/brokerkit show <handle>
|
|
78
|
+
/brokerkit approve <handle>
|
|
79
|
+
/brokerkit deny <handle>
|
|
80
|
+
/brokerkit revoke <handle>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Commands are registered only in direct mode. They require an authorized
|
|
84
|
+
sender and the `operator.approvals` scope. Requesters cancel their own
|
|
85
|
+
pending requests through the authenticated broker client API, not through
|
|
86
|
+
this operator surface. Subscriptions use OpenClaw's generic outbound adapter,
|
|
87
|
+
so this package contains no Telegram, Discord, Slack, or other
|
|
88
|
+
channel-specific implementation.
|
|
89
|
+
|
|
90
|
+
## Delegated web mode
|
|
91
|
+
|
|
92
|
+
For a deployment that treats OpenClaw as untrusted:
|
|
70
93
|
|
|
71
94
|
```json5
|
|
72
95
|
{
|
|
@@ -87,111 +110,99 @@ For a deployment that treats OpenClaw as untrusted, configure delegated web:
|
|
|
87
110
|
```
|
|
88
111
|
|
|
89
112
|
The trusted backend implements `brokerkit.io/delegated-web/v1`, authenticates
|
|
90
|
-
the human operator, and issues an in-memory decision token lasting no more
|
|
91
|
-
five minutes. The base path must be a normalized same-origin absolute
|
|
92
|
-
The OpenClaw gateway must set `gateway.controlUi.embedSandbox` to
|
|
93
|
-
the approval tab can run while retaining its opaque sandbox
|
|
94
|
-
|
|
95
|
-
sandbox.
|
|
113
|
+
the human operator, and issues an in-memory decision token lasting no more
|
|
114
|
+
than five minutes. The base path must be a normalized same-origin absolute
|
|
115
|
+
path. The OpenClaw gateway must set `gateway.controlUi.embedSandbox` to
|
|
116
|
+
`scripts` so the approval tab can run while retaining its opaque sandbox
|
|
117
|
+
origin; do not use `trusted`.
|
|
96
118
|
|
|
97
119
|
When OpenClaw is outside the credential trust boundary, the trusted backend
|
|
98
120
|
must serve the packaged `dist/ui` files at the registered UI path itself. A
|
|
99
|
-
framed popover may receive a server-enforced `read` or `decide` session
|
|
100
|
-
`read` session shows requests without action controls
|
|
101
|
-
the operator act directly in the frame.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
121
|
+
framed popover may receive a server-enforced `read` or `decide` session: a
|
|
122
|
+
`read` session shows requests without action controls, and a `decide` session
|
|
123
|
+
lets the operator act directly in the frame. The OpenClaw Gateway approvals
|
|
124
|
+
popover is an actionable surface and must receive `decide`; the trusted host
|
|
125
|
+
must retain decision authority and validate that access on every request.
|
|
126
|
+
|
|
127
|
+
### Session injection
|
|
105
128
|
|
|
106
|
-
The host injects the short-lived delegated session into the sandboxed
|
|
129
|
+
The host injects the short-lived delegated session into the sandboxed
|
|
130
|
+
response:
|
|
107
131
|
|
|
108
132
|
```html
|
|
109
133
|
<meta name="brokerkit-delegated-session" content="BASE64URL_SESSION_JSON" />
|
|
110
134
|
```
|
|
111
135
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
```text
|
|
117
|
-
{ type: "brokerkit.delegated-web.open", version: 1, nonce }
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
The host verifies the exact opaque-origin frame source and navigates the whole
|
|
121
|
-
browser tab to the trusted UI URL. The top-level response is unframeable and
|
|
122
|
-
contains a server-enforced decision session, so approval, denial, cancellation,
|
|
123
|
-
and revocation require a second explicit action in the trusted document.
|
|
124
|
-
|
|
125
|
-
A host that does not provide a framed inbox can inject this marker so the UI
|
|
126
|
-
renders only the secure-navigation launcher:
|
|
127
|
-
|
|
128
|
-
```html
|
|
129
|
-
<meta name="brokerkit-delegated-top-level" />
|
|
130
|
-
```
|
|
136
|
+
Token-bearing HTML responses must enforce `sandbox allow-scripts` in their
|
|
137
|
+
CSP, and immutable UI assets must be loadable by the opaque document (serve
|
|
138
|
+
them without a same-origin CORP restriction or set
|
|
139
|
+
`Cross-Origin-Resource-Policy: cross-origin`).
|
|
131
140
|
|
|
132
141
|
The content is a base64url-encoded `brokerkit.io/delegated-web/v1` session
|
|
133
|
-
object
|
|
134
|
-
closed payload:
|
|
142
|
+
object; the UI removes the element as soon as it reads it. Version 1 uses
|
|
143
|
+
this closed payload:
|
|
135
144
|
|
|
136
145
|
```json
|
|
137
146
|
{
|
|
138
147
|
"api_version": "brokerkit.io/delegated-web/v1",
|
|
139
|
-
"token": "opaque-short-lived-
|
|
140
|
-
"expires_at": "
|
|
141
|
-
"access": "
|
|
148
|
+
"token": "opaque-short-lived-browser-session",
|
|
149
|
+
"expires_at": "<no more than five minutes from issue time, RFC3339>",
|
|
150
|
+
"access": "decide",
|
|
142
151
|
"renewal_transport": "direct"
|
|
143
152
|
}
|
|
144
153
|
```
|
|
145
154
|
|
|
146
155
|
`access` is `read` or `decide`; the host enforces it on every endpoint.
|
|
147
|
-
`renewal_transport` is `direct`
|
|
148
|
-
`<basePath>/session`
|
|
149
|
-
|
|
150
|
-
|
|
156
|
+
`renewal_transport` is `direct` (the UI posts the current session to
|
|
157
|
+
`<basePath>/session`) or `parent` (the nonce-bound bridge below returns the
|
|
158
|
+
replacement session in memory). The host preserves the token's access when it
|
|
159
|
+
returns a replacement session.
|
|
151
160
|
|
|
152
|
-
|
|
153
|
-
delegated session endpoint directly may instead use this host-neutral bridge:
|
|
154
|
-
|
|
155
|
-
```text
|
|
156
|
-
request: { type: "brokerkit.delegated-web.session.request", version: 1, nonce }
|
|
157
|
-
response: { type: "brokerkit.delegated-web.session.response", nonce, session }
|
|
158
|
-
```
|
|
161
|
+
### Browser session transport
|
|
159
162
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
same `brokerkit.io/delegated-web/v1` object returned by `POST
|
|
163
|
-
<basePath>/session`. The bridge is a BrokerKit interface; it contains no
|
|
164
|
-
host-product namespace or host-specific payload.
|
|
163
|
+
Every direct and delegated-web browser API call carries its raw session in
|
|
164
|
+
one fixed HTTP field:
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
/
|
|
171
|
-
/brokerkit pending
|
|
172
|
-
/brokerkit show <handle>
|
|
173
|
-
/brokerkit approve <handle>
|
|
174
|
-
/brokerkit deny <handle>
|
|
175
|
-
/brokerkit cancel <handle>
|
|
176
|
-
/brokerkit revoke <handle>
|
|
166
|
+
```http
|
|
167
|
+
GET /trusted-host/api/brokerkit/snapshot HTTP/1.1
|
|
168
|
+
Origin: null
|
|
169
|
+
BrokerKit-Session: eyJ2ZXJzaW9uIjoxLCJhdWRpZW5jZSI6Ii4uLiJ9.signature
|
|
170
|
+
Accept: application/json
|
|
177
171
|
```
|
|
178
172
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
173
|
+
`BrokerKit-Session` has no authentication-scheme prefix. A host must reject
|
|
174
|
+
empty, repeated, combined, malformed, or oversized values; tokens are 32 to
|
|
175
|
+
4096 bytes of visible ASCII excluding comma and whitespace. The same field
|
|
176
|
+
protects `POST /session`, `GET /snapshot`, `GET /events`, request detail,
|
|
177
|
+
approval, denial, and revocation; direct-mode capabilities use it on
|
|
178
|
+
`/plugins/brokerkit/api/v1` as well.
|
|
179
|
+
|
|
180
|
+
Standard `Authorization` is reserved for the hosting edge and for
|
|
181
|
+
server-to-server Operator V1 clients. Browser clients never use it, and never
|
|
182
|
+
put a delegated session in cookies, query parameters, local storage, or
|
|
183
|
+
session storage. Tokens must not be logged, traced, reflected in errors,
|
|
184
|
+
copied into an Operator V1 request, or persisted by the host or UI.
|
|
185
|
+
|
|
186
|
+
Because the packaged UI has an opaque origin under the required scripts-only
|
|
187
|
+
sandbox, a delegated host must accept only the expected `Origin: null`,
|
|
188
|
+
return `Access-Control-Allow-Origin: null`, allow `BrokerKit-Session` and
|
|
189
|
+
`Content-Type` in preflight responses, allow only its fixed route methods,
|
|
190
|
+
and set `Vary: Origin` plus `Cache-Control: no-store`. It must not return
|
|
191
|
+
`Access-Control-Allow-Credentials: true`; delegated API requests deliberately
|
|
192
|
+
omit cookies.
|
|
193
|
+
|
|
194
|
+
### Parent session bridge
|
|
183
195
|
|
|
184
|
-
|
|
196
|
+
When the parent application is trusted, a sandboxed tab that cannot call the
|
|
197
|
+
delegated session endpoint directly may instead use this host-neutral bridge:
|
|
185
198
|
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
pnpm --filter openclaw-brokerkit test:browser
|
|
190
|
-
pnpm --filter openclaw-brokerkit build
|
|
191
|
-
pnpm --filter openclaw-brokerkit test:package
|
|
199
|
+
```text
|
|
200
|
+
request: { type: "brokerkit.delegated-web.session.request", version: 1, nonce }
|
|
201
|
+
response: { type: "brokerkit.delegated-web.session.response", nonce, session }
|
|
192
202
|
```
|
|
193
203
|
|
|
194
|
-
The
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
204
|
+
The trusted parent must answer only requests from the embedded BrokerKit
|
|
205
|
+
frame and must bind each response to the supplied 128-bit nonce. `session` is
|
|
206
|
+
the same `brokerkit.io/delegated-web/v1` object returned by
|
|
207
|
+
`POST <basePath>/session`. The bridge is a BrokerKit interface; it contains
|
|
208
|
+
no host-product namespace or host-specific payload.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const BROWSER_SESSION_HEADER = "BrokerKit-Session";
|
|
2
|
+
export const MAX_BROWSER_SESSION_BYTES = 4096;
|
|
3
|
+
export function validBrowserSession(value) {
|
|
4
|
+
return (value.length >= 32 &&
|
|
5
|
+
value.length <= MAX_BROWSER_SESSION_BYTES &&
|
|
6
|
+
/^[\x21-\x2B\x2D-\x7E]+$/u.test(value));
|
|
7
|
+
}
|
package/dist/src/commands.js
CHANGED
|
@@ -36,8 +36,8 @@ export async function handleCommand(runtime, ctx) {
|
|
|
36
36
|
return { text: "Invalid BrokerKit command." };
|
|
37
37
|
const lines = runtime
|
|
38
38
|
.snapshot()
|
|
39
|
-
.requests.filter((request) => request.status === "pending")
|
|
40
|
-
.map((request) => `${request.handle} · ${request.
|
|
39
|
+
.requests.filter((request) => request.request.status === "pending")
|
|
40
|
+
.map((request) => `${request.handle} · ${request.source_label} · ${request.request.presentation.title}`);
|
|
41
41
|
return {
|
|
42
42
|
text: lines.length ? lines.join("\n") : "No pending BrokerKit requests.",
|
|
43
43
|
};
|
|
@@ -49,13 +49,13 @@ export async function handleCommand(runtime, ctx) {
|
|
|
49
49
|
.requests.find((item) => item.handle === handle);
|
|
50
50
|
if (command === "show")
|
|
51
51
|
return { text: request ? formatRequest(request) : "Request not found." };
|
|
52
|
-
if (["approve", "deny", "
|
|
52
|
+
if (["approve", "deny", "revoke"].includes(command)) {
|
|
53
53
|
if (!request)
|
|
54
54
|
return { text: "Request not found." };
|
|
55
55
|
try {
|
|
56
|
-
const updated = await runtime.decide(handle, command, request.revision, ctx.senderId);
|
|
56
|
+
const updated = await runtime.decide(handle, command, request.request.revision, ctx.senderId);
|
|
57
57
|
return {
|
|
58
|
-
text: `${capitalize(command)} committed for ${updated.presentation.title}.`,
|
|
58
|
+
text: `${capitalize(command)} committed for ${updated.request.presentation.title}.`,
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
catch (error) {
|
|
@@ -88,11 +88,10 @@ function capitalize(value) {
|
|
|
88
88
|
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
89
89
|
}
|
|
90
90
|
function formatRequest(request) {
|
|
91
|
-
const facts = request.presentation.facts?.map((fact) => `${fact.label}: ${fact.value}`) ??
|
|
92
|
-
[];
|
|
91
|
+
const facts = request.request.presentation.facts?.map((fact) => `${fact.label}: ${fact.value}`) ?? [];
|
|
93
92
|
return [
|
|
94
|
-
`${request.
|
|
95
|
-
request.presentation.summary ?? "",
|
|
93
|
+
`${request.source_label}: ${request.request.presentation.title}`,
|
|
94
|
+
request.request.presentation.summary ?? "",
|
|
96
95
|
...facts,
|
|
97
96
|
`Handle: ${request.handle}`,
|
|
98
97
|
]
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export const OPERATOR_V1_SCHEMA_SHA256 = "a4510c3d0e1ddf32dfb8e8bd684677ade3f3d6541912d42720af8c43ef11c2eb";
|
|
1
|
+
export const OPERATOR_V1_SCHEMA_SHA256 = "306810514cd7e378b194f9d539aae99de07396994ec7de273a18dc5a4aa47118";
|
|
3
2
|
export const operatorV1 = {
|
|
4
3
|
apiVersion: "brokerkit.io/operator/v1",
|
|
5
4
|
statuses: [
|
|
@@ -11,29 +10,33 @@ export const operatorV1 = {
|
|
|
11
10
|
"consumed",
|
|
12
11
|
"revoked",
|
|
13
12
|
],
|
|
14
|
-
actions: ["approve", "deny", "
|
|
15
|
-
risks: ["unknown", "low", "medium", "high", "critical"],
|
|
13
|
+
actions: ["approve", "deny", "revoke"],
|
|
16
14
|
eventKinds: [
|
|
17
15
|
"request.created",
|
|
18
16
|
"request.approved",
|
|
19
17
|
"request.denied",
|
|
20
18
|
"request.canceled",
|
|
21
19
|
"request.expired",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
20
|
+
"grant.revoked",
|
|
21
|
+
"grant.reserved",
|
|
22
|
+
"grant.consumed",
|
|
23
|
+
"grant.released",
|
|
24
|
+
"execution.succeeded",
|
|
25
|
+
"execution.failed",
|
|
26
|
+
"execution.ambiguous",
|
|
25
27
|
],
|
|
26
28
|
errorCodes: [
|
|
27
29
|
"invalid_request",
|
|
28
30
|
"unauthorized",
|
|
29
31
|
"forbidden",
|
|
30
32
|
"not_found",
|
|
33
|
+
"method_not_allowed",
|
|
31
34
|
"revision_conflict",
|
|
32
|
-
"invalid_transition",
|
|
33
|
-
"constraint_exceeded",
|
|
34
35
|
"idempotency_conflict",
|
|
36
|
+
"constraint_exceeded",
|
|
37
|
+
"invalid_transition",
|
|
38
|
+
"invalid_decision_token",
|
|
35
39
|
"cursor_expired",
|
|
36
|
-
"rate_limited",
|
|
37
40
|
"temporarily_unavailable",
|
|
38
41
|
"internal_error",
|
|
39
42
|
],
|
|
@@ -52,6 +55,6 @@ export const operatorV1 = {
|
|
|
52
55
|
page: 100,
|
|
53
56
|
idempotencyKey: 200,
|
|
54
57
|
errorMessage: 500,
|
|
55
|
-
correlationId:
|
|
58
|
+
correlationId: 128,
|
|
56
59
|
},
|
|
57
60
|
};
|