@ory/argus 0.14.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +31 -46
  2. package/assets/commands/temporal-up.md +1 -1
  3. package/assets/skills/auth-setup/SKILL.md +1 -1
  4. package/assets/skills/local-dev/SKILL.md +17 -7
  5. package/assets/skills/ory-build-agent/SKILL.md +39 -91
  6. package/assets/skills/ory-e2b-sandbox/SKILL.md +18 -17
  7. package/assets/skills/ory-temporal-worker/SKILL.md +31 -33
  8. package/assets/skills/permissions-onboarding/SKILL.md +131 -104
  9. package/dist/adapters.d.ts +88 -32
  10. package/dist/adapters.js +443 -164
  11. package/dist/agent-auth.d.ts +226 -67
  12. package/dist/agent-auth.js +951 -205
  13. package/dist/auth-store.d.ts +37 -2
  14. package/dist/auth-store.js +37 -3
  15. package/dist/auth.d.ts +33 -4
  16. package/dist/auth.js +163 -20
  17. package/dist/bash-parser.d.ts +98 -0
  18. package/dist/bash-parser.js +396 -0
  19. package/dist/branding.d.ts +77 -16
  20. package/dist/branding.js +93 -23
  21. package/dist/build-info.json +4 -4
  22. package/dist/cli-invocation.d.ts +1 -1
  23. package/dist/cli-invocation.js +2 -1
  24. package/dist/cli.d.ts +20 -29
  25. package/dist/cli.js +271 -239
  26. package/dist/client.d.ts +175 -138
  27. package/dist/client.js +672 -391
  28. package/dist/config.d.ts +217 -54
  29. package/dist/config.js +461 -42
  30. package/dist/context.d.ts +10 -0
  31. package/dist/context.js +21 -0
  32. package/dist/contract-suite.d.ts +3 -5
  33. package/dist/contract-suite.js +75 -47
  34. package/dist/denial.d.ts +36 -3
  35. package/dist/denial.js +79 -10
  36. package/dist/event-reporter.d.ts +77 -0
  37. package/dist/event-reporter.js +776 -0
  38. package/dist/external-registrations-main.d.ts +10 -0
  39. package/dist/external-registrations-main.js +38 -0
  40. package/dist/external-registrations.d.ts +79 -0
  41. package/dist/external-registrations.js +188 -0
  42. package/dist/help-cli.d.ts +39 -0
  43. package/dist/help-cli.js +55 -0
  44. package/dist/hook-timeout.d.ts +64 -0
  45. package/dist/hook-timeout.js +88 -0
  46. package/dist/index.d.ts +28 -23
  47. package/dist/index.js +173 -58
  48. package/dist/lifecycle.d.ts +3 -3
  49. package/dist/lifecycle.js +38 -6
  50. package/dist/local/cli.js +11 -6
  51. package/dist/local/configs.d.ts +74 -18
  52. package/dist/local/configs.js +291 -84
  53. package/dist/local/health.js +7 -7
  54. package/dist/local/index.d.ts +2 -2
  55. package/dist/local/index.js +24 -10
  56. package/dist/local/manager.d.ts +20 -1
  57. package/dist/local/manager.js +159 -36
  58. package/dist/local/ports.d.ts +158 -0
  59. package/dist/local/ports.js +443 -0
  60. package/dist/local/seed.d.ts +13 -5
  61. package/dist/local/seed.js +62 -38
  62. package/dist/logger.d.ts +54 -25
  63. package/dist/logger.js +329 -63
  64. package/dist/mcp.d.ts +2 -2
  65. package/dist/mcp.js +10 -5
  66. package/dist/mirror-bootstrap.d.ts +48 -0
  67. package/dist/mirror-bootstrap.js +254 -0
  68. package/dist/opl.d.ts +289 -0
  69. package/dist/opl.js +446 -0
  70. package/dist/permission-mode.d.ts +87 -0
  71. package/dist/permission-mode.js +307 -0
  72. package/dist/permissions-cli.d.ts +13 -49
  73. package/dist/permissions-cli.js +154 -348
  74. package/dist/permissions.d.ts +148 -38
  75. package/dist/permissions.js +591 -45
  76. package/dist/post-install.d.ts +33 -0
  77. package/dist/post-install.js +127 -0
  78. package/dist/read-credential.d.ts +65 -0
  79. package/dist/read-credential.js +86 -0
  80. package/dist/registry/cli.js +5 -2
  81. package/dist/registry/config.d.ts +0 -17
  82. package/dist/registry/config.js +0 -23
  83. package/dist/registry/index.d.ts +1 -1
  84. package/dist/registry/index.js +2 -2
  85. package/dist/registry/manager.d.ts +4 -21
  86. package/dist/registry/manager.js +21 -37
  87. package/dist/runtime-credential.d.ts +140 -0
  88. package/dist/runtime-credential.js +572 -0
  89. package/dist/runtime.d.ts +413 -0
  90. package/dist/runtime.js +825 -0
  91. package/dist/setup.d.ts +23 -47
  92. package/dist/setup.js +59 -116
  93. package/dist/skills.js +0 -7
  94. package/dist/status-cli.d.ts +27 -11
  95. package/dist/status-cli.js +121 -115
  96. package/dist/status-data.d.ts +116 -17
  97. package/dist/status-data.js +121 -38
  98. package/dist/subject.d.ts +126 -20
  99. package/dist/subject.js +215 -30
  100. package/dist/testing.d.ts +74 -38
  101. package/dist/testing.js +185 -68
  102. package/dist/tool-catalog.d.ts +53 -11
  103. package/dist/tool-catalog.js +164 -13
  104. package/dist/tool-metadata.d.ts +7 -6
  105. package/dist/tool-metadata.js +6 -5
  106. package/dist/types.d.ts +11 -1
  107. package/dist/uninstall.d.ts +71 -34
  108. package/dist/uninstall.js +217 -85
  109. package/dist/user-login.d.ts +9 -10
  110. package/dist/user-login.js +56 -75
  111. package/dist/watch-cli.d.ts +6 -0
  112. package/dist/watch-cli.js +217 -0
  113. package/package.json +4 -27
  114. package/assets/commands/dashboard.md +0 -34
  115. package/dist/dashboard-cli.d.ts +0 -8
  116. package/dist/dashboard-cli.js +0 -70
  117. package/dist/dev.d.ts +0 -103
  118. package/dist/dev.js +0 -583
  119. package/dist/interactive-setup.d.ts +0 -286
  120. package/dist/interactive-setup.js +0 -1734
  121. package/dist/local/jaeger-main.d.ts +0 -13
  122. package/dist/local/jaeger-main.js +0 -85
  123. package/dist/local/jaeger.d.ts +0 -50
  124. package/dist/local/jaeger.js +0 -162
  125. package/dist/otel/exporter.d.ts +0 -17
  126. package/dist/otel/exporter.js +0 -12
  127. package/dist/otel/index.d.ts +0 -2
  128. package/dist/otel/index.js +0 -8
  129. package/dist/otel/otlp.d.ts +0 -103
  130. package/dist/otel/otlp.js +0 -385
  131. package/dist/project-api-key.d.ts +0 -69
  132. package/dist/project-api-key.js +0 -147
  133. package/dist/setup-actions.d.ts +0 -232
  134. package/dist/setup-actions.js +0 -507
  135. package/dist/tracer.d.ts +0 -190
  136. package/dist/tracer.js +0 -481
  137. package/dist/watch-sandbox.d.ts +0 -9
  138. package/dist/watch-sandbox.js +0 -81
  139. package/dist/web/api.d.ts +0 -33
  140. package/dist/web/api.js +0 -294
  141. package/dist/web/launch.d.ts +0 -11
  142. package/dist/web/launch.js +0 -96
  143. package/dist/web/server.d.ts +0 -20
  144. package/dist/web/server.js +0 -233
  145. package/dist/web/types.d.ts +0 -65
  146. package/dist/web/types.js +0 -2
  147. package/dist/webapp/assets/index-Wucl4SZs.css +0 -1
  148. package/dist/webapp/assets/index-m-GtEdq0.js +0 -49
  149. package/dist/webapp/favicon.ico +0 -0
  150. package/dist/webapp/index.html +0 -15
