@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.
- package/README.md +31 -46
- package/assets/commands/temporal-up.md +1 -1
- package/assets/skills/auth-setup/SKILL.md +1 -1
- package/assets/skills/local-dev/SKILL.md +17 -7
- package/assets/skills/ory-build-agent/SKILL.md +39 -91
- package/assets/skills/ory-e2b-sandbox/SKILL.md +18 -17
- package/assets/skills/ory-temporal-worker/SKILL.md +31 -33
- package/assets/skills/permissions-onboarding/SKILL.md +131 -104
- package/dist/adapters.d.ts +88 -32
- package/dist/adapters.js +443 -164
- package/dist/agent-auth.d.ts +226 -67
- package/dist/agent-auth.js +951 -205
- package/dist/auth-store.d.ts +37 -2
- package/dist/auth-store.js +37 -3
- package/dist/auth.d.ts +33 -4
- package/dist/auth.js +163 -20
- package/dist/bash-parser.d.ts +98 -0
- package/dist/bash-parser.js +396 -0
- package/dist/branding.d.ts +77 -16
- package/dist/branding.js +93 -23
- package/dist/build-info.json +4 -4
- package/dist/cli-invocation.d.ts +1 -1
- package/dist/cli-invocation.js +2 -1
- package/dist/cli.d.ts +20 -29
- package/dist/cli.js +271 -239
- package/dist/client.d.ts +175 -138
- package/dist/client.js +672 -391
- package/dist/config.d.ts +217 -54
- package/dist/config.js +461 -42
- package/dist/context.d.ts +10 -0
- package/dist/context.js +21 -0
- package/dist/contract-suite.d.ts +3 -5
- package/dist/contract-suite.js +75 -47
- package/dist/denial.d.ts +36 -3
- package/dist/denial.js +79 -10
- package/dist/event-reporter.d.ts +77 -0
- package/dist/event-reporter.js +776 -0
- package/dist/external-registrations-main.d.ts +10 -0
- package/dist/external-registrations-main.js +38 -0
- package/dist/external-registrations.d.ts +79 -0
- package/dist/external-registrations.js +188 -0
- package/dist/help-cli.d.ts +39 -0
- package/dist/help-cli.js +55 -0
- package/dist/hook-timeout.d.ts +64 -0
- package/dist/hook-timeout.js +88 -0
- package/dist/index.d.ts +28 -23
- package/dist/index.js +173 -58
- package/dist/lifecycle.d.ts +3 -3
- package/dist/lifecycle.js +38 -6
- package/dist/local/cli.js +11 -6
- package/dist/local/configs.d.ts +74 -18
- package/dist/local/configs.js +291 -84
- package/dist/local/health.js +7 -7
- package/dist/local/index.d.ts +2 -2
- package/dist/local/index.js +24 -10
- package/dist/local/manager.d.ts +20 -1
- package/dist/local/manager.js +159 -36
- package/dist/local/ports.d.ts +158 -0
- package/dist/local/ports.js +443 -0
- package/dist/local/seed.d.ts +13 -5
- package/dist/local/seed.js +62 -38
- package/dist/logger.d.ts +54 -25
- package/dist/logger.js +329 -63
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +10 -5
- package/dist/mirror-bootstrap.d.ts +48 -0
- package/dist/mirror-bootstrap.js +254 -0
- package/dist/opl.d.ts +289 -0
- package/dist/opl.js +446 -0
- package/dist/permission-mode.d.ts +87 -0
- package/dist/permission-mode.js +307 -0
- package/dist/permissions-cli.d.ts +13 -49
- package/dist/permissions-cli.js +154 -348
- package/dist/permissions.d.ts +148 -38
- package/dist/permissions.js +591 -45
- package/dist/post-install.d.ts +33 -0
- package/dist/post-install.js +127 -0
- package/dist/read-credential.d.ts +65 -0
- package/dist/read-credential.js +86 -0
- package/dist/registry/cli.js +5 -2
- package/dist/registry/config.d.ts +0 -17
- package/dist/registry/config.js +0 -23
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/index.js +2 -2
- package/dist/registry/manager.d.ts +4 -21
- package/dist/registry/manager.js +21 -37
- package/dist/runtime-credential.d.ts +140 -0
- package/dist/runtime-credential.js +572 -0
- package/dist/runtime.d.ts +408 -0
- package/dist/runtime.js +748 -0
- package/dist/setup.d.ts +23 -47
- package/dist/setup.js +59 -116
- package/dist/skills.js +0 -7
- package/dist/status-cli.d.ts +27 -11
- package/dist/status-cli.js +121 -115
- package/dist/status-data.d.ts +116 -17
- package/dist/status-data.js +121 -38
- package/dist/subject.d.ts +126 -20
- package/dist/subject.js +215 -30
- package/dist/testing.d.ts +74 -38
- package/dist/testing.js +185 -68
- package/dist/tool-catalog.d.ts +53 -11
- package/dist/tool-catalog.js +164 -13
- package/dist/tool-metadata.d.ts +7 -6
- package/dist/tool-metadata.js +6 -5
- package/dist/types.d.ts +11 -1
- package/dist/uninstall.d.ts +71 -34
- package/dist/uninstall.js +217 -85
- package/dist/user-login.d.ts +9 -10
- package/dist/user-login.js +56 -75
- package/dist/watch-cli.d.ts +6 -0
- package/dist/watch-cli.js +217 -0
- package/package.json +4 -27
- package/assets/commands/dashboard.md +0 -34
- package/dist/dashboard-cli.d.ts +0 -8
- package/dist/dashboard-cli.js +0 -70
- package/dist/dev.d.ts +0 -103
- package/dist/dev.js +0 -583
- package/dist/interactive-setup.d.ts +0 -286
- package/dist/interactive-setup.js +0 -1734
- package/dist/local/jaeger-main.d.ts +0 -13
- package/dist/local/jaeger-main.js +0 -85
- package/dist/local/jaeger.d.ts +0 -50
- package/dist/local/jaeger.js +0 -162
- package/dist/otel/exporter.d.ts +0 -17
- package/dist/otel/exporter.js +0 -12
- package/dist/otel/index.d.ts +0 -2
- package/dist/otel/index.js +0 -8
- package/dist/otel/otlp.d.ts +0 -103
- package/dist/otel/otlp.js +0 -385
- package/dist/project-api-key.d.ts +0 -69
- package/dist/project-api-key.js +0 -147
- package/dist/setup-actions.d.ts +0 -232
- package/dist/setup-actions.js +0 -507
- package/dist/tracer.d.ts +0 -190
- package/dist/tracer.js +0 -481
- package/dist/watch-sandbox.d.ts +0 -9
- package/dist/watch-sandbox.js +0 -81
- package/dist/web/api.d.ts +0 -33
- package/dist/web/api.js +0 -294
- package/dist/web/launch.d.ts +0 -11
- package/dist/web/launch.js +0 -96
- package/dist/web/server.d.ts +0 -20
- package/dist/web/server.js +0 -233
- package/dist/web/types.d.ts +0 -65
- package/dist/web/types.js +0 -2
- package/dist/webapp/assets/index-Wucl4SZs.css +0 -1
- package/dist/webapp/assets/index-m-GtEdq0.js +0 -49
- package/dist/webapp/favicon.ico +0 -0
- package/dist/webapp/index.html +0 -15
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared post-install step every harness's `install` command runs.
|
|
3
|
+
*
|
|
4
|
+
* Every install wires the same **developer-experience** surface: the Ory
|
|
5
|
+
* skills and commands, the local Ory stack, the MCP server, and local activity logging.
|
|
6
|
+
* None of that needs an Ory project, so none of it is optional or configurable
|
|
7
|
+
* here — it is simply what installing the plugin gives you.
|
|
8
|
+
*
|
|
9
|
+
* On top of that sits **Ory Agent Security** — user sign-in, permission checks
|
|
10
|
+
* on every tool call, and delegation recording. It runs only when the install
|
|
11
|
+
* has an Ory project URL. The broker and public OAuth2 client id default to the
|
|
12
|
+
* production Agent Security origin and reserved login client; explicit flags
|
|
13
|
+
* select staging, local, or custom deployments. Pass the project URL to
|
|
14
|
+
* `install` (or `configure` later) and the next session signs in and starts
|
|
15
|
+
* checking; leave it out and the
|
|
16
|
+
* plugin logs activity locally and gates nothing. Nothing else changes either way.
|
|
17
|
+
*
|
|
18
|
+
* Everything *else* an Ory project needs to serve Agent Security — the login
|
|
19
|
+
* OAuth2 client, the permission model, the per-tool grants, explicit blocks,
|
|
20
|
+
* and the observe/enforce posture — is provisioned in the **Ory Console**
|
|
21
|
+
* (Agent Security), by someone with access to the project. The plugin never
|
|
22
|
+
* writes project configuration, which is why installing it needs only a
|
|
23
|
+
* project URL and no workspace privilege at all.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Apply the install's connection intent and print the closing summary.
|
|
27
|
+
*
|
|
28
|
+
* With no connection flags the plugin installs with Agent Security simply not
|
|
29
|
+
* connected. With any of them it delegates to {@link runConfigureCommand},
|
|
30
|
+
* which validates the project URL and any explicit broker override exactly as
|
|
31
|
+
* a bare `configure` would.
|
|
32
|
+
*/
|
|
33
|
+
export declare function runPostInstall(binName: string, _harness: string, args?: string[]): Promise<void>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The shared post-install step every harness's `install` command runs.
|
|
4
|
+
*
|
|
5
|
+
* Every install wires the same **developer-experience** surface: the Ory
|
|
6
|
+
* skills and commands, the local Ory stack, the MCP server, and local activity logging.
|
|
7
|
+
* None of that needs an Ory project, so none of it is optional or configurable
|
|
8
|
+
* here — it is simply what installing the plugin gives you.
|
|
9
|
+
*
|
|
10
|
+
* On top of that sits **Ory Agent Security** — user sign-in, permission checks
|
|
11
|
+
* on every tool call, and delegation recording. It runs only when the install
|
|
12
|
+
* has an Ory project URL. The broker and public OAuth2 client id default to the
|
|
13
|
+
* production Agent Security origin and reserved login client; explicit flags
|
|
14
|
+
* select staging, local, or custom deployments. Pass the project URL to
|
|
15
|
+
* `install` (or `configure` later) and the next session signs in and starts
|
|
16
|
+
* checking; leave it out and the
|
|
17
|
+
* plugin logs activity locally and gates nothing. Nothing else changes either way.
|
|
18
|
+
*
|
|
19
|
+
* Everything *else* an Ory project needs to serve Agent Security — the login
|
|
20
|
+
* OAuth2 client, the permission model, the per-tool grants, explicit blocks,
|
|
21
|
+
* and the observe/enforce posture — is provisioned in the **Ory Console**
|
|
22
|
+
* (Agent Security), by someone with access to the project. The plugin never
|
|
23
|
+
* writes project configuration, which is why installing it needs only a
|
|
24
|
+
* project URL and no workspace privilege at all.
|
|
25
|
+
*/
|
|
26
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
27
|
+
if (k2 === undefined) k2 = k;
|
|
28
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
29
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
30
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(o, k2, desc);
|
|
33
|
+
}) : (function(o, m, k, k2) {
|
|
34
|
+
if (k2 === undefined) k2 = k;
|
|
35
|
+
o[k2] = m[k];
|
|
36
|
+
}));
|
|
37
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
38
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
39
|
+
}) : function(o, v) {
|
|
40
|
+
o["default"] = v;
|
|
41
|
+
});
|
|
42
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
43
|
+
var ownKeys = function(o) {
|
|
44
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
45
|
+
var ar = [];
|
|
46
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
47
|
+
return ar;
|
|
48
|
+
};
|
|
49
|
+
return ownKeys(o);
|
|
50
|
+
};
|
|
51
|
+
return function (mod) {
|
|
52
|
+
if (mod && mod.__esModule) return mod;
|
|
53
|
+
var result = {};
|
|
54
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
55
|
+
__setModuleDefault(result, mod);
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
})();
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.runPostInstall = runPostInstall;
|
|
61
|
+
const config_js_1 = require("./config.js");
|
|
62
|
+
const cli_js_1 = require("./cli.js");
|
|
63
|
+
const setup_js_1 = require("./setup.js");
|
|
64
|
+
const version_cli_js_1 = require("./version-cli.js");
|
|
65
|
+
const ui = __importStar(require("./ui.js"));
|
|
66
|
+
/**
|
|
67
|
+
* The `configure` connection flags `install` also accepts, so a single
|
|
68
|
+
* `install --project-url … --agent-security-url …` both registers the plugin and
|
|
69
|
+
* connects it to Ory Agent Security. Presence of any of these hands the
|
|
70
|
+
* post-install step off to `configure`, which owns the validation.
|
|
71
|
+
*/
|
|
72
|
+
const CONFIGURE_FLAGS = [
|
|
73
|
+
"--project-url",
|
|
74
|
+
"--sdk-url",
|
|
75
|
+
"--project-id",
|
|
76
|
+
"--agent-security-url",
|
|
77
|
+
"--oauth2-client-id",
|
|
78
|
+
"--disconnect",
|
|
79
|
+
"--user-subject-namespace",
|
|
80
|
+
"--no-user-subject-namespace",
|
|
81
|
+
];
|
|
82
|
+
function hasConfigureFlag(args) {
|
|
83
|
+
return args.some((a) => CONFIGURE_FLAGS.includes(a));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Apply the install's connection intent and print the closing summary.
|
|
87
|
+
*
|
|
88
|
+
* With no connection flags the plugin installs with Agent Security simply not
|
|
89
|
+
* connected. With any of them it delegates to {@link runConfigureCommand},
|
|
90
|
+
* which validates the project URL and any explicit broker override exactly as
|
|
91
|
+
* a bare `configure` would.
|
|
92
|
+
*/
|
|
93
|
+
async function runPostInstall(binName, _harness, args = []) {
|
|
94
|
+
// Surface the running CLI version up front. `npx -p @ory/<harness>` (no
|
|
95
|
+
// version pin) will happily reuse a previously-cached install rather than
|
|
96
|
+
// re-resolve to latest, so a user can silently be running an old CLI while
|
|
97
|
+
// believing they're on the current release. Printing the version makes that
|
|
98
|
+
// mismatch visible at a glance; the README's troubleshooting note explains
|
|
99
|
+
// how to clear a stale npx cache.
|
|
100
|
+
const cliVersion = (0, version_cli_js_1.resolveCoreVersion)();
|
|
101
|
+
if (cliVersion !== "unknown") {
|
|
102
|
+
ui.info(`${binName} v${cliVersion}`);
|
|
103
|
+
}
|
|
104
|
+
if (hasConfigureFlag(args)) {
|
|
105
|
+
(0, cli_js_1.runConfigureCommand)(binName, args);
|
|
106
|
+
}
|
|
107
|
+
ui.blank();
|
|
108
|
+
const security = (0, config_js_1.resolveConfig)().security;
|
|
109
|
+
ui.success("Installed.");
|
|
110
|
+
ui.hint("Skills, commands, the local Ory stack, the MCP server, and activity logging are ready to use.");
|
|
111
|
+
ui.blank();
|
|
112
|
+
if (security.connected) {
|
|
113
|
+
ui.success("Ory Agent Security is connected.");
|
|
114
|
+
ui.hint("Sign-in and permission checks run on the next session.");
|
|
115
|
+
ui.hint("Tool grants, explicit blocks, and the observe/enforce posture are managed in the Ory Console (Agent Security).");
|
|
116
|
+
ui.hint(`Inspect what this machine resolves with \`${binName} permissions status\`.`);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
ui.hint(`Ory Agent Security is not connected (${(0, config_js_1.describeSecurityGap)(security)}) — no sign-in, no permission checks.`);
|
|
120
|
+
ui.hint(`Connect it any time with \`${binName} configure --project-url <URL>\`.`);
|
|
121
|
+
ui.hint("Get the project URL from the Ory Console; pass --agent-security-url to override the production broker.");
|
|
122
|
+
}
|
|
123
|
+
// Flush the harness's deferred next-steps as the closing summary. `true`
|
|
124
|
+
// selects the short "you're set — start the harness" renderer (which reads
|
|
125
|
+
// the resolved mode) rather than the manual Ory env-var wall.
|
|
126
|
+
(0, setup_js_1.emitDeferredNextSteps)(true);
|
|
127
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make sure the client holds the agent credential required by the canonical
|
|
3
|
+
* permission broker before a read goes out.
|
|
4
|
+
*
|
|
5
|
+
* ## Why this exists
|
|
6
|
+
*
|
|
7
|
+
* Permission, mode, and event reads require a noninteractive runtime
|
|
8
|
+
* credential. This helper resolves only the process-local/injected credential
|
|
9
|
+
* path and never starts user interaction or falls back to OAuth/DCR state. It
|
|
10
|
+
* remains cheap to call for every read and preserves existing fail-open error
|
|
11
|
+
* classification when no credential is available.
|
|
12
|
+
*/
|
|
13
|
+
import { OryAgentClient } from "./client.js";
|
|
14
|
+
import { ensureAgentIdentity } from "./agent-auth.js";
|
|
15
|
+
export interface EnsureReadCredentialOptions {
|
|
16
|
+
/** Harness whose install credential to resolve. Defaults to `client.harness`. */
|
|
17
|
+
harness?: string;
|
|
18
|
+
/** Inject the agent gate for tests. */
|
|
19
|
+
agentGate?: typeof ensureAgentIdentity;
|
|
20
|
+
/** Injectable clock for the failed-attempt backoff (tests). */
|
|
21
|
+
now?: number;
|
|
22
|
+
/** Abort network work when the caller's latency budget expires. */
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
/** Retained for call-site compatibility; runtime resolution never uses DCR. */
|
|
25
|
+
allowRegistration?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* How long a *failed* resolution suppresses another attempt on the same client.
|
|
29
|
+
*
|
|
30
|
+
* A success needs no backoff — the token is on the client and every later call
|
|
31
|
+
* returns at the `present` check. A failure would otherwise be retried by each
|
|
32
|
+
* read path of each gate (the mode probe and the tool check, at least), so one
|
|
33
|
+
* unreachable token endpoint would mean several grant attempts per tool call.
|
|
34
|
+
* Short enough that a long-lived in-process session still recovers on its own
|
|
35
|
+
* once the endpoint comes back.
|
|
36
|
+
*/
|
|
37
|
+
export declare const READ_CREDENTIAL_RETRY_MS = 30000;
|
|
38
|
+
/** Drop the failed-attempt backoff. Test-only (reassigns the WeakMap). */
|
|
39
|
+
export declare function resetReadCredentialBackoff(): void;
|
|
40
|
+
export type ReadCredentialOutcome =
|
|
41
|
+
/** Agent Security isn't connected; there is nothing to authenticate against. */
|
|
42
|
+
{
|
|
43
|
+
kind: "not_connected";
|
|
44
|
+
}
|
|
45
|
+
/** The agent credential was already in hand. */
|
|
46
|
+
| {
|
|
47
|
+
kind: "present";
|
|
48
|
+
principal: "agent";
|
|
49
|
+
}
|
|
50
|
+
/** The agent identity was resolved for this read. */
|
|
51
|
+
| {
|
|
52
|
+
kind: "resolved";
|
|
53
|
+
}
|
|
54
|
+
/** No agent credential could be resolved; the read will classify locally. */
|
|
55
|
+
| {
|
|
56
|
+
kind: "unavailable";
|
|
57
|
+
reason?: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Resolve an Agent Security broker credential onto `client` if needed.
|
|
61
|
+
*
|
|
62
|
+
* Idempotent and cheap to call repeatedly: the first call in a process resolves,
|
|
63
|
+
* the rest see the principal already populated and return immediately.
|
|
64
|
+
*/
|
|
65
|
+
export declare function ensureReadCredential(client: OryAgentClient, options?: EnsureReadCredentialOptions): Promise<ReadCredentialOutcome>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Make sure the client holds the agent credential required by the canonical
|
|
4
|
+
* permission broker before a read goes out.
|
|
5
|
+
*
|
|
6
|
+
* ## Why this exists
|
|
7
|
+
*
|
|
8
|
+
* Permission, mode, and event reads require a noninteractive runtime
|
|
9
|
+
* credential. This helper resolves only the process-local/injected credential
|
|
10
|
+
* path and never starts user interaction or falls back to OAuth/DCR state. It
|
|
11
|
+
* remains cheap to call for every read and preserves existing fail-open error
|
|
12
|
+
* classification when no credential is available.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.READ_CREDENTIAL_RETRY_MS = void 0;
|
|
16
|
+
exports.resetReadCredentialBackoff = resetReadCredentialBackoff;
|
|
17
|
+
exports.ensureReadCredential = ensureReadCredential;
|
|
18
|
+
const config_js_1 = require("./config.js");
|
|
19
|
+
const agent_auth_js_1 = require("./agent-auth.js");
|
|
20
|
+
/**
|
|
21
|
+
* How long a *failed* resolution suppresses another attempt on the same client.
|
|
22
|
+
*
|
|
23
|
+
* A success needs no backoff — the token is on the client and every later call
|
|
24
|
+
* returns at the `present` check. A failure would otherwise be retried by each
|
|
25
|
+
* read path of each gate (the mode probe and the tool check, at least), so one
|
|
26
|
+
* unreachable token endpoint would mean several grant attempts per tool call.
|
|
27
|
+
* Short enough that a long-lived in-process session still recovers on its own
|
|
28
|
+
* once the endpoint comes back.
|
|
29
|
+
*/
|
|
30
|
+
exports.READ_CREDENTIAL_RETRY_MS = 30_000;
|
|
31
|
+
/** Last failed attempt per client and session. WeakMap keeps finished clients collectable. */
|
|
32
|
+
let lastFailure = new WeakMap();
|
|
33
|
+
/** Drop the failed-attempt backoff. Test-only (reassigns the WeakMap). */
|
|
34
|
+
function resetReadCredentialBackoff() {
|
|
35
|
+
lastFailure = new WeakMap();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve an Agent Security broker credential onto `client` if needed.
|
|
39
|
+
*
|
|
40
|
+
* Idempotent and cheap to call repeatedly: the first call in a process resolves,
|
|
41
|
+
* the rest see the principal already populated and return immediately.
|
|
42
|
+
*/
|
|
43
|
+
async function ensureReadCredential(client, options = {}) {
|
|
44
|
+
// Nothing is connected, so nothing is read and there is nothing to
|
|
45
|
+
// authenticate. Mirrors the gates' own not_connected short-circuit.
|
|
46
|
+
const resolved = (0, config_js_1.resolveConfig)();
|
|
47
|
+
if (!resolved.security.connected)
|
|
48
|
+
return { kind: "not_connected" };
|
|
49
|
+
// The broker requires the machine bearer, so this is the whole goal.
|
|
50
|
+
if (client.hasRuntimeCredential)
|
|
51
|
+
return { kind: "present", principal: "agent" };
|
|
52
|
+
const now = options.now ?? Date.now();
|
|
53
|
+
const sessionId = client.sessionId;
|
|
54
|
+
const sessionKey = sessionId?.trim() || "sessionless";
|
|
55
|
+
const failures = lastFailure.get(client);
|
|
56
|
+
const failedAt = failures?.get(sessionKey);
|
|
57
|
+
if (failedAt !== undefined && now - failedAt < exports.READ_CREDENTIAL_RETRY_MS) {
|
|
58
|
+
return { kind: "unavailable", reason: "a recent resolution attempt failed" };
|
|
59
|
+
}
|
|
60
|
+
const gate = options.agentGate ?? agent_auth_js_1.ensureAgentIdentity;
|
|
61
|
+
const creds = await gate(client, {
|
|
62
|
+
projectUrl: resolved.projectUrl,
|
|
63
|
+
harness: options.harness ?? client.harness,
|
|
64
|
+
sessionId,
|
|
65
|
+
// Tool-path call: skip the migration revoke queue (session start owns it —
|
|
66
|
+
// a queue of RFC 7592 deletes must not add latency to a gate) and label the
|
|
67
|
+
// activity so an auditor can tell this resolution from the session-start one.
|
|
68
|
+
drainRetired: false,
|
|
69
|
+
trigger: "read_credential",
|
|
70
|
+
signal: options.signal,
|
|
71
|
+
allowRegistration: options.allowRegistration,
|
|
72
|
+
}).catch((err) => {
|
|
73
|
+
// `ensureAgentIdentity` already swallows its own failures; this is only for
|
|
74
|
+
// a caller-injected gate that throws.
|
|
75
|
+
client.logger.warn("read_credential.failed", {
|
|
76
|
+
message: err instanceof Error ? err.message : String(err),
|
|
77
|
+
});
|
|
78
|
+
return undefined;
|
|
79
|
+
});
|
|
80
|
+
if (creds?.runtimeCredential || creds?.token)
|
|
81
|
+
return { kind: "resolved" };
|
|
82
|
+
const updatedFailures = failures ?? new Map();
|
|
83
|
+
updatedFailures.set(sessionKey, now);
|
|
84
|
+
lastFailure.set(client, updatedFailures);
|
|
85
|
+
return { kind: "unavailable", ...(creds?.reason ? { reason: creds.reason } : {}) };
|
|
86
|
+
}
|
package/dist/registry/cli.js
CHANGED
|
@@ -16,6 +16,9 @@ const manager_js_1 = require("./manager.js");
|
|
|
16
16
|
async function runRegistryCommand(binName, args) {
|
|
17
17
|
const [subcommand] = args;
|
|
18
18
|
switch (subcommand) {
|
|
19
|
+
case "dev":
|
|
20
|
+
await (0, manager_js_1.registryDev)();
|
|
21
|
+
break;
|
|
19
22
|
case "start":
|
|
20
23
|
await (0, manager_js_1.registryStart)();
|
|
21
24
|
break;
|
|
@@ -54,6 +57,7 @@ Usage:
|
|
|
54
57
|
${binName} registry <command>
|
|
55
58
|
|
|
56
59
|
Commands:
|
|
60
|
+
dev Start the registry and publish all workspace packages
|
|
57
61
|
start Start the local Verdaccio npm registry (Docker container)
|
|
58
62
|
stop Stop the running registry
|
|
59
63
|
status Show registry status and published packages
|
|
@@ -67,8 +71,7 @@ on the host, bind-mounted into the container. Everything is ephemeral —
|
|
|
67
71
|
'clean' removes both the container and the on-disk data.
|
|
68
72
|
|
|
69
73
|
Workflow:
|
|
70
|
-
${binName} registry
|
|
71
|
-
${binName} registry publish # Build and publish all packages
|
|
74
|
+
${binName} registry dev # Start and publish all packages
|
|
72
75
|
npm install --registry http://localhost:4873 @ory/claude-code
|
|
73
76
|
${binName} registry stop # Stop when done
|
|
74
77
|
${binName} registry clean # Remove all data
|
|
@@ -21,20 +21,3 @@ export declare const REGISTRY_CONTAINER_STORAGE = "/verdaccio/storage";
|
|
|
21
21
|
export declare const REGISTRY_CONTAINER_CONFIG = "/verdaccio/conf/config.yaml";
|
|
22
22
|
export declare function verdaccioConfigYaml(): string;
|
|
23
23
|
export declare function npmrcContent(): string;
|
|
24
|
-
/**
|
|
25
|
-
* Userconfig file used by the dev launcher's npm/npx subprocesses.
|
|
26
|
-
*
|
|
27
|
-
* The scope-specific `@ory:registry=…` line is the critical bit. If a
|
|
28
|
-
* developer has ever run `npm login --scope=@ory` (or otherwise pinned
|
|
29
|
-
* `@ory:registry` in their `~/.npmrc`) to publish or fetch from npmjs.org,
|
|
30
|
-
* that pin takes precedence over `--registry` / `npm_config_registry` for
|
|
31
|
-
* scoped packages — so the launcher's `npm install @ory/<harness>` and the
|
|
32
|
-
* harness's own runtime `npx -y -p @ory/<harness>` calls silently hit
|
|
33
|
-
* npmjs.org instead of localhost, producing either `ENOVERSIONS` (because
|
|
34
|
-
* npmjs's manifest doesn't list the just-bumped local version) or a tarball
|
|
35
|
-
* sha512 mismatch (when the local manifest is consulted but npmjs serves
|
|
36
|
-
* the bytes). We expose this file as `npm_config_userconfig` so it
|
|
37
|
-
* displaces `~/.npmrc` entirely for subprocesses the launcher spawns,
|
|
38
|
-
* without modifying any global config or polluting the sandbox.
|
|
39
|
-
*/
|
|
40
|
-
export declare function launcherNpmrcContent(): string;
|
package/dist/registry/config.js
CHANGED
|
@@ -13,7 +13,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.REGISTRY_CONTAINER_CONFIG = exports.REGISTRY_CONTAINER_STORAGE = exports.REGISTRY_CONTAINER = exports.REGISTRY_IMAGE = exports.REGISTRY_DIR_NAME = exports.REGISTRY_URL = exports.REGISTRY_PORT = void 0;
|
|
14
14
|
exports.verdaccioConfigYaml = verdaccioConfigYaml;
|
|
15
15
|
exports.npmrcContent = npmrcContent;
|
|
16
|
-
exports.launcherNpmrcContent = launcherNpmrcContent;
|
|
17
16
|
exports.REGISTRY_PORT = 4873;
|
|
18
17
|
exports.REGISTRY_URL = `http://localhost:${exports.REGISTRY_PORT}`;
|
|
19
18
|
exports.REGISTRY_DIR_NAME = ".ory-dev/registry";
|
|
@@ -90,29 +89,7 @@ log:
|
|
|
90
89
|
}
|
|
91
90
|
function npmrcContent() {
|
|
92
91
|
return `registry=${exports.REGISTRY_URL}/
|
|
93
|
-
//localhost:${exports.REGISTRY_PORT}/:_authToken=local-dev-token
|
|
94
|
-
`;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Userconfig file used by the dev launcher's npm/npx subprocesses.
|
|
98
|
-
*
|
|
99
|
-
* The scope-specific `@ory:registry=…` line is the critical bit. If a
|
|
100
|
-
* developer has ever run `npm login --scope=@ory` (or otherwise pinned
|
|
101
|
-
* `@ory:registry` in their `~/.npmrc`) to publish or fetch from npmjs.org,
|
|
102
|
-
* that pin takes precedence over `--registry` / `npm_config_registry` for
|
|
103
|
-
* scoped packages — so the launcher's `npm install @ory/<harness>` and the
|
|
104
|
-
* harness's own runtime `npx -y -p @ory/<harness>` calls silently hit
|
|
105
|
-
* npmjs.org instead of localhost, producing either `ENOVERSIONS` (because
|
|
106
|
-
* npmjs's manifest doesn't list the just-bumped local version) or a tarball
|
|
107
|
-
* sha512 mismatch (when the local manifest is consulted but npmjs serves
|
|
108
|
-
* the bytes). We expose this file as `npm_config_userconfig` so it
|
|
109
|
-
* displaces `~/.npmrc` entirely for subprocesses the launcher spawns,
|
|
110
|
-
* without modifying any global config or polluting the sandbox.
|
|
111
|
-
*/
|
|
112
|
-
function launcherNpmrcContent() {
|
|
113
|
-
return `registry=${exports.REGISTRY_URL}/
|
|
114
92
|
@ory:registry=${exports.REGISTRY_URL}/
|
|
115
|
-
//localhost:${exports.REGISTRY_PORT}/:_authToken=local-dev-token
|
|
116
93
|
min-release-age=0
|
|
117
94
|
`;
|
|
118
95
|
}
|
package/dist/registry/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { runRegistryCommand } from "./cli.js";
|
|
2
|
-
export { registryStart, registryStop, registryStatus, registryPublish, registryClean, registryNpmrc, ensureRegistryRunning,
|
|
2
|
+
export { registryStart, registryStop, registryStatus, registryPublish, registryDev, registryClean, registryNpmrc, ensureRegistryRunning, getLocalRegistryNpmCacheDir, } from "./manager.js";
|
|
3
3
|
export { REGISTRY_PORT, REGISTRY_URL, REGISTRY_DIR_NAME, REGISTRY_IMAGE, REGISTRY_CONTAINER, } from "./config.js";
|
package/dist/registry/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REGISTRY_CONTAINER = exports.REGISTRY_IMAGE = exports.REGISTRY_DIR_NAME = exports.REGISTRY_URL = exports.REGISTRY_PORT = exports.getLocalRegistryNpmCacheDir = exports.
|
|
3
|
+
exports.REGISTRY_CONTAINER = exports.REGISTRY_IMAGE = exports.REGISTRY_DIR_NAME = exports.REGISTRY_URL = exports.REGISTRY_PORT = exports.getLocalRegistryNpmCacheDir = exports.ensureRegistryRunning = exports.registryNpmrc = exports.registryClean = exports.registryDev = exports.registryPublish = exports.registryStatus = exports.registryStop = exports.registryStart = exports.runRegistryCommand = void 0;
|
|
4
4
|
var cli_js_1 = require("./cli.js");
|
|
5
5
|
Object.defineProperty(exports, "runRegistryCommand", { enumerable: true, get: function () { return cli_js_1.runRegistryCommand; } });
|
|
6
6
|
var manager_js_1 = require("./manager.js");
|
|
@@ -8,10 +8,10 @@ Object.defineProperty(exports, "registryStart", { enumerable: true, get: functio
|
|
|
8
8
|
Object.defineProperty(exports, "registryStop", { enumerable: true, get: function () { return manager_js_1.registryStop; } });
|
|
9
9
|
Object.defineProperty(exports, "registryStatus", { enumerable: true, get: function () { return manager_js_1.registryStatus; } });
|
|
10
10
|
Object.defineProperty(exports, "registryPublish", { enumerable: true, get: function () { return manager_js_1.registryPublish; } });
|
|
11
|
+
Object.defineProperty(exports, "registryDev", { enumerable: true, get: function () { return manager_js_1.registryDev; } });
|
|
11
12
|
Object.defineProperty(exports, "registryClean", { enumerable: true, get: function () { return manager_js_1.registryClean; } });
|
|
12
13
|
Object.defineProperty(exports, "registryNpmrc", { enumerable: true, get: function () { return manager_js_1.registryNpmrc; } });
|
|
13
14
|
Object.defineProperty(exports, "ensureRegistryRunning", { enumerable: true, get: function () { return manager_js_1.ensureRegistryRunning; } });
|
|
14
|
-
Object.defineProperty(exports, "publishHarnessToLocal", { enumerable: true, get: function () { return manager_js_1.publishHarnessToLocal; } });
|
|
15
15
|
Object.defineProperty(exports, "getLocalRegistryNpmCacheDir", { enumerable: true, get: function () { return manager_js_1.getLocalRegistryNpmCacheDir; } });
|
|
16
16
|
var config_js_1 = require("./config.js");
|
|
17
17
|
Object.defineProperty(exports, "REGISTRY_PORT", { enumerable: true, get: function () { return config_js_1.REGISTRY_PORT; } });
|
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
* container is started with `--rm` and all state lives under
|
|
7
7
|
* `.ory-dev/registry/` on the host, bind-mounted into the container.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* idempotent start, removal via `docker rm -f`.
|
|
9
|
+
* Uses one detached, auto-removed container with idempotent startup and
|
|
10
|
+
* removal via `docker rm -f`.
|
|
12
11
|
*/
|
|
13
12
|
/**
|
|
14
13
|
* Per-registry npm cache directory.
|
|
@@ -19,31 +18,15 @@
|
|
|
19
18
|
* pnpm publish/npm install even after we drop the version from Verdaccio.
|
|
20
19
|
*/
|
|
21
20
|
export declare function getLocalRegistryNpmCacheDir(): string;
|
|
22
|
-
/**
|
|
23
|
-
* Path to the userconfig npmrc the dev launcher hands to its subprocesses.
|
|
24
|
-
* See `launcherNpmrcContent` in `./config.ts` for why this exists.
|
|
25
|
-
*/
|
|
26
|
-
export declare function getLauncherNpmrcPath(): string;
|
|
27
|
-
/**
|
|
28
|
-
* Materialize the launcher userconfig npmrc on disk and return its path.
|
|
29
|
-
* Idempotent: rewrites the file every call so any drift in the rendered
|
|
30
|
-
* content (e.g. registry URL change) lands without a clean-and-restart.
|
|
31
|
-
*/
|
|
32
|
-
export declare function ensureLauncherNpmrc(): string;
|
|
33
21
|
/**
|
|
34
22
|
* Start the local registry if it isn't already running.
|
|
35
23
|
*/
|
|
36
24
|
export declare function ensureRegistryRunning(): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Publish all `@ory/*` packages to the local registry — entrypoint used by
|
|
39
|
-
* the dev launcher. The `harnessName` arg is retained for call-site
|
|
40
|
-
* compatibility; we publish the whole scope every time so any harness gets
|
|
41
|
-
* a coherent registry state without needing to compute its dep closure.
|
|
42
|
-
*/
|
|
43
|
-
export declare function publishHarnessToLocal(_harnessName: string): Promise<void>;
|
|
44
25
|
export declare function registryStart(): Promise<void>;
|
|
45
26
|
export declare function registryStop(): Promise<void>;
|
|
46
27
|
export declare function registryStatus(): Promise<void>;
|
|
47
28
|
export declare function registryPublish(): Promise<void>;
|
|
29
|
+
/** Start the local registry and publish a coherent development package set. */
|
|
30
|
+
export declare function registryDev(): Promise<void>;
|
|
48
31
|
export declare function registryClean(): Promise<void>;
|
|
49
32
|
export declare function registryNpmrc(): Promise<void>;
|
package/dist/registry/manager.js
CHANGED
|
@@ -7,9 +7,8 @@
|
|
|
7
7
|
* container is started with `--rm` and all state lives under
|
|
8
8
|
* `.ory-dev/registry/` on the host, bind-mounted into the container.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* idempotent start, removal via `docker rm -f`.
|
|
10
|
+
* Uses one detached, auto-removed container with idempotent startup and
|
|
11
|
+
* removal via `docker rm -f`.
|
|
13
12
|
*/
|
|
14
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
14
|
if (k2 === undefined) k2 = k;
|
|
@@ -46,14 +45,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
46
45
|
})();
|
|
47
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
47
|
exports.getLocalRegistryNpmCacheDir = getLocalRegistryNpmCacheDir;
|
|
49
|
-
exports.getLauncherNpmrcPath = getLauncherNpmrcPath;
|
|
50
|
-
exports.ensureLauncherNpmrc = ensureLauncherNpmrc;
|
|
51
48
|
exports.ensureRegistryRunning = ensureRegistryRunning;
|
|
52
|
-
exports.publishHarnessToLocal = publishHarnessToLocal;
|
|
53
49
|
exports.registryStart = registryStart;
|
|
54
50
|
exports.registryStop = registryStop;
|
|
55
51
|
exports.registryStatus = registryStatus;
|
|
56
52
|
exports.registryPublish = registryPublish;
|
|
53
|
+
exports.registryDev = registryDev;
|
|
57
54
|
exports.registryClean = registryClean;
|
|
58
55
|
exports.registryNpmrc = registryNpmrc;
|
|
59
56
|
const fs = __importStar(require("node:fs"));
|
|
@@ -86,29 +83,15 @@ function getRegistryDir() {
|
|
|
86
83
|
function getLocalRegistryNpmCacheDir() {
|
|
87
84
|
return path.join(getRegistryDir(), "npm-cache");
|
|
88
85
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Path to the userconfig npmrc the dev launcher hands to its subprocesses.
|
|
91
|
-
* See `launcherNpmrcContent` in `./config.ts` for why this exists.
|
|
92
|
-
*/
|
|
93
|
-
function getLauncherNpmrcPath() {
|
|
94
|
-
return path.join(getRegistryDir(), "launcher.npmrc");
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Materialize the launcher userconfig npmrc on disk and return its path.
|
|
98
|
-
* Idempotent: rewrites the file every call so any drift in the rendered
|
|
99
|
-
* content (e.g. registry URL change) lands without a clean-and-restart.
|
|
100
|
-
*/
|
|
101
|
-
function ensureLauncherNpmrc() {
|
|
102
|
-
const npmrcPath = getLauncherNpmrcPath();
|
|
103
|
-
ensureDir(path.dirname(npmrcPath));
|
|
104
|
-
fs.writeFileSync(npmrcPath, (0, config_js_1.launcherNpmrcContent)());
|
|
105
|
-
return npmrcPath;
|
|
106
|
-
}
|
|
107
86
|
function ensureDir(dir) {
|
|
108
87
|
if (!fs.existsSync(dir)) {
|
|
109
88
|
fs.mkdirSync(dir, { recursive: true });
|
|
110
89
|
}
|
|
111
90
|
}
|
|
91
|
+
function writeRegistryNpmrc(registryDir) {
|
|
92
|
+
ensureDir(registryDir);
|
|
93
|
+
fs.writeFileSync(path.join(registryDir, ".npmrc"), (0, config_js_1.npmrcContent)());
|
|
94
|
+
}
|
|
112
95
|
function listWorkspaceScopedPackages(workspaceRoot) {
|
|
113
96
|
return listWorkspaceScopedPackageJsons(workspaceRoot)
|
|
114
97
|
.map((file) => readPackageName(file))
|
|
@@ -412,9 +395,10 @@ async function ensureConfigInSync(quiet) {
|
|
|
412
395
|
* Start the local registry if it isn't already running.
|
|
413
396
|
*/
|
|
414
397
|
async function ensureRegistryRunning() {
|
|
415
|
-
if (isRegistryRunning())
|
|
416
|
-
|
|
417
|
-
|
|
398
|
+
if (!isRegistryRunning()) {
|
|
399
|
+
await registryStart();
|
|
400
|
+
}
|
|
401
|
+
writeRegistryNpmrc(getRegistryDir());
|
|
418
402
|
}
|
|
419
403
|
/**
|
|
420
404
|
* Env vars stripped before invoking the per-package publish, mirroring the
|
|
@@ -597,20 +581,12 @@ function emitCapturedOutput(quiet, label, result) {
|
|
|
597
581
|
function stripScheme(url) {
|
|
598
582
|
return url.replace(/^https?:\/\//, "");
|
|
599
583
|
}
|
|
600
|
-
/**
|
|
601
|
-
* Publish all `@ory/*` packages to the local registry — entrypoint used by
|
|
602
|
-
* the dev launcher. The `harnessName` arg is retained for call-site
|
|
603
|
-
* compatibility; we publish the whole scope every time so any harness gets
|
|
604
|
-
* a coherent registry state without needing to compute its dep closure.
|
|
605
|
-
*/
|
|
606
|
-
async function publishHarnessToLocal(_harnessName) {
|
|
607
|
-
await publishAllOryToLocal({ quiet: true });
|
|
608
|
-
}
|
|
609
584
|
// ─── Commands ──────────────────────────────────────────────────────
|
|
610
585
|
async function registryStart() {
|
|
611
586
|
const registryDir = getRegistryDir();
|
|
612
587
|
const storageDir = path.join(registryDir, "storage");
|
|
613
588
|
if (isRegistryRunning()) {
|
|
589
|
+
writeRegistryNpmrc(registryDir);
|
|
614
590
|
console.log(`Local registry is already running (container ${config_js_1.REGISTRY_CONTAINER}).`);
|
|
615
591
|
console.log(` URL: ${config_js_1.REGISTRY_URL}`);
|
|
616
592
|
return;
|
|
@@ -642,7 +618,7 @@ async function registryStart() {
|
|
|
642
618
|
const configPath = path.join(registryDir, "config.yaml");
|
|
643
619
|
fs.writeFileSync(configPath, (0, config_js_1.verdaccioConfigYaml)());
|
|
644
620
|
// .npmrc is consumed by host-side npm/pnpm tooling, not by the container.
|
|
645
|
-
|
|
621
|
+
writeRegistryNpmrc(registryDir);
|
|
646
622
|
// Stale --rm container could only exist if Docker died mid-run; clean it up
|
|
647
623
|
// so the new `docker run --rm` doesn't collide on the container name.
|
|
648
624
|
const state = inspectContainer(config_js_1.REGISTRY_CONTAINER);
|
|
@@ -798,6 +774,14 @@ async function registryPublish() {
|
|
|
798
774
|
console.log("");
|
|
799
775
|
console.log("Published.");
|
|
800
776
|
}
|
|
777
|
+
/** Start the local registry and publish a coherent development package set. */
|
|
778
|
+
async function registryDev() {
|
|
779
|
+
await ensureRegistryRunning();
|
|
780
|
+
await registryPublish();
|
|
781
|
+
console.log("");
|
|
782
|
+
console.log(`Plugin packages are available from ${config_js_1.REGISTRY_URL} at the latest tag.`);
|
|
783
|
+
console.log("Local Lite and Ory Agent Security are expected to be running separately.");
|
|
784
|
+
}
|
|
801
785
|
async function registryClean() {
|
|
802
786
|
// Stop first if running
|
|
803
787
|
await registryStop();
|