@ory/opencode 0.6.1 → 0.7.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
@@ -19,7 +19,15 @@ Run the installer from your project directory:
19
19
  npx -y -p @ory/opencode ory-opencode install
20
20
  ```
21
21
 
22
- This writes the plugin into `opencode.json`, registers the Ory MCP server, and drops the Ory skill catalog into `.opencode/skills/` and the local-stack slash commands into `.opencode/commands/ory/` — all in one step. Run `npx -y -p @ory/opencode ory-opencode uninstall` to reverse it.
22
+ This writes the plugin into `opencode.json`, registers the Ory MCP server, and drops the Ory skill catalog into `.opencode/skills/` and the local-stack slash commands into `.opencode/commands/ory/`. Run `npx -y -p @ory/opencode ory-opencode uninstall` to reverse it.
23
+
24
+ Then confirm everything landed:
25
+
26
+ ```bash
27
+ npx -y -p @ory/opencode ory-opencode status
28
+ ```
29
+
30
+ `status` is the single source of truth — it prints configuration, user and agent identity, per-tool permission coverage, plugin + skill registration, and a tail of recent debug logs. Unconfigured fields show inline as `(unset)`.
23
31
 
24
32
  <details>
25
33
  <summary>Alternative install: edit opencode.json by hand</summary>
@@ -55,13 +63,13 @@ From any project where you'd like Ory authentication, inside OpenCode:
55
63
 
56
64
  3. **Sign in.** Start your app, visit the login page OpenCode 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.
57
65
 
58
- 4. **Turn on Ory login for the OpenCode session itself.** *(Optional but recommended.)* Out of the box the plugin only governs your *app*. To also attach an Ory identity to *OpenCode's* session — so every tool call is attributed to you, not a fallback `session:<id>` subject — set:
66
+ 4. **Turn on Ory login for the OpenCode session itself.** *(Optional but recommended.)* Out of the box the plugin only governs your *app*. To also attach an Ory identity to *OpenCode's* session — so every tool call is attributed to you, not a fallback `session:<id>` subject — opt in to the user-login flow:
59
67
 
60
68
  ```bash
61
- export ORY_AUTH_GATE=1
69
+ export ORY_USER_LOGIN=1
62
70
  ```
63
71
 
64
- Then restart OpenCode. On next session start, OpenCode opens an Ory login in your browser; sign in with the same seeded credentials from step 1. This is what makes `permissions enforce` (see [Agent security](#agent-security)) deny on the right identity later. (Note: OpenCode's session-start primitive can't hard-block, so the gate runs in advisory mode — auth still happens and the audit trail is correct, but the session always proceeds.)
72
+ User login is off by default. With it on, the next OpenCode session opens an Ory login in your browser; sign in with the same seeded credentials from step 1, and the token is reused on subsequent sessions until it expires. This is what makes `permissions enforce` (see [Agent security](#agent-security)) deny on the right identity later. (Note: OpenCode's session-start primitive can't hard-block, so the flow runs in advisory mode at session start — auth still happens and the audit trail is correct, but the session always proceeds. Per-tool enforcement at `permission.ask` is unaffected.)
65
73
 
66
74
  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.
67
75
 
@@ -116,7 +124,7 @@ Without configuration the plugin still loads cleanly and runs in **pass-through
116
124
 
117
125
  Once the plugin is pointed at an Ory project (local or hosted), OpenCode's session and every tool call can be governed by Ory.
118
126
 
119
- - **Authentication.** Two identities. The human at the keyboard (the **user**) authenticates interactively via Ory Identities when `ORY_AUTH_GATE=1` is set. The OpenCode 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.
127
+ - **Authentication.** Two identities. The human at the keyboard (the **user**) authenticates interactively via Ory Identities when user login is enabled (`ORY_USER_LOGIN=1`, off by default — browser PKCE flow on first session, persisted token thereafter). The OpenCode 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.
120
128
  - **Authorization.** When OpenCode prompts for permission to use a tool, the plugin checks [Ory Permissions](https://www.ory.com/docs/keto) (Zanzibar-style relation tuples) against the user's subject and returns `allow` / `deny`. A parallel pre-tool check is recorded as part of the audit trail. MCP tool calls additionally get a server-level check.
121
129
  - **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.
122
130
 
@@ -126,10 +134,10 @@ The plugin is **fail-open** on its own infrastructure failures (network errors,
126
134
 
127
135
  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.
128
136
 
129
- 1. **Turn on the user gate.** In your shell:
137
+ 1. **Turn on user login.** It's off by default. In your shell:
130
138
 
131
139
  ```bash