@@ -0,0 +1,413 @@
1
+ /**
2
+ * The plugin **runtime store**: resolve which code a harness runs *once*, at
3
+ * install time, instead of re-resolving an npm package spec on every hook
4
+ * invocation.
5
+ *
6
+ * Historically every harness plugin wrote its runtime hook command as a
7
+ * version-pinned npx spec (`npx -y -p @ory/<pkg>@<ver> ory-<h>-hook`). That
8
+ * froze the *resolution strategy* into each harness's config file: which code
9
+ * runs was decided by npm on every `PreToolUse`, forever — one `npm exec`
10
+ * resolution per tool call, dependent on network and npm cache state, and
11
+ * untestable locally without publishing to a registry first.
12
+ *
13
+ * This module replaces that with three artifacts:
14
+ *
15
+ * 1. **A runtime store** at `<dataDir>/runtime/<version>/`, an npm prefix
16
+ * holding the plugin package and its dependency closure. Populated by a
17
+ * single `npm install --prefix` at install time — the only package
18
+ * resolution that ever happens. Several harnesses installed at the same
19
+ * version share one store directory.
20
+ * 2. **A stable entry shim** per harness at
21
+ * `<dataDir>/bin/ory-hook-<harness>.js` (and one for the MCP server).
22
+ * Harness configs reference the *shim*, whose path never changes across
23
+ * upgrades — so changing the runtime, or the resolution policy itself,
24
+ * rewrites one small file instead of N harness config formats.
25
+ * 3. **A manifest** at `<dataDir>/runtime/manifest.json` recording what is
26
+ * wired where, so `status` can report the runtime a harness will actually
27
+ * load, upgrades can rewire, and unreferenced stores can be pruned.
28
+ *
29
+ * A **linked** runtime (`linkedRuntime`) points the shim straight at a
30
+ * workspace build instead of a materialized store. That is the development
31
+ * loop: `pnpm build` + relaunch, with no publish, no version bump, and no
32
+ * registry involved.
33
+ *
34
+ * ## The shim must fail open
35
+ *
36
+ * The shim is not an indirection for its own sake: it is the only place that
37
+ * can degrade gracefully. If the runtime store is missing — a wiped config
38
+ * dir, a half-finished upgrade, dotfiles synced to a new machine — a raw
39
+ * `node "<store>/…/hook.js"` command would exit non-zero, and a harness that
40
+ * treats an unanswered gate as a block (Cursor registers `preToolUse` with
41
+ * `failClosed: true`) would then block *every* tool call. So the generated
42
+ * hook shim catches an unloadable runtime, explains itself on stderr, and
43
+ * exits 0 with the harness's pass-through response. The MCP shim does the
44
+ * opposite and exits non-zero: an MCP server that cannot start gates nothing,
45
+ * and a silent no-op server is harder to diagnose than a loud failure.
46
+ */
47
+ /** Root of the runtime store: `<dataDir>/runtime`. */
48
+ export declare function getRuntimeRoot(): string;
49
+ /** Store directory for one version: `<dataDir>/runtime/<version>`. */
50
+ export declare function getRuntimeStoreDir(version: string): string;
51
+ /** Directory holding the generated entry shims: `<dataDir>/bin`. */
52
+ export declare function getShimDir(): string;
53
+ /** Stable hook-shim path for a harness. Never changes across upgrades. */
54
+ export declare function getHookShimPath(harness: string): string;
55
+ /** Stable MCP-server shim path. Shared by every harness. */
56
+ export declare function getMcpShimPath(): string;
57
+ /** The npm package providing the MCP server, materialized alongside plugins. */
58
+ export declare const MCP_SERVER_PACKAGE = "@ory/mcp-server";
59
+ /**
60
+ * A resolved runtime: a concrete directory on disk holding the package whose
61
+ * code the harness will run.
62
+ *
63
+ * `materialized` is the production shape — an npm prefix under the data dir,
64
+ * populated at install time. `linked` points at an already-built package
65
+ * directory (a workspace checkout), used by explicit source installs.
66
+ */
67
+ export interface RuntimeTarget {
68
+ kind: "materialized" | "linked";
69
+ /** npm package name, e.g. `@ory/goose`. */
70
+ packageName: string;
71
+ /** Absolute path to the package directory (contains `package.json`, `dist/`). */
72
+ packageDir: string;
73
+ /** Version found in the resolved package's `package.json`. */
74
+ version: string;
75
+ /** The npm prefix the package was installed into (materialized only). */
76
+ storeDir?: string;
77
+ }
78
+ /**
79
+ * How the runtime store is populated. Injectable so tests exercise the
80
+ * materialization logic without reaching the network, and so a caller can
81
+ * route the install through a different registry.
82
+ */
83
+ export type NpmInstaller = (args: {
84
+ prefix: string;
85
+ specs: string[];
86
+ }) => {
87
+ ok: boolean;
88
+ output: string;
89
+ };
90
+ /**
91
+ * Default installer: one `npm install --prefix <store> <spec>…`.
92
+ *
93
+ * `--prefix` keeps the install entirely inside the store directory (npm
94
+ * creates `<store>/node_modules` and, if absent, a minimal `package.json`),
95
+ * and `--no-save` keeps it from rewriting a manifest we do not own. The
96
+ * user's own npm configuration — registry, auth, proxy — applies, which is
97
+ * the point: this is the *one* resolution, done with the user's settings, at
98
+ * a moment where a failure is visible and actionable.
99
+ */
100
+ export declare const defaultNpmInstaller: NpmInstaller;
101
+ /**
102
+ * When this install runs from inside an `npx`/`npm exec` wrapper (the
103
+ * documented `npx -p @ory/<harness> ory-<harness> install` entry point), the
104
+ * outer npm resolves the user's config and *projects it into the environment*
105
+ * as `npm_config_*` vars for child processes. Our inner `npm install <spec>…`
106
+ * inherits those — which is how the user's registry/proxy/`min-release-age`
107
+ * reach the store install, so we keep them.
108
+ *
109
+ * The one exception is `allow-scripts`: npm ≥ 11.6 rejects an env/CLI-level
110
+ * `allow-scripts` in a project-scoped install (`EALLOWSCRIPTS`), because that
111
+ * source is meant for one-off/global contexts. A user with
112
+ * `allow-scripts=…` in `~/.npmrc` (an increasingly common supply-chain
113
+ * hardening) would otherwise be unable to install the runtime at all. Dropping
114
+ * only the projected env var lets the child re-read the same setting from the
115
+ * `.npmrc` cascade (user/global level, which *is* permitted here), so packages
116
+ * that legitimately need a build step — e.g. `tree-sitter-bash` for shell
117
+ * decomposition — still get it.
118
+ */
119
+ export declare function sanitizeNpmEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
120
+ /**
121
+ * Materialize a runtime into the store and return it.
122
+ *
123
+ * The MCP server is installed into the same prefix by default: it is fetched
124
+ * by the harness at runtime in exactly the same way the hook was, so it needs
125
+ * the same treatment for the registry to drop out of the runtime path
126
+ * entirely.
127
+ *
128
+ * Throws when the install fails or the expected package directory is absent
129
+ * afterwards — an install that cannot materialize its runtime must say so
130
+ * rather than write a shim pointing at nothing.
131
+ */
132
+ export declare function materializeRuntime(opts: {
133
+ packageName: string;
134
+ version: string;
135
+ /** Extra specs to install into the same prefix. Defaults to the MCP server. */
136
+ extraPackages?: string[];
137
+ installer?: NpmInstaller;
138
+ }): RuntimeTarget;
139
+ /**
140
+ * Use an already-built package directory as the runtime — the development
141
+ * path (`install --link <dir>`), where the workspace build *is* the artifact.
142
+ *
143
+ * Validates that the directory looks like a built package so a typo surfaces
144
+ * at install time instead of as hooks that silently never run.
145
+ */
146
+ export declare function linkedRuntime(opts: {
147
+ packageName: string;
148
+ packageDir: string;
149
+ }): RuntimeTarget;
150
+ /**
151
+ * Absolute path to an entry point inside a runtime, e.g. the hook script.
152
+ * Throws when the file is absent — the shim is written from this, so a bad
153
+ * relative path must fail at install time, not at the first tool call.
154
+ */
155
+ export declare function resolveRuntimeEntry(target: RuntimeTarget, relativePath: string): string;
156
+ /**
157
+ * The MCP server inside a runtime, or `undefined` when it isn't there.
158
+ *
159
+ * A materialized store installs it as a sibling; a linked workspace build has
160
+ * it two levels up (`packages/mcp-server`). Optional by design: a plugin whose
161
+ * MCP registration is missing should degrade to no MCP server, not fail the
162
+ * whole install.
163
+ */
164
+ export declare function resolveMcpRuntimeEntry(target: RuntimeTarget): string | undefined;
165
+ /**
166
+ * Body of a generated hook shim.
167
+ *
168
+ * Deliberately tiny and dependency-free: it must be loadable even when the
169
+ * runtime it points at is not. `require` (not `import`) so the shim works
170
+ * regardless of how the harness invokes it, and the pass-through response is
171
+ * written *before* exiting 0 so a fail-closed gate still sees a valid answer.
172
+ */
173
+ export declare function hookShimBody(opts: {
174
+ entry: string;
175
+ packageName: string;
176
+ version: string;
177
+ installCommand: string;
178
+ fallbackStdout: string;
179
+ }): string;
180
+ /**
181
+ * Write (or rewrite) the stable hook shim for a harness and record the wiring
182
+ * in the manifest. Returns the shim path — what the harness config should
183
+ * reference, via {@link hookCommand}.
184
+ *
185
+ * `fallbackStdout` is the harness's pass-through response for the
186
+ * runtime-missing case. Most subprocess harnesses treat empty stdout plus
187
+ * exit 0 as "no opinion, proceed", which is the default; pass a JSON string
188
+ * for a harness that needs an explicit allow payload.
189
+ */
190
+ export declare function writeHookShim(opts: {
191
+ harness: string;
192
+ target: RuntimeTarget;
193
+ /** Entry inside the package. Defaults to the conventional `dist/hook.js`. */
194
+ entryRelPath?: string;
195
+ installCommand: string;
196
+ fallbackStdout?: string;
197
+ /** Recorded in the manifest so a bootstrap can find the MCP server. */
198
+ mcpEntry?: string;
199
+ }): string;
200
+ /**
201
+ * Write (or rewrite) the shared MCP-server shim. Returns the shim path, or
202
+ * `undefined` when this runtime has no MCP server to point at — callers then
203
+ * skip the MCP registration rather than writing a broken one.
204
+ */
205
+ export declare function writeMcpShim(opts: {
206
+ target: RuntimeTarget;
207
+ installCommand: string;
208
+ }): string | undefined;
209
+ /**
210
+ * The hook command a harness config should carry: `node "<shim>"`.
211
+ *
212
+ * Quoted because a data dir can contain spaces, and several harnesses run the
213
+ * command through a shell.
214
+ */
215
+ export declare function hookCommand(shimPath: string): string;
216
+ /**
217
+ * True when a command in a harness config is one of ours.
218
+ *
219
+ * Matches the runtime shims this module writes **and** the version-pinned
220
+ * `npx -y -p @ory/<pkg> …` commands earlier releases wrote. The legacy pattern
221
+ * has to stay recognized even though nothing emits it any more: uninstall and
222
+ * the non-destructive install merges use this predicate, and a legacy entry
223
+ * left behind would keep invoking the last published release alongside the new
224
+ * shim.
225
+ */
226
+ export declare function isOryRuntimeCommand(command: string | undefined): boolean;
227
+ /** The MCP server registration a harness config should carry. */
228
+ export declare function mcpCommand(shimPath: string): {
229
+ command: string;
230
+ args: string[];
231
+ };
232
+ /**
233
+ * Module specifier for an *in-process* plugin: the absolute package directory.
234
+ *
235
+ * In-process harnesses (OpenCode, OpenClaw, Amp, Pi) load the plugin as a
236
+ * module rather than spawning a hook, so they reference the runtime directly
237
+ * instead of through a shim — a loader file re-exporting this path, or a
238
+ * `file://` plugin spec built from it.
239
+ */
240
+ export declare function moduleSpecifier(target: RuntimeTarget): string;
241
+ /** What a single harness has wired up, as recorded in the manifest. */
242
+ export interface RuntimeWiring {
243
+ harness: string;
244
+ packageName: string;
245
+ version: string;
246
+ kind: RuntimeTarget["kind"];
247
+ /** Absolute package dir the shim loads from. */
248
+ packageDir: string;
249
+ /** The store prefix, for a materialized runtime. */
250
+ storeDir?: string;
251
+ /** Generated shim path referenced by the harness config. */
252
+ hookShim: string;
253
+ /** Entry inside the runtime that the shim requires. */
254
+ hookEntry: string;
255
+ /**
256
+ * MCP server entry inside the runtime, when this runtime has one. Recorded so
257
+ * a dependency-free bootstrap (the one committed to the public install-surface
258
+ * mirrors) can find the server without resolving a package.
259
+ */
260
+ mcpEntry?: string;
261
+ /** ISO-8601 timestamp the wiring was written. */
262
+ wiredAt: string;
263
+ }
264
+ export interface RuntimeManifest {
265
+ version: 1;
266
+ harnesses: Record<string, RuntimeWiring>;
267
+ }
268
+ /** Read the manifest. Returns an empty manifest when absent or unreadable. */
269
+ export declare function readRuntimeManifest(): RuntimeManifest;
270
+ /** Record (or replace) one harness's wiring. Called by {@link writeHookShim}. */
271
+ export declare function recordRuntimeWiring(opts: {
272
+ harness: string;
273
+ target: RuntimeTarget;
274
+ hookShim: string;
275
+ hookEntry: string;
276
+ mcpEntry?: string;
277
+ }): RuntimeWiring;
278
+ /** The wiring for one harness, or `undefined` when it isn't installed. */
279
+ export declare function getRuntimeWiring(harness: string): RuntimeWiring | undefined;
280
+ /**
281
+ * Forget a harness's wiring and remove its shim. Used by `uninstall`. The
282
+ * store itself is left to {@link pruneRuntimeStores}, which removes it only
283
+ * once no harness references it.
284
+ */
285
+ export declare function removeRuntimeWiring(harness: string): void;
286
+ /**
287
+ * Delete store directories no harness references any more — the GC step of an
288
+ * upgrade. Always called *after* the shims have been rewritten, so a store in
289
+ * use is never removed. Returns the directories deleted.
290
+ */
291
+ export declare function pruneRuntimeStores(): string[];
292
+ /**
293
+ * Where an `install` should get the runtime from.
294
+ *
295
+ * `--runtime-dir <dir>` → link that directory
296
+ * `ORY_PLUGIN_RUNTIME_DIR` → link that directory
297
+ * otherwise → materialize the CLI's own version
298
+ *
299
+ * The flag and the env var support explicit source installs that point at an
300
+ * already-built workspace package instead of materializing from a registry.
301
+ *
302
+ * The flag deliberately requires an explicit directory. A bare "link whatever
303
+ * package I am running from" would resolve to npx's ephemeral cache dir under
304
+ * the common `npx -p @ory/<pkg>` invocation — a runtime that disappears
305
+ * between sessions — and `--link` is already taken by at least one harness
306
+ * (Gemini CLI symlinks its *extension* with it), so the name has to be
307
+ * unambiguous too.
308
+ */
309
+ export declare function resolveRuntimeForInstall(opts: {
310
+ packageName: string;
311
+ /** Package root of the *running* CLI — supplies the version to materialize. */
312
+ packageRoot: string;
313
+ args?: readonly string[];
314
+ installer?: NpmInstaller;
315
+ }): RuntimeTarget;
316
+ /**
317
+ * The hook command of a subprocess-hook runtime.
318
+ *
319
+ * `PreparedRuntime.hookCommand` is optional because an in-process integration
320
+ * imports a module instead of spawning a hook. A harness that *does* spawn one
321
+ * cannot be wired without it, so its absence is a programming error — better to
322
+ * say so than to write `undefined` into a config file.
323
+ */
324
+ export declare function requireHookCommand(runtime: PreparedRuntime): string;
325
+ /** Everything a plugin's install needs to write into its harness config. */
326
+ export interface PreparedRuntime {
327
+ target: RuntimeTarget;
328
+ /**
329
+ * Stable shim path the harness config references. For an in-process
330
+ * integration there is no shim — this is the module the harness imports.
331
+ */
332
+ hookShim: string;
333
+ /**
334
+ * Ready-to-write hook command: `node "<shim>"`. Absent for an in-process
335
+ * integration, which imports a module instead of spawning a hook.
336
+ */
337
+ hookCommand?: string;
338
+ /** MCP shim path, absent when this runtime ships no MCP server. */
339
+ mcpShim?: string;
340
+ /** Ready-to-write MCP registration, absent for the same reason. */
341
+ mcpServer?: {
342
+ command: string;
343
+ args: string[];
344
+ };
345
+ /** Store directories GC'd after rewiring — reported by `install`. */
346
+ prunedStores: string[];
347
+ }
348
+ /** Serialize installs because npm mutates and prunes the shared prefix in place. */
349
+ export declare function withRuntimeInstallLock<T>(action: () => T, options?: {
350
+ timeoutMs?: number;
351
+ pollMs?: number;
352
+ }): T;
353
+ /**
354
+ * One call per plugin install: resolve the runtime, write the shims, record
355
+ * the wiring, and GC stores nothing references any more.
356
+ *
357
+ * Ordering matters — the shims are rewritten *before* pruning, so the store a
358
+ * harness is about to use is never a GC candidate.
359
+ */
360
+ export declare function wireRuntime(opts: {
361
+ harness: string;
362
+ packageName: string;
363
+ packageRoot: string;
364
+ /** Copy-pasteable command that regenerates this wiring, for shim messages. */
365
+ installCommand: string;
366
+ args?: readonly string[];
367
+ /** Entry inside the package. Defaults to `dist/hook.js`. */
368
+ entryRelPath?: string;
369
+ /** Harness pass-through payload for the runtime-missing case. */
370
+ fallbackStdout?: string;
371
+ /** Set false for a harness that registers no MCP server (e.g. Pi). */
372
+ includeMcp?: boolean;
373
+ /**
374
+ * The harness loads the plugin as a module rather than spawning a hook
375
+ * (OpenCode, OpenClaw, Pi). No hook shim is written — a shim named for a hook
376
+ * that nothing invokes is just a file whose top-level `require` could
377
+ * surprise someone later — and the wiring records the module entry instead,
378
+ * so `status` still reports what the harness will load.
379
+ */
380
+ inProcess?: boolean;
381
+ installer?: NpmInstaller;
382
+ }): PreparedRuntime;
383
+ /** Health of the runtime a harness is wired to. */
384
+ export type RuntimeHealth = {
385
+ state: "not_installed";
386
+ } | {
387
+ state: "ok";
388
+ wiring: RuntimeWiring;
389
+ } | {
390
+ state: "shim_missing";
391
+ wiring: RuntimeWiring;
392
+ } | {
393
+ state: "runtime_missing";
394
+ wiring: RuntimeWiring;
395
+ } | {
396
+ state: "version_drift";
397
+ wiring: RuntimeWiring;
398
+ runtimeVersion: string;
399
+ };
400
+ /**
401
+ * Inspect what a harness will actually load.
402
+ *
403
+ * With the runtime resolved at install time, the wired code and the CLI a user
404
+ * happens to run (`npx @ory/<pkg>@latest status`) can legitimately differ —
405
+ * so `status` reports the runtime version found on disk, not the CLI's own.
406
+ * The unhappy states are each distinguishable because they have different
407
+ * fixes: a missing shim means the harness config points at nothing, a missing
408
+ * runtime means the shim will fail open (tools unchecked), and drift means the
409
+ * store was replaced underneath a stale shim.
410
+ */
411
+ export declare function checkRuntimeHealth(harness: string): RuntimeHealth;
412
+ /** One-line human summary of {@link checkRuntimeHealth}, for `status`. */
413
+ export declare function describeRuntimeHealth(health: RuntimeHealth): string;