@ory/argus 0.14.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +31 -46
  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 +39 -91
  6. package/assets/skills/ory-e2b-sandbox/SKILL.md +18 -17
  7. package/assets/skills/ory-temporal-worker/SKILL.md +31 -33
  8. package/assets/skills/permissions-onboarding/SKILL.md +131 -104
  9. package/dist/adapters.d.ts +88 -32
  10. package/dist/adapters.js +443 -164
  11. package/dist/agent-auth.d.ts +226 -67
  12. package/dist/agent-auth.js +951 -205
  13. package/dist/auth-store.d.ts +37 -2
  14. package/dist/auth-store.js +37 -3
  15. package/dist/auth.d.ts +33 -4
  16. package/dist/auth.js +163 -20
  17. package/dist/bash-parser.d.ts +98 -0
  18. package/dist/bash-parser.js +396 -0
  19. package/dist/branding.d.ts +77 -16
  20. package/dist/branding.js +93 -23
  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 -239
  26. package/dist/client.d.ts +175 -138
  27. package/dist/client.js +672 -391
  28. package/dist/config.d.ts +217 -54
  29. package/dist/config.js +461 -42
  30. package/dist/context.d.ts +10 -0
  31. package/dist/context.js +21 -0
  32. package/dist/contract-suite.d.ts +3 -5
  33. package/dist/contract-suite.js +75 -47
  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 +28 -23
  47. package/dist/index.js +173 -58
  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.js +7 -7
  54. package/dist/local/index.d.ts +2 -2
  55. package/dist/local/index.js +24 -10
  56. package/dist/local/manager.d.ts +20 -1
  57. package/dist/local/manager.js +159 -36
  58. package/dist/local/ports.d.ts +158 -0
  59. package/dist/local/ports.js +443 -0
  60. package/dist/local/seed.d.ts +13 -5
  61. package/dist/local/seed.js +62 -38
  62. package/dist/logger.d.ts +54 -25
  63. package/dist/logger.js +329 -63
  64. package/dist/mcp.d.ts +2 -2
  65. package/dist/mcp.js +10 -5
  66. package/dist/mirror-bootstrap.d.ts +48 -0
  67. package/dist/mirror-bootstrap.js +254 -0
  68. package/dist/opl.d.ts +289 -0
  69. package/dist/opl.js +446 -0
  70. package/dist/permission-mode.d.ts +87 -0
  71. package/dist/permission-mode.js +307 -0
  72. package/dist/permissions-cli.d.ts +13 -49
  73. package/dist/permissions-cli.js +154 -348
  74. package/dist/permissions.d.ts +148 -38
  75. package/dist/permissions.js +591 -45
  76. package/dist/post-install.d.ts +33 -0
  77. package/dist/post-install.js +127 -0
  78. package/dist/read-credential.d.ts +65 -0
  79. package/dist/read-credential.js +86 -0
  80. package/dist/registry/cli.js +5 -2
  81. package/dist/registry/config.d.ts +0 -17
  82. package/dist/registry/config.js +0 -23
  83. package/dist/registry/index.d.ts +1 -1
  84. package/dist/registry/index.js +2 -2
  85. package/dist/registry/manager.d.ts +4 -21
  86. package/dist/registry/manager.js +21 -37
  87. package/dist/runtime-credential.d.ts +140 -0
  88. package/dist/runtime-credential.js +572 -0
  89. package/dist/runtime.d.ts +413 -0
  90. package/dist/runtime.js +825 -0
  91. package/dist/setup.d.ts +23 -47
  92. package/dist/setup.js +59 -116
  93. package/dist/skills.js +0 -7
  94. package/dist/status-cli.d.ts +27 -11
  95. package/dist/status-cli.js +121 -115
  96. package/dist/status-data.d.ts +116 -17
  97. package/dist/status-data.js +121 -38
  98. package/dist/subject.d.ts +126 -20
  99. package/dist/subject.js +215 -30
  100. package/dist/testing.d.ts +74 -38
  101. package/dist/testing.js +185 -68
  102. package/dist/tool-catalog.d.ts +53 -11
  103. package/dist/tool-catalog.js +164 -13
  104. package/dist/tool-metadata.d.ts +7 -6
  105. package/dist/tool-metadata.js +6 -5
  106. package/dist/types.d.ts +11 -1
  107. package/dist/uninstall.d.ts +71 -34
  108. package/dist/uninstall.js +217 -85
  109. package/dist/user-login.d.ts +9 -10
  110. package/dist/user-login.js +56 -75
  111. package/dist/watch-cli.d.ts +6 -0
  112. package/dist/watch-cli.js +217 -0
  113. package/package.json +4 -27
  114. package/assets/commands/dashboard.md +0 -34
  115. package/dist/dashboard-cli.d.ts +0 -8
  116. package/dist/dashboard-cli.js +0 -70
  117. package/dist/dev.d.ts +0 -103
  118. package/dist/dev.js +0 -583
  119. package/dist/interactive-setup.d.ts +0 -286
  120. package/dist/interactive-setup.js +0 -1734
  121. package/dist/local/jaeger-main.d.ts +0 -13
  122. package/dist/local/jaeger-main.js +0 -85
  123. package/dist/local/jaeger.d.ts +0 -50
  124. package/dist/local/jaeger.js +0 -162
  125. package/dist/otel/exporter.d.ts +0 -17
  126. package/dist/otel/exporter.js +0 -12
  127. package/dist/otel/index.d.ts +0 -2
  128. package/dist/otel/index.js +0 -8
  129. package/dist/otel/otlp.d.ts +0 -103
  130. package/dist/otel/otlp.js +0 -385
  131. package/dist/project-api-key.d.ts +0 -69
  132. package/dist/project-api-key.js +0 -147
  133. package/dist/setup-actions.d.ts +0 -232
  134. package/dist/setup-actions.js +0 -507
  135. package/dist/tracer.d.ts +0 -190
  136. package/dist/tracer.js +0 -481
  137. package/dist/watch-sandbox.d.ts +0 -9
  138. package/dist/watch-sandbox.js +0 -81
  139. package/dist/web/api.d.ts +0 -33
  140. package/dist/web/api.js +0 -294
  141. package/dist/web/launch.d.ts +0 -11
  142. package/dist/web/launch.js +0 -96
  143. package/dist/web/server.d.ts +0 -20
  144. package/dist/web/server.js +0 -233
  145. package/dist/web/types.d.ts +0 -65
  146. package/dist/web/types.js +0 -2
  147. package/dist/webapp/assets/index-Wucl4SZs.css +0 -1
  148. package/dist/webapp/assets/index-m-GtEdq0.js +0 -49
  149. package/dist/webapp/favicon.ico +0 -0
  150. package/dist/webapp/index.html +0 -15
