@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,13 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Standalone entry point for managing the dev-launcher Jaeger container.
4
- *
5
- * Used by root package.json scripts:
6
- * pnpm jaeger:up → node packages/core/dist/local/jaeger-main.js up
7
- * pnpm jaeger:down → node packages/core/dist/local/jaeger-main.js down
8
- *
9
- * The container started here (`ory-jaeger-dev`) is independent of the
10
- * Compose-managed Jaeger that ships with `pnpm local:up` (`ory-jaeger`),
11
- * so they cannot collide.
12
- */
13
- export {};
@@ -1,85 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- /**
4
- * Standalone entry point for managing the dev-launcher Jaeger container.
5
- *
6
- * Used by root package.json scripts:
7
- * pnpm jaeger:up → node packages/core/dist/local/jaeger-main.js up
8
- * pnpm jaeger:down → node packages/core/dist/local/jaeger-main.js down
9
- *
10
- * The container started here (`ory-jaeger-dev`) is independent of the
11
- * Compose-managed Jaeger that ships with `pnpm local:up` (`ory-jaeger`),
12
- * so they cannot collide.
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const jaeger_js_1 = require("./jaeger.js");
16
- async function main() {
17
- const subcommand = process.argv[2];
18
- switch (subcommand) {
19
- case "up": {
20
- const result = await (0, jaeger_js_1.ensureDevJaeger)();
21
- switch (result.status) {
22
- case "already-running":
23
- console.log(`Jaeger is already reachable at ${result.endpoint} (UI: ${result.uiUrl}).`);
24
- break;
25
- case "started":
26
- console.log(`Jaeger started in Docker. OTLP endpoint: ${result.endpoint}, UI: ${result.uiUrl}.`);
27
- console.log("Use 'pnpm jaeger:down' to stop it.");
28
- break;
29
- case "skipped:no-docker":
30
- console.error(`Could not start Jaeger: ${result.detail}`);
31
- process.exit(1);
32
- case "skipped:probe-failed":
33
- console.error(`Jaeger did not become healthy: ${result.detail}`);
34
- process.exit(1);
35
- case "error":
36
- console.error(`Jaeger failed to start: ${result.detail}`);
37
- process.exit(1);
38
- }
39
- break;
40
- }
41
- case "down": {
42
- const result = (0, jaeger_js_1.stopDevJaeger)();
43
- switch (result.status) {
44
- case "stopped":
45
- console.log("Stopped the dev Jaeger container.");
46
- break;
47
- case "not-running":
48
- console.log("No dev Jaeger container is running.");
49
- break;
50
- case "skipped:no-docker":
51
- console.error(`Cannot stop Jaeger: ${result.detail}`);
52
- process.exit(1);
53
- case "error":
54
- console.error(`Failed to stop Jaeger: ${result.detail}`);
55
- process.exit(1);
56
- }
57
- break;
58
- }
59
- case "help":
60
- case "--help":
61
- case "-h":
62
- case undefined:
63
- console.log(`
64
- ory-jaeger — Manage the standalone Jaeger container used by dev launchers
65
-
66
- Usage:
67
- pnpm jaeger:up Start a local Jaeger all-in-one container (UI on :16686, OTLP HTTP on :4318)
68
- pnpm jaeger:down Stop and remove the dev Jaeger container
69
-
70
- Dev launchers (pnpm dev:<harness>) call 'jaeger up' automatically when no
71
- OTEL_EXPORTER_OTLP_ENDPOINT is set in the parent shell. Run these manually
72
- if you want to inspect traces without launching a harness.
73
-
74
- Requires Docker.
75
- `);
76
- break;
77
- default:
78
- console.error(`Unknown subcommand: ${subcommand}`);
79
- process.exit(1);
80
- }
81
- }
82
- main().catch((err) => {
83
- console.error(err.message ?? err);
84
- process.exit(1);
85
- });
@@ -1,50 +0,0 @@
1
- /**
2
- * Standalone Jaeger lifecycle for the dev launcher.
3
- *
4
- * Runs Jaeger all-in-one as a single Docker container (no Compose project)
5
- * so `pnpm dev:<harness>` can ship traces to a local Jaeger UI without
6
- * spinning up the rest of the local Ory stack.
7
- *
8
- * The container is named distinctly from the `local up` Jaeger container
9
- * (`ory-jaeger`) so the two cannot collide. If `local up` is already running
10
- * its Jaeger, the OTLP port is bound and `ensureDevJaeger` short-circuits via
11
- * the reachability probe.
12
- */
13
- export declare const DEV_JAEGER_CONTAINER = "jaeger";
14
- export declare const DEV_JAEGER_IMAGE = "jaegertracing/all-in-one:1";
15
- export interface EnsureDevJaegerResult {
16
- /** OTLP HTTP endpoint to use, or undefined when Jaeger is unavailable. */
17
- endpoint?: string;
18
- /** UI URL when Jaeger is available. */
19
- uiUrl?: string;
20
- /** Human-readable status — "running", "started", "skipped:no-docker", "skipped:port-in-use", "error". */
21
- status: "already-running" | "started" | "skipped:no-docker" | "skipped:probe-failed" | "error";
22
- /** Detail / error message for logging. */
23
- detail?: string;
24
- }
25
- export interface StopDevJaegerResult {
26
- status: "stopped" | "not-running" | "skipped:no-docker" | "error";
27
- detail?: string;
28
- }
29
- /**
30
- * Ensure a local Jaeger is reachable on the OTLP HTTP port.
31
- *
32
- * Order of operations:
33
- * 1. Probe `localhost:4318` — return `already-running` when something
34
- * already serves it (the `local up` Jaeger, a previous dev-launcher
35
- * Jaeger, or any other OTLP collector the user has running).
36
- * 2. If Docker is unavailable, return `skipped:no-docker`.
37
- * 3. If our standalone container exists but is stopped, remove it so the
38
- * `--rm` flag stays meaningful, then re-run.
39
- * 4. `docker run` Jaeger all-in-one and wait for the OTLP port to come up.
40
- */
41
- export declare function ensureDevJaeger(opts?: {
42
- startupTimeoutMs?: number;
43
- }): Promise<EnsureDevJaegerResult>;
44
- /**
45
- * Stop the standalone dev Jaeger container.
46
- *
47
- * Idempotent: returns `not-running` when nothing matching is up. Does not
48
- * touch the `local up` Jaeger (different container name).
49
- */
50
- export declare function stopDevJaeger(): StopDevJaegerResult;
@@ -1,162 +0,0 @@
1
- "use strict";
2
- /**
3
- * Standalone Jaeger lifecycle for the dev launcher.
4
- *
5
- * Runs Jaeger all-in-one as a single Docker container (no Compose project)
6
- * so `pnpm dev:<harness>` can ship traces to a local Jaeger UI without
7
- * spinning up the rest of the local Ory stack.
8
- *
9
- * The container is named distinctly from the `local up` Jaeger container
10
- * (`ory-jaeger`) so the two cannot collide. If `local up` is already running
11
- * its Jaeger, the OTLP port is bound and `ensureDevJaeger` short-circuits via
12
- * the reachability probe.
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.DEV_JAEGER_IMAGE = exports.DEV_JAEGER_CONTAINER = void 0;
16
- exports.ensureDevJaeger = ensureDevJaeger;
17
- exports.stopDevJaeger = stopDevJaeger;
18
- const node_child_process_1 = require("node:child_process");
19
- const configs_js_1 = require("./configs.js");
20
- exports.DEV_JAEGER_CONTAINER = "jaeger";
21
- exports.DEV_JAEGER_IMAGE = "jaegertracing/all-in-one:1";
22
- function dockerAvailable() {
23
- const result = (0, node_child_process_1.spawnSync)("docker", ["info"], { stdio: "ignore" });
24
- return result.status === 0;
25
- }
26
- async function isOtlpReachable(timeoutMs = 800) {
27
- try {
28
- const ctrl = new AbortController();
29
- const timer = setTimeout(() => ctrl.abort(), timeoutMs);
30
- try {
31
- const res = await fetch(`${configs_js_1.JAEGER_OTLP_HTTP_URL}/v1/traces`, {
32
- method: "GET",
33
- signal: ctrl.signal,
34
- });
35
- return res.status >= 200 && res.status < 600;
36
- }
37
- finally {
38
- clearTimeout(timer);
39
- }
40
- }
41
- catch {
42
- return false;
43
- }
44
- }
45
- function inspectContainer(name) {
46
- const result = (0, node_child_process_1.spawnSync)("docker", ["inspect", "--format", "{{.State.Running}}", name], { stdio: ["ignore", "pipe", "ignore"] });
47
- if (result.status !== 0) {
48
- return { exists: false, running: false };
49
- }
50
- const out = (result.stdout?.toString() ?? "").trim();
51
- return { exists: true, running: out === "true" };
52
- }
53
- function startContainer() {
54
- // Use --rm so the container is wiped on stop — no stale state between runs.
55
- const args = [
56
- "run",
57
- "-d",
58
- "--rm",
59
- "--name",
60
- exports.DEV_JAEGER_CONTAINER,
61
- "-p",
62
- `${configs_js_1.JAEGER_UI_PORT}:${configs_js_1.JAEGER_UI_PORT}`,
63
- "-p",
64
- `${configs_js_1.JAEGER_OTLP_HTTP_PORT}:${configs_js_1.JAEGER_OTLP_HTTP_PORT}`,
65
- "-e",
66
- "COLLECTOR_OTLP_ENABLED=true",
67
- "-e",
68
- "LOG_LEVEL=warn",
69
- exports.DEV_JAEGER_IMAGE,
70
- ];
71
- const result = (0, node_child_process_1.spawnSync)("docker", args, { stdio: ["ignore", "ignore", "pipe"] });
72
- if (result.status === 0)
73
- return { ok: true };
74
- const stderr = (result.stderr?.toString() ?? "").trim();
75
- return { ok: false, detail: stderr || `docker run exited ${result.status}` };
76
- }
77
- async function waitUntilReachable(timeoutMs) {
78
- const deadline = Date.now() + timeoutMs;
79
- while (Date.now() < deadline) {
80
- if (await isOtlpReachable(500))
81
- return true;
82
- await new Promise((r) => setTimeout(r, 250));
83
- }
84
- return false;
85
- }
86
- /**
87
- * Ensure a local Jaeger is reachable on the OTLP HTTP port.
88
- *
89
- * Order of operations:
90
- * 1. Probe `localhost:4318` — return `already-running` when something
91
- * already serves it (the `local up` Jaeger, a previous dev-launcher
92
- * Jaeger, or any other OTLP collector the user has running).
93
- * 2. If Docker is unavailable, return `skipped:no-docker`.
94
- * 3. If our standalone container exists but is stopped, remove it so the
95
- * `--rm` flag stays meaningful, then re-run.
96
- * 4. `docker run` Jaeger all-in-one and wait for the OTLP port to come up.
97
- */
98
- async function ensureDevJaeger(opts = {}) {
99
- if (await isOtlpReachable()) {
100
- return {
101
- status: "already-running",
102
- endpoint: configs_js_1.JAEGER_OTLP_HTTP_URL,
103
- uiUrl: configs_js_1.JAEGER_UI_URL,
104
- };
105
- }
106
- if (!dockerAvailable()) {
107
- return {
108
- status: "skipped:no-docker",
109
- detail: "Docker is not running. Start Docker Desktop to auto-launch Jaeger.",
110
- };
111
- }
112
- const state = inspectContainer(exports.DEV_JAEGER_CONTAINER);
113
- if (state.exists && !state.running) {
114
- // Stale --rm container could only exist if Docker died mid-run; clean it up.
115
- (0, node_child_process_1.spawnSync)("docker", ["rm", "-f", exports.DEV_JAEGER_CONTAINER], { stdio: "ignore" });
116
- }
117
- const start = startContainer();
118
- if (!start.ok) {
119
- return { status: "error", detail: start.detail };
120
- }
121
- const ready = await waitUntilReachable(opts.startupTimeoutMs ?? 15_000);
122
- if (!ready) {
123
- return {
124
- status: "skipped:probe-failed",
125
- detail: "Jaeger container started but OTLP port did not respond in time.",
126
- };
127
- }
128
- return {
129
- status: "started",
130
- endpoint: configs_js_1.JAEGER_OTLP_HTTP_URL,
131
- uiUrl: configs_js_1.JAEGER_UI_URL,
132
- };
133
- }
134
- /**
135
- * Stop the standalone dev Jaeger container.
136
- *
137
- * Idempotent: returns `not-running` when nothing matching is up. Does not
138
- * touch the `local up` Jaeger (different container name).
139
- */
140
- function stopDevJaeger() {
141
- if (!dockerAvailable()) {
142
- return {
143
- status: "skipped:no-docker",
144
- detail: "Docker is not running.",
145
- };
146
- }
147
- const state = inspectContainer(exports.DEV_JAEGER_CONTAINER);
148
- if (!state.exists) {
149
- return { status: "not-running" };
150
- }
151
- const result = (0, node_child_process_1.spawnSync)("docker", ["rm", "-f", exports.DEV_JAEGER_CONTAINER], {
152
- stdio: ["ignore", "ignore", "pipe"],
153
- });
154
- if (result.status === 0) {
155
- return { status: "stopped" };
156
- }
157
- const stderr = (result.stderr?.toString() ?? "").trim();
158
- return {
159
- status: "error",
160
- detail: stderr || `docker rm exited ${result.status}`,
161
- };
162
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Span exporter contract.
3
- *
4
- * Implementations ship completed TraceSpan records to an external trace
5
- * sink (OTLP collector, vendor backend, in-process pipeline, etc.).
6
- *
7
- * Exporters must never throw. Transport failures, malformed responses,
8
- * and shutdown races are all swallowed and logged through whatever
9
- * channel the implementation chooses.
10
- */
11
- import type { TraceSpan } from "../tracer.js";
12
- export interface SpanExporter {
13
- /** Best-effort export of one or more spans. Must never throw. */
14
- export(spans: ReadonlyArray<TraceSpan>): Promise<void>;
15
- /** Flush any pending state and release resources. Must never throw. */
16
- shutdown(): Promise<void>;
17
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /**
3
- * Span exporter contract.
4
- *
5
- * Implementations ship completed TraceSpan records to an external trace
6
- * sink (OTLP collector, vendor backend, in-process pipeline, etc.).
7
- *
8
- * Exporters must never throw. Transport failures, malformed responses,
9
- * and shutdown races are all swallowed and logged through whatever
10
- * channel the implementation chooses.
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- export type { SpanExporter } from "./exporter.js";
2
- export { OtlpExporter, otlpExporterFromEnv, parseKeyValueList, toReadableSpan, type OtlpExporterOptions, type OtlpProtocol, } from "./otlp.js";
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toReadableSpan = exports.parseKeyValueList = exports.otlpExporterFromEnv = exports.OtlpExporter = void 0;
4
- var otlp_js_1 = require("./otlp.js");
5
- Object.defineProperty(exports, "OtlpExporter", { enumerable: true, get: function () { return otlp_js_1.OtlpExporter; } });
6
- Object.defineProperty(exports, "otlpExporterFromEnv", { enumerable: true, get: function () { return otlp_js_1.otlpExporterFromEnv; } });
7
- Object.defineProperty(exports, "parseKeyValueList", { enumerable: true, get: function () { return otlp_js_1.parseKeyValueList; } });
8
- Object.defineProperty(exports, "toReadableSpan", { enumerable: true, get: function () { return otlp_js_1.toReadableSpan; } });
@@ -1,103 +0,0 @@
1
- /**
2
- * OTLP exporter — SDK-backed.
3
- *
4
- * Bridges our internal `TraceSpan` records into the official OpenTelemetry
5
- * SDK exporters from `@opentelemetry/exporter-trace-otlp-http` and
6
- * `@opentelemetry/exporter-trace-otlp-proto`. Each completed `TraceSpan`
7
- * is converted to a `ReadableSpan` shape and handed to the SDK exporter,
8
- * which serializes (JSON or protobuf) and POSTs to an OTLP HTTP endpoint.
9
- *
10
- * Standard OTel env vars consumed by `otlpExporterFromEnv()`. Each one has
11
- * an `ORY_OTLP_*`-prefixed alias that is consulted as a fallback when the
12
- * standard name is unset. Some harnesses (notably Claude Code) sanitize the
13
- * env passed to hook subprocesses and drop every `OTEL_*` var, so the dev
14
- * launcher mirrors each setting under the Ory prefix to survive the strip.
15
- *
16
- * Standard name Ory-prefixed fallback
17
- * ───────────────────────────────────── ─────────────────────────────────
18
- * OTEL_EXPORTER_OTLP_ENDPOINT ORY_OTLP_ENDPOINT
19
- * OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ORY_OTLP_TRACES_ENDPOINT
20
- * OTEL_EXPORTER_OTLP_HEADERS ORY_OTLP_HEADERS
21
- * OTEL_EXPORTER_OTLP_TRACES_HEADERS ORY_OTLP_TRACES_HEADERS
22
- * OTEL_EXPORTER_OTLP_PROTOCOL ORY_OTLP_PROTOCOL
23
- * OTEL_EXPORTER_OTLP_TRACES_PROTOCOL ORY_OTLP_TRACES_PROTOCOL
24
- * OTEL_SERVICE_NAME ORY_OTLP_SERVICE_NAME
25
- * OTEL_RESOURCE_ATTRIBUTES ORY_OTLP_RESOURCE_ATTRIBUTES
26
- *
27
- * Failures are swallowed (callers receive a resolved Promise) so trace
28
- * export can never break the agent session. Transport errors surface
29
- * through the `onError` callback.
30
- */
31
- import { type AttributeValue } from "@opentelemetry/api";
32
- import { type Resource } from "@opentelemetry/resources";
33
- import type { ReadableSpan } from "@opentelemetry/sdk-trace-base";
34
- import type { SpanExporter as SdkSpanExporter } from "@opentelemetry/sdk-trace-base";
35
- import type { SpanExporter } from "./exporter.js";
36
- import type { TraceSpan } from "../tracer.js";
37
- export type OtlpProtocol = "http/json" | "http/protobuf";
38
- export interface OtlpExporterOptions {
39
- /** Full traces endpoint (e.g. `http://localhost:4318/v1/traces`). */
40
- endpoint: string;
41
- /** Wire protocol. Default: `http/protobuf` (the OTel spec default). */
42
- protocol?: OtlpProtocol;
43
- /** Additional HTTP headers to send with each request. */
44
- headers?: Record<string, string>;
45
- /** Resource attributes merged into every export. */
46
- resource?: Record<string, AttributeValue>;
47
- /** Per-request timeout in milliseconds. Default: 5000. */
48
- timeoutMs?: number;
49
- /** Optional sink for transport errors. Defaults to a no-op. */
50
- onError?: (err: unknown) => void;
51
- /**
52
- * Inject a custom SDK exporter (used by tests). When provided, supersedes
53
- * the protocol selector — the wrapper passes converted ReadableSpans to
54
- * this exporter as-is.
55
- */
56
- sdkExporter?: SdkSpanExporter;
57
- }
58
- /**
59
- * OTLP exporter that delegates wire-format serialization and HTTP transport
60
- * to the official `@opentelemetry/exporter-trace-otlp-*` SDK exporters.
61
- */
62
- export declare class OtlpExporter implements SpanExporter {
63
- readonly endpoint: string;
64
- readonly protocol: OtlpProtocol;
65
- readonly headers: Record<string, string>;
66
- readonly resource: Resource;
67
- private readonly delegate;
68
- private readonly onError;
69
- private readonly inFlight;
70
- constructor(opts: OtlpExporterOptions);
71
- export(spans: ReadonlyArray<TraceSpan>): Promise<void>;
72
- shutdown(): Promise<void>;
73
- }
74
- /**
75
- * Build an OtlpExporter from process env. Returns undefined when no
76
- * endpoint is configured or the requested protocol is unsupported.
77
- */
78
- export declare function otlpExporterFromEnv(opts: {
79
- harness: string;
80
- hostname?: string;
81
- user?: string;
82
- pluginVersion?: string;
83
- cwd?: string;
84
- gitBranch?: string;
85
- gitCommit?: string;
86
- onError?: (err: unknown) => void;
87
- env?: NodeJS.ProcessEnv;
88
- }): OtlpExporter | undefined;
89
- /**
90
- * Read an OTel env var, falling back to its `ORY_OTLP_*`-prefixed alias when
91
- * the standard name is unset. Trims whitespace and treats empty strings as
92
- * absent so a propagated-but-blank var doesn't shadow the alias.
93
- */
94
- export declare function readEnvWithAlias(env: NodeJS.ProcessEnv, standardName: string): string | undefined;
95
- /**
96
- * Parse the OTel `k=v,k2=v2` env-var format. Values may be URL-encoded.
97
- */
98
- export declare function parseKeyValueList(raw: string | undefined): Record<string, string>;
99
- /**
100
- * Convert our internal `TraceSpan` record to an OTel SDK `ReadableSpan`.
101
- * Exported for tests; the OTLP exporters consume this shape directly.
102
- */
103
- export declare function toReadableSpan(span: TraceSpan, resource: Resource): ReadableSpan;