@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,232 +0,0 @@
1
- /**
2
- * Headless setup actions — the prompt-free, presentation-free core of the
3
- * install walkthrough, driven by the local web installer's JSON API (and
4
- * reusable anywhere the interactive TTY wizard's step *decisions* live outside
5
- * the process, e.g. in a browser).
6
- *
7
- * Each function performs exactly one step of the same flow the TTY wizard in
8
- * {@link file://./interactive-setup.ts} runs — sign in, pick / create a
9
- * workspace and project, enable DCR, provision the OAuth2 client, grant tool
10
- * permissions, provision the project API key — but returns a plain result
11
- * object instead of prompting or printing. The heavy lifting (CLI arg shapes,
12
- * OPL model inspection/merge, Console-API key minting) is imported from
13
- * `interactive-setup.ts` so there is a single source of truth for it; only the
14
- * thin, prompt-free orchestration lives here.
15
- *
16
- * Everything is fail-open: an action never throws for an expected failure
17
- * (CLI error, network blip, missing session) — it returns `{ ok: false }` with
18
- * a short message the UI can surface.
19
- */
20
- import { type OryCliRunner, type OryWorkspace, type OryProject, type PermissionModel, type LoginUiState } from "./interactive-setup.js";
21
- import { type CreateProjectApiKeyArgs, type ProjectApiKeyResult } from "./project-api-key.js";
22
- import { type PermissionMode } from "./config.js";
23
- import { ensureUserAuthenticated } from "./user-login.js";
24
- import { ensureAgentIdentity } from "./agent-auth.js";
25
- import { OryAgentClient } from "./client.js";
26
- import { type UserSubjectRef } from "./subject.js";
27
- import { ensureLocalOryStack, seedLocalEnvironment } from "./local/index.js";
28
- /** Injectable dependencies so the web API layer and tests can stub the CLI,
29
- * the login gates, the local stack, and the Console-API key minter. Mirrors
30
- * the subset of {@link InteractiveSetupDeps} the headless actions need. */
31
- export interface SetupActionDeps {
32
- runner?: OryCliRunner;
33
- installOryCliFn?: () => Promise<OryCliRunner | null>;
34
- clientFactory?: (harness: string) => OryAgentClient;
35
- userLoginFn?: typeof ensureUserAuthenticated;
36
- agentGateFn?: typeof ensureAgentIdentity;
37
- localStackFn?: typeof ensureLocalOryStack;
38
- seedFn?: typeof seedLocalEnvironment;
39
- createProjectApiKeyFn?: (args: CreateProjectApiKeyArgs) => Promise<ProjectApiKeyResult | null>;
40
- validateApiKeyFn?: (apiKey: string, projectUrl: string) => Promise<boolean>;
41
- }
42
- export declare function resolveNamespace(): string;
43
- export interface EnsureOryCliResult {
44
- present: boolean;
45
- installed: boolean;
46
- /** The runner to use for subsequent CLI actions, or null if unavailable. */
47
- runner: OryCliRunner | null;
48
- }
49
- /**
50
- * Ensure the `ory` CLI is available. Probes the default (or injected) runner;
51
- * if the binary isn't on `PATH`, installs `@ory/cli` into a plugin-managed dir
52
- * and returns a runner bound to it. Never throws.
53
- */
54
- export declare function ensureOryCli(deps?: SetupActionDeps): Promise<EnsureOryCliResult>;
55
- /** Whether the `ory` CLI already holds a valid Ory Network session. */
56
- export declare function isSignedIn(runner: OryCliRunner): boolean;
57
- export interface SignInHandle {
58
- /** Resolves to true when `ory auth` exits 0 (signed in), false otherwise. */
59
- done: Promise<boolean>;
60
- /** Best-effort cancel (kills the child). */
61
- cancel(): void;
62
- }
63
- /**
64
- * Launch the interactive `ory auth` browser sign-in as a detached child so the
65
- * HTTP server's event loop stays free (unlike `runner.exec`, which is
66
- * spawnSync). The Ory CLI opens its own browser window and runs a local
67
- * callback listener; we only watch its exit code. Returns a handle whose
68
- * `done` promise resolves when sign-in completes. Requires `runner.bin`.
69
- */
70
- export declare function startSignIn(runner: OryCliRunner): SignInHandle;
71
- export declare function listWorkspaces(runner: OryCliRunner): OryWorkspace[] | null;
72
- export interface CreateResult<T> {
73
- ok: boolean;
74
- value?: T;
75
- error?: string;
76
- }
77
- export declare function createWorkspace(runner: OryCliRunner, name: string): CreateResult<OryWorkspace>;
78
- export declare function listProjects(runner: OryCliRunner, workspaceId: string): OryProject[] | null;
79
- export declare function createProject(runner: OryCliRunner, workspaceId: string, name: string): CreateResult<OryProject>;
80
- /** Ory Network Developer-plan project cap per workspace. */
81
- export declare const PROJECT_CAP = 2;
82
- /**
83
- * Resolve a project's canonical SDK URL from its slug, refusing a missing slug
84
- * or one that is actually the project id (a UUID) — either would build a URL
85
- * that points nowhere.
86
- */
87
- export declare function resolveProjectUrl(project: OryProject): CreateResult<string>;
88
- /** Current DCR state: true/false when known, null when it couldn't be read. */
89
- export declare function getDcrState(runner: OryCliRunner, projectId: string): boolean | null;
90
- /** Enable DCR on the project. Returns true on success. */
91
- export declare function enableDcrAction(runner: OryCliRunner, projectId: string): boolean;
92
- /**
93
- * Ensure the project's OAuth2 login/consent UI works for a hosted browser
94
- * login. A CLI-created project defaults these to the `localhost:3000`
95
- * quickstart sample; this clears them so the Ory Managed Account Experience
96
- * renders the login instead. Returns the resulting state so the UI can report
97
- * it: `managed` (fixed or already managed), `custom_external` (a deliberate
98
- * custom UI, left as-is), or `unknown` (couldn't read the config).
99
- */
100
- export declare function ensureManagedLoginUi(runner: OryCliRunner, projectId: string): Exclude<LoginUiState, "loopback">;
101
- /**
102
- * Best-effort human-readable name for a signed-in identity, resolved via the
103
- * admin `ory` CLI (`ory get identity`). The PKCE login's id_token carries only
104
- * an opaque subject id under the default `openid` scope, so rather than show a
105
- * UUID we look the identity up by id and read a display trait (email → username
106
- * → name). Returns undefined on any CLI/parse failure so callers fall back to
107
- * the id.
108
- */
109
- export declare function resolveIdentityName(runner: OryCliRunner, projectId: string, subjectId: string): string | undefined;
110
- /**
111
- * Readable label for a signed-in user when naming a resource (e.g. a project
112
- * API key), so a shared project's resource list shows an email/username rather
113
- * than an opaque `user:<uuid>`. Looks the identity up via the admin CLI and
114
- * falls back to the subject label when no name resolves (no runner, or the
115
- * lookup fails). The raw subject id is read from either subject shape.
116
- */
117
- export declare function resourceUserLabel(runner: OryCliRunner | null | undefined, projectId: string, subject: UserSubjectRef): string;
118
- export interface OAuth2ClientResult {
119
- ok: boolean;
120
- clientId?: string;
121
- /** Human-readable client name (for display in place of the opaque id). */
122
- name: string;
123
- /** True when an existing plugin client was reused rather than created. */
124
- reused: boolean;
125
- }
126
- /**
127
- * Find or create the public PKCE OAuth2 client the user login needs. Reuses an
128
- * existing plugin-provisioned client on the project so a re-run never mints a
129
- * duplicate.
130
- */
131
- export declare function provisionOAuth2Client(runner: OryCliRunner, projectId: string): OAuth2ClientResult;
132
- /** Persist the resolved Ory Network connection and enable the user login. */
133
- export declare function saveNetworkConfig(input: {
134
- projectUrl: string;
135
- projectId: string;
136
- oauth2ClientId: string;
137
- projectName?: string;
138
- workspaceName?: string;
139
- }): void;
140
- export interface FullSetupResult {
141
- authenticated: boolean;
142
- /** The resolved permission subject label (e.g. `user:<id>`), or null. */
143
- subjectLabel: string | null;
144
- /** The resolved subject reference, for a follow-up permission grant. */
145
- subject: UserSubjectRef | null;
146
- }
147
- /** The project the wizard resolved this session, to pin the login against. */
148
- export interface FullSetupTarget {
149
- /** The selected SDK/project URL (authoritative for this install). */
150
- projectUrl?: string;
151
- /** The public OAuth2 client id the PKCE login should use. */
152
- oauth2ClientId?: string;
153
- }
154
- /**
155
- * Run the PKCE user login (opens a browser and awaits the loopback callback)
156
- * and resolve the agent DCR identity, so the next session is fully wired.
157
- * Best-effort: a declined or failed login just reports `authenticated: false`.
158
- *
159
- * `target` pins the project the wizard just selected. The login gate resolves
160
- * its URL/client id through `resolveConfig()`, which is **env-first** — so a
161
- * stale `ORY_PROJECT_URL` / `ORY_SDK_URL` / `ORY_OAUTH2_CLIENT_ID` left in the
162
- * user's shell (e.g. `http://localhost:3000` from a local app) would otherwise
163
- * override the project they just picked and launch the browser at the wrong
164
- * URL. During install the fresh selection is ground truth, so we pin it into
165
- * the environment for the login. (The process exits after install, so this
166
- * doesn't leak into a long-lived session.)
167
- */
168
- export declare function runFullSetup(binName: string, harness: string, deps?: SetupActionDeps, target?: FullSetupTarget): Promise<FullSetupResult>;
169
- export interface PermissionModelState {
170
- model: PermissionModel["kind"];
171
- /** OPL source when the model exists and can be merged (kind === "merge"). */
172
- opl?: string;
173
- }
174
- /** Inspect how the project's permission model relates to the namespace. */
175
- export declare function inspectPermissions(runner: OryCliRunner, projectId: string, namespace?: string): Promise<PermissionModelState>;
176
- /**
177
- * Provision (or merge) the namespace into the project's permission model.
178
- * Pass `opl` (from a prior `inspectPermissions` "merge" result) to append the
179
- * namespace non-destructively; omit it to create a fresh minimal model.
180
- */
181
- export declare function provisionPermissions(runner: OryCliRunner, projectId: string, namespace?: string, opl?: string): boolean;
182
- export interface GrantResult {
183
- ok: boolean;
184
- count: number;
185
- error?: string;
186
- }
187
- /**
188
- * Grant `<subject>` the `use` relation on every built-in tool by writing the
189
- * relation tuples through the admin-authenticated `ory` CLI. Assumes the
190
- * namespace already exists (call {@link inspectPermissions} /
191
- * {@link provisionPermissions} first).
192
- */
193
- export declare function grantToolPermissions(runner: OryCliRunner, projectId: string, harness: string, subject: UserSubjectRef, namespace?: string): GrantResult;
194
- export type ApiKeyStatus = "env" | "valid_existing" | "created" | "failed";
195
- export interface ApiKeyResult {
196
- status: ApiKeyStatus;
197
- }
198
- /**
199
- * Ensure a valid project API key is stored for runtime permission *checks*.
200
- * No-ops for an env-provided key; validates a stored key and re-mints if it is
201
- * dead; otherwise mints one via the Console API and persists it. Best-effort.
202
- */
203
- export declare function provisionProjectApiKey(input: {
204
- projectId: string;
205
- projectUrl: string;
206
- harness: string;
207
- user?: string;
208
- }, deps?: SetupActionDeps): Promise<ApiKeyResult>;
209
- /** Configure audit-only mode (no project, no auth, no checks). */
210
- export declare function configureAuditOnly(): void;
211
- /** Set the permission deny posture — `observe` (log) vs `enforce` (block). */
212
- export declare function setPermissionMode(mode: PermissionMode): void;
213
- export interface LocalStackResult {
214
- running: boolean;
215
- detail?: string;
216
- seeded: boolean;
217
- credentials?: {
218
- email: string;
219
- password: string;
220
- };
221
- seedError?: string;
222
- projectUrl: string;
223
- oauth2ClientId: string;
224
- subjectNamespace: string;
225
- }
226
- /**
227
- * Bring up and seed the local Ory stack, persisting the (stable) local
228
- * connection details regardless of whether Docker came up. Mirrors the TTY
229
- * wizard's local branch minus the login (the UI drives {@link runFullSetup}
230
- * separately). Best-effort throughout.
231
- */
232
- export declare function configureLocalStack(deps?: SetupActionDeps): Promise<LocalStackResult>;