@walkeros/cli 4.2.1-next-1781538735002 → 4.2.1-next-1781594053720

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/dist/cli.js CHANGED
@@ -1261,9 +1261,124 @@ var init_config_file = __esm({
1261
1261
  }
1262
1262
  });
1263
1263
 
1264
+ // src/core/redact-line.ts
1265
+ function escapeRegex(s6) {
1266
+ return s6.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1267
+ }
1268
+ function shannonEntropy(s6) {
1269
+ if (s6.length === 0) return 0;
1270
+ const counts = /* @__PURE__ */ new Map();
1271
+ for (const ch of s6) counts.set(ch, (counts.get(ch) ?? 0) + 1);
1272
+ let entropy = 0;
1273
+ for (const count of counts.values()) {
1274
+ const p3 = count / s6.length;
1275
+ entropy -= p3 * Math.log2(p3);
1276
+ }
1277
+ return entropy;
1278
+ }
1279
+ function isSecretSegment(run) {
1280
+ if (RE_ALL_HEX.test(run)) return true;
1281
+ if (RE_ALL_DIGIT.test(run)) return true;
1282
+ if (RE_BASE64_SPECIAL.test(run)) return true;
1283
+ if (RE_HAS_DIGIT.test(run) && RE_HAS_LETTER.test(run)) return true;
1284
+ if (shannonEntropy(run) >= ENTROPY_THRESHOLD) return true;
1285
+ return false;
1286
+ }
1287
+ function shouldMaskToken(run) {
1288
+ if (run.includes("/")) {
1289
+ return run.split("/").filter((segment) => segment.length >= MIN_TOKEN_LEN).some(isSecretSegment);
1290
+ }
1291
+ return isSecretSegment(run);
1292
+ }
1293
+ function removePemBlocks(lines) {
1294
+ const out = [];
1295
+ let inBlock = false;
1296
+ for (const line of lines) {
1297
+ if (!inBlock) {
1298
+ if (RE_PEM_BEGIN.test(line)) {
1299
+ inBlock = true;
1300
+ continue;
1301
+ }
1302
+ out.push(line);
1303
+ } else {
1304
+ if (RE_PEM_END.test(line)) {
1305
+ inBlock = false;
1306
+ }
1307
+ }
1308
+ }
1309
+ return out;
1310
+ }
1311
+ function maskLine(line) {
1312
+ let s6 = line;
1313
+ s6 = s6.replace(RE_URL_CREDS, "$1***$2");
1314
+ s6 = s6.replace(
1315
+ RE_KV_SECRET,
1316
+ (match, boundary, keyPart, value) => shouldMaskToken(value) ? `${boundary}${keyPart}***` : match
1317
+ );
1318
+ s6 = s6.replace(RE_PREFIXED_TOKEN, "***");
1319
+ s6 = s6.replace(
1320
+ RE_TOKEN_RUN,
1321
+ (match) => shouldMaskToken(match) ? "***" : match
1322
+ );
1323
+ return s6;
1324
+ }
1325
+ function scrubSecrets(line) {
1326
+ const withoutJsonKey = line.replace(RE_JSON_SA_FIELD, '$1"***"');
1327
+ const rawLines = withoutJsonKey.split("\n");
1328
+ const cleanLines = removePemBlocks(rawLines);
1329
+ const maskedLines = cleanLines.map(maskLine);
1330
+ return maskedLines.join("\n");
1331
+ }
1332
+ function redactLine(line) {
1333
+ const scrubbed = scrubSecrets(line);
1334
+ if (scrubbed.length > MAX_LENGTH) {
1335
+ return scrubbed.slice(0, MAX_LENGTH - 1) + "\u2026";
1336
+ }
1337
+ return scrubbed;
1338
+ }
1339
+ var MAX_LENGTH, MIN_TOKEN_LEN, ENTROPY_THRESHOLD, FORCE_MASK_PREFIXES, RE_URL_CREDS, RE_JSON_SA_FIELD, RE_PEM_BEGIN, RE_PEM_END, TOKEN_VALUE_CLASS, RE_KV_SECRET, RE_TOKEN_RUN, PREFIX_ALTERNATION, RE_PREFIXED_TOKEN, RE_ALL_HEX, RE_ALL_DIGIT, RE_BASE64_SPECIAL, RE_HAS_DIGIT, RE_HAS_LETTER;
1340
+ var init_redact_line = __esm({
1341
+ "src/core/redact-line.ts"() {
1342
+ "use strict";
1343
+ MAX_LENGTH = 256;
1344
+ MIN_TOKEN_LEN = 20;
1345
+ ENTROPY_THRESHOLD = 4;
1346
+ FORCE_MASK_PREFIXES = [
1347
+ "sk-",
1348
+ "sk_",
1349
+ "pk_",
1350
+ "ghp_",
1351
+ "gho_",
1352
+ "xoxb-",
1353
+ "xoxp-",
1354
+ "AKIA"
1355
+ ];
1356
+ RE_URL_CREDS = /(:\/\/[^/:@\s]+:)[^@\s]+(@)/g;
1357
+ RE_JSON_SA_FIELD = /("(?:private_key|client_email|private_key_id|client_id|client_x509_cert_url)"\s*:\s*)"[^"]*"/g;
1358
+ RE_PEM_BEGIN = /^\s*-----BEGIN [A-Z ]*PRIVATE KEY-----/i;
1359
+ RE_PEM_END = /-----END[A-Z -]*-----/i;
1360
+ TOKEN_VALUE_CLASS = "[A-Za-z0-9+/._-]";
1361
+ RE_KV_SECRET = new RegExp(
1362
+ `(^|\\s)([A-Za-z_][A-Za-z0-9_.]{0,63}\\s*[=:]\\s*)(${TOKEN_VALUE_CLASS}{12,}={0,2})`,
1363
+ "g"
1364
+ );
1365
+ RE_TOKEN_RUN = new RegExp(`${TOKEN_VALUE_CLASS}{${MIN_TOKEN_LEN},}`, "g");
1366
+ PREFIX_ALTERNATION = [...FORCE_MASK_PREFIXES].sort((a4, b3) => b3.length - a4.length).map(escapeRegex).join("|");
1367
+ RE_PREFIXED_TOKEN = new RegExp(
1368
+ `(?:${PREFIX_ALTERNATION})${TOKEN_VALUE_CLASS}*`,
1369
+ "g"
1370
+ );
1371
+ RE_ALL_HEX = /^[0-9a-fA-F]+$/;
1372
+ RE_ALL_DIGIT = /^[0-9]+$/;
1373
+ RE_BASE64_SPECIAL = /[+=]/;
1374
+ RE_HAS_DIGIT = /[0-9]/;
1375
+ RE_HAS_LETTER = /[A-Za-z]/;
1376
+ }
1377
+ });
1378
+
1264
1379
  // src/core/cli-logger.ts
1265
1380
  import chalk2 from "chalk";
