@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.
Files changed (133) hide show
  1. package/README.md +31 -45
  2. package/assets/commands/temporal-up.md +1 -1
  3. package/assets/skills/auth-setup/SKILL.md +1 -1
  4. package/assets/skills/local-dev/SKILL.md +17 -7
  5. package/assets/skills/ory-build-agent/SKILL.md +43 -97
  6. package/assets/skills/ory-e2b-sandbox/SKILL.md +18 -18
  7. package/assets/skills/ory-temporal-worker/SKILL.md +38 -42
  8. package/assets/skills/permissions-onboarding/SKILL.md +131 -104
  9. package/dist/adapters.d.ts +93 -30
  10. package/dist/adapters.js +464 -136
  11. package/dist/agent-auth.d.ts +258 -68
  12. package/dist/agent-auth.js +998 -202
  13. package/dist/auth-store.d.ts +37 -2
  14. package/dist/auth-store.js +37 -3
  15. package/dist/auth.d.ts +40 -4
  16. package/dist/auth.js +247 -19
  17. package/dist/bash-parser.d.ts +98 -0
  18. package/dist/bash-parser.js +396 -0
  19. package/dist/branding.d.ts +128 -0
  20. package/dist/branding.js +151 -0
  21. package/dist/build-info.json +4 -4
  22. package/dist/cli-invocation.d.ts +1 -1
  23. package/dist/cli-invocation.js +2 -1
  24. package/dist/cli.d.ts +20 -29
  25. package/dist/cli.js +271 -278
  26. package/dist/client.d.ts +175 -138
  27. package/dist/client.js +672 -391
  28. package/dist/config.d.ts +249 -57
  29. package/dist/config.js +486 -62
  30. package/dist/context.d.ts +10 -0
  31. package/dist/context.js +21 -0
  32. package/dist/contract-suite.d.ts +8 -8
  33. package/dist/contract-suite.js +88 -69
  34. package/dist/denial.d.ts +36 -3
  35. package/dist/denial.js +79 -10
  36. package/dist/event-reporter.d.ts +77 -0
  37. package/dist/event-reporter.js +776 -0
  38. package/dist/external-registrations-main.d.ts +10 -0
  39. package/dist/external-registrations-main.js +38 -0
  40. package/dist/external-registrations.d.ts +79 -0
  41. package/dist/external-registrations.js +188 -0
  42. package/dist/help-cli.d.ts +39 -0
  43. package/dist/help-cli.js +55 -0
  44. package/dist/hook-timeout.d.ts +64 -0
  45. package/dist/hook-timeout.js +88 -0
  46. package/dist/index.d.ts +31 -19
  47. package/dist/index.js +182 -31
  48. package/dist/lifecycle.d.ts +3 -3
  49. package/dist/lifecycle.js +38 -6
  50. package/dist/local/cli.js +11 -6
  51. package/dist/local/configs.d.ts +74 -18
  52. package/dist/local/configs.js +291 -84
  53. package/dist/local/health.d.ts +14 -0
  54. package/dist/local/health.js +50 -4
  55. package/dist/local/index.d.ts +2 -2
  56. package/dist/local/index.js +24 -10
  57. package/dist/local/manager.d.ts +20 -1
  58. package/dist/local/manager.js +160 -39
  59. package/dist/local/ports.d.ts +158 -0
  60. package/dist/local/ports.js +443 -0
  61. package/dist/local/seed.d.ts +22 -25
  62. package/dist/local/seed.js +88 -56
  63. package/dist/logger.d.ts +54 -25
  64. package/dist/logger.js +329 -63
  65. package/dist/mcp.d.ts +2 -2
  66. package/dist/mcp.js +10 -5
  67. package/dist/mirror-bootstrap.d.ts +48 -0
  68. package/dist/mirror-bootstrap.js +254 -0
  69. package/dist/opl.d.ts +289 -0
  70. package/dist/opl.js +446 -0
  71. package/dist/permission-mode.d.ts +87 -0
  72. package/dist/permission-mode.js +307 -0
  73. package/dist/permissions-cli.d.ts +13 -49
  74. package/dist/permissions-cli.js +154 -348
  75. package/dist/permissions.d.ts +148 -38
  76. package/dist/permissions.js +591 -45
  77. package/dist/post-install.d.ts +33 -0
  78. package/dist/post-install.js +127 -0
  79. package/dist/read-credential.d.ts +65 -0
  80. package/dist/read-credential.js +86 -0
  81. package/dist/registry/cli.js +5 -2
  82. package/dist/registry/config.d.ts +0 -17
  83. package/dist/registry/config.js +0 -23
  84. package/dist/registry/index.d.ts +1 -1
  85. package/dist/registry/index.js +2 -2
  86. package/dist/registry/manager.d.ts +4 -21
  87. package/dist/registry/manager.js +83 -55
  88. package/dist/runtime-credential.d.ts +140 -0
  89. package/dist/runtime-credential.js +572 -0
  90. package/dist/runtime.d.ts +408 -0
  91. package/dist/runtime.js +748 -0
  92. package/dist/setup.d.ts +23 -28
  93. package/dist/setup.js +57 -84
  94. package/dist/status-cli.d.ts +29 -13
  95. package/dist/status-cli.js +124 -144
  96. package/dist/status-data.d.ts +195 -0
  97. package/dist/status-data.js +333 -0
  98. package/dist/status-system.d.ts +24 -0
  99. package/dist/status-system.js +56 -0
  100. package/dist/subject.d.ts +126 -20
  101. package/dist/subject.js +215 -30
  102. package/dist/testing.d.ts +74 -38
  103. package/dist/testing.js +185 -68
  104. package/dist/tool-catalog.d.ts +53 -11
  105. package/dist/tool-catalog.js +164 -13
  106. package/dist/tool-metadata.d.ts +7 -6
  107. package/dist/tool-metadata.js +6 -5
  108. package/dist/types.d.ts +11 -1
  109. package/dist/uninstall.d.ts +74 -19
  110. package/dist/uninstall.js +224 -49
  111. package/dist/user-login.d.ts +22 -16
  112. package/dist/user-login.js +67 -96
  113. package/dist/watch-cli.d.ts +6 -0
  114. package/dist/watch-cli.js +217 -0
  115. package/package.json +3 -11
  116. package/dist/dev.d.ts +0 -103
  117. package/dist/dev.js +0 -584
  118. package/dist/interactive-setup.d.ts +0 -165
  119. package/dist/interactive-setup.js +0 -1546
  120. package/dist/local/jaeger-main.d.ts +0 -13
  121. package/dist/local/jaeger-main.js +0 -85
  122. package/dist/local/jaeger.d.ts +0 -50
  123. package/dist/local/jaeger.js +0 -162
  124. package/dist/otel/exporter.d.ts +0 -17
  125. package/dist/otel/exporter.js +0 -12
  126. package/dist/otel/index.d.ts +0 -2
  127. package/dist/otel/index.js +0 -8
  128. package/dist/otel/otlp.d.ts +0 -103
  129. package/dist/otel/otlp.js +0 -385
  130. package/dist/tracer.d.ts +0 -190
  131. package/dist/tracer.js +0 -481
  132. package/dist/watch-sandbox.d.ts +0 -9
  133. package/dist/watch-sandbox.js +0 -81