@@ -3,31 +3,17 @@
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
14
  import { type OryAgentDynamicCredentials, type OryDelegationRecord } from "./config.js";
30
15
  import { OryAgentClient } from "./client.js";
16
+ import { enrollTalosChildRuntimeCredential, enrollTalosRuntimeCredential, type RuntimeCredential, type RuntimeRequestAuthenticator, type TalosCredentialStore } from "./runtime-credential.js";
31
17
  /**
32
18
  * Delegation context handed to {@link registerAgentClient} so the freshly
33
19
  * minted OAuth2 client is stamped with its delegator at the identity layer.
@@ -39,11 +25,13 @@ export interface DelegationInput {
39
25
  delegationType: OryDelegationRecord["delegationType"];
40
26
  subAgentType?: string;
41
27
  }
42
- export type AgentCredentialKind = "api_key" | "client_credentials" | "dynamic" | "none";
28
+ export type AgentCredentialKind = "talos" | "injected" | "client_credentials" | "dynamic" | "none";
43
29
  export interface AgentCredentials {
44
30
  kind: AgentCredentialKind;
45
31
  /** Bearer token to attach to outgoing Ory API calls. */
46
32
  token?: string;
33
+ /** Request-level credential used by Agent Security broker transports. */
34
+ runtimeCredential?: RuntimeCredential;
47
35
  /** Subject (sub) the token represents — usually the client_id. */
48
36
  subject?: string;
49
37
  /** Unix epoch seconds at which the token expires (client_credentials only). */
