@ory/opencode 0.6.2 → 0.7.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 CHANGED
@@ -63,13 +63,13 @@ From any project where you'd like Ory authentication, inside OpenCode:
63
63
 
64
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.
65
65
 
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 — 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:
67
67
 
68
68
  ```bash
69
- export ORY_AUTH_GATE=1
69
+ export ORY_USER_LOGIN=1
70
70
  ```
71
71
 
72
- 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.)
73
73
 
74
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.
75
75
 
@@ -124,7 +124,7 @@ Without configuration the plugin still loads cleanly and runs in **pass-through
124
124
 
125
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.
126
126
 
127
- - **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.
128
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.
129
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.
130
130
 
@@ -134,10 +134,10 @@ The plugin is **fail-open** on its own infrastructure failures (network errors,
134
134
 
135
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.
136
136
 
137
- 1. **Turn on the user gate.** In your shell:
137
+ 1. **Turn on user login.** It's off by default. In your shell:
138
138
 
139
139
  ```bash
140
- export ORY_AUTH_GATE=1
140
+ export ORY_USER_LOGIN=1
141
141
  ```
142
142
 
143
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.2",
3
+ "version": "0.7.1",
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.2"
66
+ "@ory/argus": "0.7.1"
67
67
  },
68
68
  "engines": {
69
69
  "node": ">=22"