raindrop-ai 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -145,7 +145,7 @@ var init_chunk_ZCB62SIO = __esm({
145
145
  }
146
146
  });
147
147
 
148
- // ../core/dist/chunk-5OUEKTIO.js
148
+ // ../core/dist/chunk-OPHDM4MC.js
149
149
  function state() {
150
150
  const holder = globalThis;
151
151
  let current = holder[STATE_KEY];
@@ -281,14 +281,14 @@ function attributeStorage() {
281
281
  return storage2;
282
282
  }
283
283
  function makeAttributeFrame(attributes, owner) {
284
- const snapshot = { ...attributes };
284
+ const snapshot2 = { ...attributes };
285
285
  const WeakRefCtor = owner !== void 0 ? getWeakRefCtor() : void 0;
286
286
  const ref = WeakRefCtor && owner !== void 0 ? new WeakRefCtor(owner) : void 0;
287
287
  const owned = /* @__PURE__ */ new WeakSet();
288
288
  let dead = false;
289
289
  let sawError = false;
290
290
  return {
291
- attributes: snapshot,
291
+ attributes: snapshot2,
292
292
  sawErrorSpan: () => sawError,
293
293
  ownsSpan: (span) => owned.has(span),
294
294
  claimSpan(span) {
@@ -433,24 +433,24 @@ function detectedSource(env, table, detectBranch) {
433
433
  function createAppGitContext(options, runtime = {}) {
434
434
  return new AppGitContext(options, runtime);
435
435
  }
436
- function withAppGitProperties(properties, snapshot) {
436
+ function withAppGitProperties(properties, snapshot2) {
437
437
  try {
438
438
  const merged = { ...properties };
439
439
  for (const key of APP_GIT_KEYS)
440
- if (!own(merged, key) && own(snapshot, key)) merged[key] = snapshot[key];
440
+ if (!own(merged, key) && own(snapshot2, key)) merged[key] = snapshot2[key];
441
441
  return merged;
442
442
  } catch (e) {
443
443
  return properties != null ? properties : {};
444
444
  }
445
445
  }
446
- function withAppGitAttributes(attributes, snapshot) {
446
+ function withAppGitAttributes(attributes, snapshot2) {
447
447
  try {
448
448
  const present = new Set(attributes.flatMap((attr) => attr ? [attr.key] : []));
449
449
  const added = [];
450
450
  for (const key of APP_GIT_KEYS) {
451
451
  if (present.has(key) || present.has(`ai.telemetry.metadata.${key}`) || present.has(`traceloop.association.properties.${key}`))
452
452
  continue;
453
- const value = snapshot[key];
453
+ const value = snapshot2[key];
454
454
  if (typeof value === "string") added.push({ key, value: { stringValue: value } });
455
455
  else if (typeof value === "boolean") added.push({ key, value: { boolValue: value } });
456
456
  }
@@ -976,7 +976,7 @@ async function sendJson(url2, body, headers, opts) {
976
976
  if (typeof retryAfterMs === "number") error62.retryAfterMs = retryAfterMs;
977
977
  noteSendPause(url2, resp.status, retryAfterMs);
978
978
  error62.retryable = resp.status === 408 || resp.status === 429 || resp.status >= 500;
979
- if (!error62.retryable) return { status: "rejected", error: error62 };
979
+ if (!error62.retryable) return { status: "rejected", error: error62, httpStatus: resp.status };
980
980
  lastError = error62;
981
981
  logAttemptFailure(opts, prefix, opName, attempt, error62);
982
982
  continue;
@@ -2025,6 +2025,7 @@ function needsLookup(local, remote, writeKey) {
2025
2025
  return local === void 0 && Boolean(remote) && Boolean(writeKey);
2026
2026
  }
2027
2027
  function piiRedactionNow(local, remote, endpoint, writeKey) {
2028
+ if (typeof writeKey === "function") return resolvePiiRedaction(local, remote, "unknown");
2028
2029
  if (!needsLookup(local, remote, writeKey)) return local === true;
2029
2030
  try {
2030
2031
  const answer = remotePiiAnswerNow(endpoint, writeKey);
@@ -2034,6 +2035,7 @@ function piiRedactionNow(local, remote, endpoint, writeKey) {
2034
2035
  }
2035
2036
  }
2036
2037
  async function piiRedaction(local, remote, endpoint, writeKey, deadlineAt) {
2038
+ if (typeof writeKey === "function") return resolvePiiRedaction(local, remote, "unknown");
2037
2039
  if (!needsLookup(local, remote, writeKey)) return local === true;
2038
2040
  try {
2039
2041
  return resolvePiiRedaction(local, remote, await remotePiiAnswer(endpoint, writeKey, deadlineAt));
@@ -2071,6 +2073,138 @@ function isMissingUserId(value) {
2071
2073
  const trimmed = value.trim();
2072
2074
  return trimmed === "" || PLACEHOLDER_USER_IDS.has(trimmed);
2073
2075
  }
2076
+ function hasWriteKey(writeKey) {
2077
+ if (typeof writeKey === "function") return true;
2078
+ return typeof writeKey === "string" && writeKey.trim().length > 0;
2079
+ }
2080
+ function describeError(error62) {
2081
+ try {
2082
+ if (typeof error62 !== "object" || error62 === null) return "a non-error value";
2083
+ const name = "name" in error62 ? error62.name : void 0;
2084
+ const code = "code" in error62 ? error62.code : void 0;
2085
+ const status = "status" in error62 ? error62.status : void 0;
2086
+ const labels = [
2087
+ typeof name === "string" && ERROR_NAME.test(name) ? name : "an error",
2088
+ typeof code === "string" && KNOWN_ERROR_CODES.has(code) ? code : void 0,
2089
+ typeof status === "number" && Number.isInteger(status) && status >= 100 && status <= 599 ? `(HTTP ${status})` : void 0
2090
+ ].filter((label) => label !== void 0);
2091
+ return labels.join(" ");
2092
+ } catch (e) {
2093
+ return "an error";
2094
+ }
2095
+ }
2096
+ async function callOnce(fn) {
2097
+ let timer;
2098
+ try {
2099
+ const value = await Promise.race([
2100
+ // SDK work, not the app's: keep the function's own requests out of host traces.
2101
+ Promise.resolve().then(() => runWithTracingSuppressed(fn)),
2102
+ // Unreferenced: the sends waiting on the call hold their own timers.
2103
+ new Promise((resolve2) => {
2104
+ var _a5;
2105
+ timer = setTimeout(() => resolve2(TIMED_OUT), WRITE_KEY_FUNCTION_TIMEOUT_MS);
2106
+ (_a5 = timer.unref) == null ? void 0 : _a5.call(timer);
2107
+ })
2108
+ ]);
2109
+ if (value === TIMED_OUT) {
2110
+ return { failure: `did not return within ${WRITE_KEY_FUNCTION_TIMEOUT_MS} ms` };
2111
+ }
2112
+ if (typeof value !== "string") return { failure: "returned a value that is not a string" };
2113
+ const key = value.trim();
2114
+ if (!key) return { failure: "returned an empty key" };
2115
+ if (!HEADER_SAFE.test(key)) {
2116
+ return { failure: "returned a key with characters an HTTP header cannot carry" };
2117
+ }
2118
+ return { key };
2119
+ } catch (error62) {
2120
+ return { failure: `threw ${describeError(error62)}` };
2121
+ } finally {
2122
+ clearTimeout(timer);
2123
+ }
2124
+ }
2125
+ function runningCalls() {
2126
+ var _a5;
2127
+ const holder = globalThis;
2128
+ (_a5 = holder[RUNNING_KEY]) != null ? _a5 : holder[RUNNING_KEY] = /* @__PURE__ */ new WeakMap();
2129
+ return holder[RUNNING_KEY];
2130
+ }
2131
+ function callShared(fn) {
2132
+ const running = runningCalls();
2133
+ const current = running.get(fn);
2134
+ if (current) return current;
2135
+ const call = callOnce(fn);
2136
+ running.set(fn, call);
2137
+ void call.then(() => {
2138
+ if (running.get(fn) === call) running.delete(fn);
2139
+ });
2140
+ return call;
2141
+ }
2142
+ function waitUntil(promise2, deadlineAt, cutOff) {
2143
+ const remaining = deadlineAt === void 0 ? Infinity : deadlineAt - Date.now();
2144
+ if (remaining <= 0 || (cutOff == null ? void 0 : cutOff.aborted)) return Promise.resolve(void 0);
2145
+ return new Promise((resolve2) => {
2146
+ let timer;
2147
+ const finish = (value) => {
2148
+ clearTimeout(timer);
2149
+ cutOff == null ? void 0 : cutOff.removeEventListener("abort", giveUp);
2150
+ resolve2(value);
2151
+ };
2152
+ const giveUp = () => finish(void 0);
2153
+ timer = setTimeout(giveUp, Math.min(remaining, WRITE_KEY_FUNCTION_TIMEOUT_MS + 1e3));
2154
+ cutOff == null ? void 0 : cutOff.addEventListener("abort", giveUp, { once: true });
2155
+ promise2.then(finish, giveUp);
2156
+ });
2157
+ }
2158
+ function prefixFor2(opts) {
2159
+ return opts.sdkName ? `[raindrop-ai/${opts.sdkName}]` : "[raindrop-ai/core]";
2160
+ }
2161
+ function snapshot(body) {
2162
+ try {
2163
+ const json2 = JSON.stringify(body);
2164
+ return json2 === void 0 ? body : JSON.parse(json2);
2165
+ } catch (e) {
2166
+ return body;
2167
+ }
2168
+ }
2169
+ function sendJsonWithWriteKey(url2, body, writeKey, headers, opts) {
2170
+ if (!writeKey.fn) {
2171
+ const auth = writeKey.staticKey ? { Authorization: `Bearer ${writeKey.staticKey}` } : {};
2172
+ return sendJson(url2, body, { ...auth, ...headers }, opts);
2173
+ }
2174
+ return sendWithKeyFunction(url2, body, writeKey, headers, opts);
2175
+ }
2176
+ async function sendWithKeyFunction(url2, body, writeKey, headers, opts) {
2177
+ var _a5;
2178
+ const payload = snapshot(body);
2179
+ const budgetEndsAt = opts.deadlineAt === void 0 && opts.timeoutMs !== void 0 ? Date.now() + opts.timeoutMs : void 0;
2180
+ const waitUntilAt = (_a5 = opts.deadlineAt) != null ? _a5 : budgetEndsAt;
2181
+ const sendOpts = () => budgetEndsAt === void 0 ? opts : { ...opts, timeoutMs: Math.max(1, budgetEndsAt - Date.now()) };
2182
+ const first = await writeKey.resolve(waitUntilAt, opts.cutOff);
2183
+ if (first.status === "deferred") return { status: "deferred" };
2184
+ if (first.status === "failed") {
2185
+ return {
2186
+ status: "failed",
2187
+ error: new Error("writeKey function did not return a key"),
2188
+ reported: true
2189
+ };
2190
+ }
2191
+ const outcome = await sendJson(
2192
+ url2,
2193
+ payload,
2194
+ { Authorization: `Bearer ${first.key}`, ...headers },
2195
+ sendOpts()
2196
+ );
2197
+ if (outcome.status !== "rejected" || outcome.httpStatus !== 401 || opts.maxAttempts <= 1) {
2198
+ return outcome;
2199
+ }
2200
+ const fresh = await writeKey.resolve(waitUntilAt, opts.cutOff);
2201
+ if (fresh.status === "deferred") return { status: "deferred" };
2202
+ if (fresh.status !== "key" || fresh.key === first.key) return outcome;
2203
+ if (opts.debug) {
2204
+ console.log(`${prefixFor2(opts)} HTTP 401; resending with a new key from the writeKey function`);
2205
+ }
2206
+ return sendJson(url2, payload, { Authorization: `Bearer ${fresh.key}`, ...headers }, sendOpts());
2207
+ }
2074
2208
  function snapshotPayload(payload) {
2075
2209
  try {
2076
2210
  const json2 = JSON.stringify(payload);
@@ -2373,9 +2507,9 @@ function promptToolsFromTraceloopAttributes(attributes) {
2373
2507
  }
2374
2508
  return tools;
2375
2509
  }
2376
- var require_NameRedactor, require_simple_regexp_patterns, require_utils, require_SimpleRegexpRedactor, require_composition, require_AsyncCompositeRedactor, require_SyncCompositeRedactor, require_dist, STATE_KEY, MAX_BINDING_STACK, EMPTY_STACK, ContextStackStorage, NO_AMBIENT_ROUTING_BIND_WARNING, NO_AMBIENT_ATTRIBUTE_BIND_WARNING, ROUTING_STORAGE_KEY, ATTRIBUTE_STORAGE_KEY, APP_COMMIT_SHA, APP_COMMIT_DIRTY, APP_BRANCH, APP_GIT_KEYS, own, DEPLOYMENTS, CI_SOURCES, AppGitContextImpl, AppGitContext, HANDOFF_ATTRIBUTE_SUFFIXES, AI_SDK_METADATA_PREFIX, DETACHED_MODE, SUBAGENT_AGENT_ROLE, HANDOFF_TERMINAL_CANCELLED, TOOL_EVENTS_SUFFIX, TOOL_EVENTS_ALLOW, OPERATION_ID_ATTRIBUTE, SUBAGENT_ABORT_OPERATION_ID, SUBAGENT_ABORT_SPAN_NAME, DEFAULT_DISPATCH_SPAN_NAME, HANDOFF_TERMINAL_PROPERTY_KEY, BAGGAGE_KEYS, TRACEPARENT_HEADER, BAGGAGE_HEADER, W3C_TRACE_ID, W3C_SPAN_ID, warnedNonConformantIds, HANDOFF_HEADER, LANGSMITH_TRACE_HEADER, LANGSMITH_METADATA_BAGGAGE_KEY, ConflictingCarrierError, UNRESOLVED_CARRIER_WARNING, UNRESOLVED_CARRIER_WARNED_KEY, MAX_QUOTED_ITEMS, DEFAULT_FLUSH_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, MAX_RETRY_DELAY_MS, RATE_LIMITED_LOG_INTERVAL_MS, rateLimitedLogLast, InFlightCutOff, sendPausedUntil, DELIVERED, DEFAULT_MAX_TEXT_FIELD_CHARS, TRUNCATION_MARKER, BOUNDED_CLONE_MAX_DEPTH, BOUNDED_CLONE_SLACK, currentDefaultMaxTextFieldChars, LOCAL_DEBUGGER_ENV_VAR, WORKSHOP_ENV_VAR, DEFAULT_LOCAL_WORKSHOP_URL, LOCAL_DEBUGGER_MIRROR_TIMEOUT_MS, PROJECT_ID_HEADER, PROJECT_ID_SLUG_PATTERN, PII_MARKERS, day, month, year, monthName, date, birthDate, mrn, contextualPiiRedactor, import_redact_pii, DEFAULT_PII_REDACTION_OPTIONS, redactor, CONTENT_KEY_SUFFIX, CONTENT_KEYS, NON_CONTENT_PREFIXES, ASSOCIATION_PROPERTY, SDK_ASSOCIATION_PROPERTIES, JSON_SIMPLE_ESCAPES, NO_SPAN_PII_FIELDS, MASK_FAILED, EVENT_FIELDS, SDK_PROPERTY_KEYS, KINDS, DEFAULT_PII_FIELDS, PROTECTED_LOCATIONS, SIGNAL_PATH_ALIASES, PiiFieldRedactor, REMOTE_PII_LOOKUP_TIMEOUT_MS, REFRESH_AFTER_MS, RETRY_AFTER_MS, STATE_KEY2, LOCAL_TRACE_KEY, PLACEHOLDER_USER_IDS, MAX_DEFERRED_SENDS, POST_SHUTDOWN_TIMEOUT_MS, UNSAFE_MERGE_KEYS, FINISHED_EVENT_MEMORY, MANUAL_UPDATES, EventShipper, MODEL_USAGE_ATTRIBUTES, MODEL_PROVIDER_NAMES, KNOWN_MODEL_PROVIDERS, STRING_ALIASES, NUMBER_ALIASES, DEFAULT_SECRET_KEY_NAMES, URL_USERINFO, DEFAULT_SECRET_SET, DEFAULT_REDACT_ATTRIBUTE_KEYS, REDACT_JSON_ATTRIBUTE_KEYS, UNDELIVERED, PROMPT_TOOLS_ATTRIBUTE, JSON_SCHEMA_KEYS, NOT_A_GEMINI_GROUP_KEYS;
2377
- var init_chunk_5OUEKTIO = __esm({
2378
- "../core/dist/chunk-5OUEKTIO.js"() {
2510
+ var require_NameRedactor, require_simple_regexp_patterns, require_utils, require_SimpleRegexpRedactor, require_composition, require_AsyncCompositeRedactor, require_SyncCompositeRedactor, require_dist, STATE_KEY, MAX_BINDING_STACK, EMPTY_STACK, ContextStackStorage, NO_AMBIENT_ROUTING_BIND_WARNING, NO_AMBIENT_ATTRIBUTE_BIND_WARNING, ROUTING_STORAGE_KEY, ATTRIBUTE_STORAGE_KEY, APP_COMMIT_SHA, APP_COMMIT_DIRTY, APP_BRANCH, APP_GIT_KEYS, own, DEPLOYMENTS, CI_SOURCES, AppGitContextImpl, AppGitContext, HANDOFF_ATTRIBUTE_SUFFIXES, AI_SDK_METADATA_PREFIX, DETACHED_MODE, SUBAGENT_AGENT_ROLE, HANDOFF_TERMINAL_CANCELLED, TOOL_EVENTS_SUFFIX, TOOL_EVENTS_ALLOW, OPERATION_ID_ATTRIBUTE, SUBAGENT_ABORT_OPERATION_ID, SUBAGENT_ABORT_SPAN_NAME, DEFAULT_DISPATCH_SPAN_NAME, HANDOFF_TERMINAL_PROPERTY_KEY, BAGGAGE_KEYS, TRACEPARENT_HEADER, BAGGAGE_HEADER, W3C_TRACE_ID, W3C_SPAN_ID, warnedNonConformantIds, HANDOFF_HEADER, LANGSMITH_TRACE_HEADER, LANGSMITH_METADATA_BAGGAGE_KEY, ConflictingCarrierError, UNRESOLVED_CARRIER_WARNING, UNRESOLVED_CARRIER_WARNED_KEY, MAX_QUOTED_ITEMS, DEFAULT_FLUSH_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, MAX_RETRY_DELAY_MS, RATE_LIMITED_LOG_INTERVAL_MS, rateLimitedLogLast, InFlightCutOff, sendPausedUntil, DELIVERED, DEFAULT_MAX_TEXT_FIELD_CHARS, TRUNCATION_MARKER, BOUNDED_CLONE_MAX_DEPTH, BOUNDED_CLONE_SLACK, currentDefaultMaxTextFieldChars, LOCAL_DEBUGGER_ENV_VAR, WORKSHOP_ENV_VAR, DEFAULT_LOCAL_WORKSHOP_URL, LOCAL_DEBUGGER_MIRROR_TIMEOUT_MS, PROJECT_ID_HEADER, PROJECT_ID_SLUG_PATTERN, PII_MARKERS, day, month, year, monthName, date, birthDate, mrn, contextualPiiRedactor, import_redact_pii, DEFAULT_PII_REDACTION_OPTIONS, redactor, CONTENT_KEY_SUFFIX, CONTENT_KEYS, NON_CONTENT_PREFIXES, ASSOCIATION_PROPERTY, SDK_ASSOCIATION_PROPERTIES, JSON_SIMPLE_ESCAPES, NO_SPAN_PII_FIELDS, MASK_FAILED, EVENT_FIELDS, SDK_PROPERTY_KEYS, KINDS, DEFAULT_PII_FIELDS, PROTECTED_LOCATIONS, SIGNAL_PATH_ALIASES, PiiFieldRedactor, REMOTE_PII_LOOKUP_TIMEOUT_MS, REFRESH_AFTER_MS, RETRY_AFTER_MS, STATE_KEY2, LOCAL_TRACE_KEY, PLACEHOLDER_USER_IDS, WRITE_KEY_FUNCTION_TIMEOUT_MS, TIMED_OUT, HEADER_SAFE, ERROR_NAME, KNOWN_ERROR_CODES, RUNNING_KEY, WriteKeySource, MAX_DEFERRED_SENDS, POST_SHUTDOWN_TIMEOUT_MS, UNSAFE_MERGE_KEYS, FINISHED_EVENT_MEMORY, MANUAL_UPDATES, EventShipper, MODEL_USAGE_ATTRIBUTES, MODEL_PROVIDER_NAMES, KNOWN_MODEL_PROVIDERS, STRING_ALIASES, NUMBER_ALIASES, DEFAULT_SECRET_KEY_NAMES, URL_USERINFO, DEFAULT_SECRET_SET, DEFAULT_REDACT_ATTRIBUTE_KEYS, REDACT_JSON_ATTRIBUTE_KEYS, UNDELIVERED, PROMPT_TOOLS_ATTRIBUTE, JSON_SCHEMA_KEYS, NOT_A_GEMINI_GROUP_KEYS;
2511
+ var init_chunk_OPHDM4MC = __esm({
2512
+ "../core/dist/chunk-OPHDM4MC.js"() {
2379
2513
  "use strict";
2380
2514
  init_chunk_ZCB62SIO();
2381
2515
  require_NameRedactor = __commonJS({
@@ -2858,11 +2992,11 @@ var init_chunk_5OUEKTIO = __esm({
2858
2992
  }
2859
2993
  /** Existing replay branch reporting stays separate from opt-in event properties. */
2860
2994
  snapshotForReplay() {
2861
- const snapshot = this.snapshot();
2862
- if (this.replayBranch && !own(snapshot, APP_BRANCH) && snapshot[APP_COMMIT_SHA] === this.defaults[APP_COMMIT_SHA]) {
2863
- return Object.freeze({ ...snapshot, [APP_BRANCH]: this.replayBranch });
2995
+ const snapshot2 = this.snapshot();
2996
+ if (this.replayBranch && !own(snapshot2, APP_BRANCH) && snapshot2[APP_COMMIT_SHA] === this.defaults[APP_COMMIT_SHA]) {
2997
+ return Object.freeze({ ...snapshot2, [APP_BRANCH]: this.replayBranch });
2864
2998
  }
2865
- return snapshot;
2999
+ return snapshot2;
2866
3000
  }
2867
3001
  /** Merge a frozen span snapshot without losing client-authored provenance. */
2868
3002
  mergeSnapshot(base, properties, explicitKeys = this.explicitKeys) {
@@ -3150,6 +3284,63 @@ var init_chunk_5OUEKTIO = __esm({
3150
3284
  STATE_KEY2 = /* @__PURE__ */ Symbol.for("raindrop.remotePiiConfig");
3151
3285
  LOCAL_TRACE_KEY = /* @__PURE__ */ Symbol.for("raindrop.localTracePiiRedaction");
3152
3286
  PLACEHOLDER_USER_IDS = /* @__PURE__ */ new Set(["null", "undefined"]);
3287
+ WRITE_KEY_FUNCTION_TIMEOUT_MS = 1e4;
3288
+ TIMED_OUT = /* @__PURE__ */ Symbol("timed out");
3289
+ HEADER_SAFE = /^[\x21-\x7e]+$/;
3290
+ ERROR_NAME = /^(?:[A-Z][A-Za-z]{0,39})?Error$/;
3291
+ KNOWN_ERROR_CODES = /* @__PURE__ */ new Set([
3292
+ "ambiguous_resource",
3293
+ "forbidden",
3294
+ "invalid_resource",
3295
+ "invalid_role",
3296
+ "not_found",
3297
+ "request_failed",
3298
+ "resource_oidc_not_enabled",
3299
+ "ECONNREFUSED",
3300
+ "ECONNRESET",
3301
+ "ENOTFOUND",
3302
+ "ETIMEDOUT",
3303
+ "EAI_AGAIN"
3304
+ ]);
3305
+ RUNNING_KEY = /* @__PURE__ */ Symbol.for("raindrop.writeKeyFunctionCalls.v1");
3306
+ WriteKeySource = class {
3307
+ constructor(option, prefix) {
3308
+ this.prefix = prefix;
3309
+ if (typeof option === "function") this.fn = option;
3310
+ else if (typeof option === "string") this.staticKey = option.trim() || void 0;
3311
+ }
3312
+ /** Whether there is a key to send with. */
3313
+ get configured() {
3314
+ return this.fn !== void 0 || this.staticKey !== void 0;
3315
+ }
3316
+ /** The option as the org PII lookup (`piiRedaction`) takes it. */
3317
+ get lookupKey() {
3318
+ var _a5;
3319
+ return (_a5 = this.fn) != null ? _a5 : this.staticKey;
3320
+ }
3321
+ /**
3322
+ * The key for one send. A failed call logs one rate-limited warning that
3323
+ * names the error but never its message. Never rejects.
3324
+ */
3325
+ async resolve(deadlineAt, cutOff) {
3326
+ if (this.staticKey !== void 0) return { status: "key", key: this.staticKey };
3327
+ const fn = this.fn;
3328
+ if (!fn) return { status: "failed" };
3329
+ if ((cutOff == null ? void 0 : cutOff.aborted) || deadlineAt !== void 0 && deadlineAt <= Date.now()) {
3330
+ return { status: "deferred" };
3331
+ }
3332
+ const result = await waitUntil(callShared(fn), deadlineAt, cutOff);
3333
+ if (result === void 0) return { status: "deferred" };
3334
+ if ("key" in result) return { status: "key", key: result.key };
3335
+ rateLimitedLog(
3336
+ `${this.prefix}.write_key_function_failed`,
3337
+ () => console.warn(
3338
+ `${this.prefix} writeKey function ${result.failure}; dropping this send (the next send calls it again)`
3339
+ )
3340
+ );
3341
+ return { status: "failed" };
3342
+ }
3343
+ };
3153
3344
  MAX_DEFERRED_SENDS = 1e3;
3154
3345
  POST_SHUTDOWN_TIMEOUT_MS = 5e3;
3155
3346
  UNSAFE_MERGE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
@@ -3168,22 +3359,23 @@ var init_chunk_5OUEKTIO = __esm({
3168
3359
  this.finishedEventIds = /* @__PURE__ */ new Set();
3169
3360
  this.sendChains = /* @__PURE__ */ new Map();
3170
3361
  this.deferredSends = /* @__PURE__ */ new Set();
3362
+ this.keyDrops = 0;
3171
3363
  this.hasShutdown = false;
3172
- var _a5, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3364
+ var _a5, _b, _c, _d, _e, _f, _g, _h, _i;
3173
3365
  this.appGitContext = (_a5 = opts.appGitContext) != null ? _a5 : createAppGitContext(opts.appGit);
3174
3366
  this.ownsAppGitContext = opts.appGitContext === void 0;
3175
- this.writeKey = (_b = opts.writeKey) == null ? void 0 : _b.trim();
3176
- this.baseUrl = (_c = formatEndpoint(opts.endpoint)) != null ? _c : "https://api.raindrop.ai/v1/";
3367
+ this.baseUrl = (_b = formatEndpoint(opts.endpoint)) != null ? _b : "https://api.raindrop.ai/v1/";
3177
3368
  this.enabled = opts.enabled !== false;
3178
3369
  this.debug = opts.debug;
3179
- this.partialFlushMs = (_d = opts.partialFlushMs) != null ? _d : 1e3;
3180
- this.sdkName = (_e = opts.sdkName) != null ? _e : "core";
3370
+ this.partialFlushMs = (_c = opts.partialFlushMs) != null ? _c : 1e3;
3371
+ this.sdkName = (_d = opts.sdkName) != null ? _d : "core";
3181
3372
  this.prefix = `[raindrop-ai/${this.sdkName}]`;
3182
- this.defaultEventName = (_f = opts.defaultEventName) != null ? _f : "ai_generation";
3373
+ this.writeKey = new WriteKeySource(opts.writeKey, this.prefix);
3374
+ this.defaultEventName = (_e = opts.defaultEventName) != null ? _e : "ai_generation";
3183
3375
  this.maxTextFieldCharsOpt = opts.maxTextFieldChars;
3184
3376
  this.flushTimeoutMs = resolveFlushTimeoutMs(opts.flushTimeoutMs);
3185
- this.localDebuggerUrl = (_g = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl)) != null ? _g : void 0;
3186
- this.localDebuggerFollowRedirects = (_h = opts.localDebuggerFollowRedirects) != null ? _h : true;
3377
+ this.localDebuggerUrl = (_f = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl)) != null ? _f : void 0;
3378
+ this.localDebuggerFollowRedirects = (_g = opts.localDebuggerFollowRedirects) != null ? _g : true;
3187
3379
  if (this.debug && this.localDebuggerUrl) {
3188
3380
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
3189
3381
  }
@@ -3212,8 +3404,8 @@ var init_chunk_5OUEKTIO = __esm({
3212
3404
  const runtime = detectRuntime();
3213
3405
  this.context = {
3214
3406
  library: {
3215
- name: (_i = opts.libraryName) != null ? _i : "@raindrop-ai/core",
3216
- version: (_j = opts.libraryVersion) != null ? _j : "0.0.0"
3407
+ name: (_h = opts.libraryName) != null ? _h : "@raindrop-ai/core",
3408
+ version: (_i = opts.libraryVersion) != null ? _i : "0.0.0"
3217
3409
  },
3218
3410
  metadata: {
3219
3411
  jsRuntime: runtime,
@@ -3227,11 +3419,9 @@ var init_chunk_5OUEKTIO = __esm({
3227
3419
  isDebugEnabled() {
3228
3420
  return this.debug;
3229
3421
  }
3230
- authHeaders() {
3231
- return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
3232
- }
3233
- requestHeaders() {
3234
- return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
3422
+ /** POST to ingest with the write key (resolved for this send when it is a function). */
3423
+ post(url2, body, opts) {
3424
+ return sendJsonWithWriteKey(url2, body, this.writeKey, projectIdHeaders(this.projectId), opts);
3235
3425
  }
3236
3426
  /**
3237
3427
  * Retry/timeout options for one POST. While `shutdown()` drains, sends retry
@@ -3501,7 +3691,8 @@ var init_chunk_5OUEKTIO = __esm({
3501
3691
  const ids = [...this.buffers.keys()];
3502
3692
  const fates = await Promise.all([
3503
3693
  ...ids.map((id) => this.flushOne(id, deadlineAt)),
3504
- ...deferred.map((entry) => entry.send(deadlineAt))
3694
+ // Counted here, so a key function failure in these is not counted again.
3695
+ ...deferred.map((entry) => entry.send(deadlineAt, true))
3505
3696
  ]);
3506
3697
  const background = [...this.background];
3507
3698
  if (background.length > 0) {
@@ -3515,6 +3706,7 @@ var init_chunk_5OUEKTIO = __esm({
3515
3706
  this.cutOff,
3516
3707
  (p) => this.inFlight.has(p)
3517
3708
  );
3709
+ for (; this.keyDrops > 0; this.keyDrops -= 1) fates.push("dropped");
3518
3710
  const unresolved = background.filter((op) => this.background.has(op)).length;
3519
3711
  return summarize2(
3520
3712
  fates.filter((fate) => fate !== void 0),
@@ -3570,18 +3762,18 @@ var init_chunk_5OUEKTIO = __esm({
3570
3762
  }
3571
3763
  }
3572
3764
  ];
3573
- const known = piiRedactionNow(this.redactPii, this.remotePiiConfig, this.baseUrl, this.writeKey);
3765
+ const known = piiRedactionNow(this.redactPii, this.remotePiiConfig, this.baseUrl, this.writeKey.lookupKey);
3574
3766
  if (known !== void 0) {
3575
3767
  const body = items.map((item) => this.outgoing("signal", item, known));
3576
- if (!this.writeKey) return;
3768
+ if (!this.writeKey.configured) return;
3577
3769
  await this.sendDirect("signal", `${this.baseUrl}signals/track`, body);
3578
3770
  return;
3579
3771
  }
3580
- const snapshot = items.map(snapshotPayload);
3772
+ const snapshot2 = items.map(snapshotPayload);
3581
3773
  await this.tracked(async () => {
3582
3774
  const redact = await this.shouldRedactPii();
3583
- const body = snapshot.map((item) => this.outgoing("signal", item, redact));
3584
- if (!this.writeKey) return;
3775
+ const body = snapshot2.map((item) => this.outgoing("signal", item, redact));
3776
+ if (!this.writeKey.configured) return;
3585
3777
  await this.sendDirect("signal", `${this.baseUrl}signals/track`, body, void 0, false);
3586
3778
  });
3587
3779
  }
@@ -3605,33 +3797,35 @@ var init_chunk_5OUEKTIO = __esm({
3605
3797
  traits: (_a5 = user.traits) != null ? _a5 : {}
3606
3798
  };
3607
3799
  });
3608
- if (!this.writeKey) return;
3800
+ if (!this.writeKey.configured) return;
3609
3801
  if (rows.length === 0) return;
3610
- const known = piiRedactionNow(this.redactPii, this.remotePiiConfig, this.baseUrl, this.writeKey);
3802
+ const known = piiRedactionNow(this.redactPii, this.remotePiiConfig, this.baseUrl, this.writeKey.lookupKey);
3611
3803
  if (known !== void 0) {
3612
3804
  const body = rows.map((user) => this.outgoing("identify", user, known));
3613
3805
  await this.sendDirect("identify", `${this.baseUrl}users/identify`, body);
3614
3806
  return;
3615
3807
  }
3616
- const snapshot = rows.map(snapshotPayload);
3808
+ const snapshot2 = rows.map(snapshotPayload);
3617
3809
  await this.tracked(async () => {
3618
3810
  const redact = await this.shouldRedactPii();
3619
- const body = snapshot.map((user) => this.outgoing("identify", user, redact));
3811
+ const body = snapshot2.map((user) => this.outgoing("identify", user, redact));
3620
3812
  await this.sendDirect("identify", `${this.baseUrl}users/identify`, body, void 0, false);
3621
3813
  });
3622
3814
  }
3623
3815
  /**
3624
3816
  * Send a signal or identify body. Tracked so `flush()` waits for it, unless
3625
3817
  * the caller already tracks it (`track: false`). A send a flush deadline
3626
- * deferred is kept and retried later (outside shutdown).
3818
+ * deferred is kept and retried later (outside shutdown). `counted`: the
3819
+ * caller counts the returned fate (a flush draining deferred sends).
3627
3820
  */
3628
- async sendDirect(kind, url2, body, deadlineAt, track = true) {
3821
+ async sendDirect(kind, url2, body, deadlineAt, track = true, counted = false) {
3629
3822
  const opts = this.requestOpts(deadlineAt);
3630
3823
  if (!opts) {
3631
3824
  this.warnShutdownDrop(kind);
3632
3825
  return "dropped";
3633
3826
  }
3634
- const sending = sendJson(url2, body, this.requestHeaders(), opts);
3827
+ const payload = this.writeKey.fn ? snapshotPayload(body) : body;
3828
+ const sending = this.post(url2, payload, opts);
3635
3829
  const tracked = sending.then(() => void 0);
3636
3830
  if (track) this.inFlight.add(tracked);
3637
3831
  let outcome;
@@ -3643,11 +3837,12 @@ var init_chunk_5OUEKTIO = __esm({
3643
3837
  const fate = fateOf(outcome, this.shuttingDown());
3644
3838
  if (fate === "queued") {
3645
3839
  this.deferSend(
3646
- (later) => this.sendDirect(kind, url2, body, later),
3840
+ (later, laterCounted) => this.sendDirect(kind, url2, payload, later, true, laterCounted),
3647
3841
  outcome.status === "deferred" ? outcome.retryAtMs : void 0
3648
3842
  );
3649
3843
  } else if (fate === "dropped") {
3650
3844
  this.warnSendDropped(kind, outcome);
3845
+ if (!counted && outcome.status === "failed" && outcome.reported) this.keyDrops += 1;
3651
3846
  }
3652
3847
  return fate;
3653
3848
  }
@@ -3673,6 +3868,7 @@ var init_chunk_5OUEKTIO = __esm({
3673
3868
  warnSendDropped(what, outcome) {
3674
3869
  var _a5, _b;
3675
3870
  if (outcome.status === "delivered" || outcome.status === "rejected") return;
3871
+ if (outcome.status === "failed" && outcome.reported) return;
3676
3872
  const reason = outcome.status === "cut_off" ? "cut off at the flush deadline (not resent: it may have reached ingest)" : outcome.status === "deferred" ? "not sent before the shutdown deadline" : (_b = (_a5 = outcome.error) == null ? void 0 : _a5.message) != null ? _b : outcome.status;
3677
3873
  rateLimitedLog(
3678
3874
  `${this.prefix}.send_${what}_dropped`,
@@ -3695,7 +3891,7 @@ var init_chunk_5OUEKTIO = __esm({
3695
3891
  this.redactPii,
3696
3892
  this.remotePiiConfig,
3697
3893
  this.baseUrl,
3698
- this.writeKey,
3894
+ this.writeKey.lookupKey,
3699
3895
  deadlineAt != null ? deadlineAt : this.shutdownDeadlineAt
3700
3896
  );
3701
3897
  }
@@ -3835,17 +4031,17 @@ var init_chunk_5OUEKTIO = __esm({
3835
4031
  attachments: accumulated.attachments,
3836
4032
  is_pending: isPending
3837
4033
  };
3838
- const known = piiRedactionNow(this.redactPii, this.remotePiiConfig, this.baseUrl, this.writeKey);
4034
+ const known = piiRedactionNow(this.redactPii, this.remotePiiConfig, this.baseUrl, this.writeKey.lookupKey);
3839
4035
  if (known !== void 0) {
3840
4036
  const payload = this.outgoing("event", unredacted, known);
3841
4037
  return this.shipPartial(eventId, accumulated, payload, { eventName, userId, convoId, isPending }, deadlineAt, true);
3842
4038
  }
3843
- const snapshot = snapshotPayload(unredacted);
4039
+ const snapshot2 = snapshotPayload(unredacted);
3844
4040
  const running = this.shouldRedactPii(deadlineAt).then(
3845
4041
  (redact) => this.shipPartial(
3846
4042
  eventId,
3847
4043
  accumulated,
3848
- this.outgoing("event", snapshot, redact),
4044
+ this.outgoing("event", snapshot2, redact),
3849
4045
  { eventName, userId, convoId, isPending },
3850
4046
  deadlineAt,
3851
4047
  false
@@ -3905,11 +4101,12 @@ var init_chunk_5OUEKTIO = __esm({
3905
4101
  const mirror = this.localDebuggerUrl ? mirrorPartialEventToLocalDebugger(payload, {
3906
4102
  baseUrl: this.localDebuggerUrl,
3907
4103
  followRedirects: this.localDebuggerFollowRedirects,
3908
- writeKey: this.writeKey,
4104
+ // A key function's tokens are for ingest; the local mirror needs none.
4105
+ writeKey: this.writeKey.staticKey,
3909
4106
  debug: this.debug,
3910
4107
  sdkName: this.sdkName
3911
4108
  }) : void 0;
3912
- if (!this.writeKey) {
4109
+ if (!this.writeKey.configured) {
3913
4110
  if (!isPending) this.sticky.delete(eventId);
3914
4111
  if (mirror) await mirror;
3915
4112
  return void 0;
@@ -3921,7 +4118,7 @@ var init_chunk_5OUEKTIO = __esm({
3921
4118
  if (mirror) await mirror;
3922
4119
  return "dropped";
3923
4120
  }
3924
- const sending = sendJson(url2, payload, this.requestHeaders(), opts);
4121
+ const sending = this.post(url2, payload, opts);
3925
4122
  const combined = Promise.all([mirror, sending.then(() => void 0)]).then(() => void 0);
3926
4123
  if (track) this.inFlight.add(combined);
3927
4124
  let outcome;
@@ -4099,9 +4296,8 @@ function createAppGitContext2(options, runtime = {}) {
4099
4296
  return new AppGitContext(options, { ...runtime, resolveLocal });
4100
4297
  }
4101
4298
  function hasDestination(options) {
4102
- var _a5;
4103
4299
  if (options.enabled === false) return false;
4104
- return Boolean(((_a5 = options.writeKey) == null ? void 0 : _a5.trim()) || resolveLocalDebuggerBaseUrl(options.localDebuggerUrl));
4300
+ return hasWriteKey(options.writeKey) || Boolean(resolveLocalDebuggerBaseUrl(options.localDebuggerUrl));
4105
4301
  }
4106
4302
  function findOtelContextManager() {
4107
4303
  var _a5;
@@ -4128,8 +4324,8 @@ var import_async_hooks, import_child_process, import_path, resolveLocal, EventSh
4128
4324
  var init_index_node = __esm({
4129
4325
  "../core/dist/index.node.js"() {
4130
4326
  "use strict";
4131
- init_chunk_5OUEKTIO();
4132
- init_chunk_5OUEKTIO();
4327
+ init_chunk_OPHDM4MC();
4328
+ init_chunk_OPHDM4MC();
4133
4329
  init_chunk_ZCB62SIO();
4134
4330
  import_async_hooks = require("async_hooks");
4135
4331
  import_child_process = require("child_process");
@@ -26437,7 +26633,7 @@ var SignalEventSchema = external_exports.object({
26437
26633
  // package.json
26438
26634
  var package_default = {
26439
26635
  name: "raindrop-ai",
26440
- version: "3.0.0",
26636
+ version: "3.0.1",
26441
26637
  main: "dist/index.js",
26442
26638
  module: "dist/index.mjs",
26443
26639
  types: "dist/index.d.ts",
@@ -31052,13 +31248,13 @@ var WireEvalRowTracePairReadSchema = import_v46.z.discriminatedUnion("state", [
31052
31248
  var replayGitSnapshots = /* @__PURE__ */ new WeakMap();
31053
31249
  var replayPropertySnapshots = /* @__PURE__ */ new WeakMap();
31054
31250
  var replayOverrideSnapshots = /* @__PURE__ */ new WeakSet();
31055
- function withReplayGit(snapshot, run) {
31251
+ function withReplayGit(snapshot2, run) {
31056
31252
  var _a5;
31057
31253
  return withRoutingContext(
31058
31254
  {
31059
31255
  ...currentRoutingBinding(),
31060
- appGit: (_a5 = replayPropertySnapshots.get(snapshot)) != null ? _a5 : snapshot,
31061
- appGitSource: replayOverrideSnapshots.has(snapshot) ? "replay-override" : void 0
31256
+ appGit: (_a5 = replayPropertySnapshots.get(snapshot2)) != null ? _a5 : snapshot2,
31257
+ appGitSource: replayOverrideSnapshots.has(snapshot2) ? "replay-override" : void 0
31062
31258
  },
31063
31259
  run
31064
31260
  );
@@ -31068,24 +31264,24 @@ function captureReplayGit(client, options) {
31068
31264
  try {
31069
31265
  if (options === void 0 && client.getAppGitSnapshot) {
31070
31266
  const properties = Object.freeze({ ...client.getAppGitSnapshot() });
31071
- const snapshot2 = Object.freeze({ ...(_b = (_a5 = client.getReplayAppGitSnapshot) == null ? void 0 : _a5.call(client)) != null ? _b : properties });
31072
- replayPropertySnapshots.set(snapshot2, properties);
31073
- return snapshot2;
31267
+ const snapshot3 = Object.freeze({ ...(_b = (_a5 = client.getReplayAppGitSnapshot) == null ? void 0 : _a5.call(client)) != null ? _b : properties });
31268
+ replayPropertySnapshots.set(snapshot3, properties);
31269
+ return snapshot3;
31074
31270
  }
31075
31271
  const resolver = createAppGitContext2(options, { allowLocalGit: false });
31076
- const snapshot = resolver.snapshot();
31272
+ const snapshot2 = resolver.snapshot();
31077
31273
  resolver.dispose();
31078
- if (options && typeof options === "object") replayOverrideSnapshots.add(snapshot);
31079
- return snapshot;
31274
+ if (options && typeof options === "object") replayOverrideSnapshots.add(snapshot2);
31275
+ return snapshot2;
31080
31276
  } catch (e) {
31081
31277
  return {};
31082
31278
  }
31083
31279
  }
31084
- function replayGitFields(snapshot) {
31085
- const rawSha = snapshot[APP_COMMIT_SHA];
31280
+ function replayGitFields(snapshot2) {
31281
+ const rawSha = snapshot2[APP_COMMIT_SHA];
31086
31282
  const sha = typeof rawSha === "string" && validAppCommitSha(rawSha) ? rawSha.trim() : void 0;
31087
- const dirty = snapshot[APP_COMMIT_DIRTY];
31088
- const rawBranch = snapshot[APP_BRANCH];
31283
+ const dirty = snapshot2[APP_COMMIT_DIRTY];
31284
+ const rawBranch = snapshot2[APP_BRANCH];
31089
31285
  const branch = typeof rawBranch === "string" && rawBranch.length <= 1024 ? rawBranch.trim() : "";
31090
31286
  return {
31091
31287
  commit_sha: sha != null ? sha : null,
@@ -31390,7 +31586,7 @@ async function runReplayRows(client, handle, options) {
31390
31586
  );
31391
31587
  results.set(row.id, { value: result });
31392
31588
  } catch (cause) {
31393
- const error62 = describeError(cause);
31589
+ const error62 = describeError2(cause);
31394
31590
  await report({
31395
31591
  type: "row_missing",
31396
31592
  row_id: row.id,
@@ -31688,7 +31884,7 @@ var LocalEvalReplaySessionImpl = class {
31688
31884
  )
31689
31885
  );
31690
31886
  } catch (cause) {
31691
- const error62 = describeError(cause);
31887
+ const error62 = describeError2(cause);
31692
31888
  await reportReplay(this.client, this.queryUrl, this.replayId, {
31693
31889
  type: "row_missing",
31694
31890
  row_id: row.id,
@@ -31739,7 +31935,7 @@ var LocalEvalReplaySessionImpl = class {
31739
31935
  throw new Error(`Raindrop replay ${this.replayId} omitted trace pair ${row.id}`);
31740
31936
  pair = captured;
31741
31937
  } catch (cause) {
31742
- const error62 = describeError(cause);
31938
+ const error62 = describeError2(cause);
31743
31939
  await reportReplay(this.client, this.queryUrl, this.replayId, {
31744
31940
  type: "row_missing",
31745
31941
  row_id: row.id,
@@ -31792,7 +31988,7 @@ var LocalEvalReplaySessionImpl = class {
31792
31988
  });
31793
31989
  } catch (cause) {
31794
31990
  throw new Error(
31795
- `Raindrop local evaluator ${parent.evaluator.slug} could not record attempt at ${parent.url}: ${describeError(cause)}`
31991
+ `Raindrop local evaluator ${parent.evaluator.slug} could not record attempt at ${parent.url}: ${describeError2(cause)}`
31796
31992
  );
31797
31993
  }
31798
31994
  const data = receipt.data;
@@ -32399,8 +32595,8 @@ async function waitForFailedTraceAssociation(input2) {
32399
32595
  }
32400
32596
  }
32401
32597
  function failedTraceRetentionError(taskCause, retentionCause, rowId) {
32402
- const taskError = taskCause instanceof Error ? taskCause : new Error(describeError(taskCause));
32403
- const retentionError = retentionCause instanceof Error ? retentionCause : new Error(describeError(retentionCause));
32598
+ const taskError = taskCause instanceof Error ? taskCause : new Error(describeError2(taskCause));
32599
+ const retentionError = retentionCause instanceof Error ? retentionCause : new Error(describeError2(retentionCause));
32404
32600
  return new AggregateError(
32405
32601
  [taskError, retentionError],
32406
32602
  `Raindrop replay task ${rowId} failed and its trace could not be retained`,
@@ -32473,7 +32669,7 @@ function normalizeEvaluators(evaluators) {
32473
32669
  return normalized;
32474
32670
  }
32475
32671
  function localEvaluatorError(cause) {
32476
- const message = describeError(cause).trim();
32672
+ const message = describeError2(cause).trim();
32477
32673
  return (message === "" ? "Local evaluator failed" : message).slice(0, 600);
32478
32674
  }
32479
32675
  function validateWait(name, value, allowZero) {
@@ -32482,7 +32678,7 @@ function validateWait(name, value, allowZero) {
32482
32678
  throw new Error(`Raindrop replay ${name} must be ${allowZero ? "non-negative" : "positive"}`);
32483
32679
  }
32484
32680
  }
32485
- function describeError(cause) {
32681
+ function describeError2(cause) {
32486
32682
  if (cause instanceof Error) {
32487
32683
  return cause.message.trim() === "" ? cause.name : `${cause.name}: ${cause.message}`;
32488
32684
  }
@@ -34777,8 +34973,8 @@ var Raindrop = class {
34777
34973
  const deadlineAt = (_a5 = this.shutdownDeadlineAt) != null ? _a5 : Date.now();
34778
34974
  const remainingMs = () => Math.max(0, deadlineAt - Date.now());
34779
34975
  const partialsShutdown = this.eventShipper.shutdown();
34780
- const TIMED_OUT = { ...DELIVERED, delivered: false, timedOut: true, inFlight: 1 };
34781
- let tracingResult = TIMED_OUT;
34976
+ const TIMED_OUT2 = { ...DELIVERED, delivered: false, timedOut: true, inFlight: 1 };
34977
+ let tracingResult = TIMED_OUT2;
34782
34978
  const tracing2 = raceWithTimeout(
34783
34979
  this._tracing.close().then((r) => {
34784
34980
  tracingResult = r;
@@ -34786,7 +34982,7 @@ var Raindrop = class {
34786
34982
  remainingMs()
34787
34983
  ).then((settled) => {
34788
34984
  if (!settled) {
34789
- tracingResult = TIMED_OUT;
34985
+ tracingResult = TIMED_OUT2;
34790
34986
  this.warnShutdownDrop("in-flight trace flush");
34791
34987
  }
34792
34988
  });
@@ -34809,7 +35005,7 @@ var Raindrop = class {
34809
35005
  if (stillRunning > 0) this.warnShutdownDrop(`${stillRunning} in-flight batch(es)`);
34810
35006
  return summarize2(fates, stillRunning, !settled);
34811
35007
  })();
34812
- let partialsResult = TIMED_OUT;
35008
+ let partialsResult = TIMED_OUT2;
34813
35009
  const partials = raceWithTimeout(
34814
35010
  partialsShutdown.then((r) => {
34815
35011
  partialsResult = r;
@@ -34817,7 +35013,7 @@ var Raindrop = class {
34817
35013
  remainingMs()
34818
35014
  ).then((settled) => {
34819
35015
  if (!settled) {
34820
- partialsResult = TIMED_OUT;
35016
+ partialsResult = TIMED_OUT2;
34821
35017
  this.warnShutdownDrop("partial event request(s)");
34822
35018
  }
34823
35019
  });