@ory/argus 0.13.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -45
- package/assets/commands/temporal-up.md +1 -1
- package/assets/skills/auth-setup/SKILL.md +1 -1
- package/assets/skills/local-dev/SKILL.md +17 -7
- package/assets/skills/ory-build-agent/SKILL.md +43 -97
- package/assets/skills/ory-e2b-sandbox/SKILL.md +18 -18
- package/assets/skills/ory-temporal-worker/SKILL.md +38 -42
- package/assets/skills/permissions-onboarding/SKILL.md +131 -104
- package/dist/adapters.d.ts +93 -30
- package/dist/adapters.js +464 -136
- package/dist/agent-auth.d.ts +258 -68
- package/dist/agent-auth.js +998 -202
- package/dist/auth-store.d.ts +37 -2
- package/dist/auth-store.js +37 -3
- package/dist/auth.d.ts +40 -4
- package/dist/auth.js +247 -19
- package/dist/bash-parser.d.ts +98 -0
- package/dist/bash-parser.js +396 -0
- package/dist/branding.d.ts +128 -0
- package/dist/branding.js +151 -0
- package/dist/build-info.json +4 -4
- package/dist/cli-invocation.d.ts +1 -1
- package/dist/cli-invocation.js +2 -1
- package/dist/cli.d.ts +20 -29
- package/dist/cli.js +271 -278
- package/dist/client.d.ts +175 -138
- package/dist/client.js +672 -391
- package/dist/config.d.ts +249 -57
- package/dist/config.js +486 -62
- package/dist/context.d.ts +10 -0
- package/dist/context.js +21 -0
- package/dist/contract-suite.d.ts +8 -8
- package/dist/contract-suite.js +88 -69
- package/dist/denial.d.ts +36 -3
- package/dist/denial.js +79 -10
- package/dist/event-reporter.d.ts +77 -0
- package/dist/event-reporter.js +776 -0
- package/dist/external-registrations-main.d.ts +10 -0
- package/dist/external-registrations-main.js +38 -0
- package/dist/external-registrations.d.ts +79 -0
- package/dist/external-registrations.js +188 -0
- package/dist/help-cli.d.ts +39 -0
- package/dist/help-cli.js +55 -0
- package/dist/hook-timeout.d.ts +64 -0
- package/dist/hook-timeout.js +88 -0
- package/dist/index.d.ts +31 -19
- package/dist/index.js +182 -31
- package/dist/lifecycle.d.ts +3 -3
- package/dist/lifecycle.js +38 -6
- package/dist/local/cli.js +11 -6
- package/dist/local/configs.d.ts +74 -18
- package/dist/local/configs.js +291 -84
- package/dist/local/health.d.ts +14 -0
- package/dist/local/health.js +50 -4
- package/dist/local/index.d.ts +2 -2
- package/dist/local/index.js +24 -10
- package/dist/local/manager.d.ts +20 -1
- package/dist/local/manager.js +160 -39
- package/dist/local/ports.d.ts +158 -0
- package/dist/local/ports.js +443 -0
- package/dist/local/seed.d.ts +22 -25
- package/dist/local/seed.js +88 -56
- package/dist/logger.d.ts +54 -25
- package/dist/logger.js +329 -63
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +10 -5
- package/dist/mirror-bootstrap.d.ts +48 -0
- package/dist/mirror-bootstrap.js +254 -0
- package/dist/opl.d.ts +289 -0
- package/dist/opl.js +446 -0
- package/dist/permission-mode.d.ts +87 -0
- package/dist/permission-mode.js +307 -0
- package/dist/permissions-cli.d.ts +13 -49
- package/dist/permissions-cli.js +154 -348
- package/dist/permissions.d.ts +148 -38
- package/dist/permissions.js +591 -45
- package/dist/post-install.d.ts +33 -0
- package/dist/post-install.js +127 -0
- package/dist/read-credential.d.ts +65 -0
- package/dist/read-credential.js +86 -0
- package/dist/registry/cli.js +5 -2
- package/dist/registry/config.d.ts +0 -17
- package/dist/registry/config.js +0 -23
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/index.js +2 -2
- package/dist/registry/manager.d.ts +4 -21
- package/dist/registry/manager.js +83 -55
- package/dist/runtime-credential.d.ts +140 -0
- package/dist/runtime-credential.js +572 -0
- package/dist/runtime.d.ts +408 -0
- package/dist/runtime.js +748 -0
- package/dist/setup.d.ts +23 -28
- package/dist/setup.js +57 -84
- package/dist/status-cli.d.ts +29 -13
- package/dist/status-cli.js +124 -144
- package/dist/status-data.d.ts +195 -0
- package/dist/status-data.js +333 -0
- package/dist/status-system.d.ts +24 -0
- package/dist/status-system.js +56 -0
- package/dist/subject.d.ts +126 -20
- package/dist/subject.js +215 -30
- package/dist/testing.d.ts +74 -38
- package/dist/testing.js +185 -68
- package/dist/tool-catalog.d.ts +53 -11
- package/dist/tool-catalog.js +164 -13
- package/dist/tool-metadata.d.ts +7 -6
- package/dist/tool-metadata.js +6 -5
- package/dist/types.d.ts +11 -1
- package/dist/uninstall.d.ts +74 -19
- package/dist/uninstall.js +224 -49
- package/dist/user-login.d.ts +22 -16
- package/dist/user-login.js +67 -96
- package/dist/watch-cli.d.ts +6 -0
- package/dist/watch-cli.js +217 -0
- package/package.json +3 -11
- package/dist/dev.d.ts +0 -103
- package/dist/dev.js +0 -584
- package/dist/interactive-setup.d.ts +0 -165
- package/dist/interactive-setup.js +0 -1546
- package/dist/local/jaeger-main.d.ts +0 -13
- package/dist/local/jaeger-main.js +0 -85
- package/dist/local/jaeger.d.ts +0 -50
- package/dist/local/jaeger.js +0 -162
- package/dist/otel/exporter.d.ts +0 -17
- package/dist/otel/exporter.js +0 -12
- package/dist/otel/index.d.ts +0 -2
- package/dist/otel/index.js +0 -8
- package/dist/otel/otlp.d.ts +0 -103
- package/dist/otel/otlp.js +0 -385
- package/dist/tracer.d.ts +0 -190
- package/dist/tracer.js +0 -481
- package/dist/watch-sandbox.d.ts +0 -9
- package/dist/watch-sandbox.js +0 -81
package/dist/client.d.ts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { DebugLogger } from "./logger.js";
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
2
|
+
import { type EventReporterOptions } from "./event-reporter.js";
|
|
3
|
+
import type { SessionContext } from "./context.js";
|
|
4
|
+
import { type RuntimeCredential, type RuntimeRequestAuthenticator } from "./runtime-credential.js";
|
|
4
5
|
import type { SessionInfo, OAuth2TokenInfo, PermissionCheck, PermissionResult, BatchPermissionResult, OryError } from "./types.js";
|
|
5
6
|
export interface OryAgentConfig {
|
|
6
7
|
/** Ory project URL, e.g. https://your-project.projects.oryapis.com */
|
|
7
8
|
projectUrl: string;
|
|
8
|
-
/**
|
|
9
|
-
|
|
9
|
+
/** Agent Security broker URL. Defaults to projectUrl for shipped configs. */
|
|
10
|
+
agentSecurityUrl?: string;
|
|
10
11
|
/** Which harness this client is running in */
|
|
11
12
|
harness: string;
|
|
12
|
-
/** Optional
|
|
13
|
+
/** Optional unified activity/debug NDJSON file path. */
|
|
13
14
|
logFile?: string;
|
|
14
|
-
/** Optional NDJSON trace file path for structured span output */
|
|
15
|
-
traceFile?: string;
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* {@link resolveUserSubject}; `ORY_USER_SUBJECT_NAMESPACE` overrides it.
|
|
16
|
+
* Overrides the namespace the human user is addressed under. Users are always
|
|
17
|
+
* addressed as a SubjectSet `<namespace>:<subject>` (matching how the tuples
|
|
18
|
+
* were written in Keto); this only overrides the namespace (default `User`).
|
|
19
|
+
* Read by {@link resolveUserSubject}; `ORY_USER_SUBJECT_NAMESPACE` overrides it.
|
|
21
20
|
*/
|
|
22
21
|
userSubjectNamespace?: string;
|
|
23
22
|
/**
|
|
@@ -25,15 +24,81 @@ export interface OryAgentConfig {
|
|
|
25
24
|
* Set to 0 to disable caching. Default: 60_000 (1 minute).
|
|
26
25
|
*/
|
|
27
26
|
sessionCacheTtlMs?: number;
|
|
28
|
-
/**
|
|
29
|
-
|
|
27
|
+
/** Noninteractive request authentication, e.g. a SPIFFE mTLS transport. */
|
|
28
|
+
runtimeRequestAuthenticator?: RuntimeRequestAuthenticator;
|
|
29
|
+
/** Optional stable runtime subject supplied by the custom integration. */
|
|
30
|
+
runtimeSubject?: string;
|
|
31
|
+
/** Disabled by default so direct/test clients never perform background network calls. */
|
|
32
|
+
eventReporter?: true | Omit<EventReporterOptions, "projectUrl" | "agentSecurityUrl" | "token" | "onUnauthorized" | "logger">;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Inputs for {@link OryAgentClient.recordDelegation}. The plugin supplies only
|
|
36
|
+
* the *semantic* ends of the edge; the agent-security broker owns the Keto
|
|
37
|
+
* tuple shape (namespace, `delegate` relation, and the
|
|
38
|
+
* `<identity>|<harness>|<host>` join-key encoding), so no tuple/join-key logic
|
|
39
|
+
* lives in the plugin.
|
|
40
|
+
*/
|
|
41
|
+
export interface RecordDelegationInput {
|
|
42
|
+
/**
|
|
43
|
+
* Which edge to record. `agent` records `user → agent`; `subagent` records
|
|
44
|
+
* `agent → subagent`. Maps to the broker's `PRINCIPAL_KIND_AGENT` /
|
|
45
|
+
* `PRINCIPAL_KIND_SUBAGENT`.
|
|
46
|
+
*/
|
|
47
|
+
kind: "agent" | "subagent";
|
|
48
|
+
/**
|
|
49
|
+
* Kratos identity the delegation is anchored to (→ `User:<identityId>`).
|
|
50
|
+
* Required for the `agent` edge; optional for `subagent` (the broker resolves
|
|
51
|
+
* the anchor from `delegatedBy`).
|
|
52
|
+
*/
|
|
53
|
+
identityId?: string;
|
|
54
|
+
/** Host the runtime executes on — part of the `agent` edge join key. */
|
|
55
|
+
host?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Sub-agent runtime type name (e.g. `"explore"`); required for the `subagent`
|
|
58
|
+
* edge. Sent as `principal.type_name`.
|
|
59
|
+
*/
|
|
60
|
+
subAgentType?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The parent agent's delegation node (`agent:<join>` or the bare join key),
|
|
63
|
+
* as returned in {@link RecordDelegationResult.nodeId} from the `agent` edge.
|
|
64
|
+
* Required for the `subagent` edge; echoed verbatim so the plugin never
|
|
65
|
+
* reconstructs the server's join-key encoding.
|
|
66
|
+
*/
|
|
67
|
+
delegatedBy?: string;
|
|
68
|
+
/**
|
|
69
|
+
* The harness session this edge was recorded in — sent as
|
|
70
|
+
* `principal.session_id`, which is the field the broker's proto defines. The
|
|
71
|
+
* dynamic OAuth2 credential is keyed by this session, and the broker also
|
|
72
|
+
* needs the session to build the corresponding delegation node.
|
|
73
|
+
*
|
|
74
|
+
* Defaults to the client's ambient session ({@link OryAgentClient.sessionId},
|
|
75
|
+
* set by the harness's ambient session context); pass explicitly to override. Absent
|
|
76
|
+
* for a caller with no session concept, which the broker reads as "keep this
|
|
77
|
+
* runtime on one stable node" rather than inventing a session for it.
|
|
78
|
+
*/
|
|
79
|
+
sessionId?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Identifier for one *spawn* of a sub-agent, where the harness exposes one
|
|
82
|
+
* (Cursor's `subagent_id`, Claude Code's `agent_id`, OpenClaw's `childRunId`).
|
|
83
|
+
* Sent as `principal.per_spawn_id`; it is what distinguishes two concurrent
|
|
84
|
+
* same-type sub-agents. Absent on harnesses that expose no such id, in which
|
|
85
|
+
* case concurrent spawns of a type share a node.
|
|
86
|
+
*/
|
|
87
|
+
perSpawnId?: string;
|
|
88
|
+
}
|
|
89
|
+
/** The delegation node the broker wrote, plus the resolved chain (root-first). */
|
|
90
|
+
export interface RecordDelegationResult {
|
|
91
|
+
/** The node id written: `agent:<join>` or `subagent:<join>|<type>`. */
|
|
92
|
+
nodeId: string;
|
|
93
|
+
/** Root-first chain, e.g. `["User:<id>", "agent:<join>"]`. */
|
|
94
|
+
delegationChain: string[];
|
|
30
95
|
}
|
|
31
96
|
/**
|
|
32
97
|
* A principal known to the client. Either the human user (interactive
|
|
33
98
|
* PKCE login) or the agent (machine credentials).
|
|
34
99
|
*/
|
|
35
100
|
export interface PrincipalIdentity {
|
|
36
|
-
/** Subject (sub claim or `session:<id>`)
|
|
101
|
+
/** Subject (sub claim or `session:<id>`) used in audit activity. */
|
|
37
102
|
subject?: string;
|
|
38
103
|
/** Bearer token. Agent's token authenticates outgoing API calls. */
|
|
39
104
|
token?: string;
|
|
@@ -42,10 +107,12 @@ export declare class OryAgentClient {
|
|
|
42
107
|
private frontend;
|
|
43
108
|
private oauth2;
|
|
44
109
|
private permission;
|
|
45
|
-
private relationship;
|
|
46
110
|
private config;
|
|
47
111
|
readonly logger: DebugLogger;
|
|
48
|
-
readonly
|
|
112
|
+
private readonly eventReporter?;
|
|
113
|
+
private _runtimeCredential?;
|
|
114
|
+
private readonly _runtimeCredentialsBySession;
|
|
115
|
+
private readonly _runtimeCredentialsByPrincipalKey;
|
|
49
116
|
private sessionCache;
|
|
50
117
|
private sessionCacheTtlMs;
|
|
51
118
|
/**
|
|
@@ -53,35 +120,57 @@ export declare class OryAgentClient {
|
|
|
53
120
|
* Populated by `ensureUserAuthenticated` on session start.
|
|
54
121
|
*/
|
|
55
122
|
private _userPrincipal;
|
|
123
|
+
private readonly _userPrincipalsBySession;
|
|
56
124
|
/**
|
|
57
125
|
* The AI agent process — the principal that authenticates outgoing
|
|
58
126
|
* Ory API calls. Populated by `ensureAgentIdentity`.
|
|
59
127
|
*/
|
|
60
128
|
private _agentPrincipal;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* used to authenticate the Keto Permission and Relationship APIs.
|
|
64
|
-
*
|
|
65
|
-
* This is deliberately distinct from the agent principal's token. Ory
|
|
66
|
-
* Network's permission APIs authenticate with a project API key and
|
|
67
|
-
* **reject project-issued OAuth2 access tokens** (a DCR client-credentials
|
|
68
|
-
* token is answered with `401 "Access token is not active"`). So when the
|
|
69
|
-
* agent identity resolves to a DCR OAuth2 client — the default path — its
|
|
70
|
-
* token cannot authenticate permission checks. Holding the admin key here
|
|
71
|
-
* lets {@link buildApis} route Keto through it while the agent OAuth2 token
|
|
72
|
-
* still authenticates the OAuth2 / Frontend APIs and carries attribution.
|
|
73
|
-
*
|
|
74
|
-
* When unset, Keto calls fall back to the agent token (legacy
|
|
75
|
-
* single-credential behavior, unchanged for static-key deployments).
|
|
76
|
-
*/
|
|
77
|
-
private _adminApiKey?;
|
|
129
|
+
private readonly _agentPrincipalsBySession;
|
|
130
|
+
private readonly _eventPrincipalsByKey;
|
|
78
131
|
constructor(config: OryAgentConfig);
|
|
79
132
|
/** Build a fresh set of Ory API instances using the current agent token. */
|
|
80
133
|
private buildApis;
|
|
134
|
+
/** Canonical broker origin, with the shipped project URL fallback applied. */
|
|
135
|
+
get agentSecurityUrl(): string;
|
|
136
|
+
private buildBrokerPermissionTransport;
|
|
137
|
+
private postPermissionChecks;
|
|
138
|
+
private permissionPrincipal;
|
|
139
|
+
private subAgentTypeForClient;
|
|
81
140
|
/** Snapshot of the current user principal. */
|
|
82
141
|
get userPrincipal(): PrincipalIdentity;
|
|
142
|
+
/** Snapshot of the user principal bound to one session. */
|
|
143
|
+
userPrincipalForSession(sessionId?: string): PrincipalIdentity;
|
|
83
144
|
/** Snapshot of the current agent principal. */
|
|
84
145
|
get agentPrincipal(): PrincipalIdentity;
|
|
146
|
+
/** Active noninteractive broker credential. It is process memory only. */
|
|
147
|
+
get runtimeCredential(): RuntimeCredential | undefined;
|
|
148
|
+
get hasRuntimeCredential(): boolean;
|
|
149
|
+
setRuntimeCredential(credential: RuntimeCredential | undefined): void;
|
|
150
|
+
/** Retain an actor-scoped credential for deferred event delivery without activating it globally. */
|
|
151
|
+
rememberRuntimeCredential(credential: RuntimeCredential): void;
|
|
152
|
+
/** Run one hook with session/credential state isolated from concurrent hooks. */
|
|
153
|
+
withRuntimeContext<T>(context: SessionContext, work: () => T): T;
|
|
154
|
+
/** Snapshot of the agent principal bound to one session. */
|
|
155
|
+
agentPrincipalForSession(sessionId?: string): PrincipalIdentity;
|
|
156
|
+
private eventPrincipal;
|
|
157
|
+
/**
|
|
158
|
+
* The harness this client runs in (`"claude-code"`, `"codex"`, …). Exposed
|
|
159
|
+
* because persisted agent / sub-agent credentials and delegation anchors are
|
|
160
|
+
* keyed first by harness and then by session.
|
|
161
|
+
*/
|
|
162
|
+
get harness(): string;
|
|
163
|
+
/**
|
|
164
|
+
* The harness session currently in scope, or `undefined` outside one.
|
|
165
|
+
*
|
|
166
|
+
* Read from standalone ambient session context, which every harness sets from its
|
|
167
|
+
* own session identifier at the top of a lifecycle invocation — so identity
|
|
168
|
+
* and delegation code can select the session's credential and node without
|
|
169
|
+
* each plugin threading the id through its own call chain.
|
|
170
|
+
*/
|
|
171
|
+
get sessionId(): string | undefined;
|
|
172
|
+
/** Best-effort bounded flush for short-lived hook subprocesses and tests. */
|
|
173
|
+
flushEvents(timeoutMs?: number): Promise<void>;
|
|
85
174
|
/**
|
|
86
175
|
* Configured user-subject namespace (from config, resolved at construction).
|
|
87
176
|
* `resolveUserSubject` uses this as the SubjectSet namespace when the
|
|
@@ -91,31 +180,23 @@ export declare class OryAgentClient {
|
|
|
91
180
|
get userSubjectNamespace(): string | undefined;
|
|
92
181
|
/**
|
|
93
182
|
* Set or update the human user principal. The user is the subject of
|
|
94
|
-
* permission checks
|
|
95
|
-
*
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Set or update the admin API key (an Ory Network project API key) used to
|
|
102
|
-
* authenticate the Keto Permission / Relationship APIs. Rebuilds those API
|
|
103
|
-
* instances when the key changes; a no-op update leaves them alone so test
|
|
104
|
-
* stubs survive. See {@link _adminApiKey} for why Keto needs a credential
|
|
105
|
-
* distinct from the agent's OAuth2 token.
|
|
183
|
+
* permission checks. Its token does not authenticate agent-attributed calls
|
|
184
|
+
* (OAuth2 / Frontend / Relationship), but it *is* the fallback credential for
|
|
185
|
+
* Keto permission reads when no agent token is present (see `buildApis`) — so
|
|
186
|
+
* a change to the user token rebuilds the API instances, otherwise the
|
|
187
|
+
* rehydrated user token would never reach the Permission API in a fresh
|
|
188
|
+
* subprocess. Pass `{}` (or fields set to undefined) to clear.
|
|
106
189
|
*/
|
|
107
|
-
|
|
190
|
+
setUserPrincipal(principal: PrincipalIdentity, sessionId?: string | undefined): void;
|
|
108
191
|
/**
|
|
109
192
|
* Set or update the AI agent principal. The agent's token (when present)
|
|
110
|
-
* authenticates outgoing
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* so subsequent calls pick it up; otherwise leaves the API instances alone
|
|
116
|
-
* (so test stubs survive a no-op update).
|
|
193
|
+
* authenticates *every* outgoing Ory call — OAuth2 / Frontend and Keto
|
|
194
|
+
* (Permission / Relationship) alike — and carries audit attribution ("agent X
|
|
195
|
+
* acting on behalf of user Y"). Rebuilds the underlying Ory API instances when
|
|
196
|
+
* the token actually changes so subsequent calls pick it up; otherwise leaves
|
|
197
|
+
* the API instances alone (so test stubs survive a no-op update).
|
|
117
198
|
*/
|
|
118
|
-
setAgentPrincipal(principal: PrincipalIdentity): void;
|
|
199
|
+
setAgentPrincipal(principal: PrincipalIdentity, sessionId?: string | undefined): void;
|
|
119
200
|
/**
|
|
120
201
|
* Verify an existing session token. Returns cached result if available.
|
|
121
202
|
*/
|
|
@@ -128,93 +209,55 @@ export declare class OryAgentClient {
|
|
|
128
209
|
/**
|
|
129
210
|
* Check if a subject has permission to perform an action.
|
|
130
211
|
*
|
|
131
|
-
* `options.
|
|
132
|
-
*
|
|
212
|
+
* `options.activityAttributes` are merged into the `permission.check` activity
|
|
213
|
+
* event so callers can attach harness-side context (toolName, mcpServer,
|
|
133
214
|
* etc.) that the wire-level `PermissionCheck` shape doesn't carry.
|
|
215
|
+
*
|
|
216
|
+
* `options.informational` marks a check whose `false` result is *not* a
|
|
217
|
+
* denial — e.g. the permission-mode probe, where "enforce not granted" simply
|
|
218
|
+
* selects `observe`. Such an event ends `ok` (the read succeeded) rather than
|
|
219
|
+
* `denied`, so a reader watching activity doesn't mistake a routine mode read
|
|
220
|
+
* for a blocked tool. The boolean is still recorded as the `allowed`
|
|
221
|
+
* attribute either way.
|
|
134
222
|
*/
|
|
135
223
|
checkPermission(check: PermissionCheck, options?: {
|
|
136
|
-
|
|
224
|
+
activityAttributes?: Record<string, unknown>;
|
|
225
|
+
informational?: boolean;
|
|
137
226
|
}): Promise<PermissionResult>;
|
|
138
227
|
/**
|
|
139
228
|
* Check multiple permissions in a single request.
|
|
140
229
|
*
|
|
141
|
-
* `options.
|
|
142
|
-
*
|
|
230
|
+
* `options.activityAttributes` are merged into the `permission.batch_check`
|
|
231
|
+
* activity event, for the same purpose as `checkPermission`'s attributes.
|
|
143
232
|
*/
|
|
144
233
|
batchCheckPermissions(checks: PermissionCheck[], options?: {
|
|
145
|
-
|
|
234
|
+
activityAttributes?: Record<string, unknown>;
|
|
146
235
|
}): Promise<BatchPermissionResult>;
|
|
147
236
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* the
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*/
|
|
156
|
-
createRelationship(check: PermissionCheck, options?: {
|
|
157
|
-
spanAttributes?: Record<string, unknown>;
|
|
158
|
-
}): Promise<{
|
|
159
|
-
created: boolean;
|
|
160
|
-
alreadyExisted: boolean;
|
|
161
|
-
}>;
|
|
162
|
-
/**
|
|
163
|
-
* True if the *exact* relation tuple already exists in Keto. Queries the
|
|
164
|
-
* relation-tuple listing API filtered by the tuple's own coordinates
|
|
165
|
-
* (namespace/object/relation + subject), so — unlike `checkPermission` —
|
|
166
|
-
* it does not follow subject-set expansion: it answers "is this literal
|
|
167
|
-
* tuple stored?", not "does this permission resolve?". Throws a classified
|
|
168
|
-
* {@link OryError} if the query itself fails.
|
|
169
|
-
*/
|
|
170
|
-
relationshipExists(check: PermissionCheck): Promise<boolean>;
|
|
171
|
-
/**
|
|
172
|
-
* Idempotent relationship write. Keto's create API is **not** idempotent —
|
|
173
|
-
* `PUT /admin/relation-tuples` inserts a fresh row on every call (each with
|
|
174
|
-
* a new primary key) and never returns 409, so calling `createRelationship`
|
|
175
|
-
* on repeated bootstraps / session starts accumulates duplicate tuples.
|
|
176
|
-
* This reads the exact tuple first (via {@link relationshipExists}) and only
|
|
177
|
-
* writes when it is absent — which also self-heals if the tuple was deleted
|
|
178
|
-
* out of band.
|
|
237
|
+
* Record a delegation edge through the Ory Agent Security broker
|
|
238
|
+
* (`POST <agentSecurityUrl>/agent-security/v1/delegations:record`), authenticated
|
|
239
|
+
* with the process runtime credential. The broker constructs and writes the Keto tuple — the plugin
|
|
240
|
+
* sends only the semantic inputs, so the join-key/tuple encoding stays
|
|
241
|
+
* server-side and cannot drift here. Returns the node id + chain the broker
|
|
242
|
+
* assigned. Throws a classified {@link OryError} on any non-2xx; callers wrap
|
|
243
|
+
* in fail-open semantics (delegation is audit-only).
|
|
179
244
|
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* misbehaving) and the classified error is returned as `probeError`. Callers
|
|
183
|
-
* that must guarantee the grant exists (e.g. install-time bootstrap) can
|
|
184
|
-
* fall back to {@link createRelationship} when `probeError` is set.
|
|
185
|
-
*/
|
|
186
|
-
ensureRelationship(check: PermissionCheck, options?: {
|
|
187
|
-
spanAttributes?: Record<string, unknown>;
|
|
188
|
-
}): Promise<{
|
|
189
|
-
created: boolean;
|
|
190
|
-
alreadyExisted: boolean;
|
|
191
|
-
probeError?: OryError;
|
|
192
|
-
}>;
|
|
193
|
-
/**
|
|
194
|
-
* Delete a relation tuple in Keto. Missing tuples (404) are treated as
|
|
195
|
-
* success so callers can call this idempotently when unwinding state.
|
|
196
|
-
*/
|
|
197
|
-
deleteRelationship(check: PermissionCheck, options?: {
|
|
198
|
-
spanAttributes?: Record<string, unknown>;
|
|
199
|
-
}): Promise<{
|
|
200
|
-
deleted: boolean;
|
|
201
|
-
notFound: boolean;
|
|
202
|
-
}>;
|
|
203
|
-
/**
|
|
204
|
-
* Span attributes describing which principals were attached to the
|
|
205
|
-
* client when the span was started. Useful for correlating audit logs
|
|
206
|
-
* across the user/agent split.
|
|
245
|
+
* The broker exists only on hosted Ory; against the local dev stack the call
|
|
246
|
+
* returns 404 and callers treat it as a best-effort no-op.
|
|
207
247
|
*/
|
|
208
|
-
|
|
248
|
+
recordDelegation(input: RecordDelegationInput, options?: {
|
|
249
|
+
fetchImpl?: typeof fetch;
|
|
250
|
+
activityAttributes?: Record<string, unknown>;
|
|
251
|
+
agentToken?: string;
|
|
252
|
+
runtimeCredential?: RuntimeCredential;
|
|
253
|
+
signal?: AbortSignal;
|
|
254
|
+
}): Promise<RecordDelegationResult>;
|
|
209
255
|
/**
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* Ory Network's Permission / Relationship APIs only accept a project API
|
|
214
|
-
* key. Emit an actionable hint so the failure isn't misread as a stale
|
|
215
|
-
* session (the generic `session_inactive` classification of the raw 401).
|
|
256
|
+
* Activity attributes describing which principals are attached to the
|
|
257
|
+
* client. Useful for correlating audit logs
|
|
258
|
+
* across the user/agent split.
|
|
216
259
|
*/
|
|
217
|
-
private
|
|
260
|
+
private principalActivityAttributes;
|
|
218
261
|
/**
|
|
219
262
|
* Classify an error from any Ory API call into a structured OryError.
|
|
220
263
|
*/
|
|
@@ -227,26 +270,20 @@ export declare class OryAgentClient {
|
|
|
227
270
|
* Create a client from environment variables, falling back to the
|
|
228
271
|
* shared config file at ~/.config/ory-agent-plugins/config.json.
|
|
229
272
|
*
|
|
230
|
-
* Resolution order for projectUrl
|
|
231
|
-
* 1. Environment variables (ORY_PROJECT_URL
|
|
273
|
+
* Resolution order for projectUrl:
|
|
274
|
+
* 1. Environment variables (ORY_PROJECT_URL / ORY_SDK_URL)
|
|
232
275
|
* 2. Config file (~/.config/ory-agent-plugins/config.json)
|
|
233
276
|
* 3. Placeholder (fail-open pass-through mode)
|
|
234
277
|
*/
|
|
235
|
-
static fromEnv(harness: string): OryAgentClient;
|
|
278
|
+
static fromEnv(harness: string, runtime?: Pick<OryAgentConfig, "runtimeRequestAuthenticator" | "runtimeSubject">): OryAgentClient;
|
|
236
279
|
}
|
|
237
|
-
/** Default debug
|
|
280
|
+
/** Default unified activity/debug log path under the shared per-harness data dir. */
|
|
238
281
|
export declare const DEFAULT_DEBUG_LOG_FILENAME = "ory-agent-debug.log";
|
|
239
|
-
/** Default trace (NDJSON) path under the shared per-harness data dir. */
|
|
240
|
-
export declare const DEFAULT_TRACE_FILENAME = "ory-agent-trace.ndjson";
|
|
241
282
|
/**
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
* file automatically — important for subprocess-hook harnesses whose stderr
|
|
245
|
-
* the harness may swallow.
|
|
283
|
+
* Unified activity/debug log path. Activity is always appended; verbose
|
|
284
|
+
* debug/info/warn/error entries are appended only when `ORY_AGENT_DEBUG=true`.
|
|
246
285
|
*/
|
|
247
286
|
export declare function resolveDebugLogPath(harness: string): string | undefined;
|
|
248
|
-
/** Trace (NDJSON) path. Written on every recorded span when set. */
|
|
249
|
-
export declare function resolveTraceFilePath(harness: string): string | undefined;
|
|
250
287
|
/**
|
|
251
288
|
* Pull the Ory backend request ID from a response headers bag (axios returns
|
|
252
289
|
* lowercase header names). Returns undefined when not present.
|