@@ -3,36 +3,35 @@
3
3
  *
4
4
  * The "agent" is the AI process making calls on behalf of the human
5
5
  * user. Unlike the user, the agent never authenticates interactively.
6
- * The default path is **OAuth2 Dynamic Client Registration (RFC 7591)**:
7
- * on first run the agent registers itself with the project's
8
- * `/oauth2/register` endpoint, authenticated by the user's bearer token
9
- * (or an out-of-band initial access token), and persists the issued
10
- * credentials so subsequent runs reuse them.
6
+ * The normal path resolves a noninteractive runtime credential: an injected
7
+ * request authenticator, `ORY_AGENT_API_KEY`, or a Talos key enrolled with the
8
+ * already-authenticated user. Enrolled keys remain process-local.
11
9
  *
12
- * Resolution order:
13
- *
14
- * 1. ORY_AGENT_API_KEY — explicit static bearer
15
- * 2. ORY_AGENT_CLIENT_ID +
16
- * ORY_AGENT_CLIENT_SECRET — explicit static client_credentials
17
- * 3. Persisted dynamic credentials — reuse a prior DCR registration
18
- * 4. Fresh dynamic registration — POST /oauth2/register using the
19
- * user's bearer or
20
- * ORY_AGENT_REGISTRATION_TOKEN
21
- * 5. ORY_API_KEY (deprecated) — alias for ORY_AGENT_API_KEY
22
- * 6. <none> — fail-open; plugin runs without
23
- * agent identity in audit logs
24
- *
25
- * Token-exchange (RFC 8693) — deriving an agent token whose `sub` is
26
- * the user with an `act` claim showing the agent — is intentionally
27
- * deferred.
10
+ * Legacy DCR and client-credentials helpers remain exported temporarily so the
11
+ * monorepo and existing consumers compile, but the normal gates do not select
12
+ * them.
28
13
  */
