@ory/argus 0.1.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 +134 -0
- package/assets/commands/local-down.md +19 -0
- package/assets/commands/local-up.md +27 -0
- package/assets/skills/auth-setup/SKILL.md +279 -0
- package/assets/skills/local-dev/SKILL.md +206 -0
- package/assets/skills/login-flow/SKILL.md +383 -0
- package/assets/skills/social-login/SKILL.md +312 -0
- package/dist/agent-auth.d.ts +204 -0
- package/dist/agent-auth.js +553 -0
- package/dist/auth-gate.d.ts +71 -0
- package/dist/auth-gate.js +308 -0
- package/dist/auth-store.d.ts +75 -0
- package/dist/auth-store.js +261 -0
- package/dist/auth.d.ts +93 -0
- package/dist/auth.js +323 -0
- package/dist/cli.d.ts +73 -0
- package/dist/cli.js +484 -0
- package/dist/client.d.ts +158 -0
- package/dist/client.js +679 -0
- package/dist/config.d.ts +135 -0
- package/dist/config.js +344 -0
- package/dist/denial.d.ts +79 -0
- package/dist/denial.js +103 -0
- package/dist/dev.d.ts +95 -0
- package/dist/dev.js +514 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +137 -0
- package/dist/local/cli.d.ts +12 -0
- package/dist/local/cli.js +95 -0
- package/dist/local/configs.d.ts +89 -0
- package/dist/local/configs.js +634 -0
- package/dist/local/health.d.ts +32 -0
- package/dist/local/health.js +65 -0
- package/dist/local/index.d.ts +6 -0
- package/dist/local/index.js +38 -0
- package/dist/local/jaeger-main.d.ts +13 -0
- package/dist/local/jaeger-main.js +85 -0
- package/dist/local/jaeger.d.ts +50 -0
- package/dist/local/jaeger.js +162 -0
- package/dist/local/main.d.ts +7 -0
- package/dist/local/main.js +14 -0
- package/dist/local/manager.d.ts +45 -0
- package/dist/local/manager.js +676 -0
- package/dist/local/seed.d.ts +71 -0
- package/dist/local/seed.js +237 -0
- package/dist/logger.d.ts +29 -0
- package/dist/logger.js +139 -0
- package/dist/mcp.d.ts +76 -0
- package/dist/mcp.js +122 -0
- package/dist/otel/exporter.d.ts +17 -0
- package/dist/otel/exporter.js +12 -0
- package/dist/otel/index.d.ts +2 -0
- package/dist/otel/index.js +8 -0
- package/dist/otel/otlp-http.d.ts +116 -0
- package/dist/otel/otlp-http.js +322 -0
- package/dist/registry/cli.d.ts +12 -0
- package/dist/registry/cli.js +76 -0
- package/dist/registry/config.d.ts +23 -0
- package/dist/registry/config.js +80 -0
- package/dist/registry/index.d.ts +3 -0
- package/dist/registry/index.js +21 -0
- package/dist/registry/main.d.ts +7 -0
- package/dist/registry/main.js +14 -0
- package/dist/registry/manager.d.ts +38 -0
- package/dist/registry/manager.js +674 -0
- package/dist/setup.d.ts +118 -0
- package/dist/setup.js +398 -0
- package/dist/skills.d.ts +78 -0
- package/dist/skills.js +264 -0
- package/dist/subject.d.ts +43 -0
- package/dist/subject.js +55 -0
- package/dist/tool-metadata.d.ts +41 -0
- package/dist/tool-metadata.js +127 -0
- package/dist/tracer.d.ts +172 -0
- package/dist/tracer.js +452 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.js +3 -0
- package/dist/watch-sandbox.d.ts +9 -0
- package/dist/watch-sandbox.js +81 -0
- package/package.json +79 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent identity resolution.
|
|
3
|
+
*
|
|
4
|
+
* The "agent" is the AI process making calls on behalf of the human
|
|
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.
|
|
11
|
+
*
|
|
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.
|
|
28
|
+
*/
|
|
29
|
+
import { type OryAgentDynamicCredentials } from "./config.js";
|
|
30
|
+
import { OryAgentClient } from "./client.js";
|
|
31
|
+
export type AgentCredentialKind = "api_key" | "client_credentials" | "dynamic" | "none";
|
|
32
|
+
export interface AgentCredentials {
|
|
33
|
+
kind: AgentCredentialKind;
|
|
34
|
+
/** Bearer token to attach to outgoing Ory API calls. */
|
|
35
|
+
token?: string;
|
|
36
|
+
/** Subject (sub) the token represents — usually the client_id. */
|
|
37
|
+
subject?: string;
|
|
38
|
+
/** Unix epoch seconds at which the token expires (client_credentials only). */
|
|
39
|
+
expiresAt?: number;
|
|
40
|
+
/**
|
|
41
|
+
* One-line reason for the resolved kind, suitable for telemetry.
|
|
42
|
+
* Distinguishes e.g. "no env credentials configured" vs "client_credentials
|
|
43
|
+
* grant failed: HTTP 401".
|
|
44
|
+
*/
|
|
45
|
+
reason: string;
|
|
46
|
+
/**
|
|
47
|
+
* Diagnostic warnings raised during resolution (e.g. ORY_API_KEY used
|
|
48
|
+
* via deprecated alias). Never blocks resolution.
|
|
49
|
+
*/
|
|
50
|
+
warnings: string[];
|
|
51
|
+
}
|
|
52
|
+
export interface ResolveAgentCredentialsOptions {
|
|
53
|
+
/** Ory project URL — required for client_credentials grant + DCR. */
|
|
54
|
+
projectUrl?: string;
|
|
55
|
+
/** Env override (defaults to process.env). */
|
|
56
|
+
env?: NodeJS.ProcessEnv;
|
|
57
|
+
/** User's bearer token; preferred IAT for dynamic registration. */
|
|
58
|
+
userToken?: string;
|
|
59
|
+
/** Harness identifier — baked into the registered client_name. */
|
|
60
|
+
harness?: string;
|
|
61
|
+
/** Inject the client_credentials token-grant function for tests. */
|
|
62
|
+
fetchClientCredentialsTokenFn?: typeof fetchClientCredentialsToken;
|
|
63
|
+
/** Inject the DCR registration call for tests. */
|
|
64
|
+
registerAgentClientFn?: typeof registerAgentClient;
|
|
65
|
+
/** Inject persisted-credential read/write/clear for tests. */
|
|
66
|
+
loadDynamicFn?: typeof loadAgentDynamicCredentials;
|
|
67
|
+
saveDynamicFn?: typeof saveAgentDynamicCredentials;
|
|
68
|
+
clearDynamicFn?: typeof clearAgentDynamicCredentials;
|
|
69
|
+
/** Bypass the in-memory cache (tests). */
|
|
70
|
+
skipCache?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Skew window before nominal expiry at which a cached client_credentials
|
|
74
|
+
* token is considered stale. Matches the user-token skew in auth-store.
|
|
75
|
+
*/
|
|
76
|
+
export declare const AGENT_TOKEN_EXPIRY_SKEW_SEC = 60;
|
|
77
|
+
/** Drop all cached agent client_credentials tokens. Tests only. */
|
|
78
|
+
export declare function _resetAgentCredentialsCache(): void;
|
|
79
|
+
/** Load persisted sub-agent DCR credentials keyed by sub-agent type. */
|
|
80
|
+
export declare function loadSubAgentDynamicCredentials(subAgentType: string): OryAgentDynamicCredentials | undefined;
|
|
81
|
+
/** Persist sub-agent DCR credentials under the given type key. */
|
|
82
|
+
export declare function saveSubAgentDynamicCredentials(subAgentType: string, creds: OryAgentDynamicCredentials): void;
|
|
83
|
+
/** Remove persisted sub-agent DCR credentials for the given type. */
|
|
84
|
+
export declare function clearSubAgentDynamicCredentials(subAgentType: string): void;
|
|
85
|
+
/** Load persisted DCR credentials from the shared config file. */
|
|
86
|
+
export declare function loadAgentDynamicCredentials(): OryAgentDynamicCredentials | undefined;
|
|
87
|
+
/** Persist DCR credentials. Existing credentials are replaced atomically. */
|
|
88
|
+
export declare function saveAgentDynamicCredentials(creds: OryAgentDynamicCredentials): void;
|
|
89
|
+
/** Remove persisted DCR credentials (e.g. after revocation or unregister). */
|
|
90
|
+
export declare function clearAgentDynamicCredentials(): void;
|
|
91
|
+
export interface RegisterAgentClientArgs {
|
|
92
|
+
projectUrl: string;
|
|
93
|
+
/** Bearer used as the initial access token (RFC 7591 §3). */
|
|
94
|
+
auth: string;
|
|
95
|
+
/** Harness identifier baked into the client_name for audit. */
|
|
96
|
+
harness?: string;
|
|
97
|
+
/** Override hostname for testing. */
|
|
98
|
+
hostnameFn?: () => string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Register a new OAuth2 client via RFC 7591. Authorization is carried
|
|
102
|
+
* either by the user's interactive token (the natural bootstrap) or by
|
|
103
|
+
* a pre-issued initial access token (`ORY_AGENT_REGISTRATION_TOKEN`).
|
|
104
|
+
* Throws on any non-2xx response so callers can decide whether to
|
|
105
|
+
* retry, fall back, or surface the error in the audit span. The
|
|
106
|
+
* `HTTP <status>` error message shape is preserved so callers and tests
|
|
107
|
+
* can pattern-match on it regardless of the underlying transport.
|
|
108
|
+
*/
|
|
109
|
+
export declare function registerAgentClient(args: RegisterAgentClientArgs): Promise<OryAgentDynamicCredentials>;
|
|
110
|
+
/**
|
|
111
|
+
* Resolve the agent's credentials from environment configuration and
|
|
112
|
+
* persisted state. Never throws — failures collapse to `kind: "none"`
|
|
113
|
+
* so the caller can fail open.
|
|
114
|
+
*/
|
|
115
|
+
export declare function resolveAgentCredentials(options?: ResolveAgentCredentialsOptions): Promise<AgentCredentials>;
|
|
116
|
+
interface ClientCredentialsTokenArgs {
|
|
117
|
+
projectUrl: string;
|
|
118
|
+
clientId: string;
|
|
119
|
+
clientSecret: string;
|
|
120
|
+
audience?: string;
|
|
121
|
+
scope?: string;
|
|
122
|
+
}
|
|
123
|
+
interface ClientCredentialsTokenResult {
|
|
124
|
+
accessToken: string;
|
|
125
|
+
expiresAt: number;
|
|
126
|
+
scope?: string;
|
|
127
|
+
}
|
|
128
|
+
/** POST /oauth2/token with grant_type=client_credentials. */
|
|
129
|
+
export declare function fetchClientCredentialsToken(args: ClientCredentialsTokenArgs): Promise<ClientCredentialsTokenResult>;
|
|
130
|
+
export interface EnsureAgentIdentityOptions {
|
|
131
|
+
/** Project URL for client_credentials grant + DCR. Defaults to resolveConfig(). */
|
|
132
|
+
projectUrl?: string;
|
|
133
|
+
/** Harness identifier baked into a fresh DCR client_name. */
|
|
134
|
+
harness?: string;
|
|
135
|
+
/** Env override (defaults to process.env). */
|
|
136
|
+
env?: NodeJS.ProcessEnv;
|
|
137
|
+
/** Inject resolver for tests. */
|
|
138
|
+
resolveFn?: typeof resolveAgentCredentials;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Resolve the agent's credentials and attach them to the client.
|
|
142
|
+
*
|
|
143
|
+
* Always returns the resolved credentials; never throws and never blocks.
|
|
144
|
+
* Emits exactly one `agent.auth` span so the audit trail records whether
|
|
145
|
+
* the agent identity was available for the session.
|
|
146
|
+
*/
|
|
147
|
+
export declare function ensureAgentIdentity(client: OryAgentClient, options?: EnsureAgentIdentityOptions): Promise<AgentCredentials>;
|
|
148
|
+
/**
|
|
149
|
+
* Resolved identity for a sub-agent (a typed worker that the parent
|
|
150
|
+
* agent delegates to, e.g. Claude Code's `Task` tool launching an
|
|
151
|
+
* `Explore` sub-agent). The shape mirrors AgentCredentials but the
|
|
152
|
+
* caller does not attach the token to the client — sub-agent
|
|
153
|
+
* credentials are recorded for the audit trail; they aren't injected
|
|
154
|
+
* into the harness's child process.
|
|
155
|
+
*/
|
|
156
|
+
export interface SubAgentIdentity {
|
|
157
|
+
/** "dynamic" once registered/loaded, "none" on any failure. */
|
|
158
|
+
kind: "dynamic" | "none";
|
|
159
|
+
/** Sub-agent type as reported by the harness (e.g. "Explore"). */
|
|
160
|
+
subAgentType: string;
|
|
161
|
+
/** Issued client_id — also used as the audit subject for this sub-agent. */
|
|
162
|
+
subject?: string;
|
|
163
|
+
/** Persisted credentials returned by registration (or reloaded). */
|
|
164
|
+
credentials?: OryAgentDynamicCredentials;
|
|
165
|
+
/** One-line reason suitable for telemetry. */
|
|
166
|
+
reason: string;
|
|
167
|
+
/** Diagnostic warnings raised during resolution. */
|
|
168
|
+
warnings: string[];
|
|
169
|
+
}
|
|
170
|
+
export interface EnsureSubAgentIdentityOptions {
|
|
171
|
+
/** Sub-agent type identifier (e.g. "Explore", "general-purpose"). */
|
|
172
|
+
subAgentType: string;
|
|
173
|
+
/** Project URL for DCR. Defaults to resolveConfig(). */
|
|
174
|
+
projectUrl?: string;
|
|
175
|
+
/** Harness identifier baked into a fresh DCR client_name. */
|
|
176
|
+
harness?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Bearer used as the IAT for the registration call. Defaults to the
|
|
179
|
+
* parent agent's token (when populated) so the audit trail shows the
|
|
180
|
+
* agent registering its sub-agent. Falls back to the user's token,
|
|
181
|
+
* then `ORY_AGENT_REGISTRATION_TOKEN`.
|
|
182
|
+
*/
|
|
183
|
+
iat?: string;
|
|
184
|
+
/** Env override (defaults to process.env). */
|
|
185
|
+
env?: NodeJS.ProcessEnv;
|
|
186
|
+
/** Inject the DCR registration call for tests. */
|
|
187
|
+
registerAgentClientFn?: typeof registerAgentClient;
|
|
188
|
+
/** Inject persistence for tests. */
|
|
189
|
+
loadFn?: typeof loadSubAgentDynamicCredentials;
|
|
190
|
+
saveFn?: typeof saveSubAgentDynamicCredentials;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Resolve a sub-agent identity via OAuth2 Dynamic Client Registration.
|
|
194
|
+
*
|
|
195
|
+
* Reuses persisted credentials when the `(projectUrl, subAgentType)`
|
|
196
|
+
* pair matches; otherwise registers a fresh client with
|
|
197
|
+
* `client_name = ory-subagent-<type>@<host>` and persists the result.
|
|
198
|
+
* Never throws and never blocks — on any failure the identity collapses
|
|
199
|
+
* to `kind: "none"` and the plugin continues without it. Emits exactly
|
|
200
|
+
* one `agent.auth` span so the audit trail records each sub-agent
|
|
201
|
+
* resolution.
|
|
202
|
+
*/
|
|
203
|
+
export declare function ensureSubAgentIdentity(client: OryAgentClient, options: EnsureSubAgentIdentityOptions): Promise<SubAgentIdentity>;
|
|
204
|
+
export {};
|