@ory/openclaw 0.1.2 → 0.2.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 CHANGED
@@ -2,9 +2,18 @@
2
2
 
3
3
  [Ory](https://ory.com) bundled into [OpenClaw](https://github.com/openclaw/openclaw): skills that scaffold Ory authentication into your codebase, a local Ory stack you can spin up in one command, and (when pointed at an Ory project) authentication, authorization, and audit for every tool OpenClaw runs.
4
4
 
5
+ You don't need an Ory account or any prior Ory experience to start.
6
+
7
+ ## Prerequisites
8
+
9
+ - [OpenClaw](https://github.com/openclaw/openclaw) installed and configured
10
+ - Node.js **≥ 24**
11
+ - [Docker](https://docs.docker.com/get-docker/) (only needed for the local Ory stack)
12
+ - macOS or Linux. Windows works via WSL2.
13
+
5
14
  ## Install
6
15
 
7
- OpenClaw loads in-process plugins registered in `.openclaw/config.json`. Install and register in one step, with no prior `npm install` required:
16
+ OpenClaw loads in-process plugins registered in `.openclaw/config.json`. No prior `npm install` required:
8
17
 
9
18
  ```bash
10
19
  npx @ory/openclaw install # registers in .openclaw/config.json
@@ -12,28 +21,40 @@ npx @ory/openclaw install --project-dir <path>
12
21
  npx @ory/openclaw uninstall
13
22
  ```
14
23
 
15
- `install` adds the Ory plugin and the Ory MCP server to your OpenClaw config non-destructively (existing entries are preserved) and drops the Ory skill catalog into `.openclaw/skills/`, registered under `skills.load.extraDirs` so OpenClaw discovers it.
24
+ That's it the Ory plugin, the Ory MCP server, and the Ory skill catalog (`.openclaw/skills/`, registered under `skills.load.extraDirs`) are now wired into your OpenClaw config non-destructively.
16
25
 
17
- ## Developer experience
26
+ ## Quickstart (≈ 3 minutes)
18
27
 
19
- This plugin is a productivity layer for Ory itself. You don't need a real Ory project, an account, or any prior Ory experience to start using it.
28
+ From any project where you'd like Ory authentication, inside OpenClaw:
20
29
 
21
- ### Skills for scaffolding Ory into your application
30
+ 1. **Start a local Ory instance.** Ask OpenClaw *"start the local Ory stack"* or invoke the `ory-local-up` skill from the skill picker.
22
31
 
23
- Ask OpenClaw to add Ory auth to your codebase, or invoke a skill directly. Each skill is a vetted, end-to-end playbook:
32
+ A banner prints the seeded test user's email and password. Note them you'll log in with them in step 3.
24
33
 
25
- - **`ory-auth-setup`**: full project setup. Install the Ory CLI, create an Ory Network project, add Ory Elements, configure the SDK, build the auth pages, wire session middleware.
26
- - **`ory-login-flow`**: login, registration, recovery, verification, and settings pages with Ory Elements. Next.js App Router and React SPA variants.
27
- - **`ory-social-login`**: Google, GitHub, Apple, Microsoft, Discord, and other OIDC providers with Jsonnet data mappers.
28
- - **`ory-local-dev`**: drive the local Ory stack (below) from within OpenClaw to prototype and test against without a remote project.
34
+ 2. **Scaffold Ory into your project.** Ask OpenClaw *"add Ory auth to this app"* or invoke the `ory-auth-setup` skill.
29
35
 
30
- Skills are versioned with the plugin so guidance stays in sync as Ory APIs evolve.
36
+ OpenClaw installs Ory Elements, wires the SDK, generates the login / registration / recovery / verification / settings pages, and sets up session middleware. It targets the local stack from step 1, so no signup or API key is needed.
37
+
38
+ 3. **Sign in.** Start your app, visit the login page OpenClaw added, and sign in with the seeded credentials. You now have a real Ory session backed by a real Ory stack — locally, offline, with zero configuration.
39
+
40
+ That's the full Ory DX path. Stop here if you're just evaluating the plugin. Continue to [Agent security](#agent-security) when you're ready to enforce.
41
+
42
+ ## What's included
43
+
44
+ ### Skills for scaffolding Ory into your application
45
+
46
+ Each skill is a vetted, end-to-end playbook. Ask OpenClaw in natural language or invoke a skill directly:
47
+
48
+ - **`ory-auth-setup`** — full project setup. Install the Ory CLI, create an Ory Network project (or use the local one), add Ory Elements, configure the SDK, build the auth pages, wire session middleware.
49
+ - **`ory-login-flow`** — login, registration, recovery, verification, and settings pages with Ory Elements. Next.js App Router and React SPA variants.
50
+ - **`ory-social-login`** — Google, GitHub, Apple, Microsoft, Discord, and other OIDC providers with Jsonnet data mappers.
51
+ - **`ory-local-dev`** — drive the local Ory stack from within OpenClaw to prototype and test without a remote project.
31
52
 
32
53
  ### Ory MCP server
33
54
 
34
- Bundled and registered automatically. It exposes the Ory CLI and the Ory Network REST API as MCP tools so OpenClaw can manage identities, OAuth2 clients, projects, permission tuples, and configuration without ever leaving the chat. Useful for seeding test data, verifying a scaffolded integration, or running one-off admin tasks.
55
+ Bundled and registered automatically. Exposes the Ory CLI and the Ory Network REST API as MCP tools so OpenClaw can manage identities, OAuth2 clients, projects, permission tuples, and configuration without ever leaving the chat. Useful for seeding test data, verifying a scaffolded integration, or running one-off admin tasks.
35
56
 
36
- ### Local Ory stack in one command
57
+ ### Local Ory stack
37
58
 
38
59
  From OpenClaw's skill picker:
39
60
 
@@ -44,47 +65,105 @@ ory-local-down # tear it all down
44
65
 
45
66
  Or via the CLI: `npx -y -p @ory/openclaw ory-openclaw local up | down`.
46
67
 
47
- `local up` runs a local Ory instance in Docker, covering everything the plugin and your scaffolded application need. It also brings up a login UI on `:3000` and Jaeger on `:16686`, all reachable through `http://localhost:4000`. A test user identity is seeded and the credentials are printed for you. Use it to:
68
+ `ory-local-up` brings up Ory Identities, OAuth2, and Permissions, plus a login UI on `:3000` and Jaeger on `:16686`, all reachable through `http://localhost:4000`. A test user identity is seeded and the credentials are printed for you. Use it to:
48
69
 
49
70
  - **Learn Ory hands-on** without signing up for a hosted project.
50
- - **Prototype** flows (login, social, MFA, recovery, permission tuples) against a real Ory backend in your local dev loop.
71
+ - **Prototype** flows (login, social, MFA, recovery, permission tuples) against a real Ory backend.
51
72
  - **Test** an auth integration end-to-end before pushing anything to a real environment.
52
73
  - **Develop** your application against the same identity, OAuth2, and permission surfaces you'll ship with.
53
74
 
54
- Point `ORY_PROJECT_URL` at `http://localhost:4000` (or run `npx -y -p @ory/openclaw ory-openclaw configure`) and the security features below run against the local stack.
75
+ ## Pointing at a real Ory project
55
76
 
56
- ## Configure
77
+ The Quickstart uses the local stack. If you have a hosted [Ory Network](https://console.ory.sh) project, point the plugin at it:
57
78
 
58
79
  ```bash
59
- npx -y -p @ory/openclaw ory-openclaw configure --project-url https://<id>.projects.oryapis.com --api-key ory_pat_...
80
+ npx -y -p @ory/openclaw ory-openclaw configure \
81
+ --project-url https://<id>.projects.oryapis.com \
82
+ --api-key ory_pat_...
60
83
  ```
61
84
 
62
- Config is saved to `~/.config/ory-agent-plugins/config.json` and shared across every Ory agent plugin on the machine. Without it the plugin still loads cleanly and runs in **pass-through mode**: skills work, but nothing is blocked.
85
+ Config is saved to `~/.config/ory-agent-plugins/config.json` and shared across every Ory agent plugin on the machine.
86
+
87
+ 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.
88
+
89
+ ## Agent security
90
+
91
+ Once the plugin is pointed at an Ory project (local or hosted), OpenClaw's session and every tool call can be governed by Ory.
92
+
93
+ - **Authentication.** Two identities. The human at the keyboard (the **user**) authenticates interactively via Ory Identities when `ORY_AUTH_GATE=1` is set. 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.
94
+ - **Authorization.** Before any tool runs, the plugin checks [Ory Permissions](https://www.ory.com/docs/keto) (Zanzibar-style relation tuples) against the user's subject and blocks the call on `deny`. MCP tool calls additionally get a server-level check.
95
+ - **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 tuple so *"agent X acting on behalf of user Y"* stays queryable after tokens expire.
63
96
 
64
- ## Agent security (Argus)
97
+ The plugin is **fail-open** on its own infrastructure failures (network errors, rate limits, missing config), so enforcement is only as strong as your tuples — grant explicit `invoke` relations for the tools each user should be able to run.
65
98
 
66
- Once the plugin is pointed at an Ory project (local or hosted), OpenClaw's session and every tool call are governed by Ory.
99
+ ### Enable enforcement
67
100
 
68
- - **Authentication.** Two identities. The human at the keyboard (the **user**) authenticates interactively via Ory Identities when `ORY_AUTH_GATE=1`; tokens refresh and a `user.auth` audit span is emitted at every session start. The OpenClaw process (the **agent**) gets its own OAuth2 identity, self-registered via Dynamic Client Registration on first run.
69
- - **Authorization.** Before any tool runs, the plugin checks Ory Permissions against the user's subject and blocks the tool call on `deny`. MCP tool calls additionally get a server-level check.
70
- - **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-to-agent delegation is written to Ory as a Zanzibar tuple so "agent X acting on behalf of user Y" stays queryable after tokens expire.
101
+ After install the plugin runs in **observe mode**: every tool call is checked against Ory Permissions, but a deny is recorded as a `permission.observe_deny` audit span and the tool runs anyway. This lets you see what *would* be blocked before turning on hard blocking.
71
102
 
72
- The plugin is **fail-open** on its own infrastructure failures (network errors, rate limits, missing config), so enforcement is only as strong as your tuples; grant explicit `invoke` relations for the tools each user should be able to run.
103
+ 1. **Turn on the user gate.** In your shell:
73
104
 
74
- ## CLI
105
+ ```bash
106
+ export ORY_AUTH_GATE=1
107
+ ```
108
+
109
+ The next OpenClaw session refreshes or prompts for PKCE login. Subsequent sessions reuse the persisted token until it expires.
110
+
111
+ 2. **Bootstrap tuples 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, …):
112
+
113
+ ```bash
114
+ npx -y -p @ory/openclaw ory-openclaw permissions bootstrap
115
+ ```
116
+
117
+ 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.
118
+
119
+ 3. **Check coverage.** `permissions status` probes every tool in the harness's catalog and prints allowed / denied per tool:
120
+
121
+ ```bash
122
+ npx -y -p @ory/openclaw ory-openclaw permissions status
123
+ ```
124
+
125
+ Add tuples 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"*).
126
+
127
+ 4. **Promote to enforce.** Once the observe-mode logs look right, switch over:
128
+
129
+ ```bash
130
+ npx -y -p @ory/openclaw ory-openclaw permissions enforce
131
+ ```
132
+
133
+ 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`.
134
+
135
+ ## CLI reference
75
136
 
76
137
  ```
77
138
  npx -y -p @ory/openclaw ory-openclaw install | uninstall [--project-dir <path>]
78
139
  npx -y -p @ory/openclaw ory-openclaw configure [--project-url <url>] [--api-key <key>] [--audit-only]
79
140
  npx -y -p @ory/openclaw ory-openclaw agent <status|unregister> Manage the agent's OAuth2 identity
141
+ npx -y -p @ory/openclaw ory-openclaw permissions <status|bootstrap|observe|enforce>
80
142
  npx -y -p @ory/openclaw ory-openclaw local <up|down|status|seed|logs|env|configure|reset>
81
143
  npx -y -p @ory/openclaw ory-openclaw watch [<trace-file>]
82
144
  npx -y -p @ory/openclaw ory-openclaw status [--project-dir <path>]
83
145
  ```
84
146
 
147
+ Highlights:
148
+
149
+ - `agent status` — show the current persisted DCR identity for the agent.
150
+ - `permissions observe` / `permissions enforce` — switch between "log denies, allow through" (the install default) and "block denies." `permissions bootstrap` writes `use` tuples for the harness's built-in tools so the promotion path doesn't require hand-writing relationships.
151
+ - `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`.
152
+ - `local seed` / `local env` — reseed the test user, or print env vars for pointing other tools at the local stack.
153
+
154
+ ## Troubleshooting
155
+
156
+ - **`ory-local-up` fails.** Make sure Docker is running and ports `3000`, `4000`, `4100`, and `16686` are free.
157
+ - **PKCE login loops.** Clear persisted state with `npx -y -p @ory/openclaw ory-openclaw agent unregister` and retry.
158
+ - **`npx` fetches an old version.** Force a fresh fetch: `npx -y -p @ory/openclaw@latest ory-openclaw …`.
159
+ - **Need more signal.** Set `ORY_AGENT_DEBUG=true` and `ORY_AGENT_LOG_FILE=/tmp/ory.log` to capture structured logs.
160
+
85
161
  ## Links
86
162
 
87
- - [ory.com](https://ory.com)
163
+ - [Ory documentation](https://www.ory.com/docs/)
164
+ - [Ory Network console](https://console.ory.sh)
165
+ - [Ory Elements](https://github.com/ory/elements)
166
+ - [OpenClaw documentation](https://github.com/openclaw/openclaw)
88
167
 
89
168
  ## License
90
169
 
package/dist/cli/main.js CHANGED
@@ -55,6 +55,10 @@ function main() {
55
55
  switch (command) {
56
56
  case "install":
57
57
  install(args);
58
+ postInstallPermissions("ory-openclaw", "openclaw").then(() => process.exit(0), (err) => {
59
+ console.error(err.message ?? err);
60
+ process.exit(1);
61
+ });
58
62
  break;
59
63
  case "uninstall":
60
64
  uninstall(args);
@@ -68,6 +72,12 @@ function main() {
68
72
  process.exit(1);
69
73
  });
70
74
  break;
75
+ case "permissions":
76
+ (0, argus_1.runPermissionsCommand)("ory-openclaw", "openclaw", args).then((code) => process.exit(code), (err) => {
77
+ console.error(err.message ?? err);
78
+ process.exit(1);
79
+ });
80
+ break;
71
81
  case "status":
72
82
  status(args);
73
83
  break;
@@ -92,6 +102,12 @@ function main() {
92
102
  process.exit(1);
93
103
  }
94
104
  }
105
+ async function postInstallPermissions(binName, harness) {
106
+ const bootstrapped = await (0, argus_1.maybeAutoBootstrap)(binName, harness);
107
+ (0, argus_1.printPermissionsOnboardingHelp)(binName, harness, {
108
+ bootstrappedAutomatically: bootstrapped,
109
+ });
110
+ }
95
111
  function parseProjectDir(args) {
96
112
  const idx = args.indexOf("--project-dir");
97
113
  if (idx !== -1 && args[idx + 1])
@@ -183,6 +199,7 @@ Commands:
183
199
  install [--project-dir <path>] Register the Ory plugin in OpenClaw config
184
200
  uninstall [--project-dir <path>] Remove the Ory plugin from OpenClaw config
185
201
  configure Set or view Ory project URL and API key
202
+ permissions <cmd> Manage permission mode and tool tuples (status, bootstrap, observe, enforce)
186
203
  status [--project-dir <path>] Show plugin configuration and status
187
204
  watch [trace-file] Watch live trace output
188
205
  local <cmd> Manage local Ory dev environment (up, down, status, seed, ...)
package/dist/plugin.js CHANGED
@@ -219,54 +219,80 @@ function createBeforeToolCallHandler(client) {
219
219
  subject,
220
220
  spanAttributes: { toolName: ctx.toolId },
221
221
  });
222
- if (!mcpResult.allowed) {
222
+ const mcpAttrs = {
223
+ toolName: ctx.toolId,
224
+ mcpServer: mcpTool.serverName,
225
+ mcpTool: mcpTool.toolName,
226
+ ...inputSummary,
227
+ };
228
+ const decision = (0, argus_1.applyPermissionMode)(client, mcpResult.allowed, {
229
+ object: mcpTool.serverName,
230
+ relation: "use",
231
+ subjectId,
232
+ spanAttributes: mcpAttrs,
233
+ });
234
+ if (decision.kind === "allow") {
235
+ client.tracer.record("tool.invoke", "ok", { attributes: mcpAttrs });
236
+ return;
237
+ }
238
+ if (decision.kind === "observe") {
223
239
  client.tracer.record("tool.block", "denied", {
224
- attributes: { toolName: ctx.toolId, mcpServer: mcpTool.serverName, mcpTool: mcpTool.toolName, ...inputSummary, ...(0, argus_1.alertAttributes)(true) },
225
- });
226
- const blockReason = (0, argus_1.formatDenialMessage)({
227
- tool: ctx.toolId,
228
- subjectId,
229
- mcp: mcpTool,
240
+ attributes: { ...mcpAttrs, allowed: false, ...(0, argus_1.alertAttributes)(false) },
230
241
  });
231
- client.logger.warn("tool.denied", {
232
- toolId: ctx.toolId,
233
- subjectId,
234
- message: blockReason,
242
+ client.tracer.record("tool.invoke", "ok", {
243
+ attributes: { ...mcpAttrs, allowed: false, observed: true },
235
244
  });
236
- return { block: true, blockReason };
245
+ return;
237
246
  }
238
- client.tracer.record("tool.invoke", "ok", {
239
- attributes: { toolName: ctx.toolId, mcpServer: mcpTool.serverName, mcpTool: mcpTool.toolName, ...inputSummary },
240
- });
241
- return;
242
- }
243
- const namespace = resolveNamespace();
244
- const result = await client.checkPermission({
245
- namespace,
246
- object: ctx.toolId,
247
- relation: "use",
248
- ...subject,
249
- }, { spanAttributes: { toolName: ctx.toolId } });
250
- if (!result.allowed) {
251
247
  client.tracer.record("tool.block", "denied", {
252
- attributes: { toolName: ctx.toolId, ...inputSummary, allowed: result.allowed, ...(0, argus_1.alertAttributes)(true) },
248
+ attributes: { ...mcpAttrs, allowed: false, ...(0, argus_1.alertAttributes)(true) },
253
249
  });
254
250
  const blockReason = (0, argus_1.formatDenialMessage)({
255
251
  tool: ctx.toolId,
256
252
  subjectId,
257
- namespace,
253
+ mcp: mcpTool,
258
254
  });
259
255
  client.logger.warn("tool.denied", {
260
256
  toolId: ctx.toolId,
261
257
  subjectId,
262
258
  message: blockReason,
263
259
  });
264
- // OpenClaw supports blocking — return { block: true, blockReason }
265
260
  return { block: true, blockReason };
266
261
  }
267
- client.tracer.record("tool.invoke", "ok", {
268
- attributes: { toolName: ctx.toolId, ...inputSummary, allowed: result.allowed },
262
+ const namespace = resolveNamespace();
263
+ const decision = await (0, argus_1.checkAndDecide)(client, { namespace, object: ctx.toolId, relation: "use", ...subject }, { spanAttributes: { toolName: ctx.toolId } });
264
+ if (decision.kind === "fail_open") {
265
+ handlePermissionError(decision.error, ctx.toolId, client);
266
+ return;
267
+ }
268
+ const attrs = { toolName: ctx.toolId, ...inputSummary };
269
+ if (decision.kind === "allow") {
270
+ client.tracer.record("tool.invoke", "ok", { attributes: { ...attrs, allowed: true } });
271
+ return;
272
+ }
273
+ if (decision.kind === "observe") {
274
+ client.tracer.record("tool.block", "denied", {
275
+ attributes: { ...attrs, allowed: false, ...(0, argus_1.alertAttributes)(false) },
276
+ });
277
+ client.tracer.record("tool.invoke", "ok", {
278
+ attributes: { ...attrs, allowed: false, observed: true },
279
+ });
280
+ return;
281
+ }
282
+ client.tracer.record("tool.block", "denied", {
283
+ attributes: { ...attrs, allowed: false, ...(0, argus_1.alertAttributes)(true) },
284
+ });
285
+ const blockReason = (0, argus_1.formatDenialMessage)({
286
+ tool: ctx.toolId,
287
+ subjectId,
288
+ namespace,
289
+ });
290
+ client.logger.warn("tool.denied", {
291
+ toolId: ctx.toolId,
292
+ subjectId,
293
+ message: blockReason,
269
294
  });
295
+ return { block: true, blockReason };
270
296
  }
271
297
  catch (err) {
272
298
  handlePermissionError(err, ctx.toolId, client);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ory/openclaw",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
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,7 @@
65
65
  "!dist/**/*.tsbuildinfo"
66
66
  ],
67
67
  "dependencies": {
68
- "@ory/argus": "0.1.2"
68
+ "@ory/argus": "0.2.0"
69
69
  },
70
70
  "engines": {
71
71
  "node": ">=24"