@ory/codex 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +104 -28
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,9 +2,18 @@
2
2
 
3
3
  [Ory](https://ory.com) bundled into [Codex](https://github.com/openai/codex): 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 Codex runs.
4
4
 
5
+ You don't need an Ory account or any prior Ory experience to start.
6
+
7
+ ## Prerequisites
8
+
9
+ - [Codex](https://github.com/openai/codex) installed and signed in
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
- Codex loads hooks from its config. Install and register in one step, with no prior `npm install` required:
16
+ No prior `npm install` required:
8
17
 
9
18
  ```bash
10
19
  npx @ory/codex install # current project
@@ -12,30 +21,53 @@ npx @ory/codex install --global # all Codex projects
12
21
  npx @ory/codex uninstall
13
22
  ```
14
23
 
15
- `install` wires the Ory hooks into your Codex config non-destructively (existing hooks are preserved), registers the Ory MCP server, and drops the Ory skill catalog into `.codex/skills/`. If the installer can't locate your Codex config, `npx -y -p @ory/codex ory-codex-setup` writes it directly.
24
+ That's it — skills, hooks, and the Ory MCP server are now registered. Existing entries in your Codex config are preserved.
16
25
 
17
- ## Developer experience
26
+ <details>
27
+ <summary>Alternative install</summary>
18
28
 
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.
29
+ If the installer can't locate your Codex config, this writes it directly:
20
30
 
21
- ### Skills for scaffolding Ory into your application
31
+ ```bash
32
+ npx -y -p @ory/codex ory-codex-setup
33
+ ```
34
+
35
+ </details>
36
+
37
+ ## Quickstart (≈ 3 minutes)
38
+
39
+ From any project where you'd like Ory authentication, inside Codex:
40
+
41
+ 1. **Start a local Ory instance.** Ask Codex *"start the local Ory stack"* or pick `ory-local-up` from the `/skills` menu.
42
+
43
+ A banner prints the seeded test user's email and password. Note them — you'll log in with them in step 3.
44
+
45
+ 2. **Scaffold Ory into your project.** Ask Codex *"add Ory auth to this app"* or pick `ory-auth-setup` from `/skills`.
46
+
47
+ Codex 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.
48
+
49
+ 3. **Sign in.** Start your app, visit the login page Codex 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.
50
+
51
+ 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.
22
52
 
23
- Codex surfaces the skill catalog in `/skills` and auto-invokes by description. Ask Codex to add Ory auth to your codebase, or invoke a skill directly:
53
+ ## What's included
24
54
 
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 Codex to prototype and test against without a remote project.
55
+ ### Skills for scaffolding Ory into your application
56
+
57
+ Codex surfaces the skill catalog in `/skills` and auto-invokes by description. Ask Codex in natural language or invoke a skill directly:
29
58
 
30
- Skills are versioned with the plugin so guidance stays in sync as Ory APIs evolve.
59
+ - **`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.
60
+ - **`ory-login-flow`** — login, registration, recovery, verification, and settings pages with Ory Elements. Next.js App Router and React SPA variants.
61
+ - **`ory-social-login`** — Google, GitHub, Apple, Microsoft, Discord, and other OIDC providers with Jsonnet data mappers.
62
+ - **`ory-local-dev`** — drive the local Ory stack from within Codex to prototype and test without a remote project.
31
63
 
32
64
  ### Ory MCP server
33
65
 
34
- Bundled and registered automatically. It exposes the Ory CLI and the Ory Network REST API as MCP tools so Codex 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.
66
+ Bundled and registered automatically. Exposes the Ory CLI and the Ory Network REST API as MCP tools so Codex 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
67
 
36
- ### Local Ory stack in one command
68
+ ### Local Ory stack
37
69
 
38
- From Codex's `/skills` picker:
70
+ From Codex's `/skills` menu:
39
71
 
40
72
  ```
41
73
  ory-local-up # start a local Ory instance in Docker
@@ -44,34 +76,62 @@ ory-local-down # tear it all down
44
76
 
45
77
  Or via the CLI: `npx -y -p @ory/codex ory-codex local up | down`.
46
78
 
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:
79
+ `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
80
 
49
81
  - **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.
82
+ - **Prototype** flows (login, social, MFA, recovery, permission tuples) against a real Ory backend.
51
83
  - **Test** an auth integration end-to-end before pushing anything to a real environment.
52
84
  - **Develop** your application against the same identity, OAuth2, and permission surfaces you'll ship with.
53
85
 
54
- Point `ORY_PROJECT_URL` at `http://localhost:4000` (or run `npx -y -p @ory/codex ory-codex configure`) and the security features below run against the local stack.
86
+ ## Pointing at a real Ory project
55
87
 
56
- ## Configure
88
+ The Quickstart uses the local stack. If you have a hosted [Ory Network](https://console.ory.sh) project, point the plugin at it:
57
89
 
58
90
  ```bash
59
- npx -y -p @ory/codex ory-codex configure --project-url https://<id>.projects.oryapis.com --api-key ory_pat_...
91
+ npx -y -p @ory/codex ory-codex configure \
92
+ --project-url https://<id>.projects.oryapis.com \
93
+ --api-key ory_pat_...
60
94
  ```
61
95
 
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.
96
+ Config is saved to `~/.config/ory-agent-plugins/config.json` and shared across every Ory agent plugin on the machine.
97
+
98
+ 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.
99
+
100
+ ## Agent security
101
+
102
+ Once the plugin is pointed at an Ory project (local or hosted), Codex's session and every tool call can be governed by Ory.
103
+
104
+ - **Authentication.** Two identities. The human at the keyboard (the **user**) authenticates interactively via Ory Identities when `ORY_AUTH_GATE=1` is set. The Codex 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.
105
+ - **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.
106
+ - **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.
107
+
108
+ 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.
109
+
110
+ ### Enable enforcement
63
111
 
64
- ## Agent security (Argus)
112
+ 1. **Turn on the user gate.** In your shell:
65
113
 
66
- Once the plugin is pointed at an Ory project (local or hosted), Codex's session and every tool call are governed by Ory.
114
+ ```bash
115
+ export ORY_AUTH_GATE=1
116
+ ```
67
117
 
68
- - **Authentication.** Two identities. The human at the keyboard (the **user**) authenticates interactively via Ory Identities when `ORY_AUTH_GATE=1`. The Codex 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 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.
118
+ The next Codex session opens a browser for PKCE login. Subsequent sessions reuse the persisted token until it expires.
71
119
 
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.
120
+ 2. **Grant yourself permission to use a tool.** Use the Ory MCP server from inside Codex (*"grant me invoke on the Bash tool"*) or the CLI directly:
73
121
 
74
- ## CLI
122
+ ```bash
123
+ ory create relationship \
124
+ --namespace AgentTools \
125
+ --object Bash \
126
+ --relation invoke \
127
+ --subject-id <your-user-subject-id>
128
+ ```
129
+
130
+ Your subject id is printed at the start of every Codex session when `ORY_AGENT_DEBUG=true`.
131
+
132
+ 3. **See a denial.** Pick a tool you didn't grant (or remove the tuple) and ask Codex to use it. The hook blocks the call and Codex shows the denial reason. The decision is recorded as a `tool.block` trace span.
133
+
134
+ ## CLI reference
75
135
 
76
136
  ```
77
137
  npx -y -p @ory/codex ory-codex install | uninstall [--global]
@@ -81,9 +141,25 @@ npx -y -p @ory/codex ory-codex local <up|down|status|seed|logs|env|configure|res
81
141
  npx -y -p @ory/codex ory-codex status
82
142
  ```
83
143
 
144
+ Highlights:
145
+
146
+ - `agent status` — show the current persisted DCR identity for the agent.
147
+ - `configure --audit-only` — record decisions without blocking; useful for a phased rollout.
148
+ - `local seed` / `local env` — reseed the test user, or print env vars for pointing other tools at the local stack.
149
+
150
+ ## Troubleshooting
151
+
152
+ - **`ory-local-up` fails.** Make sure Docker is running and ports `3000`, `4000`, `4100`, and `16686` are free.
153
+ - **PKCE login loops.** Clear persisted state with `npx -y -p @ory/codex ory-codex agent unregister` and retry.
154
+ - **`npx` fetches an old version.** Force a fresh fetch: `npx -y -p @ory/codex@latest ory-codex …`.
155
+ - **Need more signal.** Set `ORY_AGENT_DEBUG=true` and `ORY_AGENT_LOG_FILE=/tmp/ory.log` to capture structured logs.
156
+
84
157
  ## Links
85
158
 
86
- - [ory.com](https://ory.com)
159
+ - [Ory documentation](https://www.ory.com/docs/)
160
+ - [Ory Network console](https://console.ory.sh)
161
+ - [Ory Elements](https://github.com/ory/elements)
162
+ - [Codex documentation](https://github.com/openai/codex)
87
163
 
88
164
  ## License
89
165
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ory/codex",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Ory plugin for Codex: 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",
@@ -67,7 +67,7 @@
67
67
  ".codex-plugin"
68
68
  ],
69
69
  "dependencies": {
70
- "@ory/argus": "0.1.1"
70
+ "@ory/argus": "0.1.3"
71
71
  },
72
72
  "engines": {
73
73
  "node": ">=24"