@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/cli.js
CHANGED
|
@@ -835,7 +835,9 @@ Delivery deduplication (at most once per callback, across process restarts):
|
|
|
835
835
|
deduplicate only against --callback-id
|
|
836
836
|
|
|
837
837
|
Exporter and runtime policy (never identity):
|
|
838
|
-
--config-file <path> JSON configuration patch
|
|
838
|
+
--config-file <path> JSON configuration patch; "exporter.destinations"
|
|
839
|
+
sends to several OTLP endpoints in parallel, each
|
|
840
|
+
with its own spool (header values may be "env:NAME")
|
|
839
841
|
--endpoint <url> OTLP HTTP/protobuf traces endpoint
|
|
840
842
|
--protocol <p> http/protobuf | http/json | none
|
|
841
843
|
--service-name <name> --service-namespace <ns>
|
|
@@ -876,7 +878,9 @@ Registration lifecycle (setup / diagnose / uninstall):
|
|
|
876
878
|
documented path; required for a provider whose
|
|
877
879
|
planner is verified but whose path is not
|
|
878
880
|
--hook-command <cmd> command to register
|
|
879
|
-
(default "otel-hook run --provider <id>")
|
|
881
|
+
(default "otel-hook run --provider <id>"); add
|
|
882
|
+
--config-file <path> to it to use a config file,
|
|
883
|
+
e.g. one with several export destinations
|
|
880
884
|
--event <name> register only these events; repeatable
|
|
881
885
|
--matcher <m> matcher for a newly created hook group
|
|
882
886
|
--timeout-seconds <n> per-hook timeout written into the config
|
|
@@ -1177,6 +1181,12 @@ var otlpSignalEndpointFromBase = (base, signal) => {
|
|
|
1177
1181
|
return `${trimmed}${signal === "traces" ? OTLP_TRACES_PATH : OTLP_LOGS_PATH}`;
|
|
1178
1182
|
};
|
|
1179
1183
|
|
|
1184
|
+
// src/config/header-value.ts
|
|
1185
|
+
var isUnsafeHeaderValue = (value) => [...value].some((char) => {
|
|
1186
|
+
const code = char.codePointAt(0) ?? 0;
|
|
1187
|
+
return code < 32 && code !== 9 || code === 127 || code > 255;
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1180
1190
|
// src/config/otlp-headers.ts
|
|
1181
1191
|
var MAX_OTLP_HEADERS = 32;
|
|
1182
1192
|
var OTLP_HEADER_VARIABLES = Object.freeze({
|
|
@@ -1185,10 +1195,6 @@ var OTLP_HEADER_VARIABLES = Object.freeze({
|
|
|
1185
1195
|
logs: "OTEL_EXPORTER_OTLP_LOGS_HEADERS"
|
|
1186
1196
|
});
|
|
1187
1197
|
var HEADER_NAME_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
1188
|
-
var isUnsafeHeaderValue = (value) => [...value].some((char) => {
|
|
1189
|
-
const code = char.codePointAt(0) ?? 0;
|
|
1190
|
-
return code < 32 && code !== 9 || code === 127 || code > 255;
|
|
1191
|
-
});
|
|
1192
1198
|
var decode = (raw) => {
|
|
1193
1199
|
try {
|
|
1194
1200
|
return decodeURIComponent(raw);
|
|
@@ -1516,40 +1522,237 @@ var parseEnvironmentConfig = (env) => {
|
|
|
1516
1522
|
};
|
|
1517
1523
|
|
|
1518
1524
|
// src/config/resolve.ts
|
|
1519
|
-
import { z as
|
|
1525
|
+
import { z as z8 } from "zod";
|
|
1520
1526
|
|
|
1521
|
-
// src/config/
|
|
1527
|
+
// src/config/destinations.ts
|
|
1522
1528
|
import { z as z6 } from "zod";
|
|
1523
|
-
var
|
|
1524
|
-
|
|
1529
|
+
var DEFAULT_DESTINATION_NAME = "default";
|
|
1530
|
+
var DESTINATION_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
1531
|
+
var MAX_EXPORT_DESTINATIONS = 16;
|
|
1532
|
+
var MAX_DESTINATION_HEADERS = MAX_OTLP_HEADERS;
|
|
1533
|
+
var HEADER_ENV_REFERENCE_PREFIX = "env:";
|
|
1534
|
+
var HEADER_NAME_PATTERN2 = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;
|
|
1535
|
+
var ENV_VARIABLE_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
1536
|
+
var MAX_HEADER_VALUE_LENGTH = 8192;
|
|
1537
|
+
var exportSignalSchema = z6.enum(["traces", "logs"]);
|
|
1538
|
+
var headerValueSchema = z6.string().min(1).max(MAX_HEADER_VALUE_LENGTH).refine(
|
|
1539
|
+
(value) => !isUnsafeHeaderValue(value),
|
|
1540
|
+
"header values may not contain line breaks, control characters, or characters beyond Latin-1"
|
|
1541
|
+
).refine(
|
|
1542
|
+
(value) => !value.startsWith(HEADER_ENV_REFERENCE_PREFIX) || ENV_VARIABLE_NAME_PATTERN.test(value.slice(HEADER_ENV_REFERENCE_PREFIX.length)),
|
|
1543
|
+
"an env: header reference must name an environment variable, e.g. env:COLLECTOR_TOKEN"
|
|
1544
|
+
);
|
|
1545
|
+
var endpointSchema = z6.string().url().max(2048);
|
|
1546
|
+
var exportDestinationSchema = z6.strictObject({
|
|
1547
|
+
/** Unique, lowercase, filesystem-safe. `default` is reserved for the single-endpoint settings. */
|
|
1548
|
+
name: z6.string().regex(DESTINATION_NAME_PATTERN, "destination names are lowercase letters, digits, _ and -"),
|
|
1549
|
+
/** Default true. A disabled destination is neither sent to nor drained. */
|
|
1550
|
+
enabled: z6.boolean().optional(),
|
|
1551
|
+
/**
|
|
1552
|
+
* Traces URL, with the same meaning as `exporter.endpoint`: the logs URL is
|
|
1553
|
+
* derived from it (`/v1/traces` becomes `/v1/logs`) unless `logsEndpoint` is set.
|
|
1554
|
+
*/
|
|
1555
|
+
endpoint: endpointSchema.optional(),
|
|
1556
|
+
/** Per-signal override of `endpoint` for traces. */
|
|
1557
|
+
tracesEndpoint: endpointSchema.optional(),
|
|
1558
|
+
/** Per-signal override of the derived logs URL. */
|
|
1559
|
+
logsEndpoint: endpointSchema.optional(),
|
|
1560
|
+
/** Defaults to `exporter.protocol`. */
|
|
1561
|
+
protocol: z6.enum(["http/protobuf", "http/json", "none"]).optional(),
|
|
1562
|
+
/**
|
|
1563
|
+
* Header name to value. A value of the form `env:NAME` is read from that
|
|
1564
|
+
* environment variable at send time, so a credential never has to be written
|
|
1565
|
+
* into the file. Values never appear in a snapshot, a diagnostic, or `doctor`.
|
|
1566
|
+
*/
|
|
1567
|
+
headers: z6.record(z6.string().regex(HEADER_NAME_PATTERN2, "not a valid header name"), headerValueSchema).refine(
|
|
1568
|
+
(headers) => Object.keys(headers).length <= MAX_DESTINATION_HEADERS,
|
|
1569
|
+
`at most ${String(MAX_DESTINATION_HEADERS)} headers per destination`
|
|
1570
|
+
).optional(),
|
|
1571
|
+
/**
|
|
1572
|
+
* Which signals this destination receives. Default: both. The logs signal is
|
|
1573
|
+
* still governed by `exporter.logs.enabled`, which stays the one opt-in for a
|
|
1574
|
+
* second stream leaving the host.
|
|
1575
|
+
*/
|
|
1576
|
+
signals: z6.array(exportSignalSchema).min(1).max(2).readonly().optional()
|
|
1577
|
+
}).refine(
|
|
1578
|
+
(destination) => destination.endpoint !== void 0 || destination.tracesEndpoint !== void 0 || destination.logsEndpoint !== void 0,
|
|
1579
|
+
"a destination needs an endpoint, or a tracesEndpoint / logsEndpoint"
|
|
1580
|
+
);
|
|
1581
|
+
var exportDestinationsSchema = z6.array(exportDestinationSchema).max(MAX_EXPORT_DESTINATIONS).readonly().superRefine((destinations, context) => {
|
|
1582
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1583
|
+
destinations.forEach((destination, index) => {
|
|
1584
|
+
if (destination.name === DEFAULT_DESTINATION_NAME) {
|
|
1585
|
+
context.addIssue({
|
|
1586
|
+
code: "custom",
|
|
1587
|
+
path: [index, "name"],
|
|
1588
|
+
message: 'the name "default" is reserved for exporter.endpoint and the OTEL_EXPORTER_OTLP_* variables'
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
if (seen.has(destination.name)) {
|
|
1592
|
+
context.addIssue({
|
|
1593
|
+
code: "custom",
|
|
1594
|
+
path: [index, "name"],
|
|
1595
|
+
message: `duplicate destination name "${destination.name}"`
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
seen.add(destination.name);
|
|
1599
|
+
});
|
|
1600
|
+
});
|
|
1601
|
+
var spoolPolicySchema = z6.strictObject({
|
|
1602
|
+
/** Total bytes of queued batches. Default 16 MiB. */
|
|
1603
|
+
maxBytes: z6.number().int().min(1024).max(1073741824),
|
|
1604
|
+
/** A batch older than this is dropped instead of sent. Default 72 hours. */
|
|
1605
|
+
maxAgeMillis: z6.number().int().min(1e3).max(30 * 24 * 60 * 60 * 1e3),
|
|
1606
|
+
/** Number of queued batches. Default 500. */
|
|
1607
|
+
maxBatches: z6.number().int().min(1).max(65536)
|
|
1608
|
+
});
|
|
1609
|
+
var DEFAULT_SPOOL_POLICY = Object.freeze({
|
|
1610
|
+
maxBytes: 16 * 1024 * 1024,
|
|
1611
|
+
maxAgeMillis: 72 * 60 * 60 * 1e3,
|
|
1612
|
+
maxBatches: 500
|
|
1613
|
+
});
|
|
1614
|
+
var effectiveSpoolPolicy = (exporter) => ({
|
|
1615
|
+
maxBytes: exporter.spool?.maxBytes ?? DEFAULT_SPOOL_POLICY.maxBytes,
|
|
1616
|
+
maxAgeMillis: exporter.spool?.maxAgeMillis ?? DEFAULT_SPOOL_POLICY.maxAgeMillis,
|
|
1617
|
+
maxBatches: exporter.spool?.maxBatches ?? DEFAULT_SPOOL_POLICY.maxBatches
|
|
1618
|
+
});
|
|
1619
|
+
var legacyDestination = (exporter) => ({
|
|
1620
|
+
name: DEFAULT_DESTINATION_NAME,
|
|
1621
|
+
source: "exporter",
|
|
1622
|
+
protocol: exporter.protocol,
|
|
1623
|
+
...exporter.endpoint === void 0 ? {} : { endpoint: exporter.endpoint },
|
|
1624
|
+
...exporter.logs.endpoint === void 0 ? {} : { logsEndpoint: exporter.logs.endpoint },
|
|
1625
|
+
signals: { traces: true, logs: exporter.logs.enabled },
|
|
1626
|
+
headers: {}
|
|
1627
|
+
});
|
|
1628
|
+
var hasConfiguredDestinations = (exporter) => exporter.destinations !== void 0 && exporter.destinations.length > 0;
|
|
1629
|
+
var resolveExportDestinations = (exporter) => {
|
|
1630
|
+
if (!hasConfiguredDestinations(exporter)) {
|
|
1631
|
+
return [legacyDestination(exporter)];
|
|
1632
|
+
}
|
|
1633
|
+
const resolved = [];
|
|
1634
|
+
if (exporter.endpoint !== void 0 || exporter.logs.endpoint !== void 0) {
|
|
1635
|
+
resolved.push(legacyDestination(exporter));
|
|
1636
|
+
}
|
|
1637
|
+
for (const destination of exporter.destinations ?? []) {
|
|
1638
|
+
if (destination.enabled === false) {
|
|
1639
|
+
continue;
|
|
1640
|
+
}
|
|
1641
|
+
const signals = destination.signals ?? exportSignalSchema.options;
|
|
1642
|
+
resolved.push({
|
|
1643
|
+
name: destination.name,
|
|
1644
|
+
source: "destinations",
|
|
1645
|
+
protocol: destination.protocol ?? exporter.protocol,
|
|
1646
|
+
...destination.endpoint === void 0 ? {} : { endpoint: destination.endpoint },
|
|
1647
|
+
...destination.tracesEndpoint === void 0 ? {} : { tracesEndpoint: destination.tracesEndpoint },
|
|
1648
|
+
...destination.logsEndpoint === void 0 ? {} : { logsEndpoint: destination.logsEndpoint },
|
|
1649
|
+
signals: {
|
|
1650
|
+
traces: signals.includes("traces"),
|
|
1651
|
+
logs: exporter.logs.enabled && signals.includes("logs")
|
|
1652
|
+
},
|
|
1653
|
+
headers: { ...destination.headers ?? {} }
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
return resolved;
|
|
1657
|
+
};
|
|
1658
|
+
var parseHeaderValueReference = (value) => value.startsWith(HEADER_ENV_REFERENCE_PREFIX) ? { kind: "env", variable: value.slice(HEADER_ENV_REFERENCE_PREFIX.length) } : { kind: "literal" };
|
|
1659
|
+
var resolveDestinationHeaders = (headers, environment) => {
|
|
1660
|
+
const values = {};
|
|
1661
|
+
const missing = [];
|
|
1662
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
1663
|
+
const reference = parseHeaderValueReference(value);
|
|
1664
|
+
if (reference.kind === "literal") {
|
|
1665
|
+
values[name] = value;
|
|
1666
|
+
continue;
|
|
1667
|
+
}
|
|
1668
|
+
const resolved = environment?.[reference.variable];
|
|
1669
|
+
if (resolved === void 0 || resolved === "") {
|
|
1670
|
+
missing.push(reference.variable);
|
|
1671
|
+
continue;
|
|
1672
|
+
}
|
|
1673
|
+
values[name] = resolved;
|
|
1674
|
+
}
|
|
1675
|
+
return { values, missingVariables: [...new Set(missing)].sort() };
|
|
1676
|
+
};
|
|
1677
|
+
var endpointOrigin = (endpoint) => {
|
|
1678
|
+
if (endpoint === void 0) {
|
|
1679
|
+
return void 0;
|
|
1680
|
+
}
|
|
1681
|
+
try {
|
|
1682
|
+
return new URL(endpoint).origin;
|
|
1683
|
+
} catch {
|
|
1684
|
+
return "<unparsable>";
|
|
1685
|
+
}
|
|
1686
|
+
};
|
|
1687
|
+
var describeExportDestinations = (exporter) => {
|
|
1688
|
+
const describe = (destination, enabled2) => {
|
|
1689
|
+
const tracesOrigin = endpointOrigin(destination.tracesEndpoint ?? destination.endpoint);
|
|
1690
|
+
const logsOrigin = endpointOrigin(
|
|
1691
|
+
destination.logsEndpoint ?? destination.endpoint ?? destination.tracesEndpoint
|
|
1692
|
+
);
|
|
1693
|
+
const variables = Object.values(destination.headers).map(parseHeaderValueReference).flatMap((reference) => reference.kind === "env" ? [reference.variable] : []);
|
|
1694
|
+
return {
|
|
1695
|
+
name: destination.name,
|
|
1696
|
+
enabled: enabled2,
|
|
1697
|
+
protocol: destination.protocol,
|
|
1698
|
+
signals: exportSignalSchema.options.filter((signal) => destination.signals[signal]),
|
|
1699
|
+
...tracesOrigin === void 0 || !destination.signals.traces ? {} : { tracesEndpointOrigin: tracesOrigin },
|
|
1700
|
+
...logsOrigin === void 0 || !destination.signals.logs ? {} : { logsEndpointOrigin: logsOrigin },
|
|
1701
|
+
headerNames: destination.source === "exporter" ? [...exporter.headerNames].sort() : Object.keys(destination.headers).sort(),
|
|
1702
|
+
headerVariables: [...new Set(variables)].sort()
|
|
1703
|
+
};
|
|
1704
|
+
};
|
|
1705
|
+
const enabled = resolveExportDestinations(exporter).map(
|
|
1706
|
+
(destination) => describe(destination, true)
|
|
1707
|
+
);
|
|
1708
|
+
const disabled = (exporter.destinations ?? []).filter((destination) => destination.enabled === false).map(
|
|
1709
|
+
(destination) => describe(
|
|
1710
|
+
{
|
|
1711
|
+
name: destination.name,
|
|
1712
|
+
source: "destinations",
|
|
1713
|
+
protocol: destination.protocol ?? exporter.protocol,
|
|
1714
|
+
...destination.endpoint === void 0 ? {} : { endpoint: destination.endpoint },
|
|
1715
|
+
signals: { traces: false, logs: false },
|
|
1716
|
+
headers: { ...destination.headers ?? {} }
|
|
1717
|
+
},
|
|
1718
|
+
false
|
|
1719
|
+
)
|
|
1720
|
+
);
|
|
1721
|
+
return [...enabled, ...disabled];
|
|
1722
|
+
};
|
|
1723
|
+
|
|
1724
|
+
// src/config/schema.ts
|
|
1725
|
+
import { z as z7 } from "zod";
|
|
1726
|
+
var logsPolicySchema = z7.strictObject({
|
|
1727
|
+
enabled: z7.boolean(),
|
|
1525
1728
|
/**
|
|
1526
1729
|
* Full URL for the logs signal.
|
|
1527
1730
|
*
|
|
1528
1731
|
* Absent, it is derived from `endpoint`: a trailing `/v1/traces` becomes
|
|
1529
1732
|
* `/v1/logs`, and an endpoint with no signal path has `/v1/logs` appended.
|
|
1530
1733
|
*/
|
|
1531
|
-
endpoint:
|
|
1532
|
-
includeContent:
|
|
1533
|
-
maxBatchSize:
|
|
1734
|
+
endpoint: z7.string().url().max(2048).optional(),
|
|
1735
|
+
includeContent: z7.boolean(),
|
|
1736
|
+
maxBatchSize: z7.number().int().min(1).max(4096)
|
|
1534
1737
|
});
|
|
1535
1738
|
var DEFAULT_LOGS_POLICY = Object.freeze({
|
|
1536
1739
|
enabled: false,
|
|
1537
1740
|
includeContent: false,
|
|
1538
1741
|
maxBatchSize: 128
|
|
1539
1742
|
});
|
|
1540
|
-
var exporterPolicySchema =
|
|
1541
|
-
enabled:
|
|
1542
|
-
protocol:
|
|
1543
|
-
endpoint:
|
|
1743
|
+
var exporterPolicySchema = z7.strictObject({
|
|
1744
|
+
enabled: z7.boolean(),
|
|
1745
|
+
protocol: z7.enum(["http/protobuf", "http/json", "none"]),
|
|
1746
|
+
endpoint: z7.string().url().max(2048).optional(),
|
|
1544
1747
|
/**
|
|
1545
1748
|
* Header names only. Values are supplied separately at construction time and
|
|
1546
1749
|
* are never part of a resolved-config snapshot, which is logged and exported.
|
|
1547
1750
|
*/
|
|
1548
|
-
headerNames:
|
|
1549
|
-
timeoutMillis:
|
|
1550
|
-
maxBatchSize:
|
|
1551
|
-
maxQueueSize:
|
|
1552
|
-
maxRetryAttempts:
|
|
1751
|
+
headerNames: z7.array(nonEmptyStringSchema).max(32).readonly(),
|
|
1752
|
+
timeoutMillis: z7.number().int().min(1).max(6e5),
|
|
1753
|
+
maxBatchSize: z7.number().int().min(1).max(4096),
|
|
1754
|
+
maxQueueSize: z7.number().int().min(1).max(65536),
|
|
1755
|
+
maxRetryAttempts: z7.number().int().min(0).max(10),
|
|
1553
1756
|
serviceName: nonEmptyStringSchema,
|
|
1554
1757
|
serviceNamespace: nonEmptyStringSchema.optional(),
|
|
1555
1758
|
/**
|
|
@@ -1566,32 +1769,52 @@ var exporterPolicySchema = z6.strictObject({
|
|
|
1566
1769
|
* headers, timeout, protocol, service identity, and resource attributes above —
|
|
1567
1770
|
* a second top-level section would invite two of each to drift apart.
|
|
1568
1771
|
*/
|
|
1569
|
-
logs: logsPolicySchema
|
|
1772
|
+
logs: logsPolicySchema,
|
|
1773
|
+
/**
|
|
1774
|
+
* Additional OTLP destinations, each sent every batch in parallel.
|
|
1775
|
+
*
|
|
1776
|
+
* Absent (the default), the exporter has exactly one destination — the
|
|
1777
|
+
* single-endpoint settings above, named `default` — and behaves exactly as it
|
|
1778
|
+
* did before this list existed. See `destinations.ts`.
|
|
1779
|
+
*
|
|
1780
|
+
* Merged as one leaf: a higher layer that sets the list replaces it whole,
|
|
1781
|
+
* because "the union of two partial lists" has no answer an operator could
|
|
1782
|
+
* predict.
|
|
1783
|
+
*/
|
|
1784
|
+
destinations: exportDestinationsSchema.optional(),
|
|
1785
|
+
/**
|
|
1786
|
+
* Per-destination retry spool bounds, each optional and merged per leaf; any
|
|
1787
|
+
* bound left unset takes its value from `DEFAULT_SPOOL_POLICY`.
|
|
1788
|
+
*/
|
|
1789
|
+
spool: spoolPolicySchema.partial().optional()
|
|
1570
1790
|
});
|
|
1571
|
-
var detectionPolicySchema =
|
|
1791
|
+
var detectionPolicySchema = z7.strictObject({
|
|
1572
1792
|
/** Detections below this confidence resolve to the unknown provider. */
|
|
1573
1793
|
minimumConfidence: detectionConfidenceSchema,
|
|
1574
1794
|
/** When false, an ambiguous detection is an error rather than unknown. */
|
|
1575
|
-
allowAmbiguousFallback:
|
|
1795
|
+
allowAmbiguousFallback: z7.boolean(),
|
|
1576
1796
|
/** Optional allow-list of provider ids; empty means "any registered". */
|
|
1577
|
-
allowedProviderIds:
|
|
1797
|
+
allowedProviderIds: z7.array(nonEmptyStringSchema).max(32).readonly()
|
|
1578
1798
|
});
|
|
1579
|
-
var diagnosticsPolicySchema =
|
|
1580
|
-
logLevel:
|
|
1799
|
+
var diagnosticsPolicySchema = z7.strictObject({
|
|
1800
|
+
logLevel: z7.enum(["silent", "error", "warn", "info", "debug"]),
|
|
1581
1801
|
/** Emit `error.raised` events for contained failures. */
|
|
1582
|
-
emitErrorEvents:
|
|
1802
|
+
emitErrorEvents: z7.boolean()
|
|
1583
1803
|
});
|
|
1584
|
-
var otelHookConfigSchema =
|
|
1804
|
+
var otelHookConfigSchema = z7.strictObject({
|
|
1585
1805
|
exporter: exporterPolicySchema,
|
|
1586
1806
|
privacy: privacyPolicySchema,
|
|
1587
1807
|
detection: detectionPolicySchema,
|
|
1588
1808
|
diagnostics: diagnosticsPolicySchema
|
|
1589
1809
|
});
|
|
1590
|
-
var otelHookConfigPatchSchema =
|
|
1810
|
+
var otelHookConfigPatchSchema = z7.strictObject({
|
|
1591
1811
|
// `logs` is unwrapped and re-partialled for the same reason `privacy.limits` is:
|
|
1592
1812
|
// merging happens per leaf, so a layer must be able to set `logs.enabled` alone
|
|
1593
1813
|
// without also restating the endpoint and the batch size.
|
|
1594
|
-
exporter: exporterPolicySchema.omit({ logs: true }).partial().extend({
|
|
1814
|
+
exporter: exporterPolicySchema.omit({ logs: true, spool: true }).partial().extend({
|
|
1815
|
+
logs: logsPolicySchema.partial().optional(),
|
|
1816
|
+
spool: spoolPolicySchema.partial().optional()
|
|
1817
|
+
}).optional(),
|
|
1595
1818
|
privacy: privacyPolicySchema.omit({ limits: true }).partial().extend({ limits: privacyPolicySchema.shape.limits.partial().optional() }).optional(),
|
|
1596
1819
|
detection: detectionPolicySchema.partial().optional(),
|
|
1597
1820
|
diagnostics: diagnosticsPolicySchema.partial().optional()
|
|
@@ -1626,17 +1849,17 @@ var DEFAULT_CONFIG = Object.freeze({
|
|
|
1626
1849
|
|
|
1627
1850
|
// src/config/resolve.ts
|
|
1628
1851
|
var CONFIG_SOURCE_PRECEDENCE = ["defaults", "file", "environment", "inline-override"];
|
|
1629
|
-
var configSourceSchema =
|
|
1852
|
+
var configSourceSchema = z8.enum(CONFIG_SOURCE_PRECEDENCE);
|
|
1630
1853
|
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1631
|
-
var mergeLeaf = (target, patch, source, provenance,
|
|
1854
|
+
var mergeLeaf = (target, patch, source, provenance, path13) => {
|
|
1632
1855
|
for (const [key, value] of Object.entries(patch)) {
|
|
1633
1856
|
if (value === void 0) {
|
|
1634
1857
|
continue;
|
|
1635
1858
|
}
|
|
1636
|
-
const childPath =
|
|
1859
|
+
const childPath = path13 === "" ? key : `${path13}.${key}`;
|
|
1637
1860
|
const existing = target[key];
|
|
1638
|
-
if (isPlainObject(value) && isPlainObject(existing)) {
|
|
1639
|
-
const child = { ...existing };
|
|
1861
|
+
if (isPlainObject(value) && (isPlainObject(existing) || existing === void 0)) {
|
|
1862
|
+
const child = { ...existing ?? {} };
|
|
1640
1863
|
mergeLeaf(child, value, source, provenance, childPath);
|
|
1641
1864
|
target[key] = child;
|
|
1642
1865
|
continue;
|
|
@@ -1647,14 +1870,14 @@ var mergeLeaf = (target, patch, source, provenance, path12) => {
|
|
|
1647
1870
|
};
|
|
1648
1871
|
var initialProvenance = (config) => {
|
|
1649
1872
|
const provenance = {};
|
|
1650
|
-
const walk = (value,
|
|
1873
|
+
const walk = (value, path13) => {
|
|
1651
1874
|
if (isPlainObject(value)) {
|
|
1652
1875
|
for (const [key, child] of Object.entries(value)) {
|
|
1653
|
-
walk(child,
|
|
1876
|
+
walk(child, path13 === "" ? key : `${path13}.${key}`);
|
|
1654
1877
|
}
|
|
1655
1878
|
return;
|
|
1656
1879
|
}
|
|
1657
|
-
provenance[
|
|
1880
|
+
provenance[path13] = "defaults";
|
|
1658
1881
|
};
|
|
1659
1882
|
walk(config, "");
|
|
1660
1883
|
return provenance;
|
|
@@ -1708,10 +1931,27 @@ var resolveConfig = (layers = []) => {
|
|
|
1708
1931
|
if (parsed.data.privacy.contentMode === "raw" && !parsed.data.privacy.allowRawContent) {
|
|
1709
1932
|
notes.push("privacy.contentMode=raw will be downgraded to omit: allowRawContent is false");
|
|
1710
1933
|
}
|
|
1711
|
-
|
|
1934
|
+
const withDestinations = hasConfiguredDestinations(parsed.data.exporter);
|
|
1935
|
+
if (parsed.data.exporter.enabled && parsed.data.exporter.protocol !== "none" && parsed.data.exporter.endpoint === void 0 && !withDestinations) {
|
|
1712
1936
|
notes.push("exporter.enabled is true but no endpoint is configured");
|
|
1713
1937
|
}
|
|
1714
|
-
if (
|
|
1938
|
+
if (withDestinations) {
|
|
1939
|
+
const enabled = (parsed.data.exporter.destinations ?? []).filter(
|
|
1940
|
+
(destination) => destination.enabled !== false
|
|
1941
|
+
);
|
|
1942
|
+
if (enabled.length === 0 && parsed.data.exporter.endpoint === void 0) {
|
|
1943
|
+
notes.push("exporter.destinations is set but every destination is disabled");
|
|
1944
|
+
}
|
|
1945
|
+
if (!parsed.data.exporter.logs.enabled) {
|
|
1946
|
+
const askingForLogs = enabled.filter((destination) => destination.signals?.includes("logs") === true).map((destination) => destination.name);
|
|
1947
|
+
if (askingForLogs.length > 0) {
|
|
1948
|
+
notes.push(
|
|
1949
|
+
`destination(s) ${askingForLogs.join(", ")} list the logs signal but exporter.logs.enabled is false, so only traces are sent`
|
|
1950
|
+
);
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
if (!withDestinations && parsed.data.exporter.logs.enabled && parsed.data.exporter.logs.endpoint === void 0 && parsed.data.exporter.endpoint === void 0) {
|
|
1715
1955
|
notes.push(
|
|
1716
1956
|
"exporter.logs.enabled is true but neither a logs endpoint nor a trace endpoint to derive one from is configured"
|
|
1717
1957
|
);
|
|
@@ -1723,6 +1963,35 @@ var resolveConfig = (layers = []) => {
|
|
|
1723
1963
|
}
|
|
1724
1964
|
return { status: "ok", config: parsed.data, provenance, notes };
|
|
1725
1965
|
};
|
|
1966
|
+
var describeDestinationAttributes = (config) => {
|
|
1967
|
+
const attributes = {};
|
|
1968
|
+
if (config.exporter.spool !== void 0 || hasConfiguredDestinations(config.exporter)) {
|
|
1969
|
+
const spool = effectiveSpoolPolicy(config.exporter);
|
|
1970
|
+
attributes["exporter.spool_max_bytes"] = spool.maxBytes;
|
|
1971
|
+
attributes["exporter.spool_max_age_millis"] = spool.maxAgeMillis;
|
|
1972
|
+
attributes["exporter.spool_max_batches"] = spool.maxBatches;
|
|
1973
|
+
}
|
|
1974
|
+
if (!hasConfiguredDestinations(config.exporter)) {
|
|
1975
|
+
return attributes;
|
|
1976
|
+
}
|
|
1977
|
+
const destinations = describeExportDestinations(config.exporter);
|
|
1978
|
+
attributes["exporter.destination_names"] = destinations.map((destination) => destination.name);
|
|
1979
|
+
for (const destination of destinations) {
|
|
1980
|
+
const prefix = `exporter.destination.${destination.name}`;
|
|
1981
|
+
attributes[`${prefix}.enabled`] = destination.enabled;
|
|
1982
|
+
attributes[`${prefix}.protocol`] = destination.protocol;
|
|
1983
|
+
attributes[`${prefix}.signals`] = [...destination.signals];
|
|
1984
|
+
if (destination.tracesEndpointOrigin !== void 0) {
|
|
1985
|
+
attributes[`${prefix}.traces_endpoint_origin`] = destination.tracesEndpointOrigin;
|
|
1986
|
+
}
|
|
1987
|
+
if (destination.logsEndpointOrigin !== void 0) {
|
|
1988
|
+
attributes[`${prefix}.logs_endpoint_origin`] = destination.logsEndpointOrigin;
|
|
1989
|
+
}
|
|
1990
|
+
attributes[`${prefix}.header_names`] = [...destination.headerNames];
|
|
1991
|
+
attributes[`${prefix}.header_variables`] = [...destination.headerVariables];
|
|
1992
|
+
}
|
|
1993
|
+
return attributes;
|
|
1994
|
+
};
|
|
1726
1995
|
var describeResolvedConfig = (config) => {
|
|
1727
1996
|
const originOf = (endpoint) => {
|
|
1728
1997
|
if (endpoint === void 0) {
|
|
@@ -1734,12 +2003,12 @@ var describeResolvedConfig = (config) => {
|
|
|
1734
2003
|
return "<unparsable>";
|
|
1735
2004
|
}
|
|
1736
2005
|
};
|
|
1737
|
-
const
|
|
2006
|
+
const endpointOrigin2 = originOf(config.exporter.endpoint);
|
|
1738
2007
|
const logsEndpointOrigin = originOf(config.exporter.logs.endpoint);
|
|
1739
2008
|
return {
|
|
1740
2009
|
"exporter.enabled": config.exporter.enabled,
|
|
1741
2010
|
"exporter.protocol": config.exporter.protocol,
|
|
1742
|
-
...
|
|
2011
|
+
...endpointOrigin2 === void 0 ? {} : { "exporter.endpoint_origin": endpointOrigin2 },
|
|
1743
2012
|
"exporter.logs_enabled": config.exporter.logs.enabled,
|
|
1744
2013
|
"exporter.logs_include_content": config.exporter.logs.includeContent,
|
|
1745
2014
|
"exporter.logs_max_batch_size": config.exporter.logs.maxBatchSize,
|
|
@@ -1751,6 +2020,7 @@ var describeResolvedConfig = (config) => {
|
|
|
1751
2020
|
"exporter.resource_attribute_names": [
|
|
1752
2021
|
...describeResourceAttributeNames(config.exporter.resourceAttributes)
|
|
1753
2022
|
],
|
|
2023
|
+
...describeDestinationAttributes(config),
|
|
1754
2024
|
"exporter.timeout_millis": config.exporter.timeoutMillis,
|
|
1755
2025
|
"exporter.max_batch_size": config.exporter.maxBatchSize,
|
|
1756
2026
|
"exporter.service_name": config.exporter.serviceName,
|
|
@@ -1769,18 +2039,18 @@ var describeResolvedConfig = (config) => {
|
|
|
1769
2039
|
};
|
|
1770
2040
|
|
|
1771
2041
|
// src/runtime/ports.ts
|
|
1772
|
-
import { z as
|
|
2042
|
+
import { z as z10 } from "zod";
|
|
1773
2043
|
|
|
1774
2044
|
// src/model/usage.ts
|
|
1775
|
-
import { z as
|
|
1776
|
-
var usageTemporalitySchema =
|
|
1777
|
-
var cacheCreationAccountingSchema =
|
|
2045
|
+
import { z as z9 } from "zod";
|
|
2046
|
+
var usageTemporalitySchema = z9.enum(["delta", "cumulative"]);
|
|
2047
|
+
var cacheCreationAccountingSchema = z9.enum([
|
|
1778
2048
|
"included-in-input",
|
|
1779
2049
|
"disjoint-from-input",
|
|
1780
2050
|
"not-reported"
|
|
1781
2051
|
]);
|
|
1782
|
-
var providerTotalAgreementSchema =
|
|
1783
|
-
var usageReportSchema =
|
|
2052
|
+
var providerTotalAgreementSchema = z9.enum(["unreported", "agrees", "disagrees"]);
|
|
2053
|
+
var usageReportSchema = z9.strictObject({
|
|
1784
2054
|
temporality: usageTemporalitySchema,
|
|
1785
2055
|
/** Inclusive input tokens. */
|
|
1786
2056
|
inputTokens: tokenCountSchema.optional(),
|
|
@@ -1797,7 +2067,7 @@ var usageReportSchema = z8.strictObject({
|
|
|
1797
2067
|
/** Total exactly as the provider reported it, if it reported one. */
|
|
1798
2068
|
providerTotalTokens: tokenCountSchema.optional()
|
|
1799
2069
|
});
|
|
1800
|
-
var canonicalUsageSchema =
|
|
2070
|
+
var canonicalUsageSchema = z9.strictObject({
|
|
1801
2071
|
temporality: usageTemporalitySchema,
|
|
1802
2072
|
inputTokens: tokenCountSchema,
|
|
1803
2073
|
cachedInputTokens: tokenCountSchema,
|
|
@@ -1998,14 +2268,14 @@ var toReport = (usage) => ({
|
|
|
1998
2268
|
});
|
|
1999
2269
|
|
|
2000
2270
|
// src/runtime/ports.ts
|
|
2001
|
-
var appliedDeliverySchema =
|
|
2002
|
-
callbackId:
|
|
2271
|
+
var appliedDeliverySchema = z10.strictObject({
|
|
2272
|
+
callbackId: z10.string().regex(/^[A-Za-z0-9_-]{1,128}$/),
|
|
2003
2273
|
/** How many of that delivery's observations are folded in, counted from one. */
|
|
2004
|
-
applications:
|
|
2274
|
+
applications: z10.number().int().min(1).max(4096)
|
|
2005
2275
|
});
|
|
2006
|
-
var stateValueSchema =
|
|
2007
|
-
|
|
2008
|
-
kind:
|
|
2276
|
+
var stateValueSchema = z10.discriminatedUnion("kind", [
|
|
2277
|
+
z10.strictObject({
|
|
2278
|
+
kind: z10.literal("usage-cumulative"),
|
|
2009
2279
|
usage: canonicalUsageSchema,
|
|
2010
2280
|
/**
|
|
2011
2281
|
* Optional: absent on every record written before this field existed, which
|
|
@@ -2014,22 +2284,22 @@ var stateValueSchema = z9.discriminatedUnion("kind", [
|
|
|
2014
2284
|
*/
|
|
2015
2285
|
appliedDelivery: appliedDeliverySchema.optional()
|
|
2016
2286
|
}),
|
|
2017
|
-
|
|
2018
|
-
kind:
|
|
2287
|
+
z10.strictObject({
|
|
2288
|
+
kind: z10.literal("sequence"),
|
|
2019
2289
|
next: sequenceNumberSchema
|
|
2020
2290
|
}),
|
|
2021
|
-
|
|
2022
|
-
kind:
|
|
2291
|
+
z10.strictObject({
|
|
2292
|
+
kind: z10.literal("attributes"),
|
|
2023
2293
|
attributes: attributesSchema
|
|
2024
2294
|
})
|
|
2025
2295
|
]);
|
|
2026
|
-
var stateRecordSchema =
|
|
2296
|
+
var stateRecordSchema = z10.strictObject({
|
|
2027
2297
|
/** Incremented on each write; lets callers detect lost updates. */
|
|
2028
|
-
revision:
|
|
2298
|
+
revision: z10.number().int().min(0),
|
|
2029
2299
|
updatedAt: epochMillisSchema,
|
|
2030
2300
|
value: stateValueSchema
|
|
2031
2301
|
});
|
|
2032
|
-
var logLevelSchema =
|
|
2302
|
+
var logLevelSchema = z10.enum(["silent", "error", "warn", "info", "debug"]);
|
|
2033
2303
|
var LOG_LEVEL_RANK = Object.freeze({
|
|
2034
2304
|
silent: 0,
|
|
2035
2305
|
error: 1,
|
|
@@ -2226,6 +2496,10 @@ var createCliLogger = (io, level) => createStderrLogger({
|
|
|
2226
2496
|
});
|
|
2227
2497
|
var readIdentityFile = readJsonFile;
|
|
2228
2498
|
|
|
2499
|
+
// src/cli/doctor.ts
|
|
2500
|
+
import { readdir as readdir3 } from "fs/promises";
|
|
2501
|
+
import * as path4 from "path";
|
|
2502
|
+
|
|
2229
2503
|
// src/diagnostics/health.ts
|
|
2230
2504
|
var createHealthTracker = (subsystem, options = {}) => {
|
|
2231
2505
|
const unhealthyThreshold = options.unhealthyAfterConsecutiveFailures ?? 3;
|
|
@@ -2259,7 +2533,8 @@ var createHealthTracker = (subsystem, options = {}) => {
|
|
|
2259
2533
|
consecutiveFailures,
|
|
2260
2534
|
...lastSuccessAt === void 0 ? {} : { lastSuccessAt },
|
|
2261
2535
|
...lastFailureAt === void 0 ? {} : { lastFailureAt },
|
|
2262
|
-
...lastErrorCode === void 0 ? {} : { lastErrorCode }
|
|
2536
|
+
...lastErrorCode === void 0 ? {} : { lastErrorCode },
|
|
2537
|
+
...options.destination === void 0 ? {} : { destination: options.destination }
|
|
2263
2538
|
})
|
|
2264
2539
|
};
|
|
2265
2540
|
};
|
|
@@ -2269,15 +2544,15 @@ var summarizeHealth = (snapshots) => ({
|
|
|
2269
2544
|
});
|
|
2270
2545
|
|
|
2271
2546
|
// src/model/version.ts
|
|
2272
|
-
import { z as
|
|
2547
|
+
import { z as z11 } from "zod";
|
|
2273
2548
|
var CANONICAL_SCHEMA_VERSION = 1;
|
|
2274
|
-
var canonicalSchemaVersionSchema =
|
|
2549
|
+
var canonicalSchemaVersionSchema = z11.literal(CANONICAL_SCHEMA_VERSION);
|
|
2275
2550
|
|
|
2276
2551
|
// src/privacy/service.ts
|
|
2277
2552
|
import { createHash } from "crypto";
|
|
2278
2553
|
|
|
2279
2554
|
// src/model/extensions.ts
|
|
2280
|
-
import { z as
|
|
2555
|
+
import { z as z12 } from "zod";
|
|
2281
2556
|
var EXTENSION_KEY_PATTERN = /^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*(?:\.[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*)+$/;
|
|
2282
2557
|
var RESERVED_EXTENSION_NAMESPACES = Object.freeze([
|
|
2283
2558
|
"otelhook",
|
|
@@ -2288,7 +2563,7 @@ var MAX_EXTENSION_ENTRIES = 64;
|
|
|
2288
2563
|
var extensionKeyNamespace = (key) => key.slice(0, key.indexOf("."));
|
|
2289
2564
|
var isReservedExtensionNamespace = (key) => RESERVED_EXTENSION_NAMESPACES.includes(extensionKeyNamespace(key));
|
|
2290
2565
|
var isValidExtensionKey = (key) => EXTENSION_KEY_PATTERN.test(key) && !isReservedExtensionNamespace(key);
|
|
2291
|
-
var extensionsSchema =
|
|
2566
|
+
var extensionsSchema = z12.record(z12.string(), attributeValueSchema).check((ctx) => {
|
|
2292
2567
|
const keys = Object.keys(ctx.value);
|
|
2293
2568
|
if (keys.length > MAX_EXTENSION_ENTRIES) {
|
|
2294
2569
|
ctx.issues.push({
|
|
@@ -2538,11 +2813,11 @@ var createPrivacyService = (policyInput) => {
|
|
|
2538
2813
|
};
|
|
2539
2814
|
const flattenToAttributes = (value, prefix) => {
|
|
2540
2815
|
const attributes = {};
|
|
2541
|
-
const walk = (current,
|
|
2816
|
+
const walk = (current, path13) => {
|
|
2542
2817
|
if (typeof current === "string" || typeof current === "number" || typeof current === "boolean") {
|
|
2543
2818
|
const primitive = toAttributePrimitive(current);
|
|
2544
2819
|
if (primitive !== void 0) {
|
|
2545
|
-
attributes[
|
|
2820
|
+
attributes[path13] = primitive;
|
|
2546
2821
|
}
|
|
2547
2822
|
return;
|
|
2548
2823
|
}
|
|
@@ -2561,16 +2836,16 @@ var createPrivacyService = (policyInput) => {
|
|
|
2561
2836
|
primitives.push(entryPrimitive);
|
|
2562
2837
|
}
|
|
2563
2838
|
if (uniform) {
|
|
2564
|
-
attributes[
|
|
2839
|
+
attributes[path13] = primitives.slice(0, MAX_ATTRIBUTE_ARRAY_LENGTH);
|
|
2565
2840
|
return;
|
|
2566
2841
|
}
|
|
2567
2842
|
for (const [index, entry] of current.entries()) {
|
|
2568
|
-
walk(entry, `${
|
|
2843
|
+
walk(entry, `${path13}.${index}`);
|
|
2569
2844
|
}
|
|
2570
2845
|
return;
|
|
2571
2846
|
}
|
|
2572
2847
|
for (const [key, entry] of Object.entries(current)) {
|
|
2573
|
-
walk(entry,
|
|
2848
|
+
walk(entry, path13 === "" ? key : `${path13}.${key}`);
|
|
2574
2849
|
}
|
|
2575
2850
|
};
|
|
2576
2851
|
walk(value, prefix);
|
|
@@ -2663,15 +2938,15 @@ var createPrivacyService = (policyInput) => {
|
|
|
2663
2938
|
};
|
|
2664
2939
|
|
|
2665
2940
|
// src/model/identity.ts
|
|
2666
|
-
import { z as
|
|
2667
|
-
var workspaceKeySourceSchema =
|
|
2941
|
+
import { z as z13 } from "zod";
|
|
2942
|
+
var workspaceKeySourceSchema = z13.enum([
|
|
2668
2943
|
"git-remote",
|
|
2669
2944
|
"git-root",
|
|
2670
2945
|
"working-directory",
|
|
2671
2946
|
"explicit",
|
|
2672
2947
|
"unknown"
|
|
2673
2948
|
]);
|
|
2674
|
-
var workspaceIdentitySchema =
|
|
2949
|
+
var workspaceIdentitySchema = z13.strictObject({
|
|
2675
2950
|
workspaceId: workspaceIdSchema,
|
|
2676
2951
|
keySource: workspaceKeySourceSchema,
|
|
2677
2952
|
/** Repository name only; never an owner path or URL with credentials. */
|
|
@@ -2685,7 +2960,7 @@ var unknownWorkspaceIdentity = () => workspaceIdentitySchema.parse({
|
|
|
2685
2960
|
workspaceId: UNKNOWN_WORKSPACE_ID,
|
|
2686
2961
|
keySource: "unknown"
|
|
2687
2962
|
});
|
|
2688
|
-
var sourceProvenanceSchema =
|
|
2963
|
+
var sourceProvenanceSchema = z13.strictObject({
|
|
2689
2964
|
providerId: resolvedProviderIdSchema,
|
|
2690
2965
|
providerVersion: nonEmptyStringSchema.optional(),
|
|
2691
2966
|
adapterId: nonEmptyStringSchema,
|
|
@@ -2696,7 +2971,7 @@ var sourceProvenanceSchema = z12.strictObject({
|
|
|
2696
2971
|
transport: sourceTransportSchema
|
|
2697
2972
|
}).readonly();
|
|
2698
2973
|
var consumerAttributesSchema = attributesSchema.readonly();
|
|
2699
|
-
var invocationIdentitySchema =
|
|
2974
|
+
var invocationIdentitySchema = z13.strictObject({
|
|
2700
2975
|
invocationId: invocationIdSchema,
|
|
2701
2976
|
sessionId: sessionIdSchema,
|
|
2702
2977
|
/** Set when this invocation runs beneath another agent invocation. */
|
|
@@ -2710,7 +2985,7 @@ var invocationIdentitySchema = z12.strictObject({
|
|
|
2710
2985
|
startedAt: epochMillisSchema,
|
|
2711
2986
|
consumerAttributes: consumerAttributesSchema
|
|
2712
2987
|
}).readonly();
|
|
2713
|
-
var identityClaimFieldsSchema =
|
|
2988
|
+
var identityClaimFieldsSchema = z13.strictObject({
|
|
2714
2989
|
invocationId: invocationIdSchema.optional(),
|
|
2715
2990
|
sessionId: sessionIdSchema.optional(),
|
|
2716
2991
|
parentInvocationId: invocationIdSchema.optional(),
|
|
@@ -2719,7 +2994,7 @@ var identityClaimFieldsSchema = z12.strictObject({
|
|
|
2719
2994
|
workspace: workspaceIdentitySchema.optional(),
|
|
2720
2995
|
startedAt: epochMillisSchema.optional()
|
|
2721
2996
|
});
|
|
2722
|
-
var identityClaimSchema =
|
|
2997
|
+
var identityClaimSchema = z13.strictObject({
|
|
2723
2998
|
/** Non-sensitive label, e.g. `adapter:acme-cli` or `env:OTEL_HOOK_SESSION_ID`. */
|
|
2724
2999
|
source: nonEmptyStringSchema,
|
|
2725
3000
|
confidence: detectionConfidenceSchema,
|
|
@@ -2887,14 +3162,14 @@ var deriveWorkspaceIdentity = (privacy, input, labels = {}) => {
|
|
|
2887
3162
|
};
|
|
2888
3163
|
|
|
2889
3164
|
// src/providers/adapter.ts
|
|
2890
|
-
import { z as
|
|
3165
|
+
import { z as z17 } from "zod";
|
|
2891
3166
|
|
|
2892
3167
|
// src/model/events.ts
|
|
2893
|
-
import { z as
|
|
3168
|
+
import { z as z16 } from "zod";
|
|
2894
3169
|
|
|
2895
3170
|
// src/model/content.ts
|
|
2896
|
-
import { z as
|
|
2897
|
-
var contentKindSchema =
|
|
3171
|
+
import { z as z14 } from "zod";
|
|
3172
|
+
var contentKindSchema = z14.enum([
|
|
2898
3173
|
"prompt",
|
|
2899
3174
|
"response",
|
|
2900
3175
|
"reasoning",
|
|
@@ -2904,47 +3179,47 @@ var contentKindSchema = z13.enum([
|
|
|
2904
3179
|
"system-instruction",
|
|
2905
3180
|
"attachment"
|
|
2906
3181
|
]);
|
|
2907
|
-
var contentRoleSchema =
|
|
2908
|
-
var contentDisclosureSchema =
|
|
3182
|
+
var contentRoleSchema = z14.enum(["user", "assistant", "system", "tool", "unknown"]);
|
|
3183
|
+
var contentDisclosureSchema = z14.enum(["omitted", "masked", "redacted", "raw"]);
|
|
2909
3184
|
var CONTENT_HASH_PATTERN = /^sha256:[0-9a-f]{64}$/;
|
|
2910
|
-
var contentFactSchema =
|
|
3185
|
+
var contentFactSchema = z14.strictObject({
|
|
2911
3186
|
kind: contentKindSchema,
|
|
2912
3187
|
role: contentRoleSchema.optional(),
|
|
2913
3188
|
/** Unicode code point count of the original content. */
|
|
2914
|
-
characterLength:
|
|
3189
|
+
characterLength: z14.number().int().min(0),
|
|
2915
3190
|
/** UTF-8 byte length of the original content. */
|
|
2916
|
-
byteLength:
|
|
3191
|
+
byteLength: z14.number().int().min(0),
|
|
2917
3192
|
/** Stable salted digest of the original content. */
|
|
2918
|
-
contentHash:
|
|
3193
|
+
contentHash: z14.string().regex(CONTENT_HASH_PATTERN),
|
|
2919
3194
|
disclosure: contentDisclosureSchema,
|
|
2920
3195
|
/** Disclosed text, bounded by the privacy policy. Absent when omitted. */
|
|
2921
|
-
text:
|
|
3196
|
+
text: z14.string().optional(),
|
|
2922
3197
|
/** True when `text` was cut short by the configured string bound. */
|
|
2923
|
-
truncated:
|
|
3198
|
+
truncated: z14.boolean(),
|
|
2924
3199
|
/** Number of secret-looking spans replaced while producing `text`. */
|
|
2925
|
-
secretsRedacted:
|
|
3200
|
+
secretsRedacted: z14.number().int().min(0),
|
|
2926
3201
|
/** Optional non-sensitive label, e.g. a MIME type or tool name. */
|
|
2927
3202
|
label: nonEmptyStringSchema.optional()
|
|
2928
3203
|
});
|
|
2929
|
-
var contentFactsSchema =
|
|
3204
|
+
var contentFactsSchema = z14.array(contentFactSchema).max(64);
|
|
2930
3205
|
var isContentFactConsistent = (fact) => fact.disclosure === "omitted" ? fact.text === void 0 : fact.text !== void 0;
|
|
2931
3206
|
var isUnavailableContentFact = (fact) => fact.disclosure === "omitted" && fact.text === void 0 && fact.characterLength === 0 && fact.byteLength === 0;
|
|
2932
3207
|
|
|
2933
3208
|
// src/model/target.ts
|
|
2934
|
-
import { z as
|
|
2935
|
-
var targetSourceSchema =
|
|
3209
|
+
import { z as z15 } from "zod";
|
|
3210
|
+
var targetSourceSchema = z15.enum(["tool-path", "shell-cwd", "session-cwd"]);
|
|
2936
3211
|
var MAX_TARGET_HINT_PATHS = 8;
|
|
2937
3212
|
var MAX_TARGET_PATH_LENGTH = 4096;
|
|
2938
|
-
var localPathSchema =
|
|
2939
|
-
var targetHintSchema =
|
|
3213
|
+
var localPathSchema = z15.string().min(1).max(MAX_TARGET_PATH_LENGTH).refine((value) => !value.includes("\0"), "path must not contain NUL");
|
|
3214
|
+
var targetHintSchema = z15.strictObject({
|
|
2940
3215
|
source: targetSourceSchema,
|
|
2941
|
-
paths:
|
|
3216
|
+
paths: z15.array(localPathSchema).min(1).max(MAX_TARGET_HINT_PATHS).readonly(),
|
|
2942
3217
|
/** Absolute directory that relative `paths` resolve against. */
|
|
2943
3218
|
baseDirectory: localPathSchema.optional()
|
|
2944
3219
|
}).readonly();
|
|
2945
3220
|
var sessionCwdHint = (cwd) => cwd === void 0 || cwd.length === 0 ? void 0 : { source: "session-cwd", paths: [cwd] };
|
|
2946
|
-
var worktreeKindSchema =
|
|
2947
|
-
var workspaceTargetSchema =
|
|
3221
|
+
var worktreeKindSchema = z15.enum(["main", "linked"]);
|
|
3222
|
+
var workspaceTargetSchema = z15.strictObject({
|
|
2948
3223
|
workspaceId: workspaceIdSchema,
|
|
2949
3224
|
/** Branch checked out in that worktree; absent on a detached HEAD. */
|
|
2950
3225
|
vcsBranchName: nonEmptyStringSchema.optional(),
|
|
@@ -2954,22 +3229,22 @@ var workspaceTargetSchema = z14.strictObject({
|
|
|
2954
3229
|
worktreeKind: worktreeKindSchema.optional()
|
|
2955
3230
|
}).readonly();
|
|
2956
3231
|
var SUBAGENT_ID_PATTERN = /^[A-Za-z0-9_.:@+=-]{1,256}$/;
|
|
2957
|
-
var subagentIdSchema =
|
|
3232
|
+
var subagentIdSchema = z15.string().regex(SUBAGENT_ID_PATTERN);
|
|
2958
3233
|
|
|
2959
3234
|
// src/model/events.ts
|
|
2960
|
-
var modelDescriptorSchema =
|
|
3235
|
+
var modelDescriptorSchema = z16.strictObject({
|
|
2961
3236
|
modelId: nonEmptyStringSchema,
|
|
2962
3237
|
/** Vendor of the model, e.g. `anthropic`. Distinct from the agent provider. */
|
|
2963
3238
|
vendor: nonEmptyStringSchema.optional(),
|
|
2964
3239
|
family: nonEmptyStringSchema.optional()
|
|
2965
3240
|
});
|
|
2966
|
-
var costFactsSchema =
|
|
3241
|
+
var costFactsSchema = z16.strictObject({
|
|
2967
3242
|
/** ISO 4217 code. */
|
|
2968
|
-
currency:
|
|
2969
|
-
amount:
|
|
2970
|
-
source:
|
|
3243
|
+
currency: z16.string().length(3),
|
|
3244
|
+
amount: z16.number().min(0).finite(),
|
|
3245
|
+
source: z16.enum(["provider-reported", "computed"])
|
|
2971
3246
|
});
|
|
2972
|
-
var canonicalEventTypeSchema =
|
|
3247
|
+
var canonicalEventTypeSchema = z16.enum([
|
|
2973
3248
|
"session.start",
|
|
2974
3249
|
"session.end",
|
|
2975
3250
|
"prompt.submitted",
|
|
@@ -2983,7 +3258,7 @@ var canonicalEventTypeSchema = z15.enum([
|
|
|
2983
3258
|
"error.raised"
|
|
2984
3259
|
]);
|
|
2985
3260
|
var CANONICAL_EVENT_TYPES = canonicalEventTypeSchema.options;
|
|
2986
|
-
var outcomeSchema =
|
|
3261
|
+
var outcomeSchema = z16.enum(["ok", "error", "cancelled", "timeout", "denied", "unknown"]);
|
|
2987
3262
|
var baseEventFields = {
|
|
2988
3263
|
schemaVersion: canonicalSchemaVersionSchema,
|
|
2989
3264
|
eventId: eventIdSchema,
|
|
@@ -3002,10 +3277,10 @@ var baseEventFields = {
|
|
|
3002
3277
|
subagentId: subagentIdSchema.optional(),
|
|
3003
3278
|
extensions: extensionsSchema.default(emptyExtensions)
|
|
3004
3279
|
};
|
|
3005
|
-
var event = (shape) =>
|
|
3280
|
+
var event = (shape) => z16.strictObject({ ...baseEventFields, ...shape });
|
|
3006
3281
|
var sessionStartEventSchema = event({
|
|
3007
|
-
type:
|
|
3008
|
-
sessionKind:
|
|
3282
|
+
type: z16.literal("session.start"),
|
|
3283
|
+
sessionKind: z16.enum(["interactive", "non-interactive", "unknown"]),
|
|
3009
3284
|
agentName: nonEmptyStringSchema.optional(),
|
|
3010
3285
|
agentVersion: nonEmptyStringSchema.optional(),
|
|
3011
3286
|
model: modelDescriptorSchema.optional(),
|
|
@@ -3013,30 +3288,30 @@ var sessionStartEventSchema = event({
|
|
|
3013
3288
|
target: workspaceTargetSchema.optional()
|
|
3014
3289
|
});
|
|
3015
3290
|
var sessionEndEventSchema = event({
|
|
3016
|
-
type:
|
|
3017
|
-
reason:
|
|
3291
|
+
type: z16.literal("session.end"),
|
|
3292
|
+
reason: z16.enum(["completed", "aborted", "error", "timeout", "unknown"]),
|
|
3018
3293
|
durationMillis: durationMillisSchema.optional(),
|
|
3019
3294
|
/** Session totals, typically cumulative. */
|
|
3020
3295
|
usage: canonicalUsageSchema.optional(),
|
|
3021
3296
|
cost: costFactsSchema.optional()
|
|
3022
3297
|
});
|
|
3023
3298
|
var promptSubmittedEventSchema = event({
|
|
3024
|
-
type:
|
|
3025
|
-
promptSource:
|
|
3299
|
+
type: z16.literal("prompt.submitted"),
|
|
3300
|
+
promptSource: z16.enum(["user", "automation", "resumed", "unknown"]),
|
|
3026
3301
|
content: contentFactSchema.optional(),
|
|
3027
|
-
turnIndex:
|
|
3302
|
+
turnIndex: z16.number().int().min(0).optional(),
|
|
3028
3303
|
/** The git worktree the session runs in, resolved by the core (ADR 0008). */
|
|
3029
3304
|
target: workspaceTargetSchema.optional()
|
|
3030
3305
|
});
|
|
3031
3306
|
var generationStartEventSchema = event({
|
|
3032
|
-
type:
|
|
3307
|
+
type: z16.literal("generation.start"),
|
|
3033
3308
|
generationId: nonEmptyStringSchema,
|
|
3034
3309
|
model: modelDescriptorSchema,
|
|
3035
3310
|
requestedMaxOutputTokens: tokenCountSchema.optional(),
|
|
3036
3311
|
inputContent: contentFactsSchema.optional()
|
|
3037
3312
|
});
|
|
3038
3313
|
var generationEndEventSchema = event({
|
|
3039
|
-
type:
|
|
3314
|
+
type: z16.literal("generation.end"),
|
|
3040
3315
|
generationId: nonEmptyStringSchema,
|
|
3041
3316
|
model: modelDescriptorSchema,
|
|
3042
3317
|
outcome: outcomeSchema,
|
|
@@ -3046,7 +3321,7 @@ var generationEndEventSchema = event({
|
|
|
3046
3321
|
cost: costFactsSchema.optional(),
|
|
3047
3322
|
outputContent: contentFactsSchema.optional()
|
|
3048
3323
|
});
|
|
3049
|
-
var toolKindSchema =
|
|
3324
|
+
var toolKindSchema = z16.enum([
|
|
3050
3325
|
"read",
|
|
3051
3326
|
"write",
|
|
3052
3327
|
"execute",
|
|
@@ -3057,7 +3332,7 @@ var toolKindSchema = z15.enum([
|
|
|
3057
3332
|
"unknown"
|
|
3058
3333
|
]);
|
|
3059
3334
|
var toolStartEventSchema = event({
|
|
3060
|
-
type:
|
|
3335
|
+
type: z16.literal("tool.start"),
|
|
3061
3336
|
toolCallId: nonEmptyStringSchema,
|
|
3062
3337
|
toolName: nonEmptyStringSchema,
|
|
3063
3338
|
toolKind: toolKindSchema,
|
|
@@ -3067,53 +3342,53 @@ var toolStartEventSchema = event({
|
|
|
3067
3342
|
target: workspaceTargetSchema.optional()
|
|
3068
3343
|
});
|
|
3069
3344
|
var toolEndEventSchema = event({
|
|
3070
|
-
type:
|
|
3345
|
+
type: z16.literal("tool.end"),
|
|
3071
3346
|
toolCallId: nonEmptyStringSchema,
|
|
3072
3347
|
toolName: nonEmptyStringSchema,
|
|
3073
3348
|
outcome: outcomeSchema,
|
|
3074
3349
|
durationMillis: durationMillisSchema.optional(),
|
|
3075
3350
|
/** Present when the host asked for or recorded a permission decision. */
|
|
3076
|
-
permissionDecision:
|
|
3351
|
+
permissionDecision: z16.enum(["allowed", "denied", "deferred", "not-required"]).optional(),
|
|
3077
3352
|
output: contentFactSchema.optional(),
|
|
3078
3353
|
/** The git worktree this call targeted, resolved by the core (ADR 0008). */
|
|
3079
3354
|
target: workspaceTargetSchema.optional()
|
|
3080
3355
|
});
|
|
3081
3356
|
var subagentStartEventSchema = event({
|
|
3082
|
-
type:
|
|
3357
|
+
type: z16.literal("subagent.start"),
|
|
3083
3358
|
subagentInvocationId: invocationIdSchema,
|
|
3084
3359
|
subagentType: nonEmptyStringSchema.optional(),
|
|
3085
3360
|
/** 0 for the top-level agent; 1 for its direct children. */
|
|
3086
|
-
delegationDepth:
|
|
3361
|
+
delegationDepth: z16.number().int().min(0).max(64),
|
|
3087
3362
|
model: modelDescriptorSchema.optional()
|
|
3088
3363
|
});
|
|
3089
3364
|
var subagentEndEventSchema = event({
|
|
3090
|
-
type:
|
|
3365
|
+
type: z16.literal("subagent.end"),
|
|
3091
3366
|
subagentInvocationId: invocationIdSchema,
|
|
3092
3367
|
outcome: outcomeSchema,
|
|
3093
3368
|
durationMillis: durationMillisSchema.optional(),
|
|
3094
3369
|
usage: canonicalUsageSchema.optional()
|
|
3095
3370
|
});
|
|
3096
3371
|
var compactionPerformedEventSchema = event({
|
|
3097
|
-
type:
|
|
3098
|
-
trigger:
|
|
3372
|
+
type: z16.literal("compaction.performed"),
|
|
3373
|
+
trigger: z16.enum(["automatic", "manual", "unknown"]),
|
|
3099
3374
|
/** Provider-reported context size before and after compaction, if known. */
|
|
3100
3375
|
contextTokensBefore: tokenCountSchema.optional(),
|
|
3101
3376
|
contextTokensAfter: tokenCountSchema.optional(),
|
|
3102
|
-
droppedMessageCount:
|
|
3377
|
+
droppedMessageCount: z16.number().int().min(0).optional(),
|
|
3103
3378
|
usage: canonicalUsageSchema.optional()
|
|
3104
3379
|
});
|
|
3105
3380
|
var errorRaisedEventSchema = event({
|
|
3106
|
-
type:
|
|
3381
|
+
type: z16.literal("error.raised"),
|
|
3107
3382
|
errorCode: otelHookErrorCodeSchema,
|
|
3108
3383
|
severity: errorSeveritySchema,
|
|
3109
3384
|
phase: errorPhaseSchema,
|
|
3110
|
-
retryable:
|
|
3385
|
+
retryable: z16.boolean(),
|
|
3111
3386
|
/** Error text is content: it is described, never embedded verbatim by default. */
|
|
3112
3387
|
message: contentFactSchema.optional(),
|
|
3113
3388
|
/** Non-sensitive, provider-agnostic short label. */
|
|
3114
3389
|
detail: nonEmptyStringSchema.optional()
|
|
3115
3390
|
});
|
|
3116
|
-
var canonicalEventSchema =
|
|
3391
|
+
var canonicalEventSchema = z16.discriminatedUnion("type", [
|
|
3117
3392
|
sessionStartEventSchema,
|
|
3118
3393
|
sessionEndEventSchema,
|
|
3119
3394
|
promptSubmittedEventSchema,
|
|
@@ -3131,26 +3406,26 @@ var TARGETED = new Set(TARGETED_EVENT_TYPES);
|
|
|
3131
3406
|
var isTargetedEvent = (event3) => TARGETED.has(event3.type);
|
|
3132
3407
|
|
|
3133
3408
|
// src/providers/adapter.ts
|
|
3134
|
-
var providerDetectionSchema =
|
|
3409
|
+
var providerDetectionSchema = z17.strictObject({
|
|
3135
3410
|
providerId: resolvedProviderIdSchema,
|
|
3136
3411
|
confidence: detectionConfidenceSchema,
|
|
3137
3412
|
/**
|
|
3138
3413
|
* Short, non-sensitive justifications, e.g. `"payload.hook_event_name present"`.
|
|
3139
3414
|
* Reasons are exported in diagnostics, so they must not quote payload values.
|
|
3140
3415
|
*/
|
|
3141
|
-
reasons:
|
|
3416
|
+
reasons: z17.array(z17.string().min(1).max(160)).max(8),
|
|
3142
3417
|
providerVersion: nonEmptyStringSchema.optional(),
|
|
3143
3418
|
/** The provider's own name for this event, when the payload states one. */
|
|
3144
3419
|
sourceEventName: nonEmptyStringSchema.optional()
|
|
3145
3420
|
});
|
|
3146
|
-
var deliveryIdentifierSupportSchema =
|
|
3421
|
+
var deliveryIdentifierSupportSchema = z17.enum(["none", "partial", "all"]);
|
|
3147
3422
|
var DELIVERY_COMPONENT_PATTERN = /^[A-Za-z0-9_.:@+=-]{1,256}$/;
|
|
3148
|
-
var deliveryComponentSchema =
|
|
3423
|
+
var deliveryComponentSchema = z17.string().regex(
|
|
3149
3424
|
DELIVERY_COMPONENT_PATTERN,
|
|
3150
3425
|
"delivery component must be identifier-shaped: no whitespace, no path separators"
|
|
3151
3426
|
);
|
|
3152
3427
|
var MAX_DELIVERY_COMPONENTS = 8;
|
|
3153
|
-
var providerDeliveryClaimSchema =
|
|
3428
|
+
var providerDeliveryClaimSchema = z17.strictObject({
|
|
3154
3429
|
/**
|
|
3155
3430
|
* The provider's own session/conversation id. Scopes the callback identity, so
|
|
3156
3431
|
* two sessions reusing one tool-call id never collide.
|
|
@@ -3162,26 +3437,26 @@ var providerDeliveryClaimSchema = z16.strictObject({
|
|
|
3162
3437
|
* Identifier-shaped payload fields that, together with `sourceEventName`,
|
|
3163
3438
|
* name this callback within the session exactly once.
|
|
3164
3439
|
*/
|
|
3165
|
-
components:
|
|
3440
|
+
components: z17.array(deliveryComponentSchema).min(1).max(MAX_DELIVERY_COMPONENTS).readonly(),
|
|
3166
3441
|
/**
|
|
3167
3442
|
* Short, non-sensitive justifications, e.g. `"payload.tool_use_id names one
|
|
3168
3443
|
* tool call"`. Evidence reaches diagnostics, so it must name fields, never
|
|
3169
3444
|
* quote their values.
|
|
3170
3445
|
*/
|
|
3171
|
-
evidence:
|
|
3446
|
+
evidence: z17.array(z17.string().min(1).max(160)).min(1).max(4).readonly()
|
|
3172
3447
|
});
|
|
3173
3448
|
var DELIVERY_GAP_REASON_PATTERN = /^[^\n\r\t\\/]{1,240}$/;
|
|
3174
|
-
var deliveryGapReasonSchema =
|
|
3449
|
+
var deliveryGapReasonSchema = z17.string().regex(
|
|
3175
3450
|
DELIVERY_GAP_REASON_PATTERN,
|
|
3176
3451
|
"delivery gap reason must be one line of prose: no path separators, no control characters"
|
|
3177
3452
|
);
|
|
3178
3453
|
var MAX_DELIVERY_GAPS = 48;
|
|
3179
|
-
var providerDeliveryGapsSchema =
|
|
3454
|
+
var providerDeliveryGapsSchema = z17.record(deliveryComponentSchema, deliveryGapReasonSchema).refine((gaps) => Object.keys(gaps).length <= MAX_DELIVERY_GAPS, {
|
|
3180
3455
|
message: `at most ${String(MAX_DELIVERY_GAPS)} delivery gaps may be declared`
|
|
3181
3456
|
});
|
|
3182
|
-
var providerCapabilitiesSchema =
|
|
3457
|
+
var providerCapabilitiesSchema = z17.strictObject({
|
|
3183
3458
|
/** Event types the adapter can produce. */
|
|
3184
|
-
lifecycleEvents:
|
|
3459
|
+
lifecycleEvents: z17.array(canonicalEventTypeSchema).max(32).readonly(),
|
|
3185
3460
|
usageTemporality: usageTemporalitySchema,
|
|
3186
3461
|
/**
|
|
3187
3462
|
* Which accumulator series a `cumulative` report continues — that is, which
|
|
@@ -3200,32 +3475,32 @@ var providerCapabilitiesSchema = z16.strictObject({
|
|
|
3200
3475
|
* Subagent snapshots keep their own series regardless: a delegated agent's
|
|
3201
3476
|
* counter is not a point on the parent session's curve.
|
|
3202
3477
|
*/
|
|
3203
|
-
cumulativeUsageSeries:
|
|
3204
|
-
reportsCachedInput:
|
|
3205
|
-
reportsCacheCreation:
|
|
3478
|
+
cumulativeUsageSeries: z17.enum(["event-scope", "session-lifetime"]).optional(),
|
|
3479
|
+
reportsCachedInput: z17.boolean(),
|
|
3480
|
+
reportsCacheCreation: z17.boolean(),
|
|
3206
3481
|
cacheCreationAccounting: cacheCreationAccountingSchema,
|
|
3207
|
-
reportsReasoningOutput:
|
|
3208
|
-
reportsProviderTotal:
|
|
3209
|
-
reportsCost:
|
|
3210
|
-
emitsSubagentEvents:
|
|
3211
|
-
emitsCompactionEvents:
|
|
3482
|
+
reportsReasoningOutput: z17.boolean(),
|
|
3483
|
+
reportsProviderTotal: z17.boolean(),
|
|
3484
|
+
reportsCost: z17.boolean(),
|
|
3485
|
+
emitsSubagentEvents: z17.boolean(),
|
|
3486
|
+
emitsCompactionEvents: z17.boolean(),
|
|
3212
3487
|
/** True when the provider reads a structured response from stdout. */
|
|
3213
|
-
requiresHookResponse:
|
|
3488
|
+
requiresHookResponse: z17.boolean(),
|
|
3214
3489
|
/** How much of this provider's hook traffic is replay-identifiable. */
|
|
3215
3490
|
deliveryIdentifier: deliveryIdentifierSupportSchema
|
|
3216
3491
|
});
|
|
3217
|
-
var providerHookResponseSchema =
|
|
3492
|
+
var providerHookResponseSchema = z17.strictObject({
|
|
3218
3493
|
/**
|
|
3219
3494
|
* Always 0. A telemetry hook that can fail the host agent is a liability, so
|
|
3220
3495
|
* the type forbids expressing anything else (ADR 0004).
|
|
3221
3496
|
*/
|
|
3222
|
-
exitCode:
|
|
3497
|
+
exitCode: z17.literal(0),
|
|
3223
3498
|
/** Protocol response text. Omit to write nothing at all. */
|
|
3224
|
-
stdout:
|
|
3499
|
+
stdout: z17.string().max(8192).optional(),
|
|
3225
3500
|
/** Non-sensitive diagnostic text for stderr. */
|
|
3226
|
-
stderr:
|
|
3501
|
+
stderr: z17.string().max(8192).optional(),
|
|
3227
3502
|
/** Declares which of the two stdout contracts this response follows. */
|
|
3228
|
-
contract:
|
|
3503
|
+
contract: z17.enum(["silent", "provider-protocol"])
|
|
3229
3504
|
});
|
|
3230
3505
|
var SILENT_HOOK_RESPONSE = Object.freeze({
|
|
3231
3506
|
exitCode: 0,
|
|
@@ -3338,7 +3613,7 @@ var createEventFactory = (input) => {
|
|
|
3338
3613
|
};
|
|
3339
3614
|
|
|
3340
3615
|
// src/providers/antigravity/payload.ts
|
|
3341
|
-
import { z as
|
|
3616
|
+
import { z as z18 } from "zod";
|
|
3342
3617
|
var ANTIGRAVITY_HOOK_EVENT_NAMES = [
|
|
3343
3618
|
"PreInvocation",
|
|
3344
3619
|
"PostInvocation",
|
|
@@ -3346,48 +3621,48 @@ var ANTIGRAVITY_HOOK_EVENT_NAMES = [
|
|
|
3346
3621
|
"PostToolUse",
|
|
3347
3622
|
"Stop"
|
|
3348
3623
|
];
|
|
3349
|
-
var hookEventNameSchema =
|
|
3350
|
-
var antigravityWeakShapeSchema =
|
|
3624
|
+
var hookEventNameSchema = z18.enum(ANTIGRAVITY_HOOK_EVENT_NAMES);
|
|
3625
|
+
var antigravityWeakShapeSchema = z18.object({ hookEventName: hookEventNameSchema }).passthrough();
|
|
3351
3626
|
var commonFields = {
|
|
3352
|
-
conversationId:
|
|
3353
|
-
workspacePaths:
|
|
3354
|
-
invocationNum:
|
|
3627
|
+
conversationId: z18.string().min(1),
|
|
3628
|
+
workspacePaths: z18.array(z18.string().min(1)).max(64),
|
|
3629
|
+
invocationNum: z18.number().int().min(0),
|
|
3355
3630
|
/** Never disclosed: a real filesystem path. Accepted, never propagated. */
|
|
3356
|
-
transcriptPath:
|
|
3631
|
+
transcriptPath: z18.string().min(1).optional(),
|
|
3357
3632
|
/** Never disclosed: a real filesystem path. Accepted, never propagated. */
|
|
3358
|
-
artifactDirectoryPath:
|
|
3633
|
+
artifactDirectoryPath: z18.string().min(1).optional()
|
|
3359
3634
|
};
|
|
3360
|
-
var preInvocationPayloadSchema =
|
|
3361
|
-
hookEventName:
|
|
3635
|
+
var preInvocationPayloadSchema = z18.object({
|
|
3636
|
+
hookEventName: z18.literal("PreInvocation"),
|
|
3362
3637
|
...commonFields,
|
|
3363
|
-
agentVersion:
|
|
3638
|
+
agentVersion: z18.string().min(1).optional()
|
|
3364
3639
|
});
|
|
3365
|
-
var postInvocationPayloadSchema =
|
|
3366
|
-
hookEventName:
|
|
3640
|
+
var postInvocationPayloadSchema = z18.object({
|
|
3641
|
+
hookEventName: z18.literal("PostInvocation"),
|
|
3367
3642
|
...commonFields,
|
|
3368
|
-
agentVersion:
|
|
3643
|
+
agentVersion: z18.string().min(1).optional()
|
|
3369
3644
|
});
|
|
3370
|
-
var preToolUsePayloadSchema =
|
|
3371
|
-
hookEventName:
|
|
3645
|
+
var preToolUsePayloadSchema = z18.object({
|
|
3646
|
+
hookEventName: z18.literal("PreToolUse"),
|
|
3372
3647
|
...commonFields,
|
|
3373
|
-
stepIdx:
|
|
3374
|
-
toolName:
|
|
3375
|
-
toolInput:
|
|
3648
|
+
stepIdx: z18.number().int().min(0),
|
|
3649
|
+
toolName: z18.string().min(1),
|
|
3650
|
+
toolInput: z18.unknown().optional()
|
|
3376
3651
|
});
|
|
3377
|
-
var postToolUsePayloadSchema =
|
|
3378
|
-
hookEventName:
|
|
3652
|
+
var postToolUsePayloadSchema = z18.object({
|
|
3653
|
+
hookEventName: z18.literal("PostToolUse"),
|
|
3379
3654
|
...commonFields,
|
|
3380
|
-
stepIdx:
|
|
3381
|
-
toolName:
|
|
3382
|
-
toolResponse:
|
|
3383
|
-
isError:
|
|
3655
|
+
stepIdx: z18.number().int().min(0),
|
|
3656
|
+
toolName: z18.string().min(1),
|
|
3657
|
+
toolResponse: z18.unknown().optional(),
|
|
3658
|
+
isError: z18.boolean().optional()
|
|
3384
3659
|
});
|
|
3385
|
-
var stopPayloadSchema =
|
|
3386
|
-
hookEventName:
|
|
3660
|
+
var stopPayloadSchema = z18.object({
|
|
3661
|
+
hookEventName: z18.literal("Stop"),
|
|
3387
3662
|
...commonFields,
|
|
3388
|
-
fullyIdle:
|
|
3663
|
+
fullyIdle: z18.boolean()
|
|
3389
3664
|
});
|
|
3390
|
-
var antigravityHookPayloadSchema =
|
|
3665
|
+
var antigravityHookPayloadSchema = z18.discriminatedUnion("hookEventName", [
|
|
3391
3666
|
preInvocationPayloadSchema,
|
|
3392
3667
|
postInvocationPayloadSchema,
|
|
3393
3668
|
preToolUsePayloadSchema,
|
|
@@ -3636,35 +3911,35 @@ var CLAUDE_CODE_CAPABILITIES = Object.freeze({
|
|
|
3636
3911
|
});
|
|
3637
3912
|
|
|
3638
3913
|
// src/providers/claude/schema.ts
|
|
3639
|
-
import { z as
|
|
3914
|
+
import { z as z19 } from "zod";
|
|
3640
3915
|
var commonFields2 = {
|
|
3641
|
-
session_id:
|
|
3642
|
-
transcript_path:
|
|
3643
|
-
cwd:
|
|
3644
|
-
permission_mode:
|
|
3916
|
+
session_id: z19.string().min(1),
|
|
3917
|
+
transcript_path: z19.string().min(1).optional(),
|
|
3918
|
+
cwd: z19.string().min(1).optional(),
|
|
3919
|
+
permission_mode: z19.string().min(1).optional(),
|
|
3645
3920
|
/** Correlates a hook firing with the user prompt that triggered it (Claude Code v2.1.196+). */
|
|
3646
|
-
prompt_id:
|
|
3921
|
+
prompt_id: z19.string().min(1).optional(),
|
|
3647
3922
|
/** Present when the hook fired while running inside a subagent. */
|
|
3648
|
-
agent_id:
|
|
3649
|
-
agent_type:
|
|
3650
|
-
};
|
|
3651
|
-
var claudeCacheCreationSchema =
|
|
3652
|
-
ephemeral_5m_input_tokens:
|
|
3653
|
-
ephemeral_1h_input_tokens:
|
|
3654
|
-
});
|
|
3655
|
-
var claudeUsageIterationSchema =
|
|
3656
|
-
input_tokens:
|
|
3657
|
-
output_tokens:
|
|
3658
|
-
cache_creation_input_tokens:
|
|
3659
|
-
cache_read_input_tokens:
|
|
3660
|
-
});
|
|
3661
|
-
var claudeUsageSchema =
|
|
3662
|
-
input_tokens:
|
|
3663
|
-
output_tokens:
|
|
3664
|
-
cache_creation_input_tokens:
|
|
3665
|
-
cache_read_input_tokens:
|
|
3923
|
+
agent_id: z19.string().min(1).optional(),
|
|
3924
|
+
agent_type: z19.string().min(1).optional()
|
|
3925
|
+
};
|
|
3926
|
+
var claudeCacheCreationSchema = z19.object({
|
|
3927
|
+
ephemeral_5m_input_tokens: z19.number().int().min(0).optional(),
|
|
3928
|
+
ephemeral_1h_input_tokens: z19.number().int().min(0).optional()
|
|
3929
|
+
});
|
|
3930
|
+
var claudeUsageIterationSchema = z19.object({
|
|
3931
|
+
input_tokens: z19.number().int().min(0).optional(),
|
|
3932
|
+
output_tokens: z19.number().int().min(0).optional(),
|
|
3933
|
+
cache_creation_input_tokens: z19.number().int().min(0).optional(),
|
|
3934
|
+
cache_read_input_tokens: z19.number().int().min(0).optional()
|
|
3935
|
+
});
|
|
3936
|
+
var claudeUsageSchema = z19.object({
|
|
3937
|
+
input_tokens: z19.number().int().min(0),
|
|
3938
|
+
output_tokens: z19.number().int().min(0),
|
|
3939
|
+
cache_creation_input_tokens: z19.number().int().min(0).optional(),
|
|
3940
|
+
cache_read_input_tokens: z19.number().int().min(0).optional(),
|
|
3666
3941
|
cache_creation: claudeCacheCreationSchema.optional(),
|
|
3667
|
-
iterations:
|
|
3942
|
+
iterations: z19.array(claudeUsageIterationSchema).optional(),
|
|
3668
3943
|
/**
|
|
3669
3944
|
* Counters the canonical model has a home for but Claude Code never reports:
|
|
3670
3945
|
* 0 of 4,999 real usage objects carried either (finding 5).
|
|
@@ -3673,112 +3948,112 @@ var claudeUsageSchema = z18.object({
|
|
|
3673
3948
|
* that a harness attaching one gets told it was excluded, instead of watching
|
|
3674
3949
|
* it vanish. See `CLAUDE_EXCLUDED_USAGE_COUNTERS`.
|
|
3675
3950
|
*/
|
|
3676
|
-
total_tokens:
|
|
3677
|
-
reasoning_output_tokens:
|
|
3951
|
+
total_tokens: z19.number().int().min(0).optional(),
|
|
3952
|
+
reasoning_output_tokens: z19.number().int().min(0).optional()
|
|
3678
3953
|
});
|
|
3679
|
-
var sessionStartPayloadSchema =
|
|
3954
|
+
var sessionStartPayloadSchema = z19.object({
|
|
3680
3955
|
...commonFields2,
|
|
3681
|
-
hook_event_name:
|
|
3956
|
+
hook_event_name: z19.literal("SessionStart"),
|
|
3682
3957
|
/** Matcher values: startup | resume | clear | compact | fork. Forward-compatible: any string. */
|
|
3683
|
-
source:
|
|
3684
|
-
model:
|
|
3685
|
-
session_title:
|
|
3958
|
+
source: z19.string().min(1).optional(),
|
|
3959
|
+
model: z19.string().min(1).optional(),
|
|
3960
|
+
session_title: z19.string().min(1).optional()
|
|
3686
3961
|
});
|
|
3687
|
-
var sessionEndPayloadSchema =
|
|
3962
|
+
var sessionEndPayloadSchema = z19.object({
|
|
3688
3963
|
...commonFields2,
|
|
3689
|
-
hook_event_name:
|
|
3964
|
+
hook_event_name: z19.literal("SessionEnd"),
|
|
3690
3965
|
/** Current Claude Code field; values include clear, logout, prompt_input_exit, and other. */
|
|
3691
|
-
reason:
|
|
3966
|
+
reason: z19.string().min(1).optional(),
|
|
3692
3967
|
/** Compatibility alias emitted by older wrappers and hook integrations. */
|
|
3693
|
-
end_reason:
|
|
3968
|
+
end_reason: z19.string().min(1).optional()
|
|
3694
3969
|
});
|
|
3695
|
-
var userPromptSubmitPayloadSchema =
|
|
3970
|
+
var userPromptSubmitPayloadSchema = z19.object({
|
|
3696
3971
|
...commonFields2,
|
|
3697
|
-
hook_event_name:
|
|
3698
|
-
prompt:
|
|
3972
|
+
hook_event_name: z19.literal("UserPromptSubmit"),
|
|
3973
|
+
prompt: z19.string()
|
|
3699
3974
|
});
|
|
3700
|
-
var preToolUsePayloadSchema2 =
|
|
3975
|
+
var preToolUsePayloadSchema2 = z19.object({
|
|
3701
3976
|
...commonFields2,
|
|
3702
|
-
hook_event_name:
|
|
3703
|
-
tool_name:
|
|
3704
|
-
tool_input:
|
|
3705
|
-
tool_use_id:
|
|
3977
|
+
hook_event_name: z19.literal("PreToolUse"),
|
|
3978
|
+
tool_name: z19.string().min(1),
|
|
3979
|
+
tool_input: z19.unknown(),
|
|
3980
|
+
tool_use_id: z19.string().min(1)
|
|
3706
3981
|
});
|
|
3707
|
-
var postToolUsePayloadSchema2 =
|
|
3982
|
+
var postToolUsePayloadSchema2 = z19.object({
|
|
3708
3983
|
...commonFields2,
|
|
3709
|
-
hook_event_name:
|
|
3710
|
-
tool_name:
|
|
3711
|
-
tool_input:
|
|
3712
|
-
tool_response:
|
|
3713
|
-
tool_use_id:
|
|
3984
|
+
hook_event_name: z19.literal("PostToolUse"),
|
|
3985
|
+
tool_name: z19.string().min(1),
|
|
3986
|
+
tool_input: z19.unknown().optional(),
|
|
3987
|
+
tool_response: z19.unknown(),
|
|
3988
|
+
tool_use_id: z19.string().min(1)
|
|
3714
3989
|
});
|
|
3715
|
-
var postToolUseFailurePayloadSchema =
|
|
3990
|
+
var postToolUseFailurePayloadSchema = z19.object({
|
|
3716
3991
|
...commonFields2,
|
|
3717
|
-
hook_event_name:
|
|
3718
|
-
tool_name:
|
|
3719
|
-
tool_input:
|
|
3720
|
-
tool_error:
|
|
3721
|
-
tool_use_id:
|
|
3992
|
+
hook_event_name: z19.literal("PostToolUseFailure"),
|
|
3993
|
+
tool_name: z19.string().min(1),
|
|
3994
|
+
tool_input: z19.unknown().optional(),
|
|
3995
|
+
tool_error: z19.unknown(),
|
|
3996
|
+
tool_use_id: z19.string().min(1)
|
|
3722
3997
|
});
|
|
3723
|
-
var permissionRequestPayloadSchema =
|
|
3998
|
+
var permissionRequestPayloadSchema = z19.object({
|
|
3724
3999
|
...commonFields2,
|
|
3725
|
-
hook_event_name:
|
|
3726
|
-
tool_name:
|
|
3727
|
-
tool_input:
|
|
3728
|
-
tool_use_id:
|
|
4000
|
+
hook_event_name: z19.literal("PermissionRequest"),
|
|
4001
|
+
tool_name: z19.string().min(1),
|
|
4002
|
+
tool_input: z19.unknown().optional(),
|
|
4003
|
+
tool_use_id: z19.string().min(1)
|
|
3729
4004
|
});
|
|
3730
|
-
var subagentStartPayloadSchema =
|
|
4005
|
+
var subagentStartPayloadSchema = z19.object({
|
|
3731
4006
|
...commonFields2,
|
|
3732
|
-
hook_event_name:
|
|
3733
|
-
agent_type:
|
|
3734
|
-
agent_id:
|
|
4007
|
+
hook_event_name: z19.literal("SubagentStart"),
|
|
4008
|
+
agent_type: z19.string().min(1),
|
|
4009
|
+
agent_id: z19.string().min(1)
|
|
3735
4010
|
});
|
|
3736
|
-
var subagentStopPayloadSchema =
|
|
4011
|
+
var subagentStopPayloadSchema = z19.object({
|
|
3737
4012
|
...commonFields2,
|
|
3738
|
-
hook_event_name:
|
|
3739
|
-
agent_type:
|
|
3740
|
-
agent_id:
|
|
3741
|
-
last_assistant_message:
|
|
4013
|
+
hook_event_name: z19.literal("SubagentStop"),
|
|
4014
|
+
agent_type: z19.string().min(1),
|
|
4015
|
+
agent_id: z19.string().min(1),
|
|
4016
|
+
last_assistant_message: z19.string().optional(),
|
|
3742
4017
|
/** True when this stop fired because a hook continued the subagent's turn. */
|
|
3743
|
-
stop_hook_active:
|
|
4018
|
+
stop_hook_active: z19.boolean().optional(),
|
|
3744
4019
|
usage: claudeUsageSchema.optional()
|
|
3745
4020
|
});
|
|
3746
|
-
var preCompactPayloadSchema =
|
|
4021
|
+
var preCompactPayloadSchema = z19.object({
|
|
3747
4022
|
...commonFields2,
|
|
3748
|
-
hook_event_name:
|
|
4023
|
+
hook_event_name: z19.literal("PreCompact"),
|
|
3749
4024
|
/** Upstream values: manual | auto. Forward-compatible: any string. */
|
|
3750
|
-
trigger:
|
|
4025
|
+
trigger: z19.string().min(1).optional(),
|
|
3751
4026
|
/** Compatibility alias emitted by older wrappers and hook integrations. */
|
|
3752
|
-
compact_trigger:
|
|
4027
|
+
compact_trigger: z19.string().min(1).optional(),
|
|
3753
4028
|
/**
|
|
3754
4029
|
* Harness-supplied, never upstream. Reported as an explicit exclusion rather
|
|
3755
4030
|
* than carried across the process boundary: see `events.ts`.
|
|
3756
4031
|
*/
|
|
3757
|
-
context_tokens_before:
|
|
3758
|
-
estimated_tokens_removed:
|
|
4032
|
+
context_tokens_before: z19.number().int().min(0).optional(),
|
|
4033
|
+
estimated_tokens_removed: z19.number().int().min(0).optional()
|
|
3759
4034
|
});
|
|
3760
|
-
var postCompactPayloadSchema =
|
|
4035
|
+
var postCompactPayloadSchema = z19.object({
|
|
3761
4036
|
...commonFields2,
|
|
3762
|
-
hook_event_name:
|
|
3763
|
-
trigger:
|
|
3764
|
-
compact_trigger:
|
|
4037
|
+
hook_event_name: z19.literal("PostCompact"),
|
|
4038
|
+
trigger: z19.string().min(1).optional(),
|
|
4039
|
+
compact_trigger: z19.string().min(1).optional(),
|
|
3765
4040
|
/** Harness-supplied, never upstream; accepted here because one callback carries both. */
|
|
3766
|
-
context_tokens_before:
|
|
3767
|
-
context_tokens_after:
|
|
3768
|
-
dropped_message_count:
|
|
4041
|
+
context_tokens_before: z19.number().int().min(0).optional(),
|
|
4042
|
+
context_tokens_after: z19.number().int().min(0).optional(),
|
|
4043
|
+
dropped_message_count: z19.number().int().min(0).optional(),
|
|
3769
4044
|
usage: claudeUsageSchema.optional()
|
|
3770
4045
|
});
|
|
3771
|
-
var stopPayloadSchema2 =
|
|
4046
|
+
var stopPayloadSchema2 = z19.object({
|
|
3772
4047
|
...commonFields2,
|
|
3773
|
-
hook_event_name:
|
|
4048
|
+
hook_event_name: z19.literal("Stop"),
|
|
3774
4049
|
/**
|
|
3775
4050
|
* Interactive Stop field (Claude Code ≥ 2.1.47). Print / `-p` / Agent SDK
|
|
3776
4051
|
* result messages use `result` instead; `events.ts` reads both (and camelCase
|
|
3777
4052
|
* `lastAssistantMessage`) through `extractClaudeAssistantText`.
|
|
3778
4053
|
*/
|
|
3779
|
-
last_assistant_message:
|
|
4054
|
+
last_assistant_message: z19.string().optional(),
|
|
3780
4055
|
/** Print / `-p` JSON result field; accepted so a harness can attach it as-is. */
|
|
3781
|
-
result:
|
|
4056
|
+
result: z19.string().optional(),
|
|
3782
4057
|
/**
|
|
3783
4058
|
* True when this stop fired because a hook continued the turn.
|
|
3784
4059
|
*
|
|
@@ -3786,22 +4061,22 @@ var stopPayloadSchema2 = z18.object({
|
|
|
3786
4061
|
* stop from a continuation stop, which is what lets `delivery.ts` deduplicate
|
|
3787
4062
|
* the former without suppressing the latter.
|
|
3788
4063
|
*/
|
|
3789
|
-
stop_hook_active:
|
|
4064
|
+
stop_hook_active: z19.boolean().optional(),
|
|
3790
4065
|
usage: claudeUsageSchema.optional()
|
|
3791
4066
|
});
|
|
3792
|
-
var stopFailurePayloadSchema =
|
|
4067
|
+
var stopFailurePayloadSchema = z19.object({
|
|
3793
4068
|
...commonFields2,
|
|
3794
|
-
hook_event_name:
|
|
4069
|
+
hook_event_name: z19.literal("StopFailure"),
|
|
3795
4070
|
/**
|
|
3796
4071
|
* Matcher values: rate_limit | overloaded | authentication_failed |
|
|
3797
4072
|
* oauth_org_not_allowed | billing_error | invalid_request | model_not_found
|
|
3798
4073
|
* | server_error | max_output_tokens | unknown.
|
|
3799
4074
|
*/
|
|
3800
|
-
error_type:
|
|
3801
|
-
error_message:
|
|
4075
|
+
error_type: z19.string().min(1),
|
|
4076
|
+
error_message: z19.string().optional(),
|
|
3802
4077
|
usage: claudeUsageSchema.optional()
|
|
3803
4078
|
});
|
|
3804
|
-
var claudeHookPayloadSchema =
|
|
4079
|
+
var claudeHookPayloadSchema = z19.discriminatedUnion("hook_event_name", [
|
|
3805
4080
|
sessionStartPayloadSchema,
|
|
3806
4081
|
sessionEndPayloadSchema,
|
|
3807
4082
|
userPromptSubmitPayloadSchema,
|
|
@@ -3831,15 +4106,15 @@ var CLAUDE_HOOK_EVENT_NAMES = [
|
|
|
3831
4106
|
"Stop",
|
|
3832
4107
|
"StopFailure"
|
|
3833
4108
|
];
|
|
3834
|
-
var claudeIdentityFieldsSchema =
|
|
3835
|
-
session_id:
|
|
3836
|
-
hook_event_name:
|
|
3837
|
-
cwd:
|
|
3838
|
-
prompt_id:
|
|
3839
|
-
agent_id:
|
|
3840
|
-
tool_use_id:
|
|
4109
|
+
var claudeIdentityFieldsSchema = z19.object({
|
|
4110
|
+
session_id: z19.string().min(1),
|
|
4111
|
+
hook_event_name: z19.string().min(1),
|
|
4112
|
+
cwd: z19.string().min(1).optional(),
|
|
4113
|
+
prompt_id: z19.string().min(1).optional(),
|
|
4114
|
+
agent_id: z19.string().min(1).optional(),
|
|
4115
|
+
tool_use_id: z19.string().min(1).optional(),
|
|
3841
4116
|
/** Read by `delivery.ts` to tell a once-per-prompt stop from a continuation. */
|
|
3842
|
-
stop_hook_active:
|
|
4117
|
+
stop_hook_active: z19.boolean().optional()
|
|
3843
4118
|
});
|
|
3844
4119
|
|
|
3845
4120
|
// src/providers/claude/usage.ts
|
|
@@ -4580,105 +4855,105 @@ var createClaudeCodeAdapter = (options = {}) => ({
|
|
|
4580
4855
|
});
|
|
4581
4856
|
|
|
4582
4857
|
// src/providers/codex/payload.ts
|
|
4583
|
-
import { z as
|
|
4584
|
-
var permissionModeSchema =
|
|
4858
|
+
import { z as z20 } from "zod";
|
|
4859
|
+
var permissionModeSchema = z20.enum([
|
|
4585
4860
|
"default",
|
|
4586
4861
|
"acceptEdits",
|
|
4587
4862
|
"plan",
|
|
4588
4863
|
"dontAsk",
|
|
4589
4864
|
"bypassPermissions"
|
|
4590
4865
|
]);
|
|
4591
|
-
var codexUsageSchema =
|
|
4592
|
-
input_tokens:
|
|
4593
|
-
cached_input_tokens:
|
|
4594
|
-
output_tokens:
|
|
4595
|
-
reasoning_output_tokens:
|
|
4596
|
-
total_tokens:
|
|
4866
|
+
var codexUsageSchema = z20.object({
|
|
4867
|
+
input_tokens: z20.number().int().min(0).optional(),
|
|
4868
|
+
cached_input_tokens: z20.number().int().min(0).optional(),
|
|
4869
|
+
output_tokens: z20.number().int().min(0).optional(),
|
|
4870
|
+
reasoning_output_tokens: z20.number().int().min(0).optional(),
|
|
4871
|
+
total_tokens: z20.number().int().min(0).optional()
|
|
4597
4872
|
});
|
|
4598
4873
|
var baseFields = {
|
|
4599
|
-
session_id:
|
|
4600
|
-
cwd:
|
|
4601
|
-
model:
|
|
4874
|
+
session_id: z20.string().min(1).max(256),
|
|
4875
|
+
cwd: z20.string().min(1).max(4096).optional(),
|
|
4876
|
+
model: z20.string().min(1).max(256).optional(),
|
|
4602
4877
|
permission_mode: permissionModeSchema.optional(),
|
|
4603
|
-
transcript_path:
|
|
4604
|
-
codex_version:
|
|
4878
|
+
transcript_path: z20.string().min(1).max(4096).optional(),
|
|
4879
|
+
codex_version: z20.string().min(1).max(64).optional(),
|
|
4605
4880
|
/** Not part of the documented protocol; lets tests and replay stay deterministic. */
|
|
4606
|
-
occurred_at:
|
|
4881
|
+
occurred_at: z20.number().int().min(0).optional()
|
|
4607
4882
|
};
|
|
4608
|
-
var codexSessionStartPayloadSchema =
|
|
4883
|
+
var codexSessionStartPayloadSchema = z20.object({
|
|
4609
4884
|
...baseFields,
|
|
4610
|
-
hook_event_name:
|
|
4611
|
-
source:
|
|
4885
|
+
hook_event_name: z20.literal("SessionStart"),
|
|
4886
|
+
source: z20.enum(["startup", "resume", "clear", "compact"]).optional()
|
|
4612
4887
|
});
|
|
4613
|
-
var codexUserPromptSubmitPayloadSchema =
|
|
4888
|
+
var codexUserPromptSubmitPayloadSchema = z20.object({
|
|
4614
4889
|
...baseFields,
|
|
4615
|
-
hook_event_name:
|
|
4616
|
-
turn_id:
|
|
4617
|
-
prompt:
|
|
4890
|
+
hook_event_name: z20.literal("UserPromptSubmit"),
|
|
4891
|
+
turn_id: z20.string().min(1).max(256).optional(),
|
|
4892
|
+
prompt: z20.string().max(1e6).optional()
|
|
4618
4893
|
});
|
|
4619
|
-
var codexPreToolUsePayloadSchema =
|
|
4894
|
+
var codexPreToolUsePayloadSchema = z20.object({
|
|
4620
4895
|
...baseFields,
|
|
4621
|
-
hook_event_name:
|
|
4622
|
-
turn_id:
|
|
4623
|
-
tool_name:
|
|
4624
|
-
tool_call_id:
|
|
4625
|
-
tool_input:
|
|
4896
|
+
hook_event_name: z20.literal("PreToolUse"),
|
|
4897
|
+
turn_id: z20.string().min(1).max(256).optional(),
|
|
4898
|
+
tool_name: z20.string().min(1).max(256),
|
|
4899
|
+
tool_call_id: z20.string().min(1).max(256).optional(),
|
|
4900
|
+
tool_input: z20.unknown().optional()
|
|
4626
4901
|
});
|
|
4627
|
-
var codexPermissionRequestPayloadSchema =
|
|
4902
|
+
var codexPermissionRequestPayloadSchema = z20.object({
|
|
4628
4903
|
...baseFields,
|
|
4629
|
-
hook_event_name:
|
|
4630
|
-
turn_id:
|
|
4631
|
-
tool_name:
|
|
4632
|
-
tool_call_id:
|
|
4633
|
-
tool_input:
|
|
4904
|
+
hook_event_name: z20.literal("PermissionRequest"),
|
|
4905
|
+
turn_id: z20.string().min(1).max(256).optional(),
|
|
4906
|
+
tool_name: z20.string().min(1).max(256).optional(),
|
|
4907
|
+
tool_call_id: z20.string().min(1).max(256).optional(),
|
|
4908
|
+
tool_input: z20.unknown().optional()
|
|
4634
4909
|
});
|
|
4635
|
-
var codexPostToolUsePayloadSchema =
|
|
4910
|
+
var codexPostToolUsePayloadSchema = z20.object({
|
|
4636
4911
|
...baseFields,
|
|
4637
|
-
hook_event_name:
|
|
4638
|
-
turn_id:
|
|
4639
|
-
tool_name:
|
|
4640
|
-
tool_call_id:
|
|
4641
|
-
tool_input:
|
|
4642
|
-
tool_response:
|
|
4643
|
-
permission_decision:
|
|
4644
|
-
duration_ms:
|
|
4912
|
+
hook_event_name: z20.literal("PostToolUse"),
|
|
4913
|
+
turn_id: z20.string().min(1).max(256).optional(),
|
|
4914
|
+
tool_name: z20.string().min(1).max(256),
|
|
4915
|
+
tool_call_id: z20.string().min(1).max(256).optional(),
|
|
4916
|
+
tool_input: z20.unknown().optional(),
|
|
4917
|
+
tool_response: z20.unknown().optional(),
|
|
4918
|
+
permission_decision: z20.enum(["allowed", "denied", "deferred"]).optional(),
|
|
4919
|
+
duration_ms: z20.number().min(0).optional()
|
|
4645
4920
|
});
|
|
4646
|
-
var codexPreCompactPayloadSchema =
|
|
4921
|
+
var codexPreCompactPayloadSchema = z20.object({
|
|
4647
4922
|
...baseFields,
|
|
4648
|
-
hook_event_name:
|
|
4649
|
-
trigger:
|
|
4650
|
-
context_tokens_before:
|
|
4923
|
+
hook_event_name: z20.literal("PreCompact"),
|
|
4924
|
+
trigger: z20.enum(["auto", "manual"]).optional(),
|
|
4925
|
+
context_tokens_before: z20.number().int().min(0).optional()
|
|
4651
4926
|
});
|
|
4652
|
-
var codexPostCompactPayloadSchema =
|
|
4927
|
+
var codexPostCompactPayloadSchema = z20.object({
|
|
4653
4928
|
...baseFields,
|
|
4654
|
-
hook_event_name:
|
|
4655
|
-
trigger:
|
|
4656
|
-
context_tokens_after:
|
|
4657
|
-
dropped_message_count:
|
|
4929
|
+
hook_event_name: z20.literal("PostCompact"),
|
|
4930
|
+
trigger: z20.enum(["auto", "manual"]).optional(),
|
|
4931
|
+
context_tokens_after: z20.number().int().min(0).optional(),
|
|
4932
|
+
dropped_message_count: z20.number().int().min(0).optional(),
|
|
4658
4933
|
usage: codexUsageSchema.optional()
|
|
4659
4934
|
});
|
|
4660
|
-
var codexSubagentStartPayloadSchema =
|
|
4935
|
+
var codexSubagentStartPayloadSchema = z20.object({
|
|
4661
4936
|
...baseFields,
|
|
4662
|
-
hook_event_name:
|
|
4663
|
-
turn_id:
|
|
4664
|
-
subagent_id:
|
|
4665
|
-
subagent_type:
|
|
4937
|
+
hook_event_name: z20.literal("SubagentStart"),
|
|
4938
|
+
turn_id: z20.string().min(1).max(256).optional(),
|
|
4939
|
+
subagent_id: z20.string().min(1).max(256),
|
|
4940
|
+
subagent_type: z20.string().min(1).max(256).optional()
|
|
4666
4941
|
});
|
|
4667
|
-
var codexSubagentStopPayloadSchema =
|
|
4942
|
+
var codexSubagentStopPayloadSchema = z20.object({
|
|
4668
4943
|
...baseFields,
|
|
4669
|
-
hook_event_name:
|
|
4670
|
-
turn_id:
|
|
4671
|
-
subagent_id:
|
|
4672
|
-
status:
|
|
4944
|
+
hook_event_name: z20.literal("SubagentStop"),
|
|
4945
|
+
turn_id: z20.string().min(1).max(256).optional(),
|
|
4946
|
+
subagent_id: z20.string().min(1).max(256),
|
|
4947
|
+
status: z20.enum(["completed", "failed", "cancelled"]).optional(),
|
|
4673
4948
|
usage: codexUsageSchema.optional()
|
|
4674
4949
|
});
|
|
4675
|
-
var codexStopPayloadSchema =
|
|
4950
|
+
var codexStopPayloadSchema = z20.object({
|
|
4676
4951
|
...baseFields,
|
|
4677
|
-
hook_event_name:
|
|
4678
|
-
turn_id:
|
|
4679
|
-
stop_reason:
|
|
4952
|
+
hook_event_name: z20.literal("Stop"),
|
|
4953
|
+
turn_id: z20.string().min(1).max(256).optional(),
|
|
4954
|
+
stop_reason: z20.string().min(1).max(256).optional(),
|
|
4680
4955
|
usage: codexUsageSchema.optional(),
|
|
4681
|
-
duration_ms:
|
|
4956
|
+
duration_ms: z20.number().min(0).optional()
|
|
4682
4957
|
});
|
|
4683
4958
|
var CODEX_HOOK_EVENT_NAMES = [
|
|
4684
4959
|
"SessionStart",
|
|
@@ -4692,7 +4967,7 @@ var CODEX_HOOK_EVENT_NAMES = [
|
|
|
4692
4967
|
"SubagentStop",
|
|
4693
4968
|
"Stop"
|
|
4694
4969
|
];
|
|
4695
|
-
var codexHookPayloadSchema =
|
|
4970
|
+
var codexHookPayloadSchema = z20.discriminatedUnion("hook_event_name", [
|
|
4696
4971
|
codexSessionStartPayloadSchema,
|
|
4697
4972
|
codexUserPromptSubmitPayloadSchema,
|
|
4698
4973
|
codexPreToolUsePayloadSchema,
|
|
@@ -4704,9 +4979,9 @@ var codexHookPayloadSchema = z19.discriminatedUnion("hook_event_name", [
|
|
|
4704
4979
|
codexSubagentStopPayloadSchema,
|
|
4705
4980
|
codexStopPayloadSchema
|
|
4706
4981
|
]);
|
|
4707
|
-
var codexHookEnvelopeSchema =
|
|
4708
|
-
session_id:
|
|
4709
|
-
hook_event_name:
|
|
4982
|
+
var codexHookEnvelopeSchema = z20.object({
|
|
4983
|
+
session_id: z20.string().min(1),
|
|
4984
|
+
hook_event_name: z20.enum(CODEX_HOOK_EVENT_NAMES)
|
|
4710
4985
|
});
|
|
4711
4986
|
|
|
4712
4987
|
// src/providers/codex/delivery.ts
|
|
@@ -5235,7 +5510,7 @@ var createCodexAdapter = () => ({
|
|
|
5235
5510
|
});
|
|
5236
5511
|
|
|
5237
5512
|
// src/providers/cursor/payload.ts
|
|
5238
|
-
import { z as
|
|
5513
|
+
import { z as z21 } from "zod";
|
|
5239
5514
|
var CURSOR_PROVIDER_ID = "cursor";
|
|
5240
5515
|
var CURSOR_HOOK_EVENT_NAMES = [
|
|
5241
5516
|
"sessionStart",
|
|
@@ -5270,23 +5545,23 @@ var CURSOR_DECISION_EVENTS = Object.freeze({
|
|
|
5270
5545
|
subagentStart: "permission",
|
|
5271
5546
|
beforeSubmitPrompt: "continue"
|
|
5272
5547
|
});
|
|
5273
|
-
var modelParamSchema =
|
|
5274
|
-
id:
|
|
5275
|
-
value:
|
|
5548
|
+
var modelParamSchema = z21.object({
|
|
5549
|
+
id: z21.string(),
|
|
5550
|
+
value: z21.string()
|
|
5276
5551
|
});
|
|
5277
|
-
var attachmentSchema =
|
|
5278
|
-
type:
|
|
5279
|
-
file_path:
|
|
5552
|
+
var attachmentSchema = z21.object({
|
|
5553
|
+
type: z21.string().optional(),
|
|
5554
|
+
file_path: z21.string().optional()
|
|
5280
5555
|
});
|
|
5281
|
-
var fileEditSchema =
|
|
5282
|
-
old_string:
|
|
5283
|
-
new_string:
|
|
5556
|
+
var fileEditSchema = z21.object({
|
|
5557
|
+
old_string: z21.string().optional(),
|
|
5558
|
+
new_string: z21.string().optional()
|
|
5284
5559
|
});
|
|
5285
5560
|
var usageFields = {
|
|
5286
|
-
input_tokens:
|
|
5287
|
-
output_tokens:
|
|
5288
|
-
cache_read_tokens:
|
|
5289
|
-
cache_write_tokens:
|
|
5561
|
+
input_tokens: z21.number().int().min(0).optional(),
|
|
5562
|
+
output_tokens: z21.number().int().min(0).optional(),
|
|
5563
|
+
cache_read_tokens: z21.number().int().min(0).optional(),
|
|
5564
|
+
cache_write_tokens: z21.number().int().min(0).optional()
|
|
5290
5565
|
};
|
|
5291
5566
|
var envelopeShape = {
|
|
5292
5567
|
// Not `.min(1)`: see `cursorSessionId`. A payload naming neither
|
|
@@ -5294,136 +5569,136 @@ var envelopeShape = {
|
|
|
5294
5569
|
// `recognizeCursorPayload`'s post-parse check — but rejecting it here would
|
|
5295
5570
|
// fail the whole discriminated union on a field the adapter can source from
|
|
5296
5571
|
// either name.
|
|
5297
|
-
conversation_id:
|
|
5298
|
-
generation_id:
|
|
5299
|
-
session_id:
|
|
5300
|
-
model:
|
|
5301
|
-
model_id:
|
|
5302
|
-
model_params:
|
|
5303
|
-
cursor_version:
|
|
5304
|
-
workspace_roots:
|
|
5305
|
-
cwd:
|
|
5572
|
+
conversation_id: z21.string().optional(),
|
|
5573
|
+
generation_id: z21.string().optional(),
|
|
5574
|
+
session_id: z21.string().optional(),
|
|
5575
|
+
model: z21.string().optional(),
|
|
5576
|
+
model_id: z21.string().optional(),
|
|
5577
|
+
model_params: z21.array(modelParamSchema).max(64).optional(),
|
|
5578
|
+
cursor_version: z21.string().optional(),
|
|
5579
|
+
workspace_roots: z21.array(z21.string()).max(64).optional(),
|
|
5580
|
+
cwd: z21.string().optional(),
|
|
5306
5581
|
/** Never propagated. */
|
|
5307
|
-
user_email:
|
|
5582
|
+
user_email: z21.string().nullish(),
|
|
5308
5583
|
/** Never propagated. */
|
|
5309
|
-
transcript_path:
|
|
5584
|
+
transcript_path: z21.string().nullish()
|
|
5310
5585
|
};
|
|
5311
|
-
var event2 = (name, shape) =>
|
|
5586
|
+
var event2 = (name, shape) => z21.object({ ...envelopeShape, hook_event_name: z21.literal(name), ...shape });
|
|
5312
5587
|
var sessionStartPayloadSchema2 = event2("sessionStart", {
|
|
5313
|
-
is_background_agent:
|
|
5314
|
-
composer_mode:
|
|
5588
|
+
is_background_agent: z21.boolean().optional(),
|
|
5589
|
+
composer_mode: z21.string().optional()
|
|
5315
5590
|
});
|
|
5316
5591
|
var sessionEndPayloadSchema2 = event2("sessionEnd", {
|
|
5317
|
-
reason:
|
|
5318
|
-
duration_ms:
|
|
5319
|
-
is_background_agent:
|
|
5320
|
-
final_status:
|
|
5321
|
-
error_message:
|
|
5592
|
+
reason: z21.string().optional(),
|
|
5593
|
+
duration_ms: z21.number().min(0).optional(),
|
|
5594
|
+
is_background_agent: z21.boolean().optional(),
|
|
5595
|
+
final_status: z21.string().optional(),
|
|
5596
|
+
error_message: z21.string().optional()
|
|
5322
5597
|
});
|
|
5323
5598
|
var beforeSubmitPromptPayloadSchema = event2("beforeSubmitPrompt", {
|
|
5324
|
-
prompt:
|
|
5325
|
-
attachments:
|
|
5326
|
-
composer_mode:
|
|
5599
|
+
prompt: z21.string().optional(),
|
|
5600
|
+
attachments: z21.array(attachmentSchema).max(256).optional(),
|
|
5601
|
+
composer_mode: z21.string().optional()
|
|
5327
5602
|
});
|
|
5328
5603
|
var afterAgentResponsePayloadSchema = event2("afterAgentResponse", {
|
|
5329
|
-
text:
|
|
5604
|
+
text: z21.string().optional(),
|
|
5330
5605
|
...usageFields
|
|
5331
5606
|
});
|
|
5332
5607
|
var afterAgentThoughtPayloadSchema = event2("afterAgentThought", {
|
|
5333
|
-
text:
|
|
5334
|
-
duration_ms:
|
|
5608
|
+
text: z21.string().optional(),
|
|
5609
|
+
duration_ms: z21.number().min(0).optional()
|
|
5335
5610
|
});
|
|
5336
5611
|
var preToolUsePayloadSchema3 = event2("preToolUse", {
|
|
5337
|
-
tool_name:
|
|
5338
|
-
tool_input:
|
|
5339
|
-
tool_use_id:
|
|
5340
|
-
agent_message:
|
|
5612
|
+
tool_name: z21.string().min(1),
|
|
5613
|
+
tool_input: z21.unknown().optional(),
|
|
5614
|
+
tool_use_id: z21.string().optional(),
|
|
5615
|
+
agent_message: z21.string().optional()
|
|
5341
5616
|
});
|
|
5342
5617
|
var postToolUsePayloadSchema3 = event2("postToolUse", {
|
|
5343
|
-
tool_name:
|
|
5344
|
-
tool_input:
|
|
5345
|
-
tool_output:
|
|
5346
|
-
tool_use_id:
|
|
5347
|
-
duration:
|
|
5618
|
+
tool_name: z21.string().min(1),
|
|
5619
|
+
tool_input: z21.unknown().optional(),
|
|
5620
|
+
tool_output: z21.unknown().optional(),
|
|
5621
|
+
tool_use_id: z21.string().optional(),
|
|
5622
|
+
duration: z21.number().min(0).optional()
|
|
5348
5623
|
});
|
|
5349
5624
|
var postToolUseFailurePayloadSchema2 = event2("postToolUseFailure", {
|
|
5350
|
-
tool_name:
|
|
5351
|
-
tool_input:
|
|
5352
|
-
tool_use_id:
|
|
5353
|
-
error_message:
|
|
5354
|
-
failure_type:
|
|
5355
|
-
duration:
|
|
5356
|
-
is_interrupt:
|
|
5625
|
+
tool_name: z21.string().min(1),
|
|
5626
|
+
tool_input: z21.unknown().optional(),
|
|
5627
|
+
tool_use_id: z21.string().optional(),
|
|
5628
|
+
error_message: z21.string().optional(),
|
|
5629
|
+
failure_type: z21.string().optional(),
|
|
5630
|
+
duration: z21.number().min(0).optional(),
|
|
5631
|
+
is_interrupt: z21.boolean().optional()
|
|
5357
5632
|
});
|
|
5358
5633
|
var beforeShellExecutionPayloadSchema = event2("beforeShellExecution", {
|
|
5359
|
-
command:
|
|
5360
|
-
sandbox:
|
|
5634
|
+
command: z21.string(),
|
|
5635
|
+
sandbox: z21.boolean().optional()
|
|
5361
5636
|
});
|
|
5362
5637
|
var afterShellExecutionPayloadSchema = event2("afterShellExecution", {
|
|
5363
|
-
command:
|
|
5364
|
-
output:
|
|
5365
|
-
duration:
|
|
5366
|
-
sandbox:
|
|
5638
|
+
command: z21.string(),
|
|
5639
|
+
output: z21.string().optional(),
|
|
5640
|
+
duration: z21.number().min(0).optional(),
|
|
5641
|
+
sandbox: z21.boolean().optional()
|
|
5367
5642
|
});
|
|
5368
5643
|
var beforeMcpExecutionPayloadSchema = event2("beforeMCPExecution", {
|
|
5369
|
-
tool_name:
|
|
5370
|
-
tool_input:
|
|
5371
|
-
url:
|
|
5372
|
-
command:
|
|
5644
|
+
tool_name: z21.string().min(1),
|
|
5645
|
+
tool_input: z21.unknown().optional(),
|
|
5646
|
+
url: z21.string().optional(),
|
|
5647
|
+
command: z21.string().optional()
|
|
5373
5648
|
});
|
|
5374
5649
|
var afterMcpExecutionPayloadSchema = event2("afterMCPExecution", {
|
|
5375
|
-
tool_name:
|
|
5376
|
-
tool_input:
|
|
5377
|
-
result_json:
|
|
5378
|
-
duration:
|
|
5650
|
+
tool_name: z21.string().min(1),
|
|
5651
|
+
tool_input: z21.unknown().optional(),
|
|
5652
|
+
result_json: z21.string().optional(),
|
|
5653
|
+
duration: z21.number().min(0).optional()
|
|
5379
5654
|
});
|
|
5380
5655
|
var beforeReadFilePayloadSchema = event2("beforeReadFile", {
|
|
5381
|
-
file_path:
|
|
5382
|
-
content:
|
|
5383
|
-
attachments:
|
|
5656
|
+
file_path: z21.string(),
|
|
5657
|
+
content: z21.string().optional(),
|
|
5658
|
+
attachments: z21.array(attachmentSchema).max(256).optional()
|
|
5384
5659
|
});
|
|
5385
5660
|
var afterFileEditPayloadSchema = event2("afterFileEdit", {
|
|
5386
|
-
file_path:
|
|
5387
|
-
edits:
|
|
5661
|
+
file_path: z21.string(),
|
|
5662
|
+
edits: z21.array(fileEditSchema).max(1024).optional()
|
|
5388
5663
|
});
|
|
5389
5664
|
var subagentStartPayloadSchema2 = event2("subagentStart", {
|
|
5390
|
-
subagent_id:
|
|
5391
|
-
subagent_type:
|
|
5392
|
-
task:
|
|
5393
|
-
parent_conversation_id:
|
|
5394
|
-
tool_call_id:
|
|
5395
|
-
subagent_model:
|
|
5396
|
-
is_parallel_worker:
|
|
5397
|
-
git_branch:
|
|
5665
|
+
subagent_id: z21.string().optional(),
|
|
5666
|
+
subagent_type: z21.string().optional(),
|
|
5667
|
+
task: z21.string().optional(),
|
|
5668
|
+
parent_conversation_id: z21.string().optional(),
|
|
5669
|
+
tool_call_id: z21.string().optional(),
|
|
5670
|
+
subagent_model: z21.string().optional(),
|
|
5671
|
+
is_parallel_worker: z21.boolean().optional(),
|
|
5672
|
+
git_branch: z21.string().optional()
|
|
5398
5673
|
});
|
|
5399
5674
|
var subagentStopPayloadSchema2 = event2("subagentStop", {
|
|
5400
|
-
subagent_type:
|
|
5401
|
-
status:
|
|
5402
|
-
task:
|
|
5403
|
-
description:
|
|
5404
|
-
summary:
|
|
5405
|
-
duration_ms:
|
|
5406
|
-
message_count:
|
|
5407
|
-
tool_call_count:
|
|
5408
|
-
loop_count:
|
|
5409
|
-
modified_files:
|
|
5410
|
-
agent_transcript_path:
|
|
5675
|
+
subagent_type: z21.string().optional(),
|
|
5676
|
+
status: z21.string().optional(),
|
|
5677
|
+
task: z21.string().optional(),
|
|
5678
|
+
description: z21.string().optional(),
|
|
5679
|
+
summary: z21.string().optional(),
|
|
5680
|
+
duration_ms: z21.number().min(0).optional(),
|
|
5681
|
+
message_count: z21.number().int().min(0).optional(),
|
|
5682
|
+
tool_call_count: z21.number().int().min(0).optional(),
|
|
5683
|
+
loop_count: z21.number().int().min(0).optional(),
|
|
5684
|
+
modified_files: z21.array(z21.string()).max(1024).optional(),
|
|
5685
|
+
agent_transcript_path: z21.string().nullish()
|
|
5411
5686
|
});
|
|
5412
5687
|
var preCompactPayloadSchema2 = event2("preCompact", {
|
|
5413
|
-
trigger:
|
|
5414
|
-
context_usage_percent:
|
|
5415
|
-
context_tokens:
|
|
5416
|
-
context_window_size:
|
|
5417
|
-
message_count:
|
|
5418
|
-
messages_to_compact:
|
|
5419
|
-
is_first_compaction:
|
|
5688
|
+
trigger: z21.string().optional(),
|
|
5689
|
+
context_usage_percent: z21.number().optional(),
|
|
5690
|
+
context_tokens: z21.number().int().min(0).optional(),
|
|
5691
|
+
context_window_size: z21.number().int().min(0).optional(),
|
|
5692
|
+
message_count: z21.number().int().min(0).optional(),
|
|
5693
|
+
messages_to_compact: z21.number().int().min(0).optional(),
|
|
5694
|
+
is_first_compaction: z21.boolean().optional()
|
|
5420
5695
|
});
|
|
5421
5696
|
var stopPayloadSchema3 = event2("stop", {
|
|
5422
|
-
status:
|
|
5423
|
-
loop_count:
|
|
5697
|
+
status: z21.string().optional(),
|
|
5698
|
+
loop_count: z21.number().int().min(0).optional(),
|
|
5424
5699
|
...usageFields
|
|
5425
5700
|
});
|
|
5426
|
-
var cursorPayloadSchema =
|
|
5701
|
+
var cursorPayloadSchema = z21.discriminatedUnion("hook_event_name", [
|
|
5427
5702
|
sessionStartPayloadSchema2,
|
|
5428
5703
|
sessionEndPayloadSchema2,
|
|
5429
5704
|
beforeSubmitPromptPayloadSchema,
|
|
@@ -6289,7 +6564,7 @@ var geminiCorrelationSeed = (input) => {
|
|
|
6289
6564
|
};
|
|
6290
6565
|
|
|
6291
6566
|
// src/providers/gemini/schema.ts
|
|
6292
|
-
import { z as
|
|
6567
|
+
import { z as z22 } from "zod";
|
|
6293
6568
|
var GEMINI_HOOK_EVENT_NAMES = [
|
|
6294
6569
|
"SessionStart",
|
|
6295
6570
|
"SessionEnd",
|
|
@@ -6303,113 +6578,113 @@ var GEMINI_HOOK_EVENT_NAMES = [
|
|
|
6303
6578
|
"PreCompress",
|
|
6304
6579
|
"Notification"
|
|
6305
6580
|
];
|
|
6306
|
-
var baseHookInputSchema =
|
|
6307
|
-
session_id:
|
|
6308
|
-
transcript_path:
|
|
6309
|
-
cwd:
|
|
6310
|
-
timestamp:
|
|
6311
|
-
});
|
|
6312
|
-
var llmMessageSchema =
|
|
6313
|
-
role:
|
|
6314
|
-
content:
|
|
6581
|
+
var baseHookInputSchema = z22.object({
|
|
6582
|
+
session_id: z22.string().min(1),
|
|
6583
|
+
transcript_path: z22.string().optional(),
|
|
6584
|
+
cwd: z22.string().optional(),
|
|
6585
|
+
timestamp: z22.string().min(1).optional()
|
|
6586
|
+
});
|
|
6587
|
+
var llmMessageSchema = z22.object({
|
|
6588
|
+
role: z22.enum(["user", "model", "system"]).optional(),
|
|
6589
|
+
content: z22.union([z22.string(), z22.array(z22.unknown())]).optional()
|
|
6315
6590
|
}).loose();
|
|
6316
|
-
var llmRequestConfigSchema =
|
|
6317
|
-
temperature:
|
|
6318
|
-
maxOutputTokens:
|
|
6591
|
+
var llmRequestConfigSchema = z22.object({
|
|
6592
|
+
temperature: z22.number().optional(),
|
|
6593
|
+
maxOutputTokens: z22.number().int().min(0).optional()
|
|
6319
6594
|
}).loose();
|
|
6320
|
-
var geminiLlmRequestSchema =
|
|
6321
|
-
model:
|
|
6322
|
-
messages:
|
|
6595
|
+
var geminiLlmRequestSchema = z22.object({
|
|
6596
|
+
model: z22.string().min(1).optional(),
|
|
6597
|
+
messages: z22.array(llmMessageSchema).optional(),
|
|
6323
6598
|
config: llmRequestConfigSchema.optional(),
|
|
6324
|
-
toolConfig:
|
|
6599
|
+
toolConfig: z22.unknown().optional()
|
|
6325
6600
|
}).loose();
|
|
6326
|
-
var geminiUsageMetadataSchema =
|
|
6327
|
-
promptTokenCount:
|
|
6328
|
-
cachedContentTokenCount:
|
|
6329
|
-
candidatesTokenCount:
|
|
6330
|
-
thoughtsTokenCount:
|
|
6331
|
-
totalTokenCount:
|
|
6601
|
+
var geminiUsageMetadataSchema = z22.object({
|
|
6602
|
+
promptTokenCount: z22.number().int().min(0).optional(),
|
|
6603
|
+
cachedContentTokenCount: z22.number().int().min(0).optional(),
|
|
6604
|
+
candidatesTokenCount: z22.number().int().min(0).optional(),
|
|
6605
|
+
thoughtsTokenCount: z22.number().int().min(0).optional(),
|
|
6606
|
+
totalTokenCount: z22.number().int().min(0).optional()
|
|
6332
6607
|
}).loose();
|
|
6333
|
-
var geminiCandidateSchema =
|
|
6334
|
-
content:
|
|
6335
|
-
role:
|
|
6336
|
-
parts:
|
|
6608
|
+
var geminiCandidateSchema = z22.object({
|
|
6609
|
+
content: z22.object({
|
|
6610
|
+
role: z22.string().optional(),
|
|
6611
|
+
parts: z22.array(z22.unknown()).optional()
|
|
6337
6612
|
}).loose().optional(),
|
|
6338
|
-
finishReason:
|
|
6339
|
-
index:
|
|
6613
|
+
finishReason: z22.string().optional(),
|
|
6614
|
+
index: z22.number().int().min(0).optional()
|
|
6340
6615
|
}).loose();
|
|
6341
|
-
var geminiLlmResponseSchema =
|
|
6616
|
+
var geminiLlmResponseSchema = z22.object({
|
|
6342
6617
|
/** Whole-response text, set by the translator from `getResponseText`. */
|
|
6343
|
-
text:
|
|
6344
|
-
candidates:
|
|
6618
|
+
text: z22.string().optional(),
|
|
6619
|
+
candidates: z22.array(geminiCandidateSchema).optional(),
|
|
6345
6620
|
usageMetadata: geminiUsageMetadataSchema.optional()
|
|
6346
6621
|
}).loose();
|
|
6347
|
-
var geminiMcpContextSchema =
|
|
6348
|
-
server_name:
|
|
6349
|
-
tool_name:
|
|
6622
|
+
var geminiMcpContextSchema = z22.object({
|
|
6623
|
+
server_name: z22.string().optional(),
|
|
6624
|
+
tool_name: z22.string().optional()
|
|
6350
6625
|
}).loose();
|
|
6351
|
-
var geminiToolResponseSchema =
|
|
6352
|
-
llmContent:
|
|
6353
|
-
returnDisplay:
|
|
6354
|
-
error:
|
|
6626
|
+
var geminiToolResponseSchema = z22.object({
|
|
6627
|
+
llmContent: z22.unknown().optional(),
|
|
6628
|
+
returnDisplay: z22.unknown().optional(),
|
|
6629
|
+
error: z22.unknown().optional()
|
|
6355
6630
|
}).loose();
|
|
6356
6631
|
var sessionStartInputSchema = baseHookInputSchema.extend({
|
|
6357
|
-
hook_event_name:
|
|
6358
|
-
source:
|
|
6632
|
+
hook_event_name: z22.literal("SessionStart"),
|
|
6633
|
+
source: z22.enum(["startup", "resume", "clear"]).optional()
|
|
6359
6634
|
});
|
|
6360
6635
|
var sessionEndInputSchema = baseHookInputSchema.extend({
|
|
6361
|
-
hook_event_name:
|
|
6362
|
-
reason:
|
|
6636
|
+
hook_event_name: z22.literal("SessionEnd"),
|
|
6637
|
+
reason: z22.enum(["exit", "clear", "logout", "prompt_input_exit", "other"]).optional()
|
|
6363
6638
|
});
|
|
6364
6639
|
var beforeAgentInputSchema = baseHookInputSchema.extend({
|
|
6365
|
-
hook_event_name:
|
|
6366
|
-
prompt:
|
|
6640
|
+
hook_event_name: z22.literal("BeforeAgent"),
|
|
6641
|
+
prompt: z22.string().optional()
|
|
6367
6642
|
});
|
|
6368
6643
|
var afterAgentInputSchema = baseHookInputSchema.extend({
|
|
6369
|
-
hook_event_name:
|
|
6370
|
-
prompt:
|
|
6371
|
-
prompt_response:
|
|
6372
|
-
stop_hook_active:
|
|
6644
|
+
hook_event_name: z22.literal("AfterAgent"),
|
|
6645
|
+
prompt: z22.string().optional(),
|
|
6646
|
+
prompt_response: z22.string().optional(),
|
|
6647
|
+
stop_hook_active: z22.boolean().optional()
|
|
6373
6648
|
});
|
|
6374
6649
|
var beforeModelInputSchema = baseHookInputSchema.extend({
|
|
6375
|
-
hook_event_name:
|
|
6650
|
+
hook_event_name: z22.literal("BeforeModel"),
|
|
6376
6651
|
llm_request: geminiLlmRequestSchema
|
|
6377
6652
|
});
|
|
6378
6653
|
var afterModelInputSchema = baseHookInputSchema.extend({
|
|
6379
|
-
hook_event_name:
|
|
6654
|
+
hook_event_name: z22.literal("AfterModel"),
|
|
6380
6655
|
llm_request: geminiLlmRequestSchema,
|
|
6381
6656
|
llm_response: geminiLlmResponseSchema
|
|
6382
6657
|
});
|
|
6383
6658
|
var beforeToolSelectionInputSchema = baseHookInputSchema.extend({
|
|
6384
|
-
hook_event_name:
|
|
6659
|
+
hook_event_name: z22.literal("BeforeToolSelection"),
|
|
6385
6660
|
llm_request: geminiLlmRequestSchema
|
|
6386
6661
|
});
|
|
6387
6662
|
var beforeToolInputSchema = baseHookInputSchema.extend({
|
|
6388
|
-
hook_event_name:
|
|
6389
|
-
tool_name:
|
|
6390
|
-
tool_input:
|
|
6663
|
+
hook_event_name: z22.literal("BeforeTool"),
|
|
6664
|
+
tool_name: z22.string().min(1),
|
|
6665
|
+
tool_input: z22.unknown().optional(),
|
|
6391
6666
|
mcp_context: geminiMcpContextSchema.optional(),
|
|
6392
|
-
original_request_name:
|
|
6667
|
+
original_request_name: z22.string().min(1).optional()
|
|
6393
6668
|
});
|
|
6394
6669
|
var afterToolInputSchema = baseHookInputSchema.extend({
|
|
6395
|
-
hook_event_name:
|
|
6396
|
-
tool_name:
|
|
6397
|
-
tool_input:
|
|
6670
|
+
hook_event_name: z22.literal("AfterTool"),
|
|
6671
|
+
tool_name: z22.string().min(1),
|
|
6672
|
+
tool_input: z22.unknown().optional(),
|
|
6398
6673
|
tool_response: geminiToolResponseSchema.optional(),
|
|
6399
6674
|
mcp_context: geminiMcpContextSchema.optional(),
|
|
6400
|
-
original_request_name:
|
|
6675
|
+
original_request_name: z22.string().min(1).optional()
|
|
6401
6676
|
});
|
|
6402
6677
|
var preCompressInputSchema = baseHookInputSchema.extend({
|
|
6403
|
-
hook_event_name:
|
|
6404
|
-
trigger:
|
|
6678
|
+
hook_event_name: z22.literal("PreCompress"),
|
|
6679
|
+
trigger: z22.enum(["auto", "manual"]).optional()
|
|
6405
6680
|
});
|
|
6406
6681
|
var notificationInputSchema = baseHookInputSchema.extend({
|
|
6407
|
-
hook_event_name:
|
|
6408
|
-
notification_type:
|
|
6409
|
-
message:
|
|
6410
|
-
details:
|
|
6682
|
+
hook_event_name: z22.literal("Notification"),
|
|
6683
|
+
notification_type: z22.string().optional(),
|
|
6684
|
+
message: z22.string().optional(),
|
|
6685
|
+
details: z22.unknown().optional()
|
|
6411
6686
|
});
|
|
6412
|
-
var geminiHookInputSchema =
|
|
6687
|
+
var geminiHookInputSchema = z22.discriminatedUnion("hook_event_name", [
|
|
6413
6688
|
sessionStartInputSchema,
|
|
6414
6689
|
sessionEndInputSchema,
|
|
6415
6690
|
beforeAgentInputSchema,
|
|
@@ -7446,8 +7721,64 @@ var createFilesystemStateStore = (options) => {
|
|
|
7446
7721
|
|
|
7447
7722
|
// src/telemetry/spool-queue.ts
|
|
7448
7723
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
7449
|
-
import { mkdir as mkdir2, readFile as readFile3, readdir as readdir2, rename as rename2, unlink as unlink2, writeFile as writeFile2 } from "fs/promises";
|
|
7724
|
+
import { mkdir as mkdir2, readFile as readFile3, readdir as readdir2, rename as rename2, stat, unlink as unlink2, writeFile as writeFile2 } from "fs/promises";
|
|
7450
7725
|
import * as path3 from "path";
|
|
7726
|
+
var EMPTY_SPOOL_DROP_COUNTS = Object.freeze({
|
|
7727
|
+
total: 0,
|
|
7728
|
+
age: 0,
|
|
7729
|
+
size: 0,
|
|
7730
|
+
count: 0,
|
|
7731
|
+
rejected: 0
|
|
7732
|
+
});
|
|
7733
|
+
var SPOOL_DROPS_FILE = ".drops";
|
|
7734
|
+
var enqueuedAtOf = (fileName) => {
|
|
7735
|
+
const match = /^(\d{16})-/.exec(fileName);
|
|
7736
|
+
return match?.[1] === void 0 ? void 0 : Number(match[1]);
|
|
7737
|
+
};
|
|
7738
|
+
var isCount = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
7739
|
+
var readSpoolDropCounts = async (queueDir) => {
|
|
7740
|
+
try {
|
|
7741
|
+
const parsed = JSON.parse(await readFile3(path3.join(queueDir, SPOOL_DROPS_FILE), "utf8"));
|
|
7742
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
7743
|
+
return EMPTY_SPOOL_DROP_COUNTS;
|
|
7744
|
+
}
|
|
7745
|
+
const record = parsed;
|
|
7746
|
+
const field = (name) => isCount(record[name]) ? record[name] : 0;
|
|
7747
|
+
return {
|
|
7748
|
+
total: field("total"),
|
|
7749
|
+
age: field("age"),
|
|
7750
|
+
size: field("size"),
|
|
7751
|
+
count: field("count"),
|
|
7752
|
+
rejected: field("rejected"),
|
|
7753
|
+
...isCount(record.lastDroppedAt) ? { lastDroppedAt: record.lastDroppedAt } : {}
|
|
7754
|
+
};
|
|
7755
|
+
} catch {
|
|
7756
|
+
return EMPTY_SPOOL_DROP_COUNTS;
|
|
7757
|
+
}
|
|
7758
|
+
};
|
|
7759
|
+
var readSpoolQueueStats = async (queueDir) => {
|
|
7760
|
+
let entries;
|
|
7761
|
+
try {
|
|
7762
|
+
entries = await readdir2(queueDir);
|
|
7763
|
+
} catch {
|
|
7764
|
+
return { batches: 0, bytes: 0, dropped: await readSpoolDropCounts(queueDir) };
|
|
7765
|
+
}
|
|
7766
|
+
const files = entries.filter((entry) => entry.endsWith(".json") && !entry.startsWith(".tmp-")).sort();
|
|
7767
|
+
let bytes = 0;
|
|
7768
|
+
for (const file of files) {
|
|
7769
|
+
try {
|
|
7770
|
+
bytes += (await stat(path3.join(queueDir, file))).size;
|
|
7771
|
+
} catch {
|
|
7772
|
+
}
|
|
7773
|
+
}
|
|
7774
|
+
const oldest = files[0] === void 0 ? void 0 : enqueuedAtOf(files[0]);
|
|
7775
|
+
return {
|
|
7776
|
+
batches: files.length,
|
|
7777
|
+
bytes,
|
|
7778
|
+
...oldest === void 0 ? {} : { oldestEnqueuedAt: oldest },
|
|
7779
|
+
dropped: await readSpoolDropCounts(queueDir)
|
|
7780
|
+
};
|
|
7781
|
+
};
|
|
7451
7782
|
var DEFAULT_DRAIN_MAX_BATCHES = 20;
|
|
7452
7783
|
var isErrnoException2 = (thrown, code) => thrown instanceof Error && thrown.code === code;
|
|
7453
7784
|
var createSpoolQueue = (options) => {
|
|
@@ -7488,27 +7819,132 @@ var createSpoolQueue = (options) => {
|
|
|
7488
7819
|
}
|
|
7489
7820
|
return entries.filter((entry) => entry.endsWith(".json") && !entry.startsWith(".tmp-")).sort();
|
|
7490
7821
|
};
|
|
7822
|
+
const recordDrops = async (reason, dropped) => {
|
|
7823
|
+
if (dropped <= 0) {
|
|
7824
|
+
return;
|
|
7825
|
+
}
|
|
7826
|
+
try {
|
|
7827
|
+
const current = await readSpoolDropCounts(queueDir);
|
|
7828
|
+
const next = {
|
|
7829
|
+
...current,
|
|
7830
|
+
total: current.total + dropped,
|
|
7831
|
+
[reason]: current[reason] + dropped,
|
|
7832
|
+
lastDroppedAt: options.clock.now()
|
|
7833
|
+
};
|
|
7834
|
+
const tmp = path3.join(queueDir, `.tmp-${randomBytes2(6).toString("hex")}.drops`);
|
|
7835
|
+
await writeFile2(tmp, JSON.stringify(next), "utf8");
|
|
7836
|
+
await rename2(tmp, path3.join(queueDir, SPOOL_DROPS_FILE));
|
|
7837
|
+
} catch {
|
|
7838
|
+
}
|
|
7839
|
+
options.logger?.warn("durable spool dropped batches", {
|
|
7840
|
+
"spool.queue": options.queueName,
|
|
7841
|
+
"spool.drop_reason": reason,
|
|
7842
|
+
"spool.dropped": dropped
|
|
7843
|
+
});
|
|
7844
|
+
};
|
|
7845
|
+
const listWithSizes = async () => {
|
|
7846
|
+
const names = await listSorted();
|
|
7847
|
+
const files = [];
|
|
7848
|
+
for (const name of names) {
|
|
7849
|
+
let bytes = 0;
|
|
7850
|
+
if (options.maxBytes !== void 0) {
|
|
7851
|
+
try {
|
|
7852
|
+
bytes = (await stat(path3.join(queueDir, name))).size;
|
|
7853
|
+
} catch {
|
|
7854
|
+
continue;
|
|
7855
|
+
}
|
|
7856
|
+
}
|
|
7857
|
+
const enqueuedAt = enqueuedAtOf(name);
|
|
7858
|
+
files.push({ name, bytes, ...enqueuedAt === void 0 ? {} : { enqueuedAt } });
|
|
7859
|
+
}
|
|
7860
|
+
return files;
|
|
7861
|
+
};
|
|
7862
|
+
const evict = async (files) => {
|
|
7863
|
+
let removed = 0;
|
|
7864
|
+
for (const file of files) {
|
|
7865
|
+
try {
|
|
7866
|
+
await unlink2(path3.join(queueDir, file.name));
|
|
7867
|
+
removed += 1;
|
|
7868
|
+
} catch {
|
|
7869
|
+
}
|
|
7870
|
+
}
|
|
7871
|
+
return removed;
|
|
7872
|
+
};
|
|
7873
|
+
const isExpired = (file, now) => options.maxAgeMillis !== void 0 && file.enqueuedAt !== void 0 && now - file.enqueuedAt > options.maxAgeMillis;
|
|
7491
7874
|
const enqueue = async (batch) => {
|
|
7492
7875
|
await ensureDirs();
|
|
7493
|
-
const
|
|
7494
|
-
|
|
7876
|
+
const serialized = JSON.stringify(batch);
|
|
7877
|
+
const bytes = Buffer.byteLength(serialized, "utf8");
|
|
7878
|
+
const refuse = async (reason) => {
|
|
7495
7879
|
options.logger?.warn("durable spool at capacity; batch dropped", {
|
|
7496
7880
|
"spool.max_files": options.maxFiles,
|
|
7881
|
+
...options.maxBytes === void 0 ? {} : { "spool.max_bytes": options.maxBytes },
|
|
7497
7882
|
"spool.queue": options.queueName
|
|
7498
7883
|
});
|
|
7884
|
+
await recordDrops(reason, 1);
|
|
7499
7885
|
return { spooled: false, reason: "capacity-exceeded" };
|
|
7886
|
+
};
|
|
7887
|
+
if (options.maxBytes !== void 0 && bytes > options.maxBytes) {
|
|
7888
|
+
return refuse("size");
|
|
7500
7889
|
}
|
|
7501
|
-
|
|
7890
|
+
let queued = await listWithSizes();
|
|
7891
|
+
const now = options.clock.now();
|
|
7892
|
+
const expired = queued.filter((file) => isExpired(file, now));
|
|
7893
|
+
if (expired.length > 0) {
|
|
7894
|
+
await recordDrops("age", await evict(expired));
|
|
7895
|
+
queued = queued.filter((file) => !isExpired(file, now));
|
|
7896
|
+
}
|
|
7897
|
+
const overflow = options.overflow ?? "refuse-new";
|
|
7898
|
+
const totalBytes = () => queued.reduce((sum, file) => sum + file.bytes, 0);
|
|
7899
|
+
if (overflow === "refuse-new") {
|
|
7900
|
+
if (queued.length >= options.maxFiles) {
|
|
7901
|
+
return refuse("count");
|
|
7902
|
+
}
|
|
7903
|
+
if (options.maxBytes !== void 0 && totalBytes() + bytes > options.maxBytes) {
|
|
7904
|
+
return refuse("size");
|
|
7905
|
+
}
|
|
7906
|
+
} else {
|
|
7907
|
+
const overCount = Math.max(0, queued.length + 1 - options.maxFiles);
|
|
7908
|
+
if (overCount > 0) {
|
|
7909
|
+
await recordDrops("count", await evict(queued.slice(0, overCount)));
|
|
7910
|
+
queued = queued.slice(overCount);
|
|
7911
|
+
}
|
|
7912
|
+
if (options.maxBytes !== void 0) {
|
|
7913
|
+
let excess = totalBytes() + bytes - options.maxBytes;
|
|
7914
|
+
let cut = 0;
|
|
7915
|
+
while (excess > 0 && cut < queued.length) {
|
|
7916
|
+
excess -= queued[cut]?.bytes ?? 0;
|
|
7917
|
+
cut += 1;
|
|
7918
|
+
}
|
|
7919
|
+
if (cut > 0) {
|
|
7920
|
+
await recordDrops("size", await evict(queued.slice(0, cut)));
|
|
7921
|
+
queued = queued.slice(cut);
|
|
7922
|
+
}
|
|
7923
|
+
}
|
|
7924
|
+
}
|
|
7925
|
+
const fileName = `${String(now).padStart(16, "0")}-${randomBytes2(6).toString("hex")}.json`;
|
|
7502
7926
|
const target = path3.join(queueDir, fileName);
|
|
7503
7927
|
const tmp = path3.join(queueDir, `.tmp-${randomBytes2(6).toString("hex")}.json`);
|
|
7504
|
-
await writeFile2(tmp,
|
|
7928
|
+
await writeFile2(tmp, serialized, "utf8");
|
|
7505
7929
|
await rename2(tmp, target);
|
|
7506
7930
|
return { spooled: true };
|
|
7507
7931
|
};
|
|
7508
7932
|
const drain = async (send, drainOptions) => {
|
|
7509
7933
|
await ensureDirs();
|
|
7510
7934
|
const cap = drainOptions?.maxBatches ?? DEFAULT_DRAIN_MAX_BATCHES;
|
|
7511
|
-
|
|
7935
|
+
let files = await listSorted();
|
|
7936
|
+
if (options.maxAgeMillis !== void 0) {
|
|
7937
|
+
const now = options.clock.now();
|
|
7938
|
+
const expired = files.map((name) => {
|
|
7939
|
+
const enqueuedAt = enqueuedAtOf(name);
|
|
7940
|
+
return { name, bytes: 0, ...enqueuedAt === void 0 ? {} : { enqueuedAt } };
|
|
7941
|
+
}).filter((file) => isExpired(file, now));
|
|
7942
|
+
if (expired.length > 0) {
|
|
7943
|
+
await recordDrops("age", await evict(expired));
|
|
7944
|
+
const gone = new Set(expired.map((file) => file.name));
|
|
7945
|
+
files = files.filter((name) => !gone.has(name));
|
|
7946
|
+
}
|
|
7947
|
+
}
|
|
7512
7948
|
let drained = 0;
|
|
7513
7949
|
let failed = 0;
|
|
7514
7950
|
let quarantined = 0;
|
|
@@ -7553,6 +7989,12 @@ var createSpoolQueue = (options) => {
|
|
|
7553
7989
|
} catch {
|
|
7554
7990
|
delivered = false;
|
|
7555
7991
|
}
|
|
7992
|
+
if (delivered === "discard") {
|
|
7993
|
+
if (await unlink2(filePath).then(() => true, () => false)) {
|
|
7994
|
+
await recordDrops("rejected", 1);
|
|
7995
|
+
}
|
|
7996
|
+
continue;
|
|
7997
|
+
}
|
|
7556
7998
|
if (delivered) {
|
|
7557
7999
|
await unlink2(filePath).catch(() => void 0);
|
|
7558
8000
|
drained += 1;
|
|
@@ -7570,7 +8012,8 @@ var createSpoolQueue = (options) => {
|
|
|
7570
8012
|
size: async () => {
|
|
7571
8013
|
await ensureDirs();
|
|
7572
8014
|
return (await listSorted()).length;
|
|
7573
|
-
}
|
|
8015
|
+
},
|
|
8016
|
+
stats: () => readSpoolQueueStats(queueDir)
|
|
7574
8017
|
};
|
|
7575
8018
|
};
|
|
7576
8019
|
|
|
@@ -7669,7 +8112,10 @@ var createFileDurableLogSpool = (options) => createSpoolQueue({
|
|
|
7669
8112
|
clock: options.clock,
|
|
7670
8113
|
...options.logger === void 0 ? {} : { logger: options.logger },
|
|
7671
8114
|
maxFiles: options.maxSpoolFiles ?? DEFAULT_MAX_LOG_SPOOL_FILES,
|
|
7672
|
-
queueName: "spool-logs",
|
|
8115
|
+
queueName: options.queueName ?? "spool-logs",
|
|
8116
|
+
...options.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes },
|
|
8117
|
+
...options.maxAgeMillis === void 0 ? {} : { maxAgeMillis: options.maxAgeMillis },
|
|
8118
|
+
...options.overflow === void 0 ? {} : { overflow: options.overflow },
|
|
7673
8119
|
validate: validateLogSpoolBatch
|
|
7674
8120
|
});
|
|
7675
8121
|
|
|
@@ -7761,7 +8207,10 @@ var createFileDurableSpool = (options) => createSpoolQueue({
|
|
|
7761
8207
|
clock: options.clock,
|
|
7762
8208
|
...options.logger === void 0 ? {} : { logger: options.logger },
|
|
7763
8209
|
maxFiles: options.maxSpoolFiles ?? DEFAULT_MAX_SPOOL_FILES,
|
|
7764
|
-
queueName: "spool",
|
|
8210
|
+
queueName: options.queueName ?? "spool",
|
|
8211
|
+
...options.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes },
|
|
8212
|
+
...options.maxAgeMillis === void 0 ? {} : { maxAgeMillis: options.maxAgeMillis },
|
|
8213
|
+
...options.overflow === void 0 ? {} : { overflow: options.overflow },
|
|
7765
8214
|
validate: validateSpoolBatch
|
|
7766
8215
|
});
|
|
7767
8216
|
|
|
@@ -7771,6 +8220,13 @@ import { ExportResultCode } from "@opentelemetry/core";
|
|
|
7771
8220
|
import { millisToHrTime as millisToHrTime3 } from "@opentelemetry/core";
|
|
7772
8221
|
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-proto";
|
|
7773
8222
|
|
|
8223
|
+
// src/telemetry/export-failure.ts
|
|
8224
|
+
var RETRYABLE_HTTP_STATUSES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
|
|
8225
|
+
var isPermanentExportFailure = (result) => {
|
|
8226
|
+
const code = result.error?.code;
|
|
8227
|
+
return typeof code === "number" && Number.isInteger(code) && code >= 400 && code < 600 && !RETRYABLE_HTTP_STATUSES.has(code);
|
|
8228
|
+
};
|
|
8229
|
+
|
|
7774
8230
|
// src/telemetry/exporter-resource.ts
|
|
7775
8231
|
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
7776
8232
|
var resourceFromExporterPolicy = (policy) => resourceFromAttributes({
|
|
@@ -7927,7 +8383,7 @@ import {
|
|
|
7927
8383
|
} from "@opentelemetry/semantic-conventions/incubating";
|
|
7928
8384
|
|
|
7929
8385
|
// src/version.ts
|
|
7930
|
-
var VERSION = "0.
|
|
8386
|
+
var VERSION = "0.9.0";
|
|
7931
8387
|
|
|
7932
8388
|
// src/telemetry/semconv.ts
|
|
7933
8389
|
var SCOPE_NAME = "@osfactory/otel-hook";
|
|
@@ -8884,8 +9340,11 @@ var chunk = (items, size) => {
|
|
|
8884
9340
|
}
|
|
8885
9341
|
return chunks;
|
|
8886
9342
|
};
|
|
8887
|
-
var createDisabledSink = () => {
|
|
8888
|
-
const health = createHealthTracker(
|
|
9343
|
+
var createDisabledSink = (destination) => {
|
|
9344
|
+
const health = createHealthTracker(
|
|
9345
|
+
"telemetry-log-sink",
|
|
9346
|
+
destination === void 0 ? {} : { destination }
|
|
9347
|
+
);
|
|
8889
9348
|
return {
|
|
8890
9349
|
emit: (events) => {
|
|
8891
9350
|
health.recordSuccess(events.length);
|
|
@@ -8924,19 +9383,24 @@ var DISABLED_DETAIL = Object.freeze({
|
|
|
8924
9383
|
"no-endpoint": "otlp log sink disabled: no logs endpoint configured and none could be derived"
|
|
8925
9384
|
});
|
|
8926
9385
|
var createOtlpLogSink = (options) => {
|
|
9386
|
+
const destinationFields = options.destination === void 0 ? {} : { "export.destination": options.destination };
|
|
8927
9387
|
const deliverability = describeLogsDeliverability(options.exporter);
|
|
8928
9388
|
if (deliverability.status === "disabled") {
|
|
8929
9389
|
if (deliverability.reason !== "logs-disabled") {
|
|
8930
9390
|
options.logger?.warn(DISABLED_DETAIL[deliverability.reason], {
|
|
8931
|
-
"exporter.protocol": options.exporter.protocol
|
|
9391
|
+
"exporter.protocol": options.exporter.protocol,
|
|
9392
|
+
...destinationFields
|
|
8932
9393
|
});
|
|
8933
9394
|
}
|
|
8934
|
-
return createDisabledSink();
|
|
9395
|
+
return createDisabledSink(options.destination);
|
|
8935
9396
|
}
|
|
8936
9397
|
const scope = options.instrumentationScope ?? DEFAULT_INSTRUMENTATION_SCOPE;
|
|
8937
9398
|
const resource = resourceFromExporterPolicy(options.exporter);
|
|
8938
9399
|
const content = options.content ?? NO_LOG_CONTENT;
|
|
8939
|
-
const health = createHealthTracker(
|
|
9400
|
+
const health = createHealthTracker(
|
|
9401
|
+
"telemetry-log-sink",
|
|
9402
|
+
options.destination === void 0 ? {} : { destination: options.destination }
|
|
9403
|
+
);
|
|
8940
9404
|
const exporter = new OTLPLogExporter({
|
|
8941
9405
|
url: deliverability.endpoint,
|
|
8942
9406
|
headers: { ...options.headers },
|
|
@@ -8963,7 +9427,10 @@ var createOtlpLogSink = (options) => {
|
|
|
8963
9427
|
(record) => deserializeRecord(record, batchResource, batch.instrumentationScope)
|
|
8964
9428
|
);
|
|
8965
9429
|
const result = await exportRecords(records);
|
|
8966
|
-
|
|
9430
|
+
if (result.code === ExportResultCode.SUCCESS) {
|
|
9431
|
+
return true;
|
|
9432
|
+
}
|
|
9433
|
+
return isPermanentExportFailure(result) ? "discard" : false;
|
|
8967
9434
|
};
|
|
8968
9435
|
const resolveCorrelations = async (events) => {
|
|
8969
9436
|
if (options.correlate === void 0) {
|
|
@@ -9015,13 +9482,18 @@ var createOtlpLogSink = (options) => {
|
|
|
9015
9482
|
continue;
|
|
9016
9483
|
}
|
|
9017
9484
|
health.recordFailure("telemetry-export-failure", batch.length, options.clock.now());
|
|
9018
|
-
|
|
9485
|
+
const permanent = isPermanentExportFailure(result);
|
|
9486
|
+
if (options.spool !== void 0 && !permanent) {
|
|
9019
9487
|
const spoolResult = await options.spool.enqueue(toSpoolBatch(batch)).catch(() => ({
|
|
9020
9488
|
spooled: false,
|
|
9021
9489
|
reason: "capacity-exceeded"
|
|
9022
9490
|
}));
|
|
9023
9491
|
if (spoolResult.spooled) {
|
|
9024
9492
|
accepted += batch.length;
|
|
9493
|
+
options.logger?.warn("log record batch not delivered; spooled for the next invocation", {
|
|
9494
|
+
"export.batch_size": batch.length,
|
|
9495
|
+
...destinationFields
|
|
9496
|
+
});
|
|
9025
9497
|
continue;
|
|
9026
9498
|
}
|
|
9027
9499
|
}
|
|
@@ -9030,8 +9502,12 @@ var createOtlpLogSink = (options) => {
|
|
|
9030
9502
|
createErrorInfo({
|
|
9031
9503
|
code: "telemetry-export-failure",
|
|
9032
9504
|
phase: "export",
|
|
9033
|
-
detail: "collector rejected or was unreachable for a log record batch",
|
|
9034
|
-
details: {
|
|
9505
|
+
detail: permanent ? "collector refused a log record batch with a non-retryable status" : "collector rejected or was unreachable for a log record batch",
|
|
9506
|
+
details: {
|
|
9507
|
+
"export.batch_size": batch.length,
|
|
9508
|
+
"export.signal": "logs",
|
|
9509
|
+
...destinationFields
|
|
9510
|
+
}
|
|
9035
9511
|
})
|
|
9036
9512
|
);
|
|
9037
9513
|
}
|
|
@@ -9114,8 +9590,11 @@ var deserializeSpan = (serialized, resource, scope) => assembleReadableSpan({
|
|
|
9114
9590
|
resource,
|
|
9115
9591
|
instrumentationScope: scope
|
|
9116
9592
|
});
|
|
9117
|
-
var createDisabledSink2 = () => {
|
|
9118
|
-
const health = createHealthTracker(
|
|
9593
|
+
var createDisabledSink2 = (destination) => {
|
|
9594
|
+
const health = createHealthTracker(
|
|
9595
|
+
"telemetry-sink",
|
|
9596
|
+
destination === void 0 ? {} : { destination }
|
|
9597
|
+
);
|
|
9119
9598
|
return {
|
|
9120
9599
|
emit: (events) => {
|
|
9121
9600
|
health.recordSuccess(events.length);
|
|
@@ -9128,22 +9607,27 @@ var createDisabledSink2 = () => {
|
|
|
9128
9607
|
};
|
|
9129
9608
|
};
|
|
9130
9609
|
var createOtlpTraceSink = (options) => {
|
|
9610
|
+
const destinationFields = options.destination === void 0 ? {} : { "export.destination": options.destination };
|
|
9131
9611
|
if (!options.exporter.enabled || options.exporter.protocol === "none") {
|
|
9132
|
-
return createDisabledSink2();
|
|
9612
|
+
return createDisabledSink2(options.destination);
|
|
9133
9613
|
}
|
|
9134
9614
|
if (options.exporter.endpoint === void 0) {
|
|
9135
|
-
options.logger?.warn("otlp sink disabled: no endpoint configured",
|
|
9136
|
-
return createDisabledSink2();
|
|
9615
|
+
options.logger?.warn("otlp sink disabled: no endpoint configured", destinationFields);
|
|
9616
|
+
return createDisabledSink2(options.destination);
|
|
9137
9617
|
}
|
|
9138
9618
|
if (options.exporter.protocol !== "http/protobuf") {
|
|
9139
9619
|
options.logger?.warn("otlp sink: protocol not supported by this build, falling back to disabled", {
|
|
9140
|
-
"exporter.protocol": options.exporter.protocol
|
|
9620
|
+
"exporter.protocol": options.exporter.protocol,
|
|
9621
|
+
...destinationFields
|
|
9141
9622
|
});
|
|
9142
|
-
return createDisabledSink2();
|
|
9623
|
+
return createDisabledSink2(options.destination);
|
|
9143
9624
|
}
|
|
9144
9625
|
const scope = options.instrumentationScope ?? DEFAULT_INSTRUMENTATION_SCOPE;
|
|
9145
9626
|
const resource = resourceFromExporterPolicy(options.exporter);
|
|
9146
|
-
const health = createHealthTracker(
|
|
9627
|
+
const health = createHealthTracker(
|
|
9628
|
+
"telemetry-sink",
|
|
9629
|
+
options.destination === void 0 ? {} : { destination: options.destination }
|
|
9630
|
+
);
|
|
9147
9631
|
const exporter = new OTLPTraceExporter({
|
|
9148
9632
|
url: options.exporter.endpoint,
|
|
9149
9633
|
headers: { ...options.headers },
|
|
@@ -9165,7 +9649,10 @@ var createOtlpTraceSink = (options) => {
|
|
|
9165
9649
|
const batchResource = replayResource(batch.resourceAttributes, options.exporter);
|
|
9166
9650
|
const spans = batch.spans.map((span) => deserializeSpan(span, batchResource, batch.instrumentationScope));
|
|
9167
9651
|
const result = await exportSpans(spans);
|
|
9168
|
-
|
|
9652
|
+
if (result.code === ExportResultCode2.SUCCESS) {
|
|
9653
|
+
return true;
|
|
9654
|
+
}
|
|
9655
|
+
return isPermanentExportFailure(result) ? "discard" : false;
|
|
9169
9656
|
};
|
|
9170
9657
|
const resolveCorrelations = async (events) => {
|
|
9171
9658
|
if (options.correlate === void 0) {
|
|
@@ -9193,6 +9680,9 @@ var createOtlpTraceSink = (options) => {
|
|
|
9193
9680
|
let accepted = 0;
|
|
9194
9681
|
let rejected = 0;
|
|
9195
9682
|
for (const batch of chunk2(spans, options.exporter.maxBatchSize)) {
|
|
9683
|
+
if (batch.length === 0) {
|
|
9684
|
+
continue;
|
|
9685
|
+
}
|
|
9196
9686
|
let result;
|
|
9197
9687
|
try {
|
|
9198
9688
|
result = await exportSpans(batch);
|
|
@@ -9205,13 +9695,18 @@ var createOtlpTraceSink = (options) => {
|
|
|
9205
9695
|
continue;
|
|
9206
9696
|
}
|
|
9207
9697
|
health.recordFailure("telemetry-export-failure", batch.length, options.clock.now());
|
|
9208
|
-
|
|
9698
|
+
const permanent = isPermanentExportFailure(result);
|
|
9699
|
+
if (options.spool !== void 0 && !permanent) {
|
|
9209
9700
|
const spoolResult = await options.spool.enqueue(toSpoolBatch(batch)).catch(() => ({
|
|
9210
9701
|
spooled: false,
|
|
9211
9702
|
reason: "capacity-exceeded"
|
|
9212
9703
|
}));
|
|
9213
9704
|
if (spoolResult.spooled) {
|
|
9214
9705
|
accepted += batch.length;
|
|
9706
|
+
options.logger?.warn("span batch not delivered; spooled for the next invocation", {
|
|
9707
|
+
"export.batch_size": batch.length,
|
|
9708
|
+
...destinationFields
|
|
9709
|
+
});
|
|
9215
9710
|
continue;
|
|
9216
9711
|
}
|
|
9217
9712
|
}
|
|
@@ -9220,8 +9715,8 @@ var createOtlpTraceSink = (options) => {
|
|
|
9220
9715
|
createErrorInfo({
|
|
9221
9716
|
code: "telemetry-export-failure",
|
|
9222
9717
|
phase: "export",
|
|
9223
|
-
detail: "collector rejected or was unreachable for a span batch",
|
|
9224
|
-
details: { "export.batch_size": batch.length }
|
|
9718
|
+
detail: permanent ? "collector refused a span batch with a non-retryable status" : "collector rejected or was unreachable for a span batch",
|
|
9719
|
+
details: { "export.batch_size": batch.length, ...destinationFields }
|
|
9225
9720
|
})
|
|
9226
9721
|
);
|
|
9227
9722
|
}
|
|
@@ -9264,6 +9759,214 @@ var createOtlpTraceSink = (options) => {
|
|
|
9264
9759
|
};
|
|
9265
9760
|
};
|
|
9266
9761
|
|
|
9762
|
+
// src/telemetry/signal-fanout.ts
|
|
9763
|
+
var createSignalFanout = (options) => {
|
|
9764
|
+
const emit = async (events) => {
|
|
9765
|
+
const traces = await options.traces.emit(events);
|
|
9766
|
+
const logs = await options.logs.emit(events);
|
|
9767
|
+
const errors = [...traces.errors, ...logs.errors];
|
|
9768
|
+
return {
|
|
9769
|
+
accepted: traces.accepted + logs.accepted,
|
|
9770
|
+
rejected: traces.rejected + logs.rejected,
|
|
9771
|
+
errors
|
|
9772
|
+
};
|
|
9773
|
+
};
|
|
9774
|
+
const flush = async () => {
|
|
9775
|
+
await options.traces.flush().catch(() => void 0);
|
|
9776
|
+
await options.logs.flush().catch(() => void 0);
|
|
9777
|
+
};
|
|
9778
|
+
const shutdown = async () => {
|
|
9779
|
+
await options.traces.shutdown().catch(() => void 0);
|
|
9780
|
+
await options.logs.shutdown().catch(() => void 0);
|
|
9781
|
+
};
|
|
9782
|
+
return {
|
|
9783
|
+
emit,
|
|
9784
|
+
flush,
|
|
9785
|
+
shutdown,
|
|
9786
|
+
health: () => [
|
|
9787
|
+
options.traces.health(),
|
|
9788
|
+
options.logs.health()
|
|
9789
|
+
]
|
|
9790
|
+
};
|
|
9791
|
+
};
|
|
9792
|
+
var shareCorrelationPerBatch = (correlate) => {
|
|
9793
|
+
let pending;
|
|
9794
|
+
return (events) => {
|
|
9795
|
+
if (pending?.events === events) {
|
|
9796
|
+
return pending.result;
|
|
9797
|
+
}
|
|
9798
|
+
const result = correlate(events);
|
|
9799
|
+
pending = { events, result };
|
|
9800
|
+
return result;
|
|
9801
|
+
};
|
|
9802
|
+
};
|
|
9803
|
+
|
|
9804
|
+
// src/telemetry/export-destinations.ts
|
|
9805
|
+
var spoolQueueNamesFor = (destination) => destination === DEFAULT_DESTINATION_NAME ? { traces: "spool", logs: "spool-logs" } : { traces: `destinations/${destination}/spool`, logs: `destinations/${destination}/spool-logs` };
|
|
9806
|
+
var exporterPolicyForDestination = (exporter, destination) => {
|
|
9807
|
+
if (destination.source === "exporter") {
|
|
9808
|
+
return exporter;
|
|
9809
|
+
}
|
|
9810
|
+
const { destinations, endpoint, logs, ...shared } = exporter;
|
|
9811
|
+
void destinations;
|
|
9812
|
+
void endpoint;
|
|
9813
|
+
const tracesEndpoint = destination.tracesEndpoint ?? destination.endpoint;
|
|
9814
|
+
const derivedLogs = destination.logsEndpoint ?? (destination.endpoint === void 0 ? void 0 : (() => {
|
|
9815
|
+
const derived = resolveLogsEndpoint({
|
|
9816
|
+
...exporter,
|
|
9817
|
+
endpoint: destination.endpoint,
|
|
9818
|
+
logs: { enabled: true, includeContent: false, maxBatchSize: logs.maxBatchSize }
|
|
9819
|
+
});
|
|
9820
|
+
return "endpoint" in derived ? derived.endpoint : void 0;
|
|
9821
|
+
})());
|
|
9822
|
+
return {
|
|
9823
|
+
...shared,
|
|
9824
|
+
protocol: destination.protocol,
|
|
9825
|
+
...tracesEndpoint === void 0 ? {} : { endpoint: tracesEndpoint },
|
|
9826
|
+
headerNames: Object.keys(destination.headers).sort(),
|
|
9827
|
+
logs: {
|
|
9828
|
+
...logs,
|
|
9829
|
+
enabled: destination.signals.logs,
|
|
9830
|
+
...derivedLogs === void 0 ? {} : { endpoint: derivedLogs }
|
|
9831
|
+
}
|
|
9832
|
+
};
|
|
9833
|
+
};
|
|
9834
|
+
var createOptedOutTraceSink = (destination) => {
|
|
9835
|
+
const health = createHealthTracker(
|
|
9836
|
+
"telemetry-sink",
|
|
9837
|
+
destination === void 0 ? {} : { destination }
|
|
9838
|
+
);
|
|
9839
|
+
return {
|
|
9840
|
+
emit: () => Promise.resolve({ accepted: 0, rejected: 0, errors: [] }),
|
|
9841
|
+
flush: () => Promise.resolve(),
|
|
9842
|
+
shutdown: () => Promise.resolve(),
|
|
9843
|
+
health: () => health.snapshot(),
|
|
9844
|
+
drainSpool: () => Promise.resolve({ drained: 0, remaining: 0, failed: 0 })
|
|
9845
|
+
};
|
|
9846
|
+
};
|
|
9847
|
+
var createExportDestinationSinks = (options) => {
|
|
9848
|
+
const labelled = hasConfiguredDestinations(options.exporter);
|
|
9849
|
+
const spoolPolicy = effectiveSpoolPolicy(options.exporter);
|
|
9850
|
+
const destinations = [];
|
|
9851
|
+
const skipped = [];
|
|
9852
|
+
for (const destination of resolveExportDestinations(options.exporter)) {
|
|
9853
|
+
let headers;
|
|
9854
|
+
let logHeaders;
|
|
9855
|
+
if (destination.source === "exporter") {
|
|
9856
|
+
headers = options.defaultHeaders;
|
|
9857
|
+
logHeaders = options.defaultLogHeaders ?? options.defaultHeaders;
|
|
9858
|
+
} else {
|
|
9859
|
+
const resolved = resolveDestinationHeaders(destination.headers, options.headerEnvironment);
|
|
9860
|
+
if (resolved.missingVariables.length > 0) {
|
|
9861
|
+
options.logger?.warn("export destination skipped: a header references an unset environment variable", {
|
|
9862
|
+
"export.destination": destination.name,
|
|
9863
|
+
"config.variables": [...resolved.missingVariables]
|
|
9864
|
+
});
|
|
9865
|
+
skipped.push({
|
|
9866
|
+
name: destination.name,
|
|
9867
|
+
reason: "header-variable-missing",
|
|
9868
|
+
missingVariables: resolved.missingVariables
|
|
9869
|
+
});
|
|
9870
|
+
continue;
|
|
9871
|
+
}
|
|
9872
|
+
headers = resolved.values;
|
|
9873
|
+
logHeaders = resolved.values;
|
|
9874
|
+
}
|
|
9875
|
+
const label = labelled ? destination.name : void 0;
|
|
9876
|
+
const policy = exporterPolicyForDestination(options.exporter, destination);
|
|
9877
|
+
const queues = spoolQueueNamesFor(destination.name);
|
|
9878
|
+
const bounds = {
|
|
9879
|
+
maxSpoolFiles: spoolPolicy.maxBatches,
|
|
9880
|
+
maxBytes: spoolPolicy.maxBytes,
|
|
9881
|
+
maxAgeMillis: spoolPolicy.maxAgeMillis,
|
|
9882
|
+
overflow: "drop-oldest"
|
|
9883
|
+
};
|
|
9884
|
+
const shared = {
|
|
9885
|
+
providerId: options.providerId,
|
|
9886
|
+
installationId: options.installationId,
|
|
9887
|
+
clock: options.clock,
|
|
9888
|
+
...options.logger === void 0 ? {} : { logger: options.logger }
|
|
9889
|
+
};
|
|
9890
|
+
const spool = options.spoolRootDir === void 0 || !destination.signals.traces ? void 0 : createFileDurableSpool({
|
|
9891
|
+
rootDir: options.spoolRootDir,
|
|
9892
|
+
...shared,
|
|
9893
|
+
...bounds,
|
|
9894
|
+
queueName: queues.traces
|
|
9895
|
+
});
|
|
9896
|
+
const logSpool = options.spoolRootDir === void 0 || !destination.signals.logs ? void 0 : createFileDurableLogSpool({
|
|
9897
|
+
rootDir: options.spoolRootDir,
|
|
9898
|
+
...shared,
|
|
9899
|
+
...bounds,
|
|
9900
|
+
queueName: queues.logs
|
|
9901
|
+
});
|
|
9902
|
+
const sinkShared = {
|
|
9903
|
+
exporter: policy,
|
|
9904
|
+
...shared,
|
|
9905
|
+
...options.correlate === void 0 ? {} : { correlate: options.correlate },
|
|
9906
|
+
...label === void 0 ? {} : { destination: label }
|
|
9907
|
+
};
|
|
9908
|
+
const traces = destination.signals.traces ? createOtlpTraceSink({
|
|
9909
|
+
...sinkShared,
|
|
9910
|
+
...headers === void 0 || Object.keys(headers).length === 0 ? {} : { headers },
|
|
9911
|
+
...spool === void 0 ? {} : { spool }
|
|
9912
|
+
}) : createOptedOutTraceSink(label);
|
|
9913
|
+
const logs = createOtlpLogSink({
|
|
9914
|
+
...sinkShared,
|
|
9915
|
+
...logHeaders === void 0 || Object.keys(logHeaders).length === 0 ? {} : { headers: logHeaders },
|
|
9916
|
+
...logSpool === void 0 ? {} : { spool: logSpool },
|
|
9917
|
+
content: options.logContent
|
|
9918
|
+
});
|
|
9919
|
+
destinations.push({
|
|
9920
|
+
name: destination.name,
|
|
9921
|
+
traces,
|
|
9922
|
+
logs,
|
|
9923
|
+
...spool === void 0 ? {} : { spool },
|
|
9924
|
+
...logSpool === void 0 ? {} : { logSpool }
|
|
9925
|
+
});
|
|
9926
|
+
}
|
|
9927
|
+
return { destinations, skipped };
|
|
9928
|
+
};
|
|
9929
|
+
var createDestinationFanout = (destinations) => {
|
|
9930
|
+
const fanouts = destinations.map((destination) => ({
|
|
9931
|
+
name: destination.name,
|
|
9932
|
+
sink: createSignalFanout({ traces: destination.traces, logs: destination.logs })
|
|
9933
|
+
}));
|
|
9934
|
+
const only = fanouts.length === 1 ? fanouts[0] : void 0;
|
|
9935
|
+
if (only !== void 0) {
|
|
9936
|
+
return only.sink;
|
|
9937
|
+
}
|
|
9938
|
+
const emit = async (events) => {
|
|
9939
|
+
const results = await Promise.all(
|
|
9940
|
+
fanouts.map(
|
|
9941
|
+
(fanout) => fanout.sink.emit(events).catch(
|
|
9942
|
+
(thrown) => ({
|
|
9943
|
+
accepted: 0,
|
|
9944
|
+
rejected: events.length,
|
|
9945
|
+
errors: [errorInfoFromThrown(thrown, { code: "telemetry-export-failure", phase: "export" })]
|
|
9946
|
+
})
|
|
9947
|
+
)
|
|
9948
|
+
)
|
|
9949
|
+
);
|
|
9950
|
+
const errors = results.flatMap((result) => result.errors);
|
|
9951
|
+
return {
|
|
9952
|
+
accepted: results.reduce((sum, result) => sum + result.accepted, 0),
|
|
9953
|
+
rejected: results.reduce((sum, result) => sum + result.rejected, 0),
|
|
9954
|
+
errors
|
|
9955
|
+
};
|
|
9956
|
+
};
|
|
9957
|
+
const settleAll = async (run) => {
|
|
9958
|
+
await Promise.all(fanouts.map((fanout) => run(fanout.sink).catch(() => void 0)));
|
|
9959
|
+
};
|
|
9960
|
+
return {
|
|
9961
|
+
emit,
|
|
9962
|
+
// Each destination drains its own spool in its flush; in parallel, so one
|
|
9963
|
+
// unreachable destination's drain cannot use up the others' flush window.
|
|
9964
|
+
flush: () => settleAll((sink) => sink.flush()),
|
|
9965
|
+
shutdown: () => settleAll((sink) => sink.shutdown()),
|
|
9966
|
+
health: () => fanouts.flatMap((fanout) => fanout.sink.health())
|
|
9967
|
+
};
|
|
9968
|
+
};
|
|
9969
|
+
|
|
9267
9970
|
// src/cli/doctor.ts
|
|
9268
9971
|
var DOCTOR_STATE_NAMESPACE = "doctor";
|
|
9269
9972
|
var PROBE_KEY = "diagnostics:doctor-probe";
|
|
@@ -9334,6 +10037,12 @@ var collectDoctorReport = async (command, io) => {
|
|
|
9334
10037
|
}
|
|
9335
10038
|
}
|
|
9336
10039
|
const traceHeaders = resolveCliExporterHeaders(command.policy, io).traces;
|
|
10040
|
+
const destinations = await describeDoctorDestinations(
|
|
10041
|
+
resolved.config.exporter,
|
|
10042
|
+
io.env,
|
|
10043
|
+
command.policy.spoolDisabled === true ? void 0 : { rootDir: stateRootDir, installationId }
|
|
10044
|
+
);
|
|
10045
|
+
const withDestinations = hasConfiguredDestinations(resolved.config.exporter);
|
|
9337
10046
|
const sink = createOtlpTraceSink({
|
|
9338
10047
|
exporter: resolved.config.exporter,
|
|
9339
10048
|
...Object.keys(traceHeaders).length === 0 ? {} : { headers: traceHeaders },
|
|
@@ -9342,11 +10051,13 @@ var collectDoctorReport = async (command, io) => {
|
|
|
9342
10051
|
clock,
|
|
9343
10052
|
logger
|
|
9344
10053
|
});
|
|
9345
|
-
const
|
|
10054
|
+
const legacyConfigured = resolved.config.exporter.enabled && resolved.config.exporter.protocol === "http/protobuf" && resolved.config.exporter.endpoint !== void 0;
|
|
10055
|
+
const routable = destinations.filter((destination) => destination.enabled && destination.ok);
|
|
10056
|
+
const exporterConfigured = legacyConfigured || withDestinations && resolved.config.exporter.enabled && routable.length > 0;
|
|
9346
10057
|
checks.push({
|
|
9347
10058
|
name: "exporter",
|
|
9348
10059
|
ok: exporterConfigured,
|
|
9349
|
-
detail: exporterConfigured ? "OTLP HTTP/protobuf exporter is configured" : !resolved.config.exporter.enabled ? "exporter is disabled; events are accepted and discarded" : resolved.config.exporter.endpoint === void 0 ? "exporter is enabled but no endpoint is configured" : `protocol ${resolved.config.exporter.protocol} is not supported by this build`
|
|
10060
|
+
detail: exporterConfigured ? withDestinations ? `OTLP HTTP/protobuf export to ${String(routable.length)} destination(s): ${routable.map((destination) => destination.name).join(", ")}` : "OTLP HTTP/protobuf exporter is configured" : !resolved.config.exporter.enabled ? "exporter is disabled; events are accepted and discarded" : resolved.config.exporter.endpoint === void 0 && !withDestinations ? "exporter is enabled but no endpoint is configured" : withDestinations ? "exporter.destinations is set but no destination can be sent to" : `protocol ${resolved.config.exporter.protocol} is not supported by this build`
|
|
9350
10061
|
});
|
|
9351
10062
|
const logs = describeLogsDeliverability(resolved.config.exporter);
|
|
9352
10063
|
checks.push({
|
|
@@ -9354,6 +10065,14 @@ var collectDoctorReport = async (command, io) => {
|
|
|
9354
10065
|
ok: logs.status === "configured" || logs.reason === "logs-disabled",
|
|
9355
10066
|
detail: logs.status === "configured" ? `OTLP HTTP/protobuf logs exporter is configured${logs.derivedEndpoint ? " (endpoint derived from the trace endpoint)" : ""}; content ${resolved.config.exporter.logs.includeContent ? "permitted" : "disabled"}` : logs.reason === "logs-disabled" ? "logs are disabled; only traces are exported" : logs.reason === "no-endpoint" ? "logs are enabled but no endpoint is configured and none could be derived" : `logs are enabled but unroutable: ${logs.reason}`
|
|
9356
10067
|
});
|
|
10068
|
+
if (withDestinations) {
|
|
10069
|
+
const failing = destinations.filter((destination) => destination.enabled && !destination.ok);
|
|
10070
|
+
checks.push({
|
|
10071
|
+
name: "destinations",
|
|
10072
|
+
ok: failing.length === 0,
|
|
10073
|
+
detail: failing.length === 0 ? `${String(destinations.filter((destination) => destination.enabled).length)} enabled destination(s) resolve` : failing.map((destination) => `${destination.name}: ${destination.detail}`).join("; ")
|
|
10074
|
+
});
|
|
10075
|
+
}
|
|
9357
10076
|
const health = summarizeHealth([sink.health()]);
|
|
9358
10077
|
await sink.shutdown();
|
|
9359
10078
|
checks.push({
|
|
@@ -9388,6 +10107,7 @@ var collectDoctorReport = async (command, io) => {
|
|
|
9388
10107
|
...spooledBatches === void 0 ? {} : { spooledBatches },
|
|
9389
10108
|
...spooledLogBatches === void 0 ? {} : { spooledLogBatches }
|
|
9390
10109
|
},
|
|
10110
|
+
destinations,
|
|
9391
10111
|
providers: providers.map((entry) => ({
|
|
9392
10112
|
id: entry.id,
|
|
9393
10113
|
version: entry.version,
|
|
@@ -9396,6 +10116,109 @@ var collectDoctorReport = async (command, io) => {
|
|
|
9396
10116
|
}))
|
|
9397
10117
|
};
|
|
9398
10118
|
};
|
|
10119
|
+
var formatBytes = (bytes) => bytes < 1024 ? `${String(bytes)} B` : `${(bytes / 1024).toFixed(1)} KiB`;
|
|
10120
|
+
var describeDestinationLine = (destination) => {
|
|
10121
|
+
const parts = [];
|
|
10122
|
+
parts.push(destination.enabled ? destination.signals.join("+") || "no signals" : "disabled");
|
|
10123
|
+
if (destination.tracesEndpointOrigin !== void 0) {
|
|
10124
|
+
parts.push(`traces -> ${destination.tracesEndpointOrigin}`);
|
|
10125
|
+
}
|
|
10126
|
+
if (destination.logsEndpointOrigin !== void 0) {
|
|
10127
|
+
parts.push(`logs -> ${destination.logsEndpointOrigin}`);
|
|
10128
|
+
}
|
|
10129
|
+
if (destination.headerNames.length > 0) {
|
|
10130
|
+
parts.push(`headers ${destination.headerNames.join(", ")}`);
|
|
10131
|
+
}
|
|
10132
|
+
if (destination.missingVariables.length > 0) {
|
|
10133
|
+
parts.push(`MISSING ${destination.missingVariables.join(", ")}`);
|
|
10134
|
+
}
|
|
10135
|
+
for (const [signal, stats] of Object.entries(destination.spool ?? {})) {
|
|
10136
|
+
if (stats.batches > 0 || stats.dropped.total > 0) {
|
|
10137
|
+
const dropped = stats.dropped;
|
|
10138
|
+
parts.push(
|
|
10139
|
+
`${signal} spool ${String(stats.batches)} batch(es) ${formatBytes(stats.bytes)}, dropped ${String(
|
|
10140
|
+
dropped.total
|
|
10141
|
+
)} (age ${String(dropped.age)}, size ${String(dropped.size)}, count ${String(
|
|
10142
|
+
dropped.count
|
|
10143
|
+
)}, rejected ${String(dropped.rejected)})`
|
|
10144
|
+
);
|
|
10145
|
+
}
|
|
10146
|
+
}
|
|
10147
|
+
return `${destination.ok ? "ok " : "FAIL"} destination ${destination.name}: ${parts.join("; ")}`;
|
|
10148
|
+
};
|
|
10149
|
+
var sumSpoolStats = (all) => {
|
|
10150
|
+
const oldest = all.map((stats) => stats.oldestEnqueuedAt).filter((value) => value !== void 0);
|
|
10151
|
+
const lastDropped = all.map((stats) => stats.dropped.lastDroppedAt).filter((value) => value !== void 0);
|
|
10152
|
+
return {
|
|
10153
|
+
batches: all.reduce((sum, stats) => sum + stats.batches, 0),
|
|
10154
|
+
bytes: all.reduce((sum, stats) => sum + stats.bytes, 0),
|
|
10155
|
+
...oldest.length === 0 ? {} : { oldestEnqueuedAt: Math.min(...oldest) },
|
|
10156
|
+
dropped: {
|
|
10157
|
+
total: all.reduce((sum, stats) => sum + stats.dropped.total, 0),
|
|
10158
|
+
age: all.reduce((sum, stats) => sum + stats.dropped.age, 0),
|
|
10159
|
+
size: all.reduce((sum, stats) => sum + stats.dropped.size, 0),
|
|
10160
|
+
count: all.reduce((sum, stats) => sum + stats.dropped.count, 0),
|
|
10161
|
+
rejected: all.reduce((sum, stats) => sum + stats.dropped.rejected, 0),
|
|
10162
|
+
...lastDropped.length === 0 ? {} : { lastDroppedAt: Math.max(...lastDropped) }
|
|
10163
|
+
}
|
|
10164
|
+
};
|
|
10165
|
+
};
|
|
10166
|
+
var inspectQueue = async (spool, queueName) => {
|
|
10167
|
+
let namespaces;
|
|
10168
|
+
try {
|
|
10169
|
+
namespaces = await readdir3(spool.rootDir);
|
|
10170
|
+
} catch {
|
|
10171
|
+
namespaces = [];
|
|
10172
|
+
}
|
|
10173
|
+
const installation = sanitizeSegment(spool.installationId);
|
|
10174
|
+
const stats = await Promise.all(
|
|
10175
|
+
namespaces.map(
|
|
10176
|
+
(namespace) => readSpoolQueueStats(path4.join(spool.rootDir, namespace, installation, queueName))
|
|
10177
|
+
)
|
|
10178
|
+
);
|
|
10179
|
+
return stats.length === 0 ? { batches: 0, bytes: 0, dropped: EMPTY_SPOOL_DROP_COUNTS } : sumSpoolStats(stats);
|
|
10180
|
+
};
|
|
10181
|
+
var describeDoctorDestinations = async (exporter, environment, spool) => {
|
|
10182
|
+
const configured = new Map(
|
|
10183
|
+
(exporter.destinations ?? []).map((destination) => [destination.name, destination])
|
|
10184
|
+
);
|
|
10185
|
+
const resolvedNames = new Set(resolveExportDestinations(exporter).map((destination) => destination.name));
|
|
10186
|
+
const descriptions = describeExportDestinations(exporter);
|
|
10187
|
+
return Promise.all(
|
|
10188
|
+
descriptions.map(async (description) => {
|
|
10189
|
+
const headers = configured.get(description.name)?.headers ?? {};
|
|
10190
|
+
const missingVariables = resolveDestinationHeaders(headers, environment).missingVariables;
|
|
10191
|
+
const sends = description.signals.length > 0;
|
|
10192
|
+
const reachable = description.signals.includes("traces") && description.tracesEndpointOrigin !== void 0 || description.signals.includes("logs") && description.logsEndpointOrigin !== void 0;
|
|
10193
|
+
let detail = "resolves";
|
|
10194
|
+
let ok = true;
|
|
10195
|
+
if (!description.enabled) {
|
|
10196
|
+
detail = "disabled";
|
|
10197
|
+
} else if (missingVariables.length > 0) {
|
|
10198
|
+
ok = false;
|
|
10199
|
+
detail = `header variable(s) not set: ${missingVariables.join(", ")}; skipped until they are`;
|
|
10200
|
+
} else if (description.protocol !== "http/protobuf") {
|
|
10201
|
+
ok = description.protocol === "none";
|
|
10202
|
+
detail = description.protocol === "none" ? "protocol is none; nothing is sent" : `protocol ${description.protocol} is not supported by this build`;
|
|
10203
|
+
} else if (!sends || !reachable) {
|
|
10204
|
+
ok = false;
|
|
10205
|
+
detail = "no endpoint for any signal it receives";
|
|
10206
|
+
}
|
|
10207
|
+
const queues = spoolQueueNamesFor(description.name);
|
|
10208
|
+
const spoolStats = spool === void 0 || !resolvedNames.has(description.name) ? void 0 : {
|
|
10209
|
+
...description.signals.includes("traces") ? { traces: await inspectQueue(spool, queues.traces) } : {},
|
|
10210
|
+
...description.signals.includes("logs") ? { logs: await inspectQueue(spool, queues.logs) } : {}
|
|
10211
|
+
};
|
|
10212
|
+
return {
|
|
10213
|
+
...description,
|
|
10214
|
+
missingVariables,
|
|
10215
|
+
ok,
|
|
10216
|
+
detail,
|
|
10217
|
+
...spoolStats === void 0 ? {} : { spool: spoolStats }
|
|
10218
|
+
};
|
|
10219
|
+
})
|
|
10220
|
+
);
|
|
10221
|
+
};
|
|
9399
10222
|
var runDoctorCommand = async (command, io) => {
|
|
9400
10223
|
const report = await collectDoctorReport(command, io);
|
|
9401
10224
|
if (command.json) {
|
|
@@ -9416,6 +10239,16 @@ var runDoctorCommand = async (command, io) => {
|
|
|
9416
10239
|
if (report.state.spooledLogBatches !== void 0) {
|
|
9417
10240
|
writeLine(io.stdout, `spooled log batches: ${String(report.state.spooledLogBatches)}`);
|
|
9418
10241
|
}
|
|
10242
|
+
const listDestinations = report.config["exporter.destination_names"] !== void 0 || report.destinations.some(
|
|
10243
|
+
(destination) => Object.values(destination.spool ?? {}).some(
|
|
10244
|
+
(stats) => stats.dropped.total > 0
|
|
10245
|
+
)
|
|
10246
|
+
);
|
|
10247
|
+
if (listDestinations) {
|
|
10248
|
+
for (const destination of report.destinations) {
|
|
10249
|
+
writeLine(io.stdout, describeDestinationLine(destination));
|
|
10250
|
+
}
|
|
10251
|
+
}
|
|
9419
10252
|
for (const note of report.configNotes) {
|
|
9420
10253
|
writeLine(io.stdout, `note: ${note}`);
|
|
9421
10254
|
}
|
|
@@ -10284,7 +11117,7 @@ var SUPPORTED_REGISTRATION_PROVIDER_IDS = Object.freeze(
|
|
|
10284
11117
|
);
|
|
10285
11118
|
|
|
10286
11119
|
// src/install/scopes.ts
|
|
10287
|
-
import * as
|
|
11120
|
+
import * as path5 from "path";
|
|
10288
11121
|
var REGISTRATION_SCOPES = Object.freeze([
|
|
10289
11122
|
"global",
|
|
10290
11123
|
"project"
|
|
@@ -10352,15 +11185,15 @@ var PROVIDERS_WITH_VERIFIED_LOCATION = Object.freeze([
|
|
|
10352
11185
|
var findInstallLocation = (providerId, scope) => PROVIDER_INSTALL_LOCATIONS.find(
|
|
10353
11186
|
(entry) => entry.providerId === providerId && entry.scope === scope
|
|
10354
11187
|
);
|
|
10355
|
-
var resolveInstallPath = (location, roots) =>
|
|
11188
|
+
var resolveInstallPath = (location, roots) => path5.resolve(
|
|
10356
11189
|
location.scope === "global" ? roots.homeDir : roots.projectDir,
|
|
10357
11190
|
...location.segments
|
|
10358
11191
|
);
|
|
10359
11192
|
|
|
10360
11193
|
// src/install/document.ts
|
|
10361
11194
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
10362
|
-
import { chmod, mkdir as mkdir3, open as open2, readFile as readFile4, rename as rename3, stat, unlink as unlink3 } from "fs/promises";
|
|
10363
|
-
import * as
|
|
11195
|
+
import { chmod, mkdir as mkdir3, open as open2, readFile as readFile4, rename as rename3, stat as stat2, unlink as unlink3 } from "fs/promises";
|
|
11196
|
+
import * as path6 from "path";
|
|
10364
11197
|
var DEFAULT_DOCUMENT_FORMAT = Object.freeze({
|
|
10365
11198
|
indent: " ",
|
|
10366
11199
|
eol: "\n",
|
|
@@ -10431,15 +11264,15 @@ var renameWithRetry = async (from, to) => {
|
|
|
10431
11264
|
var NEW_DOCUMENT_MODE = 384;
|
|
10432
11265
|
var TEMPORARY_DOCUMENT_MODE = 384;
|
|
10433
11266
|
var writeDocumentAtomically = async (filePath, contents) => {
|
|
10434
|
-
const directory =
|
|
11267
|
+
const directory = path6.dirname(filePath);
|
|
10435
11268
|
await mkdir3(directory, { recursive: true });
|
|
10436
|
-
const temporary =
|
|
11269
|
+
const temporary = path6.join(
|
|
10437
11270
|
directory,
|
|
10438
|
-
`.${
|
|
11271
|
+
`.${path6.basename(filePath)}.${randomBytes3(6).toString("hex")}.tmp`
|
|
10439
11272
|
);
|
|
10440
11273
|
let existingMode;
|
|
10441
11274
|
try {
|
|
10442
|
-
existingMode = (await
|
|
11275
|
+
existingMode = (await stat2(filePath)).mode & 4095;
|
|
10443
11276
|
} catch (thrown) {
|
|
10444
11277
|
if (!isErrnoException3(thrown, "ENOENT")) {
|
|
10445
11278
|
throw thrown;
|
|
@@ -10464,12 +11297,12 @@ var writeDocumentAtomically = async (filePath, contents) => {
|
|
|
10464
11297
|
|
|
10465
11298
|
// src/install/file-lock.ts
|
|
10466
11299
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
10467
|
-
import { mkdir as mkdir4, open as open3, readFile as readFile5, rename as rename4, stat as
|
|
10468
|
-
import * as
|
|
11300
|
+
import { mkdir as mkdir4, open as open3, readFile as readFile5, rename as rename4, stat as stat3, unlink as unlink4 } from "fs/promises";
|
|
11301
|
+
import * as path7 from "path";
|
|
10469
11302
|
var FileLockTimeoutError = class extends Error {
|
|
10470
11303
|
constructor(lockPath, timeoutMillis) {
|
|
10471
11304
|
super(
|
|
10472
|
-
`timed out after ${String(timeoutMillis)}ms waiting for the lock on ${
|
|
11305
|
+
`timed out after ${String(timeoutMillis)}ms waiting for the lock on ${path7.basename(lockPath)}`
|
|
10473
11306
|
);
|
|
10474
11307
|
this.name = "FileLockTimeoutError";
|
|
10475
11308
|
}
|
|
@@ -10529,7 +11362,7 @@ var isStale = async (lockPath, clock, staleMillis) => {
|
|
|
10529
11362
|
} catch {
|
|
10530
11363
|
}
|
|
10531
11364
|
try {
|
|
10532
|
-
const stats = await
|
|
11365
|
+
const stats = await stat3(lockPath);
|
|
10533
11366
|
return { stale: clock.now() - stats.mtimeMs > staleMillis };
|
|
10534
11367
|
} catch (thrown) {
|
|
10535
11368
|
return { stale: !isErrnoException4(thrown, "ENOENT") };
|
|
@@ -10541,7 +11374,7 @@ var withFileLock = async (filePath, options, fn) => {
|
|
|
10541
11374
|
const pollIntervalMillis = options.pollIntervalMillis ?? 25;
|
|
10542
11375
|
const lockPath = lockPathFor(filePath);
|
|
10543
11376
|
const startedAt = options.clock.monotonicMillis();
|
|
10544
|
-
await mkdir4(
|
|
11377
|
+
await mkdir4(path7.dirname(filePath), { recursive: true });
|
|
10545
11378
|
for (; ; ) {
|
|
10546
11379
|
const token = randomBytes4(16).toString("hex");
|
|
10547
11380
|
let acquired = false;
|
|
@@ -10589,7 +11422,7 @@ var withFileLock = async (filePath, options, fn) => {
|
|
|
10589
11422
|
|
|
10590
11423
|
// src/install/lifecycle.ts
|
|
10591
11424
|
import { readFile as readFile6 } from "fs/promises";
|
|
10592
|
-
import * as
|
|
11425
|
+
import * as path8 from "path";
|
|
10593
11426
|
var defaultHookCommand = (providerId) => `otel-hook run --provider ${providerId}`;
|
|
10594
11427
|
var unsupportedOutcome = (providerId, scope, reason) => ({
|
|
10595
11428
|
providerId,
|
|
@@ -10606,7 +11439,7 @@ var unsupportedOutcome = (providerId, scope, reason) => ({
|
|
|
10606
11439
|
var resolveTarget = (providerId, scope, request) => {
|
|
10607
11440
|
if (request.configFile !== void 0) {
|
|
10608
11441
|
return {
|
|
10609
|
-
configPath:
|
|
11442
|
+
configPath: path8.resolve(request.configFile),
|
|
10610
11443
|
evidence: "path supplied by the caller with --settings-file"
|
|
10611
11444
|
};
|
|
10612
11445
|
}
|
|
@@ -10623,14 +11456,14 @@ var resolveTarget = (providerId, scope, request) => {
|
|
|
10623
11456
|
};
|
|
10624
11457
|
};
|
|
10625
11458
|
var codexFeatureNote = async (configPath) => {
|
|
10626
|
-
const tomlPath =
|
|
11459
|
+
const tomlPath = path8.join(path8.dirname(configPath), "config.toml");
|
|
10627
11460
|
let raw;
|
|
10628
11461
|
try {
|
|
10629
11462
|
raw = await readFile6(tomlPath, "utf8");
|
|
10630
11463
|
} catch {
|
|
10631
11464
|
return void 0;
|
|
10632
11465
|
}
|
|
10633
|
-
return readCodexHooksFeatureFlag(raw) === "disabled" ? `${
|
|
11466
|
+
return readCodexHooksFeatureFlag(raw) === "disabled" ? `${path8.basename(tomlPath)} sets [features] hooks = false; registered hooks will not fire until that is removed` : void 0;
|
|
10634
11467
|
};
|
|
10635
11468
|
var readState = async (configPath) => {
|
|
10636
11469
|
const read = await readJsonDocument(configPath);
|
|
@@ -10642,12 +11475,12 @@ var readState = async (configPath) => {
|
|
|
10642
11475
|
case "unparseable":
|
|
10643
11476
|
return {
|
|
10644
11477
|
status: "blocked",
|
|
10645
|
-
problem: `${
|
|
11478
|
+
problem: `${path8.basename(configPath)} is not well-formed JSON (${read.detail}); it was left untouched`
|
|
10646
11479
|
};
|
|
10647
11480
|
case "unreadable":
|
|
10648
11481
|
return {
|
|
10649
11482
|
status: "failed",
|
|
10650
|
-
problem: `${
|
|
11483
|
+
problem: `${path8.basename(configPath)} could not be read (${read.detail})`
|
|
10651
11484
|
};
|
|
10652
11485
|
}
|
|
10653
11486
|
};
|
|
@@ -10759,7 +11592,7 @@ var runOneTarget = async (providerId, scope, request, command) => {
|
|
|
10759
11592
|
missingEvents: [],
|
|
10760
11593
|
notes,
|
|
10761
11594
|
problems: planned.conflicts.map(
|
|
10762
|
-
(conflict) => `${
|
|
11595
|
+
(conflict) => `${path8.basename(configPath)} has an unexpected shape at ${conflict.location}: ${conflict.detail}; it was left untouched`
|
|
10763
11596
|
)
|
|
10764
11597
|
};
|
|
10765
11598
|
}
|
|
@@ -10770,7 +11603,7 @@ var runOneTarget = async (providerId, scope, request, command) => {
|
|
|
10770
11603
|
changed: false,
|
|
10771
11604
|
registeredEvents: [],
|
|
10772
11605
|
missingEvents: [],
|
|
10773
|
-
notes: [...notes, `${
|
|
11606
|
+
notes: [...notes, `${path8.basename(configPath)} does not exist; nothing to remove`],
|
|
10774
11607
|
problems: []
|
|
10775
11608
|
};
|
|
10776
11609
|
}
|
|
@@ -10813,7 +11646,7 @@ var runOneTarget = async (providerId, scope, request, command) => {
|
|
|
10813
11646
|
missingEvents: [],
|
|
10814
11647
|
notes,
|
|
10815
11648
|
problems: [
|
|
10816
|
-
`could not write ${
|
|
11649
|
+
`could not write ${path8.basename(configPath)} (${thrown instanceof Error ? thrown.name : typeof thrown})`
|
|
10817
11650
|
]
|
|
10818
11651
|
};
|
|
10819
11652
|
}
|
|
@@ -10840,7 +11673,7 @@ var runOneTarget = async (providerId, scope, request, command) => {
|
|
|
10840
11673
|
missingEvents: [],
|
|
10841
11674
|
notes,
|
|
10842
11675
|
problems: [
|
|
10843
|
-
thrown instanceof Error ? `${
|
|
11676
|
+
thrown instanceof Error ? `${path8.basename(configPath)}: ${thrown.message}` : `${path8.basename(configPath)}: the configuration file could not be locked`
|
|
10844
11677
|
]
|
|
10845
11678
|
};
|
|
10846
11679
|
}
|
|
@@ -10936,9 +11769,9 @@ var runProvidersCommand = (command, io) => {
|
|
|
10936
11769
|
|
|
10937
11770
|
// src/cli/registration.ts
|
|
10938
11771
|
import * as os2 from "os";
|
|
10939
|
-
import * as
|
|
10940
|
-
var resolveProjectDir = (command, io) =>
|
|
10941
|
-
var resolveHomeDir = (command, io) =>
|
|
11772
|
+
import * as path9 from "path";
|
|
11773
|
+
var resolveProjectDir = (command, io) => path9.resolve(command.projectDir ?? io.env.PWD ?? process.cwd());
|
|
11774
|
+
var resolveHomeDir = (command, io) => path9.resolve(command.homeDir ?? io.homeDir ?? os2.homedir());
|
|
10942
11775
|
var collectRegistrationReport = async (command, io) => runRegistrationLifecycle({
|
|
10943
11776
|
action: command.name,
|
|
10944
11777
|
// A bare `diagnose` sweeps the providers this tool can locate by itself.
|
|
@@ -11019,7 +11852,7 @@ var runRegistrationCommand = async (command, io) => {
|
|
|
11019
11852
|
};
|
|
11020
11853
|
|
|
11021
11854
|
// src/cli/run.ts
|
|
11022
|
-
import * as
|
|
11855
|
+
import * as path12 from "path";
|
|
11023
11856
|
|
|
11024
11857
|
// src/lifecycle/dedup.ts
|
|
11025
11858
|
import { randomBytes as randomBytes5 } from "crypto";
|
|
@@ -11756,7 +12589,7 @@ var createUsageAccumulator = (deps) => {
|
|
|
11756
12589
|
};
|
|
11757
12590
|
|
|
11758
12591
|
// src/runtime/hook.ts
|
|
11759
|
-
import { z as
|
|
12592
|
+
import { z as z23 } from "zod";
|
|
11760
12593
|
|
|
11761
12594
|
// src/runtime/delivery.ts
|
|
11762
12595
|
var PROVIDER_SCOPE_PREFIX = "provider-session";
|
|
@@ -11829,16 +12662,16 @@ var createDeterministicIdGenerator = (options = {}) => {
|
|
|
11829
12662
|
};
|
|
11830
12663
|
|
|
11831
12664
|
// src/runtime/target-resolution.ts
|
|
11832
|
-
import * as
|
|
12665
|
+
import * as path10 from "path";
|
|
11833
12666
|
var DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS = 50;
|
|
11834
12667
|
var absolutePathsOf = (hint) => {
|
|
11835
|
-
const base = hint.baseDirectory !== void 0 &&
|
|
12668
|
+
const base = hint.baseDirectory !== void 0 && path10.isAbsolute(hint.baseDirectory) ? hint.baseDirectory : void 0;
|
|
11836
12669
|
const resolved = [];
|
|
11837
12670
|
for (const candidate of hint.paths) {
|
|
11838
|
-
if (
|
|
11839
|
-
resolved.push(
|
|
12671
|
+
if (path10.isAbsolute(candidate)) {
|
|
12672
|
+
resolved.push(path10.resolve(candidate));
|
|
11840
12673
|
} else if (base !== void 0) {
|
|
11841
|
-
resolved.push(
|
|
12674
|
+
resolved.push(path10.resolve(base, candidate));
|
|
11842
12675
|
} else {
|
|
11843
12676
|
return void 0;
|
|
11844
12677
|
}
|
|
@@ -11917,7 +12750,7 @@ var resolveEventTargets = async (input) => {
|
|
|
11917
12750
|
};
|
|
11918
12751
|
|
|
11919
12752
|
// src/runtime/hook.ts
|
|
11920
|
-
var usageScopeSchema =
|
|
12753
|
+
var usageScopeSchema = z23.enum(["session", "generation", "subagent"]);
|
|
11921
12754
|
var classifyDurability = (input) => {
|
|
11922
12755
|
if (!input.attempted) {
|
|
11923
12756
|
return "nothing-to-deliver";
|
|
@@ -12673,8 +13506,8 @@ var buildErrorEvents = (diagnostics, identity, sequenceBase, ids, privacy) => {
|
|
|
12673
13506
|
};
|
|
12674
13507
|
|
|
12675
13508
|
// src/runtime/git-worktree.ts
|
|
12676
|
-
import { lstat, open as open4, stat as
|
|
12677
|
-
import * as
|
|
13509
|
+
import { lstat, open as open4, stat as stat4 } from "fs/promises";
|
|
13510
|
+
import * as path11 from "path";
|
|
12678
13511
|
var MAX_WORKTREE_WALK_DEPTH = 128;
|
|
12679
13512
|
var MAX_GIT_FILE_BYTES = 4096;
|
|
12680
13513
|
var MAX_CACHE_ENTRIES = 1024;
|
|
@@ -12706,7 +13539,7 @@ var parseHeadBranch = (head) => {
|
|
|
12706
13539
|
return branch;
|
|
12707
13540
|
};
|
|
12708
13541
|
var firstLine = (content) => content.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
12709
|
-
var resolveGitPath = (target, base) => target === void 0 || target.length === 0 || target.includes("\0") ? void 0 :
|
|
13542
|
+
var resolveGitPath = (target, base) => target === void 0 || target.length === 0 || target.includes("\0") ? void 0 : path11.resolve(base, target);
|
|
12710
13543
|
var parseGitDirFile = (content, worktreeRoot) => {
|
|
12711
13544
|
const line = firstLine(content);
|
|
12712
13545
|
return resolveGitPath(
|
|
@@ -12726,26 +13559,26 @@ var isMissing = async (filePath) => {
|
|
|
12726
13559
|
};
|
|
12727
13560
|
var isDirectory = async (directory) => {
|
|
12728
13561
|
try {
|
|
12729
|
-
return (await
|
|
13562
|
+
return (await stat4(directory)).isDirectory();
|
|
12730
13563
|
} catch {
|
|
12731
13564
|
return false;
|
|
12732
13565
|
}
|
|
12733
13566
|
};
|
|
12734
13567
|
var repositoryOf = async (worktreeRoot, gitDir) => {
|
|
12735
|
-
const commonDirFile =
|
|
13568
|
+
const commonDirFile = path11.join(gitDir, "commondir");
|
|
12736
13569
|
const content = await readBounded(commonDirFile);
|
|
12737
13570
|
if (content === void 0) {
|
|
12738
13571
|
return await isMissing(commonDirFile) ? { kind: "main", mainRoot: worktreeRoot } : { kind: "linked" };
|
|
12739
13572
|
}
|
|
12740
13573
|
const commonDir = parseCommonDirFile(content, gitDir);
|
|
12741
|
-
const mainRoot = commonDir !== void 0 &&
|
|
13574
|
+
const mainRoot = commonDir !== void 0 && path11.basename(commonDir) === ".git" && await isDirectory(commonDir) ? path11.dirname(commonDir) : void 0;
|
|
12742
13575
|
return { kind: "linked", ...mainRoot === void 0 ? {} : { mainRoot } };
|
|
12743
13576
|
};
|
|
12744
13577
|
var probeDirectory = async (directory) => {
|
|
12745
|
-
const dotGit =
|
|
13578
|
+
const dotGit = path11.join(directory, ".git");
|
|
12746
13579
|
let info;
|
|
12747
13580
|
try {
|
|
12748
|
-
info = await
|
|
13581
|
+
info = await stat4(dotGit);
|
|
12749
13582
|
} catch {
|
|
12750
13583
|
return ABSENT;
|
|
12751
13584
|
}
|
|
@@ -12759,7 +13592,7 @@ var probeDirectory = async (directory) => {
|
|
|
12759
13592
|
if (gitDir === void 0) {
|
|
12760
13593
|
return INVALID;
|
|
12761
13594
|
}
|
|
12762
|
-
const head = await readBounded(
|
|
13595
|
+
const head = await readBounded(path11.join(gitDir, "HEAD"));
|
|
12763
13596
|
if (head === void 0) {
|
|
12764
13597
|
return INVALID;
|
|
12765
13598
|
}
|
|
@@ -12789,10 +13622,10 @@ var createFilesystemWorktreeLocator = (options = {}) => {
|
|
|
12789
13622
|
};
|
|
12790
13623
|
const locate = async (absolutePath) => {
|
|
12791
13624
|
try {
|
|
12792
|
-
if (!
|
|
13625
|
+
if (!path11.isAbsolute(absolutePath) || absolutePath.includes("\0")) {
|
|
12793
13626
|
return void 0;
|
|
12794
13627
|
}
|
|
12795
|
-
let directory =
|
|
13628
|
+
let directory = path11.resolve(absolutePath);
|
|
12796
13629
|
for (let depth = 0; depth < MAX_WORKTREE_WALK_DEPTH; depth += 1) {
|
|
12797
13630
|
const probe = await cachedProbe(directory);
|
|
12798
13631
|
if (probe.kind === "worktree") {
|
|
@@ -12801,7 +13634,7 @@ var createFilesystemWorktreeLocator = (options = {}) => {
|
|
|
12801
13634
|
if (probe.kind === "invalid") {
|
|
12802
13635
|
return void 0;
|
|
12803
13636
|
}
|
|
12804
|
-
const parent =
|
|
13637
|
+
const parent = path11.dirname(directory);
|
|
12805
13638
|
if (parent === directory) {
|
|
12806
13639
|
return void 0;
|
|
12807
13640
|
}
|
|
@@ -12815,48 +13648,6 @@ var createFilesystemWorktreeLocator = (options = {}) => {
|
|
|
12815
13648
|
return { locate };
|
|
12816
13649
|
};
|
|
12817
13650
|
|
|
12818
|
-
// src/telemetry/signal-fanout.ts
|
|
12819
|
-
var createSignalFanout = (options) => {
|
|
12820
|
-
const emit = async (events) => {
|
|
12821
|
-
const traces = await options.traces.emit(events);
|
|
12822
|
-
const logs = await options.logs.emit(events);
|
|
12823
|
-
const errors = [...traces.errors, ...logs.errors];
|
|
12824
|
-
return {
|
|
12825
|
-
accepted: traces.accepted + logs.accepted,
|
|
12826
|
-
rejected: traces.rejected + logs.rejected,
|
|
12827
|
-
errors
|
|
12828
|
-
};
|
|
12829
|
-
};
|
|
12830
|
-
const flush = async () => {
|
|
12831
|
-
await options.traces.flush().catch(() => void 0);
|
|
12832
|
-
await options.logs.flush().catch(() => void 0);
|
|
12833
|
-
};
|
|
12834
|
-
const shutdown = async () => {
|
|
12835
|
-
await options.traces.shutdown().catch(() => void 0);
|
|
12836
|
-
await options.logs.shutdown().catch(() => void 0);
|
|
12837
|
-
};
|
|
12838
|
-
return {
|
|
12839
|
-
emit,
|
|
12840
|
-
flush,
|
|
12841
|
-
shutdown,
|
|
12842
|
-
health: () => [
|
|
12843
|
-
options.traces.health(),
|
|
12844
|
-
options.logs.health()
|
|
12845
|
-
]
|
|
12846
|
-
};
|
|
12847
|
-
};
|
|
12848
|
-
var shareCorrelationPerBatch = (correlate) => {
|
|
12849
|
-
let pending;
|
|
12850
|
-
return (events) => {
|
|
12851
|
-
if (pending?.events === events) {
|
|
12852
|
-
return pending.result;
|
|
12853
|
-
}
|
|
12854
|
-
const result = correlate(events);
|
|
12855
|
-
pending = { events, result };
|
|
12856
|
-
return result;
|
|
12857
|
-
};
|
|
12858
|
-
};
|
|
12859
|
-
|
|
12860
13651
|
// src/integration/hook-runtime.ts
|
|
12861
13652
|
var DEFAULT_FLUSH_TIMEOUT_MILLIS = 2e3;
|
|
12862
13653
|
var DEFAULT_STATE_LOCK_TIMEOUT_MILLIS = 1e3;
|
|
@@ -12919,46 +13710,23 @@ var createHookRuntime = (options) => {
|
|
|
12919
13710
|
logger,
|
|
12920
13711
|
lockTimeoutMillis: stateLockTimeoutMillis
|
|
12921
13712
|
});
|
|
12922
|
-
const spool = options.enableSpool === false ? void 0 : createFileDurableSpool({
|
|
12923
|
-
rootDir: options.stateRootDir,
|
|
12924
|
-
providerId: options.providerNamespace,
|
|
12925
|
-
installationId: options.installationId,
|
|
12926
|
-
clock,
|
|
12927
|
-
logger
|
|
12928
|
-
});
|
|
12929
|
-
const logSpool = options.enableSpool === false || !options.config.exporter.logs.enabled ? void 0 : createFileDurableLogSpool({
|
|
12930
|
-
rootDir: options.stateRootDir,
|
|
12931
|
-
providerId: options.providerNamespace,
|
|
12932
|
-
installationId: options.installationId,
|
|
12933
|
-
clock,
|
|
12934
|
-
logger
|
|
12935
|
-
});
|
|
12936
13713
|
const spanCorrelator = createSpanCorrelator({
|
|
12937
13714
|
stateStore,
|
|
12938
13715
|
clock,
|
|
12939
13716
|
maxStartAgeMillis: lifecycleMaxAge
|
|
12940
13717
|
});
|
|
12941
13718
|
const correlate = shareCorrelationPerBatch((events) => spanCorrelator.correlateBatch(events));
|
|
12942
|
-
const
|
|
13719
|
+
const exportDestinations = createExportDestinationSinks({
|
|
12943
13720
|
exporter: options.config.exporter,
|
|
12944
|
-
...options.headers === void 0 ? {} : {
|
|
13721
|
+
...options.headers === void 0 ? {} : { defaultHeaders: options.headers },
|
|
13722
|
+
...options.logHeaders === void 0 ? {} : { defaultLogHeaders: options.logHeaders },
|
|
13723
|
+
...options.headerEnvironment === void 0 ? {} : { headerEnvironment: options.headerEnvironment },
|
|
12945
13724
|
providerId: options.providerNamespace,
|
|
12946
13725
|
installationId: options.installationId,
|
|
12947
13726
|
clock,
|
|
12948
13727
|
logger,
|
|
12949
|
-
...
|
|
12950
|
-
|
|
12951
|
-
});
|
|
12952
|
-
const logHeaders = options.logHeaders ?? options.headers;
|
|
12953
|
-
const logSink = createOtlpLogSink({
|
|
12954
|
-
exporter: options.config.exporter,
|
|
12955
|
-
...logHeaders === void 0 ? {} : { headers: logHeaders },
|
|
12956
|
-
providerId: options.providerNamespace,
|
|
12957
|
-
installationId: options.installationId,
|
|
12958
|
-
clock,
|
|
12959
|
-
logger,
|
|
12960
|
-
...logSpool === void 0 ? {} : { spool: logSpool },
|
|
12961
|
-
content: {
|
|
13728
|
+
...options.enableSpool === false ? {} : { spoolRootDir: options.stateRootDir },
|
|
13729
|
+
logContent: {
|
|
12962
13730
|
includeContent: options.config.exporter.logs.includeContent,
|
|
12963
13731
|
// The pre-existing verbatim-content opt-in, passed through rather than
|
|
12964
13732
|
// re-derived: `raw` disclosure in a log body is governed by the same flag it
|
|
@@ -12967,7 +13735,22 @@ var createHookRuntime = (options) => {
|
|
|
12967
13735
|
},
|
|
12968
13736
|
correlate
|
|
12969
13737
|
});
|
|
12970
|
-
const
|
|
13738
|
+
const primary = exportDestinations.destinations[0];
|
|
13739
|
+
const traceSink = primary?.traces ?? createOtlpTraceSink({
|
|
13740
|
+
exporter: { ...options.config.exporter, enabled: false },
|
|
13741
|
+
providerId: options.providerNamespace,
|
|
13742
|
+
installationId: options.installationId,
|
|
13743
|
+
clock
|
|
13744
|
+
});
|
|
13745
|
+
const logSink = primary?.logs ?? createOtlpLogSink({
|
|
13746
|
+
exporter: { ...options.config.exporter, logs: { ...options.config.exporter.logs, enabled: false } },
|
|
13747
|
+
providerId: options.providerNamespace,
|
|
13748
|
+
installationId: options.installationId,
|
|
13749
|
+
clock
|
|
13750
|
+
});
|
|
13751
|
+
const spool = primary?.spool;
|
|
13752
|
+
const logSpool = primary?.logSpool;
|
|
13753
|
+
const sink = createDestinationFanout(exportDestinations.destinations);
|
|
12971
13754
|
const hookDeps = {
|
|
12972
13755
|
stateStore,
|
|
12973
13756
|
config: options.config,
|
|
@@ -13236,6 +14019,8 @@ var createHookRuntime = (options) => {
|
|
|
13236
14019
|
logSink,
|
|
13237
14020
|
...spool === void 0 ? {} : { spool },
|
|
13238
14021
|
...logSpool === void 0 ? {} : { logSpool },
|
|
14022
|
+
destinations: exportDestinations.destinations,
|
|
14023
|
+
skippedDestinations: exportDestinations.skipped,
|
|
13239
14024
|
privacy,
|
|
13240
14025
|
deduplicator,
|
|
13241
14026
|
usageAccumulator,
|
|
@@ -13537,13 +14322,13 @@ var runHookCommand = async (command, io) => {
|
|
|
13537
14322
|
}
|
|
13538
14323
|
const identityClaims = [];
|
|
13539
14324
|
if (command.identity.identityFile !== void 0) {
|
|
13540
|
-
const read = await readIdentityFile(
|
|
14325
|
+
const read = await readIdentityFile(path12.resolve(command.identity.identityFile));
|
|
13541
14326
|
if ("error" in read) {
|
|
13542
14327
|
logDiagnostics(logger, [read.error]);
|
|
13543
14328
|
} else {
|
|
13544
14329
|
const fromFile = claimFromIdentityFile(
|
|
13545
14330
|
read.value,
|
|
13546
|
-
|
|
14331
|
+
path12.basename(command.identity.identityFile)
|
|
13547
14332
|
);
|
|
13548
14333
|
logDiagnostics(logger, fromFile.errors);
|
|
13549
14334
|
identityClaims.push(...fromFile.claims);
|
|
@@ -13563,6 +14348,9 @@ var runHookCommand = async (command, io) => {
|
|
|
13563
14348
|
providerNamespace: selection.namespace,
|
|
13564
14349
|
...Object.keys(headers.traces).length === 0 ? {} : { headers: headers.traces },
|
|
13565
14350
|
...Object.keys(headers.logs).length === 0 ? {} : { logHeaders: headers.logs },
|
|
14351
|
+
// Only `env:` header references in `exporter.destinations` are resolved
|
|
14352
|
+
// against it; nothing else in the runtime reads the environment.
|
|
14353
|
+
headerEnvironment: io.env,
|
|
13566
14354
|
clock,
|
|
13567
14355
|
ids,
|
|
13568
14356
|
logger,
|