@ory/argus 0.8.2 → 0.9.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.
@@ -86,7 +86,7 @@ import {
86
86
  const client = OryAgentClient.fromEnv("my-agent");
87
87
  const { projectUrl } = resolveConfig();
88
88
 
89
- // 1. User gate — interactive PKCE when ORY_USER_LOGIN=1, no-op otherwise.
89
+ // 1. User gate — interactive PKCE when ORY_USER_LOGIN=true, no-op otherwise.
90
90
  const userDecision = await ensureUserAuthenticated(client, {
91
91
  binName: "my-agent",
92
92
  harness: "my-agent",
@@ -409,7 +409,7 @@ PKCE flow, permission tuples, and trace spans are all visible:
409
409
  1. {{REF_LOCAL_UP}} — brings up Kratos / Keto / Hydra on `localhost:4000`
410
410
  and seeds a demo user. The banner prints the email + password.
411
411
  2. Export the env vars the launcher writes (`ORY_PROJECT_URL`,
412
- `ORY_USER_LOGIN=1`, `ORY_OAUTH2_CLIENT_ID`, optional
412
+ `ORY_USER_LOGIN=true`, `ORY_OAUTH2_CLIENT_ID`, optional
413
413
  `ORY_AGENT_TRACE_FILE` for an NDJSON span log).
414
414
  3. Start your agent. Confirm the browser opens for PKCE login.
415
415
  4. Invoke a gated tool and `tail -f $ORY_AGENT_TRACE_FILE | jq .` — you
@@ -66,7 +66,7 @@ export const template = Template()
66
66
  // Sandbox runtime defaults. Per-tenant secrets (project URL, tokens, client
67
67
  // IDs) MUST be passed at Sandbox.create() time, never baked into the image.
68
68
  .setEnvs({
69
- ORY_USER_LOGIN: "1",
69
+ ORY_USER_LOGIN: "true",
70
70
  ORY_PERMISSION_MODE: "observe",
71
71
  ORY_PERMISSION_NAMESPACE: "AgentTools",
72
72
  ORY_AGENT_DEBUG: "true",
@@ -41,9 +41,11 @@ What you want to see:
41
41
  If any of those are wrong, fix them before continuing:
42
42
 
43
43
  ```sh
44
- {{NPX}} configure --project-url <URL> --api-key <KEY>
44
+ {{NPX}} configure --project-url <URL> --oauth2-client-id <CLIENT_ID> [--api-key <KEY>]
45
45
  ```
46
46
 
47
+ `--oauth2-client-id` is the public OAuth2 client registered in your Ory project (required when `ORY_USER_LOGIN=true`; see the *Register the user OAuth2 client* section of the plugin README).
48
+
47
49
  ## Step 2: Look at the current permission posture
48
50
 
49
51
  ```sh
@@ -94,7 +96,7 @@ Two common failure modes:
94
96
  1. **No user identity cached.** Bootstrap needs to know which subject
95
97
  to grant tuples to. If user login has never run (no PKCE login,
96
98
  no `ORY_USER_SUBJECT_ID`), the command refuses. Run the harness once
97
- with `ORY_USER_LOGIN=1` to cache a user token, or set
99
+ with `ORY_USER_LOGIN=true` to cache a user token, or set
98
100
  `ORY_USER_SUBJECT_ID=<id>` to target a known subject.
99
101
  2. **Credentials lack write scope on the permission namespace.** The
100
102
  command prints the full tuple list so you can apply them manually
@@ -290,7 +290,7 @@ async function resolveAgentCredentials(options = {}) {
290
290
  }
291
291
  return {
292
292
  kind: "none",
293
- reason: "No agent credentials configured. Run with a user session (ORY_USER_LOGIN=1) or set ORY_AGENT_API_KEY / ORY_AGENT_CLIENT_ID + ORY_AGENT_CLIENT_SECRET / ORY_AGENT_REGISTRATION_TOKEN.",
293
+ reason: "No agent credentials configured. Run with a user session (ORY_USER_LOGIN=true) or set ORY_AGENT_API_KEY / ORY_AGENT_CLIENT_ID + ORY_AGENT_CLIENT_SECRET / ORY_AGENT_REGISTRATION_TOKEN.",
294
294
  warnings,
295
295
  };
296
296
  }
package/dist/cli.d.ts CHANGED
@@ -1,8 +1,16 @@
1
1
  /**
2
2
  * Shared `configure` command implementation for all plugin CLIs.
3
3
  *
4
- * Parses --project-url and --api-key from args. If neither is provided,
5
- * shows the current configuration. Otherwise saves the provided values.
4
+ * Parses --project-url, --api-key, and --oauth2-client-id from args.
5
+ * If none is provided, shows the current configuration. Otherwise saves
6
+ * the provided values.
7
+ *
8
+ * When `--project-url` is provided, requires the OAuth2 client id to be
9
+ * resolvable from one of: the `--oauth2-client-id` flag, the
10
+ * `ORY_OAUTH2_CLIENT_ID` env var, or an already-persisted value in the
11
+ * shared config. The PKCE browser flow that runs when
12
+ * `ORY_USER_LOGIN=true` can't self-register that client — surfacing the
13
+ * requirement here keeps users from a silently-broken setup later.
6
14
  */
7
15
  export declare function runConfigureCommand(binName: string, args: string[]): void;
8
16
  /**
package/dist/cli.js CHANGED
@@ -54,12 +54,21 @@ const tracer_js_1 = require("./tracer.js");
54
54
  /**
55
55
  * Shared `configure` command implementation for all plugin CLIs.
56
56
  *
57
- * Parses --project-url and --api-key from args. If neither is provided,
58
- * shows the current configuration. Otherwise saves the provided values.
57
+ * Parses --project-url, --api-key, and --oauth2-client-id from args.
58
+ * If none is provided, shows the current configuration. Otherwise saves
59
+ * the provided values.
60
+ *
61
+ * When `--project-url` is provided, requires the OAuth2 client id to be
62
+ * resolvable from one of: the `--oauth2-client-id` flag, the
63
+ * `ORY_OAUTH2_CLIENT_ID` env var, or an already-persisted value in the
64
+ * shared config. The PKCE browser flow that runs when
65
+ * `ORY_USER_LOGIN=true` can't self-register that client — surfacing the
66
+ * requirement here keeps users from a silently-broken setup later.
59
67
  */
60
68
  function runConfigureCommand(binName, args) {
61
69
  let projectUrl;
62
70
  let apiKey;
71
+ let oauth2ClientId;
63
72
  let auditOnly = false;
64
73
  for (let i = 0; i < args.length; i++) {
65
74
  switch (args[i]) {
@@ -69,30 +78,35 @@ function runConfigureCommand(binName, args) {
69
78
  case "--api-key":
70
79
  apiKey = args[++i];
71
80
  break;
81
+ case "--oauth2-client-id":
82
+ oauth2ClientId = args[++i];
83
+ break;
72
84
  case "--audit-only":
73
85
  auditOnly = true;
74
86
  break;
75
87
  }
76
88
  }
77
- if (!projectUrl && !apiKey && !auditOnly) {
89
+ if (!projectUrl && !apiKey && !oauth2ClientId && !auditOnly) {
78
90
  const resolved = (0, config_js_1.resolveConfig)();
79
91
  const configPath = (0, config_js_1.getConfigPath)();
80
92
  console.log("Ory Plugin Configuration");
81
93
  console.log("========================");
82
94
  console.log("");
83
- console.log(`Config file: ${configPath}`);
84
- console.log(`Project URL: ${resolved.projectUrl ?? "(not set)"} [${resolved.projectUrlSource}]`);
85
- console.log(`API Key: ${resolved.apiKey ? "(set)" : "(not set)"} [${resolved.apiKeySource}]`);
86
- console.log(`Audit Only: ${resolved.auditOnly ? "yes" : "no"}`);
95
+ console.log(`Config file: ${configPath}`);
96
+ console.log(`Project URL: ${resolved.projectUrl ?? "(not set)"} [${resolved.projectUrlSource}]`);
97
+ console.log(`API Key: ${resolved.apiKey ? "(set)" : "(not set)"} [${resolved.apiKeySource}]`);
98
+ console.log(`OAuth2 Client ID: ${resolved.oauth2ClientId ?? "(not set)"} [${resolved.oauth2ClientIdSource}]`);
99
+ console.log(`Audit Only: ${resolved.auditOnly ? "yes" : "no"}`);
87
100
  console.log("");
88
101
  console.log("To configure:");
89
- console.log(` npx ${binName} configure --project-url <URL> --api-key <KEY>`);
102
+ console.log(` npx ${binName} configure --project-url <URL> --oauth2-client-id <CLIENT_ID> [--api-key <KEY>]`);
90
103
  console.log("");
91
104
  console.log("To enable audit logging only (no auth or permission checks):");
92
105
  console.log(` npx ${binName} configure --audit-only`);
93
106
  console.log("");
94
107
  console.log("Or set environment variables:");
95
108
  console.log(" export ORY_PROJECT_URL=https://your-project.projects.oryapis.com");
109
+ console.log(" export ORY_OAUTH2_CLIENT_ID=<public OAuth2 client id>");
96
110
  console.log(" export ORY_AGENT_API_KEY=ory_pat_...");
97
111
  return;
98
112
  }
@@ -106,11 +120,49 @@ function runConfigureCommand(binName, args) {
106
120
  console.log("This configuration is shared across all Ory agent plugins.");
107
121
  return;
108
122
  }
123
+ // When --project-url is provided we need a usable OAuth2 client id for
124
+ // the user PKCE flow — block the configure with a clear error if none
125
+ // is reachable from the flag, env, or already-persisted config.
126
+ if (projectUrl) {
127
+ const persisted = (0, config_js_1.loadConfig)().oauth2ClientId;
128
+ const envClientId = process.env.ORY_OAUTH2_CLIENT_ID;
129
+ const resolved = oauth2ClientId ?? envClientId ?? persisted;
130
+ if (!resolved) {
131
+ console.error("Error: --project-url requires an OAuth2 client id for the user PKCE flow.\n" +
132
+ "\n" +
133
+ "Provide one with --oauth2-client-id <id>, or set ORY_OAUTH2_CLIENT_ID in your\n" +
134
+ "environment. The client must be a public OAuth2 client (no client secret,\n" +
135
+ "token_endpoint_auth_method=none) registered in your Ory project with all four\n" +
136
+ "loopback redirect URIs:\n" +
137
+ " http://127.0.0.1:47823/callback\n" +
138
+ " http://127.0.0.1:47824/callback\n" +
139
+ " http://127.0.0.1:47825/callback\n" +
140
+ " http://127.0.0.1:47826/callback\n" +
141
+ "\n" +
142
+ "Create it with:\n" +
143
+ " ory create oauth2-client --project <project-id> \\\n" +
144
+ " --name \"ory-agent-plugin\" \\\n" +
145
+ " --grant-type authorization_code,refresh_token \\\n" +
146
+ " --response-type code \\\n" +
147
+ " --scope openid,offline_access \\\n" +
148
+ " --token-endpoint-auth-method none \\\n" +
149
+ " --redirect-uri http://127.0.0.1:47823/callback \\\n" +
150
+ " --redirect-uri http://127.0.0.1:47824/callback \\\n" +
151
+ " --redirect-uri http://127.0.0.1:47825/callback \\\n" +
152
+ " --redirect-uri http://127.0.0.1:47826/callback\n" +
153
+ "\n" +
154
+ "If you only want audit logging (no auth or permission checks), use:\n" +
155
+ ` npx ${binName} configure --audit-only`);
156
+ process.exit(1);
157
+ }
158
+ }
109
159
  const update = {};
110
160
  if (projectUrl)
111
161
  update.projectUrl = projectUrl;
112
162
  if (apiKey)
113
163
  update.apiKey = apiKey;
164
+ if (oauth2ClientId)
165
+ update.oauth2ClientId = oauth2ClientId;
114
166
  // Clear auditOnly when configuring with a project URL
115
167
  update.auditOnly = false;
116
168
  (0, config_js_1.saveConfig)(update);
@@ -120,9 +172,11 @@ function runConfigureCommand(binName, args) {
120
172
  console.log(` Project URL: ${projectUrl}`);
121
173
  if (apiKey)
122
174
  console.log(` API Key: (set)`);
175
+ if (oauth2ClientId)
176
+ console.log(` OAuth2 Client ID: ${oauth2ClientId}`);
123
177
  console.log("");
124
178
  console.log("This configuration is shared across all Ory agent plugins.");
125
- console.log("Environment variables (ORY_PROJECT_URL, ORY_AGENT_API_KEY) take precedence when set.");
179
+ console.log("Environment variables (ORY_PROJECT_URL, ORY_AGENT_API_KEY, ORY_OAUTH2_CLIENT_ID) take precedence when set.");
126
180
  }
127
181
  /**
128
182
  * Print the "Configuration:" block showing Ory project URL and API key status.
@@ -136,6 +190,7 @@ function printOryConfig() {
136
190
  console.log(` Mode: ${resolved.auditOnly ? "audit-only" : "full"}`);
137
191
  console.log(` Project URL: ${resolved.projectUrl ?? "NOT SET"} [source: ${resolved.projectUrlSource}]`);
138
192
  console.log(` API Key: ${resolved.apiKey ? "(set)" : "NOT SET"} [source: ${resolved.apiKeySource}]`);
193
+ console.log(` OAuth2 Client: ${resolved.oauth2ClientId ?? "NOT SET"} [source: ${resolved.oauth2ClientIdSource}]`);
139
194
  console.log(` Permission mode: ${resolved.permissionMode} [source: ${resolved.permissionModeSource}]`);
140
195
  console.log(` Namespace: ${namespace}`);
141
196
  }
@@ -153,6 +208,7 @@ function printEnvironment() {
153
208
  false,
154
209
  ],
155
210
  ["ORY_AGENT_CLIENT_ID", process.env.ORY_AGENT_CLIENT_ID, false],
211
+ ["ORY_OAUTH2_CLIENT_ID", process.env.ORY_OAUTH2_CLIENT_ID, false],
156
212
  [
157
213
  "ORY_USER_SESSION_TOKEN",
158
214
  process.env.ORY_USER_SESSION_TOKEN ? "(set)" : undefined,
@@ -210,10 +266,13 @@ function printEnvHelp(binName) {
210
266
  console.log("Configure your Ory credentials (one of these methods):");
211
267
  console.log("");
212
268
  console.log(" Option 1 — Save to config file (persists across sessions):");
213
- console.log(` npx ${binName} configure --project-url https://your-project.projects.oryapis.com --api-key ory_pat_...`);
269
+ console.log(` npx ${binName} configure --project-url https://your-project.projects.oryapis.com \\`);
270
+ console.log(" --oauth2-client-id <public OAuth2 client id> \\");
271
+ console.log(" --api-key ory_pat_...");
214
272
  console.log("");
215
273
  console.log(" Option 2 — Set environment variables:");
216
274
  console.log(" export ORY_PROJECT_URL=https://your-project.projects.oryapis.com");
275
+ console.log(" export ORY_OAUTH2_CLIENT_ID=<public OAuth2 client id>");
217
276
  console.log(" export ORY_AGENT_API_KEY=ory_pat_...");
218
277
  console.log("");
219
278
  console.log("If neither is set when a session starts, the agent will prompt for configuration.");
@@ -371,7 +430,7 @@ async function interactiveConfigPrompt(binName) {
371
430
  "Run one of the following commands in another terminal:",
372
431
  "",
373
432
  " Connect to Ory (enables auth & permission checks):",
374
- ` npx ${binName} configure --project-url <URL> --api-key <KEY>`,
433
+ ` npx ${binName} configure --project-url <URL> --oauth2-client-id <CLIENT_ID> [--api-key <KEY>]`,
375
434
  "",
376
435
  " Or, enable audit logging only (no auth or permission checks):",
377
436
  ` npx ${binName} configure --audit-only`,
package/dist/config.d.ts CHANGED
@@ -75,6 +75,16 @@ export type PermissionMode = "observe" | "enforce";
75
75
  export interface OryPluginConfig {
76
76
  projectUrl?: string;
77
77
  apiKey?: string;
78
+ /**
79
+ * Public OAuth2 client id used by the user PKCE browser flow when
80
+ * `ORY_USER_LOGIN` is on. The client must be registered ahead of time
81
+ * in the Ory project with all four loopback redirect URIs
82
+ * (`http://127.0.0.1:47823..47826/callback`) and
83
+ * `token_endpoint_auth_method=none`. The local stack provisions one
84
+ * automatically; against a hosted project the operator registers it
85
+ * once and supplies the id here (or via `ORY_OAUTH2_CLIENT_ID`).
86
+ */
87
+ oauth2ClientId?: string;
78
88
  /** When true, only audit logging is enabled — no auth or permission checks. */
79
89
  auditOnly?: boolean;
80
90
  /**
@@ -144,11 +154,13 @@ export declare function mutateConfig(mutator: (current: OryPluginConfig) => OryP
144
154
  export declare function resolveConfig(): {
145
155
  projectUrl?: string;
146
156
  apiKey?: string;
157
+ oauth2ClientId?: string;
147
158
  auditOnly: boolean;
148
159
  permissionMode: PermissionMode;
149
160
  permissionModeSource: "env" | "config" | "default";
150
161
  projectUrlSource: "env" | "config" | "none";
151
162
  apiKeySource: "env" | "config" | "none";
163
+ oauth2ClientIdSource: "env" | "config" | "none";
152
164
  };
153
165
  /**
154
166
  * Build the "not configured" prompt message for a given harness CLI bin name.
package/dist/config.js CHANGED
@@ -115,6 +115,7 @@ function loadConfig() {
115
115
  return {
116
116
  projectUrl: typeof parsed.projectUrl === "string" ? parsed.projectUrl : undefined,
117
117
  apiKey: typeof parsed.apiKey === "string" ? parsed.apiKey : undefined,
118
+ oauth2ClientId: typeof parsed.oauth2ClientId === "string" ? parsed.oauth2ClientId : undefined,
118
119
  auditOnly: parsed.auditOnly === true ? true : undefined,
119
120
  permissionMode: parsePermissionMode(parsed.permissionMode),
120
121
  user: parseUserCredentials(parsed),
@@ -328,6 +329,7 @@ function resolveConfig() {
328
329
  // alias kept for back-compat (agent-auth emits a warning when only the
329
330
  // legacy form is set).
330
331
  const envApiKey = process.env.ORY_AGENT_API_KEY ?? process.env.ORY_API_KEY;
332
+ const envClientId = process.env.ORY_OAUTH2_CLIENT_ID;
331
333
  const envMode = parsePermissionMode(process.env.ORY_PERMISSION_MODE);
332
334
  const permissionMode = envMode ?? file.permissionMode ?? "observe";
333
335
  const permissionModeSource = envMode
@@ -338,11 +340,13 @@ function resolveConfig() {
338
340
  return {
339
341
  projectUrl: envProjectUrl ?? file.projectUrl,
340
342
  apiKey: envApiKey ?? file.apiKey,
343
+ oauth2ClientId: envClientId ?? file.oauth2ClientId,
341
344
  auditOnly: file.auditOnly === true,
342
345
  permissionMode,
343
346
  permissionModeSource,
344
347
  projectUrlSource: envProjectUrl ? "env" : file.projectUrl ? "config" : "none",
345
348
  apiKeySource: envApiKey ? "env" : file.apiKey ? "config" : "none",
349
+ oauth2ClientIdSource: envClientId ? "env" : file.oauth2ClientId ? "config" : "none",
346
350
  };
347
351
  }
348
352
  /**
@@ -352,7 +356,7 @@ function configPromptMessage(binName) {
352
356
  return ("The Ory agent plugin is installed but not yet configured.\n" +
353
357
  "\n" +
354
358
  " Option 1 — Connect to Ory (enables authentication and permission checks):\n" +
355
- ` npx ${binName} configure --project-url <URL> --api-key <KEY>\n` +
359
+ ` npx ${binName} configure --project-url <URL> --oauth2-client-id <CLIENT_ID> [--api-key <KEY>]\n` +
356
360
  "\n" +
357
361
  " Option 2 — Continue without authentication (audit logging only):\n" +
358
362
  ` npx ${binName} configure --audit-only\n` +
package/dist/dev.js CHANGED
@@ -396,7 +396,7 @@ function buildLocalOryEnv(gatewayUrl, seed) {
396
396
  ORY_PERMISSION_NAMESPACE: seed.permissions.namespace,
397
397
  // User login — always on in local dev so the launcher demonstrates
398
398
  // the interactive PKCE login UX end-to-end every session.
399
- ORY_USER_LOGIN: "1",
399
+ ORY_USER_LOGIN: "true",
400
400
  // Agent identity — the harness self-registers via DCR on first run
401
401
  // using the user's bearer as the initial access token. No static
402
402
  // client_credentials are seeded; explicitly clear them so a leaking
@@ -622,8 +622,17 @@ function localEnv() {
622
622
  }
623
623
  function localConfigure() {
624
624
  console.log(`Saving local Ory gateway URL to shared config...`);
625
- (0, config_js_1.saveConfig)({ projectUrl: configs_js_1.GATEWAY_URL, auditOnly: false });
626
- console.log(` Project URL: ${configs_js_1.GATEWAY_URL}`);
625
+ // Persist the seeded user PKCE client id alongside the project URL so
626
+ // a subsequent `configure --project-url <hosted>` doesn't trip the
627
+ // require-OAuth2-client check, and the user gate resolves the right
628
+ // client out of the box.
629
+ (0, config_js_1.saveConfig)({
630
+ projectUrl: configs_js_1.GATEWAY_URL,
631
+ oauth2ClientId: seed_js_1.USER_CLIENT_ID,
632
+ auditOnly: false,
633
+ });
634
+ console.log(` Project URL: ${configs_js_1.GATEWAY_URL}`);
635
+ console.log(` OAuth2 Client ID: ${seed_js_1.USER_CLIENT_ID}`);
627
636
  console.log("");
628
637
  console.log("All Ory agent plugins will now connect to the local environment.");
629
638
  console.log("This persists across sessions. Run 'configure --project-url <URL>'");
@@ -647,7 +656,7 @@ function printSeedResult(result) {
647
656
  console.log("To use with any Ory agent plugin, set these environment variables:");
648
657
  console.log("");
649
658
  console.log(` export ORY_PROJECT_URL=${configs_js_1.GATEWAY_URL}`);
650
- console.log(` export ORY_USER_LOGIN=1`);
659
+ console.log(` export ORY_USER_LOGIN=true`);
651
660
  console.log(` export ORY_OAUTH2_CLIENT_ID=${result.user.client.clientId}`);
652
661
  console.log(` export ORY_USER_SUBJECT_NAMESPACE=User`);
653
662
  console.log(` export ORY_USER_SUBJECT_ID=${result.user.identity.id}`);
@@ -23,6 +23,13 @@
23
23
  * Idempotent — re-running the seed reuses existing identities and
24
24
  * recreates OAuth2 clients (so the secret is always known).
25
25
  */
26
+ /**
27
+ * Stable client id Hydra issues to the seeded user PKCE client. Stable
28
+ * so `local configure` can persist it to the shared config and downstream
29
+ * runs can rely on `ORY_OAUTH2_CLIENT_ID` resolution without first
30
+ * dragging the value out of the `local up` banner.
31
+ */
32
+ export declare const USER_CLIENT_ID = "ory-user-local";
26
33
  export interface SeededIdentity {
27
34
  id: string;
28
35
  email: string;
@@ -25,7 +25,7 @@
25
25
  * recreates OAuth2 clients (so the secret is always known).
26
26
  */
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.USER_SUBJECT_NAMESPACE = void 0;
28
+ exports.USER_SUBJECT_NAMESPACE = exports.USER_CLIENT_ID = void 0;
29
29
  exports.seedLocalEnvironment = seedLocalEnvironment;
30
30
  const auth_js_1 = require("../auth.js");
31
31
  const tool_catalog_js_1 = require("../tool-catalog.js");
@@ -38,7 +38,13 @@ const AGENT_PASSWORD = "ory-agent-local-dev-password!";
38
38
  const USER_EMAIL = "user@ory-local.dev";
39
39
  const USER_PASSWORD = "ory-user-local-dev-password!";
40
40
  const USER_CLIENT_NAME = "ory-agent-plugins-local-user";
41
- const USER_CLIENT_ID = "ory-user-local";
41
+ /**
42
+ * Stable client id Hydra issues to the seeded user PKCE client. Stable
43
+ * so `local configure` can persist it to the shared config and downstream
44
+ * runs can rely on `ORY_OAUTH2_CLIENT_ID` resolution without first
45
+ * dragging the value out of the `local up` banner.
46
+ */
47
+ exports.USER_CLIENT_ID = "ory-user-local";
42
48
  /**
43
49
  * Tools the dev launcher seeds tuples for. Sourced from the shared
44
50
  * per-harness catalog so a single seed grants the local user identity
@@ -193,11 +199,11 @@ async function seedLocalEnvironment(namespace = "AgentTools") {
193
199
  // OAuth2 client is intentionally NOT pre-registered; the harness
194
200
  // will self-register via DCR on first session start.
195
201
  process.stderr.write(" Registering user OAuth2 client (PKCE)...\n");
196
- let userClient = { clientId: USER_CLIENT_ID };
202
+ let userClient = { clientId: exports.USER_CLIENT_ID };
197
203
  try {
198
204
  userClient = await ensureOAuth2Client({
199
205
  clientName: USER_CLIENT_NAME,
200
- clientId: USER_CLIENT_ID,
206
+ clientId: exports.USER_CLIENT_ID,
201
207
  // Public PKCE client — no secret. Hydra accepts an empty string
202
208
  // for `token_endpoint_auth_method=none`.
203
209
  grantTypes: ["authorization_code", "refresh_token"],
@@ -129,12 +129,12 @@ async function runPermissionsStatus(binName, harness) {
129
129
  console.log("");
130
130
  if (resolved.auditOnly) {
131
131
  console.log("Ory is disabled (audit-only). No permission checks run.");
132
- console.log(`Re-enable with: ${binName} configure --project-url <URL> --api-key <KEY>`);
132
+ console.log(`Re-enable with: ${binName} configure --project-url <URL> --oauth2-client-id <CLIENT_ID> [--api-key <KEY>]`);
133
133
  return 0;
134
134
  }
135
135
  if (!resolved.projectUrl) {
136
136
  console.log("No project URL configured — cannot probe permission coverage.");
137
- console.log(`Configure first: ${binName} configure --project-url <URL> --api-key <KEY>`);
137
+ console.log(`Configure first: ${binName} configure --project-url <URL> --oauth2-client-id <CLIENT_ID> [--api-key <KEY>]`);
138
138
  return 0;
139
139
  }
140
140
  if (catalog.length === 0) {
@@ -211,12 +211,12 @@ async function runPermissionsBootstrap(binName, harness, args) {
211
211
  const catalog = (0, tool_catalog_js_1.getToolCatalog)(harness);
212
212
  if (resolved.auditOnly) {
213
213
  console.error("Ory is in audit-only mode (kill-switch). Nothing to bootstrap.");
214
- console.error(`Re-enable Ory: ${binName} configure --project-url <URL> --api-key <KEY>`);
214
+ console.error(`Re-enable Ory: ${binName} configure --project-url <URL> --oauth2-client-id <CLIENT_ID> [--api-key <KEY>]`);
215
215
  return 1;
216
216
  }
217
217
  if (!resolved.projectUrl) {
218
218
  console.error("No ORY_PROJECT_URL configured — cannot write permissions.");
219
- console.error(`Configure first: ${binName} configure --project-url <URL> --api-key <KEY>`);
219
+ console.error(`Configure first: ${binName} configure --project-url <URL> --oauth2-client-id <CLIENT_ID> [--api-key <KEY>]`);
220
220
  return 1;
221
221
  }
222
222
  if (catalog.length === 0) {
@@ -235,7 +235,7 @@ async function runPermissionsBootstrap(binName, harness, args) {
235
235
  console.error("No user identity resolved — refusing to write permissions for an unknown subject.");
236
236
  console.error("");
237
237
  console.error("Either:");
238
- console.error(" - run the harness once with ORY_USER_LOGIN=1 so a user token is cached, or");
238
+ console.error(" - run the harness once with ORY_USER_LOGIN=true so a user token is cached, or");
239
239
  console.error(" - set ORY_USER_SUBJECT_ID=<id> to target a known subject.");
240
240
  return 1;
241
241
  }
package/dist/setup.js CHANGED
@@ -374,7 +374,9 @@ Environment variables:
374
374
  ORY_PROJECT_URL Your Ory project URL (required at runtime)
375
375
  ORY_AGENT_API_KEY Agent API key / OAuth2 bearer (preferred name;
376
376
  ORY_API_KEY is honored as a deprecated alias)
377
- ORY_USER_LOGIN Set to "1" to enable the interactive user login
377
+ ORY_OAUTH2_CLIENT_ID Public OAuth2 client id for the user PKCE flow
378
+ (required when ORY_USER_LOGIN=true)
379
+ ORY_USER_LOGIN Set to "true" to enable the interactive user login
378
380
  ORY_PERMISSION_MODE "observe" (default) or "enforce" — what to do on deny
379
381
  ORY_AGENT_DEBUG Set to "true" for debug logging
380
382
  ORY_AGENT_LOG_FILE Path to write debug logs
@@ -392,9 +394,12 @@ function printNextSteps(harnessName, uninstallCmd) {
392
394
  console.log(" export ORY_AGENT_API_KEY=ory_pat_...");
393
395
  console.log("");
394
396
  console.log(" 2. Turn on the interactive user login (opt-in):");
395
- console.log(" export ORY_USER_LOGIN=1");
396
- console.log(` Without this, ${harnessName} runs without a human Ory identity attached`);
397
+ console.log(" export ORY_USER_LOGIN=true");
398
+ console.log(" export ORY_OAUTH2_CLIENT_ID=<public OAuth2 client id>");
399
+ console.log(` Without these, ${harnessName} runs without a human Ory identity attached`);
397
400
  console.log(" to the session and permission checks fall back to a session:<id> subject.");
401
+ console.log(" The OAuth2 client id is the public client (no secret) you registered in");
402
+ console.log(" your Ory project with the four loopback redirect URIs.");
398
403
  console.log("");
399
404
  console.log(" 3. Optionally enable debug logging:");
400
405
  console.log(" export ORY_AGENT_DEBUG=true");
@@ -57,7 +57,7 @@ function printUserIdentitySection() {
57
57
  const tokens = (0, auth_store_js_1.loadTokens)();
58
58
  console.log("");
59
59
  console.log("User identity (interactive PKCE login):");
60
- console.log(` Login: ${loginOn ? "on (ORY_USER_LOGIN)" : "off (set ORY_USER_LOGIN=1 to enable)"}`);
60
+ console.log(` Login: ${loginOn ? "on (ORY_USER_LOGIN)" : "off (set ORY_USER_LOGIN=true to enable)"}`);
61
61
  if (!tokens) {
62
62
  console.log(" Token cache: empty");
63
63
  if (loginOn) {
@@ -209,7 +209,7 @@ async function printPermissionsSection(binName, harness) {
209
209
  }
210
210
  const hasUser = !!process.env.ORY_USER_SUBJECT_ID || isUserTokenUsable();
211
211
  if (!hasUser) {
212
- console.log(` Coverage: n/a (no cached user identity — run with ORY_USER_LOGIN=1 once,`);
212
+ console.log(` Coverage: n/a (no cached user identity — run with ORY_USER_LOGIN=true once,`);
213
213
  console.log(` or set ORY_USER_SUBJECT_ID to probe a known subject)`);
214
214
  return;
215
215
  }
@@ -18,7 +18,8 @@
18
18
  * the audit trail is complete regardless of outcome.
19
19
  *
20
20
  * The whole flow is a no-op (mode `disabled`) unless the
21
- * `ORY_USER_LOGIN` env var is set to `1`/`true`.
21
+ * `ORY_USER_LOGIN` env var is set to `true` (legacy values `1`, `yes`,
22
+ * `on` are still accepted for back-compat).
22
23
  *
23
24
  * This authenticates the *user* (the human at the keyboard). The
24
25
  * separate agent identity (the AI process making the calls) is resolved
@@ -19,7 +19,8 @@
19
19
  * the audit trail is complete regardless of outcome.
20
20
  *
21
21
  * The whole flow is a no-op (mode `disabled`) unless the
22
- * `ORY_USER_LOGIN` env var is set to `1`/`true`.
22
+ * `ORY_USER_LOGIN` env var is set to `true` (legacy values `1`, `yes`,
23
+ * `on` are still accepted for back-compat).
23
24
  *
24
25
  * This authenticates the *user* (the human at the keyboard). The
25
26
  * separate agent identity (the AI process making the calls) is resolved
@@ -39,7 +40,10 @@ function isUserLoginEnabled() {
39
40
  return !!v && ENABLED_VALUES.has(v);
40
41
  }
41
42
  function clientId() {
42
- return process.env.ORY_OAUTH2_CLIENT_ID;
43
+ // resolveConfig already merges env (ORY_OAUTH2_CLIENT_ID) with the
44
+ // persisted value, env winning. Centralizing here keeps the user gate,
45
+ // status CLI, and configure command in lockstep on resolution order.
46
+ return (0, config_js_1.resolveConfig)().oauth2ClientId;
43
47
  }
44
48
  function recordAuthSpan(client, decision) {
45
49
  const status = decision.mode === "ok" || decision.mode === "refreshed" || decision.mode === "env_token"
@@ -211,7 +215,9 @@ async function runUserLogin(client, options) {
211
215
  mode: "skipped",
212
216
  reason: "ORY_OAUTH2_CLIENT_ID is not set; cannot start browser login (run `npx " +
213
217
  options.binName +
214
- " configure` and register an OAuth2 client with the loopback redirect URIs)",
218
+ " configure --oauth2-client-id <id>` after registering a public OAuth2 client " +
219
+ "in your Ory project with all four loopback redirect URIs: " +
220
+ "http://127.0.0.1:47823..47826/callback)",
215
221
  };
216
222
  }
217
223
  // No TTY check here on purpose: PKCE only needs a browser that can reach
@@ -221,7 +227,7 @@ async function runUserLogin(client, options) {
221
227
  // complete sign-in by pasting the URL into any browser that can reach
222
228
  // 127.0.0.1. Truly unattended runs (CI=true) are short-circuited by
223
229
  // `pkceLogin` itself via `detectHeadless`, and operators can bypass
224
- // login entirely with `ORY_USER_SESSION_TOKEN` or `ORY_USER_LOGIN=0`.
230
+ // login entirely with `ORY_USER_SESSION_TOKEN` or `ORY_USER_LOGIN=false`.
225
231
  // PKCE-flight lock so concurrent processes share a single browser flow.
226
232
  const lock = (0, auth_store_js_1.tryAcquirePkceFlightLock)();
227
233
  if (!lock) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ory/argus",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "Ory Argus: the core API for building authentication, authorization, and audit into AI agent harness plugins, extensions, and custom integrations",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://ory.com",