132
- export ORY_AUTH_GATE=1
140
+ export ORY_USER_LOGIN=1
133
141
  ```
134
142
 
135
143
  The next OpenCode session refreshes or prompts for PKCE login. Subsequent sessions reuse the persisted token until it expires.
package/dist/plugin.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { OryAgentClient, ensureUserAuthenticated, ensureAgentIdentity } from "@ory/argus";
2
2
  import type { PluginModule } from "./types.js";
3
3
  export interface CreateOryPluginDeps {
4
- /** Test injection point for the user auth gate. */
5
- authGate?: typeof ensureUserAuthenticated;
4
+ /** Test injection point for the user login flow. */
5
+ userLogin?: typeof ensureUserAuthenticated;
6
6
  /** Test injection point for the agent identity gate. */
7
7
  agentGate?: typeof ensureAgentIdentity;
8
8
  }
@@ -14,7 +14,7 @@ export interface CreateOryPluginDeps {
14
14
  * (input, output) => Promise<void> pattern.
15
15
  *
16
16
  * The `server` factory has no return-value channel for blocking, so the
17
- * auth gate runs in advisory mode at startup — it emits the audit span,
17
+ * user login runs in advisory mode at startup — it emits the audit span,
18
18
  * refreshes tokens, and may launch a browser flow when interactive, but
19
19
  * cannot prevent the session from starting.
20
20
  */
package/dist/plugin.js CHANGED
@@ -10,7 +10,7 @@ const argus_1 = require("@ory/argus");
10
10
  * (input, output) => Promise<void> pattern.
11
11
  *
12
12
  * The `server` factory has no return-value channel for blocking, so the
13
- * auth gate runs in advisory mode at startup — it emits the audit span,
13
+ * user login runs in advisory mode at startup — it emits the audit span,
14
14
  * refreshes tokens, and may launch a browser flow when interactive, but
15
15
  * cannot prevent the session from starting.
16
16
  */
@@ -79,13 +79,13 @@ function createChatMessageHandler(client) {
79
79
  }
80
80
  // ─── Session verification on startup ────────────────────────────────
81
81
  async function verifyOnStartup(client, deps) {
82
- // Run the user auth gate. The OpenCode `server` factory has no block
83
- // primitive, so allowBlock is false — the gate emits the user.auth
82
+ // Run the user login. The OpenCode `server` factory has no block
83
+ // primitive, so allowBlock is false — the flow emits the user.auth
84
84
  // audit span, refreshes tokens, and may prompt the user, but never
85
- // prevents the session from starting. When ORY_AUTH_GATE is unset the
86
- // gate is a no-op (mode === "disabled") and we fall through to legacy
85
+ // prevents the session from starting. When ORY_USER_LOGIN is unset
86
+ // it's a no-op (mode === "disabled") and we fall through to legacy
87
87
  // logging.
88
- const userGate = deps.authGate ?? argus_1.ensureUserAuthenticated;
88
+ const userGate = deps.userLogin ?? argus_1.ensureUserAuthenticated;
89
89
  const decision = await userGate(client, {
90
90
  binName: "ory-opencode",
91
91
  harness: "opencode",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ory/opencode",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Ory plugin for OpenCode: 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",
@@ -63,7 +63,7 @@
63
63
  "!dist/**/*.tsbuildinfo"
64
64
  ],
65
65
  "dependencies": {
66
- "@ory/argus": "0.6.1"
66
+ "@ory/argus": "0.7.0"
67
67
  },
68
68
  "engines": {
69
69
  "node": ">=22"