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/{chunk-CSH7U5JZ.mjs → chunk-HKOAIPQF.mjs} +246 -50
- package/dist/{chunk-BU322D7Q.mjs → chunk-Q2I2277O.mjs} +2 -2
- package/dist/{chunk-24GTHPYP.mjs → chunk-RSUQ3BU2.mjs} +2 -2
- package/dist/{chunk-XAV5H3AL.mjs → chunk-XN3N4TAL.mjs} +3 -3
- package/dist/evals/cli.js +416 -88
- package/dist/evals/cli.mjs +143 -9
- package/dist/index.js +278 -82
- package/dist/index.mjs +4 -4
- package/dist/{portable-runtime-G27RYK6P.mjs → portable-runtime-HVIGFQHE.mjs} +2 -2
- package/dist/tracing/index.js +11 -9
- package/dist/tracing/index.mjs +2 -2
- package/package.json +2 -2
package/dist/evals/cli.js
CHANGED
|
@@ -141,7 +141,7 @@ var init_chunk_ZCB62SIO = __esm({
|
|
|
141
141
|
}
|
|
142
142
|
});
|
|
143
143
|
|
|
144
|
-
// ../core/dist/chunk-
|
|
144
|
+
// ../core/dist/chunk-OPHDM4MC.js
|
|
145
145
|
function state() {
|
|
146
146
|
const holder = globalThis;
|
|
147
147
|
let current = holder[STATE_KEY];
|
|
@@ -277,14 +277,14 @@ function attributeStorage() {
|
|
|
277
277
|
return storage2;
|
|
278
278
|
}
|
|
279
279
|
function makeAttributeFrame(attributes, owner) {
|
|
280
|
-
const
|
|
280
|
+
const snapshot2 = { ...attributes };
|
|
281
281
|
const WeakRefCtor = owner !== void 0 ? getWeakRefCtor() : void 0;
|
|
282
282
|
const ref = WeakRefCtor && owner !== void 0 ? new WeakRefCtor(owner) : void 0;
|
|
283
283
|
const owned = /* @__PURE__ */ new WeakSet();
|
|
284
284
|
let dead = false;
|
|
285
285
|
let sawError = false;
|
|
286
286
|
return {
|
|
287
|
-
attributes:
|
|
287
|
+
attributes: snapshot2,
|
|
288
288
|
sawErrorSpan: () => sawError,
|
|
289
289
|
ownsSpan: (span) => owned.has(span),
|
|
290
290
|
claimSpan(span) {
|
|
@@ -429,24 +429,24 @@ function detectedSource(env, table, detectBranch) {
|
|
|
429
429
|
function createAppGitContext(options, runtime = {}) {
|
|
430
430
|
return new AppGitContext(options, runtime);
|
|
431
431
|
}
|
|
432
|
-
function withAppGitProperties(properties,
|
|
432
|
+
function withAppGitProperties(properties, snapshot2) {
|
|
433
433
|
try {
|
|
434
434
|
const merged = { ...properties };
|
|
435
435
|
for (const key of APP_GIT_KEYS)
|
|
436
|
-
if (!own(merged, key) && own(
|
|
436
|
+
if (!own(merged, key) && own(snapshot2, key)) merged[key] = snapshot2[key];
|
|
437
437
|
return merged;
|
|
438
438
|
} catch (e) {
|
|
439
439
|
return properties != null ? properties : {};
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
function withAppGitAttributes(attributes,
|
|
442
|
+
function withAppGitAttributes(attributes, snapshot2) {
|
|
443
443
|
try {
|
|
444
444
|
const present = new Set(attributes.flatMap((attr) => attr ? [attr.key] : []));
|
|
445
445
|
const added = [];
|
|
446
446
|
for (const key of APP_GIT_KEYS) {
|
|
447
447
|
if (present.has(key) || present.has(`ai.telemetry.metadata.${key}`) || present.has(`traceloop.association.properties.${key}`))
|
|
448
448
|
continue;
|
|
449
|
-
const value =
|
|
449
|
+
const value = snapshot2[key];
|
|
450
450
|
if (typeof value === "string") added.push({ key, value: { stringValue: value } });
|
|
451
451
|
else if (typeof value === "boolean") added.push({ key, value: { boolValue: value } });
|
|
452
452
|
}
|
|
@@ -972,7 +972,7 @@ async function sendJson(url2, body, headers, opts) {
|
|
|
972
972
|
if (typeof retryAfterMs === "number") error62.retryAfterMs = retryAfterMs;
|
|
973
973
|
noteSendPause(url2, resp.status, retryAfterMs);
|
|
974
974
|
error62.retryable = resp.status === 408 || resp.status === 429 || resp.status >= 500;
|
|
975
|
-
if (!error62.retryable) return { status: "rejected", error: error62 };
|
|
975
|
+
if (!error62.retryable) return { status: "rejected", error: error62, httpStatus: resp.status };
|
|
976
976
|
lastError = error62;
|
|
977
977
|
logAttemptFailure(opts, prefix, opName, attempt, error62);
|
|
978
978
|
continue;
|
|
@@ -2021,6 +2021,7 @@ function needsLookup(local, remote, writeKey) {
|
|
|
2021
2021
|
return local === void 0 && Boolean(remote) && Boolean(writeKey);
|
|
2022
2022
|
}
|
|
2023
2023
|
function piiRedactionNow(local, remote, endpoint, writeKey) {
|
|
2024
|
+
if (typeof writeKey === "function") return resolvePiiRedaction(local, remote, "unknown");
|
|
2024
2025
|
if (!needsLookup(local, remote, writeKey)) return local === true;
|
|
2025
2026
|
try {
|
|
2026
2027
|
const answer = remotePiiAnswerNow(endpoint, writeKey);
|
|
@@ -2030,6 +2031,7 @@ function piiRedactionNow(local, remote, endpoint, writeKey) {
|
|
|
2030
2031
|
}
|
|
2031
2032
|
}
|
|
2032
2033
|
async function piiRedaction(local, remote, endpoint, writeKey, deadlineAt) {
|
|
2034
|
+
if (typeof writeKey === "function") return resolvePiiRedaction(local, remote, "unknown");
|
|
2033
2035
|
if (!needsLookup(local, remote, writeKey)) return local === true;
|
|
2034
2036
|
try {
|
|
2035
2037
|
return resolvePiiRedaction(local, remote, await remotePiiAnswer(endpoint, writeKey, deadlineAt));
|
|
@@ -2067,6 +2069,138 @@ function isMissingUserId(value) {
|
|
|
2067
2069
|
const trimmed = value.trim();
|
|
2068
2070
|
return trimmed === "" || PLACEHOLDER_USER_IDS.has(trimmed);
|
|
2069
2071
|
}
|
|
2072
|
+
function hasWriteKey(writeKey) {
|
|
2073
|
+
if (typeof writeKey === "function") return true;
|
|
2074
|
+
return typeof writeKey === "string" && writeKey.trim().length > 0;
|
|
2075
|
+
}
|
|
2076
|
+
function describeError(error62) {
|
|
2077
|
+
try {
|
|
2078
|
+
if (typeof error62 !== "object" || error62 === null) return "a non-error value";
|
|
2079
|
+
const name = "name" in error62 ? error62.name : void 0;
|
|
2080
|
+
const code = "code" in error62 ? error62.code : void 0;
|
|
2081
|
+
const status = "status" in error62 ? error62.status : void 0;
|
|
2082
|
+
const labels = [
|
|
2083
|
+
typeof name === "string" && ERROR_NAME.test(name) ? name : "an error",
|
|
2084
|
+
typeof code === "string" && KNOWN_ERROR_CODES.has(code) ? code : void 0,
|
|
2085
|
+
typeof status === "number" && Number.isInteger(status) && status >= 100 && status <= 599 ? `(HTTP ${status})` : void 0
|
|
2086
|
+
].filter((label) => label !== void 0);
|
|
2087
|
+
return labels.join(" ");
|
|
2088
|
+
} catch (e) {
|
|
2089
|
+
return "an error";
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
async function callOnce(fn) {
|
|
2093
|
+
let timer;
|
|
2094
|
+
try {
|
|
2095
|
+
const value = await Promise.race([
|
|
2096
|
+
// SDK work, not the app's: keep the function's own requests out of host traces.
|
|
2097
|
+
Promise.resolve().then(() => runWithTracingSuppressed(fn)),
|
|
2098
|
+
// Unreferenced: the sends waiting on the call hold their own timers.
|
|
2099
|
+
new Promise((resolve3) => {
|
|
2100
|
+
var _a5;
|
|
2101
|
+
timer = setTimeout(() => resolve3(TIMED_OUT), WRITE_KEY_FUNCTION_TIMEOUT_MS);
|
|
2102
|
+
(_a5 = timer.unref) == null ? void 0 : _a5.call(timer);
|
|
2103
|
+
})
|
|
2104
|
+
]);
|
|
2105
|
+
if (value === TIMED_OUT) {
|
|
2106
|
+
return { failure: `did not return within ${WRITE_KEY_FUNCTION_TIMEOUT_MS} ms` };
|
|
2107
|
+
}
|
|
2108
|
+
if (typeof value !== "string") return { failure: "returned a value that is not a string" };
|
|
2109
|
+
const key = value.trim();
|
|
2110
|
+
if (!key) return { failure: "returned an empty key" };
|
|
2111
|
+
if (!HEADER_SAFE.test(key)) {
|
|
2112
|
+
return { failure: "returned a key with characters an HTTP header cannot carry" };
|
|
2113
|
+
}
|
|
2114
|
+
return { key };
|
|
2115
|
+
} catch (error62) {
|
|
2116
|
+
return { failure: `threw ${describeError(error62)}` };
|
|
2117
|
+
} finally {
|
|
2118
|
+
clearTimeout(timer);
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
function runningCalls() {
|
|
2122
|
+
var _a5;
|
|
2123
|
+
const holder = globalThis;
|
|
2124
|
+
(_a5 = holder[RUNNING_KEY]) != null ? _a5 : holder[RUNNING_KEY] = /* @__PURE__ */ new WeakMap();
|
|
2125
|
+
return holder[RUNNING_KEY];
|
|
2126
|
+
}
|
|
2127
|
+
function callShared(fn) {
|
|
2128
|
+
const running = runningCalls();
|
|
2129
|
+
const current = running.get(fn);
|
|
2130
|
+
if (current) return current;
|
|
2131
|
+
const call = callOnce(fn);
|
|
2132
|
+
running.set(fn, call);
|
|
2133
|
+
void call.then(() => {
|
|
2134
|
+
if (running.get(fn) === call) running.delete(fn);
|
|
2135
|
+
});
|
|
2136
|
+
return call;
|
|
2137
|
+
}
|
|
2138
|
+
function waitUntil(promise2, deadlineAt, cutOff) {
|
|
2139
|
+
const remaining = deadlineAt === void 0 ? Infinity : deadlineAt - Date.now();
|
|
2140
|
+
if (remaining <= 0 || (cutOff == null ? void 0 : cutOff.aborted)) return Promise.resolve(void 0);
|
|
2141
|
+
return new Promise((resolve3) => {
|
|
2142
|
+
let timer;
|
|
2143
|
+
const finish = (value) => {
|
|
2144
|
+
clearTimeout(timer);
|
|
2145
|
+
cutOff == null ? void 0 : cutOff.removeEventListener("abort", giveUp);
|
|
2146
|
+
resolve3(value);
|
|
2147
|
+
};
|
|
2148
|
+
const giveUp = () => finish(void 0);
|
|
2149
|
+
timer = setTimeout(giveUp, Math.min(remaining, WRITE_KEY_FUNCTION_TIMEOUT_MS + 1e3));
|
|
2150
|
+
cutOff == null ? void 0 : cutOff.addEventListener("abort", giveUp, { once: true });
|
|
2151
|
+
promise2.then(finish, giveUp);
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2154
|
+
function prefixFor2(opts) {
|
|
2155
|
+
return opts.sdkName ? `[raindrop-ai/${opts.sdkName}]` : "[raindrop-ai/core]";
|
|
2156
|
+
}
|
|
2157
|
+
function snapshot(body) {
|
|
2158
|
+
try {
|
|
2159
|
+
const json2 = JSON.stringify(body);
|
|
2160
|
+
return json2 === void 0 ? body : JSON.parse(json2);
|
|
2161
|
+
} catch (e) {
|
|
2162
|
+
return body;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
function sendJsonWithWriteKey(url2, body, writeKey, headers, opts) {
|
|
2166
|
+
if (!writeKey.fn) {
|
|
2167
|
+
const auth = writeKey.staticKey ? { Authorization: `Bearer ${writeKey.staticKey}` } : {};
|
|
2168
|
+
return sendJson(url2, body, { ...auth, ...headers }, opts);
|
|
2169
|
+
}
|
|
2170
|
+
return sendWithKeyFunction(url2, body, writeKey, headers, opts);
|
|
2171
|
+
}
|
|
2172
|
+
async function sendWithKeyFunction(url2, body, writeKey, headers, opts) {
|
|
2173
|
+
var _a5;
|
|
2174
|
+
const payload = snapshot(body);
|
|
2175
|
+
const budgetEndsAt = opts.deadlineAt === void 0 && opts.timeoutMs !== void 0 ? Date.now() + opts.timeoutMs : void 0;
|
|
2176
|
+
const waitUntilAt = (_a5 = opts.deadlineAt) != null ? _a5 : budgetEndsAt;
|
|
2177
|
+
const sendOpts = () => budgetEndsAt === void 0 ? opts : { ...opts, timeoutMs: Math.max(1, budgetEndsAt - Date.now()) };
|
|
2178
|
+
const first = await writeKey.resolve(waitUntilAt, opts.cutOff);
|
|
2179
|
+
if (first.status === "deferred") return { status: "deferred" };
|
|
2180
|
+
if (first.status === "failed") {
|
|
2181
|
+
return {
|
|
2182
|
+
status: "failed",
|
|
2183
|
+
error: new Error("writeKey function did not return a key"),
|
|
2184
|
+
reported: true
|
|
2185
|
+
};
|
|
2186
|
+
}
|
|
2187
|
+
const outcome = await sendJson(
|
|
2188
|
+
url2,
|
|
2189
|
+
payload,
|
|
2190
|
+
{ Authorization: `Bearer ${first.key}`, ...headers },
|
|
2191
|
+
sendOpts()
|
|
2192
|
+
);
|
|
2193
|
+
if (outcome.status !== "rejected" || outcome.httpStatus !== 401 || opts.maxAttempts <= 1) {
|
|
2194
|
+
return outcome;
|
|
2195
|
+
}
|
|
2196
|
+
const fresh = await writeKey.resolve(waitUntilAt, opts.cutOff);
|
|
2197
|
+
if (fresh.status === "deferred") return { status: "deferred" };
|
|
2198
|
+
if (fresh.status !== "key" || fresh.key === first.key) return outcome;
|
|
2199
|
+
if (opts.debug) {
|
|
2200
|
+
console.log(`${prefixFor2(opts)} HTTP 401; resending with a new key from the writeKey function`);
|
|
2201
|
+
}
|
|
2202
|
+
return sendJson(url2, payload, { Authorization: `Bearer ${fresh.key}`, ...headers }, sendOpts());
|
|
2203
|
+
}
|
|
2070
2204
|
function snapshotPayload(payload) {
|
|
2071
2205
|
try {
|
|
2072
2206
|
const json2 = JSON.stringify(payload);
|
|
@@ -2369,9 +2503,9 @@ function promptToolsFromTraceloopAttributes(attributes) {
|
|
|
2369
2503
|
}
|
|
2370
2504
|
return tools;
|
|
2371
2505
|
}
|
|
2372
|
-
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;
|
|
2373
|
-
var
|
|
2374
|
-
"../core/dist/chunk-
|
|
2506
|
+
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;
|
|
2507
|
+
var init_chunk_OPHDM4MC = __esm({
|
|
2508
|
+
"../core/dist/chunk-OPHDM4MC.js"() {
|
|
2375
2509
|
"use strict";
|
|
2376
2510
|
init_chunk_ZCB62SIO();
|
|
2377
2511
|
require_NameRedactor = __commonJS({
|
|
@@ -2854,11 +2988,11 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
2854
2988
|
}
|
|
2855
2989
|
/** Existing replay branch reporting stays separate from opt-in event properties. */
|
|
2856
2990
|
snapshotForReplay() {
|
|
2857
|
-
const
|
|
2858
|
-
if (this.replayBranch && !own(
|
|
2859
|
-
return Object.freeze({ ...
|
|
2991
|
+
const snapshot2 = this.snapshot();
|
|
2992
|
+
if (this.replayBranch && !own(snapshot2, APP_BRANCH) && snapshot2[APP_COMMIT_SHA] === this.defaults[APP_COMMIT_SHA]) {
|
|
2993
|
+
return Object.freeze({ ...snapshot2, [APP_BRANCH]: this.replayBranch });
|
|
2860
2994
|
}
|
|
2861
|
-
return
|
|
2995
|
+
return snapshot2;
|
|
2862
2996
|
}
|
|
2863
2997
|
/** Merge a frozen span snapshot without losing client-authored provenance. */
|
|
2864
2998
|
mergeSnapshot(base, properties, explicitKeys = this.explicitKeys) {
|
|
@@ -3146,6 +3280,63 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3146
3280
|
STATE_KEY2 = /* @__PURE__ */ Symbol.for("raindrop.remotePiiConfig");
|
|
3147
3281
|
LOCAL_TRACE_KEY = /* @__PURE__ */ Symbol.for("raindrop.localTracePiiRedaction");
|
|
3148
3282
|
PLACEHOLDER_USER_IDS = /* @__PURE__ */ new Set(["null", "undefined"]);
|
|
3283
|
+
WRITE_KEY_FUNCTION_TIMEOUT_MS = 1e4;
|
|
3284
|
+
TIMED_OUT = /* @__PURE__ */ Symbol("timed out");
|
|
3285
|
+
HEADER_SAFE = /^[\x21-\x7e]+$/;
|
|
3286
|
+
ERROR_NAME = /^(?:[A-Z][A-Za-z]{0,39})?Error$/;
|
|
3287
|
+
KNOWN_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
3288
|
+
"ambiguous_resource",
|
|
3289
|
+
"forbidden",
|
|
3290
|
+
"invalid_resource",
|
|
3291
|
+
"invalid_role",
|
|
3292
|
+
"not_found",
|
|
3293
|
+
"request_failed",
|
|
3294
|
+
"resource_oidc_not_enabled",
|
|
3295
|
+
"ECONNREFUSED",
|
|
3296
|
+
"ECONNRESET",
|
|
3297
|
+
"ENOTFOUND",
|
|
3298
|
+
"ETIMEDOUT",
|
|
3299
|
+
"EAI_AGAIN"
|
|
3300
|
+
]);
|
|
3301
|
+
RUNNING_KEY = /* @__PURE__ */ Symbol.for("raindrop.writeKeyFunctionCalls.v1");
|
|
3302
|
+
WriteKeySource = class {
|
|
3303
|
+
constructor(option, prefix) {
|
|
3304
|
+
this.prefix = prefix;
|
|
3305
|
+
if (typeof option === "function") this.fn = option;
|
|
3306
|
+
else if (typeof option === "string") this.staticKey = option.trim() || void 0;
|
|
3307
|
+
}
|
|
3308
|
+
/** Whether there is a key to send with. */
|
|
3309
|
+
get configured() {
|
|
3310
|
+
return this.fn !== void 0 || this.staticKey !== void 0;
|
|
3311
|
+
}
|
|
3312
|
+
/** The option as the org PII lookup (`piiRedaction`) takes it. */
|
|
3313
|
+
get lookupKey() {
|
|
3314
|
+
var _a5;
|
|
3315
|
+
return (_a5 = this.fn) != null ? _a5 : this.staticKey;
|
|
3316
|
+
}
|
|
3317
|
+
/**
|
|
3318
|
+
* The key for one send. A failed call logs one rate-limited warning that
|
|
3319
|
+
* names the error but never its message. Never rejects.
|
|
3320
|
+
*/
|
|
3321
|
+
async resolve(deadlineAt, cutOff) {
|
|
3322
|
+
if (this.staticKey !== void 0) return { status: "key", key: this.staticKey };
|
|
3323
|
+
const fn = this.fn;
|
|
3324
|
+
if (!fn) return { status: "failed" };
|
|
3325
|
+
if ((cutOff == null ? void 0 : cutOff.aborted) || deadlineAt !== void 0 && deadlineAt <= Date.now()) {
|
|
3326
|
+
return { status: "deferred" };
|
|
3327
|
+
}
|
|
3328
|
+
const result = await waitUntil(callShared(fn), deadlineAt, cutOff);
|
|
3329
|
+
if (result === void 0) return { status: "deferred" };
|
|
3330
|
+
if ("key" in result) return { status: "key", key: result.key };
|
|
3331
|
+
rateLimitedLog(
|
|
3332
|
+
`${this.prefix}.write_key_function_failed`,
|
|
3333
|
+
() => console.warn(
|
|
3334
|
+
`${this.prefix} writeKey function ${result.failure}; dropping this send (the next send calls it again)`
|
|
3335
|
+
)
|
|
3336
|
+
);
|
|
3337
|
+
return { status: "failed" };
|
|
3338
|
+
}
|
|
3339
|
+
};
|
|
3149
3340
|
MAX_DEFERRED_SENDS = 1e3;
|
|
3150
3341
|
POST_SHUTDOWN_TIMEOUT_MS = 5e3;
|
|
3151
3342
|
UNSAFE_MERGE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
@@ -3164,22 +3355,23 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3164
3355
|
this.finishedEventIds = /* @__PURE__ */ new Set();
|
|
3165
3356
|
this.sendChains = /* @__PURE__ */ new Map();
|
|
3166
3357
|
this.deferredSends = /* @__PURE__ */ new Set();
|
|
3358
|
+
this.keyDrops = 0;
|
|
3167
3359
|
this.hasShutdown = false;
|
|
3168
|
-
var _a5, _b, _c, _d, _e, _f, _g, _h, _i
|
|
3360
|
+
var _a5, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3169
3361
|
this.appGitContext = (_a5 = opts.appGitContext) != null ? _a5 : createAppGitContext(opts.appGit);
|
|
3170
3362
|
this.ownsAppGitContext = opts.appGitContext === void 0;
|
|
3171
|
-
this.
|
|
3172
|
-
this.baseUrl = (_c = formatEndpoint(opts.endpoint)) != null ? _c : "https://api.raindrop.ai/v1/";
|
|
3363
|
+
this.baseUrl = (_b = formatEndpoint(opts.endpoint)) != null ? _b : "https://api.raindrop.ai/v1/";
|
|
3173
3364
|
this.enabled = opts.enabled !== false;
|
|
3174
3365
|
this.debug = opts.debug;
|
|
3175
|
-
this.partialFlushMs = (
|
|
3176
|
-
this.sdkName = (
|
|
3366
|
+
this.partialFlushMs = (_c = opts.partialFlushMs) != null ? _c : 1e3;
|
|
3367
|
+
this.sdkName = (_d = opts.sdkName) != null ? _d : "core";
|
|
3177
3368
|
this.prefix = `[raindrop-ai/${this.sdkName}]`;
|
|
3178
|
-
this.
|
|
3369
|
+
this.writeKey = new WriteKeySource(opts.writeKey, this.prefix);
|
|
3370
|
+
this.defaultEventName = (_e = opts.defaultEventName) != null ? _e : "ai_generation";
|
|
3179
3371
|
this.maxTextFieldCharsOpt = opts.maxTextFieldChars;
|
|
3180
3372
|
this.flushTimeoutMs = resolveFlushTimeoutMs(opts.flushTimeoutMs);
|
|
3181
|
-
this.localDebuggerUrl = (
|
|
3182
|
-
this.localDebuggerFollowRedirects = (
|
|
3373
|
+
this.localDebuggerUrl = (_f = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl)) != null ? _f : void 0;
|
|
3374
|
+
this.localDebuggerFollowRedirects = (_g = opts.localDebuggerFollowRedirects) != null ? _g : true;
|
|
3183
3375
|
if (this.debug && this.localDebuggerUrl) {
|
|
3184
3376
|
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
3185
3377
|
}
|
|
@@ -3208,8 +3400,8 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3208
3400
|
const runtime = detectRuntime();
|
|
3209
3401
|
this.context = {
|
|
3210
3402
|
library: {
|
|
3211
|
-
name: (
|
|
3212
|
-
version: (
|
|
3403
|
+
name: (_h = opts.libraryName) != null ? _h : "@raindrop-ai/core",
|
|
3404
|
+
version: (_i = opts.libraryVersion) != null ? _i : "0.0.0"
|
|
3213
3405
|
},
|
|
3214
3406
|
metadata: {
|
|
3215
3407
|
jsRuntime: runtime,
|
|
@@ -3223,11 +3415,9 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3223
3415
|
isDebugEnabled() {
|
|
3224
3416
|
return this.debug;
|
|
3225
3417
|
}
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
requestHeaders() {
|
|
3230
|
-
return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
|
|
3418
|
+
/** POST to ingest with the write key (resolved for this send when it is a function). */
|
|
3419
|
+
post(url2, body, opts) {
|
|
3420
|
+
return sendJsonWithWriteKey(url2, body, this.writeKey, projectIdHeaders(this.projectId), opts);
|
|
3231
3421
|
}
|
|
3232
3422
|
/**
|
|
3233
3423
|
* Retry/timeout options for one POST. While `shutdown()` drains, sends retry
|
|
@@ -3497,7 +3687,8 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3497
3687
|
const ids = [...this.buffers.keys()];
|
|
3498
3688
|
const fates = await Promise.all([
|
|
3499
3689
|
...ids.map((id) => this.flushOne(id, deadlineAt)),
|
|
3500
|
-
|
|
3690
|
+
// Counted here, so a key function failure in these is not counted again.
|
|
3691
|
+
...deferred.map((entry) => entry.send(deadlineAt, true))
|
|
3501
3692
|
]);
|
|
3502
3693
|
const background = [...this.background];
|
|
3503
3694
|
if (background.length > 0) {
|
|
@@ -3511,6 +3702,7 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3511
3702
|
this.cutOff,
|
|
3512
3703
|
(p) => this.inFlight.has(p)
|
|
3513
3704
|
);
|
|
3705
|
+
for (; this.keyDrops > 0; this.keyDrops -= 1) fates.push("dropped");
|
|
3514
3706
|
const unresolved = background.filter((op) => this.background.has(op)).length;
|
|
3515
3707
|
return summarize2(
|
|
3516
3708
|
fates.filter((fate) => fate !== void 0),
|
|
@@ -3566,18 +3758,18 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3566
3758
|
}
|
|
3567
3759
|
}
|
|
3568
3760
|
];
|
|
3569
|
-
const known = piiRedactionNow(this.redactPii, this.remotePiiConfig, this.baseUrl, this.writeKey);
|
|
3761
|
+
const known = piiRedactionNow(this.redactPii, this.remotePiiConfig, this.baseUrl, this.writeKey.lookupKey);
|
|
3570
3762
|
if (known !== void 0) {
|
|
3571
3763
|
const body = items.map((item) => this.outgoing("signal", item, known));
|
|
3572
|
-
if (!this.writeKey) return;
|
|
3764
|
+
if (!this.writeKey.configured) return;
|
|
3573
3765
|
await this.sendDirect("signal", `${this.baseUrl}signals/track`, body);
|
|
3574
3766
|
return;
|
|
3575
3767
|
}
|
|
3576
|
-
const
|
|
3768
|
+
const snapshot2 = items.map(snapshotPayload);
|
|
3577
3769
|
await this.tracked(async () => {
|
|
3578
3770
|
const redact = await this.shouldRedactPii();
|
|
3579
|
-
const body =
|
|
3580
|
-
if (!this.writeKey) return;
|
|
3771
|
+
const body = snapshot2.map((item) => this.outgoing("signal", item, redact));
|
|
3772
|
+
if (!this.writeKey.configured) return;
|
|
3581
3773
|
await this.sendDirect("signal", `${this.baseUrl}signals/track`, body, void 0, false);
|
|
3582
3774
|
});
|
|
3583
3775
|
}
|
|
@@ -3601,33 +3793,35 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3601
3793
|
traits: (_a5 = user.traits) != null ? _a5 : {}
|
|
3602
3794
|
};
|
|
3603
3795
|
});
|
|
3604
|
-
if (!this.writeKey) return;
|
|
3796
|
+
if (!this.writeKey.configured) return;
|
|
3605
3797
|
if (rows.length === 0) return;
|
|
3606
|
-
const known = piiRedactionNow(this.redactPii, this.remotePiiConfig, this.baseUrl, this.writeKey);
|
|
3798
|
+
const known = piiRedactionNow(this.redactPii, this.remotePiiConfig, this.baseUrl, this.writeKey.lookupKey);
|
|
3607
3799
|
if (known !== void 0) {
|
|
3608
3800
|
const body = rows.map((user) => this.outgoing("identify", user, known));
|
|
3609
3801
|
await this.sendDirect("identify", `${this.baseUrl}users/identify`, body);
|
|
3610
3802
|
return;
|
|
3611
3803
|
}
|
|
3612
|
-
const
|
|
3804
|
+
const snapshot2 = rows.map(snapshotPayload);
|
|
3613
3805
|
await this.tracked(async () => {
|
|
3614
3806
|
const redact = await this.shouldRedactPii();
|
|
3615
|
-
const body =
|
|
3807
|
+
const body = snapshot2.map((user) => this.outgoing("identify", user, redact));
|
|
3616
3808
|
await this.sendDirect("identify", `${this.baseUrl}users/identify`, body, void 0, false);
|
|
3617
3809
|
});
|
|
3618
3810
|
}
|
|
3619
3811
|
/**
|
|
3620
3812
|
* Send a signal or identify body. Tracked so `flush()` waits for it, unless
|
|
3621
3813
|
* the caller already tracks it (`track: false`). A send a flush deadline
|
|
3622
|
-
* deferred is kept and retried later (outside shutdown).
|
|
3814
|
+
* deferred is kept and retried later (outside shutdown). `counted`: the
|
|
3815
|
+
* caller counts the returned fate (a flush draining deferred sends).
|
|
3623
3816
|
*/
|
|
3624
|
-
async sendDirect(kind, url2, body, deadlineAt, track = true) {
|
|
3817
|
+
async sendDirect(kind, url2, body, deadlineAt, track = true, counted = false) {
|
|
3625
3818
|
const opts = this.requestOpts(deadlineAt);
|
|
3626
3819
|
if (!opts) {
|
|
3627
3820
|
this.warnShutdownDrop(kind);
|
|
3628
3821
|
return "dropped";
|
|
3629
3822
|
}
|
|
3630
|
-
const
|
|
3823
|
+
const payload = this.writeKey.fn ? snapshotPayload(body) : body;
|
|
3824
|
+
const sending = this.post(url2, payload, opts);
|
|
3631
3825
|
const tracked = sending.then(() => void 0);
|
|
3632
3826
|
if (track) this.inFlight.add(tracked);
|
|
3633
3827
|
let outcome;
|
|
@@ -3639,11 +3833,12 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3639
3833
|
const fate = fateOf(outcome, this.shuttingDown());
|
|
3640
3834
|
if (fate === "queued") {
|
|
3641
3835
|
this.deferSend(
|
|
3642
|
-
(later) => this.sendDirect(kind, url2,
|
|
3836
|
+
(later, laterCounted) => this.sendDirect(kind, url2, payload, later, true, laterCounted),
|
|
3643
3837
|
outcome.status === "deferred" ? outcome.retryAtMs : void 0
|
|
3644
3838
|
);
|
|
3645
3839
|
} else if (fate === "dropped") {
|
|
3646
3840
|
this.warnSendDropped(kind, outcome);
|
|
3841
|
+
if (!counted && outcome.status === "failed" && outcome.reported) this.keyDrops += 1;
|
|
3647
3842
|
}
|
|
3648
3843
|
return fate;
|
|
3649
3844
|
}
|
|
@@ -3669,6 +3864,7 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3669
3864
|
warnSendDropped(what, outcome) {
|
|
3670
3865
|
var _a5, _b;
|
|
3671
3866
|
if (outcome.status === "delivered" || outcome.status === "rejected") return;
|
|
3867
|
+
if (outcome.status === "failed" && outcome.reported) return;
|
|
3672
3868
|
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;
|
|
3673
3869
|
rateLimitedLog(
|
|
3674
3870
|
`${this.prefix}.send_${what}_dropped`,
|
|
@@ -3691,7 +3887,7 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3691
3887
|
this.redactPii,
|
|
3692
3888
|
this.remotePiiConfig,
|
|
3693
3889
|
this.baseUrl,
|
|
3694
|
-
this.writeKey,
|
|
3890
|
+
this.writeKey.lookupKey,
|
|
3695
3891
|
deadlineAt != null ? deadlineAt : this.shutdownDeadlineAt
|
|
3696
3892
|
);
|
|
3697
3893
|
}
|
|
@@ -3831,17 +4027,17 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3831
4027
|
attachments: accumulated.attachments,
|
|
3832
4028
|
is_pending: isPending
|
|
3833
4029
|
};
|
|
3834
|
-
const known = piiRedactionNow(this.redactPii, this.remotePiiConfig, this.baseUrl, this.writeKey);
|
|
4030
|
+
const known = piiRedactionNow(this.redactPii, this.remotePiiConfig, this.baseUrl, this.writeKey.lookupKey);
|
|
3835
4031
|
if (known !== void 0) {
|
|
3836
4032
|
const payload = this.outgoing("event", unredacted, known);
|
|
3837
4033
|
return this.shipPartial(eventId, accumulated, payload, { eventName, userId, convoId, isPending }, deadlineAt, true);
|
|
3838
4034
|
}
|
|
3839
|
-
const
|
|
4035
|
+
const snapshot2 = snapshotPayload(unredacted);
|
|
3840
4036
|
const running = this.shouldRedactPii(deadlineAt).then(
|
|
3841
4037
|
(redact) => this.shipPartial(
|
|
3842
4038
|
eventId,
|
|
3843
4039
|
accumulated,
|
|
3844
|
-
this.outgoing("event",
|
|
4040
|
+
this.outgoing("event", snapshot2, redact),
|
|
3845
4041
|
{ eventName, userId, convoId, isPending },
|
|
3846
4042
|
deadlineAt,
|
|
3847
4043
|
false
|
|
@@ -3901,11 +4097,12 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3901
4097
|
const mirror = this.localDebuggerUrl ? mirrorPartialEventToLocalDebugger(payload, {
|
|
3902
4098
|
baseUrl: this.localDebuggerUrl,
|
|
3903
4099
|
followRedirects: this.localDebuggerFollowRedirects,
|
|
3904
|
-
|
|
4100
|
+
// A key function's tokens are for ingest; the local mirror needs none.
|
|
4101
|
+
writeKey: this.writeKey.staticKey,
|
|
3905
4102
|
debug: this.debug,
|
|
3906
4103
|
sdkName: this.sdkName
|
|
3907
4104
|
}) : void 0;
|
|
3908
|
-
if (!this.writeKey) {
|
|
4105
|
+
if (!this.writeKey.configured) {
|
|
3909
4106
|
if (!isPending) this.sticky.delete(eventId);
|
|
3910
4107
|
if (mirror) await mirror;
|
|
3911
4108
|
return void 0;
|
|
@@ -3917,7 +4114,7 @@ var init_chunk_5OUEKTIO = __esm({
|
|
|
3917
4114
|
if (mirror) await mirror;
|
|
3918
4115
|
return "dropped";
|
|
3919
4116
|
}
|
|
3920
|
-
const sending =
|
|
4117
|
+
const sending = this.post(url2, payload, opts);
|
|
3921
4118
|
const combined = Promise.all([mirror, sending.then(() => void 0)]).then(() => void 0);
|
|
3922
4119
|
if (track) this.inFlight.add(combined);
|
|
3923
4120
|
let outcome;
|
|
@@ -4095,9 +4292,8 @@ function createAppGitContext2(options, runtime = {}) {
|
|
|
4095
4292
|
return new AppGitContext(options, { ...runtime, resolveLocal });
|
|
4096
4293
|
}
|
|
4097
4294
|
function hasDestination(options) {
|
|
4098
|
-
var _a5;
|
|
4099
4295
|
if (options.enabled === false) return false;
|
|
4100
|
-
return
|
|
4296
|
+
return hasWriteKey(options.writeKey) || Boolean(resolveLocalDebuggerBaseUrl(options.localDebuggerUrl));
|
|
4101
4297
|
}
|
|
4102
4298
|
function findOtelContextManager() {
|
|
4103
4299
|
var _a5;
|
|
@@ -4124,8 +4320,8 @@ var import_async_hooks, import_child_process, import_path, resolveLocal, EventSh
|
|
|
4124
4320
|
var init_index_node = __esm({
|
|
4125
4321
|
"../core/dist/index.node.js"() {
|
|
4126
4322
|
"use strict";
|
|
4127
|
-
|
|
4128
|
-
|
|
4323
|
+
init_chunk_OPHDM4MC();
|
|
4324
|
+
init_chunk_OPHDM4MC();
|
|
4129
4325
|
init_chunk_ZCB62SIO();
|
|
4130
4326
|
import_async_hooks = require("async_hooks");
|
|
4131
4327
|
import_child_process = require("child_process");
|
|
@@ -5807,7 +6003,7 @@ var init_portable = __esm({
|
|
|
5807
6003
|
var import_node_path = require("path");
|
|
5808
6004
|
var import_node_url = require("url");
|
|
5809
6005
|
var import_node_util = require("util");
|
|
5810
|
-
var
|
|
6006
|
+
var import_v412 = require("zod/v4");
|
|
5811
6007
|
|
|
5812
6008
|
// src/lib/inject-als.ts
|
|
5813
6009
|
var import_node_async_hooks = require("async_hooks");
|
|
@@ -25734,7 +25930,7 @@ var SignalEventSchema = external_exports.object({
|
|
|
25734
25930
|
// package.json
|
|
25735
25931
|
var package_default = {
|
|
25736
25932
|
name: "raindrop-ai",
|
|
25737
|
-
version: "3.0.
|
|
25933
|
+
version: "3.0.1",
|
|
25738
25934
|
main: "dist/index.js",
|
|
25739
25935
|
module: "dist/index.mjs",
|
|
25740
25936
|
types: "dist/index.d.ts",
|
|
@@ -30349,13 +30545,13 @@ var WireEvalRowTracePairReadSchema = import_v46.z.discriminatedUnion("state", [
|
|
|
30349
30545
|
var replayGitSnapshots = /* @__PURE__ */ new WeakMap();
|
|
30350
30546
|
var replayPropertySnapshots = /* @__PURE__ */ new WeakMap();
|
|
30351
30547
|
var replayOverrideSnapshots = /* @__PURE__ */ new WeakSet();
|
|
30352
|
-
function withReplayGit(
|
|
30548
|
+
function withReplayGit(snapshot2, run) {
|
|
30353
30549
|
var _a5;
|
|
30354
30550
|
return withRoutingContext(
|
|
30355
30551
|
{
|
|
30356
30552
|
...currentRoutingBinding(),
|
|
30357
|
-
appGit: (_a5 = replayPropertySnapshots.get(
|
|
30358
|
-
appGitSource: replayOverrideSnapshots.has(
|
|
30553
|
+
appGit: (_a5 = replayPropertySnapshots.get(snapshot2)) != null ? _a5 : snapshot2,
|
|
30554
|
+
appGitSource: replayOverrideSnapshots.has(snapshot2) ? "replay-override" : void 0
|
|
30359
30555
|
},
|
|
30360
30556
|
run
|
|
30361
30557
|
);
|
|
@@ -30365,24 +30561,24 @@ function captureReplayGit(client, options) {
|
|
|
30365
30561
|
try {
|
|
30366
30562
|
if (options === void 0 && client.getAppGitSnapshot) {
|
|
30367
30563
|
const properties = Object.freeze({ ...client.getAppGitSnapshot() });
|
|
30368
|
-
const
|
|
30369
|
-
replayPropertySnapshots.set(
|
|
30370
|
-
return
|
|
30564
|
+
const snapshot3 = Object.freeze({ ...(_b = (_a5 = client.getReplayAppGitSnapshot) == null ? void 0 : _a5.call(client)) != null ? _b : properties });
|
|
30565
|
+
replayPropertySnapshots.set(snapshot3, properties);
|
|
30566
|
+
return snapshot3;
|
|
30371
30567
|
}
|
|
30372
30568
|
const resolver = createAppGitContext2(options, { allowLocalGit: false });
|
|
30373
|
-
const
|
|
30569
|
+
const snapshot2 = resolver.snapshot();
|
|
30374
30570
|
resolver.dispose();
|
|
30375
|
-
if (options && typeof options === "object") replayOverrideSnapshots.add(
|
|
30376
|
-
return
|
|
30571
|
+
if (options && typeof options === "object") replayOverrideSnapshots.add(snapshot2);
|
|
30572
|
+
return snapshot2;
|
|
30377
30573
|
} catch (e) {
|
|
30378
30574
|
return {};
|
|
30379
30575
|
}
|
|
30380
30576
|
}
|
|
30381
|
-
function replayGitFields(
|
|
30382
|
-
const rawSha =
|
|
30577
|
+
function replayGitFields(snapshot2) {
|
|
30578
|
+
const rawSha = snapshot2[APP_COMMIT_SHA];
|
|
30383
30579
|
const sha = typeof rawSha === "string" && validAppCommitSha(rawSha) ? rawSha.trim() : void 0;
|
|
30384
|
-
const dirty =
|
|
30385
|
-
const rawBranch =
|
|
30580
|
+
const dirty = snapshot2[APP_COMMIT_DIRTY];
|
|
30581
|
+
const rawBranch = snapshot2[APP_BRANCH];
|
|
30386
30582
|
const branch = typeof rawBranch === "string" && rawBranch.length <= 1024 ? rawBranch.trim() : "";
|
|
30387
30583
|
return {
|
|
30388
30584
|
commit_sha: sha != null ? sha : null,
|
|
@@ -30658,7 +30854,7 @@ async function runReplayRows(client, handle, options) {
|
|
|
30658
30854
|
);
|
|
30659
30855
|
results.set(row.id, { value: result });
|
|
30660
30856
|
} catch (cause) {
|
|
30661
|
-
const error62 =
|
|
30857
|
+
const error62 = describeError2(cause);
|
|
30662
30858
|
await report({
|
|
30663
30859
|
type: "row_missing",
|
|
30664
30860
|
row_id: row.id,
|
|
@@ -30956,7 +31152,7 @@ var LocalEvalReplaySessionImpl = class {
|
|
|
30956
31152
|
)
|
|
30957
31153
|
);
|
|
30958
31154
|
} catch (cause) {
|
|
30959
|
-
const error62 =
|
|
31155
|
+
const error62 = describeError2(cause);
|
|
30960
31156
|
await reportReplay(this.client, this.queryUrl, this.replayId, {
|
|
30961
31157
|
type: "row_missing",
|
|
30962
31158
|
row_id: row.id,
|
|
@@ -31007,7 +31203,7 @@ var LocalEvalReplaySessionImpl = class {
|
|
|
31007
31203
|
throw new Error(`Raindrop replay ${this.replayId} omitted trace pair ${row.id}`);
|
|
31008
31204
|
pair = captured;
|
|
31009
31205
|
} catch (cause) {
|
|
31010
|
-
const error62 =
|
|
31206
|
+
const error62 = describeError2(cause);
|
|
31011
31207
|
await reportReplay(this.client, this.queryUrl, this.replayId, {
|
|
31012
31208
|
type: "row_missing",
|
|
31013
31209
|
row_id: row.id,
|
|
@@ -31060,7 +31256,7 @@ var LocalEvalReplaySessionImpl = class {
|
|
|
31060
31256
|
});
|
|
31061
31257
|
} catch (cause) {
|
|
31062
31258
|
throw new Error(
|
|
31063
|
-
`Raindrop local evaluator ${parent.evaluator.slug} could not record attempt at ${parent.url}: ${
|
|
31259
|
+
`Raindrop local evaluator ${parent.evaluator.slug} could not record attempt at ${parent.url}: ${describeError2(cause)}`
|
|
31064
31260
|
);
|
|
31065
31261
|
}
|
|
31066
31262
|
const data = receipt.data;
|
|
@@ -31663,8 +31859,8 @@ async function waitForFailedTraceAssociation(input2) {
|
|
|
31663
31859
|
}
|
|
31664
31860
|
}
|
|
31665
31861
|
function failedTraceRetentionError(taskCause, retentionCause, rowId) {
|
|
31666
|
-
const taskError = taskCause instanceof Error ? taskCause : new Error(
|
|
31667
|
-
const retentionError = retentionCause instanceof Error ? retentionCause : new Error(
|
|
31862
|
+
const taskError = taskCause instanceof Error ? taskCause : new Error(describeError2(taskCause));
|
|
31863
|
+
const retentionError = retentionCause instanceof Error ? retentionCause : new Error(describeError2(retentionCause));
|
|
31668
31864
|
return new AggregateError(
|
|
31669
31865
|
[taskError, retentionError],
|
|
31670
31866
|
`Raindrop replay task ${rowId} failed and its trace could not be retained`,
|
|
@@ -31737,7 +31933,7 @@ function normalizeEvaluators(evaluators) {
|
|
|
31737
31933
|
return normalized;
|
|
31738
31934
|
}
|
|
31739
31935
|
function localEvaluatorError(cause) {
|
|
31740
|
-
const message =
|
|
31936
|
+
const message = describeError2(cause).trim();
|
|
31741
31937
|
return (message === "" ? "Local evaluator failed" : message).slice(0, 600);
|
|
31742
31938
|
}
|
|
31743
31939
|
function validateWait(name, value, allowZero) {
|
|
@@ -31746,7 +31942,7 @@ function validateWait(name, value, allowZero) {
|
|
|
31746
31942
|
throw new Error(`Raindrop replay ${name} must be ${allowZero ? "non-negative" : "positive"}`);
|
|
31747
31943
|
}
|
|
31748
31944
|
}
|
|
31749
|
-
function
|
|
31945
|
+
function describeError2(cause) {
|
|
31750
31946
|
if (cause instanceof Error) {
|
|
31751
31947
|
return cause.message.trim() === "" ? cause.name : `${cause.name}: ${cause.message}`;
|
|
31752
31948
|
}
|
|
@@ -33602,8 +33798,8 @@ var Raindrop = class {
|
|
|
33602
33798
|
const deadlineAt = (_a5 = this.shutdownDeadlineAt) != null ? _a5 : Date.now();
|
|
33603
33799
|
const remainingMs = () => Math.max(0, deadlineAt - Date.now());
|
|
33604
33800
|
const partialsShutdown = this.eventShipper.shutdown();
|
|
33605
|
-
const
|
|
33606
|
-
let tracingResult =
|
|
33801
|
+
const TIMED_OUT2 = { ...DELIVERED, delivered: false, timedOut: true, inFlight: 1 };
|
|
33802
|
+
let tracingResult = TIMED_OUT2;
|
|
33607
33803
|
const tracing2 = raceWithTimeout(
|
|
33608
33804
|
this._tracing.close().then((r) => {
|
|
33609
33805
|
tracingResult = r;
|
|
@@ -33611,7 +33807,7 @@ var Raindrop = class {
|
|
|
33611
33807
|
remainingMs()
|
|
33612
33808
|
).then((settled) => {
|
|
33613
33809
|
if (!settled) {
|
|
33614
|
-
tracingResult =
|
|
33810
|
+
tracingResult = TIMED_OUT2;
|
|
33615
33811
|
this.warnShutdownDrop("in-flight trace flush");
|
|
33616
33812
|
}
|
|
33617
33813
|
});
|
|
@@ -33634,7 +33830,7 @@ var Raindrop = class {
|
|
|
33634
33830
|
if (stillRunning > 0) this.warnShutdownDrop(`${stillRunning} in-flight batch(es)`);
|
|
33635
33831
|
return summarize2(fates, stillRunning, !settled);
|
|
33636
33832
|
})();
|
|
33637
|
-
let partialsResult =
|
|
33833
|
+
let partialsResult = TIMED_OUT2;
|
|
33638
33834
|
const partials = raceWithTimeout(
|
|
33639
33835
|
partialsShutdown.then((r) => {
|
|
33640
33836
|
partialsResult = r;
|
|
@@ -33642,7 +33838,7 @@ var Raindrop = class {
|
|
|
33642
33838
|
remainingMs()
|
|
33643
33839
|
).then((settled) => {
|
|
33644
33840
|
if (!settled) {
|
|
33645
|
-
partialsResult =
|
|
33841
|
+
partialsResult = TIMED_OUT2;
|
|
33646
33842
|
this.warnShutdownDrop("partial event request(s)");
|
|
33647
33843
|
}
|
|
33648
33844
|
});
|
|
@@ -33657,8 +33853,109 @@ var index_default = Raindrop;
|
|
|
33657
33853
|
|
|
33658
33854
|
// src/evals/cli.ts
|
|
33659
33855
|
init_definition();
|
|
33660
|
-
|
|
33661
|
-
|
|
33856
|
+
|
|
33857
|
+
// src/evals/endpoint.ts
|
|
33858
|
+
init_index_node();
|
|
33859
|
+
var import_v411 = require("zod/v4");
|
|
33860
|
+
init_endpoint();
|
|
33861
|
+
var SavedEvalEndpointSchema = import_v411.z.object({
|
|
33862
|
+
id: import_v411.z.string(),
|
|
33863
|
+
name: import_v411.z.string(),
|
|
33864
|
+
url: import_v411.z.string(),
|
|
33865
|
+
hasCredentials: import_v411.z.boolean(),
|
|
33866
|
+
agents: import_v411.z.array(
|
|
33867
|
+
import_v411.z.object({ slug: import_v411.z.string(), name: import_v411.z.string(), description: import_v411.z.string().nullable() })
|
|
33868
|
+
),
|
|
33869
|
+
discoveryError: import_v411.z.string().nullable()
|
|
33870
|
+
});
|
|
33871
|
+
var ENDPOINT_VARIABLE_PREFIX = "EVAL_ENDPOINT_";
|
|
33872
|
+
function evalEndpointQueryUrl(value = DEFAULT_QUERY_URL2) {
|
|
33873
|
+
const url2 = credentialEndpoint(value);
|
|
33874
|
+
const loopback = ["localhost", "127.0.0.1", "[::1]"].includes(url2.hostname);
|
|
33875
|
+
if (!loopback && !(url2.protocol === "https:" && url2.hostname.endsWith(".raindrop.ai")))
|
|
33876
|
+
throw new Error(
|
|
33877
|
+
"endpoint save only sends the auth header to https://*.raindrop.ai or a loopback Query API"
|
|
33878
|
+
);
|
|
33879
|
+
return url2;
|
|
33880
|
+
}
|
|
33881
|
+
var bareToken = (value) => value.trim().replace(/^Bearer\s+/i, "").trim();
|
|
33882
|
+
function evalEndpointHeaderFromEnv(flags, env = process.env) {
|
|
33883
|
+
var _a5;
|
|
33884
|
+
const { bearerEnv, headerName, headerValueEnv } = flags;
|
|
33885
|
+
if (bearerEnv !== void 0 && (headerName !== void 0 || headerValueEnv !== void 0))
|
|
33886
|
+
throw new Error("Use --bearer-env, or --header-name with --header-value-env, not both");
|
|
33887
|
+
if (headerName === void 0 !== (headerValueEnv === void 0))
|
|
33888
|
+
throw new Error("--header-name and --header-value-env go together");
|
|
33889
|
+
const variable = bearerEnv != null ? bearerEnv : headerValueEnv;
|
|
33890
|
+
if (variable === void 0) return void 0;
|
|
33891
|
+
if (!variable.startsWith(ENDPOINT_VARIABLE_PREFIX))
|
|
33892
|
+
throw new Error(
|
|
33893
|
+
`--bearer-env and --header-value-env only read variables named ${ENDPOINT_VARIABLE_PREFIX}*, such as EVAL_ENDPOINT_TOKEN`
|
|
33894
|
+
);
|
|
33895
|
+
const value = env[variable];
|
|
33896
|
+
if (value === void 0 || value.trim() === "")
|
|
33897
|
+
throw new Error(`Environment variable ${variable} is not set`);
|
|
33898
|
+
if (bareToken(value) === bareToken((_a5 = env.RAINDROP_QUERY_API_KEY) != null ? _a5 : ""))
|
|
33899
|
+
throw new Error(
|
|
33900
|
+
`Environment variable ${variable} holds the Raindrop Query key; use the endpoint's own token`
|
|
33901
|
+
);
|
|
33902
|
+
return bearerEnv !== void 0 ? { Authorization: `Bearer ${value}` } : { [headerName != null ? headerName : "Authorization"]: value };
|
|
33903
|
+
}
|
|
33904
|
+
async function saveEvalEndpoint(client, endpoint, options = {}) {
|
|
33905
|
+
var _a5, _b;
|
|
33906
|
+
const apiKey = (_a5 = client.connection.apiKey) == null ? void 0 : _a5.trim();
|
|
33907
|
+
if (!apiKey) throw new Error("Raindrop evals require a Query SDK API key (apiKey)");
|
|
33908
|
+
const base = evalEndpointQueryUrl(options.queryUrl).href.replace(/\/+$/, "");
|
|
33909
|
+
const headers = {
|
|
33910
|
+
Authorization: `Bearer ${apiKey}`,
|
|
33911
|
+
"Content-Type": "application/json"
|
|
33912
|
+
};
|
|
33913
|
+
if (client.connection.projectId !== void 0)
|
|
33914
|
+
headers["X-Raindrop-Project-Id"] = client.connection.projectId;
|
|
33915
|
+
const secrets = [
|
|
33916
|
+
apiKey,
|
|
33917
|
+
...Object.values((_b = endpoint.headers) != null ? _b : {}).flatMap((value) => [
|
|
33918
|
+
value,
|
|
33919
|
+
value.trim(),
|
|
33920
|
+
value.replace(/^Bearer\s+/i, "").trim()
|
|
33921
|
+
])
|
|
33922
|
+
].filter((secret) => secret !== "").flatMap((secret) => [secret, JSON.stringify(secret).slice(1, -1)]);
|
|
33923
|
+
const redact = (text) => secrets.reduce((redacted, secret) => redacted.replaceAll(secret, "[redacted]"), text);
|
|
33924
|
+
const controller = new AbortController();
|
|
33925
|
+
const timeout = setTimeout(() => controller.abort(), 3e4);
|
|
33926
|
+
try {
|
|
33927
|
+
const response = await runWithTracingSuppressed(
|
|
33928
|
+
() => fetch(`${base}/v1/eval-endpoints`, {
|
|
33929
|
+
method: "PUT",
|
|
33930
|
+
headers,
|
|
33931
|
+
body: JSON.stringify(endpoint),
|
|
33932
|
+
redirect: "error",
|
|
33933
|
+
signal: controller.signal
|
|
33934
|
+
})
|
|
33935
|
+
);
|
|
33936
|
+
const body = await response.text();
|
|
33937
|
+
if (!response.ok)
|
|
33938
|
+
throw new Error(`Raindrop PUT /v1/eval-endpoints: ${response.status} ${redact(body)}`);
|
|
33939
|
+
const saved = SavedEvalEndpointSchema.parse(JSON.parse(body));
|
|
33940
|
+
return {
|
|
33941
|
+
...saved,
|
|
33942
|
+
agents: saved.agents.map((agent) => ({
|
|
33943
|
+
slug: redact(agent.slug),
|
|
33944
|
+
name: redact(agent.name),
|
|
33945
|
+
description: agent.description === null ? null : redact(agent.description)
|
|
33946
|
+
})),
|
|
33947
|
+
discoveryError: saved.discoveryError === null ? null : redact(saved.discoveryError)
|
|
33948
|
+
};
|
|
33949
|
+
} catch (error62) {
|
|
33950
|
+
throw new Error(redact(error62 instanceof Error ? error62.message : String(error62)));
|
|
33951
|
+
} finally {
|
|
33952
|
+
clearTimeout(timeout);
|
|
33953
|
+
}
|
|
33954
|
+
}
|
|
33955
|
+
|
|
33956
|
+
// src/evals/cli.ts
|
|
33957
|
+
var SuiteModuleSchema = import_v412.z.object({
|
|
33958
|
+
default: import_v412.z.custom(isEvalSuiteDefinition)
|
|
33662
33959
|
});
|
|
33663
33960
|
async function main() {
|
|
33664
33961
|
var _a5, _b;
|
|
@@ -33670,18 +33967,29 @@ async function main() {
|
|
|
33670
33967
|
"replay-ingest-url": { type: "string" },
|
|
33671
33968
|
"run-id": { type: "string" },
|
|
33672
33969
|
repetitions: { type: "string" },
|
|
33970
|
+
id: { type: "string" },
|
|
33971
|
+
name: { type: "string" },
|
|
33972
|
+
url: { type: "string" },
|
|
33973
|
+
"bearer-env": { type: "string" },
|
|
33974
|
+
"header-name": { type: "string" },
|
|
33975
|
+
"header-value-env": { type: "string" },
|
|
33673
33976
|
json: { type: "boolean" },
|
|
33674
33977
|
help: { type: "boolean" }
|
|
33675
33978
|
}
|
|
33676
33979
|
});
|
|
33677
|
-
const [command, file2] = positionals;
|
|
33980
|
+
const [command, file2, extra] = positionals;
|
|
33678
33981
|
if (values.help || !command) {
|
|
33679
33982
|
process.stdout.write(
|
|
33680
33983
|
[
|
|
33681
33984
|
"raindrop-evals publish <suite.mjs> [--project slug] [--json]",
|
|
33682
33985
|
"raindrop-evals run <suite.mjs> [--run-id queued-run-id] [--repetitions n] [--project slug] [--json]",
|
|
33683
33986
|
"raindrop-evals read <evaluator-slug> [--json]",
|
|
33987
|
+
"raindrop-evals endpoint save --name <name> --url <https url> [--bearer-env EVAL_ENDPOINT_<NAME> | --header-name <name> --header-value-env EVAL_ENDPOINT_<NAME>] [--id endpoint-id]",
|
|
33684
33988
|
"",
|
|
33989
|
+
"endpoint save stores an agent endpoint and lists its agents. --bearer-env names the environment",
|
|
33990
|
+
"variable holding the endpoint's token (sent as Authorization: Bearer <value>); the value is read",
|
|
33991
|
+
"from the environment and never printed. Only variables named EVAL_ENDPOINT_* are read.",
|
|
33992
|
+
"Without a header flag, saved headers are kept.",
|
|
33685
33993
|
"Publish resolves the dataset version and pins existing evaluators without running them.",
|
|
33686
33994
|
"The module must default-export defineEvalSuite(...) with a dataset UUID from list_datasets.",
|
|
33687
33995
|
"Create datasets with the Raindrop app or MCP upload_dataset, and hosted evaluators in Raindrop.",
|
|
@@ -33696,10 +34004,14 @@ async function main() {
|
|
|
33696
34004
|
);
|
|
33697
34005
|
return;
|
|
33698
34006
|
}
|
|
33699
|
-
if (!file2 || !["publish", "run", "read"].includes(command))
|
|
34007
|
+
if (!file2 || !["publish", "run", "read", "endpoint"].includes(command))
|
|
33700
34008
|
throw new Error("Invalid command. Use --help.");
|
|
33701
34009
|
const apiKey = process.env.RAINDROP_QUERY_API_KEY;
|
|
33702
34010
|
if (!apiKey) throw new Error("Set RAINDROP_QUERY_API_KEY to a Query SDK organization key");
|
|
34011
|
+
if (command === "endpoint" && extra !== void 0)
|
|
34012
|
+
throw new Error("endpoint save takes flags only; pass the endpoint ID as --id");
|
|
34013
|
+
if (command === "endpoint") evalEndpointQueryUrl(values["query-url"]);
|
|
34014
|
+
const endpoint = command === "endpoint" ? endpointFromFlags(file2, values) : void 0;
|
|
33703
34015
|
const client = new index_default({
|
|
33704
34016
|
apiKey,
|
|
33705
34017
|
projectId: (_b = (_a5 = values.project) != null ? _a5 : process.env.RAINDROP_PROJECT_ID) != null ? _b : "default",
|
|
@@ -33707,7 +34019,9 @@ async function main() {
|
|
|
33707
34019
|
});
|
|
33708
34020
|
const options = { queryUrl: values["query-url"] };
|
|
33709
34021
|
try {
|
|
33710
|
-
if (
|
|
34022
|
+
if (endpoint) {
|
|
34023
|
+
print(await saveEvalEndpoint(client, endpoint, options));
|
|
34024
|
+
} else if (command === "read") {
|
|
33711
34025
|
print(await readEvaluator(client, file2, options));
|
|
33712
34026
|
} else {
|
|
33713
34027
|
const module2 = SuiteModuleSchema.parse(await import((0, import_node_url.pathToFileURL)((0, import_node_path.resolve)(file2)).href));
|
|
@@ -33748,6 +34062,20 @@ async function main() {
|
|
|
33748
34062
|
await client.close();
|
|
33749
34063
|
}
|
|
33750
34064
|
}
|
|
34065
|
+
function endpointFromFlags(action, flags) {
|
|
34066
|
+
if (action !== "save") throw new Error("Invalid command. Use --help.");
|
|
34067
|
+
if (!flags.name || !flags.url) throw new Error("endpoint save requires --name and --url");
|
|
34068
|
+
return {
|
|
34069
|
+
id: flags.id,
|
|
34070
|
+
name: flags.name,
|
|
34071
|
+
url: flags.url,
|
|
34072
|
+
headers: evalEndpointHeaderFromEnv({
|
|
34073
|
+
bearerEnv: flags["bearer-env"],
|
|
34074
|
+
headerName: flags["header-name"],
|
|
34075
|
+
headerValueEnv: flags["header-value-env"]
|
|
34076
|
+
})
|
|
34077
|
+
};
|
|
34078
|
+
}
|
|
33751
34079
|
function print(value) {
|
|
33752
34080
|
process.stdout.write(JSON.stringify(value, null, 2) + "\n");
|
|
33753
34081
|
}
|