@ory/argus 0.14.0 → 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 (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 +408 -0
  90. package/dist/runtime.js +748 -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
@@ -1,286 +0,0 @@
1
- /**
2
- * Interactive install wizard. Runs after a harness plugin has been
3
- * registered, stepping the user through connecting the plugin to Ory:
4
- *
5
- * 1. Choose a connection: **Ory Network** (browser login / account
6
- * creation) or **local / audit-only** (no project, audit logging only).
7
- * 2. Ory Network branch: shell out to the official `ory` CLI to log in,
8
- * pick a workspace, pick a project (→ `projectUrl`), and create the
9
- * public OAuth2 client the PKCE user login needs (→ `oauth2ClientId`).
10
- * 3. Persist the resolved values to the shared config file and enable the
11
- * interactive user login.
12
- * 4. Best-effort "full setup": run the PKCE user login now (we hold the
13
- * project URL + client id), resolve the agent DCR identity, and let the
14
- * caller bootstrap permissions from the freshly-cached user identity.
15
- *
16
- * The whole wizard is **fail-open and skippable**: on a missing TTY, a
17
- * `--no-configure` flag, a declined reconfigure prompt on an already-configured
18
- * plugin, a missing `ory` CLI, or any `ory` failure it prints the manual
19
- * `configure` instructions and returns without throwing. Install must never
20
- * crash because setup was declined or the network was unreachable.
21
- *
22
- * The Ory Network integration deliberately reuses the official `ory` CLI
23
- * rather than re-implementing the Console API: the CLI already owns Network
24
- * browser login + account creation, workspace/project listing, and OAuth2
25
- * client creation, and the client it creates is exactly the one the plugin
26
- * READMEs document for manual setup. The one exception is minting the project
27
- * API key that runtime permission checks need — the CLI exposes no command for
28
- * it, so that single step calls the Console API directly, reusing the CLI's
29
- * stored session for auth (see {@link createProjectApiKeyViaConsole}).
30
- */
31
- import { OryAgentClient } from "./client.js";
32
- import { ensureUserAuthenticated } from "./user-login.js";
33
- import { ensureAgentIdentity } from "./agent-auth.js";
34
- import { ensureLocalOryStack, seedLocalEnvironment } from "./local/index.js";
35
- import { type CreateProjectApiKeyArgs, type ProjectApiKeyResult } from "./project-api-key.js";
36
- /** Loopback redirect URIs the PKCE user login expects on the OAuth2 client. */
37
- export declare const LOOPBACK_REDIRECT_URIS: readonly string[];
38
- /** Result of running a captured `ory` command. */
39
- export interface OryExecResult {
40
- /** Exit code; `null` when the process could not be spawned (CLI missing). */
41
- status: number | null;
42
- stdout: string;
43
- stderr: string;
44
- }
45
- /**
46
- * Thin, injectable wrapper around the `ory` binary. Tests stub this to drive
47
- * the wizard without a real CLI; the default implementation shells out.
48
- */
49
- export interface OryCliRunner {
50
- /** Run `ory <args>` capturing stdout/stderr. `opts.input` is written to
51
- * the child's stdin (used to feed JSON to `ory create relationships -f -`). */
52
- exec(args: string[], opts?: {
53
- input?: string;
54
- }): OryExecResult;
55
- /** Run `ory <args>` inheriting the terminal (for the browser login). */
56
- execInteractive(args: string[]): number;
57
- /**
58
- * The resolved `ory` binary this runner invokes (a bare command on `PATH`, or
59
- * an absolute path to a plugin-installed binary). Exposed so the web installer
60
- * can spawn the interactive browser sign-in (`ory auth`) as a detached child
61
- * without blocking the HTTP server's event loop the way `exec` (spawnSync)
62
- * would. Absent on stub runners injected by tests.
63
- */
64
- bin?: string;
65
- }
66
- /**
67
- * Build a runner bound to a specific `ory` binary (a bare command resolved on
68
- * `PATH`, or an absolute path to a plugin-installed binary). {@link defaultRunner}
69
- * uses the bare `"ory"`; {@link installOryCli} returns one bound to the binary
70
- * it just installed.
71
- */
72
- export declare function createOryRunner(oryBin: string): OryCliRunner;
73
- /**
74
- * npm spec for the Ory CLI installed on demand when the `ory` binary isn't on
75
- * `PATH`. `@ory/cli` ships the platform `ory` binary and exposes it as its
76
- * `bin`, so an isolated `npm install` gives us a working CLI without touching
77
- * the user's global environment. Pinned to a major to stay reproducible while
78
- * still picking up patch/minor fixes.
79
- */
80
- export declare const ORY_CLI_NPM_SPEC = "@ory/cli@^1";
81
- /**
82
- * Best-effort install of the Ory CLI into a plugin-managed directory under the
83
- * shared data dir, returning a runner bound to the installed binary (or null
84
- * on any failure). Uses `npm install --prefix` so nothing global is modified;
85
- * the binary lands at `<dataDir>/cli/node_modules/.bin/ory`. Never throws.
86
- */
87
- export declare function installOryCli(): Promise<OryCliRunner | null>;
88
- export interface InteractiveSetupDeps {
89
- runner?: OryCliRunner;
90
- isTtyAvailableFn?: () => boolean;
91
- promptFn?: (prompt: string) => Promise<string | null>;
92
- clientFactory?: (harness: string) => OryAgentClient;
93
- userLoginFn?: typeof ensureUserAuthenticated;
94
- agentGateFn?: typeof ensureAgentIdentity;
95
- /** Injectable local-stack bring-up (defaults to {@link ensureLocalOryStack}). */
96
- localStackFn?: typeof ensureLocalOryStack;
97
- /** Injectable local-stack seeder (defaults to {@link seedLocalEnvironment}). */
98
- seedFn?: typeof seedLocalEnvironment;
99
- /**
100
- * Injectable Ory-CLI installer used when the `ory` binary isn't on `PATH`.
101
- * Returns a runner bound to the installed binary, or null if the install
102
- * failed. Defaults to a real `npm install` of {@link ORY_CLI_NPM_SPEC}.
103
- */
104
- installOryCliFn?: () => Promise<OryCliRunner | null>;
105
- /**
106
- * Injectable project-API-key minter. Returns the minted `{ value, id }` or
107
- * null on any failure. Defaults to {@link createProjectApiKeyViaConsole} (Ory
108
- * Console API, authenticated with the `ory` CLI's stored session). Tests stub
109
- * this to avoid real HTTP.
110
- */
111
- createProjectApiKeyFn?: (args: CreateProjectApiKeyArgs) => Promise<ProjectApiKeyResult | null>;
112
- /**
113
- * Injectable validity probe for an already-stored project API key. Returns
114
- * true when the key still authenticates against Keto, false when it's been
115
- * revoked/deleted (so provisioning re-mints one). Defaults to
116
- * {@link apiKeyAuthenticates}. Tests stub this to avoid real HTTP.
117
- */
118
- validateApiKeyFn?: (apiKey: string, projectUrl: string) => Promise<boolean>;
119
- }
120
- export type InteractiveSetupOutcome = "skipped_flag" | "skipped_no_tty" | "skipped_configured" | "audit_only" | "local_configured" | "network_configured" | "network_fallback";
121
- export interface InteractiveSetupResult {
122
- outcome: InteractiveSetupOutcome;
123
- projectUrl?: string;
124
- oauth2ClientId?: string;
125
- /** Whether a user identity was authenticated during the wizard. */
126
- userAuthenticated?: boolean;
127
- /**
128
- * When true, the caller should NOT run the DCR-token-based
129
- * {@link maybeAutoBootstrap}. The wizard bootstraps permissions itself via
130
- * the admin-authenticated `ory` CLI on the Ory Network path — the runtime
131
- * agent/user tokens can't write relation tuples on a hosted project, so
132
- * running maybeAutoBootstrap there would only produce 403s.
133
- */
134
- skipAutoBootstrap?: boolean;
135
- }
136
- /**
137
- * The shared post-install entry point every harness's `install` command
138
- * calls. Runs the interactive setup wizard, then (using whatever identity the
139
- * wizard cached) bootstraps permissions and prints the onboarding banner.
140
- *
141
- * This is the single seam that centralizes what each harness previously
142
- * open-coded as a local `postInstallPermissions` helper.
143
- */
144
- export declare function runPostInstall(binName: string, harness: string, args?: string[], deps?: InteractiveSetupDeps): Promise<void>;
145
- export interface OryWorkspace {
146
- id: string;
147
- name?: string;
148
- }
149
- export interface OryProject {
150
- id: string;
151
- name?: string;
152
- slug?: string;
153
- }
154
- /**
155
- * Run the interactive setup wizard. Always resolves; never throws.
156
- */
157
- export declare function runInteractiveSetup(binName: string, harness: string, args?: string[], deps?: InteractiveSetupDeps): Promise<InteractiveSetupResult>;
158
- /**
159
- * How the project's permission model relates to the namespace we need:
160
- *
161
- * - `present` — the namespace is already defined; grant directly.
162
- * - `empty` — the project has no model at all (a fresh Ory Network project
163
- * reports this as `null`, an absent key, an empty list, or an
164
- * empty `location`); provisioning a minimal model is safe.
165
- * - `merge` — a model exists and its OPL *source* was fetched (carries it
166
- * in `opl`), but doesn't define our namespace; we append the
167
- * namespace to that source and re-upload it, leaving the other
168
- * namespaces intact.
169
- * - `blocked` — a model provably exists but its source couldn't be retrieved
170
- * (fetch failed, or only compiled namespace *names* are exposed
171
- * with no source), so we can't merge and mustn't overwrite.
172
- * - `unknown` — the config couldn't be read/parsed at all; treated as `empty`
173
- * by the caller (provision a fresh minimal model, prompted).
174
- */
175
- export type PermissionModel = {
176
- kind: "present";
177
- } | {
178
- kind: "empty";
179
- } | {
180
- kind: "merge";
181
- opl: string;
182
- } | {
183
- kind: "blocked";
184
- } | {
185
- kind: "unknown";
186
- };
187
- /**
188
- * Inspect the project's permission model. Ory Network reports the config in one
189
- * of two shapes: `{ namespaces: [] }` (or `null`) for a project with no model,
190
- * and `{ namespaces: { location: "https://….txt" } }` for an OPL-configured
191
- * one — where the `.txt` is the full OPL *source*. We fetch that source so a
192
- * missing namespace can be merged in rather than clobbering the whole model.
193
- */
194
- export declare function inspectPermissionModel(runner: OryCliRunner, projectId: string, namespace: string): Promise<PermissionModel>;
195
- /**
196
- * Provision a permission model that defines `<namespace>` with a `use`
197
- * relation, via `ory update opl`. The namespace becomes an OPL class, so it
198
- * must be a valid identifier; if not, we bail (caller guides instead).
199
- *
200
- * When `existingOpl` is given, the namespace is appended to that source
201
- * (preserving the model's other namespaces); otherwise a fresh minimal model
202
- * is generated. Writes the OPL to a temp file because `ory update opl` reads
203
- * `--file` only (no stdin). Returns true on success.
204
- */
205
- export declare function provisionPermissionModel(runner: OryCliRunner, projectId: string, namespace: string, existingOpl?: string): boolean;
206
- export declare function oryCliPresent(runner: OryCliRunner): boolean;
207
- export declare function listProjects(runner: OryCliRunner, workspaceId: string): OryProject[] | null;
208
- /**
209
- * Read the project's current DCR state via `ory get oauth2-config`.
210
- * Returns `true`/`false` when the value is known, or `null` when it can't be
211
- * determined (CLI error, unparseable output) so the caller falls open and
212
- * prompts anyway rather than assuming a state.
213
- */
214
- export declare function dcrEnabled(runner: OryCliRunner, projectId: string): boolean | null;
215
- /**
216
- * Patch the project's oauth2-config to enable Dynamic Client Registration.
217
- * Prompt-free; returns true on success. Shared by the TTY wizard's
218
- * {@link maybeEnableDcr} and the web installer API.
219
- */
220
- export declare function enableDcr(runner: OryCliRunner, projectId: string): boolean;
221
- /** How a project's browser-login UI (across both configs) is currently wired. */
222
- export type LoginUiState = "managed" | "loopback" | "custom_external" | "unknown";
223
- /**
224
- * Classify the project's browser-login UI across the identity-config
225
- * (self-service) and oauth2-config (login/consent) URLs:
226
- * - `loopback` — at least one URL points at a `localhost` sample (needs fixing).
227
- * - `custom_external` — a deliberate custom UI is set and none are loopback.
228
- * - `managed` — everything is empty / relative / on the managed AX.
229
- * - `unknown` — neither config could be read.
230
- */
231
- export declare function projectLoginUiState(runner: OryCliRunner, projectId: string): LoginUiState;
232
- /**
233
- * Point the project's browser-login UI at the Ory Managed Account Experience by
234
- * clearing any loopback (localhost sample) URLs in *both* the identity-config
235
- * (self-service flows) and the oauth2-config (login/consent). Clearing a UI URL
236
- * makes Ory Network fall back to the managed AX. Best-effort; returns true when
237
- * the patches succeeded (or there was nothing to clear). Never touches a
238
- * deliberate non-loopback custom UI.
239
- */
240
- export declare function useManagedAccountExperience(runner: OryCliRunner, projectId: string): boolean;
241
- /**
242
- * Enable OAuth2 Dynamic Client Registration on the project so the agent
243
- * identity can self-register (RFC 7591) at runtime. First probes the project's
244
- * current DCR state and skips silently when it's already enabled. Otherwise
245
- * prompts (default yes) since it changes project-wide config; best-effort and
246
- * fail-open — a decline or failure just prints the manual command and continues.
247
- */
248
- /**
249
- * Look for an already-provisioned public PKCE client on the project so a
250
- * re-run — or another user installing against the same shared project — reuses
251
- * the one client instead of minting a duplicate. Matches the current
252
- * {@link USER_LOGIN_CLIENT_NAME} *and* any legacy name an older install may
253
- * have used, so a rename never orphans a still-valid client. Best-effort: any
254
- * CLI or parse failure returns null and the caller falls back to creating one.
255
- */
256
- export declare function findExistingOAuth2Client(runner: OryCliRunner, projectId: string): string | null;
257
- export declare function createOAuth2Client(runner: OryCliRunner, projectId: string): string | null;
258
- /**
259
- * Parse a JSON list from `ory --format json` output. Tolerates both a bare
260
- * array and the `{ <key>: [...] }` envelope the Console list endpoints use.
261
- */
262
- export declare function parseList<T>(stdout: string, key: string): T[] | null;
263
- export declare function parseObject<T>(stdout: string): T | null;
264
- /**
265
- * Derive the canonical Ory Network project SDK/API URL from a project **slug**.
266
- * The subdomain is always the slug — never the project id. A project id (a
267
- * UUID) reaching here means a slug and an id were confused upstream, which
268
- * would build a URL that points nowhere, so we refuse it loudly rather than
269
- * silently misconfigure the plugin.
270
- */
271
- export declare function projectUrlFromSlug(slug: string): string;
272
- /**
273
- * A project URL on a loopback host is the self-hosted local stack (the dev
274
- * launcher's gateway on localhost), not a hosted Ory Network project — so the
275
- * "Mode" summary should read "local stack" for it.
276
- */
277
- export declare function isLocalProjectUrl(url: string | undefined): boolean;
278
- /**
279
- * Best-effort check that an already-stored project API key still authenticates
280
- * against Keto. Runs one permission check with the key: if it completes (any
281
- * `allowed` value) the key is valid; an auth rejection (`session_inactive` /
282
- * `forbidden` / `session_aal2_required`) means it was revoked or deleted, so we
283
- * return false and the caller re-provisions. Transient failures (network /
284
- * rate-limit / unknown) return true so we don't re-mint on a blip. Never throws.
285
- */
286
- export declare function apiKeyAuthenticates(apiKey: string, projectUrl: string): Promise<boolean>;