@vymalo/opencode-core-otel 0.14.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.
- package/LICENSE +21 -0
- package/README.md +40 -0
- package/dist/config.d.ts +39 -0
- package/dist/config.js +237 -0
- package/dist/config.js.map +1 -0
- package/dist/deferred.d.ts +22 -0
- package/dist/deferred.js +29 -0
- package/dist/deferred.js.map +1 -0
- package/dist/export-logging.d.ts +28 -0
- package/dist/export-logging.js +74 -0
- package/dist/export-logging.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/instruments.d.ts +29 -0
- package/dist/instruments.js +103 -0
- package/dist/instruments.js.map +1 -0
- package/dist/lib.d.ts +11 -0
- package/dist/lib.js +12 -0
- package/dist/lib.js.map +1 -0
- package/dist/logging.d.ts +16 -0
- package/dist/logging.js +69 -0
- package/dist/logging.js.map +1 -0
- package/dist/propagation.d.ts +22 -0
- package/dist/propagation.js +57 -0
- package/dist/propagation.js.map +1 -0
- package/dist/providers.d.ts +66 -0
- package/dist/providers.js +242 -0
- package/dist/providers.js.map +1 -0
- package/dist/recorder.d.ts +166 -0
- package/dist/recorder.js +795 -0
- package/dist/recorder.js.map +1 -0
- package/dist/token-source.d.ts +59 -0
- package/dist/token-source.js +125 -0
- package/dist/token-source.js.map +1 -0
- package/dist/types.d.ts +104 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/vcs.d.ts +63 -0
- package/dist/vcs.js +188 -0
- package/dist/vcs.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,SAGE,cAEA,UACA,gBACA,aACK;AACP,SAAS,sBAAsB;AAG/B,SAAS,mBAAmB,sBAAwC;;;;;;;AAiEpE,MAAM,qBAAqB;AAE3B,SAAS,QAAQ,WAAmB,MAAsB;CACxD,OAAO,GAAG,YAAY,qBAAqB;AAC7C;A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AAe,KAAK,cAAc;GAClC,aAAa,KAAK,YAAY;GAC9B,OAAO,KAAK,MAAM;EACpB;CACF;CAEA,MAAM,WAA0B;EAC9B,KAAK,MAAM,CAAC,WAAW,UAAU,KAAK,UAAU;GAC9C,KAAK,iBAAiB,WAAW,KAAK;GACtC,MAAM,MAAM,IAAI;EAClB;EACA,KAAK,SAAS,MAAM;EACpB,KAAK,MAAM,QAAQ,CAAC,GAAG,KAAK,MAAM,OAAO,GAAG,GAAG,KAAK,aAAa,OAAO,CAAC,GAAG;GAC1E,KAAK,MAAM,IAAI;EACjB;EACA,KAAK,MAAM,MAAM;EACjB,KAAK,aAAa,MAAM;EACxB,KAAK,MAAM,QAAQ,KAAK,MAAM,OAAO,GAAG;GACtC,KAAK,MAAM,IAAI;EACjB;EACA,KAAK,MAAM,MAAM;EACjB,MAAM,KAAK,KAAK,UAAU,SAAS;CACrC;AACF","names":[],"sources":["../src/recorder.ts"],"version":3,"file":"recorder.js","sourceRoot":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Logger } from "./logging.js";
|
|
2
|
+
/** Refresh this far before the token's own expiry, so an export never races it. */
|
|
3
|
+
export declare const EXPIRY_SKEW_MS = 3e4;
|
|
4
|
+
/** Used when the token carries no readable `exp`. Below Keycloak's 300s default. */
|
|
5
|
+
export declare const DEFAULT_REFRESH_MS = 24e4;
|
|
6
|
+
export interface RunResult {
|
|
7
|
+
stdout: string;
|
|
8
|
+
stderr: string;
|
|
9
|
+
code: number;
|
|
10
|
+
}
|
|
11
|
+
/** Injectable command runner, so tests never spawn a process. */
|
|
12
|
+
export type CommandRunner = (command: string, args: string[], timeoutMs: number) => Promise<RunResult>;
|
|
13
|
+
export interface TokenSourceOptions {
|
|
14
|
+
/** Argv of the credential helper, e.g. `["governance-auth", "token"]`. */
|
|
15
|
+
command: string[];
|
|
16
|
+
/** Header to carry the token. Default `Authorization`. */
|
|
17
|
+
header?: string;
|
|
18
|
+
/** Value prefix. Default `Bearer `. */
|
|
19
|
+
prefix?: string;
|
|
20
|
+
/** Fallback cadence when the token has no readable `exp`. */
|
|
21
|
+
refreshMs?: number;
|
|
22
|
+
/** How long the helper may take before it is killed. Default 10s. */
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
logger: Logger;
|
|
25
|
+
now?: () => number;
|
|
26
|
+
run?: CommandRunner;
|
|
27
|
+
}
|
|
28
|
+
export interface TokenSource {
|
|
29
|
+
/**
|
|
30
|
+
* A `HeadersFactory` for the OTLP exporters — called before every export.
|
|
31
|
+
* Never throws: the exporters explicitly require that.
|
|
32
|
+
*/
|
|
33
|
+
headers(): Promise<Record<string, string>>;
|
|
34
|
+
/** Drop the cached token so the next call re-runs the helper. */
|
|
35
|
+
invalidate(): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Read a JWT's `exp` without verifying it. We are not authenticating anything —
|
|
39
|
+
* we only want to know when to ask the helper for a new token, and the issuer's
|
|
40
|
+
* signature is the collector's business, not ours.
|
|
41
|
+
*/
|
|
42
|
+
export declare function readJwtExpiry(token: string): number | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* A credential helper as a header source: run a command, take its stdout as the
|
|
45
|
+
* access token, cache it until shortly before it expires.
|
|
46
|
+
*
|
|
47
|
+
* Matches the contract `governance-auth token` documents (ADR-0010 in
|
|
48
|
+
* `lightbridge-governance`): **stdout is the token and nothing else**, everything
|
|
49
|
+
* else goes to stderr, and a failure is a non-zero exit with empty stdout rather
|
|
50
|
+
* than a stale value.
|
|
51
|
+
*
|
|
52
|
+
* Failure behaviour is deliberately asymmetric. A helper that fails while the
|
|
53
|
+
* cached token is *still valid* changes nothing — the cached token is current,
|
|
54
|
+
* not stale, and dropping it would lose data for no reason. A helper that fails
|
|
55
|
+
* with no valid token left emits **no auth header at all**, so the export fails
|
|
56
|
+
* closed at the collector rather than being retried forever with a dead
|
|
57
|
+
* credential. Either way the failure is logged; the token never is.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createTokenSource(options: TokenSourceOptions): TokenSource;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
/** Refresh this far before the token's own expiry, so an export never races it. */
|
|
3
|
+
export const EXPIRY_SKEW_MS = 3e4;
|
|
4
|
+
/** Used when the token carries no readable `exp`. Below Keycloak's 300s default. */
|
|
5
|
+
export const DEFAULT_REFRESH_MS = 24e4;
|
|
6
|
+
const defaultRunner = (command, args, timeoutMs) => new Promise((resolve) => {
|
|
7
|
+
execFile(command, args, {
|
|
8
|
+
timeout: timeoutMs,
|
|
9
|
+
maxBuffer: 1024 * 1024,
|
|
10
|
+
windowsHide: true
|
|
11
|
+
}, (error, stdout, stderr) => {
|
|
12
|
+
const code = error && typeof error.code === "number" ? error.code : error ? 1 : 0;
|
|
13
|
+
resolve({
|
|
14
|
+
stdout: String(stdout ?? ""),
|
|
15
|
+
stderr: String(stderr ?? ""),
|
|
16
|
+
code
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Read a JWT's `exp` without verifying it. We are not authenticating anything —
|
|
22
|
+
* we only want to know when to ask the helper for a new token, and the issuer's
|
|
23
|
+
* signature is the collector's business, not ours.
|
|
24
|
+
*/
|
|
25
|
+
export function readJwtExpiry(token) {
|
|
26
|
+
const parts = token.split(".");
|
|
27
|
+
if (parts.length !== 3) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const payload = parts[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
32
|
+
const padded = payload + "=".repeat((4 - payload.length % 4) % 4);
|
|
33
|
+
const decoded = JSON.parse(Buffer.from(padded, "base64").toString("utf8"));
|
|
34
|
+
return typeof decoded.exp === "number" && Number.isFinite(decoded.exp) ? decoded.exp * 1e3 : undefined;
|
|
35
|
+
} catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A credential helper as a header source: run a command, take its stdout as the
|
|
41
|
+
* access token, cache it until shortly before it expires.
|
|
42
|
+
*
|
|
43
|
+
* Matches the contract `governance-auth token` documents (ADR-0010 in
|
|
44
|
+
* `lightbridge-governance`): **stdout is the token and nothing else**, everything
|
|
45
|
+
* else goes to stderr, and a failure is a non-zero exit with empty stdout rather
|
|
46
|
+
* than a stale value.
|
|
47
|
+
*
|
|
48
|
+
* Failure behaviour is deliberately asymmetric. A helper that fails while the
|
|
49
|
+
* cached token is *still valid* changes nothing — the cached token is current,
|
|
50
|
+
* not stale, and dropping it would lose data for no reason. A helper that fails
|
|
51
|
+
* with no valid token left emits **no auth header at all**, so the export fails
|
|
52
|
+
* closed at the collector rather than being retried forever with a dead
|
|
53
|
+
* credential. Either way the failure is logged; the token never is.
|
|
54
|
+
*/
|
|
55
|
+
export function createTokenSource(options) {
|
|
56
|
+
const { command, header = "Authorization", prefix = "Bearer ", refreshMs = DEFAULT_REFRESH_MS, timeoutMs = 1e4, logger, now = Date.now, run = defaultRunner } = options;
|
|
57
|
+
const [executable, ...args] = command;
|
|
58
|
+
let token;
|
|
59
|
+
let validUntil = 0;
|
|
60
|
+
/** Shared so concurrent exports spawn one helper process, not three. */
|
|
61
|
+
let inFlight;
|
|
62
|
+
const refresh = async () => {
|
|
63
|
+
const started = now();
|
|
64
|
+
let result;
|
|
65
|
+
try {
|
|
66
|
+
result = await run(executable, args, timeoutMs);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
logger.warn("otel_token_command_failed", {
|
|
69
|
+
command: executable,
|
|
70
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
71
|
+
});
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const value = result.stdout.trim();
|
|
75
|
+
if (result.code !== 0 || value === "") {
|
|
76
|
+
// Never log stdout/stderr contents — stderr of a credential helper can
|
|
77
|
+
// echo the request, and stdout *is* the secret.
|
|
78
|
+
logger.warn("otel_token_command_failed", {
|
|
79
|
+
command: executable,
|
|
80
|
+
exitCode: result.code,
|
|
81
|
+
emptyStdout: value === "",
|
|
82
|
+
stderrLength: result.stderr.length,
|
|
83
|
+
durationMs: now() - started
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
token = value;
|
|
88
|
+
const expiry = readJwtExpiry(value);
|
|
89
|
+
validUntil = expiry ? expiry - EXPIRY_SKEW_MS : now() + refreshMs;
|
|
90
|
+
logger.debug("otel_token_refreshed", {
|
|
91
|
+
command: executable,
|
|
92
|
+
// Absolute time, not the token: enough to debug an expiry problem.
|
|
93
|
+
validUntil: new Date(validUntil).toISOString(),
|
|
94
|
+
source: expiry ? "jwt_exp" : "refresh_interval",
|
|
95
|
+
durationMs: now() - started
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
async headers() {
|
|
100
|
+
if (!token || now() >= validUntil) {
|
|
101
|
+
inFlight ??= refresh().finally(() => {
|
|
102
|
+
inFlight = undefined;
|
|
103
|
+
});
|
|
104
|
+
await inFlight;
|
|
105
|
+
}
|
|
106
|
+
if (!token) {
|
|
107
|
+
return {};
|
|
108
|
+
}
|
|
109
|
+
if (now() >= validUntil) {
|
|
110
|
+
// Refresh failed and what we hold has aged out. Fail closed rather than
|
|
111
|
+
// present a credential the collector will reject anyway.
|
|
112
|
+
logger.warn("otel_token_expired", { command: executable });
|
|
113
|
+
token = undefined;
|
|
114
|
+
return {};
|
|
115
|
+
}
|
|
116
|
+
return { [header]: `${prefix}${token}` };
|
|
117
|
+
},
|
|
118
|
+
invalidate() {
|
|
119
|
+
token = undefined;
|
|
120
|
+
validUntil = 0;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=token-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,SAAS,gBAAgB;;AAKzB,OAAO,MAAM,iBAAiB;;AAG9B,OAAO,MAAM,qBAAqB;AAyClC,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AA6B;IACvC,SAAS;IACT,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAC/D,CAAC;GACD;EACF;EAEA,MAAM,QAAQ,OAAO,OAAO,KAAK;EACjC,IAAI,OAAO,SAAS,KAAK,UAAU,IAAI;;;GAGrC,OAAO,KAAK,6BAA6B;IACvC,SAAS;IACT,UAAU,OAAO;IACjB,aAAa,UAAU;IACvB,cAAc,OAAO,OAAO;IAC5B,YAAY,IAAI,IAAI;GACtB,CAAC;GACD;EACF;EAEA,QAAQ;EACR,MAAM,SAAS,cAAc,KAAK;EAClC,aAAa,SAAS,SAAS,iBAAiB,IAAI,IAAI;EACxD,OAAO,MAAM,wBAAwB;GACnC,SAAS;;GAET,YAAY,IAAI,KAAK,UAAU,CAAC,CAAC,YAAY;GAC7C,QAAQ,SAAS,YAAY;GAC7B,YAAY,IAAI,IAAI;EACtB,CAAC;CACH;CAEA,OAAO;EACL,MAAM,UAAU;GACd,IAAI,CAAC,SAAS,IAAI,KAAK,YAAY;IACjC,aAAa,QAAQ,CAAC,CAAC,cAAc;KACnC,WAAW;IACb,CAAC;IACD,MAAM;GACR;GAEA,IAAI,CAAC,OAAO;IACV,OAAO,CAAC;GACV;GACA,IAAI,IAAI,KAAK,YAAY;;;IAGvB,OAAO,KAAK,sBAAsB,EAAE,SAAS,WAAW,CAAC;IACzD,QAAQ;IACR,OAAO,CAAC;GACV;GACA,OAAO,GAAG,SAAS,GAAG,SAAS,QAAQ;EACzC;EACA,aAAa;GACX,QAAQ;GACR,aAAa;EACf;CACF;AACF","names":[],"sources":["../src/token-source.ts"],"version":3,"file":"token-source.js","sourceRoot":""}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export type LogLevel = "trace" | "debug" | "info" | "warn" | "error";
|
|
2
|
+
/**
|
|
3
|
+
* Where a signal is sent. `otlp` is OTLP/HTTP-protobuf (the only wire transport
|
|
4
|
+
* this plugin ships — see ADR-0009 for why gRPC is absent); `console` prints to
|
|
5
|
+
* stdout for local debugging; `none` records nothing.
|
|
6
|
+
*/
|
|
7
|
+
export type ExporterKind = "otlp" | "console" | "none";
|
|
8
|
+
/** The three OTel signals, independently toggleable. */
|
|
9
|
+
export type SignalName = "traces" | "metrics" | "logs";
|
|
10
|
+
/**
|
|
11
|
+
* Plugin options as written in `opencode.json` (or served through
|
|
12
|
+
* `.well-known/opencode`). Every field is optional and every field has a
|
|
13
|
+
* standard `OTEL_*` environment counterpart that **overrides** it — see
|
|
14
|
+
* `resolveOtelConfig`.
|
|
15
|
+
*/
|
|
16
|
+
export interface OtelPluginOptions {
|
|
17
|
+
/** Master switch. `false` returns inert hooks without initializing anything. */
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
/** OTLP/HTTP base URL, e.g. `http://localhost:4318`. Signal paths are appended. */
|
|
20
|
+
endpoint?: string;
|
|
21
|
+
/** Per-signal endpoint overrides. A full URL including the signal path. */
|
|
22
|
+
endpoints?: Partial<Record<SignalName, string>>;
|
|
23
|
+
/** Headers sent with every OTLP request (auth tokens live here). */
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* A credential helper that prints a fresh access token on stdout, re-run
|
|
27
|
+
* before the cached one expires. Use instead of a static `Authorization`
|
|
28
|
+
* header when the collector is behind a short-lived OIDC token.
|
|
29
|
+
* String or argv array, e.g. `"governance-auth token"`.
|
|
30
|
+
*/
|
|
31
|
+
tokenCommand?: string | string[];
|
|
32
|
+
/** Header the token goes in. Default `Authorization`. */
|
|
33
|
+
tokenHeader?: string;
|
|
34
|
+
/** Token value prefix. Default `Bearer `. */
|
|
35
|
+
tokenPrefix?: string;
|
|
36
|
+
/** Fallback refresh cadence when the token carries no readable `exp`, ms. */
|
|
37
|
+
tokenRefreshMs?: number;
|
|
38
|
+
/** How long the helper may run before being killed, ms. Default 10000. */
|
|
39
|
+
tokenTimeoutMs?: number;
|
|
40
|
+
/** Which signals to export. Omitted signals default to `otlp` when an endpoint is set. */
|
|
41
|
+
exporters?: Partial<Record<SignalName, ExporterKind>>;
|
|
42
|
+
/** `service.name` resource attribute. Defaults to `opencode`. */
|
|
43
|
+
serviceName?: string;
|
|
44
|
+
/** Deployment tag, mirroring Codex's `[otel] environment`. Sets `deployment.environment.name`. */
|
|
45
|
+
environment?: string;
|
|
46
|
+
/** Extra resource attributes merged onto the defaults. */
|
|
47
|
+
resourceAttributes?: Record<string, string>;
|
|
48
|
+
/**
|
|
49
|
+
* Read repository metadata (remote URL, owner, branch, revision) off disk and
|
|
50
|
+
* attach it to the resource. On by default. Credentials in the remote URL are
|
|
51
|
+
* always stripped; set `false` to publish no repository identity at all.
|
|
52
|
+
*/
|
|
53
|
+
collectVcs?: boolean;
|
|
54
|
+
/** Metric export interval, ms. Default 60000. */
|
|
55
|
+
metricExportIntervalMs?: number;
|
|
56
|
+
/** Log record export interval, ms. Default 5000. */
|
|
57
|
+
logExportIntervalMs?: number;
|
|
58
|
+
/** Span export interval, ms. Default 5000. */
|
|
59
|
+
traceExportIntervalMs?: number;
|
|
60
|
+
/** `delta` (default) or `cumulative` metric temporality. */
|
|
61
|
+
metricTemporality?: MetricTemporality;
|
|
62
|
+
/**
|
|
63
|
+
* Attach `gen_ai.conversation.id` to **metrics** as well as logs/spans.
|
|
64
|
+
* Off by default: session id is unbounded cardinality and most metric
|
|
65
|
+
* backends bill per series. Logs and spans always carry it.
|
|
66
|
+
*/
|
|
67
|
+
includeSessionId?: boolean;
|
|
68
|
+
/** Tool names excluded from span generation. They are still counted in metrics. */
|
|
69
|
+
filteredTools?: string[];
|
|
70
|
+
/**
|
|
71
|
+
* Inject W3C `traceparent` into provider HTTP requests by wrapping
|
|
72
|
+
* `provider.options.fetch`, so gateway-side spans join the session trace.
|
|
73
|
+
* On by default when traces are enabled.
|
|
74
|
+
*/
|
|
75
|
+
propagateTraceContext?: boolean;
|
|
76
|
+
}
|
|
77
|
+
export type MetricTemporality = "delta" | "cumulative";
|
|
78
|
+
/** Fully resolved configuration — defaults applied, env overrides folded in. */
|
|
79
|
+
export interface ResolvedOtelConfig {
|
|
80
|
+
enabled: boolean;
|
|
81
|
+
/** True when at least one signal has a live (non-`none`) exporter. */
|
|
82
|
+
active: boolean;
|
|
83
|
+
endpoint?: string;
|
|
84
|
+
endpoints: Partial<Record<SignalName, string>>;
|
|
85
|
+
headers: Record<string, string>;
|
|
86
|
+
/** Argv of the credential helper; empty when none is configured. */
|
|
87
|
+
tokenCommand: string[];
|
|
88
|
+
tokenHeader: string;
|
|
89
|
+
tokenPrefix: string;
|
|
90
|
+
tokenRefreshMs: number;
|
|
91
|
+
tokenTimeoutMs: number;
|
|
92
|
+
exporters: Record<SignalName, ExporterKind>;
|
|
93
|
+
serviceName: string;
|
|
94
|
+
environment?: string;
|
|
95
|
+
resourceAttributes: Record<string, string>;
|
|
96
|
+
collectVcs: boolean;
|
|
97
|
+
metricExportIntervalMs: number;
|
|
98
|
+
logExportIntervalMs: number;
|
|
99
|
+
traceExportIntervalMs: number;
|
|
100
|
+
metricTemporality: MetricTemporality;
|
|
101
|
+
includeSessionId: boolean;
|
|
102
|
+
filteredTools: Set<string>;
|
|
103
|
+
propagateTraceContext: boolean;
|
|
104
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"","names":[],"sources":["../src/types.ts"],"version":3,"file":"types.js","sourceRoot":""}
|
package/dist/vcs.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** What we can learn about the checkout without shelling out to `git`. */
|
|
2
|
+
export interface VcsInfo {
|
|
3
|
+
/** Remote URL with any credentials stripped. */
|
|
4
|
+
url?: string;
|
|
5
|
+
/** Repository name, e.g. `lightbridge-opencode-toolbeit`. */
|
|
6
|
+
name?: string;
|
|
7
|
+
/** Owning org or user, e.g. `ADORSYS-GIS`. */
|
|
8
|
+
owner?: string;
|
|
9
|
+
/** `github` | `gitlab` | `bitbucket` | `gitea`, when the host says so. */
|
|
10
|
+
provider?: string;
|
|
11
|
+
/** Current branch or tag name. Absent on a detached HEAD. */
|
|
12
|
+
ref?: string;
|
|
13
|
+
/** `branch` or `tag`. */
|
|
14
|
+
refType?: string;
|
|
15
|
+
/** Full commit SHA of HEAD. */
|
|
16
|
+
revision?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Injectable reader so tests exercise the parsing without a real repository. */
|
|
19
|
+
export type FileReader = (path: string) => Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Strip credentials and normalise a git remote to something safe to export.
|
|
22
|
+
*
|
|
23
|
+
* The userinfo component is dropped **unconditionally**. A remote of the form
|
|
24
|
+
* `https://user:ghp_xxx@github.com/org/repo.git` is entirely ordinary in a CI
|
|
25
|
+
* checkout, and that token would otherwise be published as a resource attribute
|
|
26
|
+
* on every span, metric and log the process emits. Nothing in the userinfo
|
|
27
|
+
* identifies the repository, so there is no value being traded away.
|
|
28
|
+
*
|
|
29
|
+
* scp-like SSH remotes (`git@github.com:org/repo.git`) are rewritten to an
|
|
30
|
+
* `ssh://` URL rather than to `https://` — the transport is a fact about the
|
|
31
|
+
* checkout, and inventing a different scheme would misreport it.
|
|
32
|
+
*/
|
|
33
|
+
export declare function sanitizeRemoteUrl(raw: string): string | undefined;
|
|
34
|
+
/** Split `https://github.com/org/repo` into its owner, name and provider. */
|
|
35
|
+
export declare function describeRemote(url: string): Pick<VcsInfo, "name" | "owner" | "provider">;
|
|
36
|
+
/** Pull the `origin` remote out of a git config, falling back to the first one. */
|
|
37
|
+
export declare function parseRemoteFromConfig(config: string): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve the git directory for a checkout.
|
|
40
|
+
*
|
|
41
|
+
* `.git` is a **file** rather than a directory in a linked worktree or a
|
|
42
|
+
* submodule — it holds `gitdir: <path>`. This repository's own development
|
|
43
|
+
* happens in worktrees, so treating `.git` as always-a-directory would report
|
|
44
|
+
* nothing precisely where it is most used.
|
|
45
|
+
*
|
|
46
|
+
* Returns both the worktree's own git dir (which owns `HEAD`) and the common
|
|
47
|
+
* dir (which owns `config` and `packed-refs`); for a plain clone they are the
|
|
48
|
+
* same path.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveGitDirs(start: string, read?: FileReader): Promise<{
|
|
51
|
+
gitDir: string;
|
|
52
|
+
commonDir: string;
|
|
53
|
+
} | undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* Read repository metadata straight off disk. Never spawns `git`: the plugin
|
|
56
|
+
* runs inside the host's process on every session start, and a subprocess there
|
|
57
|
+
* costs more than the data is worth — and would fail wherever `git` is not on
|
|
58
|
+
* `PATH` while the files are right there.
|
|
59
|
+
*
|
|
60
|
+
* Every field is independent and best-effort. A repository with no remote still
|
|
61
|
+
* reports its branch; an unreadable config loses only the remote.
|
|
62
|
+
*/
|
|
63
|
+
export declare function readVcsInfo(start: string | undefined, read?: FileReader): Promise<VcsInfo>;
|
package/dist/vcs.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
3
|
+
const defaultReader = (path) => readFile(path, "utf8");
|
|
4
|
+
const PROVIDERS = [
|
|
5
|
+
[/(^|\.)github\.com$/i, "github"],
|
|
6
|
+
[/(^|\.)gitlab\.com$/i, "gitlab"],
|
|
7
|
+
[/(^|\.)bitbucket\.org$/i, "bitbucket"],
|
|
8
|
+
[/(^|\.)gitea\./i, "gitea"]
|
|
9
|
+
];
|
|
10
|
+
/**
|
|
11
|
+
* Strip credentials and normalise a git remote to something safe to export.
|
|
12
|
+
*
|
|
13
|
+
* The userinfo component is dropped **unconditionally**. A remote of the form
|
|
14
|
+
* `https://user:ghp_xxx@github.com/org/repo.git` is entirely ordinary in a CI
|
|
15
|
+
* checkout, and that token would otherwise be published as a resource attribute
|
|
16
|
+
* on every span, metric and log the process emits. Nothing in the userinfo
|
|
17
|
+
* identifies the repository, so there is no value being traded away.
|
|
18
|
+
*
|
|
19
|
+
* scp-like SSH remotes (`git@github.com:org/repo.git`) are rewritten to an
|
|
20
|
+
* `ssh://` URL rather than to `https://` — the transport is a fact about the
|
|
21
|
+
* checkout, and inventing a different scheme would misreport it.
|
|
22
|
+
*/
|
|
23
|
+
export function sanitizeRemoteUrl(raw) {
|
|
24
|
+
const trimmed = raw.trim();
|
|
25
|
+
if (trimmed === "") {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
// scp-like syntax has no scheme and a `:` separating host from path.
|
|
29
|
+
const scpLike = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+)$/.exec(trimmed);
|
|
30
|
+
const normalized = scpLike && !/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed) ? `ssh://${scpLike[2]}/${scpLike[3]}` : trimmed;
|
|
31
|
+
let parsed;
|
|
32
|
+
try {
|
|
33
|
+
parsed = new URL(normalized);
|
|
34
|
+
} catch {
|
|
35
|
+
// A local path (`/srv/git/repo.git`) or something unparseable: report
|
|
36
|
+
// nothing rather than guessing at its shape.
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
parsed.username = "";
|
|
40
|
+
parsed.password = "";
|
|
41
|
+
parsed.hash = "";
|
|
42
|
+
parsed.search = "";
|
|
43
|
+
parsed.pathname = parsed.pathname.replace(/\.git\/?$/, "");
|
|
44
|
+
return parsed.toString().replace(/\/$/, "");
|
|
45
|
+
}
|
|
46
|
+
/** Split `https://github.com/org/repo` into its owner, name and provider. */
|
|
47
|
+
export function describeRemote(url) {
|
|
48
|
+
let parsed;
|
|
49
|
+
try {
|
|
50
|
+
parsed = new URL(url);
|
|
51
|
+
} catch {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
const segments = parsed.pathname.split("/").filter((s) => s !== "");
|
|
55
|
+
const provider = PROVIDERS.find(([pattern]) => pattern.test(parsed.hostname))?.[1];
|
|
56
|
+
return {
|
|
57
|
+
...segments.length > 0 ? { name: segments[segments.length - 1] } : {},
|
|
58
|
+
...segments.length > 1 ? { owner: segments[segments.length - 2] } : {},
|
|
59
|
+
...provider ? { provider } : {}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** Pull the `origin` remote out of a git config, falling back to the first one. */
|
|
63
|
+
export function parseRemoteFromConfig(config) {
|
|
64
|
+
const remotes = new Map();
|
|
65
|
+
let current;
|
|
66
|
+
for (const line of config.split("\n")) {
|
|
67
|
+
const section = /^\s*\[remote\s+"([^"]+)"\]/.exec(line);
|
|
68
|
+
if (section) {
|
|
69
|
+
current = section[1];
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (/^\s*\[/.test(line)) {
|
|
73
|
+
current = undefined;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const url = current ? /^\s*url\s*=\s*(.+?)\s*$/.exec(line) : null;
|
|
77
|
+
if (url && current && !remotes.has(current)) {
|
|
78
|
+
remotes.set(current, url[1]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return remotes.get("origin") ?? remotes.values().next().value;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Resolve the git directory for a checkout.
|
|
85
|
+
*
|
|
86
|
+
* `.git` is a **file** rather than a directory in a linked worktree or a
|
|
87
|
+
* submodule — it holds `gitdir: <path>`. This repository's own development
|
|
88
|
+
* happens in worktrees, so treating `.git` as always-a-directory would report
|
|
89
|
+
* nothing precisely where it is most used.
|
|
90
|
+
*
|
|
91
|
+
* Returns both the worktree's own git dir (which owns `HEAD`) and the common
|
|
92
|
+
* dir (which owns `config` and `packed-refs`); for a plain clone they are the
|
|
93
|
+
* same path.
|
|
94
|
+
*/
|
|
95
|
+
export async function resolveGitDirs(start, read = defaultReader) {
|
|
96
|
+
let gitDir;
|
|
97
|
+
try {
|
|
98
|
+
const pointer = await read(join(start, ".git"));
|
|
99
|
+
const match = /^gitdir:\s*(.+?)\s*$/m.exec(pointer);
|
|
100
|
+
if (match) {
|
|
101
|
+
gitDir = isAbsolute(match[1]) ? match[1] : resolve(start, match[1]);
|
|
102
|
+
}
|
|
103
|
+
} catch {}
|
|
104
|
+
if (!gitDir) {
|
|
105
|
+
try {
|
|
106
|
+
await read(join(start, ".git", "HEAD"));
|
|
107
|
+
gitDir = join(start, ".git");
|
|
108
|
+
} catch {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
let commonDir = gitDir;
|
|
113
|
+
try {
|
|
114
|
+
const common = (await read(join(gitDir, "commondir"))).trim();
|
|
115
|
+
if (common !== "") {
|
|
116
|
+
commonDir = isAbsolute(common) ? common : resolve(gitDir, common);
|
|
117
|
+
}
|
|
118
|
+
} catch {}
|
|
119
|
+
return {
|
|
120
|
+
gitDir,
|
|
121
|
+
commonDir
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
async function readRevision(ref, gitDir, commonDir, read) {
|
|
125
|
+
for (const base of new Set([gitDir, commonDir])) {
|
|
126
|
+
try {
|
|
127
|
+
const sha = (await read(join(base, ref))).trim();
|
|
128
|
+
if (/^[0-9a-f]{40,64}$/i.test(sha)) {
|
|
129
|
+
return sha;
|
|
130
|
+
}
|
|
131
|
+
} catch {}
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
const packed = await read(join(commonDir, "packed-refs"));
|
|
135
|
+
for (const line of packed.split("\n")) {
|
|
136
|
+
const [sha, name] = line.trim().split(/\s+/);
|
|
137
|
+
if (name === ref && /^[0-9a-f]{40,64}$/i.test(sha)) {
|
|
138
|
+
return sha;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} catch {}
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Read repository metadata straight off disk. Never spawns `git`: the plugin
|
|
146
|
+
* runs inside the host's process on every session start, and a subprocess there
|
|
147
|
+
* costs more than the data is worth — and would fail wherever `git` is not on
|
|
148
|
+
* `PATH` while the files are right there.
|
|
149
|
+
*
|
|
150
|
+
* Every field is independent and best-effort. A repository with no remote still
|
|
151
|
+
* reports its branch; an unreadable config loses only the remote.
|
|
152
|
+
*/
|
|
153
|
+
export async function readVcsInfo(start, read = defaultReader) {
|
|
154
|
+
if (!start) {
|
|
155
|
+
return {};
|
|
156
|
+
}
|
|
157
|
+
const dirs = await resolveGitDirs(start, read);
|
|
158
|
+
if (!dirs) {
|
|
159
|
+
return {};
|
|
160
|
+
}
|
|
161
|
+
const { gitDir, commonDir } = dirs;
|
|
162
|
+
const info = {};
|
|
163
|
+
try {
|
|
164
|
+
const url = parseRemoteFromConfig(await read(join(commonDir, "config")));
|
|
165
|
+
const sanitized = url ? sanitizeRemoteUrl(url) : undefined;
|
|
166
|
+
if (sanitized) {
|
|
167
|
+
info.url = sanitized;
|
|
168
|
+
Object.assign(info, describeRemote(sanitized));
|
|
169
|
+
}
|
|
170
|
+
} catch {}
|
|
171
|
+
try {
|
|
172
|
+
const head = (await read(join(gitDir, "HEAD"))).trim();
|
|
173
|
+
const symbolic = /^ref:\s*(.+)$/.exec(head);
|
|
174
|
+
if (symbolic) {
|
|
175
|
+
const ref = symbolic[1].trim();
|
|
176
|
+
const tag = ref.startsWith("refs/tags/");
|
|
177
|
+
info.ref = ref.replace(/^refs\/(heads|tags)\//, "");
|
|
178
|
+
info.refType = tag ? "tag" : "branch";
|
|
179
|
+
info.revision = await readRevision(ref, gitDir, commonDir, read);
|
|
180
|
+
} else if (/^[0-9a-f]{40,64}$/i.test(head)) {
|
|
181
|
+
// Detached HEAD: there is a revision but no ref name to report.
|
|
182
|
+
info.revision = head;
|
|
183
|
+
}
|
|
184
|
+
} catch {}
|
|
185
|
+
return info;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
//# sourceMappingURL=vcs.js.map
|
package/dist/vcs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,SAAS,gBAAgB;AACzB,SAAS,YAAY,MAAM,eAAe;AAuB1C,MAAM,iBAA6B,SAAS,SAAS,MAAM,MAAM;AAEjE,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