@osfactory/otel-hook 0.8.0 → 0.9.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 +117 -1
- package/dist/cli.js +1470 -682
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +3 -2
- package/dist/config.js +451 -164
- package/dist/config.js.map +1 -1
- package/dist/destinations-C6Bm89W6.d.ts +169 -0
- package/dist/diagnostics.d.ts +8 -0
- package/dist/diagnostics.js +2 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/{otlp-log-sink-zuHojHSP.d.ts → export-destinations-d8tZV0G4.d.ts} +239 -7
- package/dist/{hook-Dh8OO4Wa.d.ts → hook-zA1b4cWd.d.ts} +2 -2
- package/dist/index.d.ts +7 -6
- package/dist/index.js +1350 -677
- package/dist/index.js.map +1 -1
- package/dist/integration.d.ts +25 -7
- package/dist/integration.js +703 -135
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.js +1 -1
- package/dist/lifecycle.js.map +1 -1
- package/dist/providers.d.ts +3 -3
- package/dist/{registry-CIVvRlVK.d.ts → registry-B8ZHc2bc.d.ts} +1 -1
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +245 -121
- package/dist/runtime.js.map +1 -1
- package/dist/{schema-Cn0-xz8L.d.ts → schema-BxiVsU-d.d.ts} +68 -2
- package/dist/telemetry.d.ts +22 -65
- package/dist/telemetry.js +625 -32
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +3 -3
- package/dist/testing.js +659 -535
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1676,37 +1676,361 @@ var sanitizeResourceAttributes = (attributes) => {
|
|
|
1676
1676
|
var describeResourceAttributeNames = (attributes) => Object.keys(attributes).sort();
|
|
1677
1677
|
|
|
1678
1678
|
// src/config/schema.ts
|
|
1679
|
+
import { z as z14 } from "zod";
|
|
1680
|
+
|
|
1681
|
+
// src/config/destinations.ts
|
|
1679
1682
|
import { z as z13 } from "zod";
|
|
1680
|
-
|
|
1681
|
-
|
|
1683
|
+
|
|
1684
|
+
// src/config/header-value.ts
|
|
1685
|
+
var isUnsafeHeaderValue = (value) => [...value].some((char) => {
|
|
1686
|
+
const code = char.codePointAt(0) ?? 0;
|
|
1687
|
+
return code < 32 && code !== 9 || code === 127 || code > 255;
|
|
1688
|
+
});
|
|
1689
|
+
|
|
1690
|
+
// src/config/otlp-headers.ts
|
|
1691
|
+
var MAX_OTLP_HEADERS = 32;
|
|
1692
|
+
var OTLP_HEADER_VARIABLES = Object.freeze({
|
|
1693
|
+
generic: "OTEL_EXPORTER_OTLP_HEADERS",
|
|
1694
|
+
traces: "OTEL_EXPORTER_OTLP_TRACES_HEADERS",
|
|
1695
|
+
logs: "OTEL_EXPORTER_OTLP_LOGS_HEADERS"
|
|
1696
|
+
});
|
|
1697
|
+
var HEADER_NAME_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
1698
|
+
var decode = (raw) => {
|
|
1699
|
+
try {
|
|
1700
|
+
return decodeURIComponent(raw);
|
|
1701
|
+
} catch {
|
|
1702
|
+
return void 0;
|
|
1703
|
+
}
|
|
1704
|
+
};
|
|
1705
|
+
var parseOtlpHeadersValue = (raw) => {
|
|
1706
|
+
const headers = {};
|
|
1707
|
+
const warnings = [];
|
|
1708
|
+
let overflowed = false;
|
|
1709
|
+
for (const [index, rawEntry] of raw.split(",").entries()) {
|
|
1710
|
+
const position = String(index + 1);
|
|
1711
|
+
const entry = rawEntry.trim();
|
|
1712
|
+
if (entry === "") {
|
|
1713
|
+
continue;
|
|
1714
|
+
}
|
|
1715
|
+
const equals = entry.indexOf("=");
|
|
1716
|
+
if (equals <= 0) {
|
|
1717
|
+
warnings.push(`entry ${position} is not a key=value pair; ignored`);
|
|
1718
|
+
continue;
|
|
1719
|
+
}
|
|
1720
|
+
const key = decode(entry.slice(0, equals).trim());
|
|
1721
|
+
const value = decode(entry.slice(equals + 1).trim());
|
|
1722
|
+
if (key === void 0 || value === void 0) {
|
|
1723
|
+
warnings.push(`entry ${position} has malformed percent-encoding; ignored`);
|
|
1724
|
+
continue;
|
|
1725
|
+
}
|
|
1726
|
+
const name = key.trim();
|
|
1727
|
+
const trimmedValue = value.trim();
|
|
1728
|
+
if (!HEADER_NAME_PATTERN.test(name)) {
|
|
1729
|
+
warnings.push(`entry ${position} does not name a valid HTTP header; ignored`);
|
|
1730
|
+
continue;
|
|
1731
|
+
}
|
|
1732
|
+
if (trimmedValue === "") {
|
|
1733
|
+
warnings.push(`entry ${position} has an empty value; ignored`);
|
|
1734
|
+
continue;
|
|
1735
|
+
}
|
|
1736
|
+
if (isUnsafeHeaderValue(trimmedValue)) {
|
|
1737
|
+
warnings.push(`entry ${position} has a character not allowed in an HTTP header value; ignored`);
|
|
1738
|
+
continue;
|
|
1739
|
+
}
|
|
1740
|
+
const existing = findHeaderName(headers, name);
|
|
1741
|
+
if (existing === void 0 && Object.keys(headers).length >= MAX_OTLP_HEADERS) {
|
|
1742
|
+
overflowed = true;
|
|
1743
|
+
continue;
|
|
1744
|
+
}
|
|
1745
|
+
if (existing !== void 0) {
|
|
1746
|
+
delete headers[existing];
|
|
1747
|
+
}
|
|
1748
|
+
headers[name] = trimmedValue;
|
|
1749
|
+
}
|
|
1750
|
+
if (overflowed) {
|
|
1751
|
+
warnings.push(`more than ${String(MAX_OTLP_HEADERS)} headers were supplied; the excess was ignored`);
|
|
1752
|
+
}
|
|
1753
|
+
return { headers, warnings };
|
|
1754
|
+
};
|
|
1755
|
+
var findHeaderName = (headers, name) => {
|
|
1756
|
+
const lower = name.toLowerCase();
|
|
1757
|
+
return Object.keys(headers).find((candidate) => candidate.toLowerCase() === lower);
|
|
1758
|
+
};
|
|
1759
|
+
var mergeOtlpHeaders = (...sources) => {
|
|
1760
|
+
const merged = {};
|
|
1761
|
+
for (const source of sources) {
|
|
1762
|
+
for (const [name, value] of Object.entries(source)) {
|
|
1763
|
+
const existing = findHeaderName(merged, name);
|
|
1764
|
+
if (existing !== void 0) {
|
|
1765
|
+
delete merged[existing];
|
|
1766
|
+
}
|
|
1767
|
+
merged[name] = value;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
return merged;
|
|
1771
|
+
};
|
|
1772
|
+
var resolveOtlpHeaders = (env, explicit = {}) => {
|
|
1773
|
+
const warnings = [];
|
|
1774
|
+
const read = (variable) => {
|
|
1775
|
+
const raw = env[variable];
|
|
1776
|
+
if (raw === void 0 || raw.trim() === "") {
|
|
1777
|
+
return {};
|
|
1778
|
+
}
|
|
1779
|
+
const parsed = parseOtlpHeadersValue(raw);
|
|
1780
|
+
for (const detail of parsed.warnings) {
|
|
1781
|
+
warnings.push({ variable, detail });
|
|
1782
|
+
}
|
|
1783
|
+
return parsed.headers;
|
|
1784
|
+
};
|
|
1785
|
+
const generic = read(OTLP_HEADER_VARIABLES.generic);
|
|
1786
|
+
const traces = read(OTLP_HEADER_VARIABLES.traces);
|
|
1787
|
+
const logs = read(OTLP_HEADER_VARIABLES.logs);
|
|
1788
|
+
return {
|
|
1789
|
+
traces: mergeOtlpHeaders(generic, traces, explicit),
|
|
1790
|
+
logs: mergeOtlpHeaders(generic, logs, explicit),
|
|
1791
|
+
warnings
|
|
1792
|
+
};
|
|
1793
|
+
};
|
|
1794
|
+
var unionOtlpHeaderNames = (...lists) => {
|
|
1795
|
+
const names = [];
|
|
1796
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1797
|
+
for (const name of lists.flat()) {
|
|
1798
|
+
if (!seen.has(name.toLowerCase())) {
|
|
1799
|
+
seen.add(name.toLowerCase());
|
|
1800
|
+
names.push(name);
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
return names.sort().slice(0, MAX_OTLP_HEADERS);
|
|
1804
|
+
};
|
|
1805
|
+
var describeOtlpHeaderNames = (...sources) => unionOtlpHeaderNames(...sources.map((source) => Object.keys(source)));
|
|
1806
|
+
|
|
1807
|
+
// src/config/destinations.ts
|
|
1808
|
+
var DEFAULT_DESTINATION_NAME = "default";
|
|
1809
|
+
var DESTINATION_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
1810
|
+
var MAX_EXPORT_DESTINATIONS = 16;
|
|
1811
|
+
var MAX_DESTINATION_HEADERS = MAX_OTLP_HEADERS;
|
|
1812
|
+
var HEADER_ENV_REFERENCE_PREFIX = "env:";
|
|
1813
|
+
var HEADER_NAME_PATTERN2 = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;
|
|
1814
|
+
var ENV_VARIABLE_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
1815
|
+
var MAX_HEADER_VALUE_LENGTH = 8192;
|
|
1816
|
+
var exportSignalSchema = z13.enum(["traces", "logs"]);
|
|
1817
|
+
var headerValueSchema = z13.string().min(1).max(MAX_HEADER_VALUE_LENGTH).refine(
|
|
1818
|
+
(value) => !isUnsafeHeaderValue(value),
|
|
1819
|
+
"header values may not contain line breaks, control characters, or characters beyond Latin-1"
|
|
1820
|
+
).refine(
|
|
1821
|
+
(value) => !value.startsWith(HEADER_ENV_REFERENCE_PREFIX) || ENV_VARIABLE_NAME_PATTERN.test(value.slice(HEADER_ENV_REFERENCE_PREFIX.length)),
|
|
1822
|
+
"an env: header reference must name an environment variable, e.g. env:COLLECTOR_TOKEN"
|
|
1823
|
+
);
|
|
1824
|
+
var endpointSchema = z13.string().url().max(2048);
|
|
1825
|
+
var exportDestinationSchema = z13.strictObject({
|
|
1826
|
+
/** Unique, lowercase, filesystem-safe. `default` is reserved for the single-endpoint settings. */
|
|
1827
|
+
name: z13.string().regex(DESTINATION_NAME_PATTERN, "destination names are lowercase letters, digits, _ and -"),
|
|
1828
|
+
/** Default true. A disabled destination is neither sent to nor drained. */
|
|
1829
|
+
enabled: z13.boolean().optional(),
|
|
1830
|
+
/**
|
|
1831
|
+
* Traces URL, with the same meaning as `exporter.endpoint`: the logs URL is
|
|
1832
|
+
* derived from it (`/v1/traces` becomes `/v1/logs`) unless `logsEndpoint` is set.
|
|
1833
|
+
*/
|
|
1834
|
+
endpoint: endpointSchema.optional(),
|
|
1835
|
+
/** Per-signal override of `endpoint` for traces. */
|
|
1836
|
+
tracesEndpoint: endpointSchema.optional(),
|
|
1837
|
+
/** Per-signal override of the derived logs URL. */
|
|
1838
|
+
logsEndpoint: endpointSchema.optional(),
|
|
1839
|
+
/** Defaults to `exporter.protocol`. */
|
|
1840
|
+
protocol: z13.enum(["http/protobuf", "http/json", "none"]).optional(),
|
|
1841
|
+
/**
|
|
1842
|
+
* Header name to value. A value of the form `env:NAME` is read from that
|
|
1843
|
+
* environment variable at send time, so a credential never has to be written
|
|
1844
|
+
* into the file. Values never appear in a snapshot, a diagnostic, or `doctor`.
|
|
1845
|
+
*/
|
|
1846
|
+
headers: z13.record(z13.string().regex(HEADER_NAME_PATTERN2, "not a valid header name"), headerValueSchema).refine(
|
|
1847
|
+
(headers) => Object.keys(headers).length <= MAX_DESTINATION_HEADERS,
|
|
1848
|
+
`at most ${String(MAX_DESTINATION_HEADERS)} headers per destination`
|
|
1849
|
+
).optional(),
|
|
1850
|
+
/**
|
|
1851
|
+
* Which signals this destination receives. Default: both. The logs signal is
|
|
1852
|
+
* still governed by `exporter.logs.enabled`, which stays the one opt-in for a
|
|
1853
|
+
* second stream leaving the host.
|
|
1854
|
+
*/
|
|
1855
|
+
signals: z13.array(exportSignalSchema).min(1).max(2).readonly().optional()
|
|
1856
|
+
}).refine(
|
|
1857
|
+
(destination) => destination.endpoint !== void 0 || destination.tracesEndpoint !== void 0 || destination.logsEndpoint !== void 0,
|
|
1858
|
+
"a destination needs an endpoint, or a tracesEndpoint / logsEndpoint"
|
|
1859
|
+
);
|
|
1860
|
+
var exportDestinationsSchema = z13.array(exportDestinationSchema).max(MAX_EXPORT_DESTINATIONS).readonly().superRefine((destinations, context) => {
|
|
1861
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1862
|
+
destinations.forEach((destination, index) => {
|
|
1863
|
+
if (destination.name === DEFAULT_DESTINATION_NAME) {
|
|
1864
|
+
context.addIssue({
|
|
1865
|
+
code: "custom",
|
|
1866
|
+
path: [index, "name"],
|
|
1867
|
+
message: 'the name "default" is reserved for exporter.endpoint and the OTEL_EXPORTER_OTLP_* variables'
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
if (seen.has(destination.name)) {
|
|
1871
|
+
context.addIssue({
|
|
1872
|
+
code: "custom",
|
|
1873
|
+
path: [index, "name"],
|
|
1874
|
+
message: `duplicate destination name "${destination.name}"`
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
seen.add(destination.name);
|
|
1878
|
+
});
|
|
1879
|
+
});
|
|
1880
|
+
var spoolPolicySchema = z13.strictObject({
|
|
1881
|
+
/** Total bytes of queued batches. Default 16 MiB. */
|
|
1882
|
+
maxBytes: z13.number().int().min(1024).max(1073741824),
|
|
1883
|
+
/** A batch older than this is dropped instead of sent. Default 72 hours. */
|
|
1884
|
+
maxAgeMillis: z13.number().int().min(1e3).max(30 * 24 * 60 * 60 * 1e3),
|
|
1885
|
+
/** Number of queued batches. Default 500. */
|
|
1886
|
+
maxBatches: z13.number().int().min(1).max(65536)
|
|
1887
|
+
});
|
|
1888
|
+
var DEFAULT_SPOOL_POLICY = Object.freeze({
|
|
1889
|
+
maxBytes: 16 * 1024 * 1024,
|
|
1890
|
+
maxAgeMillis: 72 * 60 * 60 * 1e3,
|
|
1891
|
+
maxBatches: 500
|
|
1892
|
+
});
|
|
1893
|
+
var effectiveSpoolPolicy = (exporter) => ({
|
|
1894
|
+
maxBytes: exporter.spool?.maxBytes ?? DEFAULT_SPOOL_POLICY.maxBytes,
|
|
1895
|
+
maxAgeMillis: exporter.spool?.maxAgeMillis ?? DEFAULT_SPOOL_POLICY.maxAgeMillis,
|
|
1896
|
+
maxBatches: exporter.spool?.maxBatches ?? DEFAULT_SPOOL_POLICY.maxBatches
|
|
1897
|
+
});
|
|
1898
|
+
var legacyDestination = (exporter) => ({
|
|
1899
|
+
name: DEFAULT_DESTINATION_NAME,
|
|
1900
|
+
source: "exporter",
|
|
1901
|
+
protocol: exporter.protocol,
|
|
1902
|
+
...exporter.endpoint === void 0 ? {} : { endpoint: exporter.endpoint },
|
|
1903
|
+
...exporter.logs.endpoint === void 0 ? {} : { logsEndpoint: exporter.logs.endpoint },
|
|
1904
|
+
signals: { traces: true, logs: exporter.logs.enabled },
|
|
1905
|
+
headers: {}
|
|
1906
|
+
});
|
|
1907
|
+
var hasConfiguredDestinations = (exporter) => exporter.destinations !== void 0 && exporter.destinations.length > 0;
|
|
1908
|
+
var resolveExportDestinations = (exporter) => {
|
|
1909
|
+
if (!hasConfiguredDestinations(exporter)) {
|
|
1910
|
+
return [legacyDestination(exporter)];
|
|
1911
|
+
}
|
|
1912
|
+
const resolved = [];
|
|
1913
|
+
if (exporter.endpoint !== void 0 || exporter.logs.endpoint !== void 0) {
|
|
1914
|
+
resolved.push(legacyDestination(exporter));
|
|
1915
|
+
}
|
|
1916
|
+
for (const destination of exporter.destinations ?? []) {
|
|
1917
|
+
if (destination.enabled === false) {
|
|
1918
|
+
continue;
|
|
1919
|
+
}
|
|
1920
|
+
const signals = destination.signals ?? exportSignalSchema.options;
|
|
1921
|
+
resolved.push({
|
|
1922
|
+
name: destination.name,
|
|
1923
|
+
source: "destinations",
|
|
1924
|
+
protocol: destination.protocol ?? exporter.protocol,
|
|
1925
|
+
...destination.endpoint === void 0 ? {} : { endpoint: destination.endpoint },
|
|
1926
|
+
...destination.tracesEndpoint === void 0 ? {} : { tracesEndpoint: destination.tracesEndpoint },
|
|
1927
|
+
...destination.logsEndpoint === void 0 ? {} : { logsEndpoint: destination.logsEndpoint },
|
|
1928
|
+
signals: {
|
|
1929
|
+
traces: signals.includes("traces"),
|
|
1930
|
+
logs: exporter.logs.enabled && signals.includes("logs")
|
|
1931
|
+
},
|
|
1932
|
+
headers: { ...destination.headers ?? {} }
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
return resolved;
|
|
1936
|
+
};
|
|
1937
|
+
var parseHeaderValueReference = (value) => value.startsWith(HEADER_ENV_REFERENCE_PREFIX) ? { kind: "env", variable: value.slice(HEADER_ENV_REFERENCE_PREFIX.length) } : { kind: "literal" };
|
|
1938
|
+
var resolveDestinationHeaders = (headers, environment) => {
|
|
1939
|
+
const values = {};
|
|
1940
|
+
const missing = [];
|
|
1941
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
1942
|
+
const reference = parseHeaderValueReference(value);
|
|
1943
|
+
if (reference.kind === "literal") {
|
|
1944
|
+
values[name] = value;
|
|
1945
|
+
continue;
|
|
1946
|
+
}
|
|
1947
|
+
const resolved = environment?.[reference.variable];
|
|
1948
|
+
if (resolved === void 0 || resolved === "") {
|
|
1949
|
+
missing.push(reference.variable);
|
|
1950
|
+
continue;
|
|
1951
|
+
}
|
|
1952
|
+
values[name] = resolved;
|
|
1953
|
+
}
|
|
1954
|
+
return { values, missingVariables: [...new Set(missing)].sort() };
|
|
1955
|
+
};
|
|
1956
|
+
var endpointOrigin = (endpoint) => {
|
|
1957
|
+
if (endpoint === void 0) {
|
|
1958
|
+
return void 0;
|
|
1959
|
+
}
|
|
1960
|
+
try {
|
|
1961
|
+
return new URL(endpoint).origin;
|
|
1962
|
+
} catch {
|
|
1963
|
+
return "<unparsable>";
|
|
1964
|
+
}
|
|
1965
|
+
};
|
|
1966
|
+
var describeExportDestinations = (exporter) => {
|
|
1967
|
+
const describe = (destination, enabled2) => {
|
|
1968
|
+
const tracesOrigin = endpointOrigin(destination.tracesEndpoint ?? destination.endpoint);
|
|
1969
|
+
const logsOrigin = endpointOrigin(
|
|
1970
|
+
destination.logsEndpoint ?? destination.endpoint ?? destination.tracesEndpoint
|
|
1971
|
+
);
|
|
1972
|
+
const variables = Object.values(destination.headers).map(parseHeaderValueReference).flatMap((reference) => reference.kind === "env" ? [reference.variable] : []);
|
|
1973
|
+
return {
|
|
1974
|
+
name: destination.name,
|
|
1975
|
+
enabled: enabled2,
|
|
1976
|
+
protocol: destination.protocol,
|
|
1977
|
+
signals: exportSignalSchema.options.filter((signal) => destination.signals[signal]),
|
|
1978
|
+
...tracesOrigin === void 0 || !destination.signals.traces ? {} : { tracesEndpointOrigin: tracesOrigin },
|
|
1979
|
+
...logsOrigin === void 0 || !destination.signals.logs ? {} : { logsEndpointOrigin: logsOrigin },
|
|
1980
|
+
headerNames: destination.source === "exporter" ? [...exporter.headerNames].sort() : Object.keys(destination.headers).sort(),
|
|
1981
|
+
headerVariables: [...new Set(variables)].sort()
|
|
1982
|
+
};
|
|
1983
|
+
};
|
|
1984
|
+
const enabled = resolveExportDestinations(exporter).map(
|
|
1985
|
+
(destination) => describe(destination, true)
|
|
1986
|
+
);
|
|
1987
|
+
const disabled = (exporter.destinations ?? []).filter((destination) => destination.enabled === false).map(
|
|
1988
|
+
(destination) => describe(
|
|
1989
|
+
{
|
|
1990
|
+
name: destination.name,
|
|
1991
|
+
source: "destinations",
|
|
1992
|
+
protocol: destination.protocol ?? exporter.protocol,
|
|
1993
|
+
...destination.endpoint === void 0 ? {} : { endpoint: destination.endpoint },
|
|
1994
|
+
signals: { traces: false, logs: false },
|
|
1995
|
+
headers: { ...destination.headers ?? {} }
|
|
1996
|
+
},
|
|
1997
|
+
false
|
|
1998
|
+
)
|
|
1999
|
+
);
|
|
2000
|
+
return [...enabled, ...disabled];
|
|
2001
|
+
};
|
|
2002
|
+
|
|
2003
|
+
// src/config/schema.ts
|
|
2004
|
+
var logsPolicySchema = z14.strictObject({
|
|
2005
|
+
enabled: z14.boolean(),
|
|
1682
2006
|
/**
|
|
1683
2007
|
* Full URL for the logs signal.
|
|
1684
2008
|
*
|
|
1685
2009
|
* Absent, it is derived from `endpoint`: a trailing `/v1/traces` becomes
|
|
1686
2010
|
* `/v1/logs`, and an endpoint with no signal path has `/v1/logs` appended.
|
|
1687
2011
|
*/
|
|
1688
|
-
endpoint:
|
|
1689
|
-
includeContent:
|
|
1690
|
-
maxBatchSize:
|
|
2012
|
+
endpoint: z14.string().url().max(2048).optional(),
|
|
2013
|
+
includeContent: z14.boolean(),
|
|
2014
|
+
maxBatchSize: z14.number().int().min(1).max(4096)
|
|
1691
2015
|
});
|
|
1692
2016
|
var DEFAULT_LOGS_POLICY = Object.freeze({
|
|
1693
2017
|
enabled: false,
|
|
1694
2018
|
includeContent: false,
|
|
1695
2019
|
maxBatchSize: 128
|
|
1696
2020
|
});
|
|
1697
|
-
var exporterPolicySchema =
|
|
1698
|
-
enabled:
|
|
1699
|
-
protocol:
|
|
1700
|
-
endpoint:
|
|
2021
|
+
var exporterPolicySchema = z14.strictObject({
|
|
2022
|
+
enabled: z14.boolean(),
|
|
2023
|
+
protocol: z14.enum(["http/protobuf", "http/json", "none"]),
|
|
2024
|
+
endpoint: z14.string().url().max(2048).optional(),
|
|
1701
2025
|
/**
|
|
1702
2026
|
* Header names only. Values are supplied separately at construction time and
|
|
1703
2027
|
* are never part of a resolved-config snapshot, which is logged and exported.
|
|
1704
2028
|
*/
|
|
1705
|
-
headerNames:
|
|
1706
|
-
timeoutMillis:
|
|
1707
|
-
maxBatchSize:
|
|
1708
|
-
maxQueueSize:
|
|
1709
|
-
maxRetryAttempts:
|
|
2029
|
+
headerNames: z14.array(nonEmptyStringSchema).max(32).readonly(),
|
|
2030
|
+
timeoutMillis: z14.number().int().min(1).max(6e5),
|
|
2031
|
+
maxBatchSize: z14.number().int().min(1).max(4096),
|
|
2032
|
+
maxQueueSize: z14.number().int().min(1).max(65536),
|
|
2033
|
+
maxRetryAttempts: z14.number().int().min(0).max(10),
|
|
1710
2034
|
serviceName: nonEmptyStringSchema,
|
|
1711
2035
|
serviceNamespace: nonEmptyStringSchema.optional(),
|
|
1712
2036
|
/**
|
|
@@ -1723,32 +2047,52 @@ var exporterPolicySchema = z13.strictObject({
|
|
|
1723
2047
|
* headers, timeout, protocol, service identity, and resource attributes above —
|
|
1724
2048
|
* a second top-level section would invite two of each to drift apart.
|
|
1725
2049
|
*/
|
|
1726
|
-
logs: logsPolicySchema
|
|
2050
|
+
logs: logsPolicySchema,
|
|
2051
|
+
/**
|
|
2052
|
+
* Additional OTLP destinations, each sent every batch in parallel.
|
|
2053
|
+
*
|
|
2054
|
+
* Absent (the default), the exporter has exactly one destination — the
|
|
2055
|
+
* single-endpoint settings above, named `default` — and behaves exactly as it
|
|
2056
|
+
* did before this list existed. See `destinations.ts`.
|
|
2057
|
+
*
|
|
2058
|
+
* Merged as one leaf: a higher layer that sets the list replaces it whole,
|
|
2059
|
+
* because "the union of two partial lists" has no answer an operator could
|
|
2060
|
+
* predict.
|
|
2061
|
+
*/
|
|
2062
|
+
destinations: exportDestinationsSchema.optional(),
|
|
2063
|
+
/**
|
|
2064
|
+
* Per-destination retry spool bounds, each optional and merged per leaf; any
|
|
2065
|
+
* bound left unset takes its value from `DEFAULT_SPOOL_POLICY`.
|
|
2066
|
+
*/
|
|
2067
|
+
spool: spoolPolicySchema.partial().optional()
|
|
1727
2068
|
});
|
|
1728
|
-
var detectionPolicySchema =
|
|
2069
|
+
var detectionPolicySchema = z14.strictObject({
|
|
1729
2070
|
/** Detections below this confidence resolve to the unknown provider. */
|
|
1730
2071
|
minimumConfidence: detectionConfidenceSchema,
|
|
1731
2072
|
/** When false, an ambiguous detection is an error rather than unknown. */
|
|
1732
|
-
allowAmbiguousFallback:
|
|
2073
|
+
allowAmbiguousFallback: z14.boolean(),
|
|
1733
2074
|
/** Optional allow-list of provider ids; empty means "any registered". */
|
|
1734
|
-
allowedProviderIds:
|
|
2075
|
+
allowedProviderIds: z14.array(nonEmptyStringSchema).max(32).readonly()
|
|
1735
2076
|
});
|
|
1736
|
-
var diagnosticsPolicySchema =
|
|
1737
|
-
logLevel:
|
|
2077
|
+
var diagnosticsPolicySchema = z14.strictObject({
|
|
2078
|
+
logLevel: z14.enum(["silent", "error", "warn", "info", "debug"]),
|
|
1738
2079
|
/** Emit `error.raised` events for contained failures. */
|
|
1739
|
-
emitErrorEvents:
|
|
2080
|
+
emitErrorEvents: z14.boolean()
|
|
1740
2081
|
});
|
|
1741
|
-
var otelHookConfigSchema =
|
|
2082
|
+
var otelHookConfigSchema = z14.strictObject({
|
|
1742
2083
|
exporter: exporterPolicySchema,
|
|
1743
2084
|
privacy: privacyPolicySchema,
|
|
1744
2085
|
detection: detectionPolicySchema,
|
|
1745
2086
|
diagnostics: diagnosticsPolicySchema
|
|
1746
2087
|
});
|
|
1747
|
-
var otelHookConfigPatchSchema =
|
|
2088
|
+
var otelHookConfigPatchSchema = z14.strictObject({
|
|
1748
2089
|
// `logs` is unwrapped and re-partialled for the same reason `privacy.limits` is:
|
|
1749
2090
|
// merging happens per leaf, so a layer must be able to set `logs.enabled` alone
|
|
1750
2091
|
// without also restating the endpoint and the batch size.
|
|
1751
|
-
exporter: exporterPolicySchema.omit({ logs: true }).partial().extend({
|
|
2092
|
+
exporter: exporterPolicySchema.omit({ logs: true, spool: true }).partial().extend({
|
|
2093
|
+
logs: logsPolicySchema.partial().optional(),
|
|
2094
|
+
spool: spoolPolicySchema.partial().optional()
|
|
2095
|
+
}).optional(),
|
|
1752
2096
|
privacy: privacyPolicySchema.omit({ limits: true }).partial().extend({ limits: privacyPolicySchema.shape.limits.partial().optional() }).optional(),
|
|
1753
2097
|
detection: detectionPolicySchema.partial().optional(),
|
|
1754
2098
|
diagnostics: diagnosticsPolicySchema.partial().optional()
|
|
@@ -1782,9 +2126,9 @@ var DEFAULT_CONFIG = Object.freeze({
|
|
|
1782
2126
|
});
|
|
1783
2127
|
|
|
1784
2128
|
// src/config/resolve.ts
|
|
1785
|
-
import { z as
|
|
2129
|
+
import { z as z15 } from "zod";
|
|
1786
2130
|
var CONFIG_SOURCE_PRECEDENCE = ["defaults", "file", "environment", "inline-override"];
|
|
1787
|
-
var configSourceSchema =
|
|
2131
|
+
var configSourceSchema = z15.enum(CONFIG_SOURCE_PRECEDENCE);
|
|
1788
2132
|
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1789
2133
|
var mergeLeaf = (target, patch, source, provenance, path9) => {
|
|
1790
2134
|
for (const [key, value] of Object.entries(patch)) {
|
|
@@ -1793,8 +2137,8 @@ var mergeLeaf = (target, patch, source, provenance, path9) => {
|
|
|
1793
2137
|
}
|
|
1794
2138
|
const childPath = path9 === "" ? key : `${path9}.${key}`;
|
|
1795
2139
|
const existing = target[key];
|
|
1796
|
-
if (isPlainObject(value) && isPlainObject(existing)) {
|
|
1797
|
-
const child = { ...existing };
|
|
2140
|
+
if (isPlainObject(value) && (isPlainObject(existing) || existing === void 0)) {
|
|
2141
|
+
const child = { ...existing ?? {} };
|
|
1798
2142
|
mergeLeaf(child, value, source, provenance, childPath);
|
|
1799
2143
|
target[key] = child;
|
|
1800
2144
|
continue;
|
|
@@ -1866,10 +2210,27 @@ var resolveConfig = (layers = []) => {
|
|
|
1866
2210
|
if (parsed.data.privacy.contentMode === "raw" && !parsed.data.privacy.allowRawContent) {
|
|
1867
2211
|
notes.push("privacy.contentMode=raw will be downgraded to omit: allowRawContent is false");
|
|
1868
2212
|
}
|
|
1869
|
-
|
|
2213
|
+
const withDestinations = hasConfiguredDestinations(parsed.data.exporter);
|
|
2214
|
+
if (parsed.data.exporter.enabled && parsed.data.exporter.protocol !== "none" && parsed.data.exporter.endpoint === void 0 && !withDestinations) {
|
|
1870
2215
|
notes.push("exporter.enabled is true but no endpoint is configured");
|
|
1871
2216
|
}
|
|
1872
|
-
if (
|
|
2217
|
+
if (withDestinations) {
|
|
2218
|
+
const enabled = (parsed.data.exporter.destinations ?? []).filter(
|
|
2219
|
+
(destination) => destination.enabled !== false
|
|
2220
|
+
);
|
|
2221
|
+
if (enabled.length === 0 && parsed.data.exporter.endpoint === void 0) {
|
|
2222
|
+
notes.push("exporter.destinations is set but every destination is disabled");
|
|
2223
|
+
}
|
|
2224
|
+
if (!parsed.data.exporter.logs.enabled) {
|
|
2225
|
+
const askingForLogs = enabled.filter((destination) => destination.signals?.includes("logs") === true).map((destination) => destination.name);
|
|
2226
|
+
if (askingForLogs.length > 0) {
|
|
2227
|
+
notes.push(
|
|
2228
|
+
`destination(s) ${askingForLogs.join(", ")} list the logs signal but exporter.logs.enabled is false, so only traces are sent`
|
|
2229
|
+
);
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
if (!withDestinations && parsed.data.exporter.logs.enabled && parsed.data.exporter.logs.endpoint === void 0 && parsed.data.exporter.endpoint === void 0) {
|
|
1873
2234
|
notes.push(
|
|
1874
2235
|
"exporter.logs.enabled is true but neither a logs endpoint nor a trace endpoint to derive one from is configured"
|
|
1875
2236
|
);
|
|
@@ -1881,6 +2242,35 @@ var resolveConfig = (layers = []) => {
|
|
|
1881
2242
|
}
|
|
1882
2243
|
return { status: "ok", config: parsed.data, provenance, notes };
|
|
1883
2244
|
};
|
|
2245
|
+
var describeDestinationAttributes = (config) => {
|
|
2246
|
+
const attributes = {};
|
|
2247
|
+
if (config.exporter.spool !== void 0 || hasConfiguredDestinations(config.exporter)) {
|
|
2248
|
+
const spool = effectiveSpoolPolicy(config.exporter);
|
|
2249
|
+
attributes["exporter.spool_max_bytes"] = spool.maxBytes;
|
|
2250
|
+
attributes["exporter.spool_max_age_millis"] = spool.maxAgeMillis;
|
|
2251
|
+
attributes["exporter.spool_max_batches"] = spool.maxBatches;
|
|
2252
|
+
}
|
|
2253
|
+
if (!hasConfiguredDestinations(config.exporter)) {
|
|
2254
|
+
return attributes;
|
|
2255
|
+
}
|
|
2256
|
+
const destinations = describeExportDestinations(config.exporter);
|
|
2257
|
+
attributes["exporter.destination_names"] = destinations.map((destination) => destination.name);
|
|
2258
|
+
for (const destination of destinations) {
|
|
2259
|
+
const prefix = `exporter.destination.${destination.name}`;
|
|
2260
|
+
attributes[`${prefix}.enabled`] = destination.enabled;
|
|
2261
|
+
attributes[`${prefix}.protocol`] = destination.protocol;
|
|
2262
|
+
attributes[`${prefix}.signals`] = [...destination.signals];
|
|
2263
|
+
if (destination.tracesEndpointOrigin !== void 0) {
|
|
2264
|
+
attributes[`${prefix}.traces_endpoint_origin`] = destination.tracesEndpointOrigin;
|
|
2265
|
+
}
|
|
2266
|
+
if (destination.logsEndpointOrigin !== void 0) {
|
|
2267
|
+
attributes[`${prefix}.logs_endpoint_origin`] = destination.logsEndpointOrigin;
|
|
2268
|
+
}
|
|
2269
|
+
attributes[`${prefix}.header_names`] = [...destination.headerNames];
|
|
2270
|
+
attributes[`${prefix}.header_variables`] = [...destination.headerVariables];
|
|
2271
|
+
}
|
|
2272
|
+
return attributes;
|
|
2273
|
+
};
|
|
1884
2274
|
var describeResolvedConfig = (config) => {
|
|
1885
2275
|
const originOf = (endpoint) => {
|
|
1886
2276
|
if (endpoint === void 0) {
|
|
@@ -1892,183 +2282,63 @@ var describeResolvedConfig = (config) => {
|
|
|
1892
2282
|
return "<unparsable>";
|
|
1893
2283
|
}
|
|
1894
2284
|
};
|
|
1895
|
-
const
|
|
2285
|
+
const endpointOrigin2 = originOf(config.exporter.endpoint);
|
|
1896
2286
|
const logsEndpointOrigin = originOf(config.exporter.logs.endpoint);
|
|
1897
2287
|
return {
|
|
1898
2288
|
"exporter.enabled": config.exporter.enabled,
|
|
1899
2289
|
"exporter.protocol": config.exporter.protocol,
|
|
1900
|
-
...
|
|
2290
|
+
...endpointOrigin2 === void 0 ? {} : { "exporter.endpoint_origin": endpointOrigin2 },
|
|
1901
2291
|
"exporter.logs_enabled": config.exporter.logs.enabled,
|
|
1902
|
-
"exporter.logs_include_content": config.exporter.logs.includeContent,
|
|
1903
|
-
"exporter.logs_max_batch_size": config.exporter.logs.maxBatchSize,
|
|
1904
|
-
...logsEndpointOrigin === void 0 ? {} : { "exporter.logs_endpoint_origin": logsEndpointOrigin },
|
|
1905
|
-
"exporter.header_names": [...config.exporter.headerNames],
|
|
1906
|
-
// Names only. A resource attribute *name* is already on the wire in every
|
|
1907
|
-
// exported resource, so disclosing it here adds nothing; a *value* may hold
|
|
1908
|
-
// whatever an operator put in a shell profile, so it never appears.
|
|
1909
|
-
"exporter.resource_attribute_names": [
|
|
1910
|
-
...describeResourceAttributeNames(config.exporter.resourceAttributes)
|
|
1911
|
-
],
|
|
1912
|
-
|
|
1913
|
-
"exporter.
|
|
1914
|
-
"exporter.
|
|
1915
|
-
"
|
|
1916
|
-
"privacy.
|
|
1917
|
-
"privacy.
|
|
1918
|
-
"privacy.
|
|
1919
|
-
"privacy.
|
|
1920
|
-
"privacy.
|
|
1921
|
-
"privacy.
|
|
1922
|
-
"
|
|
1923
|
-
"detection.
|
|
1924
|
-
"
|
|
1925
|
-
"diagnostics.
|
|
1926
|
-
|
|
1927
|
-
};
|
|
1928
|
-
|
|
1929
|
-
// src/config/otlp-endpoint.ts
|
|
1930
|
-
var OTLP_ENDPOINT_VARIABLES = Object.freeze({
|
|
1931
|
-
generic: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
1932
|
-
traces: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",
|
|
1933
|
-
logs: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"
|
|
1934
|
-
});
|
|
1935
|
-
var OTLP_TRACES_PATH = "/v1/traces";
|
|
1936
|
-
var OTLP_LOGS_PATH = "/v1/logs";
|
|
1937
|
-
var withoutTrailingSlashes = (value) => {
|
|
1938
|
-
let end = value.length;
|
|
1939
|
-
while (end > 0 && value.charCodeAt(end - 1) === 47) {
|
|
1940
|
-
end -= 1;
|
|
1941
|
-
}
|
|
1942
|
-
return value.slice(0, end);
|
|
1943
|
-
};
|
|
1944
|
-
var otlpSignalEndpointFromBase = (base, signal) => {
|
|
1945
|
-
const trimmed = withoutTrailingSlashes(base);
|
|
1946
|
-
if (trimmed.endsWith(OTLP_TRACES_PATH)) {
|
|
1947
|
-
return signal === "traces" ? trimmed : `${trimmed.slice(0, trimmed.length - OTLP_TRACES_PATH.length)}${OTLP_LOGS_PATH}`;
|
|
1948
|
-
}
|
|
1949
|
-
return `${trimmed}${signal === "traces" ? OTLP_TRACES_PATH : OTLP_LOGS_PATH}`;
|
|
1950
|
-
};
|
|
1951
|
-
|
|
1952
|
-
// src/config/otlp-headers.ts
|
|
1953
|
-
var MAX_OTLP_HEADERS = 32;
|
|
1954
|
-
var OTLP_HEADER_VARIABLES = Object.freeze({
|
|
1955
|
-
generic: "OTEL_EXPORTER_OTLP_HEADERS",
|
|
1956
|
-
traces: "OTEL_EXPORTER_OTLP_TRACES_HEADERS",
|
|
1957
|
-
logs: "OTEL_EXPORTER_OTLP_LOGS_HEADERS"
|
|
1958
|
-
});
|
|
1959
|
-
var HEADER_NAME_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
1960
|
-
var isUnsafeHeaderValue = (value) => [...value].some((char) => {
|
|
1961
|
-
const code = char.codePointAt(0) ?? 0;
|
|
1962
|
-
return code < 32 && code !== 9 || code === 127 || code > 255;
|
|
1963
|
-
});
|
|
1964
|
-
var decode = (raw) => {
|
|
1965
|
-
try {
|
|
1966
|
-
return decodeURIComponent(raw);
|
|
1967
|
-
} catch {
|
|
1968
|
-
return void 0;
|
|
1969
|
-
}
|
|
1970
|
-
};
|
|
1971
|
-
var parseOtlpHeadersValue = (raw) => {
|
|
1972
|
-
const headers = {};
|
|
1973
|
-
const warnings = [];
|
|
1974
|
-
let overflowed = false;
|
|
1975
|
-
for (const [index, rawEntry] of raw.split(",").entries()) {
|
|
1976
|
-
const position = String(index + 1);
|
|
1977
|
-
const entry = rawEntry.trim();
|
|
1978
|
-
if (entry === "") {
|
|
1979
|
-
continue;
|
|
1980
|
-
}
|
|
1981
|
-
const equals = entry.indexOf("=");
|
|
1982
|
-
if (equals <= 0) {
|
|
1983
|
-
warnings.push(`entry ${position} is not a key=value pair; ignored`);
|
|
1984
|
-
continue;
|
|
1985
|
-
}
|
|
1986
|
-
const key = decode(entry.slice(0, equals).trim());
|
|
1987
|
-
const value = decode(entry.slice(equals + 1).trim());
|
|
1988
|
-
if (key === void 0 || value === void 0) {
|
|
1989
|
-
warnings.push(`entry ${position} has malformed percent-encoding; ignored`);
|
|
1990
|
-
continue;
|
|
1991
|
-
}
|
|
1992
|
-
const name = key.trim();
|
|
1993
|
-
const trimmedValue = value.trim();
|
|
1994
|
-
if (!HEADER_NAME_PATTERN.test(name)) {
|
|
1995
|
-
warnings.push(`entry ${position} does not name a valid HTTP header; ignored`);
|
|
1996
|
-
continue;
|
|
1997
|
-
}
|
|
1998
|
-
if (trimmedValue === "") {
|
|
1999
|
-
warnings.push(`entry ${position} has an empty value; ignored`);
|
|
2000
|
-
continue;
|
|
2001
|
-
}
|
|
2002
|
-
if (isUnsafeHeaderValue(trimmedValue)) {
|
|
2003
|
-
warnings.push(`entry ${position} has a character not allowed in an HTTP header value; ignored`);
|
|
2004
|
-
continue;
|
|
2005
|
-
}
|
|
2006
|
-
const existing = findHeaderName(headers, name);
|
|
2007
|
-
if (existing === void 0 && Object.keys(headers).length >= MAX_OTLP_HEADERS) {
|
|
2008
|
-
overflowed = true;
|
|
2009
|
-
continue;
|
|
2010
|
-
}
|
|
2011
|
-
if (existing !== void 0) {
|
|
2012
|
-
delete headers[existing];
|
|
2013
|
-
}
|
|
2014
|
-
headers[name] = trimmedValue;
|
|
2015
|
-
}
|
|
2016
|
-
if (overflowed) {
|
|
2017
|
-
warnings.push(`more than ${String(MAX_OTLP_HEADERS)} headers were supplied; the excess was ignored`);
|
|
2018
|
-
}
|
|
2019
|
-
return { headers, warnings };
|
|
2020
|
-
};
|
|
2021
|
-
var findHeaderName = (headers, name) => {
|
|
2022
|
-
const lower = name.toLowerCase();
|
|
2023
|
-
return Object.keys(headers).find((candidate) => candidate.toLowerCase() === lower);
|
|
2024
|
-
};
|
|
2025
|
-
var mergeOtlpHeaders = (...sources) => {
|
|
2026
|
-
const merged = {};
|
|
2027
|
-
for (const source of sources) {
|
|
2028
|
-
for (const [name, value] of Object.entries(source)) {
|
|
2029
|
-
const existing = findHeaderName(merged, name);
|
|
2030
|
-
if (existing !== void 0) {
|
|
2031
|
-
delete merged[existing];
|
|
2032
|
-
}
|
|
2033
|
-
merged[name] = value;
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
return merged;
|
|
2037
|
-
};
|
|
2038
|
-
var resolveOtlpHeaders = (env, explicit = {}) => {
|
|
2039
|
-
const warnings = [];
|
|
2040
|
-
const read = (variable) => {
|
|
2041
|
-
const raw = env[variable];
|
|
2042
|
-
if (raw === void 0 || raw.trim() === "") {
|
|
2043
|
-
return {};
|
|
2044
|
-
}
|
|
2045
|
-
const parsed = parseOtlpHeadersValue(raw);
|
|
2046
|
-
for (const detail of parsed.warnings) {
|
|
2047
|
-
warnings.push({ variable, detail });
|
|
2048
|
-
}
|
|
2049
|
-
return parsed.headers;
|
|
2050
|
-
};
|
|
2051
|
-
const generic = read(OTLP_HEADER_VARIABLES.generic);
|
|
2052
|
-
const traces = read(OTLP_HEADER_VARIABLES.traces);
|
|
2053
|
-
const logs = read(OTLP_HEADER_VARIABLES.logs);
|
|
2054
|
-
return {
|
|
2055
|
-
traces: mergeOtlpHeaders(generic, traces, explicit),
|
|
2056
|
-
logs: mergeOtlpHeaders(generic, logs, explicit),
|
|
2057
|
-
warnings
|
|
2292
|
+
"exporter.logs_include_content": config.exporter.logs.includeContent,
|
|
2293
|
+
"exporter.logs_max_batch_size": config.exporter.logs.maxBatchSize,
|
|
2294
|
+
...logsEndpointOrigin === void 0 ? {} : { "exporter.logs_endpoint_origin": logsEndpointOrigin },
|
|
2295
|
+
"exporter.header_names": [...config.exporter.headerNames],
|
|
2296
|
+
// Names only. A resource attribute *name* is already on the wire in every
|
|
2297
|
+
// exported resource, so disclosing it here adds nothing; a *value* may hold
|
|
2298
|
+
// whatever an operator put in a shell profile, so it never appears.
|
|
2299
|
+
"exporter.resource_attribute_names": [
|
|
2300
|
+
...describeResourceAttributeNames(config.exporter.resourceAttributes)
|
|
2301
|
+
],
|
|
2302
|
+
...describeDestinationAttributes(config),
|
|
2303
|
+
"exporter.timeout_millis": config.exporter.timeoutMillis,
|
|
2304
|
+
"exporter.max_batch_size": config.exporter.maxBatchSize,
|
|
2305
|
+
"exporter.service_name": config.exporter.serviceName,
|
|
2306
|
+
"privacy.content_mode": config.privacy.contentMode,
|
|
2307
|
+
"privacy.allow_raw_content": config.privacy.allowRawContent,
|
|
2308
|
+
"privacy.hash_salted": config.privacy.hashSalt.length > 0,
|
|
2309
|
+
"privacy.max_string_length": config.privacy.limits.maxStringLength,
|
|
2310
|
+
"privacy.max_depth": config.privacy.limits.maxDepth,
|
|
2311
|
+
"privacy.max_array_length": config.privacy.limits.maxArrayLength,
|
|
2312
|
+
"privacy.max_events_per_invocation": config.privacy.limits.maxEventsPerInvocation,
|
|
2313
|
+
"detection.minimum_confidence": config.detection.minimumConfidence,
|
|
2314
|
+
"detection.allow_ambiguous_fallback": config.detection.allowAmbiguousFallback,
|
|
2315
|
+
"diagnostics.log_level": config.diagnostics.logLevel,
|
|
2316
|
+
"diagnostics.emit_error_events": config.diagnostics.emitErrorEvents
|
|
2058
2317
|
};
|
|
2059
2318
|
};
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2319
|
+
|
|
2320
|
+
// src/config/otlp-endpoint.ts
|
|
2321
|
+
var OTLP_ENDPOINT_VARIABLES = Object.freeze({
|
|
2322
|
+
generic: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
2323
|
+
traces: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",
|
|
2324
|
+
logs: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"
|
|
2325
|
+
});
|
|
2326
|
+
var OTLP_TRACES_PATH = "/v1/traces";
|
|
2327
|
+
var OTLP_LOGS_PATH = "/v1/logs";
|
|
2328
|
+
var withoutTrailingSlashes = (value) => {
|
|
2329
|
+
let end = value.length;
|
|
2330
|
+
while (end > 0 && value.charCodeAt(end - 1) === 47) {
|
|
2331
|
+
end -= 1;
|
|
2068
2332
|
}
|
|
2069
|
-
return
|
|
2333
|
+
return value.slice(0, end);
|
|
2334
|
+
};
|
|
2335
|
+
var otlpSignalEndpointFromBase = (base, signal) => {
|
|
2336
|
+
const trimmed = withoutTrailingSlashes(base);
|
|
2337
|
+
if (trimmed.endsWith(OTLP_TRACES_PATH)) {
|
|
2338
|
+
return signal === "traces" ? trimmed : `${trimmed.slice(0, trimmed.length - OTLP_TRACES_PATH.length)}${OTLP_LOGS_PATH}`;
|
|
2339
|
+
}
|
|
2340
|
+
return `${trimmed}${signal === "traces" ? OTLP_TRACES_PATH : OTLP_LOGS_PATH}`;
|
|
2070
2341
|
};
|
|
2071
|
-
var describeOtlpHeaderNames = (...sources) => unionOtlpHeaderNames(...sources.map((source) => Object.keys(source)));
|
|
2072
2342
|
|
|
2073
2343
|
// src/config/environment.ts
|
|
2074
2344
|
var ENVIRONMENT_VARIABLES = Object.freeze({
|
|
@@ -2288,27 +2558,27 @@ var parseEnvironmentConfig = (env) => {
|
|
|
2288
2558
|
};
|
|
2289
2559
|
|
|
2290
2560
|
// src/providers/adapter.ts
|
|
2291
|
-
import { z as
|
|
2292
|
-
var providerDetectionSchema =
|
|
2561
|
+
import { z as z16 } from "zod";
|
|
2562
|
+
var providerDetectionSchema = z16.strictObject({
|
|
2293
2563
|
providerId: resolvedProviderIdSchema,
|
|
2294
2564
|
confidence: detectionConfidenceSchema,
|
|
2295
2565
|
/**
|
|
2296
2566
|
* Short, non-sensitive justifications, e.g. `"payload.hook_event_name present"`.
|
|
2297
2567
|
* Reasons are exported in diagnostics, so they must not quote payload values.
|
|
2298
2568
|
*/
|
|
2299
|
-
reasons:
|
|
2569
|
+
reasons: z16.array(z16.string().min(1).max(160)).max(8),
|
|
2300
2570
|
providerVersion: nonEmptyStringSchema.optional(),
|
|
2301
2571
|
/** The provider's own name for this event, when the payload states one. */
|
|
2302
2572
|
sourceEventName: nonEmptyStringSchema.optional()
|
|
2303
2573
|
});
|
|
2304
|
-
var deliveryIdentifierSupportSchema =
|
|
2574
|
+
var deliveryIdentifierSupportSchema = z16.enum(["none", "partial", "all"]);
|
|
2305
2575
|
var DELIVERY_COMPONENT_PATTERN = /^[A-Za-z0-9_.:@+=-]{1,256}$/;
|
|
2306
|
-
var deliveryComponentSchema =
|
|
2576
|
+
var deliveryComponentSchema = z16.string().regex(
|
|
2307
2577
|
DELIVERY_COMPONENT_PATTERN,
|
|
2308
2578
|
"delivery component must be identifier-shaped: no whitespace, no path separators"
|
|
2309
2579
|
);
|
|
2310
2580
|
var MAX_DELIVERY_COMPONENTS = 8;
|
|
2311
|
-
var providerDeliveryClaimSchema =
|
|
2581
|
+
var providerDeliveryClaimSchema = z16.strictObject({
|
|
2312
2582
|
/**
|
|
2313
2583
|
* The provider's own session/conversation id. Scopes the callback identity, so
|
|
2314
2584
|
* two sessions reusing one tool-call id never collide.
|
|
@@ -2320,26 +2590,26 @@ var providerDeliveryClaimSchema = z15.strictObject({
|
|
|
2320
2590
|
* Identifier-shaped payload fields that, together with `sourceEventName`,
|
|
2321
2591
|
* name this callback within the session exactly once.
|
|
2322
2592
|
*/
|
|
2323
|
-
components:
|
|
2593
|
+
components: z16.array(deliveryComponentSchema).min(1).max(MAX_DELIVERY_COMPONENTS).readonly(),
|
|
2324
2594
|
/**
|
|
2325
2595
|
* Short, non-sensitive justifications, e.g. `"payload.tool_use_id names one
|
|
2326
2596
|
* tool call"`. Evidence reaches diagnostics, so it must name fields, never
|
|
2327
2597
|
* quote their values.
|
|
2328
2598
|
*/
|
|
2329
|
-
evidence:
|
|
2599
|
+
evidence: z16.array(z16.string().min(1).max(160)).min(1).max(4).readonly()
|
|
2330
2600
|
});
|
|
2331
2601
|
var DELIVERY_GAP_REASON_PATTERN = /^[^\n\r\t\\/]{1,240}$/;
|
|
2332
|
-
var deliveryGapReasonSchema =
|
|
2602
|
+
var deliveryGapReasonSchema = z16.string().regex(
|
|
2333
2603
|
DELIVERY_GAP_REASON_PATTERN,
|
|
2334
2604
|
"delivery gap reason must be one line of prose: no path separators, no control characters"
|
|
2335
2605
|
);
|
|
2336
2606
|
var MAX_DELIVERY_GAPS = 48;
|
|
2337
|
-
var providerDeliveryGapsSchema =
|
|
2607
|
+
var providerDeliveryGapsSchema = z16.record(deliveryComponentSchema, deliveryGapReasonSchema).refine((gaps) => Object.keys(gaps).length <= MAX_DELIVERY_GAPS, {
|
|
2338
2608
|
message: `at most ${String(MAX_DELIVERY_GAPS)} delivery gaps may be declared`
|
|
2339
2609
|
});
|
|
2340
|
-
var providerCapabilitiesSchema =
|
|
2610
|
+
var providerCapabilitiesSchema = z16.strictObject({
|
|
2341
2611
|
/** Event types the adapter can produce. */
|
|
2342
|
-
lifecycleEvents:
|
|
2612
|
+
lifecycleEvents: z16.array(canonicalEventTypeSchema).max(32).readonly(),
|
|
2343
2613
|
usageTemporality: usageTemporalitySchema,
|
|
2344
2614
|
/**
|
|
2345
2615
|
* Which accumulator series a `cumulative` report continues — that is, which
|
|
@@ -2358,32 +2628,32 @@ var providerCapabilitiesSchema = z15.strictObject({
|
|
|
2358
2628
|
* Subagent snapshots keep their own series regardless: a delegated agent's
|
|
2359
2629
|
* counter is not a point on the parent session's curve.
|
|
2360
2630
|
*/
|
|
2361
|
-
cumulativeUsageSeries:
|
|
2362
|
-
reportsCachedInput:
|
|
2363
|
-
reportsCacheCreation:
|
|
2631
|
+
cumulativeUsageSeries: z16.enum(["event-scope", "session-lifetime"]).optional(),
|
|
2632
|
+
reportsCachedInput: z16.boolean(),
|
|
2633
|
+
reportsCacheCreation: z16.boolean(),
|
|
2364
2634
|
cacheCreationAccounting: cacheCreationAccountingSchema,
|
|
2365
|
-
reportsReasoningOutput:
|
|
2366
|
-
reportsProviderTotal:
|
|
2367
|
-
reportsCost:
|
|
2368
|
-
emitsSubagentEvents:
|
|
2369
|
-
emitsCompactionEvents:
|
|
2635
|
+
reportsReasoningOutput: z16.boolean(),
|
|
2636
|
+
reportsProviderTotal: z16.boolean(),
|
|
2637
|
+
reportsCost: z16.boolean(),
|
|
2638
|
+
emitsSubagentEvents: z16.boolean(),
|
|
2639
|
+
emitsCompactionEvents: z16.boolean(),
|
|
2370
2640
|
/** True when the provider reads a structured response from stdout. */
|
|
2371
|
-
requiresHookResponse:
|
|
2641
|
+
requiresHookResponse: z16.boolean(),
|
|
2372
2642
|
/** How much of this provider's hook traffic is replay-identifiable. */
|
|
2373
2643
|
deliveryIdentifier: deliveryIdentifierSupportSchema
|
|
2374
2644
|
});
|
|
2375
|
-
var providerHookResponseSchema =
|
|
2645
|
+
var providerHookResponseSchema = z16.strictObject({
|
|
2376
2646
|
/**
|
|
2377
2647
|
* Always 0. A telemetry hook that can fail the host agent is a liability, so
|
|
2378
2648
|
* the type forbids expressing anything else (ADR 0004).
|
|
2379
2649
|
*/
|
|
2380
|
-
exitCode:
|
|
2650
|
+
exitCode: z16.literal(0),
|
|
2381
2651
|
/** Protocol response text. Omit to write nothing at all. */
|
|
2382
|
-
stdout:
|
|
2652
|
+
stdout: z16.string().max(8192).optional(),
|
|
2383
2653
|
/** Non-sensitive diagnostic text for stderr. */
|
|
2384
|
-
stderr:
|
|
2654
|
+
stderr: z16.string().max(8192).optional(),
|
|
2385
2655
|
/** Declares which of the two stdout contracts this response follows. */
|
|
2386
|
-
contract:
|
|
2656
|
+
contract: z16.enum(["silent", "provider-protocol"])
|
|
2387
2657
|
});
|
|
2388
2658
|
var SILENT_HOOK_RESPONSE = Object.freeze({
|
|
2389
2659
|
exitCode: 0,
|
|
@@ -2652,35 +2922,35 @@ var CLAUDE_CODE_CAPABILITIES = Object.freeze({
|
|
|
2652
2922
|
});
|
|
2653
2923
|
|
|
2654
2924
|
// src/providers/claude/schema.ts
|
|
2655
|
-
import { z as
|
|
2925
|
+
import { z as z17 } from "zod";
|
|
2656
2926
|
var commonFields = {
|
|
2657
|
-
session_id:
|
|
2658
|
-
transcript_path:
|
|
2659
|
-
cwd:
|
|
2660
|
-
permission_mode:
|
|
2927
|
+
session_id: z17.string().min(1),
|
|
2928
|
+
transcript_path: z17.string().min(1).optional(),
|
|
2929
|
+
cwd: z17.string().min(1).optional(),
|
|
2930
|
+
permission_mode: z17.string().min(1).optional(),
|
|
2661
2931
|
/** Correlates a hook firing with the user prompt that triggered it (Claude Code v2.1.196+). */
|
|
2662
|
-
prompt_id:
|
|
2932
|
+
prompt_id: z17.string().min(1).optional(),
|
|
2663
2933
|
/** Present when the hook fired while running inside a subagent. */
|
|
2664
|
-
agent_id:
|
|
2665
|
-
agent_type:
|
|
2666
|
-
};
|
|
2667
|
-
var claudeCacheCreationSchema =
|
|
2668
|
-
ephemeral_5m_input_tokens:
|
|
2669
|
-
ephemeral_1h_input_tokens:
|
|
2670
|
-
});
|
|
2671
|
-
var claudeUsageIterationSchema =
|
|
2672
|
-
input_tokens:
|
|
2673
|
-
output_tokens:
|
|
2674
|
-
cache_creation_input_tokens:
|
|
2675
|
-
cache_read_input_tokens:
|
|
2676
|
-
});
|
|
2677
|
-
var claudeUsageSchema =
|
|
2678
|
-
input_tokens:
|
|
2679
|
-
output_tokens:
|
|
2680
|
-
cache_creation_input_tokens:
|
|
2681
|
-
cache_read_input_tokens:
|
|
2934
|
+
agent_id: z17.string().min(1).optional(),
|
|
2935
|
+
agent_type: z17.string().min(1).optional()
|
|
2936
|
+
};
|
|
2937
|
+
var claudeCacheCreationSchema = z17.object({
|
|
2938
|
+
ephemeral_5m_input_tokens: z17.number().int().min(0).optional(),
|
|
2939
|
+
ephemeral_1h_input_tokens: z17.number().int().min(0).optional()
|
|
2940
|
+
});
|
|
2941
|
+
var claudeUsageIterationSchema = z17.object({
|
|
2942
|
+
input_tokens: z17.number().int().min(0).optional(),
|
|
2943
|
+
output_tokens: z17.number().int().min(0).optional(),
|
|
2944
|
+
cache_creation_input_tokens: z17.number().int().min(0).optional(),
|
|
2945
|
+
cache_read_input_tokens: z17.number().int().min(0).optional()
|
|
2946
|
+
});
|
|
2947
|
+
var claudeUsageSchema = z17.object({
|
|
2948
|
+
input_tokens: z17.number().int().min(0),
|
|
2949
|
+
output_tokens: z17.number().int().min(0),
|
|
2950
|
+
cache_creation_input_tokens: z17.number().int().min(0).optional(),
|
|
2951
|
+
cache_read_input_tokens: z17.number().int().min(0).optional(),
|
|
2682
2952
|
cache_creation: claudeCacheCreationSchema.optional(),
|
|
2683
|
-
iterations:
|
|
2953
|
+
iterations: z17.array(claudeUsageIterationSchema).optional(),
|
|
2684
2954
|
/**
|
|
2685
2955
|
* Counters the canonical model has a home for but Claude Code never reports:
|
|
2686
2956
|
* 0 of 4,999 real usage objects carried either (finding 5).
|
|
@@ -2689,112 +2959,112 @@ var claudeUsageSchema = z16.object({
|
|
|
2689
2959
|
* that a harness attaching one gets told it was excluded, instead of watching
|
|
2690
2960
|
* it vanish. See `CLAUDE_EXCLUDED_USAGE_COUNTERS`.
|
|
2691
2961
|
*/
|
|
2692
|
-
total_tokens:
|
|
2693
|
-
reasoning_output_tokens:
|
|
2962
|
+
total_tokens: z17.number().int().min(0).optional(),
|
|
2963
|
+
reasoning_output_tokens: z17.number().int().min(0).optional()
|
|
2694
2964
|
});
|
|
2695
|
-
var sessionStartPayloadSchema =
|
|
2965
|
+
var sessionStartPayloadSchema = z17.object({
|
|
2696
2966
|
...commonFields,
|
|
2697
|
-
hook_event_name:
|
|
2967
|
+
hook_event_name: z17.literal("SessionStart"),
|
|
2698
2968
|
/** Matcher values: startup | resume | clear | compact | fork. Forward-compatible: any string. */
|
|
2699
|
-
source:
|
|
2700
|
-
model:
|
|
2701
|
-
session_title:
|
|
2969
|
+
source: z17.string().min(1).optional(),
|
|
2970
|
+
model: z17.string().min(1).optional(),
|
|
2971
|
+
session_title: z17.string().min(1).optional()
|
|
2702
2972
|
});
|
|
2703
|
-
var sessionEndPayloadSchema =
|
|
2973
|
+
var sessionEndPayloadSchema = z17.object({
|
|
2704
2974
|
...commonFields,
|
|
2705
|
-
hook_event_name:
|
|
2975
|
+
hook_event_name: z17.literal("SessionEnd"),
|
|
2706
2976
|
/** Current Claude Code field; values include clear, logout, prompt_input_exit, and other. */
|
|
2707
|
-
reason:
|
|
2977
|
+
reason: z17.string().min(1).optional(),
|
|
2708
2978
|
/** Compatibility alias emitted by older wrappers and hook integrations. */
|
|
2709
|
-
end_reason:
|
|
2979
|
+
end_reason: z17.string().min(1).optional()
|
|
2710
2980
|
});
|
|
2711
|
-
var userPromptSubmitPayloadSchema =
|
|
2981
|
+
var userPromptSubmitPayloadSchema = z17.object({
|
|
2712
2982
|
...commonFields,
|
|
2713
|
-
hook_event_name:
|
|
2714
|
-
prompt:
|
|
2983
|
+
hook_event_name: z17.literal("UserPromptSubmit"),
|
|
2984
|
+
prompt: z17.string()
|
|
2715
2985
|
});
|
|
2716
|
-
var preToolUsePayloadSchema =
|
|
2986
|
+
var preToolUsePayloadSchema = z17.object({
|
|
2717
2987
|
...commonFields,
|
|
2718
|
-
hook_event_name:
|
|
2719
|
-
tool_name:
|
|
2720
|
-
tool_input:
|
|
2721
|
-
tool_use_id:
|
|
2988
|
+
hook_event_name: z17.literal("PreToolUse"),
|
|
2989
|
+
tool_name: z17.string().min(1),
|
|
2990
|
+
tool_input: z17.unknown(),
|
|
2991
|
+
tool_use_id: z17.string().min(1)
|
|
2722
2992
|
});
|
|
2723
|
-
var postToolUsePayloadSchema =
|
|
2993
|
+
var postToolUsePayloadSchema = z17.object({
|
|
2724
2994
|
...commonFields,
|
|
2725
|
-
hook_event_name:
|
|
2726
|
-
tool_name:
|
|
2727
|
-
tool_input:
|
|
2728
|
-
tool_response:
|
|
2729
|
-
tool_use_id:
|
|
2995
|
+
hook_event_name: z17.literal("PostToolUse"),
|
|
2996
|
+
tool_name: z17.string().min(1),
|
|
2997
|
+
tool_input: z17.unknown().optional(),
|
|
2998
|
+
tool_response: z17.unknown(),
|
|
2999
|
+
tool_use_id: z17.string().min(1)
|
|
2730
3000
|
});
|
|
2731
|
-
var postToolUseFailurePayloadSchema =
|
|
3001
|
+
var postToolUseFailurePayloadSchema = z17.object({
|
|
2732
3002
|
...commonFields,
|
|
2733
|
-
hook_event_name:
|
|
2734
|
-
tool_name:
|
|
2735
|
-
tool_input:
|
|
2736
|
-
tool_error:
|
|
2737
|
-
tool_use_id:
|
|
3003
|
+
hook_event_name: z17.literal("PostToolUseFailure"),
|
|
3004
|
+
tool_name: z17.string().min(1),
|
|
3005
|
+
tool_input: z17.unknown().optional(),
|
|
3006
|
+
tool_error: z17.unknown(),
|
|
3007
|
+
tool_use_id: z17.string().min(1)
|
|
2738
3008
|
});
|
|
2739
|
-
var permissionRequestPayloadSchema =
|
|
3009
|
+
var permissionRequestPayloadSchema = z17.object({
|
|
2740
3010
|
...commonFields,
|
|
2741
|
-
hook_event_name:
|
|
2742
|
-
tool_name:
|
|
2743
|
-
tool_input:
|
|
2744
|
-
tool_use_id:
|
|
3011
|
+
hook_event_name: z17.literal("PermissionRequest"),
|
|
3012
|
+
tool_name: z17.string().min(1),
|
|
3013
|
+
tool_input: z17.unknown().optional(),
|
|
3014
|
+
tool_use_id: z17.string().min(1)
|
|
2745
3015
|
});
|
|
2746
|
-
var subagentStartPayloadSchema =
|
|
3016
|
+
var subagentStartPayloadSchema = z17.object({
|
|
2747
3017
|
...commonFields,
|
|
2748
|
-
hook_event_name:
|
|
2749
|
-
agent_type:
|
|
2750
|
-
agent_id:
|
|
3018
|
+
hook_event_name: z17.literal("SubagentStart"),
|
|
3019
|
+
agent_type: z17.string().min(1),
|
|
3020
|
+
agent_id: z17.string().min(1)
|
|
2751
3021
|
});
|
|
2752
|
-
var subagentStopPayloadSchema =
|
|
3022
|
+
var subagentStopPayloadSchema = z17.object({
|
|
2753
3023
|
...commonFields,
|
|
2754
|
-
hook_event_name:
|
|
2755
|
-
agent_type:
|
|
2756
|
-
agent_id:
|
|
2757
|
-
last_assistant_message:
|
|
3024
|
+
hook_event_name: z17.literal("SubagentStop"),
|
|
3025
|
+
agent_type: z17.string().min(1),
|
|
3026
|
+
agent_id: z17.string().min(1),
|
|
3027
|
+
last_assistant_message: z17.string().optional(),
|
|
2758
3028
|
/** True when this stop fired because a hook continued the subagent's turn. */
|
|
2759
|
-
stop_hook_active:
|
|
3029
|
+
stop_hook_active: z17.boolean().optional(),
|
|
2760
3030
|
usage: claudeUsageSchema.optional()
|
|
2761
3031
|
});
|
|
2762
|
-
var preCompactPayloadSchema =
|
|
3032
|
+
var preCompactPayloadSchema = z17.object({
|
|
2763
3033
|
...commonFields,
|
|
2764
|
-
hook_event_name:
|
|
3034
|
+
hook_event_name: z17.literal("PreCompact"),
|
|
2765
3035
|
/** Upstream values: manual | auto. Forward-compatible: any string. */
|
|
2766
|
-
trigger:
|
|
3036
|
+
trigger: z17.string().min(1).optional(),
|
|
2767
3037
|
/** Compatibility alias emitted by older wrappers and hook integrations. */
|
|
2768
|
-
compact_trigger:
|
|
3038
|
+
compact_trigger: z17.string().min(1).optional(),
|
|
2769
3039
|
/**
|
|
2770
3040
|
* Harness-supplied, never upstream. Reported as an explicit exclusion rather
|
|
2771
3041
|
* than carried across the process boundary: see `events.ts`.
|
|
2772
3042
|
*/
|
|
2773
|
-
context_tokens_before:
|
|
2774
|
-
estimated_tokens_removed:
|
|
3043
|
+
context_tokens_before: z17.number().int().min(0).optional(),
|
|
3044
|
+
estimated_tokens_removed: z17.number().int().min(0).optional()
|
|
2775
3045
|
});
|
|
2776
|
-
var postCompactPayloadSchema =
|
|
3046
|
+
var postCompactPayloadSchema = z17.object({
|
|
2777
3047
|
...commonFields,
|
|
2778
|
-
hook_event_name:
|
|
2779
|
-
trigger:
|
|
2780
|
-
compact_trigger:
|
|
3048
|
+
hook_event_name: z17.literal("PostCompact"),
|
|
3049
|
+
trigger: z17.string().min(1).optional(),
|
|
3050
|
+
compact_trigger: z17.string().min(1).optional(),
|
|
2781
3051
|
/** Harness-supplied, never upstream; accepted here because one callback carries both. */
|
|
2782
|
-
context_tokens_before:
|
|
2783
|
-
context_tokens_after:
|
|
2784
|
-
dropped_message_count:
|
|
3052
|
+
context_tokens_before: z17.number().int().min(0).optional(),
|
|
3053
|
+
context_tokens_after: z17.number().int().min(0).optional(),
|
|
3054
|
+
dropped_message_count: z17.number().int().min(0).optional(),
|
|
2785
3055
|
usage: claudeUsageSchema.optional()
|
|
2786
3056
|
});
|
|
2787
|
-
var stopPayloadSchema =
|
|
3057
|
+
var stopPayloadSchema = z17.object({
|
|
2788
3058
|
...commonFields,
|
|
2789
|
-
hook_event_name:
|
|
3059
|
+
hook_event_name: z17.literal("Stop"),
|
|
2790
3060
|
/**
|
|
2791
3061
|
* Interactive Stop field (Claude Code ≥ 2.1.47). Print / `-p` / Agent SDK
|
|
2792
3062
|
* result messages use `result` instead; `events.ts` reads both (and camelCase
|
|
2793
3063
|
* `lastAssistantMessage`) through `extractClaudeAssistantText`.
|
|
2794
3064
|
*/
|
|
2795
|
-
last_assistant_message:
|
|
3065
|
+
last_assistant_message: z17.string().optional(),
|
|
2796
3066
|
/** Print / `-p` JSON result field; accepted so a harness can attach it as-is. */
|
|
2797
|
-
result:
|
|
3067
|
+
result: z17.string().optional(),
|
|
2798
3068
|
/**
|
|
2799
3069
|
* True when this stop fired because a hook continued the turn.
|
|
2800
3070
|
*
|
|
@@ -2802,22 +3072,22 @@ var stopPayloadSchema = z16.object({
|
|
|
2802
3072
|
* stop from a continuation stop, which is what lets `delivery.ts` deduplicate
|
|
2803
3073
|
* the former without suppressing the latter.
|
|
2804
3074
|
*/
|
|
2805
|
-
stop_hook_active:
|
|
3075
|
+
stop_hook_active: z17.boolean().optional(),
|
|
2806
3076
|
usage: claudeUsageSchema.optional()
|
|
2807
3077
|
});
|
|
2808
|
-
var stopFailurePayloadSchema =
|
|
3078
|
+
var stopFailurePayloadSchema = z17.object({
|
|
2809
3079
|
...commonFields,
|
|
2810
|
-
hook_event_name:
|
|
3080
|
+
hook_event_name: z17.literal("StopFailure"),
|
|
2811
3081
|
/**
|
|
2812
3082
|
* Matcher values: rate_limit | overloaded | authentication_failed |
|
|
2813
3083
|
* oauth_org_not_allowed | billing_error | invalid_request | model_not_found
|
|
2814
3084
|
* | server_error | max_output_tokens | unknown.
|
|
2815
3085
|
*/
|
|
2816
|
-
error_type:
|
|
2817
|
-
error_message:
|
|
3086
|
+
error_type: z17.string().min(1),
|
|
3087
|
+
error_message: z17.string().optional(),
|
|
2818
3088
|
usage: claudeUsageSchema.optional()
|
|
2819
3089
|
});
|
|
2820
|
-
var claudeHookPayloadSchema =
|
|
3090
|
+
var claudeHookPayloadSchema = z17.discriminatedUnion("hook_event_name", [
|
|
2821
3091
|
sessionStartPayloadSchema,
|
|
2822
3092
|
sessionEndPayloadSchema,
|
|
2823
3093
|
userPromptSubmitPayloadSchema,
|
|
@@ -2847,15 +3117,15 @@ var CLAUDE_HOOK_EVENT_NAMES = [
|
|
|
2847
3117
|
"Stop",
|
|
2848
3118
|
"StopFailure"
|
|
2849
3119
|
];
|
|
2850
|
-
var claudeIdentityFieldsSchema =
|
|
2851
|
-
session_id:
|
|
2852
|
-
hook_event_name:
|
|
2853
|
-
cwd:
|
|
2854
|
-
prompt_id:
|
|
2855
|
-
agent_id:
|
|
2856
|
-
tool_use_id:
|
|
3120
|
+
var claudeIdentityFieldsSchema = z17.object({
|
|
3121
|
+
session_id: z17.string().min(1),
|
|
3122
|
+
hook_event_name: z17.string().min(1),
|
|
3123
|
+
cwd: z17.string().min(1).optional(),
|
|
3124
|
+
prompt_id: z17.string().min(1).optional(),
|
|
3125
|
+
agent_id: z17.string().min(1).optional(),
|
|
3126
|
+
tool_use_id: z17.string().min(1).optional(),
|
|
2857
3127
|
/** Read by `delivery.ts` to tell a once-per-prompt stop from a continuation. */
|
|
2858
|
-
stop_hook_active:
|
|
3128
|
+
stop_hook_active: z17.boolean().optional()
|
|
2859
3129
|
});
|
|
2860
3130
|
|
|
2861
3131
|
// src/providers/claude/usage.ts
|
|
@@ -3596,7 +3866,7 @@ var createClaudeCodeAdapter = (options = {}) => ({
|
|
|
3596
3866
|
});
|
|
3597
3867
|
|
|
3598
3868
|
// src/providers/cursor/payload.ts
|
|
3599
|
-
import { z as
|
|
3869
|
+
import { z as z18 } from "zod";
|
|
3600
3870
|
var CURSOR_PROVIDER_ID = "cursor";
|
|
3601
3871
|
var CURSOR_HOOK_EVENT_NAMES = [
|
|
3602
3872
|
"sessionStart",
|
|
@@ -3631,23 +3901,23 @@ var CURSOR_DECISION_EVENTS = Object.freeze({
|
|
|
3631
3901
|
subagentStart: "permission",
|
|
3632
3902
|
beforeSubmitPrompt: "continue"
|
|
3633
3903
|
});
|
|
3634
|
-
var modelParamSchema =
|
|
3635
|
-
id:
|
|
3636
|
-
value:
|
|
3904
|
+
var modelParamSchema = z18.object({
|
|
3905
|
+
id: z18.string(),
|
|
3906
|
+
value: z18.string()
|
|
3637
3907
|
});
|
|
3638
|
-
var attachmentSchema =
|
|
3639
|
-
type:
|
|
3640
|
-
file_path:
|
|
3908
|
+
var attachmentSchema = z18.object({
|
|
3909
|
+
type: z18.string().optional(),
|
|
3910
|
+
file_path: z18.string().optional()
|
|
3641
3911
|
});
|
|
3642
|
-
var fileEditSchema =
|
|
3643
|
-
old_string:
|
|
3644
|
-
new_string:
|
|
3912
|
+
var fileEditSchema = z18.object({
|
|
3913
|
+
old_string: z18.string().optional(),
|
|
3914
|
+
new_string: z18.string().optional()
|
|
3645
3915
|
});
|
|
3646
3916
|
var usageFields = {
|
|
3647
|
-
input_tokens:
|
|
3648
|
-
output_tokens:
|
|
3649
|
-
cache_read_tokens:
|
|
3650
|
-
cache_write_tokens:
|
|
3917
|
+
input_tokens: z18.number().int().min(0).optional(),
|
|
3918
|
+
output_tokens: z18.number().int().min(0).optional(),
|
|
3919
|
+
cache_read_tokens: z18.number().int().min(0).optional(),
|
|
3920
|
+
cache_write_tokens: z18.number().int().min(0).optional()
|
|
3651
3921
|
};
|
|
3652
3922
|
var envelopeShape = {
|
|
3653
3923
|
// Not `.min(1)`: see `cursorSessionId`. A payload naming neither
|
|
@@ -3655,136 +3925,136 @@ var envelopeShape = {
|
|
|
3655
3925
|
// `recognizeCursorPayload`'s post-parse check — but rejecting it here would
|
|
3656
3926
|
// fail the whole discriminated union on a field the adapter can source from
|
|
3657
3927
|
// either name.
|
|
3658
|
-
conversation_id:
|
|
3659
|
-
generation_id:
|
|
3660
|
-
session_id:
|
|
3661
|
-
model:
|
|
3662
|
-
model_id:
|
|
3663
|
-
model_params:
|
|
3664
|
-
cursor_version:
|
|
3665
|
-
workspace_roots:
|
|
3666
|
-
cwd:
|
|
3928
|
+
conversation_id: z18.string().optional(),
|
|
3929
|
+
generation_id: z18.string().optional(),
|
|
3930
|
+
session_id: z18.string().optional(),
|
|
3931
|
+
model: z18.string().optional(),
|
|
3932
|
+
model_id: z18.string().optional(),
|
|
3933
|
+
model_params: z18.array(modelParamSchema).max(64).optional(),
|
|
3934
|
+
cursor_version: z18.string().optional(),
|
|
3935
|
+
workspace_roots: z18.array(z18.string()).max(64).optional(),
|
|
3936
|
+
cwd: z18.string().optional(),
|
|
3667
3937
|
/** Never propagated. */
|
|
3668
|
-
user_email:
|
|
3938
|
+
user_email: z18.string().nullish(),
|
|
3669
3939
|
/** Never propagated. */
|
|
3670
|
-
transcript_path:
|
|
3940
|
+
transcript_path: z18.string().nullish()
|
|
3671
3941
|
};
|
|
3672
|
-
var event2 = (name, shape) =>
|
|
3942
|
+
var event2 = (name, shape) => z18.object({ ...envelopeShape, hook_event_name: z18.literal(name), ...shape });
|
|
3673
3943
|
var sessionStartPayloadSchema2 = event2("sessionStart", {
|
|
3674
|
-
is_background_agent:
|
|
3675
|
-
composer_mode:
|
|
3944
|
+
is_background_agent: z18.boolean().optional(),
|
|
3945
|
+
composer_mode: z18.string().optional()
|
|
3676
3946
|
});
|
|
3677
3947
|
var sessionEndPayloadSchema2 = event2("sessionEnd", {
|
|
3678
|
-
reason:
|
|
3679
|
-
duration_ms:
|
|
3680
|
-
is_background_agent:
|
|
3681
|
-
final_status:
|
|
3682
|
-
error_message:
|
|
3948
|
+
reason: z18.string().optional(),
|
|
3949
|
+
duration_ms: z18.number().min(0).optional(),
|
|
3950
|
+
is_background_agent: z18.boolean().optional(),
|
|
3951
|
+
final_status: z18.string().optional(),
|
|
3952
|
+
error_message: z18.string().optional()
|
|
3683
3953
|
});
|
|
3684
3954
|
var beforeSubmitPromptPayloadSchema = event2("beforeSubmitPrompt", {
|
|
3685
|
-
prompt:
|
|
3686
|
-
attachments:
|
|
3687
|
-
composer_mode:
|
|
3955
|
+
prompt: z18.string().optional(),
|
|
3956
|
+
attachments: z18.array(attachmentSchema).max(256).optional(),
|
|
3957
|
+
composer_mode: z18.string().optional()
|
|
3688
3958
|
});
|
|
3689
3959
|
var afterAgentResponsePayloadSchema = event2("afterAgentResponse", {
|
|
3690
|
-
text:
|
|
3960
|
+
text: z18.string().optional(),
|
|
3691
3961
|
...usageFields
|
|
3692
3962
|
});
|
|
3693
3963
|
var afterAgentThoughtPayloadSchema = event2("afterAgentThought", {
|
|
3694
|
-
text:
|
|
3695
|
-
duration_ms:
|
|
3964
|
+
text: z18.string().optional(),
|
|
3965
|
+
duration_ms: z18.number().min(0).optional()
|
|
3696
3966
|
});
|
|
3697
3967
|
var preToolUsePayloadSchema2 = event2("preToolUse", {
|
|
3698
|
-
tool_name:
|
|
3699
|
-
tool_input:
|
|
3700
|
-
tool_use_id:
|
|
3701
|
-
agent_message:
|
|
3968
|
+
tool_name: z18.string().min(1),
|
|
3969
|
+
tool_input: z18.unknown().optional(),
|
|
3970
|
+
tool_use_id: z18.string().optional(),
|
|
3971
|
+
agent_message: z18.string().optional()
|
|
3702
3972
|
});
|
|
3703
3973
|
var postToolUsePayloadSchema2 = event2("postToolUse", {
|
|
3704
|
-
tool_name:
|
|
3705
|
-
tool_input:
|
|
3706
|
-
tool_output:
|
|
3707
|
-
tool_use_id:
|
|
3708
|
-
duration:
|
|
3974
|
+
tool_name: z18.string().min(1),
|
|
3975
|
+
tool_input: z18.unknown().optional(),
|
|
3976
|
+
tool_output: z18.unknown().optional(),
|
|
3977
|
+
tool_use_id: z18.string().optional(),
|
|
3978
|
+
duration: z18.number().min(0).optional()
|
|
3709
3979
|
});
|
|
3710
3980
|
var postToolUseFailurePayloadSchema2 = event2("postToolUseFailure", {
|
|
3711
|
-
tool_name:
|
|
3712
|
-
tool_input:
|
|
3713
|
-
tool_use_id:
|
|
3714
|
-
error_message:
|
|
3715
|
-
failure_type:
|
|
3716
|
-
duration:
|
|
3717
|
-
is_interrupt:
|
|
3981
|
+
tool_name: z18.string().min(1),
|
|
3982
|
+
tool_input: z18.unknown().optional(),
|
|
3983
|
+
tool_use_id: z18.string().optional(),
|
|
3984
|
+
error_message: z18.string().optional(),
|
|
3985
|
+
failure_type: z18.string().optional(),
|
|
3986
|
+
duration: z18.number().min(0).optional(),
|
|
3987
|
+
is_interrupt: z18.boolean().optional()
|
|
3718
3988
|
});
|
|
3719
3989
|
var beforeShellExecutionPayloadSchema = event2("beforeShellExecution", {
|
|
3720
|
-
command:
|
|
3721
|
-
sandbox:
|
|
3990
|
+
command: z18.string(),
|
|
3991
|
+
sandbox: z18.boolean().optional()
|
|
3722
3992
|
});
|
|
3723
3993
|
var afterShellExecutionPayloadSchema = event2("afterShellExecution", {
|
|
3724
|
-
command:
|
|
3725
|
-
output:
|
|
3726
|
-
duration:
|
|
3727
|
-
sandbox:
|
|
3994
|
+
command: z18.string(),
|
|
3995
|
+
output: z18.string().optional(),
|
|
3996
|
+
duration: z18.number().min(0).optional(),
|
|
3997
|
+
sandbox: z18.boolean().optional()
|
|
3728
3998
|
});
|
|
3729
3999
|
var beforeMcpExecutionPayloadSchema = event2("beforeMCPExecution", {
|
|
3730
|
-
tool_name:
|
|
3731
|
-
tool_input:
|
|
3732
|
-
url:
|
|
3733
|
-
command:
|
|
4000
|
+
tool_name: z18.string().min(1),
|
|
4001
|
+
tool_input: z18.unknown().optional(),
|
|
4002
|
+
url: z18.string().optional(),
|
|
4003
|
+
command: z18.string().optional()
|
|
3734
4004
|
});
|
|
3735
4005
|
var afterMcpExecutionPayloadSchema = event2("afterMCPExecution", {
|
|
3736
|
-
tool_name:
|
|
3737
|
-
tool_input:
|
|
3738
|
-
result_json:
|
|
3739
|
-
duration:
|
|
4006
|
+
tool_name: z18.string().min(1),
|
|
4007
|
+
tool_input: z18.unknown().optional(),
|
|
4008
|
+
result_json: z18.string().optional(),
|
|
4009
|
+
duration: z18.number().min(0).optional()
|
|
3740
4010
|
});
|
|
3741
4011
|
var beforeReadFilePayloadSchema = event2("beforeReadFile", {
|
|
3742
|
-
file_path:
|
|
3743
|
-
content:
|
|
3744
|
-
attachments:
|
|
4012
|
+
file_path: z18.string(),
|
|
4013
|
+
content: z18.string().optional(),
|
|
4014
|
+
attachments: z18.array(attachmentSchema).max(256).optional()
|
|
3745
4015
|
});
|
|
3746
4016
|
var afterFileEditPayloadSchema = event2("afterFileEdit", {
|
|
3747
|
-
file_path:
|
|
3748
|
-
edits:
|
|
4017
|
+
file_path: z18.string(),
|
|
4018
|
+
edits: z18.array(fileEditSchema).max(1024).optional()
|
|
3749
4019
|
});
|
|
3750
4020
|
var subagentStartPayloadSchema2 = event2("subagentStart", {
|
|
3751
|
-
subagent_id:
|
|
3752
|
-
subagent_type:
|
|
3753
|
-
task:
|
|
3754
|
-
parent_conversation_id:
|
|
3755
|
-
tool_call_id:
|
|
3756
|
-
subagent_model:
|
|
3757
|
-
is_parallel_worker:
|
|
3758
|
-
git_branch:
|
|
4021
|
+
subagent_id: z18.string().optional(),
|
|
4022
|
+
subagent_type: z18.string().optional(),
|
|
4023
|
+
task: z18.string().optional(),
|
|
4024
|
+
parent_conversation_id: z18.string().optional(),
|
|
4025
|
+
tool_call_id: z18.string().optional(),
|
|
4026
|
+
subagent_model: z18.string().optional(),
|
|
4027
|
+
is_parallel_worker: z18.boolean().optional(),
|
|
4028
|
+
git_branch: z18.string().optional()
|
|
3759
4029
|
});
|
|
3760
4030
|
var subagentStopPayloadSchema2 = event2("subagentStop", {
|
|
3761
|
-
subagent_type:
|
|
3762
|
-
status:
|
|
3763
|
-
task:
|
|
3764
|
-
description:
|
|
3765
|
-
summary:
|
|
3766
|
-
duration_ms:
|
|
3767
|
-
message_count:
|
|
3768
|
-
tool_call_count:
|
|
3769
|
-
loop_count:
|
|
3770
|
-
modified_files:
|
|
3771
|
-
agent_transcript_path:
|
|
4031
|
+
subagent_type: z18.string().optional(),
|
|
4032
|
+
status: z18.string().optional(),
|
|
4033
|
+
task: z18.string().optional(),
|
|
4034
|
+
description: z18.string().optional(),
|
|
4035
|
+
summary: z18.string().optional(),
|
|
4036
|
+
duration_ms: z18.number().min(0).optional(),
|
|
4037
|
+
message_count: z18.number().int().min(0).optional(),
|
|
4038
|
+
tool_call_count: z18.number().int().min(0).optional(),
|
|
4039
|
+
loop_count: z18.number().int().min(0).optional(),
|
|
4040
|
+
modified_files: z18.array(z18.string()).max(1024).optional(),
|
|
4041
|
+
agent_transcript_path: z18.string().nullish()
|
|
3772
4042
|
});
|
|
3773
4043
|
var preCompactPayloadSchema2 = event2("preCompact", {
|
|
3774
|
-
trigger:
|
|
3775
|
-
context_usage_percent:
|
|
3776
|
-
context_tokens:
|
|
3777
|
-
context_window_size:
|
|
3778
|
-
message_count:
|
|
3779
|
-
messages_to_compact:
|
|
3780
|
-
is_first_compaction:
|
|
4044
|
+
trigger: z18.string().optional(),
|
|
4045
|
+
context_usage_percent: z18.number().optional(),
|
|
4046
|
+
context_tokens: z18.number().int().min(0).optional(),
|
|
4047
|
+
context_window_size: z18.number().int().min(0).optional(),
|
|
4048
|
+
message_count: z18.number().int().min(0).optional(),
|
|
4049
|
+
messages_to_compact: z18.number().int().min(0).optional(),
|
|
4050
|
+
is_first_compaction: z18.boolean().optional()
|
|
3781
4051
|
});
|
|
3782
4052
|
var stopPayloadSchema2 = event2("stop", {
|
|
3783
|
-
status:
|
|
3784
|
-
loop_count:
|
|
4053
|
+
status: z18.string().optional(),
|
|
4054
|
+
loop_count: z18.number().int().min(0).optional(),
|
|
3785
4055
|
...usageFields
|
|
3786
4056
|
});
|
|
3787
|
-
var cursorPayloadSchema =
|
|
4057
|
+
var cursorPayloadSchema = z18.discriminatedUnion("hook_event_name", [
|
|
3788
4058
|
sessionStartPayloadSchema2,
|
|
3789
4059
|
sessionEndPayloadSchema2,
|
|
3790
4060
|
beforeSubmitPromptPayloadSchema,
|
|
@@ -4560,105 +4830,105 @@ var createCursorAdapter = (options = {}) => {
|
|
|
4560
4830
|
};
|
|
4561
4831
|
|
|
4562
4832
|
// src/providers/codex/payload.ts
|
|
4563
|
-
import { z as
|
|
4564
|
-
var permissionModeSchema =
|
|
4833
|
+
import { z as z19 } from "zod";
|
|
4834
|
+
var permissionModeSchema = z19.enum([
|
|
4565
4835
|
"default",
|
|
4566
4836
|
"acceptEdits",
|
|
4567
4837
|
"plan",
|
|
4568
4838
|
"dontAsk",
|
|
4569
4839
|
"bypassPermissions"
|
|
4570
4840
|
]);
|
|
4571
|
-
var codexUsageSchema =
|
|
4572
|
-
input_tokens:
|
|
4573
|
-
cached_input_tokens:
|
|
4574
|
-
output_tokens:
|
|
4575
|
-
reasoning_output_tokens:
|
|
4576
|
-
total_tokens:
|
|
4841
|
+
var codexUsageSchema = z19.object({
|
|
4842
|
+
input_tokens: z19.number().int().min(0).optional(),
|
|
4843
|
+
cached_input_tokens: z19.number().int().min(0).optional(),
|
|
4844
|
+
output_tokens: z19.number().int().min(0).optional(),
|
|
4845
|
+
reasoning_output_tokens: z19.number().int().min(0).optional(),
|
|
4846
|
+
total_tokens: z19.number().int().min(0).optional()
|
|
4577
4847
|
});
|
|
4578
4848
|
var baseFields = {
|
|
4579
|
-
session_id:
|
|
4580
|
-
cwd:
|
|
4581
|
-
model:
|
|
4849
|
+
session_id: z19.string().min(1).max(256),
|
|
4850
|
+
cwd: z19.string().min(1).max(4096).optional(),
|
|
4851
|
+
model: z19.string().min(1).max(256).optional(),
|
|
4582
4852
|
permission_mode: permissionModeSchema.optional(),
|
|
4583
|
-
transcript_path:
|
|
4584
|
-
codex_version:
|
|
4853
|
+
transcript_path: z19.string().min(1).max(4096).optional(),
|
|
4854
|
+
codex_version: z19.string().min(1).max(64).optional(),
|
|
4585
4855
|
/** Not part of the documented protocol; lets tests and replay stay deterministic. */
|
|
4586
|
-
occurred_at:
|
|
4856
|
+
occurred_at: z19.number().int().min(0).optional()
|
|
4587
4857
|
};
|
|
4588
|
-
var codexSessionStartPayloadSchema =
|
|
4858
|
+
var codexSessionStartPayloadSchema = z19.object({
|
|
4589
4859
|
...baseFields,
|
|
4590
|
-
hook_event_name:
|
|
4591
|
-
source:
|
|
4860
|
+
hook_event_name: z19.literal("SessionStart"),
|
|
4861
|
+
source: z19.enum(["startup", "resume", "clear", "compact"]).optional()
|
|
4592
4862
|
});
|
|
4593
|
-
var codexUserPromptSubmitPayloadSchema =
|
|
4863
|
+
var codexUserPromptSubmitPayloadSchema = z19.object({
|
|
4594
4864
|
...baseFields,
|
|
4595
|
-
hook_event_name:
|
|
4596
|
-
turn_id:
|
|
4597
|
-
prompt:
|
|
4865
|
+
hook_event_name: z19.literal("UserPromptSubmit"),
|
|
4866
|
+
turn_id: z19.string().min(1).max(256).optional(),
|
|
4867
|
+
prompt: z19.string().max(1e6).optional()
|
|
4598
4868
|
});
|
|
4599
|
-
var codexPreToolUsePayloadSchema =
|
|
4869
|
+
var codexPreToolUsePayloadSchema = z19.object({
|
|
4600
4870
|
...baseFields,
|
|
4601
|
-
hook_event_name:
|
|
4602
|
-
turn_id:
|
|
4603
|
-
tool_name:
|
|
4604
|
-
tool_call_id:
|
|
4605
|
-
tool_input:
|
|
4871
|
+
hook_event_name: z19.literal("PreToolUse"),
|
|
4872
|
+
turn_id: z19.string().min(1).max(256).optional(),
|
|
4873
|
+
tool_name: z19.string().min(1).max(256),
|
|
4874
|
+
tool_call_id: z19.string().min(1).max(256).optional(),
|
|
4875
|
+
tool_input: z19.unknown().optional()
|
|
4606
4876
|
});
|
|
4607
|
-
var codexPermissionRequestPayloadSchema =
|
|
4877
|
+
var codexPermissionRequestPayloadSchema = z19.object({
|
|
4608
4878
|
...baseFields,
|
|
4609
|
-
hook_event_name:
|
|
4610
|
-
turn_id:
|
|
4611
|
-
tool_name:
|
|
4612
|
-
tool_call_id:
|
|
4613
|
-
tool_input:
|
|
4879
|
+
hook_event_name: z19.literal("PermissionRequest"),
|
|
4880
|
+
turn_id: z19.string().min(1).max(256).optional(),
|
|
4881
|
+
tool_name: z19.string().min(1).max(256).optional(),
|
|
4882
|
+
tool_call_id: z19.string().min(1).max(256).optional(),
|
|
4883
|
+
tool_input: z19.unknown().optional()
|
|
4614
4884
|
});
|
|
4615
|
-
var codexPostToolUsePayloadSchema =
|
|
4885
|
+
var codexPostToolUsePayloadSchema = z19.object({
|
|
4616
4886
|
...baseFields,
|
|
4617
|
-
hook_event_name:
|
|
4618
|
-
turn_id:
|
|
4619
|
-
tool_name:
|
|
4620
|
-
tool_call_id:
|
|
4621
|
-
tool_input:
|
|
4622
|
-
tool_response:
|
|
4623
|
-
permission_decision:
|
|
4624
|
-
duration_ms:
|
|
4887
|
+
hook_event_name: z19.literal("PostToolUse"),
|
|
4888
|
+
turn_id: z19.string().min(1).max(256).optional(),
|
|
4889
|
+
tool_name: z19.string().min(1).max(256),
|
|
4890
|
+
tool_call_id: z19.string().min(1).max(256).optional(),
|
|
4891
|
+
tool_input: z19.unknown().optional(),
|
|
4892
|
+
tool_response: z19.unknown().optional(),
|
|
4893
|
+
permission_decision: z19.enum(["allowed", "denied", "deferred"]).optional(),
|
|
4894
|
+
duration_ms: z19.number().min(0).optional()
|
|
4625
4895
|
});
|
|
4626
|
-
var codexPreCompactPayloadSchema =
|
|
4896
|
+
var codexPreCompactPayloadSchema = z19.object({
|
|
4627
4897
|
...baseFields,
|
|
4628
|
-
hook_event_name:
|
|
4629
|
-
trigger:
|
|
4630
|
-
context_tokens_before:
|
|
4898
|
+
hook_event_name: z19.literal("PreCompact"),
|
|
4899
|
+
trigger: z19.enum(["auto", "manual"]).optional(),
|
|
4900
|
+
context_tokens_before: z19.number().int().min(0).optional()
|
|
4631
4901
|
});
|
|
4632
|
-
var codexPostCompactPayloadSchema =
|
|
4902
|
+
var codexPostCompactPayloadSchema = z19.object({
|
|
4633
4903
|
...baseFields,
|
|
4634
|
-
hook_event_name:
|
|
4635
|
-
trigger:
|
|
4636
|
-
context_tokens_after:
|
|
4637
|
-
dropped_message_count:
|
|
4904
|
+
hook_event_name: z19.literal("PostCompact"),
|
|
4905
|
+
trigger: z19.enum(["auto", "manual"]).optional(),
|
|
4906
|
+
context_tokens_after: z19.number().int().min(0).optional(),
|
|
4907
|
+
dropped_message_count: z19.number().int().min(0).optional(),
|
|
4638
4908
|
usage: codexUsageSchema.optional()
|
|
4639
4909
|
});
|
|
4640
|
-
var codexSubagentStartPayloadSchema =
|
|
4910
|
+
var codexSubagentStartPayloadSchema = z19.object({
|
|
4641
4911
|
...baseFields,
|
|
4642
|
-
hook_event_name:
|
|
4643
|
-
turn_id:
|
|
4644
|
-
subagent_id:
|
|
4645
|
-
subagent_type:
|
|
4912
|
+
hook_event_name: z19.literal("SubagentStart"),
|
|
4913
|
+
turn_id: z19.string().min(1).max(256).optional(),
|
|
4914
|
+
subagent_id: z19.string().min(1).max(256),
|
|
4915
|
+
subagent_type: z19.string().min(1).max(256).optional()
|
|
4646
4916
|
});
|
|
4647
|
-
var codexSubagentStopPayloadSchema =
|
|
4917
|
+
var codexSubagentStopPayloadSchema = z19.object({
|
|
4648
4918
|
...baseFields,
|
|
4649
|
-
hook_event_name:
|
|
4650
|
-
turn_id:
|
|
4651
|
-
subagent_id:
|
|
4652
|
-
status:
|
|
4919
|
+
hook_event_name: z19.literal("SubagentStop"),
|
|
4920
|
+
turn_id: z19.string().min(1).max(256).optional(),
|
|
4921
|
+
subagent_id: z19.string().min(1).max(256),
|
|
4922
|
+
status: z19.enum(["completed", "failed", "cancelled"]).optional(),
|
|
4653
4923
|
usage: codexUsageSchema.optional()
|
|
4654
4924
|
});
|
|
4655
|
-
var codexStopPayloadSchema =
|
|
4925
|
+
var codexStopPayloadSchema = z19.object({
|
|
4656
4926
|
...baseFields,
|
|
4657
|
-
hook_event_name:
|
|
4658
|
-
turn_id:
|
|
4659
|
-
stop_reason:
|
|
4927
|
+
hook_event_name: z19.literal("Stop"),
|
|
4928
|
+
turn_id: z19.string().min(1).max(256).optional(),
|
|
4929
|
+
stop_reason: z19.string().min(1).max(256).optional(),
|
|
4660
4930
|
usage: codexUsageSchema.optional(),
|
|
4661
|
-
duration_ms:
|
|
4931
|
+
duration_ms: z19.number().min(0).optional()
|
|
4662
4932
|
});
|
|
4663
4933
|
var CODEX_HOOK_EVENT_NAMES = [
|
|
4664
4934
|
"SessionStart",
|
|
@@ -4672,7 +4942,7 @@ var CODEX_HOOK_EVENT_NAMES = [
|
|
|
4672
4942
|
"SubagentStop",
|
|
4673
4943
|
"Stop"
|
|
4674
4944
|
];
|
|
4675
|
-
var codexHookPayloadSchema =
|
|
4945
|
+
var codexHookPayloadSchema = z19.discriminatedUnion("hook_event_name", [
|
|
4676
4946
|
codexSessionStartPayloadSchema,
|
|
4677
4947
|
codexUserPromptSubmitPayloadSchema,
|
|
4678
4948
|
codexPreToolUsePayloadSchema,
|
|
@@ -4684,9 +4954,9 @@ var codexHookPayloadSchema = z18.discriminatedUnion("hook_event_name", [
|
|
|
4684
4954
|
codexSubagentStopPayloadSchema,
|
|
4685
4955
|
codexStopPayloadSchema
|
|
4686
4956
|
]);
|
|
4687
|
-
var codexHookEnvelopeSchema =
|
|
4688
|
-
session_id:
|
|
4689
|
-
hook_event_name:
|
|
4957
|
+
var codexHookEnvelopeSchema = z19.object({
|
|
4958
|
+
session_id: z19.string().min(1),
|
|
4959
|
+
hook_event_name: z19.enum(CODEX_HOOK_EVENT_NAMES)
|
|
4690
4960
|
});
|
|
4691
4961
|
|
|
4692
4962
|
// src/providers/codex/delivery.ts
|
|
@@ -5305,7 +5575,7 @@ var geminiCorrelationSeed = (input) => {
|
|
|
5305
5575
|
};
|
|
5306
5576
|
|
|
5307
5577
|
// src/providers/gemini/schema.ts
|
|
5308
|
-
import { z as
|
|
5578
|
+
import { z as z20 } from "zod";
|
|
5309
5579
|
var GEMINI_HOOK_EVENT_NAMES = [
|
|
5310
5580
|
"SessionStart",
|
|
5311
5581
|
"SessionEnd",
|
|
@@ -5319,113 +5589,113 @@ var GEMINI_HOOK_EVENT_NAMES = [
|
|
|
5319
5589
|
"PreCompress",
|
|
5320
5590
|
"Notification"
|
|
5321
5591
|
];
|
|
5322
|
-
var baseHookInputSchema =
|
|
5323
|
-
session_id:
|
|
5324
|
-
transcript_path:
|
|
5325
|
-
cwd:
|
|
5326
|
-
timestamp:
|
|
5327
|
-
});
|
|
5328
|
-
var llmMessageSchema =
|
|
5329
|
-
role:
|
|
5330
|
-
content:
|
|
5592
|
+
var baseHookInputSchema = z20.object({
|
|
5593
|
+
session_id: z20.string().min(1),
|
|
5594
|
+
transcript_path: z20.string().optional(),
|
|
5595
|
+
cwd: z20.string().optional(),
|
|
5596
|
+
timestamp: z20.string().min(1).optional()
|
|
5597
|
+
});
|
|
5598
|
+
var llmMessageSchema = z20.object({
|
|
5599
|
+
role: z20.enum(["user", "model", "system"]).optional(),
|
|
5600
|
+
content: z20.union([z20.string(), z20.array(z20.unknown())]).optional()
|
|
5331
5601
|
}).loose();
|
|
5332
|
-
var llmRequestConfigSchema =
|
|
5333
|
-
temperature:
|
|
5334
|
-
maxOutputTokens:
|
|
5602
|
+
var llmRequestConfigSchema = z20.object({
|
|
5603
|
+
temperature: z20.number().optional(),
|
|
5604
|
+
maxOutputTokens: z20.number().int().min(0).optional()
|
|
5335
5605
|
}).loose();
|
|
5336
|
-
var geminiLlmRequestSchema =
|
|
5337
|
-
model:
|
|
5338
|
-
messages:
|
|
5606
|
+
var geminiLlmRequestSchema = z20.object({
|
|
5607
|
+
model: z20.string().min(1).optional(),
|
|
5608
|
+
messages: z20.array(llmMessageSchema).optional(),
|
|
5339
5609
|
config: llmRequestConfigSchema.optional(),
|
|
5340
|
-
toolConfig:
|
|
5610
|
+
toolConfig: z20.unknown().optional()
|
|
5341
5611
|
}).loose();
|
|
5342
|
-
var geminiUsageMetadataSchema =
|
|
5343
|
-
promptTokenCount:
|
|
5344
|
-
cachedContentTokenCount:
|
|
5345
|
-
candidatesTokenCount:
|
|
5346
|
-
thoughtsTokenCount:
|
|
5347
|
-
totalTokenCount:
|
|
5612
|
+
var geminiUsageMetadataSchema = z20.object({
|
|
5613
|
+
promptTokenCount: z20.number().int().min(0).optional(),
|
|
5614
|
+
cachedContentTokenCount: z20.number().int().min(0).optional(),
|
|
5615
|
+
candidatesTokenCount: z20.number().int().min(0).optional(),
|
|
5616
|
+
thoughtsTokenCount: z20.number().int().min(0).optional(),
|
|
5617
|
+
totalTokenCount: z20.number().int().min(0).optional()
|
|
5348
5618
|
}).loose();
|
|
5349
|
-
var geminiCandidateSchema =
|
|
5350
|
-
content:
|
|
5351
|
-
role:
|
|
5352
|
-
parts:
|
|
5619
|
+
var geminiCandidateSchema = z20.object({
|
|
5620
|
+
content: z20.object({
|
|
5621
|
+
role: z20.string().optional(),
|
|
5622
|
+
parts: z20.array(z20.unknown()).optional()
|
|
5353
5623
|
}).loose().optional(),
|
|
5354
|
-
finishReason:
|
|
5355
|
-
index:
|
|
5624
|
+
finishReason: z20.string().optional(),
|
|
5625
|
+
index: z20.number().int().min(0).optional()
|
|
5356
5626
|
}).loose();
|
|
5357
|
-
var geminiLlmResponseSchema =
|
|
5627
|
+
var geminiLlmResponseSchema = z20.object({
|
|
5358
5628
|
/** Whole-response text, set by the translator from `getResponseText`. */
|
|
5359
|
-
text:
|
|
5360
|
-
candidates:
|
|
5629
|
+
text: z20.string().optional(),
|
|
5630
|
+
candidates: z20.array(geminiCandidateSchema).optional(),
|
|
5361
5631
|
usageMetadata: geminiUsageMetadataSchema.optional()
|
|
5362
5632
|
}).loose();
|
|
5363
|
-
var geminiMcpContextSchema =
|
|
5364
|
-
server_name:
|
|
5365
|
-
tool_name:
|
|
5633
|
+
var geminiMcpContextSchema = z20.object({
|
|
5634
|
+
server_name: z20.string().optional(),
|
|
5635
|
+
tool_name: z20.string().optional()
|
|
5366
5636
|
}).loose();
|
|
5367
|
-
var geminiToolResponseSchema =
|
|
5368
|
-
llmContent:
|
|
5369
|
-
returnDisplay:
|
|
5370
|
-
error:
|
|
5637
|
+
var geminiToolResponseSchema = z20.object({
|
|
5638
|
+
llmContent: z20.unknown().optional(),
|
|
5639
|
+
returnDisplay: z20.unknown().optional(),
|
|
5640
|
+
error: z20.unknown().optional()
|
|
5371
5641
|
}).loose();
|
|
5372
5642
|
var sessionStartInputSchema = baseHookInputSchema.extend({
|
|
5373
|
-
hook_event_name:
|
|
5374
|
-
source:
|
|
5643
|
+
hook_event_name: z20.literal("SessionStart"),
|
|
5644
|
+
source: z20.enum(["startup", "resume", "clear"]).optional()
|
|
5375
5645
|
});
|
|
5376
5646
|
var sessionEndInputSchema = baseHookInputSchema.extend({
|
|
5377
|
-
hook_event_name:
|
|
5378
|
-
reason:
|
|
5647
|
+
hook_event_name: z20.literal("SessionEnd"),
|
|
5648
|
+
reason: z20.enum(["exit", "clear", "logout", "prompt_input_exit", "other"]).optional()
|
|
5379
5649
|
});
|
|
5380
5650
|
var beforeAgentInputSchema = baseHookInputSchema.extend({
|
|
5381
|
-
hook_event_name:
|
|
5382
|
-
prompt:
|
|
5651
|
+
hook_event_name: z20.literal("BeforeAgent"),
|
|
5652
|
+
prompt: z20.string().optional()
|
|
5383
5653
|
});
|
|
5384
5654
|
var afterAgentInputSchema = baseHookInputSchema.extend({
|
|
5385
|
-
hook_event_name:
|
|
5386
|
-
prompt:
|
|
5387
|
-
prompt_response:
|
|
5388
|
-
stop_hook_active:
|
|
5655
|
+
hook_event_name: z20.literal("AfterAgent"),
|
|
5656
|
+
prompt: z20.string().optional(),
|
|
5657
|
+
prompt_response: z20.string().optional(),
|
|
5658
|
+
stop_hook_active: z20.boolean().optional()
|
|
5389
5659
|
});
|
|
5390
5660
|
var beforeModelInputSchema = baseHookInputSchema.extend({
|
|
5391
|
-
hook_event_name:
|
|
5661
|
+
hook_event_name: z20.literal("BeforeModel"),
|
|
5392
5662
|
llm_request: geminiLlmRequestSchema
|
|
5393
5663
|
});
|
|
5394
5664
|
var afterModelInputSchema = baseHookInputSchema.extend({
|
|
5395
|
-
hook_event_name:
|
|
5665
|
+
hook_event_name: z20.literal("AfterModel"),
|
|
5396
5666
|
llm_request: geminiLlmRequestSchema,
|
|
5397
5667
|
llm_response: geminiLlmResponseSchema
|
|
5398
5668
|
});
|
|
5399
5669
|
var beforeToolSelectionInputSchema = baseHookInputSchema.extend({
|
|
5400
|
-
hook_event_name:
|
|
5670
|
+
hook_event_name: z20.literal("BeforeToolSelection"),
|
|
5401
5671
|
llm_request: geminiLlmRequestSchema
|
|
5402
5672
|
});
|
|
5403
5673
|
var beforeToolInputSchema = baseHookInputSchema.extend({
|
|
5404
|
-
hook_event_name:
|
|
5405
|
-
tool_name:
|
|
5406
|
-
tool_input:
|
|
5674
|
+
hook_event_name: z20.literal("BeforeTool"),
|
|
5675
|
+
tool_name: z20.string().min(1),
|
|
5676
|
+
tool_input: z20.unknown().optional(),
|
|
5407
5677
|
mcp_context: geminiMcpContextSchema.optional(),
|
|
5408
|
-
original_request_name:
|
|
5678
|
+
original_request_name: z20.string().min(1).optional()
|
|
5409
5679
|
});
|
|
5410
5680
|
var afterToolInputSchema = baseHookInputSchema.extend({
|
|
5411
|
-
hook_event_name:
|
|
5412
|
-
tool_name:
|
|
5413
|
-
tool_input:
|
|
5681
|
+
hook_event_name: z20.literal("AfterTool"),
|
|
5682
|
+
tool_name: z20.string().min(1),
|
|
5683
|
+
tool_input: z20.unknown().optional(),
|
|
5414
5684
|
tool_response: geminiToolResponseSchema.optional(),
|
|
5415
5685
|
mcp_context: geminiMcpContextSchema.optional(),
|
|
5416
|
-
original_request_name:
|
|
5686
|
+
original_request_name: z20.string().min(1).optional()
|
|
5417
5687
|
});
|
|
5418
5688
|
var preCompressInputSchema = baseHookInputSchema.extend({
|
|
5419
|
-
hook_event_name:
|
|
5420
|
-
trigger:
|
|
5689
|
+
hook_event_name: z20.literal("PreCompress"),
|
|
5690
|
+
trigger: z20.enum(["auto", "manual"]).optional()
|
|
5421
5691
|
});
|
|
5422
5692
|
var notificationInputSchema = baseHookInputSchema.extend({
|
|
5423
|
-
hook_event_name:
|
|
5424
|
-
notification_type:
|
|
5425
|
-
message:
|
|
5426
|
-
details:
|
|
5693
|
+
hook_event_name: z20.literal("Notification"),
|
|
5694
|
+
notification_type: z20.string().optional(),
|
|
5695
|
+
message: z20.string().optional(),
|
|
5696
|
+
details: z20.unknown().optional()
|
|
5427
5697
|
});
|
|
5428
|
-
var geminiHookInputSchema =
|
|
5698
|
+
var geminiHookInputSchema = z20.discriminatedUnion("hook_event_name", [
|
|
5429
5699
|
sessionStartInputSchema,
|
|
5430
5700
|
sessionEndInputSchema,
|
|
5431
5701
|
beforeAgentInputSchema,
|
|
@@ -5870,7 +6140,7 @@ var normalizeUsageOrWarn = (usage, warnings) => {
|
|
|
5870
6140
|
};
|
|
5871
6141
|
|
|
5872
6142
|
// src/providers/antigravity/payload.ts
|
|
5873
|
-
import { z as
|
|
6143
|
+
import { z as z21 } from "zod";
|
|
5874
6144
|
var ANTIGRAVITY_HOOK_EVENT_NAMES = [
|
|
5875
6145
|
"PreInvocation",
|
|
5876
6146
|
"PostInvocation",
|
|
@@ -5878,48 +6148,48 @@ var ANTIGRAVITY_HOOK_EVENT_NAMES = [
|
|
|
5878
6148
|
"PostToolUse",
|
|
5879
6149
|
"Stop"
|
|
5880
6150
|
];
|
|
5881
|
-
var hookEventNameSchema =
|
|
5882
|
-
var antigravityWeakShapeSchema =
|
|
6151
|
+
var hookEventNameSchema = z21.enum(ANTIGRAVITY_HOOK_EVENT_NAMES);
|
|
6152
|
+
var antigravityWeakShapeSchema = z21.object({ hookEventName: hookEventNameSchema }).passthrough();
|
|
5883
6153
|
var commonFields2 = {
|
|
5884
|
-
conversationId:
|
|
5885
|
-
workspacePaths:
|
|
5886
|
-
invocationNum:
|
|
6154
|
+
conversationId: z21.string().min(1),
|
|
6155
|
+
workspacePaths: z21.array(z21.string().min(1)).max(64),
|
|
6156
|
+
invocationNum: z21.number().int().min(0),
|
|
5887
6157
|
/** Never disclosed: a real filesystem path. Accepted, never propagated. */
|
|
5888
|
-
transcriptPath:
|
|
6158
|
+
transcriptPath: z21.string().min(1).optional(),
|
|
5889
6159
|
/** Never disclosed: a real filesystem path. Accepted, never propagated. */
|
|
5890
|
-
artifactDirectoryPath:
|
|
6160
|
+
artifactDirectoryPath: z21.string().min(1).optional()
|
|
5891
6161
|
};
|
|
5892
|
-
var preInvocationPayloadSchema =
|
|
5893
|
-
hookEventName:
|
|
6162
|
+
var preInvocationPayloadSchema = z21.object({
|
|
6163
|
+
hookEventName: z21.literal("PreInvocation"),
|
|
5894
6164
|
...commonFields2,
|
|
5895
|
-
agentVersion:
|
|
6165
|
+
agentVersion: z21.string().min(1).optional()
|
|
5896
6166
|
});
|
|
5897
|
-
var postInvocationPayloadSchema =
|
|
5898
|
-
hookEventName:
|
|
6167
|
+
var postInvocationPayloadSchema = z21.object({
|
|
6168
|
+
hookEventName: z21.literal("PostInvocation"),
|
|
5899
6169
|
...commonFields2,
|
|
5900
|
-
agentVersion:
|
|
6170
|
+
agentVersion: z21.string().min(1).optional()
|
|
5901
6171
|
});
|
|
5902
|
-
var preToolUsePayloadSchema3 =
|
|
5903
|
-
hookEventName:
|
|
6172
|
+
var preToolUsePayloadSchema3 = z21.object({
|
|
6173
|
+
hookEventName: z21.literal("PreToolUse"),
|
|
5904
6174
|
...commonFields2,
|
|
5905
|
-
stepIdx:
|
|
5906
|
-
toolName:
|
|
5907
|
-
toolInput:
|
|
6175
|
+
stepIdx: z21.number().int().min(0),
|
|
6176
|
+
toolName: z21.string().min(1),
|
|
6177
|
+
toolInput: z21.unknown().optional()
|
|
5908
6178
|
});
|
|
5909
|
-
var postToolUsePayloadSchema3 =
|
|
5910
|
-
hookEventName:
|
|
6179
|
+
var postToolUsePayloadSchema3 = z21.object({
|
|
6180
|
+
hookEventName: z21.literal("PostToolUse"),
|
|
5911
6181
|
...commonFields2,
|
|
5912
|
-
stepIdx:
|
|
5913
|
-
toolName:
|
|
5914
|
-
toolResponse:
|
|
5915
|
-
isError:
|
|
6182
|
+
stepIdx: z21.number().int().min(0),
|
|
6183
|
+
toolName: z21.string().min(1),
|
|
6184
|
+
toolResponse: z21.unknown().optional(),
|
|
6185
|
+
isError: z21.boolean().optional()
|
|
5916
6186
|
});
|
|
5917
|
-
var stopPayloadSchema3 =
|
|
5918
|
-
hookEventName:
|
|
6187
|
+
var stopPayloadSchema3 = z21.object({
|
|
6188
|
+
hookEventName: z21.literal("Stop"),
|
|
5919
6189
|
...commonFields2,
|
|
5920
|
-
fullyIdle:
|
|
6190
|
+
fullyIdle: z21.boolean()
|
|
5921
6191
|
});
|
|
5922
|
-
var antigravityHookPayloadSchema =
|
|
6192
|
+
var antigravityHookPayloadSchema = z21.discriminatedUnion("hookEventName", [
|
|
5923
6193
|
preInvocationPayloadSchema,
|
|
5924
6194
|
postInvocationPayloadSchema,
|
|
5925
6195
|
preToolUsePayloadSchema3,
|
|
@@ -6233,15 +6503,15 @@ var describeProviderCatalog = (options = {}) => {
|
|
|
6233
6503
|
};
|
|
6234
6504
|
|
|
6235
6505
|
// src/runtime/ports.ts
|
|
6236
|
-
import { z as
|
|
6237
|
-
var appliedDeliverySchema =
|
|
6238
|
-
callbackId:
|
|
6506
|
+
import { z as z22 } from "zod";
|
|
6507
|
+
var appliedDeliverySchema = z22.strictObject({
|
|
6508
|
+
callbackId: z22.string().regex(/^[A-Za-z0-9_-]{1,128}$/),
|
|
6239
6509
|
/** How many of that delivery's observations are folded in, counted from one. */
|
|
6240
|
-
applications:
|
|
6510
|
+
applications: z22.number().int().min(1).max(4096)
|
|
6241
6511
|
});
|
|
6242
|
-
var stateValueSchema =
|
|
6243
|
-
|
|
6244
|
-
kind:
|
|
6512
|
+
var stateValueSchema = z22.discriminatedUnion("kind", [
|
|
6513
|
+
z22.strictObject({
|
|
6514
|
+
kind: z22.literal("usage-cumulative"),
|
|
6245
6515
|
usage: canonicalUsageSchema,
|
|
6246
6516
|
/**
|
|
6247
6517
|
* Optional: absent on every record written before this field existed, which
|
|
@@ -6250,22 +6520,22 @@ var stateValueSchema = z21.discriminatedUnion("kind", [
|
|
|
6250
6520
|
*/
|
|
6251
6521
|
appliedDelivery: appliedDeliverySchema.optional()
|
|
6252
6522
|
}),
|
|
6253
|
-
|
|
6254
|
-
kind:
|
|
6523
|
+
z22.strictObject({
|
|
6524
|
+
kind: z22.literal("sequence"),
|
|
6255
6525
|
next: sequenceNumberSchema
|
|
6256
6526
|
}),
|
|
6257
|
-
|
|
6258
|
-
kind:
|
|
6527
|
+
z22.strictObject({
|
|
6528
|
+
kind: z22.literal("attributes"),
|
|
6259
6529
|
attributes: attributesSchema
|
|
6260
6530
|
})
|
|
6261
6531
|
]);
|
|
6262
|
-
var stateRecordSchema =
|
|
6532
|
+
var stateRecordSchema = z22.strictObject({
|
|
6263
6533
|
/** Incremented on each write; lets callers detect lost updates. */
|
|
6264
|
-
revision:
|
|
6534
|
+
revision: z22.number().int().min(0),
|
|
6265
6535
|
updatedAt: epochMillisSchema,
|
|
6266
6536
|
value: stateValueSchema
|
|
6267
6537
|
});
|
|
6268
|
-
var logLevelSchema =
|
|
6538
|
+
var logLevelSchema = z22.enum(["silent", "error", "warn", "info", "debug"]);
|
|
6269
6539
|
var LOG_LEVEL_RANK = Object.freeze({
|
|
6270
6540
|
silent: 0,
|
|
6271
6541
|
error: 1,
|
|
@@ -6537,7 +6807,7 @@ var resolveDeliveryIdentity = (input) => {
|
|
|
6537
6807
|
};
|
|
6538
6808
|
|
|
6539
6809
|
// src/runtime/hook.ts
|
|
6540
|
-
import { z as
|
|
6810
|
+
import { z as z23 } from "zod";
|
|
6541
6811
|
|
|
6542
6812
|
// src/runtime/target-resolution.ts
|
|
6543
6813
|
import * as path from "path";
|
|
@@ -6707,7 +6977,7 @@ var withOptionalSessionLock = async (store, sessionId, fn, options) => {
|
|
|
6707
6977
|
};
|
|
6708
6978
|
|
|
6709
6979
|
// src/runtime/hook.ts
|
|
6710
|
-
var usageScopeSchema =
|
|
6980
|
+
var usageScopeSchema = z23.enum(["session", "generation", "subagent"]);
|
|
6711
6981
|
var classifyDurability = (input) => {
|
|
6712
6982
|
if (!input.attempted) {
|
|
6713
6983
|
return "nothing-to-deliver";
|
|
@@ -7820,7 +8090,7 @@ import {
|
|
|
7820
8090
|
} from "@opentelemetry/semantic-conventions/incubating";
|
|
7821
8091
|
|
|
7822
8092
|
// src/version.ts
|
|
7823
|
-
var VERSION = "0.
|
|
8093
|
+
var VERSION = "0.9.0";
|
|
7824
8094
|
|
|
7825
8095
|
// src/telemetry/export-identity.ts
|
|
7826
8096
|
import { ATTR_SESSION_ID } from "@opentelemetry/semantic-conventions/incubating";
|
|
@@ -9329,8 +9599,64 @@ var createFilesystemStateStore = (options) => {
|
|
|
9329
9599
|
|
|
9330
9600
|
// src/telemetry/spool-queue.ts
|
|
9331
9601
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
9332
|
-
import { mkdir as mkdir2, readFile as readFile2, readdir as readdir2, rename as rename2, unlink as unlink2, writeFile as writeFile2 } from "fs/promises";
|
|
9602
|
+
import { mkdir as mkdir2, readFile as readFile2, readdir as readdir2, rename as rename2, stat as stat2, unlink as unlink2, writeFile as writeFile2 } from "fs/promises";
|
|
9333
9603
|
import * as path4 from "path";
|
|
9604
|
+
var EMPTY_SPOOL_DROP_COUNTS = Object.freeze({
|
|
9605
|
+
total: 0,
|
|
9606
|
+
age: 0,
|
|
9607
|
+
size: 0,
|
|
9608
|
+
count: 0,
|
|
9609
|
+
rejected: 0
|
|
9610
|
+
});
|
|
9611
|
+
var SPOOL_DROPS_FILE = ".drops";
|
|
9612
|
+
var enqueuedAtOf = (fileName) => {
|
|
9613
|
+
const match = /^(\d{16})-/.exec(fileName);
|
|
9614
|
+
return match?.[1] === void 0 ? void 0 : Number(match[1]);
|
|
9615
|
+
};
|
|
9616
|
+
var isCount = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
9617
|
+
var readSpoolDropCounts = async (queueDir) => {
|
|
9618
|
+
try {
|
|
9619
|
+
const parsed = JSON.parse(await readFile2(path4.join(queueDir, SPOOL_DROPS_FILE), "utf8"));
|
|
9620
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
9621
|
+
return EMPTY_SPOOL_DROP_COUNTS;
|
|
9622
|
+
}
|
|
9623
|
+
const record = parsed;
|
|
9624
|
+
const field = (name) => isCount(record[name]) ? record[name] : 0;
|
|
9625
|
+
return {
|
|
9626
|
+
total: field("total"),
|
|
9627
|
+
age: field("age"),
|
|
9628
|
+
size: field("size"),
|
|
9629
|
+
count: field("count"),
|
|
9630
|
+
rejected: field("rejected"),
|
|
9631
|
+
...isCount(record.lastDroppedAt) ? { lastDroppedAt: record.lastDroppedAt } : {}
|
|
9632
|
+
};
|
|
9633
|
+
} catch {
|
|
9634
|
+
return EMPTY_SPOOL_DROP_COUNTS;
|
|
9635
|
+
}
|
|
9636
|
+
};
|
|
9637
|
+
var readSpoolQueueStats = async (queueDir) => {
|
|
9638
|
+
let entries;
|
|
9639
|
+
try {
|
|
9640
|
+
entries = await readdir2(queueDir);
|
|
9641
|
+
} catch {
|
|
9642
|
+
return { batches: 0, bytes: 0, dropped: await readSpoolDropCounts(queueDir) };
|
|
9643
|
+
}
|
|
9644
|
+
const files = entries.filter((entry) => entry.endsWith(".json") && !entry.startsWith(".tmp-")).sort();
|
|
9645
|
+
let bytes = 0;
|
|
9646
|
+
for (const file of files) {
|
|
9647
|
+
try {
|
|
9648
|
+
bytes += (await stat2(path4.join(queueDir, file))).size;
|
|
9649
|
+
} catch {
|
|
9650
|
+
}
|
|
9651
|
+
}
|
|
9652
|
+
const oldest = files[0] === void 0 ? void 0 : enqueuedAtOf(files[0]);
|
|
9653
|
+
return {
|
|
9654
|
+
batches: files.length,
|
|
9655
|
+
bytes,
|
|
9656
|
+
...oldest === void 0 ? {} : { oldestEnqueuedAt: oldest },
|
|
9657
|
+
dropped: await readSpoolDropCounts(queueDir)
|
|
9658
|
+
};
|
|
9659
|
+
};
|
|
9334
9660
|
var DEFAULT_DRAIN_MAX_BATCHES = 20;
|
|
9335
9661
|
var isErrnoException2 = (thrown, code) => thrown instanceof Error && thrown.code === code;
|
|
9336
9662
|
var createSpoolQueue = (options) => {
|
|
@@ -9371,27 +9697,132 @@ var createSpoolQueue = (options) => {
|
|
|
9371
9697
|
}
|
|
9372
9698
|
return entries.filter((entry) => entry.endsWith(".json") && !entry.startsWith(".tmp-")).sort();
|
|
9373
9699
|
};
|
|
9700
|
+
const recordDrops = async (reason, dropped) => {
|
|
9701
|
+
if (dropped <= 0) {
|
|
9702
|
+
return;
|
|
9703
|
+
}
|
|
9704
|
+
try {
|
|
9705
|
+
const current = await readSpoolDropCounts(queueDir);
|
|
9706
|
+
const next = {
|
|
9707
|
+
...current,
|
|
9708
|
+
total: current.total + dropped,
|
|
9709
|
+
[reason]: current[reason] + dropped,
|
|
9710
|
+
lastDroppedAt: options.clock.now()
|
|
9711
|
+
};
|
|
9712
|
+
const tmp = path4.join(queueDir, `.tmp-${randomBytes3(6).toString("hex")}.drops`);
|
|
9713
|
+
await writeFile2(tmp, JSON.stringify(next), "utf8");
|
|
9714
|
+
await rename2(tmp, path4.join(queueDir, SPOOL_DROPS_FILE));
|
|
9715
|
+
} catch {
|
|
9716
|
+
}
|
|
9717
|
+
options.logger?.warn("durable spool dropped batches", {
|
|
9718
|
+
"spool.queue": options.queueName,
|
|
9719
|
+
"spool.drop_reason": reason,
|
|
9720
|
+
"spool.dropped": dropped
|
|
9721
|
+
});
|
|
9722
|
+
};
|
|
9723
|
+
const listWithSizes = async () => {
|
|
9724
|
+
const names = await listSorted();
|
|
9725
|
+
const files = [];
|
|
9726
|
+
for (const name of names) {
|
|
9727
|
+
let bytes = 0;
|
|
9728
|
+
if (options.maxBytes !== void 0) {
|
|
9729
|
+
try {
|
|
9730
|
+
bytes = (await stat2(path4.join(queueDir, name))).size;
|
|
9731
|
+
} catch {
|
|
9732
|
+
continue;
|
|
9733
|
+
}
|
|
9734
|
+
}
|
|
9735
|
+
const enqueuedAt = enqueuedAtOf(name);
|
|
9736
|
+
files.push({ name, bytes, ...enqueuedAt === void 0 ? {} : { enqueuedAt } });
|
|
9737
|
+
}
|
|
9738
|
+
return files;
|
|
9739
|
+
};
|
|
9740
|
+
const evict = async (files) => {
|
|
9741
|
+
let removed = 0;
|
|
9742
|
+
for (const file of files) {
|
|
9743
|
+
try {
|
|
9744
|
+
await unlink2(path4.join(queueDir, file.name));
|
|
9745
|
+
removed += 1;
|
|
9746
|
+
} catch {
|
|
9747
|
+
}
|
|
9748
|
+
}
|
|
9749
|
+
return removed;
|
|
9750
|
+
};
|
|
9751
|
+
const isExpired = (file, now) => options.maxAgeMillis !== void 0 && file.enqueuedAt !== void 0 && now - file.enqueuedAt > options.maxAgeMillis;
|
|
9374
9752
|
const enqueue = async (batch) => {
|
|
9375
9753
|
await ensureDirs();
|
|
9376
|
-
const
|
|
9377
|
-
|
|
9754
|
+
const serialized = JSON.stringify(batch);
|
|
9755
|
+
const bytes = Buffer.byteLength(serialized, "utf8");
|
|
9756
|
+
const refuse = async (reason) => {
|
|
9378
9757
|
options.logger?.warn("durable spool at capacity; batch dropped", {
|
|
9379
9758
|
"spool.max_files": options.maxFiles,
|
|
9759
|
+
...options.maxBytes === void 0 ? {} : { "spool.max_bytes": options.maxBytes },
|
|
9380
9760
|
"spool.queue": options.queueName
|
|
9381
9761
|
});
|
|
9762
|
+
await recordDrops(reason, 1);
|
|
9382
9763
|
return { spooled: false, reason: "capacity-exceeded" };
|
|
9764
|
+
};
|
|
9765
|
+
if (options.maxBytes !== void 0 && bytes > options.maxBytes) {
|
|
9766
|
+
return refuse("size");
|
|
9767
|
+
}
|
|
9768
|
+
let queued = await listWithSizes();
|
|
9769
|
+
const now = options.clock.now();
|
|
9770
|
+
const expired = queued.filter((file) => isExpired(file, now));
|
|
9771
|
+
if (expired.length > 0) {
|
|
9772
|
+
await recordDrops("age", await evict(expired));
|
|
9773
|
+
queued = queued.filter((file) => !isExpired(file, now));
|
|
9774
|
+
}
|
|
9775
|
+
const overflow = options.overflow ?? "refuse-new";
|
|
9776
|
+
const totalBytes = () => queued.reduce((sum, file) => sum + file.bytes, 0);
|
|
9777
|
+
if (overflow === "refuse-new") {
|
|
9778
|
+
if (queued.length >= options.maxFiles) {
|
|
9779
|
+
return refuse("count");
|
|
9780
|
+
}
|
|
9781
|
+
if (options.maxBytes !== void 0 && totalBytes() + bytes > options.maxBytes) {
|
|
9782
|
+
return refuse("size");
|
|
9783
|
+
}
|
|
9784
|
+
} else {
|
|
9785
|
+
const overCount = Math.max(0, queued.length + 1 - options.maxFiles);
|
|
9786
|
+
if (overCount > 0) {
|
|
9787
|
+
await recordDrops("count", await evict(queued.slice(0, overCount)));
|
|
9788
|
+
queued = queued.slice(overCount);
|
|
9789
|
+
}
|
|
9790
|
+
if (options.maxBytes !== void 0) {
|
|
9791
|
+
let excess = totalBytes() + bytes - options.maxBytes;
|
|
9792
|
+
let cut = 0;
|
|
9793
|
+
while (excess > 0 && cut < queued.length) {
|
|
9794
|
+
excess -= queued[cut]?.bytes ?? 0;
|
|
9795
|
+
cut += 1;
|
|
9796
|
+
}
|
|
9797
|
+
if (cut > 0) {
|
|
9798
|
+
await recordDrops("size", await evict(queued.slice(0, cut)));
|
|
9799
|
+
queued = queued.slice(cut);
|
|
9800
|
+
}
|
|
9801
|
+
}
|
|
9383
9802
|
}
|
|
9384
|
-
const fileName = `${String(
|
|
9803
|
+
const fileName = `${String(now).padStart(16, "0")}-${randomBytes3(6).toString("hex")}.json`;
|
|
9385
9804
|
const target = path4.join(queueDir, fileName);
|
|
9386
9805
|
const tmp = path4.join(queueDir, `.tmp-${randomBytes3(6).toString("hex")}.json`);
|
|
9387
|
-
await writeFile2(tmp,
|
|
9806
|
+
await writeFile2(tmp, serialized, "utf8");
|
|
9388
9807
|
await rename2(tmp, target);
|
|
9389
9808
|
return { spooled: true };
|
|
9390
9809
|
};
|
|
9391
9810
|
const drain = async (send, drainOptions) => {
|
|
9392
9811
|
await ensureDirs();
|
|
9393
9812
|
const cap = drainOptions?.maxBatches ?? DEFAULT_DRAIN_MAX_BATCHES;
|
|
9394
|
-
|
|
9813
|
+
let files = await listSorted();
|
|
9814
|
+
if (options.maxAgeMillis !== void 0) {
|
|
9815
|
+
const now = options.clock.now();
|
|
9816
|
+
const expired = files.map((name) => {
|
|
9817
|
+
const enqueuedAt = enqueuedAtOf(name);
|
|
9818
|
+
return { name, bytes: 0, ...enqueuedAt === void 0 ? {} : { enqueuedAt } };
|
|
9819
|
+
}).filter((file) => isExpired(file, now));
|
|
9820
|
+
if (expired.length > 0) {
|
|
9821
|
+
await recordDrops("age", await evict(expired));
|
|
9822
|
+
const gone = new Set(expired.map((file) => file.name));
|
|
9823
|
+
files = files.filter((name) => !gone.has(name));
|
|
9824
|
+
}
|
|
9825
|
+
}
|
|
9395
9826
|
let drained = 0;
|
|
9396
9827
|
let failed = 0;
|
|
9397
9828
|
let quarantined = 0;
|
|
@@ -9436,6 +9867,12 @@ var createSpoolQueue = (options) => {
|
|
|
9436
9867
|
} catch {
|
|
9437
9868
|
delivered = false;
|
|
9438
9869
|
}
|
|
9870
|
+
if (delivered === "discard") {
|
|
9871
|
+
if (await unlink2(filePath).then(() => true, () => false)) {
|
|
9872
|
+
await recordDrops("rejected", 1);
|
|
9873
|
+
}
|
|
9874
|
+
continue;
|
|
9875
|
+
}
|
|
9439
9876
|
if (delivered) {
|
|
9440
9877
|
await unlink2(filePath).catch(() => void 0);
|
|
9441
9878
|
drained += 1;
|
|
@@ -9453,7 +9890,8 @@ var createSpoolQueue = (options) => {
|
|
|
9453
9890
|
size: async () => {
|
|
9454
9891
|
await ensureDirs();
|
|
9455
9892
|
return (await listSorted()).length;
|
|
9456
|
-
}
|
|
9893
|
+
},
|
|
9894
|
+
stats: () => readSpoolQueueStats(queueDir)
|
|
9457
9895
|
};
|
|
9458
9896
|
};
|
|
9459
9897
|
|
|
@@ -9545,7 +9983,10 @@ var createFileDurableSpool = (options) => createSpoolQueue({
|
|
|
9545
9983
|
clock: options.clock,
|
|
9546
9984
|
...options.logger === void 0 ? {} : { logger: options.logger },
|
|
9547
9985
|
maxFiles: options.maxSpoolFiles ?? DEFAULT_MAX_SPOOL_FILES,
|
|
9548
|
-
queueName: "spool",
|
|
9986
|
+
queueName: options.queueName ?? "spool",
|
|
9987
|
+
...options.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes },
|
|
9988
|
+
...options.maxAgeMillis === void 0 ? {} : { maxAgeMillis: options.maxAgeMillis },
|
|
9989
|
+
...options.overflow === void 0 ? {} : { overflow: options.overflow },
|
|
9549
9990
|
validate: validateSpoolBatch
|
|
9550
9991
|
});
|
|
9551
9992
|
|
|
@@ -9586,7 +10027,8 @@ var createHealthTracker = (subsystem, options = {}) => {
|
|
|
9586
10027
|
consecutiveFailures,
|
|
9587
10028
|
...lastSuccessAt === void 0 ? {} : { lastSuccessAt },
|
|
9588
10029
|
...lastFailureAt === void 0 ? {} : { lastFailureAt },
|
|
9589
|
-
...lastErrorCode === void 0 ? {} : { lastErrorCode }
|
|
10030
|
+
...lastErrorCode === void 0 ? {} : { lastErrorCode },
|
|
10031
|
+
...options.destination === void 0 ? {} : { destination: options.destination }
|
|
9590
10032
|
})
|
|
9591
10033
|
};
|
|
9592
10034
|
};
|
|
@@ -9595,6 +10037,13 @@ var summarizeHealth = (snapshots) => ({
|
|
|
9595
10037
|
subsystems: [...snapshots]
|
|
9596
10038
|
});
|
|
9597
10039
|
|
|
10040
|
+
// src/telemetry/export-failure.ts
|
|
10041
|
+
var RETRYABLE_HTTP_STATUSES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
|
|
10042
|
+
var isPermanentExportFailure = (result) => {
|
|
10043
|
+
const code = result.error?.code;
|
|
10044
|
+
return typeof code === "number" && Number.isInteger(code) && code >= 400 && code < 600 && !RETRYABLE_HTTP_STATUSES.has(code);
|
|
10045
|
+
};
|
|
10046
|
+
|
|
9598
10047
|
// src/telemetry/exporter-resource.ts
|
|
9599
10048
|
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
9600
10049
|
var resourceFromExporterPolicy = (policy) => resourceFromAttributes({
|
|
@@ -9666,8 +10115,11 @@ var deserializeSpan = (serialized, resource, scope) => assembleReadableSpan({
|
|
|
9666
10115
|
resource,
|
|
9667
10116
|
instrumentationScope: scope
|
|
9668
10117
|
});
|
|
9669
|
-
var createDisabledSink = () => {
|
|
9670
|
-
const health = createHealthTracker(
|
|
10118
|
+
var createDisabledSink = (destination) => {
|
|
10119
|
+
const health = createHealthTracker(
|
|
10120
|
+
"telemetry-sink",
|
|
10121
|
+
destination === void 0 ? {} : { destination }
|
|
10122
|
+
);
|
|
9671
10123
|
return {
|
|
9672
10124
|
emit: (events) => {
|
|
9673
10125
|
health.recordSuccess(events.length);
|
|
@@ -9680,22 +10132,27 @@ var createDisabledSink = () => {
|
|
|
9680
10132
|
};
|
|
9681
10133
|
};
|
|
9682
10134
|
var createOtlpTraceSink = (options) => {
|
|
10135
|
+
const destinationFields = options.destination === void 0 ? {} : { "export.destination": options.destination };
|
|
9683
10136
|
if (!options.exporter.enabled || options.exporter.protocol === "none") {
|
|
9684
|
-
return createDisabledSink();
|
|
10137
|
+
return createDisabledSink(options.destination);
|
|
9685
10138
|
}
|
|
9686
10139
|
if (options.exporter.endpoint === void 0) {
|
|
9687
|
-
options.logger?.warn("otlp sink disabled: no endpoint configured",
|
|
9688
|
-
return createDisabledSink();
|
|
10140
|
+
options.logger?.warn("otlp sink disabled: no endpoint configured", destinationFields);
|
|
10141
|
+
return createDisabledSink(options.destination);
|
|
9689
10142
|
}
|
|
9690
10143
|
if (options.exporter.protocol !== "http/protobuf") {
|
|
9691
10144
|
options.logger?.warn("otlp sink: protocol not supported by this build, falling back to disabled", {
|
|
9692
|
-
"exporter.protocol": options.exporter.protocol
|
|
10145
|
+
"exporter.protocol": options.exporter.protocol,
|
|
10146
|
+
...destinationFields
|
|
9693
10147
|
});
|
|
9694
|
-
return createDisabledSink();
|
|
10148
|
+
return createDisabledSink(options.destination);
|
|
9695
10149
|
}
|
|
9696
10150
|
const scope = options.instrumentationScope ?? DEFAULT_INSTRUMENTATION_SCOPE;
|
|
9697
10151
|
const resource = resourceFromExporterPolicy(options.exporter);
|
|
9698
|
-
const health = createHealthTracker(
|
|
10152
|
+
const health = createHealthTracker(
|
|
10153
|
+
"telemetry-sink",
|
|
10154
|
+
options.destination === void 0 ? {} : { destination: options.destination }
|
|
10155
|
+
);
|
|
9699
10156
|
const exporter = new OTLPTraceExporter({
|
|
9700
10157
|
url: options.exporter.endpoint,
|
|
9701
10158
|
headers: { ...options.headers },
|
|
@@ -9717,7 +10174,10 @@ var createOtlpTraceSink = (options) => {
|
|
|
9717
10174
|
const batchResource = replayResource(batch.resourceAttributes, options.exporter);
|
|
9718
10175
|
const spans = batch.spans.map((span) => deserializeSpan(span, batchResource, batch.instrumentationScope));
|
|
9719
10176
|
const result = await exportSpans(spans);
|
|
9720
|
-
|
|
10177
|
+
if (result.code === ExportResultCode.SUCCESS) {
|
|
10178
|
+
return true;
|
|
10179
|
+
}
|
|
10180
|
+
return isPermanentExportFailure(result) ? "discard" : false;
|
|
9721
10181
|
};
|
|
9722
10182
|
const resolveCorrelations = async (events) => {
|
|
9723
10183
|
if (options.correlate === void 0) {
|
|
@@ -9745,6 +10205,9 @@ var createOtlpTraceSink = (options) => {
|
|
|
9745
10205
|
let accepted = 0;
|
|
9746
10206
|
let rejected = 0;
|
|
9747
10207
|
for (const batch of chunk(spans, options.exporter.maxBatchSize)) {
|
|
10208
|
+
if (batch.length === 0) {
|
|
10209
|
+
continue;
|
|
10210
|
+
}
|
|
9748
10211
|
let result;
|
|
9749
10212
|
try {
|
|
9750
10213
|
result = await exportSpans(batch);
|
|
@@ -9757,13 +10220,18 @@ var createOtlpTraceSink = (options) => {
|
|
|
9757
10220
|
continue;
|
|
9758
10221
|
}
|
|
9759
10222
|
health.recordFailure("telemetry-export-failure", batch.length, options.clock.now());
|
|
9760
|
-
|
|
10223
|
+
const permanent = isPermanentExportFailure(result);
|
|
10224
|
+
if (options.spool !== void 0 && !permanent) {
|
|
9761
10225
|
const spoolResult = await options.spool.enqueue(toSpoolBatch(batch)).catch(() => ({
|
|
9762
10226
|
spooled: false,
|
|
9763
10227
|
reason: "capacity-exceeded"
|
|
9764
10228
|
}));
|
|
9765
10229
|
if (spoolResult.spooled) {
|
|
9766
10230
|
accepted += batch.length;
|
|
10231
|
+
options.logger?.warn("span batch not delivered; spooled for the next invocation", {
|
|
10232
|
+
"export.batch_size": batch.length,
|
|
10233
|
+
...destinationFields
|
|
10234
|
+
});
|
|
9767
10235
|
continue;
|
|
9768
10236
|
}
|
|
9769
10237
|
}
|
|
@@ -9772,8 +10240,8 @@ var createOtlpTraceSink = (options) => {
|
|
|
9772
10240
|
createErrorInfo({
|
|
9773
10241
|
code: "telemetry-export-failure",
|
|
9774
10242
|
phase: "export",
|
|
9775
|
-
detail: "collector rejected or was unreachable for a span batch",
|
|
9776
|
-
details: { "export.batch_size": batch.length }
|
|
10243
|
+
detail: permanent ? "collector refused a span batch with a non-retryable status" : "collector rejected or was unreachable for a span batch",
|
|
10244
|
+
details: { "export.batch_size": batch.length, ...destinationFields }
|
|
9777
10245
|
})
|
|
9778
10246
|
);
|
|
9779
10247
|
}
|
|
@@ -10330,7 +10798,10 @@ var createFileDurableLogSpool = (options) => createSpoolQueue({
|
|
|
10330
10798
|
clock: options.clock,
|
|
10331
10799
|
...options.logger === void 0 ? {} : { logger: options.logger },
|
|
10332
10800
|
maxFiles: options.maxSpoolFiles ?? DEFAULT_MAX_LOG_SPOOL_FILES,
|
|
10333
|
-
queueName: "spool-logs",
|
|
10801
|
+
queueName: options.queueName ?? "spool-logs",
|
|
10802
|
+
...options.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes },
|
|
10803
|
+
...options.maxAgeMillis === void 0 ? {} : { maxAgeMillis: options.maxAgeMillis },
|
|
10804
|
+
...options.overflow === void 0 ? {} : { overflow: options.overflow },
|
|
10334
10805
|
validate: validateLogSpoolBatch
|
|
10335
10806
|
});
|
|
10336
10807
|
|
|
@@ -10415,8 +10886,11 @@ var chunk2 = (items, size) => {
|
|
|
10415
10886
|
}
|
|
10416
10887
|
return chunks;
|
|
10417
10888
|
};
|
|
10418
|
-
var createDisabledSink2 = () => {
|
|
10419
|
-
const health = createHealthTracker(
|
|
10889
|
+
var createDisabledSink2 = (destination) => {
|
|
10890
|
+
const health = createHealthTracker(
|
|
10891
|
+
"telemetry-log-sink",
|
|
10892
|
+
destination === void 0 ? {} : { destination }
|
|
10893
|
+
);
|
|
10420
10894
|
return {
|
|
10421
10895
|
emit: (events) => {
|
|
10422
10896
|
health.recordSuccess(events.length);
|
|
@@ -10455,19 +10929,24 @@ var DISABLED_DETAIL = Object.freeze({
|
|
|
10455
10929
|
"no-endpoint": "otlp log sink disabled: no logs endpoint configured and none could be derived"
|
|
10456
10930
|
});
|
|
10457
10931
|
var createOtlpLogSink = (options) => {
|
|
10932
|
+
const destinationFields = options.destination === void 0 ? {} : { "export.destination": options.destination };
|
|
10458
10933
|
const deliverability = describeLogsDeliverability(options.exporter);
|
|
10459
10934
|
if (deliverability.status === "disabled") {
|
|
10460
10935
|
if (deliverability.reason !== "logs-disabled") {
|
|
10461
10936
|
options.logger?.warn(DISABLED_DETAIL[deliverability.reason], {
|
|
10462
|
-
"exporter.protocol": options.exporter.protocol
|
|
10937
|
+
"exporter.protocol": options.exporter.protocol,
|
|
10938
|
+
...destinationFields
|
|
10463
10939
|
});
|
|
10464
10940
|
}
|
|
10465
|
-
return createDisabledSink2();
|
|
10941
|
+
return createDisabledSink2(options.destination);
|
|
10466
10942
|
}
|
|
10467
10943
|
const scope = options.instrumentationScope ?? DEFAULT_INSTRUMENTATION_SCOPE;
|
|
10468
10944
|
const resource = resourceFromExporterPolicy(options.exporter);
|
|
10469
10945
|
const content = options.content ?? NO_LOG_CONTENT;
|
|
10470
|
-
const health = createHealthTracker(
|
|
10946
|
+
const health = createHealthTracker(
|
|
10947
|
+
"telemetry-log-sink",
|
|
10948
|
+
options.destination === void 0 ? {} : { destination: options.destination }
|
|
10949
|
+
);
|
|
10471
10950
|
const exporter = new OTLPLogExporter({
|
|
10472
10951
|
url: deliverability.endpoint,
|
|
10473
10952
|
headers: { ...options.headers },
|
|
@@ -10494,7 +10973,10 @@ var createOtlpLogSink = (options) => {
|
|
|
10494
10973
|
(record) => deserializeRecord(record, batchResource, batch.instrumentationScope)
|
|
10495
10974
|
);
|
|
10496
10975
|
const result = await exportRecords(records);
|
|
10497
|
-
|
|
10976
|
+
if (result.code === ExportResultCode2.SUCCESS) {
|
|
10977
|
+
return true;
|
|
10978
|
+
}
|
|
10979
|
+
return isPermanentExportFailure(result) ? "discard" : false;
|
|
10498
10980
|
};
|
|
10499
10981
|
const resolveCorrelations = async (events) => {
|
|
10500
10982
|
if (options.correlate === void 0) {
|
|
@@ -10546,13 +11028,18 @@ var createOtlpLogSink = (options) => {
|
|
|
10546
11028
|
continue;
|
|
10547
11029
|
}
|
|
10548
11030
|
health.recordFailure("telemetry-export-failure", batch.length, options.clock.now());
|
|
10549
|
-
|
|
11031
|
+
const permanent = isPermanentExportFailure(result);
|
|
11032
|
+
if (options.spool !== void 0 && !permanent) {
|
|
10550
11033
|
const spoolResult = await options.spool.enqueue(toSpoolBatch(batch)).catch(() => ({
|
|
10551
11034
|
spooled: false,
|
|
10552
11035
|
reason: "capacity-exceeded"
|
|
10553
11036
|
}));
|
|
10554
11037
|
if (spoolResult.spooled) {
|
|
10555
11038
|
accepted += batch.length;
|
|
11039
|
+
options.logger?.warn("log record batch not delivered; spooled for the next invocation", {
|
|
11040
|
+
"export.batch_size": batch.length,
|
|
11041
|
+
...destinationFields
|
|
11042
|
+
});
|
|
10556
11043
|
continue;
|
|
10557
11044
|
}
|
|
10558
11045
|
}
|
|
@@ -10561,8 +11048,12 @@ var createOtlpLogSink = (options) => {
|
|
|
10561
11048
|
createErrorInfo({
|
|
10562
11049
|
code: "telemetry-export-failure",
|
|
10563
11050
|
phase: "export",
|
|
10564
|
-
detail: "collector rejected or was unreachable for a log record batch",
|
|
10565
|
-
details: {
|
|
11051
|
+
detail: permanent ? "collector refused a log record batch with a non-retryable status" : "collector rejected or was unreachable for a log record batch",
|
|
11052
|
+
details: {
|
|
11053
|
+
"export.batch_size": batch.length,
|
|
11054
|
+
"export.signal": "logs",
|
|
11055
|
+
...destinationFields
|
|
11056
|
+
}
|
|
10566
11057
|
})
|
|
10567
11058
|
);
|
|
10568
11059
|
}
|
|
@@ -10649,6 +11140,172 @@ var shareCorrelationPerBatch = (correlate) => {
|
|
|
10649
11140
|
};
|
|
10650
11141
|
};
|
|
10651
11142
|
|
|
11143
|
+
// src/telemetry/export-destinations.ts
|
|
11144
|
+
var spoolQueueNamesFor = (destination) => destination === DEFAULT_DESTINATION_NAME ? { traces: "spool", logs: "spool-logs" } : { traces: `destinations/${destination}/spool`, logs: `destinations/${destination}/spool-logs` };
|
|
11145
|
+
var exporterPolicyForDestination = (exporter, destination) => {
|
|
11146
|
+
if (destination.source === "exporter") {
|
|
11147
|
+
return exporter;
|
|
11148
|
+
}
|
|
11149
|
+
const { destinations, endpoint, logs, ...shared } = exporter;
|
|
11150
|
+
void destinations;
|
|
11151
|
+
void endpoint;
|
|
11152
|
+
const tracesEndpoint = destination.tracesEndpoint ?? destination.endpoint;
|
|
11153
|
+
const derivedLogs = destination.logsEndpoint ?? (destination.endpoint === void 0 ? void 0 : (() => {
|
|
11154
|
+
const derived = resolveLogsEndpoint({
|
|
11155
|
+
...exporter,
|
|
11156
|
+
endpoint: destination.endpoint,
|
|
11157
|
+
logs: { enabled: true, includeContent: false, maxBatchSize: logs.maxBatchSize }
|
|
11158
|
+
});
|
|
11159
|
+
return "endpoint" in derived ? derived.endpoint : void 0;
|
|
11160
|
+
})());
|
|
11161
|
+
return {
|
|
11162
|
+
...shared,
|
|
11163
|
+
protocol: destination.protocol,
|
|
11164
|
+
...tracesEndpoint === void 0 ? {} : { endpoint: tracesEndpoint },
|
|
11165
|
+
headerNames: Object.keys(destination.headers).sort(),
|
|
11166
|
+
logs: {
|
|
11167
|
+
...logs,
|
|
11168
|
+
enabled: destination.signals.logs,
|
|
11169
|
+
...derivedLogs === void 0 ? {} : { endpoint: derivedLogs }
|
|
11170
|
+
}
|
|
11171
|
+
};
|
|
11172
|
+
};
|
|
11173
|
+
var createOptedOutTraceSink = (destination) => {
|
|
11174
|
+
const health = createHealthTracker(
|
|
11175
|
+
"telemetry-sink",
|
|
11176
|
+
destination === void 0 ? {} : { destination }
|
|
11177
|
+
);
|
|
11178
|
+
return {
|
|
11179
|
+
emit: () => Promise.resolve({ accepted: 0, rejected: 0, errors: [] }),
|
|
11180
|
+
flush: () => Promise.resolve(),
|
|
11181
|
+
shutdown: () => Promise.resolve(),
|
|
11182
|
+
health: () => health.snapshot(),
|
|
11183
|
+
drainSpool: () => Promise.resolve({ drained: 0, remaining: 0, failed: 0 })
|
|
11184
|
+
};
|
|
11185
|
+
};
|
|
11186
|
+
var createExportDestinationSinks = (options) => {
|
|
11187
|
+
const labelled = hasConfiguredDestinations(options.exporter);
|
|
11188
|
+
const spoolPolicy = effectiveSpoolPolicy(options.exporter);
|
|
11189
|
+
const destinations = [];
|
|
11190
|
+
const skipped = [];
|
|
11191
|
+
for (const destination of resolveExportDestinations(options.exporter)) {
|
|
11192
|
+
let headers;
|
|
11193
|
+
let logHeaders;
|
|
11194
|
+
if (destination.source === "exporter") {
|
|
11195
|
+
headers = options.defaultHeaders;
|
|
11196
|
+
logHeaders = options.defaultLogHeaders ?? options.defaultHeaders;
|
|
11197
|
+
} else {
|
|
11198
|
+
const resolved = resolveDestinationHeaders(destination.headers, options.headerEnvironment);
|
|
11199
|
+
if (resolved.missingVariables.length > 0) {
|
|
11200
|
+
options.logger?.warn("export destination skipped: a header references an unset environment variable", {
|
|
11201
|
+
"export.destination": destination.name,
|
|
11202
|
+
"config.variables": [...resolved.missingVariables]
|
|
11203
|
+
});
|
|
11204
|
+
skipped.push({
|
|
11205
|
+
name: destination.name,
|
|
11206
|
+
reason: "header-variable-missing",
|
|
11207
|
+
missingVariables: resolved.missingVariables
|
|
11208
|
+
});
|
|
11209
|
+
continue;
|
|
11210
|
+
}
|
|
11211
|
+
headers = resolved.values;
|
|
11212
|
+
logHeaders = resolved.values;
|
|
11213
|
+
}
|
|
11214
|
+
const label = labelled ? destination.name : void 0;
|
|
11215
|
+
const policy = exporterPolicyForDestination(options.exporter, destination);
|
|
11216
|
+
const queues = spoolQueueNamesFor(destination.name);
|
|
11217
|
+
const bounds = {
|
|
11218
|
+
maxSpoolFiles: spoolPolicy.maxBatches,
|
|
11219
|
+
maxBytes: spoolPolicy.maxBytes,
|
|
11220
|
+
maxAgeMillis: spoolPolicy.maxAgeMillis,
|
|
11221
|
+
overflow: "drop-oldest"
|
|
11222
|
+
};
|
|
11223
|
+
const shared = {
|
|
11224
|
+
providerId: options.providerId,
|
|
11225
|
+
installationId: options.installationId,
|
|
11226
|
+
clock: options.clock,
|
|
11227
|
+
...options.logger === void 0 ? {} : { logger: options.logger }
|
|
11228
|
+
};
|
|
11229
|
+
const spool = options.spoolRootDir === void 0 || !destination.signals.traces ? void 0 : createFileDurableSpool({
|
|
11230
|
+
rootDir: options.spoolRootDir,
|
|
11231
|
+
...shared,
|
|
11232
|
+
...bounds,
|
|
11233
|
+
queueName: queues.traces
|
|
11234
|
+
});
|
|
11235
|
+
const logSpool = options.spoolRootDir === void 0 || !destination.signals.logs ? void 0 : createFileDurableLogSpool({
|
|
11236
|
+
rootDir: options.spoolRootDir,
|
|
11237
|
+
...shared,
|
|
11238
|
+
...bounds,
|
|
11239
|
+
queueName: queues.logs
|
|
11240
|
+
});
|
|
11241
|
+
const sinkShared = {
|
|
11242
|
+
exporter: policy,
|
|
11243
|
+
...shared,
|
|
11244
|
+
...options.correlate === void 0 ? {} : { correlate: options.correlate },
|
|
11245
|
+
...label === void 0 ? {} : { destination: label }
|
|
11246
|
+
};
|
|
11247
|
+
const traces = destination.signals.traces ? createOtlpTraceSink({
|
|
11248
|
+
...sinkShared,
|
|
11249
|
+
...headers === void 0 || Object.keys(headers).length === 0 ? {} : { headers },
|
|
11250
|
+
...spool === void 0 ? {} : { spool }
|
|
11251
|
+
}) : createOptedOutTraceSink(label);
|
|
11252
|
+
const logs = createOtlpLogSink({
|
|
11253
|
+
...sinkShared,
|
|
11254
|
+
...logHeaders === void 0 || Object.keys(logHeaders).length === 0 ? {} : { headers: logHeaders },
|
|
11255
|
+
...logSpool === void 0 ? {} : { spool: logSpool },
|
|
11256
|
+
content: options.logContent
|
|
11257
|
+
});
|
|
11258
|
+
destinations.push({
|
|
11259
|
+
name: destination.name,
|
|
11260
|
+
traces,
|
|
11261
|
+
logs,
|
|
11262
|
+
...spool === void 0 ? {} : { spool },
|
|
11263
|
+
...logSpool === void 0 ? {} : { logSpool }
|
|
11264
|
+
});
|
|
11265
|
+
}
|
|
11266
|
+
return { destinations, skipped };
|
|
11267
|
+
};
|
|
11268
|
+
var createDestinationFanout = (destinations) => {
|
|
11269
|
+
const fanouts = destinations.map((destination) => ({
|
|
11270
|
+
name: destination.name,
|
|
11271
|
+
sink: createSignalFanout({ traces: destination.traces, logs: destination.logs })
|
|
11272
|
+
}));
|
|
11273
|
+
const only = fanouts.length === 1 ? fanouts[0] : void 0;
|
|
11274
|
+
if (only !== void 0) {
|
|
11275
|
+
return only.sink;
|
|
11276
|
+
}
|
|
11277
|
+
const emit = async (events) => {
|
|
11278
|
+
const results = await Promise.all(
|
|
11279
|
+
fanouts.map(
|
|
11280
|
+
(fanout) => fanout.sink.emit(events).catch(
|
|
11281
|
+
(thrown) => ({
|
|
11282
|
+
accepted: 0,
|
|
11283
|
+
rejected: events.length,
|
|
11284
|
+
errors: [errorInfoFromThrown(thrown, { code: "telemetry-export-failure", phase: "export" })]
|
|
11285
|
+
})
|
|
11286
|
+
)
|
|
11287
|
+
)
|
|
11288
|
+
);
|
|
11289
|
+
const errors = results.flatMap((result) => result.errors);
|
|
11290
|
+
return {
|
|
11291
|
+
accepted: results.reduce((sum, result) => sum + result.accepted, 0),
|
|
11292
|
+
rejected: results.reduce((sum, result) => sum + result.rejected, 0),
|
|
11293
|
+
errors
|
|
11294
|
+
};
|
|
11295
|
+
};
|
|
11296
|
+
const settleAll = async (run) => {
|
|
11297
|
+
await Promise.all(fanouts.map((fanout) => run(fanout.sink).catch(() => void 0)));
|
|
11298
|
+
};
|
|
11299
|
+
return {
|
|
11300
|
+
emit,
|
|
11301
|
+
// Each destination drains its own spool in its flush; in parallel, so one
|
|
11302
|
+
// unreachable destination's drain cannot use up the others' flush window.
|
|
11303
|
+
flush: () => settleAll((sink) => sink.flush()),
|
|
11304
|
+
shutdown: () => settleAll((sink) => sink.shutdown()),
|
|
11305
|
+
health: () => fanouts.flatMap((fanout) => fanout.sink.health())
|
|
11306
|
+
};
|
|
11307
|
+
};
|
|
11308
|
+
|
|
10652
11309
|
// src/integration/hook-runtime.ts
|
|
10653
11310
|
var DEFAULT_FLUSH_TIMEOUT_MILLIS = 2e3;
|
|
10654
11311
|
var DEFAULT_STATE_LOCK_TIMEOUT_MILLIS = 1e3;
|
|
@@ -10711,46 +11368,23 @@ var createHookRuntime = (options) => {
|
|
|
10711
11368
|
logger,
|
|
10712
11369
|
lockTimeoutMillis: stateLockTimeoutMillis
|
|
10713
11370
|
});
|
|
10714
|
-
const spool = options.enableSpool === false ? void 0 : createFileDurableSpool({
|
|
10715
|
-
rootDir: options.stateRootDir,
|
|
10716
|
-
providerId: options.providerNamespace,
|
|
10717
|
-
installationId: options.installationId,
|
|
10718
|
-
clock,
|
|
10719
|
-
logger
|
|
10720
|
-
});
|
|
10721
|
-
const logSpool = options.enableSpool === false || !options.config.exporter.logs.enabled ? void 0 : createFileDurableLogSpool({
|
|
10722
|
-
rootDir: options.stateRootDir,
|
|
10723
|
-
providerId: options.providerNamespace,
|
|
10724
|
-
installationId: options.installationId,
|
|
10725
|
-
clock,
|
|
10726
|
-
logger
|
|
10727
|
-
});
|
|
10728
11371
|
const spanCorrelator = createSpanCorrelator({
|
|
10729
11372
|
stateStore,
|
|
10730
11373
|
clock,
|
|
10731
11374
|
maxStartAgeMillis: lifecycleMaxAge
|
|
10732
11375
|
});
|
|
10733
11376
|
const correlate = shareCorrelationPerBatch((events) => spanCorrelator.correlateBatch(events));
|
|
10734
|
-
const
|
|
10735
|
-
exporter: options.config.exporter,
|
|
10736
|
-
...options.headers === void 0 ? {} : { headers: options.headers },
|
|
10737
|
-
providerId: options.providerNamespace,
|
|
10738
|
-
installationId: options.installationId,
|
|
10739
|
-
clock,
|
|
10740
|
-
logger,
|
|
10741
|
-
...spool === void 0 ? {} : { spool },
|
|
10742
|
-
correlate
|
|
10743
|
-
});
|
|
10744
|
-
const logHeaders = options.logHeaders ?? options.headers;
|
|
10745
|
-
const logSink = createOtlpLogSink({
|
|
11377
|
+
const exportDestinations = createExportDestinationSinks({
|
|
10746
11378
|
exporter: options.config.exporter,
|
|
10747
|
-
...
|
|
11379
|
+
...options.headers === void 0 ? {} : { defaultHeaders: options.headers },
|
|
11380
|
+
...options.logHeaders === void 0 ? {} : { defaultLogHeaders: options.logHeaders },
|
|
11381
|
+
...options.headerEnvironment === void 0 ? {} : { headerEnvironment: options.headerEnvironment },
|
|
10748
11382
|
providerId: options.providerNamespace,
|
|
10749
11383
|
installationId: options.installationId,
|
|
10750
11384
|
clock,
|
|
10751
11385
|
logger,
|
|
10752
|
-
...
|
|
10753
|
-
|
|
11386
|
+
...options.enableSpool === false ? {} : { spoolRootDir: options.stateRootDir },
|
|
11387
|
+
logContent: {
|
|
10754
11388
|
includeContent: options.config.exporter.logs.includeContent,
|
|
10755
11389
|
// The pre-existing verbatim-content opt-in, passed through rather than
|
|
10756
11390
|
// re-derived: `raw` disclosure in a log body is governed by the same flag it
|
|
@@ -10759,7 +11393,22 @@ var createHookRuntime = (options) => {
|
|
|
10759
11393
|
},
|
|
10760
11394
|
correlate
|
|
10761
11395
|
});
|
|
10762
|
-
const
|
|
11396
|
+
const primary = exportDestinations.destinations[0];
|
|
11397
|
+
const traceSink = primary?.traces ?? createOtlpTraceSink({
|
|
11398
|
+
exporter: { ...options.config.exporter, enabled: false },
|
|
11399
|
+
providerId: options.providerNamespace,
|
|
11400
|
+
installationId: options.installationId,
|
|
11401
|
+
clock
|
|
11402
|
+
});
|
|
11403
|
+
const logSink = primary?.logs ?? createOtlpLogSink({
|
|
11404
|
+
exporter: { ...options.config.exporter, logs: { ...options.config.exporter.logs, enabled: false } },
|
|
11405
|
+
providerId: options.providerNamespace,
|
|
11406
|
+
installationId: options.installationId,
|
|
11407
|
+
clock
|
|
11408
|
+
});
|
|
11409
|
+
const spool = primary?.spool;
|
|
11410
|
+
const logSpool = primary?.logSpool;
|
|
11411
|
+
const sink = createDestinationFanout(exportDestinations.destinations);
|
|
10763
11412
|
const hookDeps = {
|
|
10764
11413
|
stateStore,
|
|
10765
11414
|
config: options.config,
|
|
@@ -11028,6 +11677,8 @@ var createHookRuntime = (options) => {
|
|
|
11028
11677
|
logSink,
|
|
11029
11678
|
...spool === void 0 ? {} : { spool },
|
|
11030
11679
|
...logSpool === void 0 ? {} : { logSpool },
|
|
11680
|
+
destinations: exportDestinations.destinations,
|
|
11681
|
+
skippedDestinations: exportDestinations.skipped,
|
|
11031
11682
|
privacy,
|
|
11032
11683
|
deduplicator,
|
|
11033
11684
|
usageAccumulator,
|
|
@@ -11975,7 +12626,7 @@ var resolveInstallPath = (location, roots) => path5.resolve(
|
|
|
11975
12626
|
|
|
11976
12627
|
// src/install/document.ts
|
|
11977
12628
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
11978
|
-
import { chmod, mkdir as mkdir3, open as open3, readFile as readFile3, rename as rename3, stat as
|
|
12629
|
+
import { chmod, mkdir as mkdir3, open as open3, readFile as readFile3, rename as rename3, stat as stat3, unlink as unlink3 } from "fs/promises";
|
|
11979
12630
|
import * as path6 from "path";
|
|
11980
12631
|
var DEFAULT_DOCUMENT_FORMAT = Object.freeze({
|
|
11981
12632
|
indent: " ",
|
|
@@ -12055,7 +12706,7 @@ var writeDocumentAtomically = async (filePath, contents) => {
|
|
|
12055
12706
|
);
|
|
12056
12707
|
let existingMode;
|
|
12057
12708
|
try {
|
|
12058
|
-
existingMode = (await
|
|
12709
|
+
existingMode = (await stat3(filePath)).mode & 4095;
|
|
12059
12710
|
} catch (thrown) {
|
|
12060
12711
|
if (!isErrnoException3(thrown, "ENOENT")) {
|
|
12061
12712
|
throw thrown;
|
|
@@ -12080,7 +12731,7 @@ var writeDocumentAtomically = async (filePath, contents) => {
|
|
|
12080
12731
|
|
|
12081
12732
|
// src/install/file-lock.ts
|
|
12082
12733
|
import { randomBytes as randomBytes5 } from "crypto";
|
|
12083
|
-
import { mkdir as mkdir4, open as open4, readFile as readFile4, rename as rename4, stat as
|
|
12734
|
+
import { mkdir as mkdir4, open as open4, readFile as readFile4, rename as rename4, stat as stat4, unlink as unlink4 } from "fs/promises";
|
|
12084
12735
|
import * as path7 from "path";
|
|
12085
12736
|
var FileLockTimeoutError = class extends Error {
|
|
12086
12737
|
constructor(lockPath, timeoutMillis) {
|
|
@@ -12145,7 +12796,7 @@ var isStale = async (lockPath, clock, staleMillis) => {
|
|
|
12145
12796
|
} catch {
|
|
12146
12797
|
}
|
|
12147
12798
|
try {
|
|
12148
|
-
const stats = await
|
|
12799
|
+
const stats = await stat4(lockPath);
|
|
12149
12800
|
return { stale: clock.now() - stats.mtimeMs > staleMillis };
|
|
12150
12801
|
} catch (thrown) {
|
|
12151
12802
|
return { stale: !isErrnoException4(thrown, "ENOENT") };
|
|
@@ -12571,6 +13222,7 @@ export {
|
|
|
12571
13222
|
CURSOR_UNMODELLED_HOOK_EVENT_NAMES,
|
|
12572
13223
|
CURSOR_UNREGISTERED_HOOK_EVENTS,
|
|
12573
13224
|
DEFAULT_CONFIG,
|
|
13225
|
+
DEFAULT_DESTINATION_NAME,
|
|
12574
13226
|
DEFAULT_DETECTION_POLICY,
|
|
12575
13227
|
DEFAULT_DIAGNOSTICS_POLICY,
|
|
12576
13228
|
DEFAULT_DOCUMENT_FORMAT,
|
|
@@ -12583,11 +13235,13 @@ export {
|
|
|
12583
13235
|
DEFAULT_PRIVACY_POLICY,
|
|
12584
13236
|
DEFAULT_SECRET_KEY_PATTERNS,
|
|
12585
13237
|
DEFAULT_SECRET_VALUE_PATTERNS,
|
|
13238
|
+
DEFAULT_SPOOL_POLICY,
|
|
12586
13239
|
DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS,
|
|
12587
13240
|
DEFAULT_WORKTREE_CACHE_TTL_MILLIS,
|
|
12588
13241
|
DELIVERY_COMPONENT_PATTERN,
|
|
12589
13242
|
DELIVERY_GAP_REASON_PATTERN,
|
|
12590
13243
|
DELIVERY_IDENTIFIER_SUMMARY,
|
|
13244
|
+
DESTINATION_NAME_PATTERN,
|
|
12591
13245
|
DETECTION_CONFIDENCE_RANK,
|
|
12592
13246
|
EMPTY_DELTA_USAGE,
|
|
12593
13247
|
EMPTY_EXTENSIONS,
|
|
@@ -12600,6 +13254,7 @@ export {
|
|
|
12600
13254
|
GEMINI_ADAPTER_VERSION,
|
|
12601
13255
|
GEMINI_HOOK_EVENT_NAMES,
|
|
12602
13256
|
GEMINI_PROVIDER_ID,
|
|
13257
|
+
HEADER_ENV_REFERENCE_PREFIX,
|
|
12603
13258
|
LOG_LEVEL_RANK,
|
|
12604
13259
|
LOG_MAPPING_VERSION,
|
|
12605
13260
|
LOG_SIGNALS,
|
|
@@ -12610,6 +13265,8 @@ export {
|
|
|
12610
13265
|
MAX_ATTRIBUTE_STRING_LENGTH,
|
|
12611
13266
|
MAX_DELIVERY_COMPONENTS,
|
|
12612
13267
|
MAX_DELIVERY_GAPS,
|
|
13268
|
+
MAX_DESTINATION_HEADERS,
|
|
13269
|
+
MAX_EXPORT_DESTINATIONS,
|
|
12613
13270
|
MAX_EXTENSION_ENTRIES,
|
|
12614
13271
|
MAX_IDENTIFIER_LENGTH,
|
|
12615
13272
|
MAX_LOG_BODY_CHARACTERS,
|
|
@@ -12690,9 +13347,11 @@ export {
|
|
|
12690
13347
|
createCodexAdapter,
|
|
12691
13348
|
createCursorAdapter,
|
|
12692
13349
|
createDefaultProviderRegistry,
|
|
13350
|
+
createDestinationFanout,
|
|
12693
13351
|
createDeterministicIdGenerator,
|
|
12694
13352
|
createErrorInfo,
|
|
12695
13353
|
createEventFactory,
|
|
13354
|
+
createExportDestinationSinks,
|
|
12696
13355
|
createFileDurableLogSpool,
|
|
12697
13356
|
createFileDurableSpool,
|
|
12698
13357
|
createFilesystemStateStore,
|
|
@@ -12726,6 +13385,7 @@ export {
|
|
|
12726
13385
|
deriveWorkspaceIdentity,
|
|
12727
13386
|
describeAdapter,
|
|
12728
13387
|
describeErrorCode,
|
|
13388
|
+
describeExportDestinations,
|
|
12729
13389
|
describeLogsDeliverability,
|
|
12730
13390
|
describeOtlpHeaderNames,
|
|
12731
13391
|
describeProviderCatalog,
|
|
@@ -12737,7 +13397,9 @@ export {
|
|
|
12737
13397
|
detectionPolicySchema,
|
|
12738
13398
|
diagnosticsPolicySchema,
|
|
12739
13399
|
durationMillisSchema,
|
|
13400
|
+
effectiveSpoolPolicy,
|
|
12740
13401
|
emptyExtensions,
|
|
13402
|
+
endpointOrigin,
|
|
12741
13403
|
epochMillisSchema,
|
|
12742
13404
|
errorInfoFromThrown,
|
|
12743
13405
|
errorPhaseSchema,
|
|
@@ -12745,6 +13407,10 @@ export {
|
|
|
12745
13407
|
errorSeveritySchema,
|
|
12746
13408
|
eventIdSchema,
|
|
12747
13409
|
eventUsage,
|
|
13410
|
+
exportDestinationSchema,
|
|
13411
|
+
exportDestinationsSchema,
|
|
13412
|
+
exportSignalSchema,
|
|
13413
|
+
exporterPolicyForDestination,
|
|
12748
13414
|
exporterPolicySchema,
|
|
12749
13415
|
extensionKeyNamespace,
|
|
12750
13416
|
extensionsSchema,
|
|
@@ -12755,6 +13421,7 @@ export {
|
|
|
12755
13421
|
findRegistrationSupport,
|
|
12756
13422
|
generationEndEventSchema,
|
|
12757
13423
|
generationStartEventSchema,
|
|
13424
|
+
hasConfiguredDestinations,
|
|
12758
13425
|
hostDeliveryIdentity,
|
|
12759
13426
|
identityClaimFieldsSchema,
|
|
12760
13427
|
identityClaimSchema,
|
|
@@ -12765,6 +13432,7 @@ export {
|
|
|
12765
13432
|
isExperimentalProvider,
|
|
12766
13433
|
isLockingStateStore,
|
|
12767
13434
|
isOtelHookError,
|
|
13435
|
+
isPermanentExportFailure,
|
|
12768
13436
|
isReservedExtensionNamespace,
|
|
12769
13437
|
isReservedResourceAttributeKey,
|
|
12770
13438
|
isSecretResourceAttributeKey,
|
|
@@ -12801,6 +13469,7 @@ export {
|
|
|
12801
13469
|
parseEnvironmentConfig,
|
|
12802
13470
|
parseGitDirFile,
|
|
12803
13471
|
parseHeadBranch,
|
|
13472
|
+
parseHeaderValueReference,
|
|
12804
13473
|
parseOtlpHeadersValue,
|
|
12805
13474
|
parseResourceAttributesValue,
|
|
12806
13475
|
planProviderRegistration,
|
|
@@ -12833,7 +13502,9 @@ export {
|
|
|
12833
13502
|
renderJsonDocument,
|
|
12834
13503
|
resolveConfig,
|
|
12835
13504
|
resolveDeliveryIdentity,
|
|
13505
|
+
resolveDestinationHeaders,
|
|
12836
13506
|
resolveEventTargets,
|
|
13507
|
+
resolveExportDestinations,
|
|
12837
13508
|
resolveInstallPath,
|
|
12838
13509
|
resolveInvocationIdentity,
|
|
12839
13510
|
resolveLogsEndpoint,
|
|
@@ -12853,6 +13524,8 @@ export {
|
|
|
12853
13524
|
sourceProvenanceSchema,
|
|
12854
13525
|
sourceTransportSchema,
|
|
12855
13526
|
spanScopeRefOf,
|
|
13527
|
+
spoolPolicySchema,
|
|
13528
|
+
spoolQueueNamesFor,
|
|
12856
13529
|
startOnlySpanAttributes,
|
|
12857
13530
|
stateRecordSchema,
|
|
12858
13531
|
stateValueSchema,
|