@ory/openclaw 0.11.1 → 0.12.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/README.md +96 -174
- package/dist/cli/main.js +21 -31
- package/dist/cli/plugin-config.d.ts +52 -0
- package/dist/cli/plugin-config.js +192 -0
- package/dist/cli/setup.js +17 -23
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# Ory Agent Plugin: OpenClaw
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Security and developer experience for [OpenClaw](https://github.com/openclaw/openclaw), powered by [Ory](https://ory.com).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Security.** OpenClaw runs real actions on your machine — editing files, running shell commands, calling APIs. The plugin gives every session a verifiable identity (you sign in once; OpenClaw and any sub-agents it spawns each get their own), checks every tool call against permissions you control, and records each decision as an audit trace you can ship to your observability stack. It starts in watch mode so nothing is blocked on day one, and if Ory is ever unreachable it steps aside rather than locking you out.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**Developer experience.** A single command installs the plugin and walks you through connecting — choose Ory Network, a local Docker stack, or audit-only, and it wires up the project, sign-in client, login, and permissions for you. It also helps you build Ory into your own app: ask in plain language to scaffold login, registration, and recovery pages, run a local Ory, or manage identities and permissions through the bundled MCP server.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## What you'll need
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
- **
|
|
11
|
+
- [OpenClaw](https://github.com/openclaw/openclaw), installed and configured
|
|
12
|
+
- Node.js **22 or newer**
|
|
13
|
+
- [Docker](https://docs.docker.com/get-docker/) — only if you want to run Ory locally
|
|
14
|
+
- macOS or Linux (Windows works via WSL2)
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
## Get started
|
|
15
17
|
|
|
16
18
|
1. **Build auth into your app.** Have OpenClaw scaffold Ory login, registration, social sign-in, and permissions into the project you're working on, backed by the local stack. This is the Quickstart below — it needs nothing but Docker.
|
|
17
19
|
2. **Govern the agent itself.** Authenticate OpenClaw's own session and authorize every tool it runs against Ory Permissions, with a full audit trail. See [Agent security](#agent-security).
|
|
@@ -27,132 +29,118 @@ If you're just exploring, do the Quickstart first.
|
|
|
27
29
|
|
|
28
30
|
## Install
|
|
29
31
|
|
|
30
|
-
OpenClaw
|
|
32
|
+
OpenClaw discovers plugins by their manifest id (`ory-agent-security`) under the nested `plugins` object in `.openclaw/config.json` — it does not scan `node_modules`, so the plugin's location has to be registered. Two ways to do that:
|
|
33
|
+
|
|
34
|
+
**Recommended — OpenClaw's plugin ecosystem.** Copies the plugin into OpenClaw's managed extensions directory and enables it by id:
|
|
31
35
|
|
|
32
36
|
```bash
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
npx @ory/openclaw uninstall
|
|
37
|
+
openclaw plugins install npm:@ory/openclaw
|
|
38
|
+
openclaw plugins enable ory-agent-security
|
|
36
39
|
```
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
**Or let the Ory CLI write the config.** This registers the installed package directory on `plugins.load.paths` and sets `plugins.entries.ory-agent-security.enabled = true`, and also installs the Ory skills and MCP server. Install the package into the project first so it has a stable path for OpenClaw to load:
|
|
39
42
|
|
|
40
43
|
```bash
|
|
41
|
-
|
|
44
|
+
npm install @ory/openclaw # so OpenClaw can resolve the package
|
|
45
|
+
npx @ory/openclaw install # register + enable in .openclaw/config.json
|
|
46
|
+
npx @ory/openclaw install --project-dir <path>
|
|
47
|
+
npx @ory/openclaw uninstall
|
|
48
|
+
Run one command. It installs the plugin and walks you through connecting:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx -y -p @ory/openclaw ory-openclaw install
|
|
42
52
|
```
|
|
43
53
|
|
|
44
|
-
|
|
54
|
+
OpenClaw loads plugins that run inside its own process, so the installer registers the plugin in `.openclaw/config.json` (along with its skills and the Ory MCP server), then walks you through connecting. You'll be asked how you want to connect — **press Enter for the default**:
|
|
45
55
|
|
|
46
|
-
|
|
56
|
+
- **Ory Network** *(default)* — sign in, or create a free account, in your browser. The project, keys, permissions, and login are all set up for you. Nothing to configure by hand.
|
|
57
|
+
- **Local** — run a complete Ory on your laptop with Docker. No account, no signup, no keys. Great for trying it out.
|
|
58
|
+
- **Audit-only** — skip Ory entirely and just log what OpenClaw does.
|
|
47
59
|
|
|
48
|
-
|
|
60
|
+
That's it. Confirm everything landed with:
|
|
49
61
|
|
|
50
|
-
|
|
62
|
+
```bash
|
|
63
|
+
npx -y -p @ory/openclaw ory-openclaw status
|
|
64
|
+
```
|
|
51
65
|
|
|
52
|
-
|
|
66
|
+
`status` is your one-stop check: what's configured, who's signed in, which tools are covered by permissions, plugin and skill registration, and recent activity. Anything not set up yet shows as `(unset)`.
|
|
53
67
|
|
|
54
|
-
|
|
68
|
+
Re-run install with `--reconfigure` to change your connection later, or `--no-configure` to skip the wizard.
|
|
55
69
|
|
|
56
|
-
|
|
70
|
+
<details>
|
|
71
|
+
<summary>Register the plugin by hand</summary>
|
|
57
72
|
|
|
58
|
-
|
|
73
|
+
OpenClaw finds in-process plugins by module name from `node_modules` plus an entry in `.openclaw/config.json`. To register it without the guided setup:
|
|
59
74
|
|
|
60
|
-
|
|
75
|
+
```bash
|
|
76
|
+
npx @ory/openclaw install # registers in .openclaw/config.json
|
|
77
|
+
npx @ory/openclaw install --project-dir <path>
|
|
78
|
+
npx @ory/openclaw uninstall
|
|
79
|
+
```
|
|
61
80
|
|
|
62
|
-
|
|
63
|
-
export ORY_USER_LOGIN=true
|
|
64
|
-
export ORY_OAUTH2_CLIENT_ID=<value printed by `local up`>
|
|
65
|
-
```
|
|
81
|
+
This registers the plugin and its skills but skips the connect step. Run `ory-openclaw install` (or `configure`) in a terminal afterwards to connect.
|
|
66
82
|
|
|
67
|
-
|
|
83
|
+
</details>
|
|
68
84
|
|
|
69
|
-
|
|
85
|
+
## What you get
|
|
70
86
|
|
|
71
|
-
|
|
87
|
+
Once connected, every tool OpenClaw runs is governed by Ory — three things happen automatically:
|
|
72
88
|
|
|
73
|
-
|
|
89
|
+
- **Who's driving.** You sign in once in your browser; the OpenClaw process gets its own identity too, registered automatically on first run. No tokens to copy around, and the "who acted on whose behalf" trail stays queryable later.
|
|
90
|
+
- **What it's allowed to do.** Before a tool runs, Ory checks whether it's permitted. It starts in **watch mode** — nothing is blocked, you just *see* what would be — so it never gets in your way on day one.
|
|
91
|
+
- **A record of everything.** Every decision (allowed, denied, skipped) is logged as a trace you can send to Jaeger, Honeycomb, Grafana, or just a file.
|
|
74
92
|
|
|
75
|
-
|
|
93
|
+
If Ory is ever unreachable, the plugin gets out of the way and lets OpenClaw keep working — so it can't lock you out.
|
|
76
94
|
|
|
77
|
-
**
|
|
95
|
+
> **One nuance:** because the plugin runs inside OpenClaw's own process, it can't hard-block at the moment a session opens. Browser sign-in still runs there and the record stays correct — but the session always proceeds. Per-tool checks are unaffected: when a tool is about to run, a denial blocks it for real.
|
|
78
96
|
|
|
79
|
-
|
|
80
|
-
- **`ory-login-flow`** — login, registration, recovery, verification, and settings pages with Ory Elements. Next.js App Router and React SPA variants.
|
|
81
|
-
- **`ory-social-login`** — Google, GitHub, Apple, Microsoft, Discord, and other OIDC providers with Jsonnet data mappers.
|
|
82
|
-
- **`ory-local-dev`** — drive the local Ory stack from within OpenClaw to prototype and test without a remote project.
|
|
97
|
+
### See what's happening
|
|
83
98
|
|
|
84
|
-
|
|
99
|
+
Everything the plugin does is observable out of the box — no configuration required:
|
|
85
100
|
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
- **`ory-contribute-integration`** — author a brand-new integration as a contribution to `ory/integrates`, including `registry.entry.yaml`, the `Maintained by:` footer, DCO sign-off, and registry regeneration.
|
|
89
|
-
- **`ory-e2b-sandbox`** — scaffold an [E2B](https://e2b.dev) sandbox template that boots with this plugin preinstalled and registered, so every sandbox session is gated by Ory auth, permissions, and tracing without any per-sandbox setup.
|
|
90
|
-
- **`ory-build-agent`** — drop `@ory/argus` directly into a custom agent you own (Claude Agent SDK, OpenAI Agents SDK, Mastra, Vercel AI SDK, PydanticAI, LangGraph, Mistral AI, or Salesforce Agentforce) so the user is authenticated, every tool call is authorized against Ory Permissions, and the lifecycle emits trace spans.
|
|
91
|
-
- **`ory-temporal-worker`** — scaffold a [Temporal](https://temporal.io) TypeScript worker per the [official local-dev guide](https://docs.temporal.io/develop/typescript/set-up-your-local-typescript), with every Activity gated by an Ory permission check, the worker's agent identity resolved via DCR, and the full lifecycle emitting trace spans.
|
|
101
|
+
- **Status at a glance.** `npx -y -p @ory/openclaw ory-openclaw status` shows what's configured, who's signed in, how many built-in tools your permissions cover, and the most recent tool-call activity.
|
|
102
|
+
- **Live traces.** Every tool call is recorded as an OpenTelemetry-style span. Watch them stream as the agent works:
|
|
92
103
|
|
|
93
|
-
|
|
104
|
+
```bash
|
|
105
|
+
npx -y -p @ory/openclaw ory-openclaw watch
|
|
106
|
+
```
|
|
94
107
|
|
|
95
|
-
|
|
108
|
+
Spans are also written to `~/.config/ory-agent-plugins/openclaw/ory-agent-trace.ndjson` (NDJSON, one span per line) — tail that file, or point `OTEL_EXPORTER_OTLP_ENDPOINT` at a collector to ship them straight to Jaeger, Honeycomb, or Grafana.
|
|
109
|
+
- **Debug log.** For a verbose play-by-play, set `ORY_AGENT_DEBUG=true`; structured logs land in `~/.config/ory-agent-plugins/openclaw/ory-agent-debug.log`.
|
|
96
110
|
|
|
97
|
-
###
|
|
111
|
+
### Ready to enforce?
|
|
98
112
|
|
|
99
|
-
|
|
113
|
+
When the watch-mode logs look right, turn on blocking with one command (setup already granted you the built-in tools):
|
|
100
114
|
|
|
115
|
+
```bash
|
|
116
|
+
npx -y -p @ory/openclaw ory-openclaw permissions enforce
|
|
101
117
|
```
|
|
102
|
-
ory-local-up # start a local Ory instance in Docker
|
|
103
|
-
ory-local-down # tear it all down
|
|
104
|
-
ory-temporal-up # start a local Temporal dev server (for ory-temporal-worker)
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Or via the CLI: `npx -y -p @ory/openclaw ory-openclaw local up | down`.
|
|
108
118
|
|
|
109
|
-
|
|
119
|
+
Now a denied tool is actually blocked and OpenClaw shows why. Go back to watch mode anytime with `permissions observe`. Use `permissions status` to see what's covered and `permissions bootstrap` to (re-)grant the built-in tools — or just ask OpenClaw in chat, e.g. *"grant me use of the execute_command tool."*
|
|
110
120
|
|
|
111
|
-
|
|
112
|
-
- **Prototype** flows (login, social, MFA, recovery, permissions) against a real Ory backend.
|
|
113
|
-
- **Test** an auth integration end-to-end before pushing anything to a real environment.
|
|
114
|
-
- **Develop** your application against the same identity, OAuth2, and permission surfaces you'll ship with.
|
|
121
|
+
## Also: add login to your own app
|
|
115
122
|
|
|
116
|
-
|
|
123
|
+
Beyond securing OpenClaw, the plugin helps you build Ory into whatever you're working on. Ask OpenClaw *"add Ory login to this app"* and it scaffolds the login, registration, recovery, and settings pages (using [Ory Elements](https://github.com/ory/elements)) wired to a local Ory — no signup or keys needed. Start that local Ory with the `ory-local-up` skill (it prints a test email + password to sign in with) and tear it down with `ory-local-down`.
|
|
117
124
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
npx -y -p @ory/openclaw ory-openclaw configure \
|
|
122
|
-
--project-url https://<id>.projects.oryapis.com \
|
|
123
|
-
--oauth2-client-id <public OAuth2 client id>
|
|
124
|
-
```
|
|
125
|
+
Bundled **skills** (just ask in plain language, or pick one from OpenClaw's skill picker) cover more: `ory-auth-setup`, `ory-login-flow`, `ory-social-login` (Google, GitHub, Apple…), `ory-permissions-onboarding`, and playbooks for wiring Ory into your own agents, E2B sandboxes, or Temporal workers. A built-in **Ory MCP server** lets OpenClaw manage identities, projects, and permissions straight from chat.
|
|
125
126
|
|
|
126
|
-
|
|
127
|
-
- **`--oauth2-client-id`** is required because the **user** PKCE browser flow (triggered by `ORY_USER_LOGIN=true`) cannot self-register — you must register a public OAuth2 client ahead of time and supply its id here. The configure command refuses to save a project URL without it, so you don't end up with a silently-broken setup later. See [Register the user OAuth2 client](#register-the-user-oauth2-client) below for the exact CLI / Console steps.
|
|
128
|
-
- **`--api-key ory_pat_...`** is optional — pass it only if you want to override the auto-registered agent identity with a static personal access token (operator override; rarely needed).
|
|
127
|
+
## Configure by hand (CI / advanced)
|
|
129
128
|
|
|
130
|
-
|
|
129
|
+
The guided setup covers most people. For scripted or CI setups, or to point at an existing Ory Network project, configure directly. Settings are saved to `~/.config/ory-agent-plugins/config.json` and shared across all your Ory agent plugins; environment variables win when both are set.
|
|
131
130
|
|
|
132
131
|
```bash
|
|
133
|
-
npx -y -p @ory/openclaw ory-openclaw configure
|
|
132
|
+
npx -y -p @ory/openclaw ory-openclaw configure \
|
|
133
|
+
--project-url https://<slug>.projects.oryapis.com \
|
|
134
|
+
--oauth2-client-id <sign-in client id> \
|
|
135
|
+
--user-login
|
|
134
136
|
```
|
|
135
137
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
Config is saved to `~/.config/ory-agent-plugins/config.json` and shared across every Ory agent plugin on the machine.
|
|
139
|
-
|
|
140
|
-
Without configuration the plugin still loads cleanly and runs in **pass-through mode**: skills work, but nothing is blocked. You can stay in pass-through mode indefinitely if you only want the DX features.
|
|
141
|
-
|
|
142
|
-
### Register the user OAuth2 client
|
|
143
|
-
|
|
144
|
-
If you plan to turn on `ORY_USER_LOGIN=true` (recommended — it's what attributes every tool call to *you* rather than a fallback `session:<id>` subject), your hosted Ory project needs a **public** OAuth2 client (no client secret) registered ahead of time. The local stack provisions this for you automatically; against a hosted project you have to register it once yourself.
|
|
145
|
-
|
|
146
|
-
The client must list **all four** loopback ports as redirect URIs:
|
|
138
|
+
OpenClaw's own identity registers itself automatically on first run — nothing to create. The `--oauth2-client-id` is the one piece browser sign-in needs; the guided setup makes it for you, or see below to do it by hand. For logging-only with no checks, use `--audit-only`.
|
|
147
139
|
|
|
148
|
-
|
|
149
|
-
-
|
|
150
|
-
- `http://127.0.0.1:47825/callback`
|
|
151
|
-
- `http://127.0.0.1:47826/callback`
|
|
140
|
+
<details>
|
|
141
|
+
<summary>Create the sign-in client by hand</summary>
|
|
152
142
|
|
|
153
|
-
The
|
|
154
|
-
|
|
155
|
-
Create the client with the [Ory CLI](https://www.ory.com/docs/guides/cli/installation):
|
|
143
|
+
The guided setup normally does this. To do it yourself, create a **public** OAuth2 client (no secret) listing all four loopback URLs — the plugin tries each in turn so sign-in survives a busy port:
|
|
156
144
|
|
|
157
145
|
```bash
|
|
158
146
|
ory create oauth2-client --project <project-id> \
|
|
@@ -167,103 +155,37 @@ ory create oauth2-client --project <project-id> \
|
|
|
167
155
|
--redirect-uri http://127.0.0.1:47826/callback
|
|
168
156
|
```
|
|
169
157
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
npx -y -p @ory/openclaw ory-openclaw configure \
|
|
174
|
-
--project-url https://<id>.projects.oryapis.com \
|
|
175
|
-
--oauth2-client-id <client-id from the step above>
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
…or set it in the environment alongside `ORY_USER_LOGIN`:
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
export ORY_USER_LOGIN=true
|
|
182
|
-
export ORY_OAUTH2_CLIENT_ID=<client-id from the step above>
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
Headless / CI runs that already hold a session token can skip this entirely by setting `ORY_USER_SESSION_TOKEN` instead — no browser flow runs, so no OAuth2 client is needed.
|
|
186
|
-
|
|
187
|
-
## Agent security
|
|
188
|
-
|
|
189
|
-
Once the plugin is pointed at an Ory project (local or hosted), OpenClaw's session and every tool call can be governed by Ory.
|
|
190
|
-
|
|
191
|
-
- **Authentication.** Two identities. The human at the keyboard (the **user**) authenticates interactively via Ory Identities when user login is enabled (`ORY_USER_LOGIN=true`, off by default — browser PKCE flow on first session, persisted token thereafter). The OpenClaw process (the **agent**) gets its own OAuth2 identity, self-registered via [Dynamic Client Registration (RFC 7591)](https://datatracker.ietf.org/doc/html/rfc7591) on first run.
|
|
192
|
-
- **Authorization.** Before any tool runs, the plugin checks [Ory Permissions](https://www.ory.com/docs/keto) (Zanzibar-style relations) against the user's subject and blocks the call on `deny`. MCP tool calls additionally get a server-level check.
|
|
193
|
-
- **Audit.** Every decision (allow, deny, fallback) is recorded as a structured trace span: NDJSON file output and/or OTLP/HTTP export to Jaeger, Honeycomb, Grafana, and similar collectors. The user → agent delegation is written to Ory as a relation so *"agent X acting on behalf of user Y"* stays queryable after tokens expire.
|
|
194
|
-
|
|
195
|
-
The plugin is **fail-open** on its own infrastructure failures (network errors, rate limits, missing config), so enforcement is only as strong as your permission grants — grant explicit `use` on the tools each user should be able to run.
|
|
158
|
+
Pass the resulting id to `configure --oauth2-client-id`. Running headless with a session token already? Set `ORY_USER_SESSION_TOKEN` and skip the browser step entirely.
|
|
196
159
|
|
|
197
|
-
|
|
160
|
+
</details>
|
|
198
161
|
|
|
199
|
-
|
|
162
|
+
With nothing configured, the plugin still loads and runs in **pass-through mode**: skills and logging work, but no checks run and nothing is blocked. Perfectly fine if you only want the app-building features.
|
|
200
163
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
export ORY_USER_LOGIN=true
|
|
205
|
-
export ORY_OAUTH2_CLIENT_ID=<public OAuth2 client id>
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
The next OpenClaw session refreshes or prompts for PKCE login. Subsequent sessions reuse the persisted token until it expires.
|
|
209
|
-
|
|
210
|
-
`ORY_OAUTH2_CLIENT_ID` is required when `ORY_USER_LOGIN` is on: PKCE needs a public OAuth2 client registered with the four loopback redirect URIs (`http://127.0.0.1:47823..47826/callback`) to exchange the authorization code for a token. The local stack provisions one and prints the export in its `local up` banner; for a hosted Ory project see [Register the user OAuth2 client](#register-the-user-oauth2-client) for the exact CLI / Console steps. Headless / CI runs can skip the browser flow entirely by pre-supplying `ORY_USER_SESSION_TOKEN` instead.
|
|
211
|
-
|
|
212
|
-
2. **Bootstrap permissions for the built-in tools.** One idempotent command grants the current user `use` on every tool OpenClaw ships with (execute_command, read_file, write_file, …):
|
|
213
|
-
|
|
214
|
-
```bash
|
|
215
|
-
npx -y -p @ory/openclaw ory-openclaw permissions bootstrap
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
If a user identity is already cached at install time, the installer runs this for you automatically — re-run after adding tools, switching subjects, or changing the namespace.
|
|
219
|
-
|
|
220
|
-
3. **Check coverage.** `permissions status` probes every tool in the harness's catalog and prints allowed / denied per tool:
|
|
221
|
-
|
|
222
|
-
```bash
|
|
223
|
-
npx -y -p @ory/openclaw ory-openclaw permissions status
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
Add permissions for any MCP server tools or custom commands by hand, or via the Ory MCP server from inside OpenClaw (*"grant me use on the execute_command tool"*).
|
|
227
|
-
|
|
228
|
-
4. **Promote to enforce.** Once the observe-mode logs look right, switch over:
|
|
229
|
-
|
|
230
|
-
```bash
|
|
231
|
-
npx -y -p @ory/openclaw ory-openclaw permissions enforce
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
Denies now block the tool call; OpenClaw shows the denial reason and the decision is recorded as a `tool.block` trace span with `blocked: true`. Switch back any time with `permissions observe`.
|
|
235
|
-
|
|
236
|
-
## CLI reference
|
|
164
|
+
## Commands
|
|
237
165
|
|
|
238
166
|
```
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
167
|
+
ory-openclaw install | uninstall Install/remove; --reconfigure re-runs setup, --no-configure skips it
|
|
168
|
+
ory-openclaw status Show configuration, identities, permission coverage, recent activity
|
|
169
|
+
ory-openclaw watch Tail the live trace stream (OTel spans)
|
|
170
|
+
ory-openclaw permissions <cmd> status | bootstrap | observe (watch) | enforce (block)
|
|
171
|
+
ory-openclaw configure <flags> Point at a project by hand (--project-url, --oauth2-client-id, --user-login, --audit-only)
|
|
172
|
+
ory-openclaw agent <status|unregister> Manage OpenClaw's own auto-created identity
|
|
173
|
+
ory-openclaw local <up|down|status|…> Run / manage a local Ory in Docker
|
|
174
|
+
ory-openclaw watch [<trace-file>] Live-tail the trace of decisions as they happen
|
|
246
175
|
```
|
|
247
176
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
- `agent status` — show the current persisted DCR identity for the agent.
|
|
251
|
-
- `permissions observe` / `permissions enforce` — switch between "log denies, allow through" (the install default) and "block denies." `permissions bootstrap` writes `use` permissions for the harness's built-in tools so the promotion path doesn't require hand-writing relations.
|
|
252
|
-
- `configure --audit-only` — kill switch that disables Ory entirely (no auth, no permission checks; only audit logging of tool invocations). For phased rollouts, prefer `permissions observe` over `--audit-only`.
|
|
253
|
-
- `local seed` / `local env` — reseed the test user, or print env vars for pointing other tools at the local stack.
|
|
177
|
+
All prefixed with `npx -y -p @ory/openclaw`.
|
|
254
178
|
|
|
255
179
|
## Troubleshooting
|
|
256
180
|
|
|
257
|
-
- **`
|
|
258
|
-
- **
|
|
259
|
-
- **`npx`
|
|
260
|
-
- **
|
|
181
|
+
- **`local-up` fails** — make sure Docker is running and ports `4000`, `4100`, `4455`, and `16686` are free.
|
|
182
|
+
- **Browser sign-in loops** — reset with `ory-openclaw agent unregister` and try again.
|
|
183
|
+
- **`npx` grabbed an old version** — force the latest: `npx -y -p @ory/openclaw@latest ory-openclaw …`.
|
|
184
|
+
- **Want to see what's happening** — `npx -y -p @ory/openclaw ory-openclaw status` for a snapshot, `npx -y -p @ory/openclaw ory-openclaw watch` for the live trace stream, or set `ORY_AGENT_DEBUG=true` for a verbose log. Traces and logs live under `~/.config/ory-agent-plugins/openclaw/` (see [See what's happening](#see-whats-happening)).
|
|
261
185
|
|
|
262
|
-
##
|
|
186
|
+
## Learn more
|
|
263
187
|
|
|
264
|
-
- [Ory documentation](https://www.ory.com/docs/)
|
|
265
|
-
- [Ory Network console](https://console.ory.sh)
|
|
266
|
-
- [Ory Elements](https://github.com/ory/elements)
|
|
188
|
+
- [Ory documentation](https://www.ory.com/docs/) · [Ory Console](https://console.ory.sh) · [Ory Elements](https://github.com/ory/elements)
|
|
267
189
|
- [OpenClaw documentation](https://github.com/openclaw/openclaw)
|
|
268
190
|
|
|
269
191
|
## License
|
package/dist/cli/main.js
CHANGED
|
@@ -48,20 +48,25 @@ const path = __importStar(require("node:path"));
|
|
|
48
48
|
const fs = __importStar(require("node:fs"));
|
|
49
49
|
const argus_1 = require("@ory/argus");
|
|
50
50
|
const assets_js_1 = require("./assets.js");
|
|
51
|
-
const
|
|
51
|
+
const plugin_config_js_1 = require("./plugin-config.js");
|
|
52
52
|
const CONFIG_DIR = ".openclaw";
|
|
53
53
|
function main() {
|
|
54
54
|
const [command, ...args] = process.argv.slice(2);
|
|
55
55
|
switch (command) {
|
|
56
56
|
case "install":
|
|
57
|
+
(0, argus_1.beginDeferNextSteps)();
|
|
57
58
|
install(args);
|
|
58
|
-
|
|
59
|
+
(0, argus_1.runPostInstall)("ory-openclaw", "openclaw", args).then(() => process.exit(0), (err) => {
|
|
59
60
|
console.error(err.message ?? err);
|
|
60
61
|
process.exit(1);
|
|
61
62
|
});
|
|
62
63
|
break;
|
|
63
64
|
case "uninstall":
|
|
64
65
|
uninstall(args);
|
|
66
|
+
(0, argus_1.clearCredentialsForUninstall)().then(() => process.exit(0), (err) => {
|
|
67
|
+
console.error(err.message ?? err);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
});
|
|
65
70
|
break;
|
|
66
71
|
case "configure":
|
|
67
72
|
(0, argus_1.runConfigureCommand)("ory-openclaw", args);
|
|
@@ -91,7 +96,7 @@ function main() {
|
|
|
91
96
|
});
|
|
92
97
|
break;
|
|
93
98
|
case "watch":
|
|
94
|
-
(0, argus_1.runWatchCommand)(args);
|
|
99
|
+
(0, argus_1.runWatchCommand)("openclaw", args);
|
|
95
100
|
break;
|
|
96
101
|
case "help":
|
|
97
102
|
case "--help":
|
|
@@ -105,12 +110,6 @@ function main() {
|
|
|
105
110
|
process.exit(1);
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
|
-
async function postInstallPermissions(binName, harness) {
|
|
109
|
-
const bootstrapped = await (0, argus_1.maybeAutoBootstrap)(binName, harness);
|
|
110
|
-
(0, argus_1.printPermissionsOnboardingHelp)(binName, harness, {
|
|
111
|
-
bootstrappedAutomatically: bootstrapped,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
113
|
function parseProjectDir(args) {
|
|
115
114
|
const idx = args.indexOf("--project-dir");
|
|
116
115
|
if (idx !== -1 && args[idx + 1])
|
|
@@ -131,13 +130,11 @@ function install(args) {
|
|
|
131
130
|
const configPath = getOpenClawConfigPath(projectDir);
|
|
132
131
|
ensureConfigDir(projectDir);
|
|
133
132
|
const config = (0, argus_1.readJsonFile)(configPath);
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
config.plugins = plugins;
|
|
137
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
133
|
+
const merged = (0, plugin_config_js_1.registerPluginInConfig)(config, projectDir);
|
|
134
|
+
fs.writeFileSync(configPath, JSON.stringify(merged, null, 2) + "\n");
|
|
138
135
|
(0, assets_js_1.installOpenclawOryAssets)(projectDir);
|
|
139
136
|
console.log(`Ory plugin registered in ${configPath}`);
|
|
140
|
-
console.log(`
|
|
137
|
+
console.log(` Plugin id: ${plugin_config_js_1.PLUGIN_ID}`);
|
|
141
138
|
console.log(` Skills + commands installed under ${path.join(projectDir, CONFIG_DIR, "skills")}`);
|
|
142
139
|
(0, argus_1.printEnvHelp)("ory-openclaw");
|
|
143
140
|
}
|
|
@@ -150,14 +147,8 @@ function uninstall(args) {
|
|
|
150
147
|
}
|
|
151
148
|
(0, assets_js_1.uninstallOpenclawOryAssets)(projectDir);
|
|
152
149
|
const config = (0, argus_1.readJsonFile)(configPath);
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
delete config.plugins;
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
config.plugins = plugins;
|
|
159
|
-
}
|
|
160
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
150
|
+
const updated = (0, plugin_config_js_1.unregisterPluginFromConfig)(config, projectDir);
|
|
151
|
+
fs.writeFileSync(configPath, JSON.stringify(updated, null, 2) + "\n");
|
|
161
152
|
console.log(`Ory plugin and skills removed from ${configPath}`);
|
|
162
153
|
}
|
|
163
154
|
async function status(args) {
|
|
@@ -167,13 +158,12 @@ async function status(args) {
|
|
|
167
158
|
title: "OpenClaw",
|
|
168
159
|
printPluginSection: () => {
|
|
169
160
|
const config = (0, argus_1.readJsonFile)(configPath);
|
|
170
|
-
const
|
|
171
|
-
const registered = plugins.includes(PLUGIN_MODULE);
|
|
161
|
+
const registered = (0, plugin_config_js_1.isPluginRegistered)(config);
|
|
172
162
|
console.log("Hooks & plugin:");
|
|
173
163
|
console.log(` Config file: ${configPath}`);
|
|
174
164
|
console.log(` Plugin registered: ${registered ? "yes" : "NO"}`);
|
|
175
165
|
if (registered) {
|
|
176
|
-
console.log(`
|
|
166
|
+
console.log(` Plugin id: ${plugin_config_js_1.PLUGIN_ID}`);
|
|
177
167
|
}
|
|
178
168
|
console.log(` Blocking support: yes (before_tool_call can deny tool execution)`);
|
|
179
169
|
console.log(` Hooks registered: session_start, before_tool_call, after_tool_call`);
|
|
@@ -185,7 +175,7 @@ function help() {
|
|
|
185
175
|
ory-openclaw — Ory plugin for OpenClaw
|
|
186
176
|
|
|
187
177
|
Usage:
|
|
188
|
-
npx ory-openclaw <command> [options]
|
|
178
|
+
npx -y -p @ory/openclaw ory-openclaw <command> [options]
|
|
189
179
|
|
|
190
180
|
Commands:
|
|
191
181
|
install [--project-dir <path>] Register the Ory plugin in OpenClaw config
|
|
@@ -203,11 +193,11 @@ After installing, the plugin hooks into these OpenClaw lifecycle events:
|
|
|
203
193
|
after_tool_call Record tool completion trace
|
|
204
194
|
|
|
205
195
|
Examples:
|
|
206
|
-
npx ory-openclaw install # Register in current directory
|
|
207
|
-
npx ory-openclaw configure --project-url https://my.oryapis.com --api-key ory_pat_...
|
|
208
|
-
npx ory-openclaw status # Check configuration
|
|
209
|
-
npx ory-openclaw watch # Watch trace output in real-time
|
|
210
|
-
npx ory-openclaw uninstall # Remove plugin
|
|
196
|
+
npx -y -p @ory/openclaw ory-openclaw install # Register in current directory
|
|
197
|
+
npx -y -p @ory/openclaw ory-openclaw configure --project-url https://my.oryapis.com --api-key ory_pat_...
|
|
198
|
+
npx -y -p @ory/openclaw ory-openclaw status # Check configuration
|
|
199
|
+
npx -y -p @ory/openclaw ory-openclaw watch # Watch trace output in real-time
|
|
200
|
+
npx -y -p @ory/openclaw ory-openclaw uninstall # Remove plugin
|
|
211
201
|
`);
|
|
212
202
|
}
|
|
213
203
|
main();
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read/write helpers for registering the Ory plugin in an OpenClaw
|
|
3
|
+
* `.openclaw/config.json`.
|
|
4
|
+
*
|
|
5
|
+
* Current OpenClaw addresses plugins by their **manifest id** (ours is
|
|
6
|
+
* `ory-agent-security`, from `openclaw.plugin.json`) under a nested
|
|
7
|
+
* `plugins` object — never the flat `plugins: [<module>]` array older
|
|
8
|
+
* versions of this installer wrote (that shape is silently ignored, so the
|
|
9
|
+
* plugin never loaded). Registration means two things, mirroring the native
|
|
10
|
+
* `openclaw plugins install` + `openclaw plugins enable` pair:
|
|
11
|
+
*
|
|
12
|
+
* 1. Discovery — the plugin's package directory (the one holding
|
|
13
|
+
* `openclaw.plugin.json`) is added to `plugins.load.paths`. OpenClaw only
|
|
14
|
+
* scans its bundled dir, `~/.openclaw/extensions`, `<ws>/.openclaw/extensions`,
|
|
15
|
+
* and configured `load.paths`; it does *not* auto-scan `node_modules`.
|
|
16
|
+
* 2. Enablement — `plugins.entries["ory-agent-security"].enabled = true`,
|
|
17
|
+
* byte-for-byte what `openclaw plugins enable` writes.
|
|
18
|
+
*
|
|
19
|
+
* We deliberately do NOT create a `plugins.allow` allowlist: when `allow` is
|
|
20
|
+
* present and non-empty, OpenClaw loads *only* the listed ids, so writing one
|
|
21
|
+
* onto a config that didn't have it would silently disable every other
|
|
22
|
+
* plugin. We only append our id to an allowlist that already exists.
|
|
23
|
+
*/
|
|
24
|
+
/** Plugin manifest id (from `openclaw.plugin.json`). */
|
|
25
|
+
export declare const PLUGIN_ID = "ory-agent-security";
|
|
26
|
+
/** npm module name — used only to migrate away the legacy flat-array shape. */
|
|
27
|
+
export declare const PLUGIN_MODULE = "@ory/openclaw";
|
|
28
|
+
type Rec = Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve the directory that contains the plugin's `openclaw.plugin.json`
|
|
31
|
+
* manifest, so it can be registered on `plugins.load.paths`.
|
|
32
|
+
*
|
|
33
|
+
* Prefer the copy installed in the target project's `node_modules` — that path
|
|
34
|
+
* is stable across sessions. Fall back to the package root of the currently
|
|
35
|
+
* running CLI (best effort; under a bare `npx` run this is the ephemeral npx
|
|
36
|
+
* cache, which is why the README recommends `npm install` or the native
|
|
37
|
+
* `openclaw plugins install` flow).
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolvePluginRoot(projectDir: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Non-destructively register + enable the Ory plugin in an OpenClaw config
|
|
42
|
+
* object. Returns a new config; does not mutate the input.
|
|
43
|
+
*/
|
|
44
|
+
export declare function registerPluginInConfig(config: Rec, projectDir: string): Rec;
|
|
45
|
+
/**
|
|
46
|
+
* Non-destructively remove the Ory plugin from an OpenClaw config object,
|
|
47
|
+
* leaving any other plugins' config intact. Returns a new config.
|
|
48
|
+
*/
|
|
49
|
+
export declare function unregisterPluginFromConfig(config: Rec, projectDir: string): Rec;
|
|
50
|
+
/** True when the plugin is enabled under the current nested schema. */
|
|
51
|
+
export declare function isPluginRegistered(config: Rec): boolean;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Read/write helpers for registering the Ory plugin in an OpenClaw
|
|
4
|
+
* `.openclaw/config.json`.
|
|
5
|
+
*
|
|
6
|
+
* Current OpenClaw addresses plugins by their **manifest id** (ours is
|
|
7
|
+
* `ory-agent-security`, from `openclaw.plugin.json`) under a nested
|
|
8
|
+
* `plugins` object — never the flat `plugins: [<module>]` array older
|
|
9
|
+
* versions of this installer wrote (that shape is silently ignored, so the
|
|
10
|
+
* plugin never loaded). Registration means two things, mirroring the native
|
|
11
|
+
* `openclaw plugins install` + `openclaw plugins enable` pair:
|
|
12
|
+
*
|
|
13
|
+
* 1. Discovery — the plugin's package directory (the one holding
|
|
14
|
+
* `openclaw.plugin.json`) is added to `plugins.load.paths`. OpenClaw only
|
|
15
|
+
* scans its bundled dir, `~/.openclaw/extensions`, `<ws>/.openclaw/extensions`,
|
|
16
|
+
* and configured `load.paths`; it does *not* auto-scan `node_modules`.
|
|
17
|
+
* 2. Enablement — `plugins.entries["ory-agent-security"].enabled = true`,
|
|
18
|
+
* byte-for-byte what `openclaw plugins enable` writes.
|
|
19
|
+
*
|
|
20
|
+
* We deliberately do NOT create a `plugins.allow` allowlist: when `allow` is
|
|
21
|
+
* present and non-empty, OpenClaw loads *only* the listed ids, so writing one
|
|
22
|
+
* onto a config that didn't have it would silently disable every other
|
|
23
|
+
* plugin. We only append our id to an allowlist that already exists.
|
|
24
|
+
*/
|
|
25
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
28
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
29
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
30
|
+
}
|
|
31
|
+
Object.defineProperty(o, k2, desc);
|
|
32
|
+
}) : (function(o, m, k, k2) {
|
|
33
|
+
if (k2 === undefined) k2 = k;
|
|
34
|
+
o[k2] = m[k];
|
|
35
|
+
}));
|
|
36
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
37
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
38
|
+
}) : function(o, v) {
|
|
39
|
+
o["default"] = v;
|
|
40
|
+
});
|
|
41
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
42
|
+
var ownKeys = function(o) {
|
|
43
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
44
|
+
var ar = [];
|
|
45
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
46
|
+
return ar;
|
|
47
|
+
};
|
|
48
|
+
return ownKeys(o);
|
|
49
|
+
};
|
|
50
|
+
return function (mod) {
|
|
51
|
+
if (mod && mod.__esModule) return mod;
|
|
52
|
+
var result = {};
|
|
53
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
54
|
+
__setModuleDefault(result, mod);
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
})();
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
exports.PLUGIN_MODULE = exports.PLUGIN_ID = void 0;
|
|
60
|
+
exports.resolvePluginRoot = resolvePluginRoot;
|
|
61
|
+
exports.registerPluginInConfig = registerPluginInConfig;
|
|
62
|
+
exports.unregisterPluginFromConfig = unregisterPluginFromConfig;
|
|
63
|
+
exports.isPluginRegistered = isPluginRegistered;
|
|
64
|
+
const fs = __importStar(require("node:fs"));
|
|
65
|
+
const path = __importStar(require("node:path"));
|
|
66
|
+
/** Plugin manifest id (from `openclaw.plugin.json`). */
|
|
67
|
+
exports.PLUGIN_ID = "ory-agent-security";
|
|
68
|
+
/** npm module name — used only to migrate away the legacy flat-array shape. */
|
|
69
|
+
exports.PLUGIN_MODULE = "@ory/openclaw";
|
|
70
|
+
/** Shallow-clone a value into a plain record, or start fresh if it isn't one. */
|
|
71
|
+
function asRec(value) {
|
|
72
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
73
|
+
? { ...value }
|
|
74
|
+
: {};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolve the directory that contains the plugin's `openclaw.plugin.json`
|
|
78
|
+
* manifest, so it can be registered on `plugins.load.paths`.
|
|
79
|
+
*
|
|
80
|
+
* Prefer the copy installed in the target project's `node_modules` — that path
|
|
81
|
+
* is stable across sessions. Fall back to the package root of the currently
|
|
82
|
+
* running CLI (best effort; under a bare `npx` run this is the ephemeral npx
|
|
83
|
+
* cache, which is why the README recommends `npm install` or the native
|
|
84
|
+
* `openclaw plugins install` flow).
|
|
85
|
+
*/
|
|
86
|
+
function resolvePluginRoot(projectDir) {
|
|
87
|
+
const inProject = path.join(projectDir, "node_modules", exports.PLUGIN_MODULE);
|
|
88
|
+
if (fs.existsSync(path.join(inProject, "openclaw.plugin.json"))) {
|
|
89
|
+
return path.resolve(inProject);
|
|
90
|
+
}
|
|
91
|
+
// dist/cli/plugin-config.js -> package root
|
|
92
|
+
return path.resolve(__dirname, "..", "..");
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Non-destructively register + enable the Ory plugin in an OpenClaw config
|
|
96
|
+
* object. Returns a new config; does not mutate the input.
|
|
97
|
+
*/
|
|
98
|
+
function registerPluginInConfig(config, projectDir) {
|
|
99
|
+
const next = { ...config };
|
|
100
|
+
// asRec drops any legacy flat `plugins: [...]` array — that shape was never
|
|
101
|
+
// read by current OpenClaw, so nothing functional is lost by migrating it.
|
|
102
|
+
const plugins = asRec(next.plugins);
|
|
103
|
+
const root = resolvePluginRoot(projectDir);
|
|
104
|
+
// 1. Discovery — add the package dir to plugins.load.paths (deduped).
|
|
105
|
+
const load = asRec(plugins.load);
|
|
106
|
+
const paths = Array.isArray(load.paths)
|
|
107
|
+
? load.paths.filter((p) => p !== root)
|
|
108
|
+
: [];
|
|
109
|
+
paths.push(root);
|
|
110
|
+
load.paths = paths;
|
|
111
|
+
plugins.load = load;
|
|
112
|
+
// 2. Enablement — plugins.entries["ory-agent-security"].enabled = true,
|
|
113
|
+
// preserving any existing per-plugin config.
|
|
114
|
+
const entries = asRec(plugins.entries);
|
|
115
|
+
const entry = asRec(entries[exports.PLUGIN_ID]);
|
|
116
|
+
entry.enabled = true;
|
|
117
|
+
entries[exports.PLUGIN_ID] = entry;
|
|
118
|
+
plugins.entries = entries;
|
|
119
|
+
// 3. Only touch an allowlist that already exists — never create one.
|
|
120
|
+
if (Array.isArray(plugins.allow) &&
|
|
121
|
+
plugins.allow.length > 0 &&
|
|
122
|
+
!plugins.allow.includes(exports.PLUGIN_ID)) {
|
|
123
|
+
plugins.allow = [...plugins.allow, exports.PLUGIN_ID];
|
|
124
|
+
}
|
|
125
|
+
next.plugins = plugins;
|
|
126
|
+
return next;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Non-destructively remove the Ory plugin from an OpenClaw config object,
|
|
130
|
+
* leaving any other plugins' config intact. Returns a new config.
|
|
131
|
+
*/
|
|
132
|
+
function unregisterPluginFromConfig(config, projectDir) {
|
|
133
|
+
const next = { ...config };
|
|
134
|
+
if (next.plugins == null)
|
|
135
|
+
return next;
|
|
136
|
+
// Legacy flat-array shape — just drop our module name.
|
|
137
|
+
if (Array.isArray(next.plugins)) {
|
|
138
|
+
const rest = next.plugins.filter((p) => p !== exports.PLUGIN_MODULE);
|
|
139
|
+
if (rest.length === 0)
|
|
140
|
+
delete next.plugins;
|
|
141
|
+
else
|
|
142
|
+
next.plugins = rest;
|
|
143
|
+
return next;
|
|
144
|
+
}
|
|
145
|
+
const plugins = asRec(next.plugins);
|
|
146
|
+
const root = resolvePluginRoot(projectDir);
|
|
147
|
+
// Remove our load path.
|
|
148
|
+
const load = asRec(plugins.load);
|
|
149
|
+
if (Array.isArray(load.paths)) {
|
|
150
|
+
const paths = load.paths.filter((p) => p !== root);
|
|
151
|
+
if (paths.length === 0)
|
|
152
|
+
delete load.paths;
|
|
153
|
+
else
|
|
154
|
+
load.paths = paths;
|
|
155
|
+
}
|
|
156
|
+
if (Object.keys(load).length === 0)
|
|
157
|
+
delete plugins.load;
|
|
158
|
+
else
|
|
159
|
+
plugins.load = load;
|
|
160
|
+
// Remove our entry.
|
|
161
|
+
const entries = asRec(plugins.entries);
|
|
162
|
+
delete entries[exports.PLUGIN_ID];
|
|
163
|
+
if (Object.keys(entries).length === 0)
|
|
164
|
+
delete plugins.entries;
|
|
165
|
+
else
|
|
166
|
+
plugins.entries = entries;
|
|
167
|
+
// Remove our id from any allowlist.
|
|
168
|
+
if (Array.isArray(plugins.allow)) {
|
|
169
|
+
const allow = plugins.allow.filter((p) => p !== exports.PLUGIN_ID);
|
|
170
|
+
if (allow.length === 0)
|
|
171
|
+
delete plugins.allow;
|
|
172
|
+
else
|
|
173
|
+
plugins.allow = allow;
|
|
174
|
+
}
|
|
175
|
+
if (Object.keys(plugins).length === 0)
|
|
176
|
+
delete next.plugins;
|
|
177
|
+
else
|
|
178
|
+
next.plugins = plugins;
|
|
179
|
+
return next;
|
|
180
|
+
}
|
|
181
|
+
/** True when the plugin is enabled under the current nested schema. */
|
|
182
|
+
function isPluginRegistered(config) {
|
|
183
|
+
const plugins = config.plugins;
|
|
184
|
+
if (!plugins || typeof plugins !== "object" || Array.isArray(plugins)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
const entries = plugins.entries;
|
|
188
|
+
if (!entries || typeof entries !== "object")
|
|
189
|
+
return false;
|
|
190
|
+
const entry = entries[exports.PLUGIN_ID];
|
|
191
|
+
return (!!entry && typeof entry === "object" && entry.enabled === true);
|
|
192
|
+
}
|
package/dist/cli/setup.js
CHANGED
|
@@ -47,7 +47,7 @@ const fs = __importStar(require("node:fs"));
|
|
|
47
47
|
const path = __importStar(require("node:path"));
|
|
48
48
|
const argus_1 = require("@ory/argus");
|
|
49
49
|
const assets_js_1 = require("./assets.js");
|
|
50
|
-
const
|
|
50
|
+
const plugin_config_js_1 = require("./plugin-config.js");
|
|
51
51
|
const CONFIG_DIR = ".openclaw";
|
|
52
52
|
function getConfigPath(args) {
|
|
53
53
|
return path.join(args.projectDir, CONFIG_DIR, "config.json");
|
|
@@ -58,24 +58,6 @@ function ensureConfigDir(args) {
|
|
|
58
58
|
fs.mkdirSync(dir, { recursive: true });
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
function mergePlugin(existing) {
|
|
62
|
-
const merged = { ...existing };
|
|
63
|
-
const plugins = (merged.plugins ?? []).filter((p) => p !== PLUGIN_MODULE);
|
|
64
|
-
plugins.push(PLUGIN_MODULE);
|
|
65
|
-
merged.plugins = plugins;
|
|
66
|
-
return merged;
|
|
67
|
-
}
|
|
68
|
-
function removePlugin(existing) {
|
|
69
|
-
const merged = { ...existing };
|
|
70
|
-
const plugins = (merged.plugins ?? []).filter((p) => p !== PLUGIN_MODULE);
|
|
71
|
-
if (plugins.length === 0) {
|
|
72
|
-
delete merged.plugins;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
merged.plugins = plugins;
|
|
76
|
-
}
|
|
77
|
-
return merged;
|
|
78
|
-
}
|
|
79
61
|
function main() {
|
|
80
62
|
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
81
63
|
(0, argus_1.printSetupHelp)("ory-openclaw-setup", "OpenClaw");
|
|
@@ -83,7 +65,7 @@ function main() {
|
|
|
83
65
|
}
|
|
84
66
|
const args = (0, argus_1.parseSetupArgs)();
|
|
85
67
|
if (args.print) {
|
|
86
|
-
console.log(JSON.stringify({
|
|
68
|
+
console.log(JSON.stringify((0, plugin_config_js_1.registerPluginInConfig)({}, args.projectDir), null, 2));
|
|
87
69
|
return;
|
|
88
70
|
}
|
|
89
71
|
const configPath = getConfigPath(args);
|
|
@@ -94,19 +76,31 @@ function main() {
|
|
|
94
76
|
return;
|
|
95
77
|
}
|
|
96
78
|
(0, assets_js_1.uninstallOpenclawOryAssets)(args.projectDir);
|
|
97
|
-
let updated =
|
|
79
|
+
let updated = (0, plugin_config_js_1.unregisterPluginFromConfig)(existing, args.projectDir);
|
|
98
80
|
updated = (0, argus_1.removeMcpServer)(updated);
|
|
99
81
|
(0, argus_1.writeJsonFile)(configPath, updated);
|
|
100
82
|
console.log(`Removed Ory plugin, MCP server, and skills from ${configPath}`);
|
|
101
83
|
return;
|
|
102
84
|
}
|
|
103
85
|
ensureConfigDir(args);
|
|
104
|
-
let merged =
|
|
86
|
+
let merged = (0, plugin_config_js_1.registerPluginInConfig)(existing, args.projectDir);
|
|
105
87
|
merged = (0, argus_1.mergeMcpServer)(merged);
|
|
106
88
|
(0, argus_1.writeJsonFile)(configPath, merged);
|
|
107
89
|
(0, assets_js_1.installOpenclawOryAssets)(args.projectDir);
|
|
108
90
|
console.log(`Ory plugin and MCP server configured in ${configPath}`);
|
|
109
91
|
console.log(`Ory skills installed to ${path.join(args.projectDir, CONFIG_DIR, "skills")}`);
|
|
110
|
-
(0, argus_1.printNextSteps)("OpenClaw", "npx ory-openclaw-setup --uninstall"
|
|
92
|
+
(0, argus_1.printNextSteps)("OpenClaw", "npx -y -p @ory/openclaw ory-openclaw-setup --uninstall", {
|
|
93
|
+
binName: "ory-openclaw",
|
|
94
|
+
harness: "openclaw",
|
|
95
|
+
});
|
|
111
96
|
}
|
|
112
97
|
main();
|
|
98
|
+
// When invoked directly as the `-setup` bin with `--uninstall`, also clear
|
|
99
|
+
// stored Ory credentials. When required by the plugin's main CLI, that
|
|
100
|
+
// command owns the purge, so the `require.main` guard prevents a double run.
|
|
101
|
+
if (require.main === module && process.argv.includes("--uninstall")) {
|
|
102
|
+
(0, argus_1.clearCredentialsForUninstall)().then(() => process.exit(0), (err) => {
|
|
103
|
+
console.error(err.message ?? err);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
});
|
|
106
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ory/openclaw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Ory plugin for OpenClaw: scaffolding skills, a local Ory instance, and authentication, authorization, and audit for every tool call",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://ory.com",
|
|
@@ -65,7 +65,8 @@
|
|
|
65
65
|
"!dist/**/*.tsbuildinfo"
|
|
66
66
|
],
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"
|
|
68
|
+
"reo-census": "^1.2.8",
|
|
69
|
+
"@ory/argus": "0.12.1"
|
|
69
70
|
},
|
|
70
71
|
"engines": {
|
|
71
72
|
"node": ">=22"
|