@ory/cline 0.14.0 → 1.0.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
@@ -2,9 +2,12 @@
2
2
 
3
3
  Security and developer experience for [Cline](https://github.com/cline/cline), powered by [Ory](https://ory.com).
4
4
 
5
- **Security.** Cline 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; Cline 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.
5
+ Cline runs real actions on your machine — editing files, running shell commands, calling APIs. This plugin gives those actions an identity, a permission check, and an audit trail.
6
6
 
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.
7
+ One command installs two independent halves:
8
+
9
+ - **Developer experience** — the Ory skill catalog, the local Ory dev stack, and activity logging. No account, no keys, nothing to configure: it works the moment it's installed.
10
+ - **Ory Agent Security** — browser sign-in, brokered permission checks before tool calls, and the delegation trail. Opt-in connection details from the [Ory Console](https://console.ory.sh) switch it on, and it takes nothing away from the half above. See [Connect to Ory Agent Security](#connect-to-ory-agent-security).
8
11
 
9
12
  ## What you'll need
10
13
 
@@ -15,110 +18,119 @@ Security and developer experience for [Cline](https://github.com/cline/cline), p
15
18
 
16
19
  ## Get started
17
20
 
18
- Run one command. It installs the plugin and walks you through connecting:
21
+ Run one command:
19
22
 
20
23
  ```bash
21
24
  npx -y -p @ory/cline ory-cline install
22
25
  ```
23
26
 
24
- It opens a guided setup **in your browser** where you pick how to connect the default takes just a click:
25
-
26
- - **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.
27
- - **Local** — run a complete Ory on your laptop with Docker. No account, no signup, no keys. Great for trying it out.
28
- - **Audit-only** — skip Ory entirely and just log what Cline does.
29
-
30
- > No browser available (CI, SSH, headless)? The same walkthrough runs right in your terminal instead — or force it with `--no-web`.
31
-
32
- That's it. Confirm everything landed with:
27
+ Add `--global` to install for every project (`~/.cline/hooks/`) instead of just this one. Confirm everything landed with:
33
28
 
34
29
  ```bash
35
30
  npx -y -p @ory/cline ory-cline status
36
31
  ```
37
32
 
38
- `status` is your one-stop check: what's configured, who's signed in, which tools are covered by permissions, and recent activity. Anything not set up yet shows as `(unset)`.
33
+ `status` is your one-stop check: what's configured, who's signed in, which tools are covered by permissions, and recent activity. Until you connect Agent Security, the identity and permission rows say so and name what's missing.
34
+
35
+ ## Skills and commands
36
+
37
+ Installing the plugin drops the full Ory playbook catalog into Cline. **Skills** are model-invoked — just say what you want in plain language and the matching one takes over.
38
+
39
+ | Skill | What it does for you |
40
+ |---|---|
41
+ | `ory-auth-setup` | Adds a complete auth system to your app — login, registration, recovery, verification, settings — on [Ory Elements](https://github.com/ory/elements) |
42
+ | `ory-login-flow` | Builds just the pages, wired to Ory's self-service flows |
43
+ | `ory-social-login` | "Sign in with…" for Google, GitHub, Apple, Microsoft, Discord, Slack, GitLab, Facebook |
44
+ | `ory-local-dev` | Develops and tests login/permission flows against a local Ory — no project, no account, offline |
45
+ | `ory-permissions-onboarding` | Walks a fresh install from observe mode to enforced per-tool permissions without getting blocked |
46
+ | `ory-build-agent` | Drops `@ory/argus` into an agent *you* own — Claude Agent SDK, OpenAI Agents, Mastra, Vercel AI, LangGraph/PydanticAI |
47
+ | `ory-build-integration` | Wires Ory into your app: Action webhooks, JWT validation at a gateway, live event streams |
48
+ | `ory-contribute-integration` | Authors and submits an integration to the public `ory/integrates` registry |
49
+ | `ory-e2b-sandbox` | Scaffolds an E2B sandbox template that boots with this plugin preinstalled |
50
+ | `ory-temporal-worker` | Scaffolds a Temporal TypeScript worker where every Activity is authenticated, authorized, and audited |
51
+
52
+ The local stack has its own playbooks — ask for them by name:
39
53
 
40
- > Re-run install with `--reconfigure` to change your connection later, or `--no-configure` to skip the wizard and configure by hand. Add `--global` to install for every project (`~/.cline/hooks/`) instead of just this one.
54
+ | Command | What it does |
55
+ |---|---|
56
+ | `ory-local-up` | Starts a local Ory (Identities, OAuth2, Permissions) in Docker and seeds a test user — it prints the email + password to sign in with |
57
+ | `ory-local-down` | Stops it, keeping your data volumes |
58
+ | `ory-temporal-up` | Starts a local Temporal dev server for the `ory-temporal-worker` scaffold |
59
+
60
+ The local stack runs entirely on your laptop: Ory APIs at `http://localhost:4000`, a login UI on `:4455` (not `:3000`, to dodge Next.js port clashes), and the Ory Console on `:4100`.
61
+
62
+ So: ask Cline *"add Ory login to this app"* and it scaffolds the pages, starts a local Ory, and wires them together.
41
63
 
42
64
  ## What you get
43
65
 
44
- Once connected, every task and tool call Cline runs is governed by Ory three things happen automatically:
66
+ Out of the box, every tool Cline runs produces a privacy-safe structured activity event in the unified local log.
45
67
 
46
- - **Who's driving.** You sign in once in your browser; Cline gets its own identity too, and registers it automatically on first run — no tokens to copy around. The "who acted on whose behalf" trail stays queryable later.
47
- - **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.
48
- - **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.
68
+ Once you connect to Ory Agent Security, two more things happen automatically:
69
+
70
+ - **Who's driving.** You sign in once in your browser; each Cline session gets its own identity and registers it automatically on first use — no tokens to copy around. The "who acted on whose behalf" trail stays queryable later.
71
+ - **What it's allowed to do.** Before a tool runs, Ory checks whether it's permitted. It starts in **observe mode** — nothing is blocked, you just *see* what would be — so it never gets in your way on day one.
49
72
 
50
73
  If Ory is ever unreachable, the plugin gets out of the way and lets Cline keep working — so it can't lock you out.
51
74
 
52
75
  ### See what's happening
53
76
 
54
- Everything the plugin does is observable out of the box — no configuration required:
77
+ Everything the plugin does is observable out of the box:
55
78
 
56
- - **Status at a glance.** `npx -y -p @ory/cline ory-cline status` shows what's configured, who's signed in, how many built-in tools your permissions cover, and the most recent tool-call activity.
57
- - **Live dashboard.** `npx -y -p @ory/cline ory-cline dashboard` opens the same picture in your browser — configuration, identities, permission coverage, Ory service health, and the latest tool-call activity, all refreshing live. From there you can flip **enforcement** on or off, toggle **user login**, and use **Change stack** to reconnect to a different Ory — no CLI required.
58
- - **Live traces.** Every tool call is recorded as an OpenTelemetry-style span. Watch them stream as the agent works:
79
+ - **Activity log.** Privacy-safe activity is always appended to `~/.config/ory-agent-plugins/cline/ory-agent-debug.log`. View events, decisions, and errors live with:
59
80
 
60
81
  ```bash
61
82
  npx -y -p @ory/cline ory-cline watch
62
83
  ```
63
84
 
64
- Spans are also written to `~/.config/ory-agent-plugins/cline/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.
65
- - **Debug log.** For a verbose play-by-play, set `ORY_AGENT_DEBUG=true`; structured logs land in `~/.config/ory-agent-plugins/cline/ory-agent-debug.log`.
85
+ Set `ORY_AGENT_LOG_FILE` to override the path; set it empty to disable file persistence.
86
+ - **Live debug.** Launch Cline with `ORY_AGENT_DEBUG=true` to add verbose local diagnostics, including raw shell commands, to the watched log and stderr. Secrets are recursively redacted; pass `watch --json` for NDJSON.
66
87
 
67
88
  ### Ready to enforce?
68
89
 
69
- When the watch-mode logs look right, turn on blocking with one command (setup already granted you the built-in tools):
90
+ Once connected, the deny posture lives on the Ory project: when the observe-mode activity looks right, an admin promotes it to **enforce** in the **Ory Console** (Agent Security). Every session reads that posture live, so nothing has to be reinstalled.
70
91
 
71
92
  ```bash
72
- npx -y -p @ory/cline ory-cline permissions enforce
93
+ npx -y -p @ory/cline ory-cline permissions # what the project grants, and the live mode
73
94
  ```
74
95
 
75
- Now a denied tool is actually blocked and Cline shows why. Go back to watch mode anytime with `permissions observe`. Prefer clicking? The dashboard has the same **Enforce** switch — flip it on, or back to watch mode, without touching the CLI. Use `permissions status` to see what's covered and `permissions bootstrap` to (re-)grant the built-in tools.
76
-
77
- ## Also: add login to your own app
96
+ Then a denied tool is actually blocked and Cline shows why.
78
97
 
79
- Beyond securing Cline, the plugin helps you build Ory into whatever you're working on. Ask Cline *"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. These are **skills**: just ask in plain language and the matching one takes over.
98
+ ## Connect to Ory Agent Security
80
99
 
81
- 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`. It runs the Ory APIs at `http://localhost:4000`, a login UI on `:4455` (not :3000, to avoid Next.js port conflicts), the Ory Console on `:4100`, and Jaeger on `:16686`. More bundled skills cover login flows, social sign-in (Google, GitHub, Apple…), permissions onboarding, and playbooks for wiring Ory into your own agents, E2B sandboxes, or Temporal workers.
100
+ Copy the connection details from the [Ory Console](https://console.ory.sh) under **Agent Security**:
82
101
 
83
- ## Configure by hand (CI / advanced)
84
-
85
- 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.
102
+ | Value | Flag | Environment variable |
103
+ |---|---|---|
104
+ | Project URL | `--project-url` | `ORY_PROJECT_URL` |
105
+ | Agent Security URL | `--agent-security-url` | `ORY_AGENT_SECURITY_URL` |
106
+ | Sign-in client id override (default `ory-agent-security-login`) | `--oauth2-client-id` | `ORY_OAUTH2_CLIENT_ID` |
86
107
 
87
108
  ```bash
88
109
  npx -y -p @ory/cline ory-cline configure \
89
110
  --project-url https://<slug>.projects.oryapis.com \
90
- --oauth2-client-id <sign-in client id>
111
+ --agent-security-url https://agents.console.ory.com
91
112
  ```
92
113
 
93
- Cline's own identity registers itself automatically on first run nothing to create. The `--oauth2-client-id` is the one piece browser sign-in needs (a **public sign-in client** registered with the loopback URLs `http://127.0.0.1:47823..47826/callback`); the guided setup makes it for you. For logging-only with no checks, use `--audit-only`. The interactive user login runs every session (always on, non-blocking) and only needs `ORY_OAUTH2_CLIENT_ID` to complete the browser flow.
94
-
95
- 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.
96
-
97
- <details>
98
- <summary>How the integration works</summary>
99
-
100
- Cline discovers hooks by directory — the presence of an executable script named after the event *is* the registration. `install` writes one thin shell shim per event into the workspace hooks directory `<project>/.clinerules/hooks/` (or `~/.cline/hooks/` with `--global`), makes each executable, and materializes the Ory skills. Each shim execs the published hook binary via `npx`. Install and uninstall respect hook scripts you authored: if an event name is already taken by a script Ory didn't write, install skips it and prints a warning; uninstall removes only the scripts Ory wrote.
114
+ `install` accepts the same flags, so you can register the plugin **and** connect in one shot (`install --project-url <URL> --agent-security-url <URL>`). The login client defaults to `ory-agent-security-login`; custom deployments can override it with `--oauth2-client-id`. Existing configurations fall back to the project URL when the Agent Security URL is unset. To turn sign-in and checks back off later, use `configure --disconnect`.
101
115
 
102
- Cline runs each hook as a **subprocess**, passing the event as JSON on stdin and reading a JSON decision on stdout. A hook blocks a tool call by returning `{"cancel":true}`. Cline does **not** expose a separate approval-ask hook, so the plugin gates at the tool-call event. Hooks have a 30-second timeout.
116
+ **Ory Network or OEL.** Either works. For an Ory Network project the URL is `https://<slug>.projects.oryapis.com`; for a self-hosted **Ory Enterprise License** deployment, point `--project-url` at that deployment's base URL and use the sign-in client id from its Agent Security configuration. Everything downstream sign-in, checks, delegation is identical.
103
117
 
104
- The hook filenames are PascalCase (`TaskStart`, `PreToolUse`, …); the payload Cline delivers carries the matching snake_case event name (`agent_start`, `tool_call`, …) the plugin acts on. The shims wire into these phases:
118
+ **There is nothing else for you to create.** The sign-in client, the permission model, the per-tool grants and blocks, and the observe/enforce posture are all provisioned in the Console by someone with project access. At runtime the plugin only *reads* permissions it has no write path into your project, which is why installing it needs no workspace privilege. Each Cline session registers its own identity automatically on first use.
105
119
 
106
- - **TaskStart** (`agent_start`) signs the user in and gives Cline its identity.
107
- - **PreToolUse** (`tool_call`) — checks the tool against your permissions; a deny blocks the call in enforce mode.
108
- - **PostToolUse / TaskComplete / TaskCancel / TaskError / UserPromptSubmit / PreCompact / SessionShutdown** — audit-only trace spans.
120
+ Sign-in runs at the start of every session and never blocks a declined, skipped, or timed-out login simply leaves that session without a user identity.
109
121
 
110
- </details>
122
+ 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. Running headless with an OAuth2 access token already? Set `ORY_USER_OAUTH2_TOKEN` and the browser step is skipped entirely.
111
123
 
112
124
  ## Commands
113
125
 
114
126
  ```
115
- ory-cline install | uninstall Install/remove; --reconfigure re-runs setup, --no-web forces the terminal wizard, --no-configure skips it
127
+ ory-cline install | uninstall Install (add --project-url to also connect Agent Security) / remove; --global installs for every project
116
128
  ory-cline status Show configuration, identities, permission coverage, recent activity
117
- ory-cline dashboard Open the live browser dashboard (status + service health + Change stack)
118
- ory-cline watch Tail the live trace stream (OTel spans)
119
- ory-cline permissions <cmd> status | bootstrap | observe (watch) | enforce (block)
120
- ory-cline configure <flags> Point at a project by hand (--project-url, --oauth2-client-id, --audit-only)
129
+ ory-cline permissions <cmd> status (read-only; grants + posture live in the Ory Console)
130
+ ory-cline configure <flags> Connect a project (--project-url) or --disconnect
121
131
  ory-cline agent <status|unregister> Manage Cline's own auto-created identity
132
+ ory-cline local <up|down|status|…> Run / manage a local Ory in Docker
133
+ ory-cline version Print plugin, core, and Node versions (--json for machine-readable)
122
134
  ```
123
135
 
124
136
  All prefixed with `npx -y -p @ory/cline`.
@@ -126,16 +138,14 @@ All prefixed with `npx -y -p @ory/cline`.
126
138
  ## Troubleshooting
127
139
 
128
140
  - **Local Ory fails to start** — make sure Docker is running and ports `4000`, `4100`, `4455`, and `16686` are free.
129
- - **Browser sign-in loops** — reset with `ory-cline agent unregister` and try again.
130
- - **Install ran but never asked how to connect** — you're almost certainly on a stale `npx` cache. `npx -p @ory/cline` (no version pin) reuses a previously-downloaded copy instead of re-resolving to the latest, so an older CLI whose install predates the setup wizard can run while you believe you're on the current release. The install banner prints the running version; confirm it with `npx -y -p @ory/cline ory-cline version`. To force the current release, clear the cache and reinstall: `rm -rf ~/.npm/_npx` then `npx -y -p @ory/cline ory-cline install`. Pinning an exact version (`@ory/cline@<version>`) also bypasses the cached copy.
141
+ - **Browser sign-in loops** (after connecting) — reset with `ory-cline agent unregister` and try again.
142
+ - **Running an older CLI than expected** — `npx -p @ory/cline` (no version pin) reuses a previously-downloaded copy instead of re-resolving to the latest. The install banner prints the running version; confirm it with `npx -y -p @ory/cline ory-cline version`. To force the current release, clear the cache and reinstall: `rm -rf ~/.npm/_npx` then `npx -y -p @ory/cline ory-cline install`. Pinning an exact version (`@ory/cline@<version>`) also bypasses the cached copy.
131
143
  - **A hook didn't install** — check the install output for a skipped-event warning; move or remove your own script at that event name and re-run install.
132
- - **Want to see what's happening** — `npx -y -p @ory/cline ory-cline status` for a snapshot, `npx -y -p @ory/cline ory-cline 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/cline/` (see [See what's happening](#see-whats-happening)).
133
144
 
134
145
  ## Learn more
135
146
 
136
147
  - [Ory documentation](https://www.ory.com/docs/) · [Ory Console](https://console.ory.sh) · [Ory Elements](https://github.com/ory/elements)
137
148
  - [Cline repository](https://github.com/cline/cline)
138
- - [Repo README](../../README.md) and [AGENTS.md](../../AGENTS.md) — full env-var and permission-mode reference
139
149
 
140
150
  ## License
141
151
 
@@ -7,7 +7,7 @@
7
7
  * npx ory-cline uninstall [--global] Remove the Ory hook scripts
8
8
  * npx ory-cline configure Set or view Ory credentials
9
9
  * npx ory-cline agent <cmd> Manage the agent's OAuth2 (DCR) identity
10
- * npx ory-cline permissions <cmd> Manage permission mode and tool permissions
10
+ * npx ory-cline permissions Show permission mode and per-tool coverage
11
11
  * npx ory-cline setup [options] Write hook scripts directly (fallback)
12
12
  * npx ory-cline status Show plugin status
13
13
  * npx ory-cline local <cmd> Manage the local Ory dev environment
package/dist/cli/main.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * npx ory-cline uninstall [--global] Remove the Ory hook scripts
9
9
  * npx ory-cline configure Set or view Ory credentials
10
10
  * npx ory-cline agent <cmd> Manage the agent's OAuth2 (DCR) identity
11
- * npx ory-cline permissions <cmd> Manage permission mode and tool permissions
11
+ * npx ory-cline permissions Show permission mode and per-tool coverage
12
12
  * npx ory-cline setup [options] Write hook scripts directly (fallback)
13
13
  * npx ory-cline status Show plugin status
14
14
  * npx ory-cline local <cmd> Manage the local Ory dev environment
@@ -54,6 +54,11 @@ const argus_1 = require("@ory/argus");
54
54
  const PACKAGE_ROOT = path.resolve(__dirname, "..", "..");
55
55
  function main() {
56
56
  const [command, ...args] = process.argv.slice(2);
57
+ // `--help` after a matched subcommand: print usage, do nothing else.
58
+ // Without this the switch below ignores the flag and `install --help`
59
+ // performs a real install (#221).
60
+ if ((0, argus_1.shouldPrintHelp)(command, args))
61
+ return help();
57
62
  switch (command) {
58
63
  case "install":
59
64
  (0, argus_1.beginDeferNextSteps)();
@@ -65,7 +70,10 @@ function main() {
65
70
  break;
66
71
  case "uninstall":
67
72
  uninstall(args);
68
- (0, argus_1.clearCredentialsForUninstall)().then(() => process.exit(0), (err) => {
73
+ (0, argus_1.clearCredentialsForUninstall)({
74
+ harness: "cline",
75
+ purge: args.includes("--purge"),
76
+ }).then(() => process.exit(0), (err) => {
69
77
  console.error(err.message ?? err);
70
78
  process.exit(1);
71
79
  });
@@ -74,7 +82,7 @@ function main() {
74
82
  (0, argus_1.runConfigureCommand)("ory-cline", args);
75
83
  break;
76
84
  case "agent":
77
- (0, argus_1.runAgentCommand)("ory-cline", args).then((code) => process.exit(code), (err) => {
85
+ (0, argus_1.runAgentCommand)("ory-cline", "cline", args).then((code) => process.exit(code), (err) => {
78
86
  console.error(err.message ?? err);
79
87
  process.exit(1);
80
88
  });
@@ -94,17 +102,11 @@ function main() {
94
102
  process.exit(1);
95
103
  });
96
104
  break;
97
- case "local":
98
- (0, argus_1.runLocalCommand)("ory-cline", args).catch((err) => {
99
- console.error(err.message ?? err);
100
- process.exit(1);
101
- });
102
- break;
103
105
  case "watch":
104
- (0, argus_1.runWatchCommand)("cline", args);
106
+ (0, argus_1.runWatchCommand)("ory-cline", "cline", args).then((code) => process.exit(code), (err) => { console.error(err.message ?? err); process.exit(1); });
105
107
  break;
106
- case "dashboard":
107
- (0, argus_1.runDashboardCommand)("ory-cline", "cline", args).then((code) => process.exit(code), (err) => {
108
+ case "local":
109
+ (0, argus_1.runLocalCommand)("ory-cline", args).catch((err) => {
108
110
  console.error(err.message ?? err);
109
111
  process.exit(1);
110
112
  });
@@ -169,11 +171,11 @@ Commands:
169
171
  uninstall [--global] Remove the Ory hook scripts from Cline
170
172
  configure Set or view Ory project URL and API key
171
173
  agent <cmd> Manage the agent's OAuth2 (DCR) identity (status, unregister)
172
- permissions <cmd> Manage permission mode and tool permissions (status, bootstrap, observe, enforce)
174
+ permissions Show the live permission mode and per-tool coverage
173
175
  setup [options] Write hook scripts directly to the hooks directory (fallback)
174
176
  status Show plugin status and configuration
175
- dashboard Open the Ory Agent dashboard (system health + configuration)
176
- watch [trace-file] Tail the trace stream (OTel spans) live
177
+ watch [--json] [--lines <count>]
178
+ Follow the live activity/debug log
177
179
  version Show version and the ory-agent-plugins build commit
178
180
  local <cmd> Manage local Ory dev environment (up, down, status, seed, ...)
179
181
 
@@ -6,8 +6,8 @@
6
6
  * filename matches the event name, found in a hooks directory. There is no
7
7
  * per-hook config file — presence of the script IS the registration. We
8
8
  * therefore write one thin shell shim per event into the hooks directory and
9
- * `chmod 0755` it. Each shim execs the published hook binary via npx,
10
- * forwarding stdin so the JSON payload reaches the Node entry point.
9
+ * `chmod 0755` it. Each shim execs the Ory runtime shim resolved at install
10
+ * time, forwarding stdin so the JSON payload reaches the Node entry point.
11
11
  *
12
12
  * Hooks directory (verified against cline@3.0.29):
13
13
  * workspace : <projectDir>/.clinerules/hooks/
package/dist/cli/setup.js CHANGED
@@ -7,8 +7,8 @@
7
7
  * filename matches the event name, found in a hooks directory. There is no
8
8
  * per-hook config file — presence of the script IS the registration. We
9
9
  * therefore write one thin shell shim per event into the hooks directory and
10
- * `chmod 0755` it. Each shim execs the published hook binary via npx,
11
- * forwarding stdin so the JSON payload reaches the Node entry point.
10
+ * `chmod 0755` it. Each shim execs the Ory runtime shim resolved at install
11
+ * time, forwarding stdin so the JSON payload reaches the Node entry point.
12
12
  *
13
13
  * Hooks directory (verified against cline@3.0.29):
14
14
  * workspace : <projectDir>/.clinerules/hooks/
@@ -61,37 +61,22 @@ const path = __importStar(require("node:path"));
61
61
  const argus_1 = require("@ory/argus");
62
62
  const assets_js_1 = require("./assets.js");
63
63
  const shims_js_1 = require("./shims.js");
64
- const HOOK_BIN = "ory-cline-hook";
64
+ const PACKAGE_ROOT = path.resolve(__dirname, "..", "..");
65
65
  /**
66
- * The version-pinned npx command that each shim execs. Resolving via npx
67
- * keeps the binary off the PATH requirement and pins the version the shim was
68
- * generated with (read from this package's own package.json).
69
- */
70
- function hookCommand() {
71
- return (0, argus_1.pinHookToLocalRegistry)(`npx -y -p ${shims_js_1.PACKAGE_NAME}@${readPackageVersion()} ${HOOK_BIN}`);
72
- }
73
- function readPackageVersion() {
74
- // dist/cli/setup.js -> package root is two levels up.
75
- const pkgPath = path.resolve(__dirname, "..", "..", "package.json");
76
- try {
77
- const parsed = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
78
- return parsed.version ?? "latest";
79
- }
80
- catch {
81
- return "latest";
82
- }
83
- }
84
- /**
85
- * Body of a per-event shim. A POSIX shell script that execs the hook binary,
86
- * forwarding stdin/stdout transparently. `exec` replaces the shell so the
87
- * hook's exit status and stdout flow straight back to Cline.
66
+ * Body of a per-event shim. A POSIX shell script that execs the Ory runtime
67
+ * entry, forwarding stdin/stdout transparently. `exec` replaces the shell so
68
+ * the hook's exit status and stdout flow straight back to Cline.
69
+ *
70
+ * The `${PACKAGE_NAME}` line is load-bearing beyond documentation: install and
71
+ * uninstall use it to tell our shims apart from hook scripts the user authored
72
+ * under the same event name (see `isOryShim`).
88
73
  */
89
- function shimBody() {
74
+ function shimBody(hookCommand) {
90
75
  return `#!/bin/sh
91
76
  # Ory plugin hook shim for Cline. Generated by ${shims_js_1.PACKAGE_NAME} — do not edit.
92
77
  # Forwards the event payload (stdin JSON) to the Ory hook and returns its
93
78
  # JSON decision on stdout.
94
- exec ${hookCommand()}
79
+ exec ${hookCommand}
95
80
  `;
96
81
  }
97
82
  /**
@@ -128,8 +113,9 @@ function main() {
128
113
  process.exit(0);
129
114
  }
130
115
  const args = (0, argus_1.parseSetupArgs)({ supportsGlobal: true });
131
- const body = shimBody();
132
116
  if (args.print) {
117
+ // Nothing is resolved or written on a --print run.
118
+ const body = shimBody('node "<runtime shim>"');
133
119
  for (const event of shims_js_1.HOOK_EVENTS) {
134
120
  console.log(`# ── ${event} ───────────────────────────────`);
135
121
  console.log(body);
@@ -155,12 +141,29 @@ function main() {
155
141
  }
156
142
  (0, assets_js_1.uninstallClineOryAssets)(rulesRoot);
157
143
  console.log(`Removed Ory skills from ${path.join(rulesRoot, "skills")}`);
144
+ (0, argus_1.removeRuntimeWiring)("cline");
145
+ for (const pruned of (0, argus_1.pruneRuntimeStores)()) {
146
+ console.log(` Removed runtime: ${pruned}`);
147
+ }
158
148
  return;
159
149
  }
150
+ const runtime = (0, argus_1.wireRuntime)({
151
+ harness: "cline",
152
+ packageName: shims_js_1.PACKAGE_NAME,
153
+ packageRoot: PACKAGE_ROOT,
154
+ installCommand: "npx -y -p @ory/cline ory-cline install",
155
+ args: process.argv.slice(2),
156
+ });
157
+ console.log(runtime.target.kind === "linked"
158
+ ? `Runtime: linked to ${runtime.target.packageDir} (dev)`
159
+ : `Runtime: ${runtime.target.packageName}@${runtime.target.version} in ${runtime.target.storeDir}`);
160
+ for (const pruned of runtime.prunedStores) {
161
+ console.log(` Removed stale runtime: ${pruned}`);
162
+ }
160
163
  // Write the per-event shims, skipping any event whose script the user
161
164
  // authored (i.e. it exists but is not an Ory shim). Existing Ory shims
162
165
  // are refreshed.
163
- const { written, skipped } = (0, shims_js_1.writeHookShims)(hooksDir, body);
166
+ const { written, skipped } = (0, shims_js_1.writeHookShims)(hooksDir, shimBody((0, argus_1.requireHookCommand)(runtime)));
164
167
  (0, assets_js_1.installClineOryAssets)(rulesRoot);
165
168
  console.log(`Ory hook scripts installed to ${hooksDir}`);
166
169
  console.log(` Scripts: ${written.length > 0 ? written.join(", ") : "(none)"}`);
@@ -180,7 +183,10 @@ main();
180
183
  // stored Ory credentials. When required by the plugin's main CLI, that
181
184
  // command owns the purge, so the `require.main` guard prevents a double run.
182
185
  if (require.main === module && process.argv.includes("--uninstall")) {
183
- (0, argus_1.clearCredentialsForUninstall)().then(() => process.exit(0), (err) => {
186
+ (0, argus_1.clearCredentialsForUninstall)({
187
+ harness: "cline",
188
+ purge: process.argv.includes("--purge"),
189
+ }).then(() => process.exit(0), (err) => {
184
190
  console.error(err.message ?? err);
185
191
  process.exit(1);
186
192
  });
@@ -16,15 +16,15 @@ export declare const PACKAGE_NAME = "@ory/cline";
16
16
  * carries the snake_case `hookName` the handler switches on:
17
17
  *
18
18
  * TaskStart → agent_start (auth gates)
19
- * TaskResume → agent_resume (trace-only)
20
- * TaskCancel → agent_abort (trace-only)
21
- * TaskComplete → agent_end (trace-only)
22
- * TaskError → agent_error (trace-only)
19
+ * TaskResume → agent_resume (activity-only)
20
+ * TaskCancel → agent_abort (activity-only)
21
+ * TaskComplete → agent_end (activity-only)
22
+ * TaskError → agent_error (activity-only)
23
23
  * PreToolUse → tool_call (permission gate, blocking)
24
- * PostToolUse → tool_result (trace-only)
25
- * UserPromptSubmit → prompt_submit (trace-only)
26
- * PreCompact → pre_compact (trace-only)
27
- * SessionShutdown → session_shutdown (trace-only)
24
+ * PostToolUse → tool_result (activity-only)
25
+ * UserPromptSubmit → prompt_submit (activity-only)
26
+ * PreCompact → pre_compact (activity-only)
27
+ * SessionShutdown → session_shutdown (activity-only)
28
28
  */
29
29
  export declare const HOOK_EVENTS: readonly ["TaskStart", "TaskResume", "TaskCancel", "TaskComplete", "TaskError", "PreToolUse", "PostToolUse", "UserPromptSubmit", "PreCompact", "SessionShutdown"];
30
30
  export declare function isOryShim(file: string): boolean;
package/dist/cli/shims.js CHANGED
@@ -57,15 +57,15 @@ exports.PACKAGE_NAME = "@ory/cline";
57
57
  * carries the snake_case `hookName` the handler switches on:
58
58
  *
59
59
  * TaskStart → agent_start (auth gates)
60
- * TaskResume → agent_resume (trace-only)
61
- * TaskCancel → agent_abort (trace-only)
62
- * TaskComplete → agent_end (trace-only)
63
- * TaskError → agent_error (trace-only)
60
+ * TaskResume → agent_resume (activity-only)
61
+ * TaskCancel → agent_abort (activity-only)
62
+ * TaskComplete → agent_end (activity-only)
63
+ * TaskError → agent_error (activity-only)
64
64
  * PreToolUse → tool_call (permission gate, blocking)
65
- * PostToolUse → tool_result (trace-only)
66
- * UserPromptSubmit → prompt_submit (trace-only)
67
- * PreCompact → pre_compact (trace-only)
68
- * SessionShutdown → session_shutdown (trace-only)
65
+ * PostToolUse → tool_result (activity-only)
66
+ * UserPromptSubmit → prompt_submit (activity-only)
67
+ * PreCompact → pre_compact (activity-only)
68
+ * SessionShutdown → session_shutdown (activity-only)
69
69
  */
70
70
  exports.HOOK_EVENTS = [
71
71
  "TaskStart",
@@ -1,20 +1,12 @@
1
- import { OryAgentClient, ensureUserAuthenticated, ensureAgentIdentity } from "@ory/argus";
1
+ import { OryAgentClient, ensureAgentIdentity, ensureSubAgentIdentity, ensureUserAuthenticated } from "@ory/argus";
2
2
  import type { ClineHookInput, ClineHookOutput } from "./types.js";
3
3
  export interface HandleHookEventDeps {
4
- /** Test injection point for the user login flow. */
5
4
  userLogin?: typeof ensureUserAuthenticated;
6
- /** Test injection point for the agent identity gate. */
7
5
  agentGate?: typeof ensureAgentIdentity;
6
+ subAgentGate?: typeof ensureSubAgentIdentity;
8
7
  }
9
8
  /**
10
- * Route a Cline file-hook event to the appropriate Ory integration.
11
- *
12
- * Cline has no dedicated approval-ask hook, so authorization is enforced at
13
- * the `tool_call` event. A deny becomes `{ cancel: true, errorMessage }`, which
14
- * prevents the tool from running.
15
- *
16
- * The on-disk script filenames are PascalCase (TaskStart, PreToolUse, …) but
17
- * the `hookName` field inside the stdin payload is the snake_case
18
- * `HookEventName` enum (verified against cline@3.0.29) — we switch on that.
9
+ * Route a Cline file-hook event to Ory. Cline blocks a `tool_call` with
10
+ * `{ cancel: true, errorMessage }`.
19
11
  */
20
12
  export declare function handleHookEvent(input: ClineHookInput, client: OryAgentClient, deps?: HandleHookEventDeps): Promise<ClineHookOutput>;
package/dist/handlers.js CHANGED
@@ -2,16 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleHookEvent = handleHookEvent;
4
4
  const argus_1 = require("@ory/argus");
5
+ const HARNESS = "cline";
5
6
  /**
6
- * Route a Cline file-hook event to the appropriate Ory integration.
7
- *
8
- * Cline has no dedicated approval-ask hook, so authorization is enforced at
9
- * the `tool_call` event. A deny becomes `{ cancel: true, errorMessage }`, which
10
- * prevents the tool from running.
11
- *
12
- * The on-disk script filenames are PascalCase (TaskStart, PreToolUse, …) but
13
- * the `hookName` field inside the stdin payload is the snake_case
14
- * `HookEventName` enum (verified against cline@3.0.29) — we switch on that.
7
+ * Route a Cline file-hook event to Ory. Cline blocks a `tool_call` with
8
+ * `{ cancel: true, errorMessage }`.
15
9
  */
16
10
  async function handleHookEvent(input, client, deps = {}) {
17
11
  const event = input.hookName;
@@ -20,245 +14,116 @@ async function handleHookEvent(input, client, deps = {}) {
20
14
  taskId: input.taskId,
21
15
  toolName: input.preToolUse?.toolName ?? input.postToolUse?.toolName,
22
16
  });
23
- // Set trace context so all spans within this hook invocation correlate.
24
- client.tracer.setContext({
25
- traceId: (0, argus_1.deriveTraceId)(input.taskId),
26
- sessionId: input.taskId,
27
- });
28
- try {
17
+ return (0, argus_1.withHookContext)(client, { sessionId: input.taskId }, async () => {
29
18
  switch (event) {
30
19
  case "agent_start":
31
- return await handleTaskStart(input, client, deps);
20
+ client.logger.info("lifecycle.task_start", {
21
+ taskId: input.taskId,
22
+ workspaceRoots: input.workspaceRoots,
23
+ });
24
+ await startTask(input, client, deps);
25
+ return {};
32
26
  case "agent_resume":
33
- return await handleTaskResume(input, client);
27
+ client.logger.info("lifecycle.task_resume", { taskId: input.taskId });
28
+ await startTask(input, client, deps);
29
+ return {};
30
+ case "tool_call": {
31
+ const toolName = input.preToolUse?.toolName ?? "unknown";
32
+ const toolArgs = input.preToolUse?.parameters;
33
+ client.logger.info("lifecycle.pre_tool_use", {
34
+ taskId: input.taskId,
35
+ toolName,
36
+ toolInput: toolArgs,
37
+ });
38
+ const result = await (0, argus_1.gate)(client, {
39
+ harness: HARNESS,
40
+ toolName,
41
+ toolArgs,
42
+ subjectFallback: `session:${input.taskId}`,
43
+ principals: actingSubagentPrincipals(input),
44
+ });
45
+ return result.blocked
46
+ ? { cancel: true, errorMessage: result.denialMessage }
47
+ : {};
48
+ }
49
+ case "tool_result": {
50
+ const toolName = input.postToolUse?.toolName ?? "unknown";
51
+ client.logger.info("lifecycle.post_tool_use", {
52
+ taskId: input.taskId,
53
+ toolName,
54
+ success: input.postToolUse?.success,
55
+ });
56
+ const terminal = {
57
+ toolName,
58
+ input: input.postToolUse?.parameters,
59
+ extraActivityAttributes: {
60
+ success: input.postToolUse?.success,
61
+ executionTimeMs: input.postToolUse?.executionTimeMs,
62
+ },
63
+ };
64
+ if (input.postToolUse?.success === false) {
65
+ (0, argus_1.fail)(client, { ...terminal, error: input.postToolUse.result });
66
+ }
67
+ else {
68
+ (0, argus_1.complete)(client, { ...terminal, output: input.postToolUse?.result });
69
+ }
70
+ return {};
71
+ }
34
72
  case "agent_abort":
35
- return await handleTaskCancel(input, client);
73
+ return endTask(client, input, "ok", { reasonCode: "abort" }, "lifecycle.task_cancel");
36
74
  case "agent_end":
37
- return await handleTaskComplete(input, client);
75
+ return endTask(client, input, "ok", { reasonCode: "complete" }, "lifecycle.task_complete");
38
76
  case "agent_error":
39
- return await handleTaskError(input, client);
40
- case "tool_call":
41
- return await handlePreToolUse(input, client);
42
- case "tool_result":
43
- return await handlePostToolUse(input, client);
77
+ return endTask(client, input, "error", { reasonCode: "error" }, "lifecycle.task_error");
78
+ case "session_shutdown":
79
+ return endTask(client, input, "ok", { stage: "session_shutdown" }, "lifecycle.session_shutdown");
44
80
  case "prompt_submit":
45
- return await handleUserPromptSubmit(input, client);
81
+ client.logger.info("lifecycle.user_prompt_submit", { taskId: input.taskId });
82
+ client.logger.activity("user.prompt", "ok", {
83
+ attributes: { stage: "user_prompt_submit" },
84
+ });
85
+ return {};
46
86
  case "pre_compact":
47
- return await handlePreCompact(input, client);
48
- case "session_shutdown":
49
- return await handleSessionShutdown(input, client);
87
+ client.logger.info("lifecycle.pre_compact", { taskId: input.taskId });
88
+ client.logger.activity("compaction", "ok", { attributes: { stage: "pre_compact" } });
89
+ return {};
50
90
  default:
51
91
  client.logger.debug("hook.passthrough", { event });
52
- client.tracer.record("hook.passthrough", "skipped", {
53
- attributes: { event },
54
- });
92
+ client.logger.activity("hook.passthrough", "skipped", { attributes: { event } });
55
93
  return {};
56
94
  }
57
- }
58
- finally {
59
- client.tracer.clearContext();
60
- }
61
- }
62
- // ─── agent_start (session.start) ───────────────────────────────────
63
- async function handleTaskStart(input, client, deps) {
64
- client.logger.info("lifecycle.task_start", {
65
- taskId: input.taskId,
66
- workspaceRoots: input.workspaceRoots,
67
- });
68
- client.tracer.record("session.start", "ok", {
69
- attributes: { clineVersion: input.clineVersion },
70
- });
71
- // 1. User gate. The user login runs every session and never blocks;
72
- // enforcement is governed solely by permissionMode at tool-call time.
73
- const userGate = deps.userLogin ?? argus_1.ensureUserAuthenticated;
74
- await userGate(client, {
75
- binName: "ory-cline",
76
- harness: "cline",
77
- });
78
- // 2. Agent gate. Never blocks; attaches the agent's bearer token to
79
- // outgoing Ory API calls.
80
- const agentGate = deps.agentGate ?? argus_1.ensureAgentIdentity;
81
- await agentGate(client, {
82
- projectUrl: (0, argus_1.resolveConfig)().projectUrl,
83
- harness: "cline",
84
95
  });
85
- // 3. User → agent delegation tuple. Best-effort; never blocks. Written at
86
- // most once per install.
87
- await (0, argus_1.writeUserDelegatesAgent)(client);
88
- return {};
89
96
  }
90
- // ─── tool_call (tool.before, blocking) ─────────────────────────────
91
- async function handlePreToolUse(input, client) {
92
- const toolName = input.preToolUse?.toolName ?? "unknown";
93
- const toolInput = input.preToolUse?.parameters;
94
- client.logger.info("lifecycle.pre_tool_use", {
95
- taskId: input.taskId,
96
- toolName,
97
- toolInput,
98
- });
99
- const inputSummary = (0, argus_1.summarizeToolInput)(toolName, toolInput);
100
- // In audit-only mode, log the invocation but skip permission checks.
101
- if ((0, argus_1.resolveConfig)().auditOnly) {
102
- client.tracer.record("tool.invoke", "ok", {
103
- attributes: { toolName, ...inputSummary },
104
- });
105
- return {};
106
- }
107
- const subject = (0, argus_1.resolveUserSubject)(client, `session:${input.taskId}`);
108
- const subjectId = (0, argus_1.subjectLabel)(subject);
109
- const namespace = resolveNamespace();
110
- try {
111
- const outcome = await (0, argus_1.gateToolCall)(client, {
112
- harness: "cline",
113
- toolName,
114
- check: { namespace, object: toolName, relation: "use", ...subject },
115
- spanAttributes: { toolName },
116
- });
117
- // Interactive tools (operator-extensible via ORY_INTERACTIVE_TOOLS):
118
- // user.interaction span is already recorded; pass through.
119
- if (outcome.kind === "interactive") {
120
- return {};
121
- }
122
- const decision = outcome;
123
- if (decision.kind === "fail_open") {
124
- return handlePermissionError(decision.error, toolName, client);
125
- }
126
- const attrs = { toolName, ...inputSummary };
127
- const decisionAttrs = decision.spanAttributes;
128
- if (decision.kind === "allow") {
129
- client.tracer.record("tool.invoke", "ok", {
130
- attributes: { ...attrs, ...decisionAttrs, allowed: true },
131
- });
132
- return {};
133
- }
134
- if (decision.kind === "observe") {
135
- client.tracer.record("tool.block", "denied", {
136
- attributes: {
137
- ...attrs,
138
- ...decisionAttrs,
139
- allowed: false,
140
- ...(0, argus_1.alertAttributes)(false),
141
- },
142
- });
143
- client.tracer.record("tool.invoke", "ok", {
144
- attributes: { ...attrs, ...decisionAttrs, allowed: false, observed: true },
145
- });
146
- return {};
147
- }
148
- // deny → cancel the tool.
149
- client.tracer.record("tool.block", "denied", {
150
- attributes: {
151
- ...attrs,
152
- ...decisionAttrs,
153
- allowed: false,
154
- ...(0, argus_1.alertAttributes)(true),
155
- },
156
- });
157
- return {
158
- cancel: true,
159
- errorMessage: (0, argus_1.formatDenialMessage)({ tool: toolName, subjectId, namespace }),
160
- };
161
- }
162
- catch (err) {
163
- return handlePermissionError(err, toolName, client);
164
- }
165
- }
166
- // ─── tool_result (tool.after) ──────────────────────────────────────
167
- async function handlePostToolUse(input, client) {
168
- const toolName = input.postToolUse?.toolName ?? "unknown";
169
- const toolInput = input.postToolUse?.parameters;
170
- const toolResult = input.postToolUse?.result;
171
- client.logger.info("lifecycle.post_tool_use", {
172
- taskId: input.taskId,
173
- toolName,
174
- success: input.postToolUse?.success,
175
- });
176
- client.tracer.record("tool.complete", "ok", {
177
- attributes: {
178
- toolName,
179
- success: input.postToolUse?.success,
180
- executionTimeMs: input.postToolUse?.executionTimeMs,
181
- ...(0, argus_1.summarizeToolInput)(toolName, toolInput),
182
- ...(0, argus_1.summarizeToolOutput)(toolName, toolResult),
183
- },
184
- });
185
- return {};
186
- }
187
- // ─── Trace-only lifecycle events ───────────────────────────────────
188
- async function handleTaskResume(input, client) {
189
- client.logger.info("lifecycle.task_resume", { taskId: input.taskId });
190
- client.tracer.record("session.start", "ok", {
191
- attributes: { resumed: true, clineVersion: input.clineVersion },
192
- });
193
- return {};
194
- }
195
- async function handleTaskCancel(input, client) {
196
- client.logger.info("lifecycle.task_cancel", { taskId: input.taskId });
197
- client.tracer.record("session.end", "ok", {
198
- attributes: { reason: "abort" },
199
- });
200
- return {};
201
- }
202
- async function handleTaskComplete(input, client) {
203
- client.logger.info("lifecycle.task_complete", { taskId: input.taskId });
204
- client.tracer.record("session.end", "ok", {
205
- attributes: { reason: "complete" },
206
- });
207
- return {};
208
- }
209
- async function handleTaskError(input, client) {
210
- client.logger.info("lifecycle.task_error", { taskId: input.taskId });
211
- client.tracer.record("session.end", "error", {
212
- attributes: { reason: "error" },
213
- });
214
- return {};
215
- }
216
- async function handleSessionShutdown(input, client) {
217
- client.logger.info("lifecycle.session_shutdown", { taskId: input.taskId });
218
- client.tracer.record("session.end", "ok", {
219
- attributes: { stage: "session_shutdown" },
220
- });
221
- return {};
222
- }
223
- async function handleUserPromptSubmit(input, client) {
224
- client.logger.info("lifecycle.user_prompt_submit", { taskId: input.taskId });
225
- // User-facing phase: the human is the decision-maker. Audit span only.
226
- client.tracer.record("user.prompt", "ok", {
227
- attributes: { stage: "user_prompt_submit" },
228
- });
229
- return {};
230
- }
231
- async function handlePreCompact(input, client) {
232
- client.logger.info("lifecycle.pre_compact", { taskId: input.taskId });
233
- client.tracer.record("compaction", "ok", {
234
- attributes: { stage: "pre_compact" },
235
- });
236
- return {};
237
- }
238
- // ─── Helpers ────────────────────────────────────────────────────────
239
- function resolveNamespace() {
240
- return process.env.ORY_PERMISSION_NAMESPACE ?? "AgentTools";
97
+ function actingSubagentPrincipals(input) {
98
+ if (!input.parent_agent_id || !input.agent_id)
99
+ return undefined;
100
+ const credential = (0, argus_1.loadSubAgentDynamicCredentials)(HARNESS, input.taskId, HARNESS);
101
+ if (!credential)
102
+ return undefined;
103
+ return {
104
+ subAgentClientId: credential.clientId,
105
+ subAgentType: HARNESS,
106
+ perSpawnId: input.agent_id,
107
+ sessionId: input.taskId,
108
+ };
241
109
  }
242
- function handlePermissionError(oryErr, toolName, client) {
243
- if (oryErr.code === "network_error") {
244
- client.logger.warn("permission.network_error", {
245
- toolName,
246
- message: "Ory unreachable, failing open",
110
+ async function startTask(input, client, deps) {
111
+ await (0, argus_1.sessionStart)(client, {
112
+ harness: HARNESS,
113
+ userLogin: deps.userLogin,
114
+ agentGate: deps.agentGate,
115
+ });
116
+ if (input.parent_agent_id && input.agent_id) {
117
+ await (0, argus_1.registerSubagent)(client, {
118
+ harness: HARNESS,
119
+ subAgentType: HARNESS,
120
+ perSpawnId: input.agent_id,
121
+ subAgentGate: deps.subAgentGate,
247
122
  });
248
- return {};
249
123
  }
250
- if (oryErr.code === "rate_limited") {
251
- client.logger.warn("permission.rate_limited", {
252
- toolName,
253
- message: "Ory rate limited, failing open",
254
- });
255
- return {};
256
- }
257
- // For other errors, also fail open but log prominently.
258
- client.logger.error("permission.check.error", {
259
- toolName,
260
- code: oryErr.code,
261
- message: oryErr.message,
262
- });
124
+ }
125
+ function endTask(client, input, status, attributes, logEvent) {
126
+ client.logger.info(logEvent, { taskId: input.taskId });
127
+ client.logger.activity("session.end", status, { attributes });
263
128
  return {};
264
129
  }
package/dist/hook.js CHANGED
@@ -18,6 +18,16 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  const argus_1 = require("@ory/argus");
20
20
  const handlers_js_1 = require("./handlers.js");
21
+ const EVENT_FLUSH_TIMEOUT_MS = 750;
22
+ let client;
23
+ async function flushEvents() {
24
+ try {
25
+ await client?.flushEvents(EVENT_FLUSH_TIMEOUT_MS);
26
+ }
27
+ catch {
28
+ // The hook decision must not depend on activity delivery.
29
+ }
30
+ }
21
31
  /**
22
32
  * Read all of stdin as a string.
23
33
  *
@@ -53,7 +63,7 @@ function readStdin() {
53
63
  });
54
64
  }
55
65
  async function main() {
56
- const client = argus_1.OryAgentClient.fromEnv("cline");
66
+ client = argus_1.OryAgentClient.fromEnv("cline");
57
67
  const raw = await readStdin();
58
68
  let input;
59
69
  try {
@@ -61,7 +71,6 @@ async function main() {
61
71
  }
62
72
  catch {
63
73
  client.logger.error("hook.stdin.parse_failed", { raw: raw.slice(0, 200) });
64
- await client.tracer.shutdown();
65
74
  process.exit(0); // Don't block on parse errors
66
75
  }
67
76
  const output = await (0, handlers_js_1.handleHookEvent)(input, client);
@@ -70,10 +79,11 @@ async function main() {
70
79
  if (output.cancel || output.contextModification || output.errorMessage) {
71
80
  process.stdout.write(JSON.stringify(output));
72
81
  }
73
- await client.tracer.shutdown();
82
+ await flushEvents();
74
83
  process.exit(0);
75
84
  }
76
- main().catch((err) => {
85
+ main().catch(async (err) => {
77
86
  process.stderr.write(`[ory-agent] fatal: ${err}\n`);
87
+ await flushEvents();
78
88
  process.exit(0); // Fail open
79
89
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ory/cline",
3
- "version": "0.14.0",
3
+ "version": "1.0.1",
4
4
  "description": "Ory plugin for Cline: 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",
@@ -35,8 +35,7 @@
35
35
  "agent-security",
36
36
  "guardrails",
37
37
  "llm",
38
- "tracing",
39
- "distributed-tracing",
38
+ "activity-auditing",
40
39
  "observability",
41
40
  "kratos",
42
41
  "keto",
@@ -47,6 +46,10 @@
47
46
  "registry": "https://registry.npmjs.org/",
48
47
  "provenance": true
49
48
  },
49
+ "reova": {
50
+ "enabled": true,
51
+ "endpoint": "https://telemetry.reo.dev/data"
52
+ },
50
53
  "main": "dist/index.js",
51
54
  "types": "dist/index.d.ts",
52
55
  "exports": {
@@ -62,12 +65,11 @@
62
65
  },
63
66
  "files": [
64
67
  "dist",
65
- "!dist/dev",
66
68
  "!dist/**/*.tsbuildinfo"
67
69
  ],
68
70
  "dependencies": {
69
- "reo-census": "^1.2.8",
70
- "@ory/argus": "0.14.0"
71
+ "reova": "^0.7.0",
72
+ "@ory/argus": "1.0.1"
71
73
  },
72
74
  "devDependencies": {
73
75
  "typescript": "^6.0.2",
@@ -81,7 +83,6 @@
81
83
  "clean": "rm -rf dist *.tsbuildinfo",
82
84
  "test": "vitest run",
83
85
  "test:watch": "vitest",
84
- "typecheck": "tsc --noEmit",
85
- "dev": "node dist/dev/launcher.js"
86
+ "typecheck": "tsc --noEmit"
86
87
  }
87
88
  }