@@ -55,8 +43,8 @@ export interface AgentCredentials {
55
43
  */
56
44
  reason: string;
57
45
  /**
58
- * Diagnostic warnings raised during resolution (e.g. ORY_API_KEY used
59
- * 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.
60
48
  */
61
49
  warnings: string[];
62
50
  /**
@@ -84,6 +72,17 @@ export interface ResolveAgentCredentialsOptions {
84
72
  userSubject?: string;
85
73
  /** Harness identifier — baked into the registered client_name. */
86
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;
87
86
  /** Inject the client_credentials token-grant function for tests. */
88
87
  fetchClientCredentialsTokenFn?: typeof fetchClientCredentialsToken;
89
88
  /** Inject the DCR registration call for tests. */
@@ -92,9 +91,28 @@ export interface ResolveAgentCredentialsOptions {
92
91
  loadDynamicFn?: typeof loadAgentDynamicCredentials;
93
92
  saveDynamicFn?: typeof saveAgentDynamicCredentials;
94
93
  clearDynamicFn?: typeof clearAgentDynamicCredentials;
95
- /** 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). */
96
97
  skipCache?: boolean;
97
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>;
98
116
  /**
99
117
  * Skew window before nominal expiry at which a cached client_credentials
100
118
  * token is considered stale. Matches the user-token skew in auth-store.
@@ -102,18 +120,118 @@ export interface ResolveAgentCredentialsOptions {
102
120
  export declare const AGENT_TOKEN_EXPIRY_SKEW_SEC = 60;
103
121
  /** Drop all cached agent client_credentials tokens. Tests only. */
104
122
  export declare function _resetAgentCredentialsCache(): void;
105
- /** Load persisted sub-agent DCR credentials keyed by sub-agent type. */
106
- export declare function loadSubAgentDynamicCredentials(subAgentType: string): OryAgentDynamicCredentials | undefined;
107
- /** Persist sub-agent DCR credentials under the given type key. */
108
- export declare function saveSubAgentDynamicCredentials(subAgentType: string, creds: OryAgentDynamicCredentials): void;
109
- /** Remove persisted sub-agent DCR credentials for the given type. */
110
- export declare function clearSubAgentDynamicCredentials(subAgentType: string): void;
111
- /** Load persisted DCR credentials from the shared config file. */
112
- export declare function loadAgentDynamicCredentials(): OryAgentDynamicCredentials | undefined;
113
- /** Persist DCR credentials. Existing credentials are replaced atomically. */
114
- export declare function saveAgentDynamicCredentials(creds: OryAgentDynamicCredentials): void;
115
- /** Remove persisted DCR credentials (e.g. after revocation or unregister). */
116
- 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;
117
235
  /** Outcome of a best-effort RFC 7592 client revocation. */
118
236
  export interface RevokeAgentClientResult {
119
237
  /**
@@ -145,6 +263,10 @@ export interface RegisterAgentClientArgs {
145
263
  harness?: string;
146
264
  /** When set, names the client as a sub-agent of the given type. */
147
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;
148
270
  /**
149
271
  * Delegation edge recorded for this client. When present, the issued
150
272
  * credentials carry a durable record of who delegated to the agent — the
@@ -164,15 +286,14 @@ export interface RegisterAgentClientArgs {
164
286
  * either by the user's interactive token (the natural bootstrap) or by
165
287
  * a pre-issued initial access token (`ORY_AGENT_REGISTRATION_TOKEN`).
166
288
  * Throws on any non-2xx response so callers can decide whether to
167
- * retry, fall back, or surface the error in the audit span. The
289
+ * retry, fall back, or surface the error in audit activity. The
168
290
  * `HTTP <status>` error message shape is preserved so callers and tests
169
291
  * can pattern-match on it regardless of the underlying transport.
170
292
  */
171
293
  export declare function registerAgentClient(args: RegisterAgentClientArgs): Promise<OryAgentDynamicCredentials>;
172
294
  /**
173
- * Resolve the agent's credentials from environment configuration and
174
- * persisted state. Never throws — failures collapse to `kind: "none"`
175
- * so the caller can fail open.
295
+ * Legacy OAuth/DCR resolver retained for source compatibility. Normal runtime
296
+ * gates use {@link resolveRuntimeAgentCredentials} instead.
176
297
  */
177
298
  export declare function resolveAgentCredentials(options?: ResolveAgentCredentialsOptions): Promise<AgentCredentials>;
178
299
  interface ClientCredentialsTokenArgs {
@@ -181,6 +302,7 @@ interface ClientCredentialsTokenArgs {
181
302
  clientSecret: string;
182
303
  audience?: string;
183
304
  scope?: string;
305
+ signal?: AbortSignal;
184
306
  }
185
307
  interface ClientCredentialsTokenResult {
186
308
  accessToken: string;
@@ -190,20 +312,47 @@ interface ClientCredentialsTokenResult {
190
312
  /** POST /oauth2/token with grant_type=client_credentials. */
191
313
  export declare function fetchClientCredentialsToken(args: ClientCredentialsTokenArgs): Promise<ClientCredentialsTokenResult>;
192
314
  export interface EnsureAgentIdentityOptions {
193
- /** Project URL for client_credentials grant + DCR. Defaults to resolveConfig(). */
315
+ /** Retained for source compatibility; runtime resolution uses the connected client. */
194
316
  projectUrl?: string;
195
- /** Harness identifier baked into a fresh DCR client_name. */
317
+ /** Retained for source compatibility and activity attribution. */
196
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;
197
330
  /** Env override (defaults to process.env). */
198
331
  env?: NodeJS.ProcessEnv;
199
332
  /** Inject resolver for tests. */
200
- 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;
201
350
  }
202
351
  /**
203
352
  * Resolve the agent's credentials and attach them to the client.
204
353
  *
205
354
  * Always returns the resolved credentials; never throws and never blocks.
206
- * 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
207
356
  * the agent identity was available for the session.
208
357
  */
209
358
  export declare function ensureAgentIdentity(client: OryAgentClient, options?: EnsureAgentIdentityOptions): Promise<AgentCredentials>;
@@ -211,19 +360,22 @@ export declare function ensureAgentIdentity(client: OryAgentClient, options?: En
211
360
  * Resolved identity for a sub-agent (a typed worker that the parent
212
361
  * agent delegates to, e.g. Claude Code's `Task` tool launching an
213
362
  * `Explore` sub-agent). The shape mirrors AgentCredentials but the
214
- * caller does not attach the token to the client sub-agent
215
- * credentials are recorded for the audit trail; they aren't injected
216
- * 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.
217
365
  */
218
366
  export interface SubAgentIdentity {
219
- /** "dynamic" once registered/loaded, "none" on any failure. */
220
- kind: "dynamic" | "none";
367
+ /** `runtime` in normal use; `dynamic` remains for injected legacy callers. */
368
+ kind: "runtime" | "dynamic" | "none";
221
369
  /** Sub-agent type as reported by the harness (e.g. "Explore"). */
222
370
  subAgentType: string;
223
371
  /** Issued client_id — also used as the audit subject for this sub-agent. */
224
372
  subject?: string;
373
+ /** Access token proving the reported sub-agent client id to the broker. */
374
+ token?: string;
225
375
  /** Persisted credentials returned by registration (or reloaded). */
226
376
  credentials?: OryAgentDynamicCredentials;
377
+ /** Child-owned credential used for delegation and subsequent child calls. */
378
+ runtimeCredential?: RuntimeCredential;
227
379
  /** One-line reason suitable for telemetry. */
228
380
  reason: string;
229
381
  /** Diagnostic warnings raised during resolution. */
@@ -232,35 +384,42 @@ export interface SubAgentIdentity {
232
384
  export interface EnsureSubAgentIdentityOptions {
233
385
  /** Sub-agent type identifier (e.g. "Explore", "general-purpose"). */
234
386
  subAgentType: string;
235
- /** Project URL for DCR. Defaults to resolveConfig(). */
387
+ /** Retained for source compatibility; no DCR request is made. */
236
388
  projectUrl?: string;
237
- /** Harness identifier baked into a fresh DCR client_name. */
389
+ /** Harness identifier used for activity and delegation context. */
238
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;
239
399
  /**
240
- * Bearer used as the IAT for the registration call. Defaults to the
241
- * parent agent's token (when populated) so the audit trail shows the
242
- * agent registering its sub-agent. Falls back to the user's token,
243
- * then `ORY_AGENT_REGISTRATION_TOKEN`.
400
+ * @deprecated Runtime sub-agent resolution never registers OAuth clients.
244
401
  */
245
402
  iat?: string;
246
403
  /** Env override (defaults to process.env). */
247
404
  env?: NodeJS.ProcessEnv;
248
- /** Inject the DCR registration call for tests. */
405
+ /** @deprecated Retained for source compatibility and never called. */
249
406
  registerAgentClientFn?: typeof registerAgentClient;
250
- /** Inject persistence for tests. */
407
+ /** @deprecated Retained for source compatibility and never called. */
251
408
  loadFn?: typeof loadSubAgentDynamicCredentials;
252
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;
253
418
  }
254
419
  /**
255
- * Resolve a sub-agent identity via OAuth2 Dynamic Client Registration.
256
- *
257
- * Reuses persisted credentials when the `(projectUrl, subAgentType)`
258
- * pair matches; otherwise registers a fresh client named
259
- * `Ory Agent Security · sub-agent · <harness>/<type> @ <host>` and persists the result.
260
- * Never throws and never blocks — on any failure the identity collapses
261
- * to `kind: "none"` and the plugin continues without it. Emits exactly
262
- * one `agent.auth` span so the audit trail records each sub-agent
263
- * 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.
264
423
  */
265
424
  export declare function ensureSubAgentIdentity(client: OryAgentClient, options: EnsureSubAgentIdentityOptions): Promise<SubAgentIdentity>;
266
425
  export {};