@ory/argus 0.13.4 → 0.13.5
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/dist/build-info.json +4 -4
- package/dist/client.js +36 -0
- package/dist/permissions-cli.js +0 -17
- package/package.json +1 -1
package/dist/build-info.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"repo": "ory-agent-plugins",
|
|
3
|
-
"commit": "
|
|
4
|
-
"commitShort": "
|
|
3
|
+
"commit": "6a1250a1a231524d64aed17df86d694f829cf938",
|
|
4
|
+
"commitShort": "6a1250a",
|
|
5
5
|
"branch": "main",
|
|
6
|
-
"commitDate": "2026-07-
|
|
6
|
+
"commitDate": "2026-07-15T07:09:03-07:00",
|
|
7
7
|
"dirty": false,
|
|
8
|
-
"builtAt": "2026-07-
|
|
8
|
+
"builtAt": "2026-07-15T14:13:28.336Z"
|
|
9
9
|
}
|
package/dist/client.js
CHANGED
|
@@ -42,6 +42,7 @@ const path = __importStar(require("node:path"));
|
|
|
42
42
|
const logger_js_1 = require("./logger.js");
|
|
43
43
|
const tracer_js_1 = require("./tracer.js");
|
|
44
44
|
const config_js_1 = require("./config.js");
|
|
45
|
+
const auth_store_js_1 = require("./auth-store.js");
|
|
45
46
|
const otlp_js_1 = require("./otel/otlp.js");
|
|
46
47
|
class OryAgentClient {
|
|
47
48
|
frontend;
|
|
@@ -752,6 +753,7 @@ class OryAgentClient {
|
|
|
752
753
|
"Ory integration is disabled — all hooks will pass through. " +
|
|
753
754
|
"Set ORY_PROJECT_URL or run the plugin's configure command.",
|
|
754
755
|
});
|
|
756
|
+
rehydrateUserPrincipal(client);
|
|
755
757
|
attachOtlpExporterFromEnv(client, harness);
|
|
756
758
|
return client;
|
|
757
759
|
}
|
|
@@ -770,11 +772,45 @@ class OryAgentClient {
|
|
|
770
772
|
projectUrlSource: resolved.projectUrlSource,
|
|
771
773
|
apiKeySource: resolved.apiKeySource,
|
|
772
774
|
});
|
|
775
|
+
rehydrateUserPrincipal(client);
|
|
773
776
|
attachOtlpExporterFromEnv(client, harness);
|
|
774
777
|
return client;
|
|
775
778
|
}
|
|
776
779
|
}
|
|
777
780
|
exports.OryAgentClient = OryAgentClient;
|
|
781
|
+
/**
|
|
782
|
+
* Rehydrate the user principal from persisted OAuth2 tokens.
|
|
783
|
+
*
|
|
784
|
+
* The interactive user login ({@link ensureUserAuthenticated}) populates
|
|
785
|
+
* `client.userPrincipal` in memory *and* caches the tokens to the shared
|
|
786
|
+
* config file. But subprocess-hook harnesses (claude-code, codex,
|
|
787
|
+
* gemini-cli) spawn a fresh process — and thus a fresh client via
|
|
788
|
+
* {@link OryAgentClient.fromEnv} — for every lifecycle event. Only the
|
|
789
|
+
* `SessionStart` process runs the login gate, so on later events (e.g.
|
|
790
|
+
* `PreToolUse`) the in-memory principal is gone and permission checks
|
|
791
|
+
* would fall back to a per-launch `session:<id>` subject that matches no
|
|
792
|
+
* bootstrapped tuple.
|
|
793
|
+
*
|
|
794
|
+
* Seeding the principal from the cached tokens here makes the *stable*
|
|
795
|
+
* user subject available on every constructed client, independent of which
|
|
796
|
+
* lifecycle event is running. The live login gate still overwrites this
|
|
797
|
+
* with fresh values when it runs at `SessionStart`.
|
|
798
|
+
*
|
|
799
|
+
* The subject is attached whenever it is known — even for an expired token,
|
|
800
|
+
* since the subject is what permission checks resolve against and Keto
|
|
801
|
+
* checks authenticate with the admin API key, not this token. The access
|
|
802
|
+
* token itself is only carried forward while still valid, so nothing
|
|
803
|
+
* authenticates with a stale bearer.
|
|
804
|
+
*/
|
|
805
|
+
function rehydrateUserPrincipal(client) {
|
|
806
|
+
const tokens = (0, auth_store_js_1.loadTokens)();
|
|
807
|
+
if (!tokens?.subject)
|
|
808
|
+
return;
|
|
809
|
+
client.setUserPrincipal({
|
|
810
|
+
subject: tokens.subject,
|
|
811
|
+
token: (0, auth_store_js_1.isExpired)(tokens) ? undefined : tokens.accessToken,
|
|
812
|
+
});
|
|
813
|
+
}
|
|
778
814
|
/** Default debug-log path under the shared per-harness data dir. */
|
|
779
815
|
exports.DEFAULT_DEBUG_LOG_FILENAME = "ory-agent-debug.log";
|
|
780
816
|
/** Default trace (NDJSON) path under the shared per-harness data dir. */
|
package/dist/permissions-cli.js
CHANGED
|
@@ -71,21 +71,6 @@ const ENV_PERMISSION_MODE = "ORY_PERMISSION_MODE";
|
|
|
71
71
|
function resolveNamespace() {
|
|
72
72
|
return process.env.ORY_PERMISSION_NAMESPACE ?? "AgentTools";
|
|
73
73
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Apply persisted user OAuth2 tokens (if any) to the client's user
|
|
76
|
-
* principal so downstream subject resolution and tuple writes see a
|
|
77
|
-
* concrete identity. Mirrors what `ensureUserAuthenticated` does on a
|
|
78
|
-
* cache hit — but works whether or not `ORY_USER_LOGIN` is enabled.
|
|
79
|
-
*/
|
|
80
|
-
function attachCachedUserPrincipal(client) {
|
|
81
|
-
const tokens = (0, auth_store_js_1.loadTokens)();
|
|
82
|
-
if (!tokens || (0, auth_store_js_1.isExpired)(tokens))
|
|
83
|
-
return;
|
|
84
|
-
client.setUserPrincipal({
|
|
85
|
-
subject: tokens.subject,
|
|
86
|
-
token: tokens.accessToken,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
74
|
/**
|
|
90
75
|
* Entry point invoked by each harness CLI's `permissions` case.
|
|
91
76
|
*
|
|
@@ -178,7 +163,6 @@ async function runPermissionsStatus(binName, harness) {
|
|
|
178
163
|
return 0;
|
|
179
164
|
}
|
|
180
165
|
const client = client_js_1.OryAgentClient.fromEnv(harness);
|
|
181
|
-
attachCachedUserPrincipal(client);
|
|
182
166
|
await (0, agent_auth_js_1.ensureAgentIdentity)(client, { projectUrl: resolved.projectUrl }).catch(() => {
|
|
183
167
|
/* best-effort; status keeps working in pass-through */
|
|
184
168
|
});
|
|
@@ -260,7 +244,6 @@ async function runPermissionsBootstrap(binName, harness, args) {
|
|
|
260
244
|
return 1;
|
|
261
245
|
}
|
|
262
246
|
const client = client_js_1.OryAgentClient.fromEnv(harness);
|
|
263
|
-
attachCachedUserPrincipal(client);
|
|
264
247
|
await (0, agent_auth_js_1.ensureAgentIdentity)(client, { projectUrl: resolved.projectUrl }).catch(() => {
|
|
265
248
|
/* best-effort; the write may still succeed with the API key or no auth (local Keto) */
|
|
266
249
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ory/argus",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.5",
|
|
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",
|