1266
- function createCLILogger(options = {}) {
1381
+ function createCLILoggerConfig(options = {}) {
1267
1382
  const {
1268
1383
  verbose = false,
1269
1384
  silent = false,
@@ -1271,12 +1386,14 @@ function createCLILogger(options = {}) {
1271
1386
  stderr = false
1272
1387
  } = options;
1273
1388
  const out = stderr ? console.error : console.log;
1274
- return Ue({
1275
- // Let handler control visibility — pass everything through
1389
+ return {
1390
+ // Let handler control visibility — pass everything through. With the gate
1391
+ // at DEBUG, ERROR always reaches the handler (and the ring) even without
1392
+ // --verbose.
1276
1393
  level: l.DEBUG,
1277
1394
  handler: (level, message, _context, scope) => {
1278
1395
  const scopePath = scope.length > 0 ? `[${scope.join(":")}] ` : "";
1279
- const fullMessage = `${scopePath}${message}`;
1396
+ const fullMessage = scrubSecrets(`${scopePath}${message}`);
1280
1397
  try {
1281
1398
  options.onLine?.(level, fullMessage);
1282
1399
  } catch {
@@ -1296,12 +1413,16 @@ function createCLILogger(options = {}) {
1296
1413
  jsonHandler: (data) => {
1297
1414
  if (!silent) out(JSON.stringify(data, null, 2));
1298
1415
  }
1299
- });
1416
+ };
1417
+ }
1418
+ function createCLILogger(options = {}) {
1419
+ return Ue(createCLILoggerConfig(options));
1300
1420
  }
1301
1421
  var init_cli_logger = __esm({
1302
1422
  "src/core/cli-logger.ts"() {
1303
1423
  "use strict";
1304
1424
  init_dist();
1425
+ init_redact_line();
1305
1426
  }
1306
1427
  });
1307
1428
 
@@ -2122,7 +2243,7 @@ function An(e4) {
2122
2243
  for (const [e5, i4] of Object.entries(t4)) i4 && "object" == typeof i4 && ("object" === i4.type && i4.properties && "string" != typeof i4.title && (i4.title = e5), An(i4));
2123
2244
  }
2124
2245
  }
2125
- var e3, t3, i2, r3, a3, s4, c, l2, d, p, u, m2, f2, g2, h2, b2, v2, S, y, w2, k2, C, x, j, D3, P2, E2, O, I2, J2, $, z2, A, q2, L2, N, W, B2, U2, _, H, V, Z2, G2, K, Q2, X2, Y2, ee2, te2, ie, ne2, oe2, re2, ae2, se2, ce2, le3, de3, pe3, ue3, me3, fe2, ge3, he3, be3, ve3, Se2, ye3, we3, ke3, Ce2, xe2, je3, De3, Pe3, Ee3, Oe3, Ie3, Je3, Re3, Me3, Te3, Fe3, $e2, ze2, Ae2, qe3, Le3, Ne2, We3, Be3, Ue3, _e2, He3, Ve3, Ze2, Ge2, Ke3, Qe2, Xe2, Ye2, et2, tt2, it3, nt2, ot3, rt2, at2, st2, ct3, lt, dt2, pt2, ut2, mt3, ft2, gt3, ht3, bt2, vt2, St, yt3, wt2, kt2, Ct3, xt, jt, Dt2, Pt3, Et2, Ot, It, Jt2, Rt2, Mt2, Tt, Ft3, $t, zt, At2, qt, Lt2, Nt3, Wt3, Bt2, Ut3, _t2, Ht2, Vt2, Zt2, Gt2, Kt3, Qt2, Xt, Yt, ei, ti, ii, ni, oi, ri, ai, si, ci, li, di, pi, ui, mi, fi, gi, hi, bi, vi, Si, yi, wi, ki, Ci, xi, Di, Pi, Ei, Oi, Ii, Ji, Ri, Mi, Ti, Fi, $i, zi, Wi, Bi, Ui, _i, Hi, Vi, Zi, Gi, Ki, Qi, Yi, en, tn, nn2, on2, rn2, an2, cn2, fn2, gn2, hn, bn, vn, Sn, yn, wn, Ln;
2246
+ var e3, t3, i2, r3, a3, s4, c, l2, d, p, u, m2, f2, g2, h2, b2, v2, S, y, w2, k2, C, x, j, D3, P2, E2, O, I2, J2, $, z2, A, q2, L2, N, W, B2, U2, _, H, V, Z2, G2, K, Q2, X2, Y2, ee2, te2, ie, ne2, oe2, re2, ae2, se2, ce2, le3, de3, pe3, ue3, me3, fe2, ge3, he3, be3, ve3, Se2, ye3, we3, ke3, Ce2, xe2, je3, De3, Pe3, Ee3, Oe3, Ie3, Je3, Re3, Me3, Te3, Fe3, $e2, ze2, Ae2, qe3, Le3, Ne2, We3, Be3, Ue3, _e2, He3, Ve3, Ze2, Ge2, Ke3, Qe2, Xe2, Ye2, et2, tt2, it3, nt2, ot3, rt2, at2, st2, ct3, lt2, dt3, pt2, ut3, mt2, ft2, gt2, ht2, bt2, vt2, St2, yt3, wt2, kt2, Ct3, xt, jt, Dt2, Pt2, Et2, Ot, It2, Jt3, Rt2, Mt3, Tt, Ft2, $t, zt, At, qt2, Lt3, Nt3, Wt3, Bt2, Ut3, _t2, Ht3, Vt2, Zt2, Gt, Kt2, Qt2, Xt, Yt2, ei, ti, ii, ni, oi, ri, ai, si, ci, li, di, pi, ui, mi, fi, gi, hi, bi, vi, Si, yi, wi, ki, Ci, xi, Di, Pi, Ei, Oi, Ii, Ji, Ri, Mi, Ti, Fi, $i, zi, Wi, Bi, Ui, _i, Hi, Vi, Zi, Gi, Ki, Qi, Yi, en, tn, nn2, on2, rn2, an2, cn2, fn2, gn2, hn, bn, vn, Sn, yn, wn, Ln;
2126
2247
  var init_dev = __esm({
2127
2248
  "../core/dist/dev.mjs"() {
2128
2249
  "use strict";
@@ -2212,7 +2333,7 @@ var init_dev = __esm({
2212
2333
  Ie3 = o2(ye3);
2213
2334
  Je3 = o2(we3);
2214
2335
  Re3 = {};
2215
- t3(Re3, { BatchSchema: () => pt2, ConfigSchema: () => nt2, ContextSchema: () => at2, DLQSchema: () => yt3, DataSchema: () => ut2, DestinationPolicySchema: () => rt2, DestinationsSchema: () => ht3, InitDestinationsSchema: () => gt3, InitSchema: () => ft2, InstanceSchema: () => mt3, PartialConfigSchema: () => ot3, PushBatchContextSchema: () => ct3, PushContextSchema: () => st2, PushEventSchema: () => lt, PushEventsSchema: () => dt2, PushResultSchema: () => vt2, RefSchema: () => bt2, ResultSchema: () => St, batchJsonSchema: () => jt, configJsonSchema: () => wt2, contextJsonSchema: () => Ct3, instanceJsonSchema: () => Dt2, partialConfigJsonSchema: () => kt2, pushContextJsonSchema: () => xt, resultJsonSchema: () => Pt3 });
2336
+ t3(Re3, { BatchSchema: () => pt2, ConfigSchema: () => nt2, ContextSchema: () => at2, DLQSchema: () => yt3, DataSchema: () => ut3, DestinationPolicySchema: () => rt2, DestinationsSchema: () => ht2, InitDestinationsSchema: () => gt2, InitSchema: () => ft2, InstanceSchema: () => mt2, PartialConfigSchema: () => ot3, PushBatchContextSchema: () => ct3, PushContextSchema: () => st2, PushEventSchema: () => lt2, PushEventsSchema: () => dt3, PushResultSchema: () => vt2, RefSchema: () => bt2, ResultSchema: () => St2, batchJsonSchema: () => jt, configJsonSchema: () => wt2, contextJsonSchema: () => Ct3, instanceJsonSchema: () => Dt2, partialConfigJsonSchema: () => kt2, pushContextJsonSchema: () => xt, resultJsonSchema: () => Pt2 });
2216
2337
  Me3 = {};
2217
2338
  t3(Me3, { MatchExpressionSchema: () => $e2, RouteSchema: () => We3, RouteWithoutManySchema: () => He3 });
2218
2339
  Te3 = n3.enum(["eq", "contains", "prefix", "suffix", "regex", "gt", "lt", "exists"]).meta({ id: "MatcherOperator", title: "Matcher.Operator", description: "Supported operators for a match condition." });
@@ -2253,62 +2374,62 @@ var init_dev = __esm({
2253
2374
  }).meta({ id: "StateConfig", title: "State.Config", description: "Declarative store operation: stash (set) or fetch (get) a value against a store. key = store side, value = event side, mode = direction." });
2254
2375
  tt2 = n3.any().meta({ id: "LoggerHandler", title: "Logger.Handler", description: "Custom log handler function (level, ...args) => void" });
2255
2376
  it3 = n3.object({ level: n3.union([n3.number(), n3.enum(["ERROR", "WARN", "INFO", "DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"), handler: tt2.optional().describe("Custom log handler function") }).meta({ id: "LoggerConfig", title: "Logger.Config", description: "Logger configuration (level, handler) to override the collector defaults" });
2256
- nt2 = n3.object({ consent: Z2.optional().describe("Required consent states to send events to this destination"), settings: n3.any().meta({ id: "DestinationSettings", title: "Destination.Settings", description: "Implementation-specific configuration (destination-defined shape)." }).describe("Implementation-specific configuration").optional(), credentials: n3.any().meta({ id: "DestinationCredentials", title: "Destination.Credentials", description: "Optional credentials slot (destination-defined shape); supports $env. The per-package shape is supplied via mergeConfigSchema." }).describe("Optional credentials (destination-defined shape)").optional(), data: n3.union([pe3, ue3]).optional().describe("Global data transformation applied to all events for this destination"), include: n3.array(n3.string()).optional().describe("Event sections to flatten into context.data"), env: n3.any().meta({ id: "DestinationEnv", title: "Destination.Env", description: "Environment dependencies (destination-defined shape) \u2014 platform, SDK, or mock hook." }).describe("Environment dependencies (platform-specific)").optional(), id: c.describe("Destination instance identifier (defaults to destination key)").optional(), init: n3.boolean().describe("Whether to initialize immediately").optional(), loadScript: n3.boolean().describe("Whether to load external script (for web destinations)").optional(), mapping: ye3.optional().describe("Entity-action specific mapping rules for this destination"), policy: be3.optional().describe("Pre-processing policy rules applied before event mapping"), queue: n3.boolean().describe("Whether to queue events when consent is not granted").optional(), require: n3.array(n3.string()).optional().describe('Defer destination initialization until these collector events fire (e.g., ["consent"])'), logger: it3.optional().describe("Logger configuration (level, handler) to override the collector defaults"), setup: n3.union([n3.boolean(), n3.record(n3.string(), n3.unknown())]).optional().describe("One-time setup options applied during destination registration (boolean enables defaults, object configures specifics)"), before: He3.optional().describe("Post-collector transformer chain applied before this destination receives the event. `many` is not valid here \u2014 use multiple destinations for post-collector fan-out."), next: He3.optional().describe("Post-push transformer chain. Runs after destination push completes; push response is available at ingest._response. `many` is not valid here \u2014 use multiple destinations for post-collector fan-out."), cache: Ge2.optional().describe("Cache configuration for deduplication; skip push on cache HIT"), state: n3.union([et2, n3.array(et2)]).optional().describe("Declarative store get/set operations applied around this destination"), disabled: n3.boolean().describe("Completely skip this destination (no init, no push, no queue)").optional(), mock: n3.unknown().meta({ id: "DestinationMock", title: "Destination.Mock", description: "Return this value instead of calling push(). Dev/testing only." }).optional().describe("Return this value instead of calling push(). Dev/testing only."), queueMax: n3.number().optional().describe("Maximum consent-denied events retained in queuePush for this destination. FIFO drop on overflow. Default 1000."), dlqMax: n3.number().optional().describe("Maximum failed-push entries retained in dlq for this destination. FIFO drop on overflow. Default 100."), batch: n3.union([n3.number(), n3.object({ wait: n3.number().optional(), size: n3.number().optional(), age: n3.number().optional() })]).optional().describe("Enables batching for all of this destination's events into one shared default buffer; a mapping rule's own batch splits that entity-action into its own buffer and overrides per field. Bare number is the debounce wait window; object form supports wait (debounce ms), size (count cap, default 1000), age (max ms since first entry, default 30000).") }).meta({ id: "DestinationConfig", title: "Destination.Config", description: "Destination configuration: consent, settings, data, env, mapping rules, policy, queue, logger, before/next chains, cache." }).describe("Destination configuration");
2377
+ nt2 = n3.object({ consent: Z2.optional().describe("Required consent states to send events to this destination"), settings: n3.any().meta({ id: "DestinationSettings", title: "Destination.Settings", description: "Implementation-specific configuration (destination-defined shape)." }).describe("Implementation-specific configuration").optional(), credentials: n3.any().meta({ id: "DestinationCredentials", title: "Destination.Credentials", description: "Optional credentials slot (destination-defined shape); supports $env. The per-package shape is supplied via mergeConfigSchema." }).describe("Optional credentials (destination-defined shape)").optional(), data: n3.union([pe3, ue3]).optional().describe("Global data transformation applied to all events for this destination"), include: n3.array(n3.string()).optional().describe("Event sections to flatten into context.data"), env: n3.any().meta({ id: "DestinationEnv", title: "Destination.Env", description: "Environment dependencies (destination-defined shape) \u2014 platform, SDK, or mock hook." }).describe("Environment dependencies (platform-specific)").optional(), id: c.describe("Destination instance identifier (defaults to destination key)").optional(), init: n3.boolean().describe("Whether to initialize immediately").optional(), loadScript: n3.boolean().describe("Whether to load external script (for web destinations)").optional(), mapping: ye3.optional().describe("Entity-action specific mapping rules for this destination"), policy: be3.optional().describe("Pre-processing policy rules applied before event mapping"), queue: n3.boolean().describe("Whether to queue events when consent is not granted").optional(), require: n3.array(n3.string()).optional().describe('Defer destination initialization until these collector events fire (e.g., ["consent"])'), logger: it3.optional().describe("Logger configuration (level, handler) to override the collector defaults"), setup: n3.union([n3.boolean(), n3.record(n3.string(), n3.unknown())]).optional().describe("One-time setup options applied during destination registration (boolean enables defaults, object configures specifics)"), before: He3.optional().describe("Post-collector transformer chain applied before this destination receives the event. `many` is not valid here \u2014 use multiple destinations for post-collector fan-out."), next: He3.optional().describe("Post-push transformer chain. Runs after destination push completes; push response is available at ingest._response. `many` is not valid here \u2014 use multiple destinations for post-collector fan-out."), cache: Ge2.optional().describe("Cache configuration for deduplication; skip push on cache HIT"), state: n3.union([et2, n3.array(et2)]).optional().describe("Declarative store get/set operations applied around this destination"), disabled: n3.boolean().describe("Completely skip this destination (no init, no push, no queue)").optional(), mock: n3.unknown().meta({ id: "DestinationMock", title: "Destination.Mock", description: "Return this value instead of calling push(). Dev/testing only." }).optional().describe("Return this value instead of calling push(). Dev/testing only."), queueMax: n3.number().optional().describe("Maximum consent-denied events retained in queuePush for this destination. FIFO drop on overflow. Default 1000."), dlqMax: n3.number().optional().describe("Maximum failed-push entries retained in dlq for this destination. FIFO drop on overflow. Default 100."), timeout: n3.number().optional().describe("Per-destination delivery timeout in ms (default 10000); a delivery that does not settle in this window is routed to the DLQ like a thrown push."), batch: n3.union([n3.number(), n3.object({ wait: n3.number().optional(), size: n3.number().optional(), age: n3.number().optional() })]).optional().describe("Enables batching for all of this destination's events into one shared default buffer; a mapping rule's own batch splits that entity-action into its own buffer and overrides per field. Bare number is the debounce wait window; object form supports wait (debounce ms), size (count cap, default 1000), age (max ms since first entry, default 30000).") }).meta({ id: "DestinationConfig", title: "Destination.Config", description: "Destination configuration: consent, settings, data, env, mapping rules, policy, queue, logger, before/next chains, cache." }).describe("Destination configuration");
2257
2378
  ot3 = nt2.partial().meta({ id: "DestinationPartialConfig", title: "Destination.PartialConfig", description: "Partial destination configuration with all fields optional." }).describe("Partial destination configuration with all fields optional");
2258
2379
  rt2 = be3.describe("Destination policy rules for event pre-processing");
2259
2380
  at2 = n3.object({ collector: n3.unknown().meta({ id: "DestinationContextCollector", title: "Collector.Instance", description: "Collector instance handed to the destination (runtime object)." }).describe("Collector instance (runtime object)"), config: nt2.describe("Destination configuration"), data: n3.union([n3.unknown(), n3.array(n3.unknown())]).optional().describe("Transformed event data"), env: n3.unknown().meta({ id: "DestinationContextEnv", title: "Destination.Env", description: "Environment dependencies (destination-defined shape)." }).describe("Environment dependencies") }).meta({ id: "DestinationContext", title: "Destination.Context", description: "Destination context passed to init and push functions." }).describe("Destination context for init and push functions");
2260
2381
  st2 = at2.extend({ mapping: Se2.optional().describe("Resolved mapping rule for this specific event") }).meta({ id: "DestinationPushContext", title: "Destination.PushContext", description: "Destination context for push() with the resolved event mapping rule." }).describe("Push context with event-specific mapping");
2261
2382
  ct3 = st2.describe("Batch push context with event-specific mapping");
2262
- lt = n3.object({ event: Y2.describe("The event to process"), mapping: Se2.optional().describe("Mapping rule for this event") }).meta({ id: "DestinationPushEvent", title: "Destination.PushEvent", description: "Single event paired with its resolved mapping rule (batch element)." }).describe("Event with optional mapping for batch processing");
2263
- dt2 = n3.array(lt).meta({ id: "DestinationPushEvents", title: "Destination.PushEvents", description: "Array of events with mappings (batch input)." }).describe("Array of events with mappings");
2383
+ lt2 = n3.object({ event: Y2.describe("The event to process"), mapping: Se2.optional().describe("Mapping rule for this event") }).meta({ id: "DestinationPushEvent", title: "Destination.PushEvent", description: "Single event paired with its resolved mapping rule (batch element)." }).describe("Event with optional mapping for batch processing");
2384
+ dt3 = n3.array(lt2).meta({ id: "DestinationPushEvents", title: "Destination.PushEvents", description: "Array of events with mappings (batch input)." }).describe("Array of events with mappings");
2264
2385
  pt2 = n3.object({ key: n3.string().describe('Batch key (usually mapping key like "product.view")'), events: n3.array(Y2).describe("Array of events in batch"), data: n3.array(n3.union([n3.unknown(), n3.array(n3.unknown())]).optional()).describe("Transformed data for each event"), mapping: Se2.optional().describe("Shared mapping rule for batch") }).meta({ id: "DestinationBatch", title: "Destination.Batch", description: "Batch of events grouped by mapping key for batch delivery." }).describe("Batch of events grouped by mapping key");
2265
- ut2 = n3.union([n3.unknown(), n3.array(n3.unknown())]).meta({ id: "DestinationData", title: "Destination.Data", description: "Transformed event data delivered to the destination (Property, undefined, or array)." }).optional().describe("Transformed event data (Property, undefined, or array)");
2266
- mt3 = n3.object({ config: nt2.describe("Destination configuration"), queue: n3.array(Y2).optional().describe("Queued events awaiting consent"), dlq: n3.array(n3.tuple([Y2, n3.unknown()])).optional().describe("Dead letter queue (failed events with errors)"), type: n3.string().optional().describe("Destination type identifier"), env: n3.unknown().optional().describe("Environment dependencies"), init: n3.unknown().optional().describe("Initialization function"), push: n3.unknown().describe("Push function for single events"), pushBatch: n3.unknown().optional().describe("Batch push function"), on: n3.unknown().optional().describe("Event lifecycle hook function") }).meta({ id: "DestinationInstance", title: "Destination.Instance", description: "Destination instance (runtime object with init/push/pushBatch/on)." }).describe("Destination instance (runtime object with functions)");
2267
- ft2 = n3.object({ code: mt3.describe("Destination instance with implementation"), config: ot3.optional().describe("Partial configuration overrides"), env: n3.unknown().optional().describe("Partial environment overrides") }).meta({ id: "DestinationInit", title: "Destination.Init", description: "Destination initialization bundle (instance code + config + env)." }).describe("Destination initialization configuration");
2268
- gt3 = n3.record(n3.string(), ft2).meta({ id: "DestinationInitDestinations", title: "Destination.InitDestinations", description: "Map of destination IDs to initialization configurations." }).describe("Map of destination IDs to initialization configurations");
2269
- ht3 = n3.record(n3.string(), mt3).meta({ id: "DestinationDestinations", title: "Destination.Destinations", description: "Map of destination IDs to runtime destination instances." }).describe("Map of destination IDs to runtime instances");
2386
+ ut3 = n3.union([n3.unknown(), n3.array(n3.unknown())]).meta({ id: "DestinationData", title: "Destination.Data", description: "Transformed event data delivered to the destination (Property, undefined, or array)." }).optional().describe("Transformed event data (Property, undefined, or array)");
2387
+ mt2 = n3.object({ config: nt2.describe("Destination configuration"), queue: n3.array(Y2).optional().describe("Queued events awaiting consent"), dlq: n3.array(n3.tuple([Y2, n3.unknown()])).optional().describe("Dead letter queue (failed events with errors)"), type: n3.string().optional().describe("Destination type identifier"), env: n3.unknown().optional().describe("Environment dependencies"), init: n3.unknown().optional().describe("Initialization function"), push: n3.unknown().describe("Push function for single events"), pushBatch: n3.unknown().optional().describe("Batch push function"), on: n3.unknown().optional().describe("Event lifecycle hook function") }).meta({ id: "DestinationInstance", title: "Destination.Instance", description: "Destination instance (runtime object with init/push/pushBatch/on)." }).describe("Destination instance (runtime object with functions)");
2388
+ ft2 = n3.object({ code: mt2.describe("Destination instance with implementation"), config: ot3.optional().describe("Partial configuration overrides"), env: n3.unknown().optional().describe("Partial environment overrides") }).meta({ id: "DestinationInit", title: "Destination.Init", description: "Destination initialization bundle (instance code + config + env)." }).describe("Destination initialization configuration");
2389
+ gt2 = n3.record(n3.string(), ft2).meta({ id: "DestinationInitDestinations", title: "Destination.InitDestinations", description: "Map of destination IDs to initialization configurations." }).describe("Map of destination IDs to initialization configurations");
2390
+ ht2 = n3.record(n3.string(), mt2).meta({ id: "DestinationDestinations", title: "Destination.Destinations", description: "Map of destination IDs to runtime destination instances." }).describe("Map of destination IDs to runtime instances");
2270
2391
  bt2 = n3.object({ type: n3.string().describe('Destination type ("gtag", "meta", "bigquery")'), data: n3.unknown().optional().describe("Response from push()"), error: n3.unknown().optional().describe("Error if failed") }).meta({ id: "DestinationRef", title: "Destination.Ref", description: "Reference to a destination outcome (type + response data or error)." }).describe("Destination reference with type and response data");
2271
2392
  vt2 = n3.object({ queue: n3.array(Y2).optional().describe("Events queued (awaiting consent)"), error: n3.unknown().optional().describe("Error if push failed") }).meta({ id: "DestinationPushResult", title: "Destination.PushResult", description: "Result of a single destination push (queued events, optional error)." }).describe("Push operation result");
2272
- St = n3.object({ ok: n3.boolean().describe("True if nothing failed"), event: n3.unknown().optional().describe("The processed event"), done: n3.record(n3.string(), bt2).optional().describe("Destinations that processed successfully"), queued: n3.record(n3.string(), bt2).optional().describe("Destinations that queued events"), failed: n3.record(n3.string(), bt2).optional().describe("Destinations that failed to process") }).meta({ id: "DestinationResult", title: "Destination.Result", description: "Overall push result aggregated across all destinations (done/queued/failed maps)." }).describe("Push result with destination outcomes");
2393
+ St2 = n3.object({ ok: n3.boolean().describe("True if nothing failed"), event: n3.unknown().optional().describe("The processed event"), done: n3.record(n3.string(), bt2).optional().describe("Destinations that processed successfully"), queued: n3.record(n3.string(), bt2).optional().describe("Destinations that queued events"), failed: n3.record(n3.string(), bt2).optional().describe("Destinations that failed to process") }).meta({ id: "DestinationResult", title: "Destination.Result", description: "Overall push result aggregated across all destinations (done/queued/failed maps)." }).describe("Push result with destination outcomes");
2273
2394
  yt3 = n3.array(n3.tuple([Y2, n3.unknown()])).meta({ id: "DestinationDLQ", title: "Destination.DLQ", description: "Dead-letter queue: list of [event, error] tuples." }).describe("Dead letter queue: [(event, error), ...]");
2274
2395
  wt2 = o2(nt2);
2275
2396
  kt2 = o2(ot3);
2276
2397
  Ct3 = o2(at2);
2277
2398
  xt = o2(st2);
2278
2399
  jt = o2(pt2);
2279
- Dt2 = o2(mt3);
2280
- Pt3 = o2(St);
2400
+ Dt2 = o2(mt2);
2401
+ Pt2 = o2(St2);
2281
2402
  Et2 = {};
2282
- t3(Et2, { CommandTypeSchema: () => Ot, ConfigSchema: () => It, DestinationsSchema: () => Ft3, InitConfigSchema: () => Rt2, InstanceSchema: () => $t, PushContextSchema: () => Mt2, SessionDataSchema: () => Jt2, SourcesSchema: () => Tt, commandTypeJsonSchema: () => zt, configJsonSchema: () => At2, initConfigJsonSchema: () => Lt2, instanceJsonSchema: () => Wt3, pushContextJsonSchema: () => Nt3, sessionDataJsonSchema: () => qt });
2403
+ t3(Et2, { CommandTypeSchema: () => Ot, ConfigSchema: () => It2, DestinationsSchema: () => Ft2, InitConfigSchema: () => Rt2, InstanceSchema: () => $t, PushContextSchema: () => Mt3, SessionDataSchema: () => Jt3, SourcesSchema: () => Tt, commandTypeJsonSchema: () => zt, configJsonSchema: () => At, initConfigJsonSchema: () => Lt3, instanceJsonSchema: () => Wt3, pushContextJsonSchema: () => Nt3, sessionDataJsonSchema: () => qt2 });
2283
2404
  Ot = n3.union([n3.enum(["action", "config", "consent", "context", "destination", "elb", "globals", "hook", "init", "link", "run", "user", "walker"]), n3.string()]).meta({ id: "CollectorCommandType", title: "Collector.CommandType", description: "Collector command type identifier (standard or extension string)." }).describe("Collector command type: standard commands or custom string for extensions");
2284
- It = n3.object({ run: n3.boolean().describe("Whether to run collector automatically on initialization").optional(), globalsStatic: _.describe("Static global properties that persist across collector runs"), sessionStatic: n3.record(n3.string(), n3.unknown()).meta({ id: "CollectorSessionStatic", title: "Collector.SessionStatic", description: "Static session data that persists across collector runs." }).describe("Static session data that persists across collector runs"), logger: it3.optional().describe("Logger configuration (level, handler)"), queueMax: n3.number().optional().describe("Maximum events retained in collector.queue (late-registration replay). FIFO drop on overflow. Default 1000.") }).meta({ id: "CollectorConfig", title: "Collector.Config", description: "Core collector configuration (globals/session statics, logger, buffer bounds)." }).describe("Core collector configuration");
2285
- Jt2 = _.and(n3.object({ isStart: n3.boolean().describe("Whether this is a new session start"), storage: n3.boolean().describe("Whether storage is available"), id: c.describe("Session identifier").optional(), start: l2.describe("Session start timestamp").optional(), marketing: n3.literal(true).optional().describe("Marketing attribution flag"), updated: l2.describe("Last update timestamp").optional(), isNew: n3.boolean().describe("Whether this is a new session").optional(), device: c.describe("Device identifier").optional(), count: d.describe("Event count in session").optional(), runs: d.describe("Number of runs").optional() })).meta({ id: "CollectorSessionData", title: "Collector.SessionData", description: "Session state and tracking data." }).describe("Session state and tracking data");
2286
- Rt2 = It.partial().extend({ consent: Z2.optional().describe("Initial consent state"), user: G2.optional().describe("Initial user data"), globals: _.optional().describe("Initial global properties"), sources: n3.unknown().meta({ id: "CollectorInitSources", title: "Source.InitSources", description: "Source configurations map (id \u2192 InitSource)." }).optional().describe("Source configurations"), destinations: n3.unknown().meta({ id: "CollectorInitDestinations", title: "Destination.InitDestinations", description: "Destination configurations map (id \u2192 Init)." }).optional().describe("Destination configurations"), transformers: n3.unknown().meta({ id: "CollectorInitTransformers", title: "Transformer.Configs", description: "Transformer configurations map (id \u2192 Config)." }).optional().describe("Transformer configurations"), stores: n3.unknown().meta({ id: "CollectorInitStores", title: "Store.Configs", description: "Store configurations map (id \u2192 Config)." }).optional().describe("Store configurations"), custom: _.optional().describe("Initial custom implementation-specific properties"), hooks: n3.unknown().meta({ id: "CollectorHooks", title: "Collector.Hooks", description: "Pipeline observation hooks." }).optional().describe("Pipeline observation hooks") }).meta({ id: "CollectorInitConfig", title: "Collector.InitConfig", description: "Collector initialization configuration with initial state (consent, user, globals, components, hooks)." }).describe("Collector initialization configuration with initial state");
2287
- Mt2 = n3.object({ mapping: we3.optional().describe("Source-level mapping configuration") }).meta({ id: "CollectorPushContext", title: "Collector.PushContext", description: "Push context with optional source-level mapping." }).describe("Push context with optional source mapping");
2405
+ It2 = n3.object({ run: n3.boolean().describe("Whether to run collector automatically on initialization").optional(), globalsStatic: _.describe("Static global properties that persist across collector runs"), sessionStatic: n3.record(n3.string(), n3.unknown()).meta({ id: "CollectorSessionStatic", title: "Collector.SessionStatic", description: "Static session data that persists across collector runs." }).describe("Static session data that persists across collector runs"), logger: it3.optional().describe("Logger configuration (level, handler)"), queueMax: n3.number().optional().describe("Maximum events retained in collector.queue (late-registration replay). FIFO drop on overflow. Default 1000.") }).meta({ id: "CollectorConfig", title: "Collector.Config", description: "Core collector configuration (globals/session statics, logger, buffer bounds)." }).describe("Core collector configuration");
2406
+ Jt3 = _.and(n3.object({ isStart: n3.boolean().describe("Whether this is a new session start"), storage: n3.boolean().describe("Whether storage is available"), id: c.describe("Session identifier").optional(), start: l2.describe("Session start timestamp").optional(), marketing: n3.literal(true).optional().describe("Marketing attribution flag"), updated: l2.describe("Last update timestamp").optional(), isNew: n3.boolean().describe("Whether this is a new session").optional(), device: c.describe("Device identifier").optional(), count: d.describe("Event count in session").optional(), runs: d.describe("Number of runs").optional() })).meta({ id: "CollectorSessionData", title: "Collector.SessionData", description: "Session state and tracking data." }).describe("Session state and tracking data");
2407
+ Rt2 = It2.partial().extend({ consent: Z2.optional().describe("Initial consent state"), user: G2.optional().describe("Initial user data"), globals: _.optional().describe("Initial global properties"), sources: n3.unknown().meta({ id: "CollectorInitSources", title: "Source.InitSources", description: "Source configurations map (id \u2192 InitSource)." }).optional().describe("Source configurations"), destinations: n3.unknown().meta({ id: "CollectorInitDestinations", title: "Destination.InitDestinations", description: "Destination configurations map (id \u2192 Init)." }).optional().describe("Destination configurations"), transformers: n3.unknown().meta({ id: "CollectorInitTransformers", title: "Transformer.Configs", description: "Transformer configurations map (id \u2192 Config)." }).optional().describe("Transformer configurations"), stores: n3.unknown().meta({ id: "CollectorInitStores", title: "Store.Configs", description: "Store configurations map (id \u2192 Config)." }).optional().describe("Store configurations"), custom: _.optional().describe("Initial custom implementation-specific properties"), hooks: n3.unknown().meta({ id: "CollectorHooks", title: "Collector.Hooks", description: "Pipeline observation hooks." }).optional().describe("Pipeline observation hooks") }).meta({ id: "CollectorInitConfig", title: "Collector.InitConfig", description: "Collector initialization configuration with initial state (consent, user, globals, components, hooks)." }).describe("Collector initialization configuration with initial state");
2408
+ Mt3 = n3.object({ mapping: we3.optional().describe("Source-level mapping configuration") }).meta({ id: "CollectorPushContext", title: "Collector.PushContext", description: "Push context with optional source-level mapping." }).describe("Push context with optional source mapping");
2288
2409
  Tt = n3.record(n3.string(), n3.unknown()).meta({ id: "CollectorSources", title: "Collector.Sources", description: "Map of source IDs to runtime source instances." }).describe("Map of source IDs to source instances");
2289
- Ft3 = n3.record(n3.string(), n3.unknown()).meta({ id: "CollectorDestinations", title: "Collector.Destinations", description: "Map of destination IDs to runtime destination instances." }).describe("Map of destination IDs to destination instances");
2290
- $t = n3.object({ push: n3.unknown().describe("Push function for processing events"), command: n3.unknown().describe("Command function for walker commands"), allowed: n3.boolean().describe("Whether event processing is allowed"), config: It.describe("Current collector configuration"), consent: Z2.describe("Current consent state"), custom: _.describe("Custom implementation-specific properties"), sources: Tt.describe("Registered source instances"), destinations: Ft3.describe("Registered destination instances"), globals: _.describe("Current global properties"), hooks: n3.unknown().describe("Lifecycle hook functions"), on: n3.unknown().describe("Event lifecycle configuration"), queue: n3.array(Y2).describe("Queued events awaiting processing"), round: n3.number().describe("Collector run count (increments with each run)"), session: n3.union([Jt2]).describe("Current session state"), timing: n3.number().describe("Event processing timing information"), user: G2.describe("Current user data") }).meta({ id: "CollectorInstance", title: "Collector.Instance", description: "Collector instance (runtime object with push/command + full state and component maps)." }).describe("Collector instance with state and methods");
2410
+ Ft2 = n3.record(n3.string(), n3.unknown()).meta({ id: "CollectorDestinations", title: "Collector.Destinations", description: "Map of destination IDs to runtime destination instances." }).describe("Map of destination IDs to destination instances");
2411
+ $t = n3.object({ push: n3.unknown().describe("Push function for processing events"), command: n3.unknown().describe("Command function for walker commands"), allowed: n3.boolean().describe("Whether event processing is allowed"), config: It2.describe("Current collector configuration"), consent: Z2.describe("Current consent state"), custom: _.describe("Custom implementation-specific properties"), sources: Tt.describe("Registered source instances"), destinations: Ft2.describe("Registered destination instances"), globals: _.describe("Current global properties"), hooks: n3.unknown().describe("Lifecycle hook functions"), on: n3.unknown().describe("Event lifecycle configuration"), queue: n3.array(Y2).describe("Queued events awaiting processing"), round: n3.number().describe("Collector run count (increments with each run)"), session: n3.union([Jt3]).describe("Current session state"), timing: n3.number().describe("Event processing timing information"), user: G2.describe("Current user data") }).meta({ id: "CollectorInstance", title: "Collector.Instance", description: "Collector instance (runtime object with push/command + full state and component maps)." }).describe("Collector instance with state and methods");
2291
2412
  zt = o2(Ot);
2292
- At2 = o2(It);
2293
- qt = o2(Jt2);
2294
- Lt2 = o2(Rt2);
2295
- Nt3 = o2(Mt2);
2413
+ At = o2(It2);
2414
+ qt2 = o2(Jt3);
2415
+ Lt3 = o2(Rt2);
2416
+ Nt3 = o2(Mt3);
2296
2417
  Wt3 = o2($t);
2297
2418
  Bt2 = {};
2298
- t3(Bt2, { BaseEnvSchema: () => Ut3, ConfigSchema: () => _t2, InitSchema: () => Zt2, InitSourceSchema: () => Gt2, InitSourcesSchema: () => Kt3, InstanceSchema: () => Vt2, PartialConfigSchema: () => Ht2, baseEnvJsonSchema: () => Qt2, configJsonSchema: () => Xt, initSourceJsonSchema: () => ti, initSourcesJsonSchema: () => ii, instanceJsonSchema: () => ei, partialConfigJsonSchema: () => Yt });
2419
+ t3(Bt2, { BaseEnvSchema: () => Ut3, ConfigSchema: () => _t2, InitSchema: () => Zt2, InitSourceSchema: () => Gt, InitSourcesSchema: () => Kt2, InstanceSchema: () => Vt2, PartialConfigSchema: () => Ht3, baseEnvJsonSchema: () => Qt2, configJsonSchema: () => Xt, initSourceJsonSchema: () => ti, initSourcesJsonSchema: () => ii, instanceJsonSchema: () => ei, partialConfigJsonSchema: () => Yt2 });
2299
2420
  Ut3 = n3.object({ push: n3.unknown().meta({ id: "SourcePushFn", title: "Source.PushFn", description: "Collector push function passed to the source via dependency injection." }).describe("Collector push function"), command: n3.unknown().meta({ id: "SourceCommandFn", title: "Source.CommandFn", description: "Collector command function passed to the source." }).describe("Collector command function"), sources: n3.unknown().optional().describe("Map of registered source instances"), elb: n3.unknown().meta({ id: "ElbFn", title: "Elb.Fn", description: "Public `elb(...)` API function alias for collector.push." }).describe("Public API function (alias for collector.push)") }).catchall(n3.unknown()).meta({ id: "SourceBaseEnv", title: "Source.BaseEnv", description: "Base environment for source dependency injection; platform-specific sources extend this." }).describe("Base environment for dependency injection - platform-specific sources extend this");
2300
2421
  _t2 = we3.extend({ settings: n3.any().meta({ id: "SourceSettings", title: "Source.Settings", description: "Implementation-specific configuration (source-defined shape)." }).describe("Implementation-specific configuration").optional(), credentials: n3.any().meta({ id: "SourceCredentials", title: "Source.Credentials", description: "Optional credentials slot (source-defined shape); supports $env. The per-package shape is supplied via mergeConfigSchema." }).describe("Optional credentials (source-defined shape)").optional(), env: Ut3.optional().describe("Environment dependencies (platform-specific)"), id: c.describe("Source identifier (defaults to source key)").optional(), primary: n3.boolean().describe("Mark as primary (only one can be primary)").optional(), require: n3.array(n3.string()).optional().describe('Defer source initialization until these collector events fire (e.g., ["consent"])'), logger: it3.optional().describe("Logger configuration (level, handler) to override the collector defaults"), setup: n3.union([n3.boolean(), n3.record(n3.string(), n3.unknown())]).optional().describe("One-time setup options applied during source registration (boolean enables defaults, object configures specifics)"), ingest: n3.union([pe3, ue3]).optional().describe("Ingest metadata extraction mapping. Extracts values from raw request objects (Express req, Lambda event) using mapping syntax."), disabled: n3.boolean().describe("Completely skip this source (no init, no event capture)").optional(), state: n3.union([et2, n3.array(et2)]).optional().describe("Declarative store get/set operations applied around this source"), init: n3.boolean().optional().describe("Init lifecycle flag set by collector to true after Instance.init() runs") }).meta({ id: "SourceConfig", title: "Source.Config", description: "Source configuration with mapping, environment, and lifecycle hooks." }).describe("Source configuration with mapping and environment");
2301
- Ht2 = _t2.partial().meta({ id: "SourcePartialConfig", title: "Source.PartialConfig", description: "Partial source configuration with all fields optional." }).describe("Partial source configuration with all fields optional");
2422
+ Ht3 = _t2.partial().meta({ id: "SourcePartialConfig", title: "Source.PartialConfig", description: "Partial source configuration with all fields optional." }).describe("Partial source configuration with all fields optional");
2302
2423
  Vt2 = n3.object({ type: n3.string().describe('Source type identifier (e.g., "browser", "dataLayer")'), config: _t2.describe("Current source configuration"), push: n3.any().meta({ id: "SourceInstancePushFn", title: "Source.PushFn", description: "Push function \u2014 THE HANDLER (flexible signature for platform compatibility)." }).describe("Push function - THE HANDLER (flexible signature for platform compatibility)"), destroy: n3.any().meta({ id: "SourceDestroyFn", title: "Source.DestroyFn", description: "Cleanup function called when the source is removed." }).optional().describe("Cleanup function called when source is removed"), on: n3.unknown().optional().describe("Lifecycle hook function for event types") }).meta({ id: "SourceInstance", title: "Source.Instance", description: "Source instance (runtime object with push handler and lifecycle methods)." }).describe("Source instance with push handler and lifecycle methods");
2303
2424
  Zt2 = n3.any().meta({ id: "SourceInit", title: "Source.Init", description: "Source initialization function: (config, env) => Instance | Promise<Instance>." }).describe("Source initialization function: (config, env) => Instance | Promise<Instance>");
2304
- Gt2 = n3.object({ code: Zt2.describe("Source initialization function"), config: Ht2.optional().describe("Partial configuration overrides"), env: Ut3.partial().optional().describe("Partial environment overrides"), state: n3.union([et2, n3.array(et2)]).optional().describe("Declarative store get/set operations applied around this source"), primary: n3.boolean().optional().describe("Mark as primary source (only one can be primary)") }).meta({ id: "SourceInitSource", title: "Source.InitSource", description: "Source initialization bundle (init function + config + env + primary flag)." }).describe("Source initialization configuration");
2305
- Kt3 = n3.record(n3.string(), Gt2).meta({ id: "SourceInitSources", title: "Source.InitSources", description: "Map of source IDs to initialization configurations." }).describe("Map of source IDs to initialization configurations");
2425
+ Gt = n3.object({ code: Zt2.describe("Source initialization function"), config: Ht3.optional().describe("Partial configuration overrides"), env: Ut3.partial().optional().describe("Partial environment overrides"), state: n3.union([et2, n3.array(et2)]).optional().describe("Declarative store get/set operations applied around this source"), primary: n3.boolean().optional().describe("Mark as primary source (only one can be primary)") }).meta({ id: "SourceInitSource", title: "Source.InitSource", description: "Source initialization bundle (init function + config + env + primary flag)." }).describe("Source initialization configuration");
2426
+ Kt2 = n3.record(n3.string(), Gt).meta({ id: "SourceInitSources", title: "Source.InitSources", description: "Map of source IDs to initialization configurations." }).describe("Map of source IDs to initialization configurations");
2306
2427
  Qt2 = o2(Ut3);
2307
2428
  Xt = o2(_t2);
2308
- Yt = o2(Ht2);
2429
+ Yt2 = o2(Ht3);
2309
2430
  ei = o2(Vt2);
2310
- ti = o2(Gt2);
2311
- ii = o2(Kt3);
2431
+ ti = o2(Gt);
2432
+ ii = o2(Kt2);
2312
2433
  ni = {};
2313
2434
  t3(ni, { ConfigSchema: () => oi, PartialConfigSchema: () => ri, configJsonSchema: () => ai, partialConfigJsonSchema: () => si });
2314
2435
  oi = n3.object({ settings: n3.any().meta({ id: "TransformerSettings", title: "Transformer.Settings", description: "Implementation-specific configuration (transformer-defined shape)." }).describe("Implementation-specific configuration").optional(), env: n3.any().meta({ id: "TransformerEnv", title: "Transformer.Env", description: "Environment dependencies (transformer-defined shape)." }).describe("Environment dependencies (platform-specific)").optional(), id: c.describe("Transformer instance identifier (defaults to transformer key)").optional(), logger: it3.optional().describe("Logger configuration (level, handler) to override the collector defaults"), before: We3.optional().describe("Pre-transformer chain that runs before this transformer pushes"), next: We3.optional().describe("Graph wiring to the next transformer in the chain"), cache: Ge2.optional().describe("Step-level cache configuration for this transformer"), state: n3.union([et2, n3.array(et2)]).optional().describe("Declarative store get/set operations applied around this transformer"), init: n3.boolean().describe("Whether to initialize immediately").optional(), disabled: n3.boolean().describe("Completely skip this transformer in chains").optional(), mock: n3.unknown().meta({ id: "TransformerMock", title: "Transformer.Mock", description: "Return this value instead of calling push(). Dev/testing only." }).optional().describe("Return this value instead of calling push(). Global mock for all chains. Dev/testing only."), chainMocks: n3.record(n3.string(), n3.unknown().meta({ id: "TransformerChainMock", title: "Transformer.ChainMock", description: "Chain-path-specific mock value. Dev/testing only." })).optional().describe("Path-specific mock values keyed by chain path. Takes precedence over global mock. Dev/testing only."), mapping: we3.optional().describe("Declarative event-to-event mapping applied when this transformer step has no code. At this position, only event-mutating fields apply (policy, mapping[].policy, mapping[].name, mapping[].ignore, mapping[].consent, include); vendor-payload fields are ignored.") }).strict().meta({ id: "TransformerConfig", title: "Transformer.Config", description: "Transformer configuration (settings, env, chain wiring, cache, mocks)." }).describe("Transformer configuration");
@@ -2966,16 +3087,81 @@ async function loadNpmConfigForPacote(projectDir = process.cwd(), homeDir = os3.
2966
3087
  }
2967
3088
  return { ...merged, registry, preferOnline: true };
2968
3089
  }
2969
- async function withTimeout2(promise, ms, errorMessage) {
2970
- let timer;
2971
- const timeout = new Promise((_2, reject) => {
2972
- timer = setTimeout(() => reject(new Error(errorMessage)), ms);
3090
+ function readErrorCode(value) {
3091
+ if (typeof value !== "object" || value === null) return void 0;
3092
+ const code = Reflect.get(value, "code");
3093
+ return typeof code === "string" ? code : void 0;
3094
+ }
3095
+ function isPermanentError(error) {
3096
+ const code = readErrorCode(error);
3097
+ return code !== void 0 && PERMANENT_ERROR_CODES.has(code);
3098
+ }
3099
+ function backoffForAttempt(index) {
3100
+ const base = BASE_BACKOFF_MS[Math.min(index, BASE_BACKOFF_MS.length - 1)] ?? 0;
3101
+ const spread = base * JITTER;
3102
+ return base + (Math.random() * 2 - 1) * spread;
3103
+ }
3104
+ function delay(ms) {
3105
+ return new Promise((resolve4) => {
3106
+ setTimeout(resolve4, ms);
2973
3107
  });
2974
- try {
2975
- return await Promise.race([promise, timeout]);
2976
- } finally {
2977
- clearTimeout(timer);
3108
+ }
3109
+ function describeError(error) {
3110
+ if (error instanceof Error) return error.message;
3111
+ return String(error);
3112
+ }
3113
+ function withSignal(opts, signal) {
3114
+ return { ...opts, signal };
3115
+ }
3116
+ async function withPacoteRetry(fn3, label, options = {}) {
3117
+ const attempts = options.attempts ?? PACOTE_RETRY_ATTEMPTS;
3118
+ const perAttemptTimeoutMs = options.perAttemptTimeoutMs ?? PACOTE_PER_ATTEMPT_TIMEOUT_MS;
3119
+ const maxTotalMs = options.maxTotalMs ?? PACOTE_MAX_TOTAL_MS;
3120
+ const start = Date.now();
3121
+ let lastError;
3122
+ let made = 0;
3123
+ for (let attempt = 0; attempt < attempts; attempt++) {
3124
+ const remaining = maxTotalMs - (Date.now() - start);
3125
+ if (remaining <= MIN_ATTEMPT_BUDGET_MS) break;
3126
+ const attemptTimeoutMs = Math.min(perAttemptTimeoutMs, remaining);
3127
+ made = attempt + 1;
3128
+ const controller = new AbortController();
3129
+ const timeoutId = setTimeout(() => controller.abort(), attemptTimeoutMs);
3130
+ try {
3131
+ return await fn3(controller.signal);
3132
+ } catch (error) {
3133
+ lastError = error;
3134
+ if (isPermanentError(error)) throw error;
3135
+ } finally {
3136
+ clearTimeout(timeoutId);
3137
+ }
3138
+ const isLastAttempt = attempt === attempts - 1;
3139
+ const budgetSpent = Date.now() - start >= maxTotalMs;
3140
+ if (isLastAttempt || budgetSpent) break;
3141
+ const sleepMs = Math.min(
3142
+ backoffForAttempt(attempt),
3143
+ maxTotalMs - (Date.now() - start)
3144
+ );
3145
+ if (sleepMs <= 0) break;
3146
+ await delay(sleepMs);
2978
3147
  }
3148
+ throw new Error(
3149
+ `Failed ${label} after ${made} attempts: ${describeError(lastError)}`
3150
+ );
3151
+ }
3152
+ function extractWithResilience(spec, dest, opts, _logger, retryOptions) {
3153
+ return withPacoteRetry(
3154
+ (signal) => pacote.extract(spec, dest, withSignal(opts, signal)),
3155
+ `download ${spec}`,
3156
+ retryOptions
3157
+ );
3158
+ }
3159
+ function manifestWithResilience(spec, opts, _logger, retryOptions) {
3160
+ return withPacoteRetry(
3161
+ (signal) => pacote.manifest(spec, withSignal(opts, signal)),
3162
+ `fetch manifest ${spec}`,
3163
+ retryOptions
3164
+ );
2979
3165
  }
2980
3166
  function getPackageDirectory(baseDir, packageName) {
2981
3167
  return path8.join(baseDir, "node_modules", packageName);
@@ -3080,14 +3266,14 @@ async function collectAllSpecs(packages, logger, configDir, overrides = {}, npmC
3080
3266
  }
3081
3267
  let manifest;
3082
3268
  try {
3083
- manifest = await withTimeout2(
3084
- pacote.manifest(`${item.name}@${item.spec}`, npmConfig),
3085
- PACKAGE_DOWNLOAD_TIMEOUT_MS,
3086
- `Manifest fetch timed out: ${item.name}@${item.spec}`
3269
+ manifest = await manifestWithResilience(
3270
+ `${item.name}@${item.spec}`,
3271
+ npmConfig,
3272
+ logger
3087
3273
  );
3088
3274
  } catch (error) {
3089
- logger.debug(
3090
- `Failed to fetch manifest for ${item.name}@${item.spec}: ${error}`
3275
+ logger.warn(
3276
+ `Failed to fetch manifest for ${item.name}@${item.spec} after retries; its dependencies may be unresolved: ${error instanceof Error ? error.message : String(error)}`
3091
3277
  );
3092
3278
  continue;
3093
3279
  }
@@ -3192,9 +3378,10 @@ async function resolveVersionConflicts(allSpecs, logger, npmConfig = {}) {
3192
3378
  concreteVersion = chosenVersion;
3193
3379
  } else {
3194
3380
  try {
3195
- const manifest = await pacote.manifest(
3381
+ const manifest = await manifestWithResilience(
3196
3382
  `${name}@${chosenVersion}`,
3197
- npmConfig
3383
+ npmConfig,
3384
+ logger
3198
3385
  );
3199
3386
  concreteVersion = manifest.version;
3200
3387
  } catch (err) {
@@ -3307,13 +3494,11 @@ async function downloadPackagesImpl(packages, targetDir, logger, useCache, confi
3307
3494
  try {
3308
3495
  await fs7.ensureDir(path8.dirname(packageDir));
3309
3496
  const cacheDir = process.env.NPM_CACHE_DIR || getTmpPath(tmpDir, "cache", "npm");
3310
- await withTimeout2(
3311
- pacote.extract(packageSpec, packageDir, {
3312
- ...npmConfig,
3313
- cache: cacheDir
3314
- }),
3315
- PACKAGE_DOWNLOAD_TIMEOUT_MS,
3316
- `Package download timed out after ${PACKAGE_DOWNLOAD_TIMEOUT_MS / 1e3}s: ${packageSpec}`
3497
+ await extractWithResilience(
3498
+ packageSpec,
3499
+ packageDir,
3500
+ { ...npmConfig, cache: cacheDir },
3501
+ logger
3317
3502
  );
3318
3503
  if (userSpecifiedPackages.has(name)) {
3319
3504
  logger.debug(`Downloading ${packageSpec}`);
@@ -3334,10 +3519,10 @@ async function downloadPackagesImpl(packages, targetDir, logger, useCache, confi
3334
3519
  let resolvedSpec = `${nestedPkg.name}@${nestedPkg.version}`;
3335
3520
  if (!semver2.valid(nestedPkg.version)) {
3336
3521
  try {
3337
- const manifest = await withTimeout2(
3338
- pacote.manifest(resolvedSpec, npmConfig),
3339
- PACKAGE_DOWNLOAD_TIMEOUT_MS,
3340
- `Manifest fetch timed out: ${resolvedSpec}`
3522
+ const manifest = await manifestWithResilience(
3523
+ resolvedSpec,
3524
+ npmConfig,
3525
+ logger
3341
3526
  );
3342
3527
  resolvedSpec = `${nestedPkg.name}@${manifest.version}`;
3343
3528
  } catch (error) {
@@ -3355,13 +3540,11 @@ async function downloadPackagesImpl(packages, targetDir, logger, useCache, confi
3355
3540
  try {
3356
3541
  await fs7.ensureDir(path8.dirname(nestedDir));
3357
3542
  const cacheDir = process.env.NPM_CACHE_DIR || getTmpPath(tmpDir, "cache", "npm");
3358
- await withTimeout2(
3359
- pacote.extract(resolvedSpec, nestedDir, {
3360
- ...npmConfig,
3361
- cache: cacheDir
3362
- }),
3363
- PACKAGE_DOWNLOAD_TIMEOUT_MS,
3364
- `Nested package download timed out: ${resolvedSpec}`
3543
+ await extractWithResilience(
3544
+ resolvedSpec,
3545
+ nestedDir,
3546
+ { ...npmConfig, cache: cacheDir },
3547
+ logger
3365
3548
  );
3366
3549
  logger.debug(`Nested: ${resolvedSpec} under ${consumer}`);
3367
3550
  } catch (error) {
@@ -3404,19 +3587,33 @@ Each package must use the same version across all declarations. Please update yo
3404
3587
  );
3405
3588
  }
3406
3589
  }
3407
- var PACKAGE_DOWNLOAD_TIMEOUT_MS, PACOTE_OPTS, SOURCE_PRIORITY;
3590
+ var PACOTE_OPTS, PACOTE_RETRY_ATTEMPTS, PACOTE_PER_ATTEMPT_TIMEOUT_MS, PACOTE_MAX_TOTAL_MS, MIN_ATTEMPT_BUDGET_MS, BASE_BACKOFF_MS, JITTER, PERMANENT_ERROR_CODES, SOURCE_PRIORITY;
3408
3591
  var init_package_manager = __esm({
3409
3592
  "src/commands/bundle/package-manager.ts"() {
3410
3593
  "use strict";
3411
3594
  init_core();
3412
3595
  init_cache_utils();
3413
3596
  init_tmp();
3414
- PACKAGE_DOWNLOAD_TIMEOUT_MS = 6e4;
3415
3597
  PACOTE_OPTS = {
3416
3598
  registry: "https://registry.npmjs.org/",
3417
3599
  preferOnline: true,
3418
3600
  where: void 0
3419
3601
  };
3602
+ PACOTE_RETRY_ATTEMPTS = 3;
3603
+ PACOTE_PER_ATTEMPT_TIMEOUT_MS = 6e4;
3604
+ PACOTE_MAX_TOTAL_MS = 9e4;
3605
+ MIN_ATTEMPT_BUDGET_MS = 1e3;
3606
+ BASE_BACKOFF_MS = [2e3, 5e3];
3607
+ JITTER = 0.2;
3608
+ PERMANENT_ERROR_CODES = /* @__PURE__ */ new Set([
3609
+ "E404",
3610
+ "ETARGET",
3611
+ "EINVALIDPACKAGENAME",
3612
+ "E401",
3613
+ "E403",
3614
+ "EINTEGRITY",
3615
+ "Z_DATA_ERROR"
3616
+ ]);
3420
3617
  SOURCE_PRIORITY = {
3421
3618
  direct: 0,
3422
3619
  override: 1,
@@ -6152,17 +6349,17 @@ async function Ie2(e4) {
6152
6349
  if (be2(n5)) continue;
6153
6350
  const o4 = n5.config.require;
6154
6351
  if (!o4?.length) continue;
6155
- const s6 = o4.filter((t5) => !$e(e4, t5));
6352
+ const s6 = o4.filter((t5) => !Ae(e4, t5));
6156
6353
  s6.length !== o4.length && (n5.config.require = s6, be2(n5) && await ve2(e4, n5, t4));
6157
6354
  }
6158
6355
  for (const [t4, n5] of Object.entries(e4.pending.destinations)) {
6159
6356
  if (!e4.pending.destinations[t4] || e4.destinations[t4]) continue;
6160
6357
  const o4 = n5.config?.require;
6161
6358
  if (!o4) continue;
6162
- const s6 = o4.filter((t5) => !$e(e4, t5));
6359
+ const s6 = o4.filter((t5) => !Ae(e4, t5));
6163
6360
  if (n5.config && (n5.config.require = s6), s6.length > 0) continue;
6164
6361
  delete e4.pending.destinations[t4];
6165
- const r5 = at(n5);
6362
+ const r5 = ut2(n5);
6166
6363
  false !== r5.config.queue && (r5.queuePush = [...e4.queue]), e4.destinations[t4] = r5;
6167
6364
  }
6168
6365
  }
@@ -6184,7 +6381,7 @@ var je2 = [n.Commands.Consent, n.Commands.User, n.Commands.Globals, n.Commands.C
6184
6381
  function De2(e4) {
6185
6382
  return je2.includes(e4);
6186
6383
  }
6187
- function Ae(e4, t4) {
6384
+ function $e(e4, t4) {
6188
6385
  switch (t4) {
6189
6386
  case n.Commands.Consent:
6190
6387
  return Object.keys(e4.consent).length > 0;
@@ -6198,13 +6395,13 @@ function Ae(e4, t4) {
6198
6395
  return false;
6199
6396
  }
6200
6397
  }
6201
- function $e(e4, t4) {
6398
+ function Ae(e4, t4) {
6202
6399
  switch (t4) {
6203
6400
  case n.Commands.Consent:
6204
6401
  case n.Commands.User:
6205
6402
  case n.Commands.Globals:
6206
6403
  case n.Commands.Custom:
6207
- return Ae(e4, t4);
6404
+ return $e(e4, t4);
6208
6405
  case n.Commands.Run:
6209
6406
  case n.Commands.Ready:
6210
6407
  return true === e4.allowed;
@@ -6225,13 +6422,13 @@ function Te2(e4, t4, n5) {
6225
6422
  return void 0 === s6 ? -1 : s6;
6226
6423
  })(e4, t4, n5);
6227
6424
  }
6228
- function _e(e4) {
6425
+ function Pe2(e4) {
6229
6426
  return e4.cascade ? () => {
6230
6427
  } : (e4.cascade = { counts: /* @__PURE__ */ new WeakMap() }, () => {
6231
6428
  e4.cascade = void 0;
6232
6429
  });
6233
6430
  }
6234
- function Pe2(e4, t4, n5) {
6431
+ function _e(e4, t4, n5) {
6235
6432
  const o4 = e4.cascade;
6236
6433
  if (!o4) return true;
6237
6434
  let s6 = o4.counts.get(t4);
@@ -6251,7 +6448,7 @@ async function Be2(e4, t4, n5) {
6251
6448
  }
6252
6449
  function He2(e4, t4, n5, o4, s6) {
6253
6450
  if (!t4.on) return;
6254
- const r5 = t4.type || "unknown", a4 = e4.logger.scope(r5).scope("on").scope(o4), i4 = { collector: e4, logger: a4, id: n5, config: t4.config, data: s6, env: ct2(t4.env, t4.config.env) };
6451
+ const r5 = t4.type || "unknown", a4 = e4.logger.scope(r5).scope("on").scope(o4), i4 = { collector: e4, logger: a4, id: n5, config: t4.config, data: s6, env: lt(t4.env, t4.config.env) };
6255
6452
  We(t4.on, (t5) => Oe2(e4, "destination", t5, { destId: n5, type: o4 }))(o4, i4);
6256
6453
  }
6257
6454
  function Re2(e4, t4, o4, s6) {
@@ -6262,7 +6459,7 @@ function Re2(e4, t4, o4, s6) {
6262
6459
  !(function(e5, t5, o5) {
6263
6460
  const s7 = o5 || e5.consent, r6 = ze(e5, n.Commands.Consent);
6264
6461
  t5.forEach((t6) => {
6265
- Te2(e5, t6, n.Commands.Consent) && Pe2(e5, t6, n.Commands.Consent) && (Object.keys(s7).filter((e6) => e6 in t6).forEach((n5) => {
6462
+ Te2(e5, t6, n.Commands.Consent) && _e(e5, t6, n.Commands.Consent) && (Object.keys(s7).filter((e6) => e6 in t6).forEach((n5) => {
6266
6463
  We(t6[n5], (t7) => Oe2(e5, "consent", t7, { key: n5 }))(s7, r6);
6267
6464
  }), Me2(e5, t6, n.Commands.Consent));
6268
6465
  });
@@ -6298,7 +6495,7 @@ function Re2(e4, t4, o4, s6) {
6298
6495
  default: {
6299
6496
  const n5 = ze(e4, t4), s7 = De2(t4);
6300
6497
  o4.forEach((o5) => {
6301
- "function" == typeof o5 && (s7 && !Te2(e4, o5, t4) || s7 && !Pe2(e4, o5, t4) || (We(o5, (n6) => Oe2(e4, "generic", n6, { type: t4 }))(r5, n5), s7 && Me2(e4, o5, t4)));
6498
+ "function" == typeof o5 && (s7 && !Te2(e4, o5, t4) || s7 && !_e(e4, o5, t4) || (We(o5, (n6) => Oe2(e4, "generic", n6, { type: t4 }))(r5, n5), s7 && Me2(e4, o5, t4)));
6302
6499
  });
6303
6500
  break;
6304
6501
  }
@@ -6325,13 +6522,13 @@ function Fe2(e4, t4, o4) {
6325
6522
  async function Ge(e4, t4, n5, o4, s6) {
6326
6523
  if (!t4.on) return false;
6327
6524
  if (De2(o4) && !Te2(e4, t4, o4)) return false;
6328
- if (De2(o4) && !Pe2(e4, t4, o4)) return false;
6525
+ if (De2(o4) && !_e(e4, t4, o4)) return false;
6329
6526
  const r5 = await Le(t4.on, (t5) => Oe2(e4, "source", t5, { sourceId: n5, type: o4 }))(o4, s6);
6330
6527
  return De2(o4) && Me2(e4, t4, o4), false === r5;
6331
6528
  }
6332
6529
  async function Ke2(e4) {
6333
6530
  if (qe2(e4)) for (const t4 of je2) {
6334
- if (!Ae(e4, t4)) continue;
6531
+ if (!$e(e4, t4)) continue;
6335
6532
  const n5 = Fe2(e4, t4);
6336
6533
  Re2(e4, t4, e4.on[t4] || []);
6337
6534
  for (const [o4, s6] of Object.entries(e4.sources)) be2(s6) && await Ge(e4, s6, o4, t4, n5);
@@ -6378,31 +6575,48 @@ function Ne(e4, t4, n5, o4) {
6378
6575
  function Le2(e4) {
6379
6576
  Ve2.delete(e4);
6380
6577
  }
6381
- var Ye = Object.freeze({ batched: true });
6382
- function Je2(e4) {
6383
- return e4 === Ye;
6578
+ function Ye(e4) {
6579
+ return "number" == typeof e4 && e4 > 0 ? e4 : 1e4;
6580
+ }
6581
+ var Je2 = class extends Error {
6582
+ constructor(e4) {
6583
+ super(e4), this.name = "DestinationTimeoutError";
6584
+ }
6585
+ };
6586
+ function Qe(e4, t4, n5) {
6587
+ let o4;
6588
+ const s6 = new Promise((e5, s7) => {
6589
+ o4 = setTimeout(() => s7(new Je2(n5)), t4);
6590
+ });
6591
+ return Promise.race([e4, s6]).finally(() => {
6592
+ o4 && clearTimeout(o4);
6593
+ });
6594
+ }
6595
+ var Xe = Object.freeze({ batched: true });
6596
+ function Ze(e4) {
6597
+ return e4 === Xe;
6384
6598
  }
6385
- function Qe(e4) {
6599
+ function et(e4) {
6386
6600
  return void 0 === e4 ? {} : "number" == typeof e4 ? { wait: e4 } : { wait: e4.wait, size: e4.size, age: e4.age };
6387
6601
  }
6388
- function Xe(e4, t4) {
6602
+ function tt(e4, t4) {
6389
6603
  return e4.status.destinations[t4] || (e4.status.destinations[t4] = { count: 0, failed: 0, duration: 0, queuePushSize: 0, dlqSize: 0 }), e4.status.destinations[t4];
6390
6604
  }
6391
- function Ze(e4, t4, n5, o4) {
6605
+ function nt(e4, t4, n5, o4) {
6392
6606
  e4.dropped[t4] || (e4.dropped[t4] = {});
6393
6607
  const s6 = e4.dropped[t4];
6394
6608
  return s6[n5] = (s6[n5] ?? 0) + o4, s6[n5];
6395
6609
  }
6396
- function et(e4, t4, n5) {
6610
+ function ot2(e4, t4, n5) {
6397
6611
  if (!e4) return [];
6398
6612
  if (Array.isArray(e4) && e4.every((e5) => "string" == typeof e5)) return fe(e4, t4);
6399
6613
  if ("string" == typeof e4) return fe(e4, t4);
6400
6614
  const o4 = Zt(e4, nn(n5));
6401
6615
  return 0 === o4.length ? [] : 1 === o4.length ? fe(o4[0], t4) : fe(o4, t4);
6402
6616
  }
6403
- async function tt(e4, t4) {
6617
+ async function st(e4, t4) {
6404
6618
  const { code: n5, config: o4 = {}, env: s6 = {}, before: r5, next: a4, cache: i4, state: c2 } = t4;
6405
- if (!le(n5.push)) return rt({ ok: false, failed: { invalid: { type: "invalid", error: "Destination code must have a push method" } } });
6619
+ if (!le(n5.push)) return ct2({ ok: false, failed: { invalid: { type: "invalid", error: "Destination code must have a push method" } } });
6406
6620
  const u2 = o4 || { init: false };
6407
6621
  let d2 = r5 ? { ...u2, before: r5 } : { ...u2 };
6408
6622
  a4 && (d2 = { ...d2, next: a4 }), i4 && (d2 = { ...d2, cache: i4 }), void 0 !== c2 && void 0 === d2.state && (d2 = { ...d2, state: c2 });
@@ -6413,20 +6627,20 @@ async function tt(e4, t4) {
6413
6627
  if (d2.require?.length) {
6414
6628
  e4.pending.destinations[l3] = t4, await Ie2(e4);
6415
6629
  const n6 = e4.destinations[l3];
6416
- return n6 ? nt(e4, void 0, {}, { [l3]: n6 }) : rt({ ok: true });
6630
+ return n6 ? rt(e4, void 0, {}, { [l3]: n6 }) : ct2({ ok: true });
6417
6631
  }
6418
- const f3 = { ...n5, config: d2, env: ct2(n5.env, s6) };
6419
- return e4.destinations[l3] = f3, false !== f3.config.queue && (f3.queuePush = [...e4.queue]), nt(e4, void 0, {}, { [l3]: f3 });
6632
+ const f3 = { ...n5, config: d2, env: lt(n5.env, s6) };
6633
+ return e4.destinations[l3] = f3, false !== f3.config.queue && (f3.queuePush = [...e4.queue]), rt(e4, void 0, {}, { [l3]: f3 });
6420
6634
  }
6421
- async function nt(e4, t4, n5 = {}, o4) {
6635
+ async function rt(e4, t4, n5 = {}, o4) {
6422
6636
  const { allowed: s6, consent: r5, globals: a4, user: g3 } = e4;
6423
- if (!s6) return rt({ ok: false });
6637
+ if (!s6) return ct2({ ok: false });
6424
6638
  if (t4) {
6425
6639
  const n6 = e4.config.queueMax;
6426
6640
  if (void 0 === n6) throw new Error("Collector.Config.queueMax is undefined; defaults must be seeded by collector()");
6427
6641
  const o5 = We2(e4.queue, t4, { max: n6 });
6428
6642
  if (o5.dropped > 0) {
6429
- const t5 = Ze(e4.status, o("collector"), "queue", o5.dropped);
6643
+ const t5 = nt(e4.status, o("collector"), "queue", o5.dropped);
6430
6644
  Ne(e4.queue, e4.logger, "collector.queue overflow; oldest events dropped", { buffer: "queue", cap: n6, droppedCount: t5 });
6431
6645
  } else e4.queue.length < n6 && Le2(e4.queue);
6432
6646
  e4.status.in++;
@@ -6442,7 +6656,7 @@ async function nt(e4, t4, n5 = {}, o4) {
6442
6656
  if (!je(s7.config.consent, r5)) return { id: o5, destination: s7, skipped: true };
6443
6657
  let t5 = false;
6444
6658
  try {
6445
- t5 = await ot2(e4, s7, o5, true);
6659
+ t5 = await at(e4, s7, o5, true);
6446
6660
  } catch (t6) {
6447
6661
  e4.status.failed++;
6448
6662
  const n6 = s7.type || "unknown";
@@ -6463,15 +6677,15 @@ async function nt(e4, t4, n5 = {}, o4) {
6463
6677
  a5 += We2(t5, e5, r6).dropped;
6464
6678
  }
6465
6679
  if (a5 > 0) {
6466
- Xe(e4, n6);
6467
- const o6 = Ze(e4.status, o("destination", n6), "queue", a5);
6680
+ tt(e4, n6);
6681
+ const o6 = nt(e4.status, o("destination", n6), "queue", a5);
6468
6682
  Ne(t5, e4.logger.scope(s7.type || "unknown"), "destination.queuePush overflow; oldest events dropped", { buffer: "queuePush", destination: n6, cap: r6.max, droppedCount: o6 });
6469
6683
  } else t5.length < r6.max && Le2(t5);
6470
6684
  }
6471
6685
  if (!b4.length) return { id: o5, destination: s7, queue: w4 };
6472
6686
  let C2, S2, j2 = false;
6473
6687
  try {
6474
- j2 = await ot2(e4, s7, o5, true);
6688
+ j2 = await at(e4, s7, o5, true);
6475
6689
  } catch (t5) {
6476
6690
  e4.status.failed++;
6477
6691
  const n6 = s7.type || "unknown";
@@ -6479,7 +6693,7 @@ async function nt(e4, t4, n5 = {}, o4) {
6479
6693
  }
6480
6694
  if (!j2) return { id: o5, destination: s7, queue: w4 };
6481
6695
  s7.dlq || (s7.dlq = []);
6482
- const A2 = et(s7.config.before, h3, v4), $2 = s7.config.next, E3 = s7.config?.cache, M3 = E3 ? rn(E3) : void 0, T3 = M3 ? ce(M3, e4) : void 0, _2 = s7.config?.state ? cn(s7.config.state) : void 0, P3 = _2?.filter((e5) => "get" === e5.mode), z4 = _2?.filter((e5) => "set" === e5.mode);
6696
+ const $2 = ot2(s7.config.before, h3, v4), A2 = s7.config.next, E3 = s7.config?.cache, M3 = E3 ? rn(E3) : void 0, T3 = M3 ? ce(M3, e4) : void 0, P3 = s7.config?.state ? cn(s7.config.state) : void 0, _2 = P3?.filter((e5) => "get" === e5.mode), z4 = P3?.filter((e5) => "set" === e5.mode);
6483
6697
  let B3 = 0, H2 = 0;
6484
6698
  return await Promise.all(b4.map(async (t5) => {
6485
6699
  let r6;
@@ -6489,8 +6703,8 @@ async function nt(e4, t4, n5 = {}, o4) {
6489
6703
  "MISS" === n6?.status && (r6 = { key: n6.key, ttl: n6.rule.ttl });
6490
6704
  }
6491
6705
  let u2 = t5, d2 = n5.respond;
6492
- if (A2.length > 0 && e4.transformers && Object.keys(e4.transformers).length > 0) {
6493
- const s8 = await he2(e4, e4.transformers, A2, t5, v4, n5.respond, `destination.${o5}.before`);
6706
+ if ($2.length > 0 && e4.transformers && Object.keys(e4.transformers).length > 0) {
6707
+ const s8 = await he2(e4, e4.transformers, $2, t5, v4, n5.respond, `destination.${o5}.before`);
6494
6708
  if (null === s8.event) return t5;
6495
6709
  s8.respond && (d2 = s8.respond), u2 = Array.isArray(s8.event) ? s8.event[0] : s8.event;
6496
6710
  }
@@ -6499,22 +6713,22 @@ async function nt(e4, t4, n5 = {}, o4) {
6499
6713
  if ("HIT" === n6?.status) return t5;
6500
6714
  "MISS" === n6?.status && (r6 = { key: n6.key, ttl: n6.rule.ttl });
6501
6715
  }
6502
- P3 && P3.length > 0 && u2 && (u2 = await un(P3, (t6) => ue2(t6, e4), u2, e4));
6716
+ _2 && _2.length > 0 && u2 && (u2 = await un(_2, (t6) => ue2(t6, e4), u2, e4));
6503
6717
  const p3 = Date.now();
6504
6718
  let m3 = false;
6505
- const y2 = await Le(st, (t6) => {
6719
+ const y2 = await Le(it2, (t6) => {
6506
6720
  const n6 = s7.type || "unknown";
6507
6721
  e4.logger.scope(n6).error("Push failed", { error: t6, event: u2.name }), C2 = t6, m3 = true;
6508
6722
  const r7 = s7.dlq, a5 = s7.config.id || o5, i4 = { max: s7.config.dlqMax ?? 100 }, c2 = We2(r7, [u2, t6], i4);
6509
6723
  if (c2.dropped > 0) {
6510
- Xe(e4, a5);
6511
- const t7 = Ze(e4.status, o("destination", a5), "dlq", c2.dropped);
6724
+ tt(e4, a5);
6725
+ const t7 = nt(e4.status, o("destination", a5), "dlq", c2.dropped);
6512
6726
  Ne(r7, e4.logger.scope(s7.type || "unknown"), "destination.dlq overflow; oldest entries dropped", { buffer: "dlq", destination: a5, cap: i4.max, droppedCount: t7 });
6513
6727
  } else r7.length < i4.max && Le2(r7);
6514
6728
  })(e4, s7, o5, u2, v4, d2);
6515
- if (B3 += Date.now() - p3, r6 && T3 && void 0 === s7.config.mock && an(T3, r6.key, y2 ?? true, r6.ttl), !m3 && !Je2(y2) && z4 && z4.length > 0 && u2 && (u2 = await un(z4, (t6) => ue2(t6, e4), u2, e4)), void 0 === y2 || Je2(y2) || (S2 = y2), Je2(y2) && H2++, !m3 && $2) {
6729
+ if (B3 += Date.now() - p3, r6 && T3 && void 0 === s7.config.mock && an(T3, r6.key, y2 ?? true, r6.ttl), !m3 && !Ze(y2) && z4 && z4.length > 0 && u2 && (u2 = await un(z4, (t6) => ue2(t6, e4), u2, e4)), void 0 === y2 || Ze(y2) || (S2 = y2), Ze(y2) && H2++, !m3 && A2) {
6516
6730
  void 0 !== y2 && (v4._response = y2);
6517
- const t6 = et($2, h3, v4);
6731
+ const t6 = ot2(A2, h3, v4);
6518
6732
  if (t6.length > 0 && e4.transformers && Object.keys(e4.transformers).length > 0) {
6519
6733
  const n6 = await he2(e4, e4.transformers, t6, u2, v4, d2, `destination.${o5}.next`);
6520
6734
  n6.respond && (d2 = n6.respond);
@@ -6526,7 +6740,7 @@ async function nt(e4, t4, n5 = {}, o4) {
6526
6740
  for (const t5 of w3) {
6527
6741
  if (t5.skipped) continue;
6528
6742
  const n6 = t5.destination, o5 = { type: n6.type || "unknown", data: t5.response };
6529
- Xe(e4, t5.id);
6743
+ tt(e4, t5.id);
6530
6744
  const s7 = e4.status.destinations[t5.id], r6 = Date.now();
6531
6745
  if (s7.queuePushSize = n6.queuePush?.length ?? 0, s7.dlqSize = n6.dlq?.length ?? 0, t5.error) o5.error = t5.error, k3[t5.id] = o5, s7.failed++, s7.lastAt = r6, s7.duration += t5.totalDuration || 0, e4.status.failed++;
6532
6746
  else if (t5.queue && t5.queue.length) b3[t5.id] = o5;
@@ -6535,15 +6749,15 @@ async function nt(e4, t4, n5 = {}, o4) {
6535
6749
  (Math.max(0, a5 - n7) > 0 || 0 === a5) && (v3[t5.id] = o5, s7.count++, s7.lastAt = r6, s7.duration += t5.totalDuration || 0, e4.status.out++);
6536
6750
  }
6537
6751
  }
6538
- return rt({ event: t4, ...Object.keys(v3).length && { done: v3 }, ...Object.keys(b3).length && { queued: b3 }, ...Object.keys(k3).length && { failed: k3 } });
6752
+ return ct2({ event: t4, ...Object.keys(v3).length && { done: v3 }, ...Object.keys(b3).length && { queued: b3 }, ...Object.keys(k3).length && { failed: k3 } });
6539
6753
  }
6540
- async function ot2(e4, t4, n5, o4 = false) {
6754
+ async function at(e4, t4, n5, o4 = false) {
6541
6755
  if (t4.init && !t4.config.init) {
6542
6756
  if (!o4 && (function(e5) {
6543
6757
  const t5 = e5.config.consent;
6544
6758
  return !!t5 && Object.keys(t5).length > 0;
6545
6759
  })(t4)) return e4.logger.scope(t4.type || "unknown").debug("init blocked: consent gate not cleared"), false;
6546
- const s6 = t4.type || "unknown", r5 = e4.logger.scope(s6), a4 = { collector: e4, logger: r5, id: n5, config: t4.config, env: ct2(t4.env, t4.config.env) };
6760
+ const s6 = t4.type || "unknown", r5 = e4.logger.scope(s6), a4 = { collector: e4, logger: r5, id: n5, config: t4.config, env: lt(t4.env, t4.config.env) };
6547
6761
  r5.debug("init");
6548
6762
  const i4 = Date.now();
6549
6763
  let c2;
@@ -6564,22 +6778,22 @@ async function ot2(e4, t4, n5, o4 = false) {
6564
6778
  }
6565
6779
  return true;
6566
6780
  }
6567
- async function st(e4, t4, n5, o4, s6, r5) {
6781
+ async function it2(e4, t4, n5, o4, s6, r5) {
6568
6782
  const { config: a4 } = t4, i4 = await Je(o4, a4, e4);
6569
6783
  if (i4.ignore) return false;
6570
- const c2 = t4.type || "unknown", u2 = e4.logger.scope(c2), d2 = { collector: e4, logger: u2, id: n5, config: a4, data: i4.data, rule: i4.mapping, ingest: s6, env: { ...ct2(t4.env, a4.env), ...r5 ? { respond: r5 } : {} } };
6784
+ const c2 = t4.type || "unknown", u2 = e4.logger.scope(c2), d2 = { collector: e4, logger: u2, id: n5, config: a4, data: i4.data, rule: i4.mapping, ingest: s6, env: { ...lt(t4.env, a4.env), ...r5 ? { respond: r5 } : {} } };
6571
6785
  if (void 0 !== a4.mock) return u2.debug("mock", { event: i4.event.name }), a4.mock;
6572
6786
  const l3 = i4.mapping, f3 = void 0 !== l3?.batch, p3 = f3 ? i4.mappingKey || "* *" : " batch-all";
6573
6787
  if ((f3 || void 0 !== a4.batch) && t4.pushBatch && void 0 === a4.mock) {
6574
6788
  if (t4.batches = t4.batches || {}, !t4.batches[p3]) {
6575
- const o6 = { key: p3, entries: [], events: [], data: [] }, s7 = Qe(l3?.batch), r6 = Qe(a4.batch), i5 = s7.wait ?? r6.wait ?? 3e4, c4 = s7.size ?? r6.size ?? 1e3, d4 = s7.age ?? r6.age ?? 3e4, h3 = ct2(t4.env, a4.env), y2 = Ie(async () => {
6789
+ const o6 = { key: p3, entries: [], events: [], data: [] }, s7 = et(l3?.batch), r6 = et(a4.batch), i5 = s7.wait ?? r6.wait ?? 3e4, c4 = s7.size ?? r6.size ?? 1e3, d4 = s7.age ?? r6.age ?? 3e4, h3 = lt(t4.env, a4.env), y2 = Ie(async () => {
6576
6790
  const o7 = t4.batches[p3], s8 = o7.batched;
6577
6791
  if (0 === s8.entries.length) return;
6578
6792
  const r7 = { key: s8.key, entries: s8.entries, events: s8.events, data: s8.data };
6579
6793
  s8.entries = [], s8.events = [], s8.data = [];
6580
6794
  const i6 = r7.entries[0], c5 = { collector: e4, logger: u2, id: n5, config: a4, data: void 0, rule: o7.isDefault ? void 0 : i6.rule, ingest: i6.ingest, env: { ...h3, ...i6.respond ? { respond: i6.respond } : {} } };
6581
6795
  u2.debug("push batch", { events: r7.entries.length });
6582
- const d5 = t4.config.id || n5, l4 = Xe(e4, d5), f4 = Date.now(), g3 = D2(e4, { stepId: o("destination", n5), stepType: "destination", phase: "flush", eventId: "", now: f4 });
6796
+ const d5 = t4.config.id || n5, l4 = tt(e4, d5), f4 = Date.now(), g3 = D2(e4, { stepId: o("destination", n5), stepType: "destination", phase: "flush", eventId: "", now: f4 });
6583
6797
  g3.batch = { size: r7.entries.length, index: 0 }, yt(e4, g3);
6584
6798
  const y3 = (n6) => {
6585
6799
  const o8 = t4.dlq = t4.dlq || [], s9 = { max: t4.config.dlqMax ?? 100 };
@@ -6588,26 +6802,26 @@ async function st(e4, t4, n5, o4, s6, r5) {
6588
6802
  r8 += We2(o8, e5, s9).dropped;
6589
6803
  }
6590
6804
  if (r8 > 0) {
6591
- const t5 = Ze(e4.status, o("destination", d5), "dlq", r8);
6805
+ const t5 = nt(e4.status, o("destination", d5), "dlq", r8);
6592
6806
  Ne(o8, u2, "destination.dlq overflow; oldest entries dropped", { buffer: "dlq", destination: d5, cap: s9.max, droppedCount: t5 });
6593
6807
  } else o8.length < s9.max && Le2(o8);
6594
6808
  l4.failed += n6.length, l4.dlqSize = o8.length, e4.status.failed += n6.length;
6595
6809
  };
6596
6810
  let w3 = r7.entries.length;
6597
- const v3 = await Le(ct(t4.pushBatch, "DestinationPushBatch", e4.hooks, e4.logger), (t5) => {
6811
+ const v3 = Ye(a4.timeout), b3 = await Le((o8, s9) => Qe(Promise.resolve(ct(t4.pushBatch, "DestinationPushBatch", e4.hooks, e4.logger)(o8, s9)), v3, `Destination "${n5}" batch delivery timed out after ${v3}ms`), (t5) => {
6598
6812
  w3 = 0;
6599
6813
  const o8 = Date.now(), s9 = D2(e4, { stepId: o("destination", n5), stepType: "destination", phase: "error", eventId: "", now: o8 });
6600
6814
  s9.durationMs = o8 - f4, s9.error = t5 instanceof Error ? { name: t5.name, message: t5.message } : { message: String(t5) }, s9.batch = { size: r7.entries.length, index: 0 }, yt(e4, s9), y3(r7.entries.map((e5) => [e5.event, t5])), u2.error("Push batch failed", { error: t5 instanceof Error ? t5.message : String(t5), entries: r7.entries.length });
6601
6815
  })(r7, c5);
6602
- if (de(b3 = v3) && Array.isArray(b3.failed) && v3.failed.length > 0) {
6816
+ if (de(C2 = b3) && Array.isArray(C2.failed) && b3.failed.length > 0) {
6603
6817
  const e5 = [], t5 = /* @__PURE__ */ new Set();
6604
- for (const n6 of v3.failed) {
6818
+ for (const n6 of b3.failed) {
6605
6819
  const o8 = r7.entries[n6.index];
6606
6820
  o8 && !t5.has(n6.index) && (t5.add(n6.index), e5.push([o8.event, n6.error ?? new Error(`Push batch entry ${n6.index} failed (no per-row error provided)`)]));
6607
6821
  }
6608
6822
  e5.length > 0 && (y3(e5), w3 = Math.max(0, r7.entries.length - e5.length), u2.error("Push batch partial failure", { failed: e5.length, delivered: w3, entries: r7.entries.length }));
6609
6823
  }
6610
- var b3;
6824
+ var C2;
6611
6825
  u2.debug("push batch done"), l4.inFlightBatch = Math.max(0, (l4.inFlightBatch ?? 0) - r7.entries.length), w3 > 0 && (l4.count += w3, l4.lastAt = Date.now(), e4.status.out += w3);
6612
6826
  }, { wait: i5, size: c4, age: d4 });
6613
6827
  t4.batches[p3] = { batched: o6, isDefault: !f3, batchFn: () => {
@@ -6618,43 +6832,43 @@ async function st(e4, t4, n5, o4, s6, r5) {
6618
6832
  }
6619
6833
  const o5 = t4.batches[p3];
6620
6834
  o5.batched.entries.push({ event: i4.event, ingest: s6, respond: r5, rule: l3, data: i4.data }), o5.batched.events.push(i4.event), ue(i4.data) && o5.batched.data.push(i4.data);
6621
- const c3 = t4.config.id || n5, d3 = Xe(e4, c3);
6622
- return d3.inFlightBatch = (d3.inFlightBatch ?? 0) + 1, o5.batchFn(), Ye;
6835
+ const c3 = t4.config.id || n5, d3 = tt(e4, c3);
6836
+ return d3.inFlightBatch = (d3.inFlightBatch ?? 0) + 1, o5.batchFn(), Xe;
6623
6837
  }
6624
6838
  {
6625
6839
  u2.debug("push", { event: i4.event.name });
6626
6840
  const o5 = "string" == typeof i4.event.id ? i4.event.id : "", s7 = Date.now(), r6 = D2(e4, { stepId: o("destination", n5), stepType: "destination", phase: "in", eventId: o5, now: s7 });
6627
6841
  i4.mappingKey && (r6.mappingKey = i4.mappingKey), i4.event.consent && (r6.consent = { ...i4.event.consent }), yt(e4, r6);
6628
6842
  try {
6629
- const r7 = await ct(t4.push, "DestinationPush", e4.hooks, e4.logger)(i4.event, d2), a5 = Date.now(), c3 = D2(e4, { stepId: o("destination", n5), stepType: "destination", phase: "out", eventId: o5, now: a5 });
6630
- return c3.durationMs = a5 - s7, c3.outEvent = r7, i4.mappingKey && (c3.mappingKey = i4.mappingKey), yt(e4, c3), u2.debug("push done"), r7;
6843
+ const r7 = Ye(a4.timeout), c3 = await Qe(Promise.resolve(ct(t4.push, "DestinationPush", e4.hooks, e4.logger)(i4.event, d2)), r7, `Destination "${n5}" delivery timed out after ${r7}ms`), l4 = Date.now(), f4 = D2(e4, { stepId: o("destination", n5), stepType: "destination", phase: "out", eventId: o5, now: l4 });
6844
+ return f4.durationMs = l4 - s7, f4.outEvent = c3, i4.mappingKey && (f4.mappingKey = i4.mappingKey), yt(e4, f4), u2.debug("push done"), c3;
6631
6845
  } catch (t5) {
6632
6846
  const r7 = Date.now(), a5 = D2(e4, { stepId: o("destination", n5), stepType: "destination", phase: "error", eventId: o5, now: r7 });
6633
6847
  throw a5.durationMs = r7 - s7, a5.error = t5 instanceof Error ? { name: t5.name, message: t5.message } : { message: String(t5) }, i4.mappingKey && (a5.mappingKey = i4.mappingKey), yt(e4, a5), t5;
6634
6848
  }
6635
6849
  }
6636
6850
  }
6637
- function rt(e4) {
6851
+ function ct2(e4) {
6638
6852
  return { ok: !e4?.failed, ...e4 };
6639
6853
  }
6640
- function at(e4) {
6854
+ function ut2(e4) {
6641
6855
  const { code: t4, config: n5 = {}, env: o4 = {}, cache: s6, state: r5 } = e4, { config: a4 } = le2(e4, "before"), { config: i4 } = le2({ ...e4, config: a4 }, "next"), c2 = { ...t4.config, ...n5, ...i4 };
6642
6856
  s6 && (c2.cache = s6), void 0 !== r5 && void 0 === c2.state && (c2.state = r5);
6643
- const u2 = ct2(t4.env, o4);
6857
+ const u2 = lt(t4.env, o4);
6644
6858
  return { ...t4, config: c2, env: u2 };
6645
6859
  }
6646
- async function it2(e4, t4 = {}) {
6860
+ async function dt2(e4, t4 = {}) {
6647
6861
  const n5 = {};
6648
- for (const [o4, s6] of Object.entries(t4)) s6.config?.require?.length ? e4.pending.destinations[o4] = s6 : n5[o4] = at(s6);
6862
+ for (const [o4, s6] of Object.entries(t4)) s6.config?.require?.length ? e4.pending.destinations[o4] = s6 : n5[o4] = ut2(s6);
6649
6863
  return n5;
6650
6864
  }
6651
- function ct2(e4, t4) {
6865
+ function lt(e4, t4) {
6652
6866
  return e4 || t4 ? t4 ? e4 && de(e4) && de(t4) ? { ...e4, ...t4 } : t4 : e4 : {};
6653
6867
  }
6654
- var gt2 = 5e3;
6655
- async function mt2(e4) {
6868
+ var yt2 = 5e3;
6869
+ async function wt(e4) {
6656
6870
  const t4 = e4.logger;
6657
- await ht2(e4.sources, "source", t4), await (async function(e5, t5) {
6871
+ await vt(e4.sources, "source", t4), await (async function(e5, t5) {
6658
6872
  const n5 = Object.entries(e5).flatMap(([e6, n6]) => {
6659
6873
  const o4 = n6.batches;
6660
6874
  if (!o4) return [];
@@ -6663,7 +6877,7 @@ async function mt2(e4) {
6663
6877
  let n7;
6664
6878
  try {
6665
6879
  await Promise.race([t6.flush(), new Promise((t7, o5) => {
6666
- n7 = setTimeout(() => o5(new Error(`destination '${e6}' batch flush timed out`)), gt2);
6880
+ n7 = setTimeout(() => o5(new Error(`destination '${e6}' batch flush timed out`)), yt2);
6667
6881
  })]);
6668
6882
  } catch (t7) {
6669
6883
  s6.error(`destination '${e6}' batch flush failed: ${t7}`);
@@ -6673,9 +6887,9 @@ async function mt2(e4) {
6673
6887
  });
6674
6888
  });
6675
6889
  await Promise.allSettled(n5);
6676
- })(e4.destinations, t4), await ht2(e4.destinations, "destination", t4), await ht2(e4.transformers, "transformer", t4), await ht2(e4.stores, "store", t4);
6890
+ })(e4.destinations, t4), await vt(e4.destinations, "destination", t4), await vt(e4.transformers, "transformer", t4), await vt(e4.stores, "store", t4);
6677
6891
  }
6678
- async function ht2(e4, t4, n5) {
6892
+ async function vt(e4, t4, n5) {
6679
6893
  const o4 = Object.entries(e4).map(async ([e5, o5]) => {
6680
6894
  const s6 = o5.destroy;
6681
6895
  if (!s6) return;
@@ -6683,7 +6897,7 @@ async function ht2(e4, t4, n5) {
6683
6897
  let c2;
6684
6898
  try {
6685
6899
  await Promise.race([s6(i4), new Promise((n6, o6) => {
6686
- c2 = setTimeout(() => o6(new Error(`${t4} '${e5}' destroy timed out`)), gt2);
6900
+ c2 = setTimeout(() => o6(new Error(`${t4} '${e5}' destroy timed out`)), yt2);
6687
6901
  })]);
6688
6902
  } catch (n6) {
6689
6903
  a4.error(`${t4} '${e5}' destroy failed: ${n6}`);
@@ -6693,12 +6907,12 @@ async function ht2(e4, t4, n5) {
6693
6907
  });
6694
6908
  await Promise.allSettled(o4);
6695
6909
  }
6696
- function yt2(e4, t4) {
6910
+ function bt(e4, t4) {
6697
6911
  e4.stateVersion++, e4.cellVersion[t4] = e4.stateVersion;
6698
6912
  }
6699
- async function wt(e4, t4, o4) {
6913
+ async function kt(e4, t4, o4) {
6700
6914
  let r5, a4, i4 = false;
6701
- const c2 = _e(e4);
6915
+ const c2 = Pe2(e4);
6702
6916
  try {
6703
6917
  return await (async function() {
6704
6918
  switch (t4) {
@@ -6708,17 +6922,17 @@ async function wt(e4, t4, o4) {
6708
6922
  case n.Commands.Consent:
6709
6923
  if (de(o4)) {
6710
6924
  const { update: t5 } = s2(e4, o4);
6711
- yt2(e4, n.Commands.Consent), a4 = t5, i4 = true;
6925
+ bt(e4, n.Commands.Consent), a4 = t5, i4 = true;
6712
6926
  }
6713
6927
  break;
6714
6928
  case n.Commands.Custom:
6715
- de(o4) && (e4.custom = oe(e4.custom, o4), yt2(e4, n.Commands.Custom), a4 = o4, i4 = true);
6929
+ de(o4) && (e4.custom = oe(e4.custom, o4), bt(e4, n.Commands.Custom), a4 = o4, i4 = true);
6716
6930
  break;
6717
6931
  case n.Commands.Destination:
6718
- de(o4) && "code" in o4 && de(o4.code) && (r5 = await tt(e4, o4));
6932
+ de(o4) && "code" in o4 && de(o4.code) && (r5 = await st(e4, o4));
6719
6933
  break;
6720
6934
  case n.Commands.Globals:
6721
- de(o4) && (e4.globals = oe(e4.globals, o4), yt2(e4, n.Commands.Globals), a4 = o4, i4 = true);
6935
+ de(o4) && (e4.globals = oe(e4.globals, o4), bt(e4, n.Commands.Globals), a4 = o4, i4 = true);
6722
6936
  break;
6723
6937
  case n.Commands.Hook:
6724
6938
  if (de(o4) && ge(o4.name) && le(o4.fn)) {
@@ -6736,44 +6950,44 @@ async function wt(e4, t4, o4) {
6736
6950
  i4 = true;
6737
6951
  break;
6738
6952
  case n.Commands.Run:
6739
- r5 = await Ct2(e4, o4), i4 = true;
6953
+ r5 = await St(e4, o4), i4 = true;
6740
6954
  break;
6741
6955
  case n.Commands.Session:
6742
6956
  i4 = true;
6743
6957
  break;
6744
6958
  case n.Commands.Shutdown:
6745
- e4.hasShutdown || (e4.hasShutdown = true, await mt2(e4));
6959
+ e4.hasShutdown || (e4.hasShutdown = true, await wt(e4));
6746
6960
  break;
6747
6961
  case n.Commands.User:
6748
- de(o4) && (oe(e4.user, o4, { shallow: false }), yt2(e4, n.Commands.User), a4 = o4, i4 = true);
6962
+ de(o4) && (oe(e4.user, o4, { shallow: false }), bt(e4, n.Commands.User), a4 = o4, i4 = true);
6749
6963
  }
6750
- i4 && (await Ue2(e4, t4, void 0, a4), r5 = await nt(e4));
6751
- return r5 || rt({ ok: true });
6964
+ i4 && (await Ue2(e4, t4, void 0, a4), r5 = await rt(e4));
6965
+ return r5 || ct2({ ok: true });
6752
6966
  })();
6753
6967
  } finally {
6754
6968
  c2();
6755
6969
  }
6756
6970
  }
6757
- function vt(e4, t4) {
6758
- return { timing: Math.round((Date.now() - e4.timing) / 10) / 100, source: { type: "collector", schema: "4", version: "4.2.1-next-1781538735002" }, ...t4 };
6971
+ function Ct2(e4, t4) {
6972
+ return { timing: Math.round((Date.now() - e4.timing) / 10) / 100, source: { type: "collector", schema: "4", version: "4.2.1-next-1781594053720" }, ...t4 };
6759
6973
  }
6760
- function bt(e4, t4) {
6974
+ function It(e4, t4) {
6761
6975
  if (!t4.name) throw new Error("Event name is required");
6762
6976
  const [n5, o4] = t4.name.split(" ");
6763
6977
  if (!n5 || !o4) throw new Error("Event name is invalid");
6764
6978
  const { timestamp: s6 = Date.now(), name: r5 = `${n5} ${o4}`, data: a4 = {}, context: i4 = {}, globals: c2 = e4.globals, custom: u2 = {}, user: d2 = e4.user, nested: l3 = [], consent: f3 = e4.consent, id: p3 = Oe(), trigger: g3 = "", entity: m3 = n5, action: h3 = o4, timing: y2 = 0, source: w3 = { type: "collector", schema: "4" } } = t4;
6765
6979
  return { name: r5, data: a4, context: i4, globals: c2, custom: u2, user: d2, nested: l3, consent: f3, id: p3, trigger: g3, entity: m3, action: h3, timestamp: s6, timing: y2, source: w3 };
6766
6980
  }
6767
- function kt(e4, t4) {
6768
- return bt(e4, vt(e4, t4));
6981
+ function qt(e4, t4) {
6982
+ return It(e4, Ct2(e4, t4));
6769
6983
  }
6770
- async function Ct2(e4, t4) {
6771
- e4.allowed = true, e4.timing = Date.now(), t4 && (t4.consent && (e4.consent = oe(e4.consent, t4.consent), yt2(e4, n.Commands.Consent)), t4.user && (e4.user = oe(e4.user, t4.user), yt2(e4, n.Commands.User)), t4.globals && (e4.globals = oe(e4.config.globalsStatic || {}, t4.globals), yt2(e4, n.Commands.Globals)), t4.custom && (e4.custom = oe(e4.custom, t4.custom), yt2(e4, n.Commands.Custom))), Object.values(e4.destinations).forEach((e5) => {
6984
+ async function St(e4, t4) {
6985
+ e4.allowed = true, e4.timing = Date.now(), t4 && (t4.consent && (e4.consent = oe(e4.consent, t4.consent), bt(e4, n.Commands.Consent)), t4.user && (e4.user = oe(e4.user, t4.user), bt(e4, n.Commands.User)), t4.globals && (e4.globals = oe(e4.config.globalsStatic || {}, t4.globals), bt(e4, n.Commands.Globals)), t4.custom && (e4.custom = oe(e4.custom, t4.custom), bt(e4, n.Commands.Custom))), Object.values(e4.destinations).forEach((e5) => {
6772
6986
  e5.queuePush = [];
6773
6987
  }), e4.queue = [], e4.round++, await Ie2(e4), await Ke2(e4);
6774
- return await nt(e4);
6988
+ return await rt(e4);
6775
6989
  }
6776
- function At(e4, t4) {
6990
+ function Mt2(e4, t4) {
6777
6991
  const n5 = ct(async (n6, o4 = {}) => await Le(async () => {
6778
6992
  const s6 = Date.now(), { id: r5, ingest: a4, respond: i4, mapping: c2, preChain: u2, include: d2, exclude: l3 } = o4;
6779
6993
  let f3 = i4, p3 = n6;
@@ -6783,31 +6997,31 @@ function At(e4, t4) {
6783
6997
  })(e4.destinations, d2, l3) : void 0, m3 = a4 ?? E(r5 || "unknown");
6784
6998
  if (c2) {
6785
6999
  const t5 = await Je(p3, c2, e4);
6786
- if (t5.ignore) return rt({ ok: true });
7000
+ if (t5.ignore) return ct2({ ok: true });
6787
7001
  if (c2.consent) {
6788
- if (!je(c2.consent, e4.consent, t5.event.consent)) return rt({ ok: true });
7002
+ if (!je(c2.consent, e4.consent, t5.event.consent)) return ct2({ ok: true });
6789
7003
  }
6790
7004
  p3 = t5.event;
6791
7005
  }
6792
7006
  if (u2?.length && e4.transformers && Object.keys(e4.transformers).length > 0) {
6793
7007
  const n7 = await he2(e4, e4.transformers, u2, p3, m3, f3, r5 ? `source.${r5}.next` : void 0);
6794
- if (null === n7.event) return rt({ ok: true });
6795
- if (n7.stopped) return n7.respond && (f3 = n7.respond), rt({ ok: true });
7008
+ if (null === n7.event) return ct2({ ok: true });
7009
+ if (n7.stopped) return n7.respond && (f3 = n7.respond), ct2({ ok: true });
6796
7010
  if (n7.respond && (f3 = n7.respond), Array.isArray(n7.event)) {
6797
7011
  const o5 = await Promise.all(n7.event.map(async (n8) => {
6798
- const o6 = t4(n8), s7 = bt(e4, o6);
6799
- return nt(e4, s7, { id: r5, ingest: m3, respond: f3 }, g3);
7012
+ const o6 = t4(n8), s7 = It(e4, o6);
7013
+ return rt(e4, s7, { id: r5, ingest: m3, respond: f3 }, g3);
6800
7014
  }));
6801
7015
  if (r5) {
6802
7016
  e4.status.sources[r5] || (e4.status.sources[r5] = { count: 0, duration: 0 });
6803
7017
  const t5 = e4.status.sources[r5];
6804
7018
  t5.count += n7.event.length, t5.lastAt = Date.now(), t5.duration += Date.now() - s6;
6805
7019
  }
6806
- return o5[0] ?? rt({ ok: true });
7020
+ return o5[0] ?? ct2({ ok: true });
6807
7021
  }
6808
7022
  p3 = n7.event;
6809
7023
  }
6810
- const h3 = kt(e4, p3), y2 = await nt(e4, h3, { id: r5, ingest: m3, respond: f3 }, g3);
7024
+ const h3 = qt(e4, p3), y2 = await rt(e4, h3, { id: r5, ingest: m3, respond: f3 }, g3);
6811
7025
  if (r5) {
6812
7026
  e4.status.sources[r5] || (e4.status.sources[r5] = { count: 0, duration: 0 });
6813
7027
  const t5 = e4.status.sources[r5];
@@ -6816,7 +7030,7 @@ function At(e4, t4) {
6816
7030
  return y2;
6817
7031
  }, (t5) => {
6818
7032
  if (t5 instanceof He) throw t5;
6819
- return e4.status.failed++, e4.logger.error("push failed", { event: n6, ingest: o4.ingest, error: t5 }), rt({ ok: false });
7033
+ return e4.status.failed++, e4.logger.error("push failed", { event: n6, ingest: o4.ingest, error: t5 }), ct2({ ok: false });
6820
7034
  })(), "Push", e4.hooks, e4.logger);
6821
7035
  return async (t5, o4) => {
6822
7036
  const s6 = "string" == typeof t5.id ? t5.id : "", r5 = Date.now();
@@ -6830,7 +7044,7 @@ function At(e4, t4) {
6830
7044
  }
6831
7045
  };
6832
7046
  }
6833
- function Pt2(e4 = {}) {
7047
+ function Ht2(e4 = {}) {
6834
7048
  const t4 = e4.maxEntries ?? 1e4, n5 = e4.lowWaterMark ?? 0.8, o4 = e4.sweepIntervalMs ?? 6e4, s6 = Math.floor(t4 * n5), r5 = /* @__PURE__ */ new Map(), a4 = { hits: 0, misses: 0, populates: 0, writes: 0, deletes: 0, evictions_entries: 0, evictions_ttl: 0 };
6835
7049
  let i4;
6836
7050
  o4 > 0 && (i4 = setInterval(function() {
@@ -6863,7 +7077,7 @@ function Pt2(e4 = {}) {
6863
7077
  void 0 !== i4 && (clearInterval(i4), i4 = void 0), r5.clear();
6864
7078
  } };
6865
7079
  }
6866
- function Ft2(e4, t4) {
7080
+ function Ut2(e4, t4) {
6867
7081
  const { cacheConfig: n5, cacheStore: o4, namespace: s6, logger: r5, storeId: a4, collector: i4 } = t4, c2 = (e5, t5) => {
6868
7082
  if (!i4) return;
6869
7083
  const n6 = D2(i4, { stepId: `store.${a4}`, stepType: "store", phase: "in", eventId: "", now: Date.now() });
@@ -6928,7 +7142,7 @@ function Ft2(e4, t4) {
6928
7142
  r5 ? r5.warn(o5, { error: n6 }) : console.warn(o5, n6);
6929
7143
  }
6930
7144
  }
6931
- function Gt(e4, t4, n5) {
7145
+ function Wt2(e4, t4, n5) {
6932
7146
  const o4 = `store.${n5}`, s6 = ct(t4.get, "StoreGet", e4.hooks, e4.logger), r5 = ct(t4.set, "StoreSet", e4.hooks, e4.logger), a4 = ct(t4.delete, "StoreDelete", e4.hooks, e4.logger);
6933
7147
  t4.get = async (t5) => {
6934
7148
  const n6 = Date.now(), r6 = D2(e4, { stepId: o4, stepType: "store", phase: "in", eventId: "", now: n6 });
@@ -6964,7 +7178,7 @@ function Gt(e4, t4, n5) {
6964
7178
  }
6965
7179
  };
6966
7180
  }
6967
- async function Kt2(e4, t4 = {}) {
7181
+ async function Vt(e4, t4 = {}) {
6968
7182
  const n5 = {};
6969
7183
  for (const [o5, s7] of Object.entries(t4)) {
6970
7184
  const { code: t5, config: r5 = {}, env: a4 = {} } = s7, i4 = e4.logger.scope("store").scope(o5), c2 = { collector: e4, logger: i4, id: o5, config: r5, env: a4 }, u2 = await t5(c2);
@@ -6996,23 +7210,23 @@ async function Kt2(e4, t4 = {}) {
6996
7210
  const s7 = o4[t5].cache;
6997
7211
  if (!s7) continue;
6998
7212
  let r5, a4;
6999
- void 0 !== s7.store ? (r5 = n5[s7.store], a4 = s7.store) : (n5.__cache || (n5.__cache = Pt2()), r5 = n5.__cache, a4 = "__cache");
7213
+ void 0 !== s7.store ? (r5 = n5[s7.store], a4 = s7.store) : (n5.__cache || (n5.__cache = Ht2()), r5 = n5.__cache, a4 = "__cache");
7000
7214
  const i4 = s7.namespace ?? t5;
7001
- e4.logger.scope("store-cache").scope(t5).info(`store "${t5}" caches with namespace "${i4}:" via ${a4}`), n5[t5] = Ft2(n5[t5], { storeId: t5, cacheConfig: s7, cacheStore: r5, namespace: i4, logger: e4.logger.scope("store-cache").scope(t5), collector: e4 });
7215
+ e4.logger.scope("store-cache").scope(t5).info(`store "${t5}" caches with namespace "${i4}:" via ${a4}`), n5[t5] = Ut2(n5[t5], { storeId: t5, cacheConfig: s7, cacheStore: r5, namespace: i4, logger: e4.logger.scope("store-cache").scope(t5), collector: e4 });
7002
7216
  }
7003
- for (const [t5, o5] of Object.entries(n5)) "__cache" !== t5 && Gt(e4, o5, t5);
7217
+ for (const [t5, o5] of Object.entries(n5)) "__cache" !== t5 && Wt2(e4, o5, t5);
7004
7218
  return n5;
7005
7219
  }
7006
- async function Ut2(e4) {
7220
+ async function Nt2(e4) {
7007
7221
  const t4 = oe({ globalsStatic: {}, sessionStatic: {}, run: true, queueMax: 1e3 }, e4, { merge: false, extend: false }), n5 = { level: e4.logger?.level, handler: e4.logger?.handler }, o4 = Ue(n5), s6 = { ...t4.globalsStatic, ...e4.globals }, i4 = { allowed: false, config: t4, consent: e4.consent || {}, custom: e4.custom || {}, destinations: {}, transformers: {}, stores: {}, globals: s6, hooks: e4.hooks || {}, observers: /* @__PURE__ */ new Set(), logger: o4, on: {}, queue: [], round: 0, stateVersion: 0, cellVersion: {}, delivery: /* @__PURE__ */ new WeakMap(), session: void 0, status: { startedAt: Date.now(), in: 0, out: 0, failed: 0, sources: {}, destinations: {}, dropped: {} }, timing: Date.now(), user: e4.user || {}, sources: {}, pending: { destinations: {} }, hasShutdown: false, seenEvents: /* @__PURE__ */ new Set(), push: void 0, command: void 0 };
7008
- i4.push = At(i4, (e5) => vt(i4, e5)), i4.command = (function(e5, t5) {
7222
+ i4.push = Mt2(i4, (e5) => Ct2(i4, e5)), i4.command = (function(e5, t5) {
7009
7223
  return ct(async (n6, o5, s7) => await Le(async () => await t5(e5, n6, o5, s7), (t6) => {
7010
7224
  if (t6 instanceof He) throw t6;
7011
- return e5.status.failed++, e5.logger.error("command failed", { command: n6, data: o5, error: t6 }), rt({ ok: false });
7225
+ return e5.status.failed++, e5.logger.error("command failed", { command: n6, data: o5, error: t6 }), ct2({ ok: false });
7012
7226
  })(), "Command", e5.hooks, e5.logger);
7013
- })(i4, wt);
7227
+ })(i4, kt);
7014
7228
  const c2 = e4.stores || {};
7015
- return i4.stores = await Kt2(i4, c2), (function(e5, t5, n6) {
7229
+ return i4.stores = await Vt(i4, c2), (function(e5, t5, n6) {
7016
7230
  const o5 = /* @__PURE__ */ new Map();
7017
7231
  for (const [n7, s8] of Object.entries(e5)) t5[n7] && o5.set(s8, t5[n7]);
7018
7232
  if (0 !== o5.size) {
@@ -7026,7 +7240,7 @@ async function Ut2(e4) {
7026
7240
  }
7027
7241
  }
7028
7242
  }
7029
- })(c2, i4.stores, e4), i4.stores.__cache || (i4.stores.__cache = Pt2()), i4.destinations = await it2(i4, e4.destinations || {}), i4.transformers = await (async function(e5, t5 = {}) {
7243
+ })(c2, i4.stores, e4), i4.stores.__cache || (i4.stores.__cache = Ht2()), i4.destinations = await dt2(i4, e4.destinations || {}), i4.transformers = await (async function(e5, t5 = {}) {
7030
7244
  const n6 = {};
7031
7245
  for (const [o5, s7] of Object.entries(t5)) {
7032
7246
  const { code: t6, env: r5 = {} } = s7, a4 = mn(s7, "Transformer");
@@ -7057,9 +7271,9 @@ async function Ut2(e4) {
7057
7271
  return n6;
7058
7272
  })(i4, e4.transformers || {}), i4;
7059
7273
  }
7060
- async function Wt2(e4) {
7274
+ async function Lt2(e4) {
7061
7275
  e4 = e4 || {};
7062
- const t4 = await Ut2(e4), n5 = (o4 = t4, { type: "elb", config: {}, push: async (e5, t5, n6, s7, r6) => {
7276
+ const t4 = await Nt2(e4), n5 = (o4 = t4, { type: "elb", config: {}, push: async (e5, t5, n6, s7, r6) => {
7063
7277
  if ("string" == typeof e5 && e5.startsWith("walker ")) {
7064
7278
  const n7 = e5.replace("walker ", "");
7065
7279
  return o4.command(n7, t5);
@@ -7067,7 +7281,7 @@ async function Wt2(e4) {
7067
7281
  let a5;
7068
7282
  if ("string" == typeof e5) a5 = { name: e5 }, t5 && "object" == typeof t5 && !Array.isArray(t5) && (a5.data = t5);
7069
7283
  else {
7070
- if (!e5 || "object" != typeof e5) return rt({ ok: false });
7284
+ if (!e5 || "object" != typeof e5) return ct2({ ok: false });
7071
7285
  a5 = e5, t5 && "object" == typeof t5 && !Array.isArray(t5) && (a5.data = { ...a5.data || {}, ...t5 });
7072
7286
  }
7073
7287
  return n6 && "object" == typeof n6 && (a5.context = n6), s7 && Array.isArray(s7) && (a5.nested = s7), r6 && "object" == typeof r6 && (a5.custom = r6), o4.push(a5);
@@ -7080,15 +7294,15 @@ async function Wt2(e4) {
7080
7294
  const u2 = Object.values(t4.sources).filter((e5) => "elb" !== e5.type), d2 = u2.find((e5) => e5.config.primary);
7081
7295
  return d2 ? c2 = d2.push : u2.length > 0 && (c2 = u2[0].push), { collector: t4, elb: c2 };
7082
7296
  }
7083
- function Vt(e4) {
7297
+ function Yt(e4) {
7084
7298
  if (null === e4 || "object" != typeof e4) return e4;
7085
- if (Array.isArray(e4)) return e4.map(Vt);
7299
+ if (Array.isArray(e4)) return e4.map(Yt);
7086
7300
  const t4 = {};
7087
- for (const [n5, o4] of Object.entries(e4)) t4[n5] = "function" == typeof o4 ? o4 : Vt(o4);
7301
+ for (const [n5, o4] of Object.entries(e4)) t4[n5] = "function" == typeof o4 ? o4 : Yt(o4);
7088
7302
  return t4;
7089
7303
  }
7090
- function Nt2(e4) {
7091
- const t4 = [], { simulation: n5, ...o4 } = e4, s6 = Vt(o4);
7304
+ function Jt2(e4) {
7305
+ const t4 = [], { simulation: n5, ...o4 } = e4, s6 = Yt(o4);
7092
7306
  for (const e5 of n5) {
7093
7307
  const n6 = e5.startsWith("call:") ? e5.slice(5) : e5, o5 = n6.split(".");
7094
7308
  let r5 = s6;
@@ -7241,7 +7455,7 @@ async function createEmitter(opts) {
7241
7455
  }
7242
7456
  }
7243
7457
  };
7244
- const { elb } = await Wt2(collectorConfig);
7458
+ const { elb } = await Lt2(collectorConfig);
7245
7459
  elbFn = elb;
7246
7460
  return elbFn;
7247
7461
  }
@@ -7508,13 +7722,13 @@ function installTimerInterception(options = {}) {
7508
7722
  setInterval: Reflect.get(target, "setInterval"),
7509
7723
  clearInterval: Reflect.get(target, "clearInterval")
7510
7724
  });
7511
- const trackedSetTimeout = (callback, delay2, ...args) => {
7725
+ const trackedSetTimeout = (callback, delay3, ...args) => {
7512
7726
  if (typeof callback !== "function") return 0;
7513
7727
  const id = nextId++;
7514
7728
  pending.set(id, {
7515
7729
  id,
7516
7730
  callback,
7517
- delay: delay2 ?? 0,
7731
+ delay: delay3 ?? 0,
7518
7732
  type: "timeout",
7519
7733
  args,
7520
7734
  cleared: false
@@ -7527,13 +7741,13 @@ function installTimerInterception(options = {}) {
7527
7741
  const entry = pending.get(numId);
7528
7742
  if (entry) entry.cleared = true;
7529
7743
  };
7530
- const trackedSetInterval = (callback, delay2, ...args) => {
7744
+ const trackedSetInterval = (callback, delay3, ...args) => {
7531
7745
  if (typeof callback !== "function") return 0;
7532
7746
  const id = nextId++;
7533
7747
  pending.set(id, {
7534
7748
  id,
7535
7749
  callback,
7536
- delay: delay2 ?? 0,
7750
+ delay: delay3 ?? 0,
7537
7751
  type: "interval",
7538
7752
  args,
7539
7753
  cleared: false
@@ -8708,7 +8922,7 @@ async function simulateCollector(configOrPath, event, options) {
8708
8922
  if (options.state.timing !== void 0)
8709
8923
  collector.timing = options.state.timing;
8710
8924
  }
8711
- const enriched = kt(collector, event);
8925
+ const enriched = qt(collector, event);
8712
8926
  const captured = [{ event: enriched, timestamp: Date.now() }];
8713
8927
  await collector.command("shutdown");
8714
8928
  return buildSimulationResult({
@@ -8814,7 +9028,7 @@ async function simulateDestination(configOrPath, event, options) {
8814
9028
  ...devEnv.push,
8815
9029
  simulation: devEnv.simulation
8816
9030
  };
8817
- const { wrappedEnv, calls } = Nt2(combined);
9031
+ const { wrappedEnv, calls } = Jt2(combined);
8818
9032
  if (destConfig) destConfig.env = wrappedEnv;
8819
9033
  trackedCalls = calls;
8820
9034
  }
@@ -8911,7 +9125,7 @@ async function loadBundle(file, context2, logger) {
8911
9125
  }
8912
9126
 
8913
9127
  // src/runtime/runner.ts
8914
- async function loadFlow(file, config, logger, loggerConfig, healthServer, observers) {
9128
+ async function loadFlowHandle(file, config, logger, loggerConfig, healthServer, observers) {
8915
9129
  const absolutePath = resolve3(file);
8916
9130
  const flowDir = dirname4(absolutePath);
8917
9131
  process.chdir(flowDir);
@@ -8922,9 +9136,6 @@ async function loadFlow(file, config, logger, loggerConfig, healthServer, observ
8922
9136
  ...observers ? { observers } : {}
8923
9137
  };
8924
9138
  const result = await loadBundle(absolutePath, flowContext, logger);
8925
- if (healthServer && typeof result.httpHandler === "function") {
8926
- healthServer.setFlowHandler(result.httpHandler);
8927
- }
8928
9139
  return {
8929
9140
  collector: {
8930
9141
  command: result.collector.command,
@@ -8934,10 +9145,40 @@ async function loadFlow(file, config, logger, loggerConfig, healthServer, observ
8934
9145
  httpHandler: result.httpHandler
8935
9146
  };
8936
9147
  }
8937
- async function swapFlow(currentHandle, newFile, config, logger, loggerConfig, healthServer, observers) {
8938
- logger.info("Shutting down current flow for hot-swap...");
8939
- if (healthServer) {
8940
- healthServer.setFlowHandler(null);
9148
+ async function loadFlow(file, config, logger, loggerConfig, healthServer, observers) {
9149
+ const handle = await loadFlowHandle(
9150
+ file,
9151
+ config,
9152
+ logger,
9153
+ loggerConfig,
9154
+ healthServer,
9155
+ observers
9156
+ );
9157
+ if (healthServer && typeof handle.httpHandler === "function") {
9158
+ healthServer.setFlowHandler(handle.httpHandler);
9159
+ }
9160
+ return handle;
9161
+ }
9162
+ async function swapFlow(currentHandle, newFile, config, logger, loggerConfig, healthServer, observers, load = loadFlowHandle) {
9163
+ logger.info("Loading new flow for hot-swap...");
9164
+ let newHandle;
9165
+ try {
9166
+ newHandle = await load(
9167
+ newFile,
9168
+ config,
9169
+ logger,
9170
+ loggerConfig,
9171
+ healthServer,
9172
+ observers
9173
+ );
9174
+ } catch (error) {
9175
+ logger.error(
9176
+ `Hot-swap load failed, keeping current flow: ${error instanceof Error ? error.message : String(error)}`
9177
+ );
9178
+ return currentHandle;
9179
+ }
9180
+ if (healthServer && typeof newHandle.httpHandler === "function") {
9181
+ healthServer.setFlowHandler(newHandle.httpHandler);
8941
9182
  }
8942
9183
  try {
8943
9184
  if (currentHandle.collector.command) {
@@ -8946,14 +9187,6 @@ async function swapFlow(currentHandle, newFile, config, logger, loggerConfig, he
8946
9187
  } catch (error) {
8947
9188
  logger.debug(`Shutdown warning: ${error}`);
8948
9189
  }
8949
- const newHandle = await loadFlow(
8950
- newFile,
8951
- config,
8952
- logger,
8953
- loggerConfig,
8954
- healthServer,
8955
- observers
8956
- );
8957
9190
  logger.info("Flow swapped successfully");
8958
9191
  return newHandle;
8959
9192
  }
@@ -8975,9 +9208,9 @@ import { x as tarExtract } from "tar";
8975
9208
  var DEFAULT_PER_ATTEMPT_TIMEOUT_MS = 3e4;
8976
9209
  var DEFAULT_MAX_TOTAL_MS = 6e4;
8977
9210
  var DEFAULT_ATTEMPTS = 3;
8978
- var MIN_ATTEMPT_BUDGET_MS = 1e3;
8979
- var BASE_BACKOFF_MS = [2e3, 5e3];
8980
- var JITTER = 0.2;
9211
+ var MIN_ATTEMPT_BUDGET_MS2 = 1e3;
9212
+ var BASE_BACKOFF_MS2 = [2e3, 5e3];
9213
+ var JITTER2 = 0.2;
8981
9214
  var RETRYABLE_NETWORK_CODES = /* @__PURE__ */ new Set([
8982
9215
  "ECONNRESET",
8983
9216
  "ECONNREFUSED",
@@ -8985,7 +9218,7 @@ var RETRYABLE_NETWORK_CODES = /* @__PURE__ */ new Set([
8985
9218
  "EAI_AGAIN",
8986
9219
  "ENOTFOUND"
8987
9220
  ]);
8988
- function readErrorCode(value) {
9221
+ function readErrorCode2(value) {
8989
9222
  if (typeof value !== "object" || value === null) return void 0;
8990
9223
  const code = Reflect.get(value, "code");
8991
9224
  return typeof code === "string" ? code : void 0;
@@ -8998,10 +9231,10 @@ function readErrorName(value) {
8998
9231
  function isTransientThrow(error) {
8999
9232
  const name = readErrorName(error);
9000
9233
  if (name === "TimeoutError" || name === "AbortError") return true;
9001
- const directCode = readErrorCode(error);
9234
+ const directCode = readErrorCode2(error);
9002
9235
  if (directCode && RETRYABLE_NETWORK_CODES.has(directCode)) return true;
9003
9236
  if (typeof error === "object" && error !== null) {
9004
- const causeCode = readErrorCode(Reflect.get(error, "cause"));
9237
+ const causeCode = readErrorCode2(Reflect.get(error, "cause"));
9005
9238
  if (causeCode && RETRYABLE_NETWORK_CODES.has(causeCode)) return true;
9006
9239
  }
9007
9240
  return error instanceof TypeError;
@@ -9021,19 +9254,19 @@ function describeReason(reason) {
9021
9254
  let detail = name ? `${name}: ${message}` : message;
9022
9255
  if (typeof reason.error === "object" && reason.error !== null) {
9023
9256
  const cause = Reflect.get(reason.error, "cause");
9024
- const causeCode = readErrorCode(cause);
9257
+ const causeCode = readErrorCode2(cause);
9025
9258
  const causeMessage = readErrorMessage(cause);
9026
9259
  const causeDetail = causeCode ?? causeMessage;
9027
9260
  if (causeDetail) detail = `${detail} (${causeDetail})`;
9028
9261
  }
9029
9262
  return detail;
9030
9263
  }
9031
- function backoffForAttempt(index) {
9032
- const base = BASE_BACKOFF_MS[Math.min(index, BASE_BACKOFF_MS.length - 1)] ?? 0;
9033
- const spread = base * JITTER;
9264
+ function backoffForAttempt2(index) {
9265
+ const base = BASE_BACKOFF_MS2[Math.min(index, BASE_BACKOFF_MS2.length - 1)] ?? 0;
9266
+ const spread = base * JITTER2;
9034
9267
  return base + (Math.random() * 2 - 1) * spread;
9035
9268
  }
9036
- function delay(ms) {
9269
+ function delay2(ms) {
9037
9270
  return new Promise((resolve4) => {
9038
9271
  setTimeout(resolve4, ms);
9039
9272
  });
@@ -9048,7 +9281,7 @@ async function fetchWithRetry(url, options = {}) {
9048
9281
  let made = 0;
9049
9282
  for (let attempt = 0; attempt < attempts; attempt++) {
9050
9283
  const remaining = maxTotalMs - (Date.now() - start);
9051
- if (remaining <= MIN_ATTEMPT_BUDGET_MS) break;
9284
+ if (remaining <= MIN_ATTEMPT_BUDGET_MS2) break;
9052
9285
  const attemptTimeoutMs = Math.min(perAttemptTimeoutMs, remaining);
9053
9286
  made = attempt + 1;
9054
9287
  let reason;
@@ -9076,11 +9309,11 @@ async function fetchWithRetry(url, options = {}) {
9076
9309
  const budgetSpent = Date.now() - start >= maxTotalMs;
9077
9310
  if (isLastAttempt || budgetSpent) break;
9078
9311
  const sleepMs = Math.min(
9079
- backoffForAttempt(attempt),
9312
+ backoffForAttempt2(attempt),
9080
9313
  maxTotalMs - (Date.now() - start)
9081
9314
  );
9082
9315
  if (sleepMs <= 0) break;
9083
- await delay(sleepMs);
9316
+ await delay2(sleepMs);
9084
9317
  }
9085
9318
  const cause = lastReason ? describeReason(lastReason) : "no attempts made";
9086
9319
  throw new Error(`Fetch failed after ${made} attempts: ${cause}`);
@@ -9260,103 +9493,11 @@ init_cache();
9260
9493
  // src/runtime/heartbeat.ts
9261
9494
  import { randomBytes } from "crypto";
9262
9495
  init_http();
9496
+ init_dist();
9263
9497
 
9264
9498
  // src/runtime/redact.ts
9265
- var MAX_LENGTH = 256;
9266
- var MIN_TOKEN_LEN = 20;
9267
- var ENTROPY_THRESHOLD = 4;
9268
- var FORCE_MASK_PREFIXES = [
9269
- "sk-",
9270
- "sk_",
9271
- "pk_",
9272
- "ghp_",
9273
- "gho_",
9274
- "xoxb-",
9275
- "xoxp-",
9276
- "AKIA"
9277
- ];
9278
- var RE_URL_CREDS = /(:\/\/[^/:@\s]+:)[^@\s]+(@)/g;
9279
- var RE_JSON_PRIVATE_KEY = /("private_key"\s*:\s*)"[^"]*"/g;
9280
- var RE_PEM_BEGIN = /^\s*-----BEGIN [A-Z ]*PRIVATE KEY-----/i;
9281
- var RE_PEM_END = /-----END[A-Z -]*-----/i;
9282
- var TOKEN_VALUE_CLASS = "[A-Za-z0-9+/._-]";
9283
- var RE_KV_SECRET = new RegExp(
9284
- `(^|\\s)([A-Za-z_][A-Za-z0-9_.]{0,63}\\s*[=:]\\s*)(${TOKEN_VALUE_CLASS}{12,}={0,2})`,
9285
- "g"
9286
- );
9287
- var RE_TOKEN_RUN = new RegExp(`${TOKEN_VALUE_CLASS}{${MIN_TOKEN_LEN},}`, "g");
9288
- function escapeRegex(s6) {
9289
- return s6.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
9290
- }
9291
- var PREFIX_ALTERNATION = [...FORCE_MASK_PREFIXES].sort((a4, b3) => b3.length - a4.length).map(escapeRegex).join("|");
9292
- var RE_PREFIXED_TOKEN = new RegExp(
9293
- `(?:${PREFIX_ALTERNATION})${TOKEN_VALUE_CLASS}*`,
9294
- "g"
9295
- );
9296
- function shannonEntropy(s6) {
9297
- if (s6.length === 0) return 0;
9298
- const counts = /* @__PURE__ */ new Map();
9299
- for (const ch of s6) counts.set(ch, (counts.get(ch) ?? 0) + 1);
9300
- let entropy = 0;
9301
- for (const count of counts.values()) {
9302
- const p3 = count / s6.length;
9303
- entropy -= p3 * Math.log2(p3);
9304
- }
9305
- return entropy;
9306
- }
9307
- var RE_ALL_HEX = /^[0-9a-fA-F]+$/;
9308
- var RE_ALL_DIGIT = /^[0-9]+$/;
9309
- var RE_BASE64_SPECIAL = /[+/=]/;
9310
- var RE_HAS_DIGIT = /[0-9]/;
9311
- var RE_HAS_LETTER = /[A-Za-z]/;
9312
- function shouldMaskToken(run) {
9313
- if (RE_ALL_HEX.test(run)) return true;
9314
- if (RE_ALL_DIGIT.test(run)) return true;
9315
- if (RE_BASE64_SPECIAL.test(run)) return true;
9316
- if (RE_HAS_DIGIT.test(run) && RE_HAS_LETTER.test(run)) return true;
9317
- if (shannonEntropy(run) >= ENTROPY_THRESHOLD) return true;
9318
- return false;
9319
- }
9320
- function removePemBlocks(lines) {
9321
- const out = [];
9322
- let inBlock = false;
9323
- for (const line of lines) {
9324
- if (!inBlock) {
9325
- if (RE_PEM_BEGIN.test(line)) {
9326
- inBlock = true;
9327
- continue;
9328
- }
9329
- out.push(line);
9330
- } else {
9331
- if (RE_PEM_END.test(line)) {
9332
- inBlock = false;
9333
- }
9334
- }
9335
- }
9336
- return out;
9337
- }
9338
- function maskLine(line) {
9339
- let s6 = line;
9340
- s6 = s6.replace(RE_URL_CREDS, "$1***$2");
9341
- s6 = s6.replace(RE_KV_SECRET, "$1$2***");
9342
- s6 = s6.replace(RE_PREFIXED_TOKEN, "***");
9343
- s6 = s6.replace(
9344
- RE_TOKEN_RUN,
9345
- (match) => shouldMaskToken(match) ? "***" : match
9346
- );
9347
- return s6;
9348
- }
9349
- function redactLine(line) {
9350
- const withoutJsonKey = line.replace(RE_JSON_PRIVATE_KEY, '$1"***"');
9351
- const rawLines = withoutJsonKey.split("\n");
9352
- const cleanLines = removePemBlocks(rawLines);
9353
- const maskedLines = cleanLines.map(maskLine);
9354
- const joined = maskedLines.join("\n");
9355
- if (joined.length > MAX_LENGTH) {
9356
- return joined.slice(0, MAX_LENGTH - 1) + "\u2026";
9357
- }
9358
- return joined;
9359
- }
9499
+ init_redact_line();
9500
+ init_redact_line();
9360
9501
  function redactErrors(errors) {
9361
9502
  return errors.map((e4) => ({
9362
9503
  message: redactLine(e4.message),
@@ -9380,12 +9521,18 @@ function computeCounterDelta(current, last) {
9380
9521
  const prev = last.destinations[name] || {
9381
9522
  count: 0,
9382
9523
  failed: 0,
9383
- duration: 0
9524
+ duration: 0,
9525
+ dlqSize: 0,
9526
+ dropped: 0
9384
9527
  };
9385
9528
  destinations[name] = {
9386
9529
  count: dest.count - prev.count,
9387
9530
  failed: dest.failed - prev.failed,
9388
- duration: dest.duration - prev.duration
9531
+ duration: dest.duration - prev.duration,
9532
+ // dlqSize is a current-depth gauge, not a monotonic counter: report the
9533
+ // live value rather than the difference between two snapshots.
9534
+ dlqSize: dest.dlqSize,
9535
+ dropped: dest.dropped - prev.dropped
9389
9536
  };
9390
9537
  }
9391
9538
  return {
@@ -9395,13 +9542,17 @@ function computeCounterDelta(current, last) {
9395
9542
  destinations
9396
9543
  };
9397
9544
  }
9398
- function snapshotDestinations(destinations) {
9545
+ function snapshotDestinations(status) {
9399
9546
  const result = {};
9400
- for (const [name, dest] of Object.entries(destinations)) {
9547
+ for (const [name, dest] of Object.entries(status.destinations)) {
9548
+ const drops = status.dropped[o("destination", name)];
9549
+ const dropped = (drops?.queue ?? 0) + (drops?.dlq ?? 0);
9401
9550
  result[name] = {
9402
9551
  count: dest.count,
9403
9552
  failed: dest.failed,
9404
- duration: dest.duration
9553
+ duration: dest.duration,
9554
+ dlqSize: dest.dlqSize,
9555
+ dropped
9405
9556
  };
9406
9557
  }
9407
9558
  return result;
@@ -9430,7 +9581,7 @@ function createHeartbeat(config, logger) {
9430
9581
  in: status.in,
9431
9582
  out: status.out,
9432
9583
  failed: status.failed,
9433
- destinations: snapshotDestinations(status.destinations)
9584
+ destinations: snapshotDestinations(status)
9434
9585
  };
9435
9586
  counters = computeCounterDelta(current, lastReported);
9436
9587
  }
@@ -9453,7 +9604,10 @@ function createHeartbeat(config, logger) {
9453
9604
  cliVersion: VERSION,
9454
9605
  uptime: Math.floor((Date.now() - startTime) / 1e3),
9455
9606
  ...counters && { counters },
9456
- ...errors.length && { recentErrors: errors },
9607
+ // Always send recentErrors (even []) so a heartbeat that no longer
9608
+ // carries any errors clears a stale snapshot on the app side. logs
9609
+ // have no clear semantics, so they stay omit-when-empty.
9610
+ recentErrors: errors,
9457
9611
  ...logs.length && { recentLogs: logs }
9458
9612
  }),
9459
9613
  signal: AbortSignal.timeout(1e4)
@@ -9492,7 +9646,7 @@ function createHeartbeat(config, logger) {
9492
9646
  // src/runtime/poller.ts
9493
9647
  function createPoller(config, logger) {
9494
9648
  let timer = null;
9495
- let lastEtag;
9649
+ let lastEtag = config.initialEtag;
9496
9650
  async function pollOnce() {
9497
9651
  try {
9498
9652
  const result = await fetchConfig({
@@ -9513,7 +9667,6 @@ function createPoller(config, logger) {
9513
9667
  }
9514
9668
  }
9515
9669
  function start() {
9516
- lastEtag = void 0;
9517
9670
  const jitter = config.intervalMs * 0.15 * (Math.random() * 2 - 1);
9518
9671
  timer = setInterval(() => pollOnce(), config.intervalMs + jitter);
9519
9672
  logger.info(
@@ -9867,7 +10020,7 @@ async function runPipeline(options) {
9867
10020
  logger.info(`walkeros/flow v${VERSION}`);
9868
10021
  logger.info(`Instance: ${getInstanceId()}`);
9869
10022
  if (configFrozen) {
9870
- logger.info("Config frozen: hot-swap and heartbeat disabled");
10023
+ logger.info("Config frozen: hot-swap disabled (heartbeat still active)");
9871
10024
  }
9872
10025
  const healthServer = await createHealthServer(port, logger);
9873
10026
  const observeLevel = readObserveLevel(logger);
@@ -9920,7 +10073,7 @@ async function runPipeline(options) {
9920
10073
  }
9921
10074
  let currentBundleCleanup;
9922
10075
  let currentConfigPath;
9923
- if (api && !configFrozen) {
10076
+ if (shouldStartHeartbeat(api)) {
9924
10077
  heartbeat = createHeartbeat(
9925
10078
  {
9926
10079
  appUrl: api.appUrl,
@@ -9938,6 +10091,8 @@ async function runPipeline(options) {
9938
10091
  );
9939
10092
  heartbeat.start();
9940
10093
  logger.info(`Heartbeat: active (every ${api.heartbeatIntervalMs / 1e3}s)`);
10094
+ }
10095
+ if (api && shouldStartPoller(api, configFrozen)) {
9941
10096
  poller = createPoller(
9942
10097
  {
9943
10098
  fetchOptions: {
@@ -9947,6 +10102,7 @@ async function runPipeline(options) {
9947
10102
  flowId: api.flowId
9948
10103
  },
9949
10104
  intervalMs: api.pollIntervalMs,
10105
+ initialEtag: resolveInitialEtag(options.bootEtag),
9950
10106
  onUpdate: async (content, version) => {
9951
10107
  try {
9952
10108
  await injectSecrets(api, logger);
@@ -9970,8 +10126,7 @@ async function runPipeline(options) {
9970
10126
  silent: true,
9971
10127
  flowName: api.flowName
9972
10128
  });
9973
- healthServer.setReady(false);
9974
- handle = await swapFlow(
10129
+ const swapped = await swapFlow(
9975
10130
  handle,
9976
10131
  newBundleResult.bundlePath,
9977
10132
  runtimeConfig,
@@ -9980,7 +10135,14 @@ async function runPipeline(options) {
9980
10135
  healthServer,
9981
10136
  telemetryObservers
9982
10137
  );
9983
- healthServer.setReady(true);
10138
+ if (swapped === handle) {
10139
+ await newBundleResult.cleanup().catch(() => {
10140
+ });
10141
+ await fs17.remove(tmpConfigPath).catch(() => {
10142
+ });
10143
+ return;
10144
+ }
10145
+ handle = swapped;
9984
10146
  writeCache(
9985
10147
  api.cacheDir,
9986
10148
  newBundleResult.bundlePath,
@@ -10036,9 +10198,44 @@ async function runPipeline(options) {
10036
10198
  };
10037
10199
  process.on("SIGTERM", () => shutdown("SIGTERM"));
10038
10200
  process.on("SIGINT", () => shutdown("SIGINT"));
10201
+ registerProcessGuards(logger);
10039
10202
  await new Promise(() => {
10040
10203
  });
10041
10204
  }
10205
+ function handleUnhandledRejection(reason, deps) {
10206
+ deps.logger.error(
10207
+ `Unhandled rejection (continuing): ${reason instanceof Error ? reason.message : String(reason)}`
10208
+ );
10209
+ }
10210
+ function handleUncaughtException(error, deps) {
10211
+ deps.logger.error(`Uncaught exception (continuing): ${error.message}`);
10212
+ }
10213
+ var processGuardsRegistered = false;
10214
+ function registerProcessGuards(logger) {
10215
+ if (processGuardsRegistered) return;
10216
+ processGuardsRegistered = true;
10217
+ const deps = {
10218
+ logger,
10219
+ exit: (code) => process.exit(code)
10220
+ };
10221
+ process.on(
10222
+ "unhandledRejection",
10223
+ (reason) => handleUnhandledRejection(reason, deps)
10224
+ );
10225
+ process.on(
10226
+ "uncaughtException",
10227
+ (error) => handleUncaughtException(error, deps)
10228
+ );
10229
+ }
10230
+ function resolveInitialEtag(bootEtag) {
10231
+ return bootEtag ?? process.env.WALKEROS_CONFIG_ETAG;
10232
+ }
10233
+ function shouldStartHeartbeat(api) {
10234
+ return Boolean(api);
10235
+ }
10236
+ function shouldStartPoller(api, configFrozen) {
10237
+ return Boolean(api) && !configFrozen;
10238
+ }
10042
10239
  var OBSERVE_LEVELS = [
10043
10240
  "off",
10044
10241
  "standard",
@@ -10122,13 +10319,12 @@ async function runCommand(options) {
10122
10319
  [l.INFO]: "info",
10123
10320
  [l.DEBUG]: "debug"
10124
10321
  };
10125
- const logger = createCLILogger({
10126
- ...options,
10127
- onLine: (level, message) => {
10128
- if (level === l.ERROR) errorRing.add(message);
10129
- logRing.add({ time: Date.now(), level: LEVEL_NAME[level], message });
10130
- }
10131
- });
10322
+ const onLine = (level, message) => {
10323
+ if (level === l.ERROR) errorRing.add(message);
10324
+ logRing.add({ time: Date.now(), level: LEVEL_NAME[level], message });
10325
+ };
10326
+ const logger = createCLILogger({ ...options, onLine });
10327
+ const collectorLoggerConfig = createCLILoggerConfig({ ...options, onLine });
10132
10328
  try {
10133
10329
  if (options.envFile) {
10134
10330
  const { loadEnvFile: loadEnvFile2 } = await Promise.resolve().then(() => (init_env_file(), env_file_exports));
@@ -10187,7 +10383,7 @@ async function runCommand(options) {
10187
10383
  prepareBundleForRun: lazyPrepareBundleForRun
10188
10384
  };
10189
10385
  }
10190
- const bundlePath = await resolveBundlePath(
10386
+ const { bundlePath, bootEtag } = await resolveBundlePath(
10191
10387
  options.config,
10192
10388
  apiConfig,
10193
10389
  logger
@@ -10195,9 +10391,10 @@ async function runCommand(options) {
10195
10391
  logger.info("Starting flow...");
10196
10392
  await runPipeline({
10197
10393
  bundlePath,
10394
+ bootEtag,
10198
10395
  port,
10199
10396
  logger: logger.scope("runner"),
10200
- loggerConfig: options.verbose ? { level: 0 } : void 0,
10397
+ loggerConfig: collectorLoggerConfig,
10201
10398
  api: apiConfig,
10202
10399
  errorRing,
10203
10400
  logRing
@@ -10228,7 +10425,7 @@ async function resolveBundlePath(configInput, apiConfig, logger) {
10228
10425
  logger.info(`Bundle: ${resolved.path}`);
10229
10426
  }
10230
10427
  if (isPreBuiltConfig(resolved.path)) {
10231
- return path18.resolve(resolved.path);
10428
+ return { bundlePath: path18.resolve(resolved.path) };
10232
10429
  }
10233
10430
  const flowFile = validateFlowFile(resolved.path);
10234
10431
  logger.debug("Building flow bundle");
@@ -10237,7 +10434,7 @@ async function resolveBundlePath(configInput, apiConfig, logger) {
10237
10434
  silent: true,
10238
10435
  flowName: apiConfig?.flowName
10239
10436
  });
10240
- return result.bundlePath;
10437
+ return { bundlePath: result.bundlePath };
10241
10438
  }
10242
10439
  if (process.env.WALKEROS_CLIENT_TYPE === "runner") {
10243
10440
  logger.error(
@@ -10284,7 +10481,7 @@ async function resolveBundlePath(configInput, apiConfig, logger) {
10284
10481
  } catch {
10285
10482
  logger.debug("Cache write failed (non-critical)");
10286
10483
  }
10287
- return bundleResult.bundlePath;
10484
+ return { bundlePath: bundleResult.bundlePath, bootEtag: result.etag };
10288
10485
  }
10289
10486
  } catch (error) {
10290
10487
  logger.error(
@@ -10293,7 +10490,7 @@ async function resolveBundlePath(configInput, apiConfig, logger) {
10293
10490
  const cached = readCache(apiConfig.cacheDir);
10294
10491
  if (cached) {
10295
10492
  logger.info(`Using cached bundle (version: ${cached.version})`);
10296
- return cached.bundlePath;
10493
+ return { bundlePath: cached.bundlePath };
10297
10494
  }
10298
10495
  throw new Error(
10299
10496
  "No config available. API fetch failed and no cached bundle."
@@ -10302,7 +10499,7 @@ async function resolveBundlePath(configInput, apiConfig, logger) {
10302
10499
  }
10303
10500
  const defaultFile = "server-collect.mjs";
10304
10501
  logger.debug(`No config specified, using default: ${defaultFile}`);
10305
- return path18.resolve(defaultFile);
10502
+ return { bundlePath: path18.resolve(defaultFile) };
10306
10503
  }
10307
10504
 
10308
10505
  // src/commands/setup/index.ts
@@ -12354,7 +12551,7 @@ function validateMapping(input) {
12354
12551
  // src/commands/validate/validators/entry.ts
12355
12552
  init_dist();
12356
12553
  import Ajv from "ajv";
12357
- var CLIENT_HEADER = "walkeros-cli/4.2.1-next-1781538735002";
12554
+ var CLIENT_HEADER = "walkeros-cli/4.2.1-next-1781594053720";
12358
12555
  var SECTIONS = ["destinations", "sources", "transformers"];
12359
12556
  function resolveEntry(path19, flowConfig) {
12360
12557
  const flows = flowConfig.flows;