29
- import { type OryAgentDynamicCredentials } from "./config.js";
14
+ import { type OryAgentDynamicCredentials, type OryDelegationRecord } from "./config.js";
30
15
  import { OryAgentClient } from "./client.js";
31
- export type AgentCredentialKind = "api_key" | "client_credentials" | "dynamic" | "none";
16
+ import { enrollTalosChildRuntimeCredential, enrollTalosRuntimeCredential, type RuntimeCredential, type RuntimeRequestAuthenticator, type TalosCredentialStore } from "./runtime-credential.js";
17
+ /**
18
+ * Delegation context handed to {@link registerAgentClient} so the freshly
19
+ * minted OAuth2 client is stamped with its delegator at the identity layer.
20
+ * `delegatedAt` is stamped by the registrar, not the caller.
21
+ */
22
+ export interface DelegationInput {
23
+ /** The delegator, namespaced: `user:<sub>` or `agent:<sub>`. */
24
+ delegatedBy: string;
25
+ delegationType: OryDelegationRecord["delegationType"];
26
+ subAgentType?: string;
27
+ }
28
+ export type AgentCredentialKind = "talos" | "injected" | "client_credentials" | "dynamic" | "none";
32
29
  export interface AgentCredentials {
33
30
  kind: AgentCredentialKind;
34
31
  /** Bearer token to attach to outgoing Ory API calls. */
35
32
  token?: string;
33
+ /** Request-level credential used by Agent Security broker transports. */
34
+ runtimeCredential?: RuntimeCredential;
36
35
  /** Subject (sub) the token represents — usually the client_id. */
37
36
  subject?: string;
38
37
  /** Unix epoch seconds at which the token expires (client_credentials only). */
@@ -44,8 +43,8 @@ export interface AgentCredentials {
44
43
  */
45
44
  reason: string;
46
45
  /**
47
- * Diagnostic warnings raised during resolution (e.g. ORY_API_KEY used
48
- * via deprecated alias). Never blocks resolution.
46
+ * Diagnostic warnings raised during resolution (e.g. a client_credentials
47
+ * grant that had to be retried). Never blocks resolution.
49
48
  */
50
49
  warnings: string[];
51
50
  /**
@@ -64,8 +63,26 @@ export interface ResolveAgentCredentialsOptions {
64
63
  env?: NodeJS.ProcessEnv;
65
64
  /** User's bearer token; preferred IAT for dynamic registration. */
66
65
  userToken?: string;
66
+ /**
67
+ * User's subject. When present, a fresh DCR stamps `metadata.delegatedBy`
68
+ * = `user:<userSubject>` on the agent client so the user→agent delegation
69
+ * has an identity-layer anchor. Absent ⇒ the client registers without a
70
+ * delegation anchor (no delegator known).
71
+ */
72
+ userSubject?: string;
67
73
  /** Harness identifier — baked into the registered client_name. */
68
74
  harness?: string;
75
+ /**
76
+ * The harness session this resolution belongs to. Each session gets its own
77
+ * OAuth2 identity, so this is part of the credential key and of the
78
+ * registered `client_name`. Omitted ⇒ the caller has no session concept and
79
+ * gets the single {@link SESSIONLESS_KEY} identity.
80
+ */
81
+ sessionId?: string;
82
+ /** Abort network work owned by this resolution attempt. */
83
+ signal?: AbortSignal;
84
+ /** Skip fresh DCR when a caller may only recover an existing identity. */
85
+ allowRegistration?: boolean;
69
86
  /** Inject the client_credentials token-grant function for tests. */
70
87
  fetchClientCredentialsTokenFn?: typeof fetchClientCredentialsToken;
71
88
  /** Inject the DCR registration call for tests. */
@@ -74,9 +91,28 @@ export interface ResolveAgentCredentialsOptions {
74
91
  loadDynamicFn?: typeof loadAgentDynamicCredentials;
75
92
  saveDynamicFn?: typeof saveAgentDynamicCredentials;
76
93
  clearDynamicFn?: typeof clearAgentDynamicCredentials;
77
- /** Bypass the in-memory cache (tests). */
94
+ /** Inject the RFC 7592 revoke used to clean up a lost registration race. */
95
+ revokeFn?: typeof revokeAgentDynamicClient;
96
+ /** Bypass the in-memory token cache (tests). */
78
97
  skipCache?: boolean;
79
98
  }
99
+ export interface ResolveRuntimeAgentCredentialsOptions {
100
+ env?: NodeJS.ProcessEnv;
101
+ subject?: string;
102
+ projectUrl?: string;
103
+ runtimeCredential?: RuntimeCredential;
104
+ requestAuthenticator?: RuntimeRequestAuthenticator;
105
+ credentialStore?: TalosCredentialStore;
106
+ fetchImpl?: typeof fetch;
107
+ signal?: AbortSignal;
108
+ harness?: string;
109
+ sessionId?: string;
110
+ }
111
+ /**
112
+ * Resolve the runtime credential used by the normal Agent Security path.
113
+ * This intentionally does not inspect OAuth client credentials or persisted DCR.
114
+ */
115
+ export declare function resolveRuntimeAgentCredentials(options?: ResolveRuntimeAgentCredentialsOptions): Promise<AgentCredentials>;
80
116
  /**
81
117
  * Skew window before nominal expiry at which a cached client_credentials
82
118
  * token is considered stale. Matches the user-token skew in auth-store.
@@ -84,18 +120,118 @@ export interface ResolveAgentCredentialsOptions {
84
120
  export declare const AGENT_TOKEN_EXPIRY_SKEW_SEC = 60;
85
121
  /** Drop all cached agent client_credentials tokens. Tests only. */
86
122
  export declare function _resetAgentCredentialsCache(): void;
87
- /** Load persisted sub-agent DCR credentials keyed by sub-agent type. */
88
- export declare function loadSubAgentDynamicCredentials(subAgentType: string): OryAgentDynamicCredentials | undefined;
89
- /** Persist sub-agent DCR credentials under the given type key. */
90
- export declare function saveSubAgentDynamicCredentials(subAgentType: string, creds: OryAgentDynamicCredentials): void;
91
- /** Remove persisted sub-agent DCR credentials for the given type. */
92
- export declare function clearSubAgentDynamicCredentials(subAgentType: string): void;
93
- /** Load persisted DCR credentials from the shared config file. */
94
- export declare function loadAgentDynamicCredentials(): OryAgentDynamicCredentials | undefined;
95
- /** Persist DCR credentials. Existing credentials are replaced atomically. */
96
- export declare function saveAgentDynamicCredentials(creds: OryAgentDynamicCredentials): void;
97
- /** Remove persisted DCR credentials (e.g. after revocation or unregister). */
98
- export declare function clearAgentDynamicCredentials(): void;
123
+ /** Evict a bearer rejected by Agent Security without disturbing other sessions. */
124
+ export declare function invalidateAgentAccessToken(rejectedToken: string): void;
125
+ /** Load persisted sub-agent DCR credentials for one harness + type. */
126
+ export declare function loadSubAgentDynamicCredentials(harness: string, sessionOrType: string, subAgentType?: string): OryAgentDynamicCredentials | undefined;
127
+ /**
128
+ * Load one harness's persisted sub-agent registrations, keyed by sub-agent type.
129
+ * Returns an empty object when none have been registered. Used by the status
130
+ * report to enumerate the sub-agent kinds this harness has resolved.
131
+ */
132
+ export declare function loadAllSubAgentDynamicCredentials(harness: string, sessionKey?: string): Record<string, OryAgentDynamicCredentials>;
133
+ /**
134
+ * Every persisted sub-agent registration, keyed by harness, session, then type. Used by
135
+ * teardown and reporting paths that must reach beyond the harness they run under.
136
+ */
137
+ export declare function loadSubAgentDynamicCredentialsByHarness(): Record<string, Record<string, Record<string, OryAgentDynamicCredentials>>>;
138
+ /** Persist sub-agent DCR credentials under the given harness + session + type. */
139
+ export declare function saveSubAgentDynamicCredentials(harness: string, subAgentType: string, creds: OryAgentDynamicCredentials): void;
140
+ export declare function saveSubAgentDynamicCredentials(harness: string, sessionKey: string, subAgentType: string, creds: OryAgentDynamicCredentials): void;
141
+ /** Remove persisted sub-agent DCR credentials for one harness + type. */
142
+ export declare function clearSubAgentDynamicCredentials(harness: string, sessionOrType: string, subAgentType?: string): void;
143
+ /** Remove every persisted sub-agent registration for one harness. */
144
+ export declare function clearSubAgentDynamicCredentialsForHarness(harness: string): void;
145
+ /** Load persisted DCR credentials for one harness session. */
146
+ export declare function loadAgentDynamicCredentials(harness: string, sessionKey?: string): OryAgentDynamicCredentials | undefined;
147
+ /**
148
+ * Every persisted agent registration, keyed by harness then session.
149
+ * reporting paths that must reach beyond the harness they run under.
150
+ */
151
+ export declare function loadAgentDynamicCredentialsByHarness(): Record<string, Record<string, OryAgentDynamicCredentials>>;
152
+ /**
153
+ * Persist DCR credentials for one harness install. Other harnesses are left
154
+ * untouched.
155
+ */
156
+ export declare function saveAgentDynamicCredentials(harness: string, creds: OryAgentDynamicCredentials): void;
157
+ export declare function saveAgentDynamicCredentials(harness: string, sessionKey: string, creds: OryAgentDynamicCredentials): void;
158
+ /** Remove one session, or every session when no session key is supplied. */
159
+ export declare function clearAgentDynamicCredentials(harness: string, sessionKey?: string): void;
160
+ /** Most recently registered agent session for status/reporting. */
161
+ export declare function latestAgentRegistration(harness: string): {
162
+ sessionKey: string;
163
+ credentials: OryAgentDynamicCredentials;
164
+ } | undefined;
165
+ /** Newest session containing at least one sub-agent registration. */
166
+ export declare function latestSubAgentSession(harness: string): string | undefined;
167
+ export declare function countAgentSessions(harness: string): number;
168
+ /**
169
+ * The delegation node the broker assigned to this harness's `user → agent` edge
170
+ * for one session, or `undefined` if that session hasn't recorded one yet.
171
+ *
172
+ * Read by the sub-agent edge to pass as `delegated_by` — which is why it is
173
+ * looked up by session and not just by harness: the credential is shared across
174
+ * sessions but the node is not, so a sub-agent must hang off *its own* run's
175
+ * agent node.
176
+ */
177
+ export declare function loadDelegationNodeId(harness: string, sessionKey: string): string | undefined;
178
+ /**
179
+ * Record the broker-assigned delegation node for `(harness, session)`, trimming
180
+ * the map to the most recent {@link DELEGATION_NODE_HISTORY} entries.
181
+ *
182
+ * The anchor is not a credential and is safe to persist independently. A
183
+ * repeated idempotent edge does not rewrite the config file.
184
+ */
185
+ export declare function saveDelegationNodeId(harness: string, sessionKey: string, nodeId: string): void;
186
+ /** Registrations queued for best-effort revocation. */
187
+ export declare function loadRetiredCredentials(): OryAgentDynamicCredentials[];
188
+ /**
189
+ * Remove `clientIds` from the drain queue. Called with the ones that were
190
+ * actually revoked; anything left stays queued for the next run, so a transient
191
+ * failure retries instead of orphaning the client.
192
+ */
193
+ export declare function clearRetiredCredentials(clientIds: readonly string[]): void;
194
+ /** Automatic retirement is opt-in because age alone cannot prove a session ended. */
195
+ export declare const DEFAULT_SESSION_RETENTION = 0;
196
+ /** `0` disables automatic retirement. */
197
+ export declare function sessionRetention(env?: NodeJS.ProcessEnv): number;
198
+ /**
199
+ * Move aged-out agent sessions and all of their child credentials to the
200
+ * retirement queue atomically. They remain addressable until RFC 7592 cleanup
201
+ * succeeds, avoiding the orphaning behavior of the original pruning path.
202
+ */
203
+ export declare function retireAgentSessions(harness: string, opts: {
204
+ keep: number;
205
+ protect?: string;
206
+ }): number;
207
+ /**
208
+ * The credentials a cold-starting session ends up with after registering, and
209
+ * whether a concurrent peer beat it to the slot.
210
+ */
211
+ export interface AgentRegistrationClaim {
212
+ /** The credentials now persisted for this key — ours, or the peer's. */
213
+ credentials: OryAgentDynamicCredentials;
214
+ /**
215
+ * True when a peer registration was already persisted for this key, so the
216
+ * freshly minted client was *not* stored. The caller should revoke it
217
+ * (RFC 7592) rather than leave an orphan on the project.
218
+ */
219
+ peer: boolean;
220
+ }
221
+ /**
222
+ * Persist a freshly registered agent client, unless a concurrent peer already
223
+ * claimed the `(projectUrl, harness)` slot.
224
+ *
225
+ * Keying credentials by harness removes the cold-start collision *between*
226
+ * harnesses, but two instances of the *same* harness starting at once still
227
+ * target one key. Both POST `/oauth2/register`, and a plain last-writer-wins
228
+ * save would leave one client orphaned server-side (and its delegation edge
229
+ * dangling). The read and the write happen inside a single `mutateConfig`, so
230
+ * the loser sees the winner's registration and reports it back to be revoked.
231
+ */
232
+ export declare function claimAgentDynamicCredentials(harness: string, sessionKey: string, registered: OryAgentDynamicCredentials): AgentRegistrationClaim;
233
+ /** {@link claimAgentDynamicCredentials} for a `(harness, subAgentType)` slot. */
234
+ export declare function claimSubAgentDynamicCredentials(harness: string, sessionKey: string, subAgentType: string, registered: OryAgentDynamicCredentials): AgentRegistrationClaim;
99
235
  /** Outcome of a best-effort RFC 7592 client revocation. */
100
236
  export interface RevokeAgentClientResult {
101
237
  /**
@@ -125,23 +261,39 @@ export interface RegisterAgentClientArgs {
125
261
  auth: string;
126
262
  /** Harness identifier baked into the client_name for audit. */
127
263
  harness?: string;
264
+ /** When set, names the client as a sub-agent of the given type. */
265
+ subAgentType?: string;
266
+ /** Session owning this DCR client; included in its display name. */
267
+ sessionId?: string;
268
+ /** Abort the registration request when its owning operation expires. */
269
+ signal?: AbortSignal;
270
+ /**
271
+ * Delegation edge recorded for this client. When present, the issued
272
+ * credentials carry a durable record of who delegated to the agent — the
273
+ * integrity anchor from which the Keto delegation tuple can be rebuilt.
274
+ * Persisted in local config only; Ory's public DCR endpoint rejects a
275
+ * `metadata` field, so it is not stored server-side. Omitted when the
276
+ * delegator isn't known at registration time.
277
+ */
278
+ delegation?: DelegationInput;
128
279
  /** Override hostname for testing. */
129
280
  hostnameFn?: () => string;
281
+ /** Inject the wall clock for deterministic `delegatedAt` in tests. */
282
+ nowFn?: () => Date;
130
283
  }
131
284
  /**
132
285
  * Register a new OAuth2 client via RFC 7591. Authorization is carried
133
286
  * either by the user's interactive token (the natural bootstrap) or by
134
287
  * a pre-issued initial access token (`ORY_AGENT_REGISTRATION_TOKEN`).
135
288
  * Throws on any non-2xx response so callers can decide whether to
136
- * retry, fall back, or surface the error in the audit span. The
289
+ * retry, fall back, or surface the error in audit activity. The
137
290
  * `HTTP <status>` error message shape is preserved so callers and tests
138
291
  * can pattern-match on it regardless of the underlying transport.
139
292
  */
140
293
  export declare function registerAgentClient(args: RegisterAgentClientArgs): Promise<OryAgentDynamicCredentials>;
141
294
  /**
142
- * Resolve the agent's credentials from environment configuration and
143
- * persisted state. Never throws — failures collapse to `kind: "none"`
144
- * so the caller can fail open.
295
+ * Legacy OAuth/DCR resolver retained for source compatibility. Normal runtime
296
+ * gates use {@link resolveRuntimeAgentCredentials} instead.
145
297
  */
146
298
  export declare function resolveAgentCredentials(options?: ResolveAgentCredentialsOptions): Promise<AgentCredentials>;
147
299
  interface ClientCredentialsTokenArgs {
@@ -150,6 +302,7 @@ interface ClientCredentialsTokenArgs {
150
302
  clientSecret: string;
151
303
  audience?: string;
152
304
  scope?: string;
305
+ signal?: AbortSignal;
153
306
  }
154
307
  interface ClientCredentialsTokenResult {
155
308
  accessToken: string;
@@ -159,20 +312,47 @@ interface ClientCredentialsTokenResult {
159
312
  /** POST /oauth2/token with grant_type=client_credentials. */
160
313
  export declare function fetchClientCredentialsToken(args: ClientCredentialsTokenArgs): Promise<ClientCredentialsTokenResult>;
161
314
  export interface EnsureAgentIdentityOptions {
162
- /** Project URL for client_credentials grant + DCR. Defaults to resolveConfig(). */
315
+ /** Retained for source compatibility; runtime resolution uses the connected client. */
163
316
  projectUrl?: string;
164
- /** Harness identifier baked into a fresh DCR client_name. */
317
+ /** Retained for source compatibility and activity attribution. */
165
318
  harness?: string;
319
+ /**
320
+ * Session this identity acts in. Selects the persisted DCR slot and defaults
321
+ * to the client's ambient session.
322
+ */
323
+ sessionId?: string;
324
+ /** Abort network work when a bounded caller, such as hook shutdown, expires. */
325
+ signal?: AbortSignal;
326
+ /** @deprecated Runtime resolution never uses DCR. */
327
+ allowRegistration?: boolean;
328
+ /** Inject the RFC 7592 revoke used when draining retired credentials. */
329
+ revokeFn?: typeof revokeAgentDynamicClient;
166
330
  /** Env override (defaults to process.env). */
167
331
  env?: NodeJS.ProcessEnv;
168
332
  /** Inject resolver for tests. */
169
- resolveFn?: typeof resolveAgentCredentials;
333
+ resolveFn?: (options: ResolveRuntimeAgentCredentialsOptions & ResolveAgentCredentialsOptions) => Promise<AgentCredentials>;
334
+ /** Inject OS-backed persistence for tests or embedded runtimes. */
335
+ credentialStore?: TalosCredentialStore;
336
+ /** Inject Talos enrollment for tests. */
337
+ enrollFn?: typeof enrollTalosRuntimeCredential;
338
+ /** Inject random idempotency-key generation for tests. */
339
+ createIdempotencyKey?: () => string;
340
+ /**
341
+ * @deprecated Normal runtime resolution never processes OAuth registrations.
342
+ */
343
+ drainRetired?: boolean;
344
+ /**
345
+ * What prompted this resolution, recorded on the `agent.auth` activity event. Absent for
346
+ * the session-start gate; `read_credential` when the tool gate resolved the
347
+ * identity because it needed a credential to authenticate a permission read.
348
+ */
349
+ trigger?: string;
170
350
  }
171
351
  /**
172
352
  * Resolve the agent's credentials and attach them to the client.
173
353
  *
174
354
  * Always returns the resolved credentials; never throws and never blocks.
175
- * Emits exactly one `agent.auth` span so the audit trail records whether
355
+ * Emits exactly one `agent.auth` activity event so the audit trail records whether
176
356
  * the agent identity was available for the session.
177
357
  */
178
358
  export declare function ensureAgentIdentity(client: OryAgentClient, options?: EnsureAgentIdentityOptions): Promise<AgentCredentials>;
@@ -180,19 +360,22 @@ export declare function ensureAgentIdentity(client: OryAgentClient, options?: En
180
360
  * Resolved identity for a sub-agent (a typed worker that the parent
181
361
  * agent delegates to, e.g. Claude Code's `Task` tool launching an
182
362
  * `Explore` sub-agent). The shape mirrors AgentCredentials but the
183
- * caller does not attach the token to the client sub-agent
184
- * credentials are recorded for the audit trail; they aren't injected
185
- * into the harness's child process.
363
+ * harness integration reloads the child runtime credential for hooks that
364
+ * execute inside that child; the secret is never injected into the child process.
186
365
  */
187
366
  export interface SubAgentIdentity {
188
- /** "dynamic" once registered/loaded, "none" on any failure. */
189
- kind: "dynamic" | "none";
367
+ /** `runtime` in normal use; `dynamic` remains for injected legacy callers. */
368
+ kind: "runtime" | "dynamic" | "none";
190
369
  /** Sub-agent type as reported by the harness (e.g. "Explore"). */
191
370
  subAgentType: string;
192
371
  /** Issued client_id — also used as the audit subject for this sub-agent. */
193
372
  subject?: string;
373
+ /** Access token proving the reported sub-agent client id to the broker. */
374
+ token?: string;
194
375
  /** Persisted credentials returned by registration (or reloaded). */
195
376
  credentials?: OryAgentDynamicCredentials;
377
+ /** Child-owned credential used for delegation and subsequent child calls. */
378
+ runtimeCredential?: RuntimeCredential;
196
379
  /** One-line reason suitable for telemetry. */
197
380
  reason: string;
198
381
  /** Diagnostic warnings raised during resolution. */
@@ -201,35 +384,42 @@ export interface SubAgentIdentity {
201
384
  export interface EnsureSubAgentIdentityOptions {
202
385
  /** Sub-agent type identifier (e.g. "Explore", "general-purpose"). */
203
386
  subAgentType: string;
204
- /** Project URL for DCR. Defaults to resolveConfig(). */
387
+ /** Retained for source compatibility; no DCR request is made. */
205
388
  projectUrl?: string;
206
- /** Harness identifier baked into a fresh DCR client_name. */
389
+ /** Harness identifier used for activity and delegation context. */
207
390
  harness?: string;
391
+ /** Session this sub-agent belongs to. Defaults to the client's ambient session. */
392
+ sessionId?: string;
393
+ /** Stable identifier for this individual child spawn. */
394
+ perSpawnId?: string;
395
+ /** Abort network work owned by this resolution attempt. */
396
+ signal?: AbortSignal;
397
+ /** Let an adapter emit authentication after selecting the Sub-Agent bearer. */
398
+ emitActivity?: boolean;
208
399
  /**
209
- * Bearer used as the IAT for the registration call. Defaults to the
210
- * parent agent's token (when populated) so the audit trail shows the
211
- * agent registering its sub-agent. Falls back to the user's token,
212
- * then `ORY_AGENT_REGISTRATION_TOKEN`.
400
+ * @deprecated Runtime sub-agent resolution never registers OAuth clients.
213
401
  */
214
402
  iat?: string;
215
403
  /** Env override (defaults to process.env). */
216
404
  env?: NodeJS.ProcessEnv;
217
- /** Inject the DCR registration call for tests. */
405
+ /** @deprecated Retained for source compatibility and never called. */
218
406
  registerAgentClientFn?: typeof registerAgentClient;
219
- /** Inject persistence for tests. */
407
+ /** @deprecated Retained for source compatibility and never called. */
220
408
  loadFn?: typeof loadSubAgentDynamicCredentials;
221
409
  saveFn?: typeof saveSubAgentDynamicCredentials;
410
+ /** @deprecated Retained for source compatibility and never called. */
411
+ revokeFn?: typeof revokeAgentDynamicClient;
412
+ /** @deprecated Retained for source compatibility and never called. */
413
+ fetchClientCredentialsTokenFn?: typeof fetchClientCredentialsToken;
414
+ credentialStore?: TalosCredentialStore;
415
+ enrollFn?: typeof enrollTalosChildRuntimeCredential;
416
+ createIdempotencyKey?: () => string;
417
+ allowEnrollment?: boolean;
222
418
  }
223
419
  /**
224
- * Resolve a sub-agent identity via OAuth2 Dynamic Client Registration.
225
- *
226
- * Reuses persisted credentials when the `(projectUrl, subAgentType)`
227
- * pair matches; otherwise registers a fresh client with
228
- * `client_name = ory-subagent-<type>@<host>` and persists the result.
229
- * Never throws and never blocks — on any failure the identity collapses
230
- * to `kind: "none"` and the plugin continues without it. Emits exactly
231
- * one `agent.auth` span so the audit trail records each sub-agent
232
- * resolution.
420
+ * Resolve a sub-agent against the process runtime credential. The broker's
421
+ * `type_name` supplies sub-agent attribution; no separate OAuth identity is
422
+ * registered, loaded, minted, or persisted.
233
423
  */
234
424
  export declare function ensureSubAgentIdentity(client: OryAgentClient, options: EnsureSubAgentIdentityOptions): Promise<SubAgentIdentity>;
235
425
  export {};